Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'bundler'
Bundler.require
include Contracts
Contract Num, Num => Num
def add_c(a, b)
a + b
end
vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:271:in `call': undefined method `url_options' for #<Module:0x007fd2d8597d58> (NoMethodError)
from vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:222:in `call'
from vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:334:in `block (2 levels) in define_url_helper'
from config/environment.rb:134:in `block (2 levels) in <top (required)>'
[... app specific code, sorry ...]
from vendor/bundle/ruby/2.0.0/gems/sidekiq-3.2.5/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'
from vendor/bundle/ruby/2.0.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:122:in `call'
from vendor/bundle/ruby/2.0.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:122:in `block in invoke'
from vendor/bundle/ruby/2.0.0/gems/sidekiq-pro-1.9.0/lib/sidekiq/batch/middleware.rb:26:in `call'
from vendor/bundle/ruby/2.0.0/gems/sidekiq-3.2.5/lib/sidekiq/middlewar
package com.pavelkalvoda.misc.smoothvox.terrain;
import java.util.Random;
// Based on http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// http://www.csee.umbc.edu/~olano/s2002c36/ch02.pdf
// http://mrl.nyu.edu/~perlin/doc/oscar.html
// + simplified
public class SimpleSimplexNoise {
module M
def x
'M'
end
end
class A
def x
42
end
@PJK
PJK / bridge.rb
Created March 11, 2015 16:33
Bridge pattern
class Window
def initialize
# Implementor selection strategy
extend [WindowsAPI, X11API].sample
end
def drawRectangle
4.times { drawLine }
end
end
module Libcbor
extend FFI::Library
ffi_lib ['/usr/local/lib/libcbor.so']
attach_function :cbor_new_int8, [], :pointer
attach_function :cbor_set_uint16, [:pointer, :ushort], :void
attach_function :cbor_set_uint8, [:pointer, :uchar], :void
attach_function :cbor_serialize, [:pointer, :pointer, :size_t], :size_t
puts 'yo'
end
@PJK
PJK / Make
Created May 3, 2015 11:59
Latex citations with URL dates
$(NAME).bbl: $(BIB) $(NAME).tex
pdflatex -shell-escape $(PDFL_FLAGS) $(NAME)
biber $(NAME)
@PJK
PJK / ex.c
Last active August 29, 2015 14:21
libcbor example
#include "cbor.h"
int main(int argc, char * argv[])
{
/* Preallocate the map structure */
cbor_item_t * root = cbor_new_definite_map(2);
/* Add the content */
cbor_map_add(root, (struct cbor_pair) {
.key = cbor_move(cbor_build_string("Is CBOR awesome?")),
.value = cbor_move(cbor_build_bool(true))
#include <cbor.h>
#include <stdio.h>
int main(int argc, char * argv[])
{
/* Preallocate the map structure */
cbor_item_t * root = cbor_new_definite_map(2);
/* Add the content */
cbor_map_add(root, (struct cbor_pair) {
.key = cbor_move(cbor_build_string("Is CBOR awesome?")),
@PJK
PJK / _readme.md
Last active October 2, 2019 12:44
ETH Systems Construction 2015