Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@damphyr
damphyr / tokenizer.rb
Created June 5, 2015 11:33
Diesel tokenizer
module Diesel
module Tokenize
attr_accessor :input
def tokenize source
tokens = Array.new
source.each do |line|
# Comment Type 1: Completely ignore all text between '##' and EOL
input = line.gsub(/##.*$/, "").strip
# Comment Type 2: Interpret all text between '%%' and EOL as docs
parts = input.split("%%")
@damphyr
damphyr / keybase.md
Created September 23, 2014 08:13
keybase.md

Keybase proof

I hereby claim:

  • I am damphyr on github.
  • I am arcandros (https://keybase.io/arcandros) on keybase.
  • I have a public key whose fingerprint is D1E4 FC0C 45A3 9A3D 3162 F7D1 99B7 A1A5 F690 9409

To claim this, I am signing this object:

INFO global: Vagrant version: 1.6.3
INFO global: Ruby version: 2.0.0
INFO global: RubyGems version: 2.0.14
INFO global: VAGRANT_DETECTED_OS="MINGW32_NT-6.1"
INFO global: VAGRANT_EXECUTABLE="d:/tools/Vagrant/bin/../embedded/gems/gems/vagrant-1.6.3/bin/vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="d:/tools/Vagrant/bin/../embedded"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_INTERNAL_BUNDLERIZED="1"
INFO global: VAGRANT_LOG="debug"
@damphyr
damphyr / Robot.ino
Created November 17, 2013 15:40
ATCAR
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
int potpin = 0; // analog pin used to connect the potentiometer
int mode=1;
void setup()
{
@damphyr
damphyr / pdfkit_0.5.3_windows_bug.rb
Created July 4, 2013 12:35
Reproduces the pdfkit 0.5.3 behaviour with paths that contain spaces on Windows. Tested with RubyInstaller Ruby 1.9.3p392
require 'pdfkit'
def reproduce html,output,path_to_wk
PDFKit.configure do |config|
config.wkhtmltopdf = path_to_wk
end
kit=PDFKit.new(html,:page_size=>'A4')
kit.to_file(output)
end
@damphyr
damphyr / Vagrantfile
Last active December 18, 2015 08:49
Refactored multiple Vagrant provider configuration (alternative to https://gist.github.com/tknerr/5753319)
#
# Vagrantfile for testing
#
def configure_provider provider,config,cfg_lmbd
config.vm.provider provider do |prvdr,override|
cfg_lmbd.call(prvdr,override)
end
end
def vbox_config name,ip,memory_size=384
@damphyr
damphyr / backtrace
Created October 8, 2012 15:26
Reproduce the windows marshalling bug in systemu
c:/ruby/lib/ruby/gems/1.9.1/gems/systemu-2.5.2/lib/systemu.rb:89:in `rescue in block (3 levels) in s
ystemu': systemu: Error - process interrupted! (RuntimeError)
o:↕ArgumentError: mesg"∟dump format error(0x67):bt[I"kC:/Users/C11865/AppData/Local/Temp/syste
encoding"♂IBM437I"mC:/Users/C11865/AppData/Local/Temp/systemu_C11865DEV_3620_3920_0.942001098869122_
1/program:5:in `<main>'♠@
from c:/ruby/lib/ruby/gems/1.9.1/gems/systemu-2.5.2/lib/systemu.rb:82:in `block (3 levels) i
n systemu'
from c:/ruby/lib/ruby/gems/1.9.1/gems/systemu-2.5.2/lib/systemu.rb:76:in `popen'
from c:/ruby/lib/ruby/gems/1.9.1/gems/systemu-2.5.2/lib/systemu.rb:76:in `block (2 levels) i
n systemu'
@damphyr
damphyr / jruby 1.6.7
Created May 16, 2012 14:57
Thread behaviour in Ruby (In the GIL's grip)
meisterbrau:sandbox riva$ ruby -v
jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_31) [darwin-x86_64-java]
meisterbrau:sandbox riva$ ruby threading.rb
No threads: 0.955 seconds
Single thread: 0.667 seconds
Two threads: 0.683 seconds
@damphyr
damphyr / gist:1405100
Created November 29, 2011 15:03
rutema minimal example output
[20111129 17:02:21] INFO: rutema v1.2.4
[20111129 17:02:21] INFO: Configuration loaded from config/minimal.rutema
[20111129 17:02:21] INFO: Run started in mode 'unattended'
[20111129 17:02:21] INFO: Running T001 - T001
[20111129 17:02:21] INFO: Scenario for T001
[20111129 17:02:21] INFO: Running step 1 - echo - echo
Hello Testing World
[20111129 17:02:21] INFO: 1 - echo - echo - success
[20111129 17:02:21] INFO: Running T002 - T002
[20111129 17:02:21] INFO: Scenario for T002
@damphyr
damphyr / cloc_history.rb
Created August 18, 2011 10:59
Plot the LOC history for a bunch of svn revisions
#manually add the revisions or grep them out of svn log
revisions=[]
require 'psych'
require 'yaml'
require 'rubygems'
require 'fileutils'
require 'patir/command'
require 'json'