Skip to content

Instantly share code, notes, and snippets.

@shime
shime / kata.md
Created November 19, 2014 21:40
text from kata at http://www.codewars.com/kata/a-chain-adding-function/. solution is in 3 lines of code.

We want to create a function that will add numbers together when called in succession.

add(1)(2) == 3 // true

We also want to be able to continue to add numbers to our chain.

add(1)(2)(3) == 6 // true
@shime
shime / rc.xml
Created November 6, 2014 17:10
openbox shortcuts for window management
<keyboard>
<!-- resize windows with Alt + Direction -->
<keybind key="A-Right">
<action name="GrowToEdgeEast"/>
</keybind>
<keybind key="A-Left">
<action name="GrowToEdgeWest"/>
</keybind>
<keybind key="A-Down">
<action name="GrowToEdgeSouth"/>
@shime
shime / ngnix.conf
Created October 31, 2014 10:29
redirect non-www to www with or without ssl in ngnix
# http://domain.com -> https://www.domain.com
# http://www.domain.com -> https://www.domain.com
server {
listen 80;
server_name domain.com www.domain.com;
return 301 https://www.domain.com$request_uri;
}
# https://domain.com -> https://www.domain.com
server {
@shime
shime / list_files.js
Created October 9, 2014 20:31
list files in a directory with node.js
var fs = require('fs'),
path = require('path')
var listFiles = function(dir, next){
fs.readdir(dir, function(err, nodes){
if (err) next(err)
next(null, nodes.filter(function(node){
return fs.lstatSync(path.resolve(dir) + "/" + node).isFile()
}))
})
@shime
shime / readme.md
Created September 30, 2014 14:15
run the minitest test suite without rake

To run bunch of Minitest tests in one go, without using Rake, use this command

$ ruby -e 'ARGV.each { |path| require "./#{path}" }' test/*.rb

@shime
shime / _readme.md
Last active April 28, 2023 18:56
github oauth in node using express

What?

Most basic example of authenticating with Github in node.

How?

Clone this gist, change keys inside config.js and then hit npm install && node app.js.

Done?

@shime
shime / _README.md
Last active March 15, 2021 19:26
comparing dates and times in RSpec

What is this?

How do you compare date/times in RSpec?

If you do this

expect(Time.now.to_i).to eq Time.new(2014, 4, 2).to_i
@shime
shime / test.coffee
Created January 16, 2014 22:27
testing Ember.RSVP with QUnit
test "the Ember.RSVP.Promise works", ->
promise = new Ember.RSVP.Promise((resolve, reject) ->
Ember.run(null, resolve, "value")
)
Ember.run =>
promise.then (actual) ->
equal(actual, 'value', 'promise resolved with "hello"')
@shime
shime / _readme.md
Created November 28, 2013 14:25
easier renaming and moving of files in vim

Simple function that makes moving and renaming files in Vim much easier.

Usage

Place it in your ~/.vimrc.

I'm calling it with N here, map it to anything you like.

@shime
shime / artists.json
Created November 2, 2013 10:29
some good electroswing artists
{
"artists": [
"parov stelar",
"proleter",
"goldfish",
"tape five",
"movits",
"odjbox"
]
}