Skip to content

Instantly share code, notes, and snippets.

View jurre's full-sized avatar

Jurre jurre

View GitHub Profile
### Keybase proof
I hereby claim:
* I am jurre on github.
* I am jurre (https://keybase.io/jurre) on keybase.
* I have a public key whose fingerprint is E2C5 A255 3185 7FB9 4C43 EB4B 199C 1AC1 4FA6 F5E3
To claim this, I am signing this object:
@jurre
jurre / decorator.rb
Last active August 29, 2015 14:16
Simple Collection Decorator that plays nice with Kaminari
class BaseDecorator
def initialize(source)
@source = source
end
def method_missing(method_key, *args, &block)
@source.send(method_key, *args, &block)
end
def respond_to_missing?(method_key, *args, &block)
@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
@jurre
jurre / chat.js
Last active August 29, 2015 14:11
Phoenix framework events error
$(function () {
var $messages = $("#messages");
var $messageInput = $("#message-input");
var socket = new Phoenix.Socket("/ws");
socket.join("rooms", "public", {}, function (channel) {
channel.on("new:message", function (message) {
console.log(message);
$messages.append("<li>" + message.content + "</li>");
});
@jurre
jurre / gist:a1ade23f7b42e8c3ccd7
Created September 9, 2014 11:58
omg-apple-keynote
#!/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
}
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 5f3e9b6..8c515ad 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -13,4 +13,4 @@
//= require jquery
//= require jquery_ujs
//= require bootstrap
-//= require_tree .
\ No newline at end of file
require "octokit"
Octokit.configure do |c|
c.access_token = "YOUR_GITHUB_ACCESS_TOKEN",
c.auto_paginate = true
end
# get all comments from all issues
comments = Octokit.issues_comments("DefactoSoftware/CAPP11")
@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
}
@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 / 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