Skip to content

Instantly share code, notes, and snippets.

View ariejan's full-sized avatar

Ariejan de Vroom ariejan

View GitHub Profile
@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 / 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 / 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 / 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;
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
class Reader
has_many :memberships
has_many :magazines, through: :memberships
end
class Membership
belongs_to :reader
belongs_to :magazine
end
@ariejan
ariejan / work.sh
Created December 20, 2012 16:47 — forked from anonymous/gist:4346624
export COL=$COLUMNS ; grep '\[CatalogItem\] Retrieved' production.log | awk '{ print $6 $7 }' | ruby -ne 'BEGIN { puts ENV.inspect;$columns = ENV["COL"].to_i; $all = Hash.new { |h,k| h[k] = 0 } }; a, b = $_.split("(").map(&:to_f); next if a < 1; $all[((b/a/100).floor)] += a.to_i; END { max_value = $all.values.max; puts "\e[2J\e[f"; puts "Average request time".center($columns); print "\033[37m" ; puts "ms/req ±50ms".center($columns); print "\033[0m" ; puts ("─" * $columns); $all.keys.sort.each { |k| puts "#{(k * 100 + 50).to_s.rjust(6)}: \033[31m#{"▓" * ($all[k].to_f / max_value * ($columns - 8))}\033[0m"; }; puts "─" * $columns; print "\033[5m\033[35m" ; puts "(╯°□°)╯︵ ┻━┻ © Arjan & Ariejan".center($columns); print "\033[0m" }'
public abstract class BlockType {
public static byte VOID = 0;
public static byte DIRT = 1;
}

Consider the following query

SELECT "orders".* FROM "orders" 
WHERE "orders"."bid" = 't' 
AND "orders"."region_id" = 10000002 
AND "orders"."type_id" = 30259 
ORDER BY price DESC
LIMIT 1

From a table with about 2.5million rows, it returns this one result in about 1075ms.

@ariejan
ariejan / init-sidekiq.sh
Last active December 14, 2015 01:09
Init.d script for managing a Sidekiq worker.
#! /bin/bash
# /etc/init.d/gitlab
# GITLAB
# Maintainer: @randx
# App Version: 3.0
### BEGIN INIT INFO
# Provides: gitlab