Madole's blog
Tag – code
30 posts tagged with "code" (See all tags)

HHow to download an image to file on disk when scraping a website

2019-02-07T05:59:56.344Z1 Min Read

Recently I was recovering data from one of my websites that had been unceremoniously taken down while I was on holidays when I got stomped for a little while on how to scrape an image and save it to file using NodeJS. Let’s say you are using…

CCreating a pull request template in Github

2019-01-31T05:46:00.344Z1 Min Read

There comes a time when your team needs to conform on pull requests to provide an adequate amount of information in a common format so that automated tools, QA testers, code reviewers can grok the important information when they need to. Github makes…

HHow to do a github pull request from the command line

2019-01-20T01:19:16.924Z1 Min Read

I spend a lot of time in the command line, especially when dealing with git commands. My usual workflow is to stage the files I've been working on. Then commit those changes using the following command which allows me to add a commit message using…

UUsing Async/Await to batch asynchronous requests

2018-06-24T10:28:07.097Z2 Min Read

Lets say you have written a file uploader app and your users might upload 100s of files at a time. You could just loop the files and send off a request per file. This might overload your server, interrupt downloads or just fail due to hitting a…

MMigrating data from Ghost to GatsbyJS

2018-06-18T10:28:07.097Z3 Min Read

What is Gatsby? 🔥 Blazing-fast static site generator for React It's is perfect for a static blog, it reads markdown and gives you a GraphQL API to query it and a React front end. Coupled with https://www.netlify.com/ , it is a fantastic solution…

BBuilding node-canvas in Amazon Linux AMI for Lambdas

2017-10-08T18:06:13.000Z1 Min Read

Building node-canvas for use inside an AWS Lambda is tricky as it requires some dependencies to be built by node-gyp against the target architecture. If you build these dependencies locally before deploying your lambda, they'll be built on against…

MMocking relative dependencies in Jest with jest.mock()

2016-12-07T15:31:07.000Z1 Min Read

If you're like me and have just entered the world of Jest for testing your React application. You might be familiar with a mocking library called Proxyquire. Proxyquire - "nodejs require in order to allow overriding dependencies during testing." An…

PPutting Yarn Package Manager to the test

2016-11-22T17:26:37.000Z3 Min Read

What is Yarn? FAST, RELIABLE, AND SECURE DEPENDENCY MANAGEMENT. - https://yarnpkg.com/ How does it achieve all of this? It uses caching to speed up installs by only ever downloading them once and parallelizes operations to maximise resource…

MMy favourite VSCode plugins

2016-11-06T14:35:03.000Z9 Min Read

A while ago I published a comprehensive list of my favourite Atom Editor plugins, I've since moved to VSCode for the majority of my development so I thought I'd gather together a similar list for it. Auto-close-tag Automatically add HTML/XML close…

WWebpack-dev-server: Where does your CSS go?

2016-09-14T16:29:10.000Z1 Min Read

You might have noticed when using webpack-dev-server that the CSS seems to appear on the page as if by magic. If you have a look at the build manifest , you'll see your file listed but no sign of the CSS bundle. This may lead you to think that…

SServerside CSS Modules with babel

2016-08-21T21:09:38.000Z2 Min Read

I had a requirement to use CSS modules with serverside rendering, it took me a while to figure out so I thought I'd write the process down. In order to set css modules, we need babel to turn our generic classnames ( ) into localised class names like…

bbabel-loader's hidden feature - babelrc:false

2016-08-21T19:59:31.000Z2 Min Read

I've spent 3 days configuring Webpack and babel to deal with CSS Modules while doing server-side rendering. I've just discovered an undocumented setting in Webpack's babel-loader that solves the mystery of disappearing css. On the server, I've got a…

WWhat actually gets included in your npm module?

2016-08-01T01:23:34.000Z2 Min Read

Npm automatically includes some files. From the documentation ( https://docs.npmjs.com/files/package.json#files ) we can see the following files are always included regardless of settings: package.json README (and it's variants) CHANGELOG (and it's…

NNPM uses your .gitignore file

2016-07-03T02:59:42.000Z1 Min Read

The Problem I recently published a package to npm and got an issue raised on Github to tell me that the build artifact hadn't been published. The helpful person who raised the issue informed me that in the absence of an file, npm will use your…

UUsing console.time to profile performance in your node application

2016-06-09T15:27:36.000Z3 Min Read

I was writing an express application, when I started to notice one of the routes was taking quite a while to respond to a request. The route was doing some heavy lifting shaping data from an API . I needed to figure out where the bottleneck was and…

bbabel-plugin-transform-async-to-module-method gotcha

2016-05-08T02:41:11.000Z2 Min Read

We have been using ES7 Async/Await with and bluebird co-routines for about a month now. This has been working great for us in most cases. Although we started noticing an issue when we've been using classes and extending upon them. The transpilation…

AAsset hashing with webpack

2016-04-15T14:32:57.000Z5 Min Read

Why would you hash your assets? If you're creating a website that has a caching layer sitting in front of it, you're going to need a way to bust the cache every time you make a release so your cache doesn't continue to serve up your old files. What…

UUsing webpack to set up polyfills in your site

2016-04-03T21:40:03.000Z2 Min Read

Webpack's Provide Plugin allows you to set up variables that get injected into your code when they are used in your codebase. This means that if I want to polyfill the new ES6 native promise for older browsers, I can do it at build time. Two…

WWriting a Gulpfile in ES6

2016-03-30T15:36:06.000Z1 Min Read

So you've written your app in ES6 and you're using babel to transpile to ES5. But your build process uses Gulp and it requires you to write your Gulpfile in ES5 meaning you can't take advantage of all the latest JavaScript features you're using…

AASYNC/AWAIT ES7

2016-03-12T21:56:32.000Z4 Min Read

This feature has been available in other languages like C# and Visual Basic for a while. It allows you to write your function declaration prefixed with and then inside your function, use the keyword to pause your function in a non-blocking way…

MMy favourite Atom packages of 2015

2016-01-02T06:29:19.000Z6 Min Read

atom-beautify Beautify HTML (including Handlebars), CSS (including Sass and Less), JavaScript, and much more in Atom atom-jade Jade language support in Atom autocomplete-modules Autocomplete for require/import statements autocomplete-paths Adds path…

SSemver - the sane way

2015-11-07T13:05:03.000Z4 Min Read

Semantic Versioning 2.0.0 - http://semver.org Summary Given a version number MAJOR.MINOR.PATCH, increment the: MAJOR version when you make incompatible API changes, MINOR version when you add functionality in a backwards-compatible manner, and…

SSetting up webpack dev middleware in express

2015-11-07T13:04:33.000Z3 Min Read

[[[ THIS BLOG POST IS 2 YEARS OLD, CHECK OUT WEBPACK2 INSTEAD ]]] What is webpack dev server? Webpack dev server is a live reloading server for webpack. What is webpack dev middleware? It's a simple wrapper middleware for webpack. It serves the…

SSelenium ActionSequence

2015-11-07T12:34:54.000Z2 Min Read

Selenium test Should do something when an outer div, with an inner div placed in the middle in front, is clicked. How to usually do this? Say our test is trying to test that a video plays when an image is clicked. But our image has a play button…

JJsFiddle - Firebug lite

2015-11-07T12:31:46.000Z1 Min Read

I recently discovered a cool feature in JSFiddle which changed the way I use it. Until now, I've been hopping on to JSFiddle to test out little bits of code and logging out to the console. If you're like me, you'll be familiar with having Chrome Dev…

SSome useful everyday linux commands

2015-11-07T12:22:16.000Z2 Min Read

I decided to write down a list of every day commands that I use in the the Bash command line in Linux. This is by no means a definitive list and it will grow as I remember or come across commands that make my life easier ls list information about…

CCreating SVG animation with WalkwayJS

2015-11-01T01:01:07.000Z2 Min Read

A few days ago this link ( http://www.connoratherton.com/walkway ) popped up on Reddit’s /r/javascript . I liked how it looked so I set about having a go. Turns out Connor Atherton’s library has made this super easy so I thought I’d document the…

JJavascript Interview Questions

2015-11-01T00:29:11.000Z11 Min Read

I was asked recently by a friend of mine to come up with a list of interview questions that you can get asked during a Javascript interview. I looked by to my last interview and came up with a few topics for him to brush up on. I thought I'd write…

JJavascript Toolbox

2015-11-01T00:27:54.000Z7 Min Read

I write Javascript most days and have done so for a few years now. I still find new tools, websites, frameworks and ways to do things. I thought I'd write them down and get the list online as it may help other people discover some useful tools of the…