Skip to content

Instantly share code, notes, and snippets.

View plukevdh's full-sized avatar
🔥

Luke van der Hoeven plukevdh

🔥
View GitHub Profile
@plukevdh
plukevdh / benchmark.rb
Last active August 26, 2015 15:43
Call comparisons
class Processor
def plus_two(arg)
arg + 2
end
end
class Runner
def block_run(arg, &block)
yield arg
end
@plukevdh
plukevdh / range.js
Created February 4, 2014 17:21
Crazy Range Explain
// same things as ~~
// basically rounds to an integer (when x is a float)
// see: http://stackoverflow.com/questions/4055633/what-does-do-in-javascript
function doubleTilde(x) {
if(x < 0) return Math.ceil(x);
else return Math.floor(x);
}
function range(to, from, step) {
// set defaults
@plukevdh
plukevdh / newrelic.ps1
Created February 11, 2014 11:52
Deployment notification to NewRelic from OctoDeploy
$headers = @{"x-api-key"="$OctopusParameters['NewRelic.APIKey']"}
$key = "NewRelic." + $OctopusParameters['Octopus.Project.Name'] + ".ID"
$body = @{
"deployment[user]"="$OctopusParameters['Octopus.Deployment.CreatedBy.DisplayName']";
"deployment[revision]"="$OctopusParameters['Octopus.Release.Number']";
"deployment[description]"="$OctopusParameters['Octopus.Release.Notes']";
"deployment[application_id]"="$OctopusParameters[$key]";
}
@plukevdh
plukevdh / crash.log
Created February 13, 2014 13:23
Sidekiq jruby explosions
2014-02-13T00:25:55Z 1267 TID-9a3e WARN: {:context=>"Sidetiq::Handler#dispatch"}
2014-02-13T00:25:55Z 1267 TID-9a3e WARN: unable to create new native thread
2014-02-13T00:25:55Z 1267 TID-9a3e WARN: java.lang.Thread.start0(Native Method)
java.lang.Thread.start(Thread.java:693)
java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:949)
java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1371)
java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:110)
org.jruby.RubyEnumerator$ThreadedNexter.ensureStarted(RubyEnumerator.java:622)
org.jruby.RubyEnumerator$ThreadedNexter.next(RubyEnumerator.java:578)
org.jruby.RubyEnumerator.next(RubyEnumerator.java:435)
@plukevdh
plukevdh / halogen_test.rb
Created April 10, 2014 19:36
halogen redirect
require 'sinatra'
require 'pry'
USERNAME = 'BFGIT'
SALT = "mytestsalt"
def generate_hash(str)
Digest::SHA256.new.digest str
end
@plukevdh
plukevdh / markdown_renderer.rb
Created April 11, 2014 14:00
simple markdown switcher for jruby vs mri
if RUBY_PLATFORM == 'java'
require 'kramdown'
TYPE = Kramdown
else
require 'redcarpet'
TYPE = Redcarpet
end
class MarkdownRenderer
def initialize(type=TYPE)
@plukevdh
plukevdh / keybase.md
Created April 12, 2014 04:11
keybase.io proof

Keybase proof

I hereby claim:

  • I am plukevdh on github.
  • I am plukevdh (https://keybase.io/plukevdh) on keybase.
  • I have a public key whose fingerprint is 6123 C2CA ED33 DBC7 9E9F ED4A D7CE 9EB3 8910 3832

To claim this, I am signing this object:

@plukevdh
plukevdh / entity.rb
Last active August 29, 2015 14:01
entity parser for a schama dsl
require 'schemad/extensions'
require 'schemad/type_handler'
module Schemad
class Entity
extend Schemad::Extensions
def self.inherited(subclass)
subclass.instance_variable_set(:@attributes, [])
end
@plukevdh
plukevdh / angular-ace.coffee
Last active August 29, 2015 14:01
ace + angular
AceEditor = angular.module('AceEditor', [])
AceEditor.controller 'EditorCtrl', ['$scope', 'editorSession', ($scope, editorSession) ->
$scope.editing = editorSession.editing
$scope.editors = editorSession.editors
$scope.sanitize = editorSession.sanitize
]
codeFetchFactory = (editor) ->
->
editor.getSession().getDocument().getValue()
@plukevdh
plukevdh / code.js
Created May 15, 2014 19:55
TeachTDD example code
var Storage = (function() {
var uniqueId = 0;
function Storage() {}
Storage.prototype.add = function(item) {
var id = this.generateId()
, data = this._toJSON(item);
localStorage[id] = data;
};