Skip to content

Instantly share code, notes, and snippets.

View jurre's full-sized avatar

Jurre jurre

View GitHub Profile
@jurre
jurre / gist:7155759
Created October 25, 2013 14:42
.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
# Example aliases
@jurre
jurre / devise.rb
Last active December 31, 2015 18:22
After removing all the root elements from our JSON API I ran into an issue with devise expecting the `sign_in` params to be wrapped in their respective scope (`user` in our case), so: ```ruby { user: { email: "whatever@whatever.com", password: "whatever } } ``` But with our new JSON API we wanted to get rid of the root element wrapping and wante…
# config/initializers/devise.rb
Devise.setup do |config|
# .. snip
config.warden do |manager|
manager.default_strategies(:scope => :user).unshift :unwrapped_authenticatable
end
end
@jurre
jurre / gist:8030430
Last active December 31, 2015 18:59
string to pastel color
def pastel_color_for_string(string)
start_color = 128
total_offset = 64
hex_value = [
0,
string_to_integer_hash(string) % total_offset,
string_to_integer_hash(string.reverse) % total_offset,
total_offset
].sort.each_cons(2).map do |a, b|
"%02x" % (start_color + b - a)
@jurre
jurre / happy2014.sh
Created December 31, 2013 13:41
Happy 2014!
#!/bin/bash
formatted_time() {
local total_seconds=${1}
((hours=total_seconds/3600))
((minutes=total_seconds%3600/60))
((seconds=total_seconds%60))
printf "%02d:%02d:%02d\n" $hours $minutes $seconds
}
#import <Foundation/Foundation.h>
#import "sqlite3.h"
typedef int64_t timestamp;
NSUInteger randomNumberInRange(NSUInteger start, NSUInteger end);
// Create a sample date using the ISO-8601 format.
// 2013-04-23T16:29:05Z
NSString* generateSampleDate();
@jurre
jurre / bench.rb
Created January 13, 2015 10:51
roar vs ams
require "bundler"
require "active_model_serializers"
require "roar"
require "roar/json/json_api"
require "benchmark"
require "ffaker"
Post = Struct.new(:id, :author, :body, :draft) do
include ActiveModel::Serializers::JSON
end