Skip to content

Instantly share code, notes, and snippets.

View ariejan's full-sized avatar

Ariejan de Vroom ariejan

View GitHub Profile
class BankAccount < ActiveRecord::Base
include AttributeEncryption
belongs_to :billable, polymorphic: true
encrypted_attribute :encrypted_number, hash: true
validates :number,
format: { with: /[pP]?\d*/ }
# encrypted_attribute overrides #number= in order
@ariejan
ariejan / evasion_test.c
Created August 27, 2012 22:53
First attempt at collision detectin/evasion
#include <AFMotor.h>
#include <Servo.h>
AF_DCMotor motorFrontLeft(3);
AF_DCMotor motorBackLeft(4);
AF_DCMotor motorFrontRight(2);
AF_DCMotor motorBackRight(1);
int servoPin = 10;
int pingPin = 15;
@ariejan
ariejan / rfid.ino
Created August 22, 2012 16:03
Arduino Sketch for RFID Unit 1.0
/**
* RFID Ding 1.0
* Copyright (C) 2012 Kabisa ICT
* Authors:
* Ralph Rooding <[email protected]>
* Harm de Laat <[email protected]>
* Ariejan de Vroom <[email protected]>
*/
@ariejan
ariejan / knight_rider.c
Created May 24, 2012 21:03
This runs, then flails, the restarts.
int ledPins[] = {2,3,4,5,6,7,8,9};
void setup(){
for(int i = 0; i < 8; i++){
pinMode(ledPins[i], OUTPUT);
}
}
void loop(){
oneAfterAnotherNoLoop();
@ariejan
ariejan / log-after.txt
Created March 21, 2012 14:12
Vim speed up for Ruby and CSS
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.034 000.034: --- VIM STARTING ---
000.163 000.129: Allocated generic buffers
000.751 000.588: locale set
000.771 000.020: window checked
@ariejan
ariejan / seed_file.rb
Created March 13, 2012 12:31 — forked from eventualbuddha/seed_file.rb
SeedFile, a helper for doing database setup in a Rails 3 app
# Helper class for importing files with records to the database.
class SeedFile
def self.import(path)
new(path).import
end
attr_reader :path
def initialize(path)
@path = Pathname(path)
@ariejan
ariejan / idea.rb
Created February 2, 2012 15:50
Idea of new Invoicing design.
class Batch
end
class Invoice < ActiveRecord::Base
belongs_to :invoicable, polymorphic: true
belongs_to :invoicer, polymorphic: true
has_many :invoice_lines
def amount
1) Partnership as a relation between two people connects a person with a partner
Failure/Error: person = create(:person_parent, partner: partner)
ActiveRecord::RecordInvalid:
Validation failed: Person partnership cannot assign partner to a partner
# ./spec/models/partnership_spec.rb:13:in `block (3 levels) in <top (required)>'
2) Partnership as a relation between two people connects a partner with a customer_partner
Failure/Error: person = create(:person_parent, partner: partner)
ActiveRecord::RecordInvalid:
Validation failed: Person partnership cannot assign partner to a partner
@ariejan
ariejan / redis-benchmark-10000.txt
Created January 11, 2012 15:18
Redis Benchmark -
$ redis-benchmark ‹ruby-1.9.2›
====== PING (inline) ======
10000 requests completed in 0.09 seconds
50 parallel clients
3 bytes payload
keep alive: 1
100.00% <= 0 milliseconds
109890.11 requests per second
@ariejan
ariejan / con.rb
Created December 1, 2011 16:00
EM::Connection specs?
module MyApp
class Con < EM::Connection
def post_init
@queue = EM::Queue.new
end
def receive_data(data)
@queue.push(data)
end
end