How to fix slow gem installs

If you’ve ever run gem install, you know how long it can take to complete. Trust me, you’re not alone: plenty of examples showcase similar frustrations in dealing with slow gem install.

Most larger Ruby projects comes with extensive documentation (awesome! 👍), unfortunately the process of turning RDoc into HTML and ri can be quite time-consuming - especially on larger projects or slower machines.

Fortunately, it’s possible to turn off ri and rdoc processing on gem install by executing the command with flags --no-ri and --no-rdoc:

$ gem install rails --no-rdoc --no-ri

Now keep in mind that RDoc and ri is actually pretty cool and if you use them often, instead of online documentation, then you might want to skip this.

If you want this as your default behavior add this to your ~/.gemrc file:

gem: --no-ri --no-rdoc

Another option is to create a Shell alias for gem install that in addition also prefixes with sudo to avoid those pesky “You don’t have write permissions …“:

# Alias
$ alias gemi=”sudo gem install –no-ri –no-rdoc”

# Usage
$ gemi rails

Using WebPack with shims and polyfills

I’ve been getting into webpack a lot lately, partly because of the amazing experience of using React with a hot reloader like react-hot-loader.

If you haven’t used webpack in a project yet, go play around with it right now! For a quick React hot reloader boilerplate checkout react-hot-boilerplate or react-webpack-boilerplate.

In a recent project I wanted to use the new fetch API, if you are not familiar with the background story go read Jack Archibald’s That’s so fetch! post.

The overall browser support is starting to pick up, with Chrome 42(beta), Firefox 39 and Opera 29 all shipping with it by default. Internet Explorer is currently listing it as “under consideration” on their platform status page.

Luckily for us GitHub has been maintaining a great polyfill github/fetch since October 2014, which means we can already use this in production. Using the polyfill without a bundler like webpack would mean adding a <script> tag to your template.

I couldn’t figure out the “webpack way” of including the polyfill in my bundle, and after reading the webpack wiki page on shimming modules I still couldn’t quite figure out the syntax.

That was until I stumbled upon this gist by Luís Couto, showing exactly how to use the fetch polyfill with webpack.

The important part of the webpack config:

plugins: [
  new webpack.ProvidePlugin({
    'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'

It uses the imports-loader and exports-loader for webpack, so make sure you have them installed:

$ npm i imports-loader exports-loader -S

For more information about shimming modules in webpack, checkout the documentation.

Update: Corrected small typo spotted by @stkhlm, thanks!

Release: grunt-xcode v2

complete rewrite + new features: grunt-xcode

I started building the initial version of grunt-xcode around November last year. The primary reason for the project was that I was getting tired of manually having to do iOS builds for our clients - it needed to be a part of our Grunt build task.

I stumbled upon shenzhen which actually worked fairly well for me as a command-line tool, so I thought “hey let me just wrap this in JS”. That was probably not the wisest decision, but grunt-xcode v1 ended up sort of working for us (not so much for everybody else).

To be honest the code was quite ugly and I didn’t like the dependency on a RubyGem - it just didn’t feel right. I also started getting some bug reports on GitHub and email.


The primary goal of the rewrite was to remove the dependency on shenzhen and use the built-in xcodebuild tool instead.


  • remove dependency on shenzhen
  • added support for all parameters available in xcodebuild
  • show progress indicators for archiving and export tasks
  • show stdout if Grunt is run with the --verbose flag

grunt-xcode build


I’m actively using grunt-xcode for a client project and it’s been working out great for me.

Installing grunt-xcode is just as simple as any other npm module:

$ npm install grunt-xcode --save-dev

    xcode: {
        options: {
          project: '/path/to/my/awesome/App/App.xcodeproj',
          scheme: 'Release'

grunt.registerTask('default', ['xcode']);

For a list of all options please refer to the README.

Hopefully the codebase is a lot more readable now, that was at least the goal.

Please do let me know if you run into any issues with grunt-xcode, I’m sure there are multiple cases I haven’t tested properly.

Download YouTube videos and songs

youtube-dl allows you to download any video or song from YouTube, Vimeo, SoundCloud and 410 more sites.

youtube-dl have quickly become one of my favorite command line tools. Say goodbye to faulty browser extensions and sketchy websites, and say hello to downloading everything from any of the major video/audio sites right from your command line.1


You can download the binary on the official download page - I always choose the easier Homebrew installation:

# Homebrew installation (preferred)
$ brew install youtube-dl

# UNIX installation with curl
$ sudo curl -o /usr/local/bin/youtube-dl
$ sudo chmod a+x /usr/local/bin/youtube-dl


$ youtube-dl
[youtube] Setting language
[youtube] Confirming age
[youtube] DwYPG6vreJg: Downloading webpage
[youtube] DwYPG6vreJg: Downloading video info webpage
[youtube] DwYPG6vreJg: Extracting video information
[download] Destination: Douglas Crockford - Advanced JavaScript-DwYPG6vreJg.mp4
[download] 100% of 169.41MiB in 00:43

Supported sites

Most of the leading video sites like YouTube, Vimeo, Dailymotion are supported, including a bunch of news, sports, trailers and of course porn sites. For a full list please see supported sites on GitHub.

# List all available sites
$ youtube-dl --extractor-descriptions

Is your favorite site missing from youtube-dl? Then please do head over to the GitHub repo and check out the Adding support for a new site section. Open source contributors are constantly improving the tool with support for new sites.

Video formats

youtube-dl supports a long range of formats and resolutions, that are passed in the -f, --format FORMAT parameter.

Every format has a format code that can be specified when downloading a video, including special name codes like: "best", "bestvideo", "bestaudio", "worst", "worstvideo" and "worstaudio". If no specific format is specified the best quality format is chosen.

To list down all available formats for a video URL use -F, --list-formats, the output will look like this:

$ youtube-dl -F
[youtube] Setting language
[youtube] Confirming age
[youtube] DwYPG6vreJg: Downloading webpage
[youtube] DwYPG6vreJg: Downloading video info webpage
[youtube] DwYPG6vreJg: Extracting video information
[info] Available formats for DwYPG6vreJg:
format code extension resolution  note
171         webm      audio only  DASH audio , audio@128k (worst)
140         m4a       audio only  DASH audio , audio@128k
160         mp4       144p        DASH video , video only
242         webm      240p        DASH video , video only
133         mp4       240p        DASH video , video only
243         webm      360p        DASH video , video only
134         mp4       360p        DASH video , video only
244         webm      480p        DASH video , video only
135         mp4       480p        DASH video , video only
17          3gp       176x144
36          3gp       320x240
5           flv       400x240
43          webm      640x360
18          mp4       640x360     (best)

Rip music from videos - YouTube songs to Spotify

In addition to the video formats, youtube-dl also supports a whole range of post-processing options. Check out the GitHub repo for a full list of options.

I primarily use the -x, --extract-audio option to convert videos files into audio-only files - do note that the options has a couple of extra dependencies: ffmpeg or avconv and ffprobe or avprobe.

Shell alias yt

I pretty much only use Spotify for listening to music, unfortunately more obscure remixes and new releases often aren’t available for streaming through Spotify, so I end up needing an offline copy. Luckily youtube-dl supports downloading tracks from SoundCloud, where I find a lot of great new music - but as described earlier it supports extracting music from videos as one of the post-processing options.

Because I end up extracting audio from video files fairly often, I’ve created a quick little shell alias for downloading the audio from for example YouTube:

# alias for youtube-dl extracting audio
alias yt='youtube-dl --extract-audio --audio-format mp3'

Additional parameters

I’ve mentioned a couple of the parameters for youtube-dl in this post, but it supports a ton more. All options are well documented in the options section of the README.

One of my favorite hidden features is the ability to download your entire Watch Later playlist from YouTube or Vimeo, perfect entertainment for a long-haul flight.

Tool updates

The rate of updates to youtube-dl is very frequent, and there seems to be a lot of active contributors to the project. The original creator of the project Ricardo Garcia have long since stepped down as a maintainer, check out his post regarding the team working on it now: The fantastic youtube-dl team.

I once encountered a problem where I couldn’t download a video off YouTube because of a problem with encrypted signatures, I apparently had an old version of the tool and a simple update fixed the problem:

# Update youtube-dl
$ youtube-dl -U
  1. I shall avoid all talk about copyright laws and other legal implications of using this tool.

Update: Corrected small typo spotted by @soerenr, thanks!