Skip to content

Instantly share code, notes, and snippets.

View jakobmattsson's full-sized avatar

Jakob Mattsson jakobmattsson

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jakobmattsson on github.
  • I am jakobm (https://keybase.io/jakobm) on keybase.
  • I have a public key whose fingerprint is BF01 CCA2 16A6 D68A 354D 84D5 E35C 2E0C A5D3 6189

To claim this, I am signing this object:

@jakobmattsson
jakobmattsson / gist:10858811
Created April 16, 2014 11:41
Renaming an AWS-user using the CLI
AWS_ACCESS_KEY_ID=MYKEY AWS_SECRET_ACCESS_KEY=MYSECRET aws iam update-user --user-name OLDNAME --new-user-name NEWNAME
@jakobmattsson
jakobmattsson / gist:9762351
Created March 25, 2014 13:55
HTTP request with promises
Q = require 'q'
request = require 'request'
req = (params) ->
deferred = Q.defer()
request params, (error, response, body) ->
return deferred.reject(new Error(error)) if error
deferred.resolve
statusCode: response.statusCode
headers: response.headers
@jakobmattsson
jakobmattsson / gist:8038195
Last active December 31, 2015 20:09
Combinations - kodapor
flatten = (arrays) ->
result = []
arrays.forEach (array) ->
result = result.concat(array)
result
combinations = (n, values) ->
return [[]] if n <= 0
flatten [0 ... values.length].map (x) ->
@jakobmattsson
jakobmattsson / gist:7704638
Created November 29, 2013 11:49
Travis setup
travis encrypt my_npm_key --add deploy.api_key
travis encrypt api_token@'Deep Thought' --add notifications.hipchat.rooms
@jakobmattsson
jakobmattsson / gist:7083975
Created October 21, 2013 13:34
Cutting an image into equally sized parts and for each image shaving off a bit on the top and bottom, resizing them and extending their canvas sizes.
convert tweaked.png -crop 729x870 -shave 0x80 -resize 80x70 -gravity East -extent 80x70 tiles_%d.png
@jakobmattsson
jakobmattsson / deps.coffee
Last active December 24, 2015 19:49
Run this is a node-project to get a list of all repeated dependencies
fs = require 'fs'
_ = require 'underscore'
{exec} = require 'child_process'
exec 'npm ls', (err, output) ->
return console.log(err) if err?
lines = output.split('\n').slice(1, -2)
packages = lines.map (x) ->
@jakobmattsson
jakobmattsson / getSelenium.coffee
Created September 15, 2013 23:54
getSelenium.coffee
getfile = require '../lib/getfile'
getfile.get
url: 'http://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar'
dir: '../.selenium'
onDownload: (callback) ->
console.log "Installing selenium...."
callback()
, (err, filepath) ->
return console.log(err) if err?
@jakobmattsson
jakobmattsson / getFile.coffee
Last active December 23, 2015 03:39
getFile
fs = require 'fs'
urlLib = require 'url'
path = require 'path'
mkdirp = require 'mkdirp'
downloader = require 'downloader'
exports.get = ({ url, dir, onDownload }, callback) ->
onDownload ?= (callback) -> callback()
{pathname} = urlLib.parse(url)
_ = require 'underscore'
semver = require 'semver'
readInstalled = require 'read-installed'
expectedPackages = (pkgJson) ->
pack = require(pkgJson)
devDeps = pack.devDependencies || {}
deps = pack.dependencies || {}
_.extend({}, devDeps, deps)