Update: please note that I have since switched to using a set of bash scripts instead of poluting the Git repository with git svn
.
Author: Kaspars Dambis
kaspars.net / @konstruktors
Update: please note that I have since switched to using a set of bash scripts instead of poluting the Git repository with git svn
.
Author: Kaspars Dambis
kaspars.net / @konstruktors
# From a fresh install of squeeze | |
apt-get install ruby rubygems # Need ruby to use fpm | |
gem1.8 install fpm --no-ri --no-rdoc | |
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
tar -zxvf ruby-1.9.3-p125.tar.gz | |
cd ruby-1.9.3-p125 | |
rm -rf /tmp/ruby193 |
class Luhn | |
def self.checksum(number) | |
digits = number.to_s.reverse.scan(/\d/).map { |x| x.to_i } | |
digits = digits.each_with_index.map { |d, i| | |
d *= 2 if i.even? | |
d > 9 ? d - 9 : d | |
} | |
sum = digits.inject(0) { |m, x| m + x } | |
mod = 10 - sum % 10 | |
mod==10 ? 0 : mod |
#!/usr/bin/env ruby | |
#/ Usage: <progname> [options]... | |
#/ How does this script make my life easier? | |
# ** Tip: use #/ lines to define the --help usage message. | |
$stderr.sync = true | |
require 'optparse' | |
# default options | |
flag = false | |
option = "default value" |
#import <Cocoa/Cocoa.h> | |
#import "opencv2/imgproc/imgproc_c.h" | |
#import "opencv2/highgui/highgui_c.h" | |
#import "opencv2/objdetect/objdetect.hpp" | |
@interface OpenCV : NSObject { | |
int scale; | |
CvCapture* camera; |
# sometimes watchr freaks out when you view this file in textmate (hits timestamp?) | |
# ie: it prints "Watching..." over and over | |
# just hit Ctrl-\ to run all tests and it calms down | |
ENV["WATCHR"] = "1" | |
puts "Watching..." | |
def growl(result) | |
result_lines = result.split("\n") | |
message = result_lines[result_lines.size - 1] |
# Adapted from the javascript implementation at http://sedition.com/perl/javascript-fy.html | |
# Randomizes the order of elements in the passed in array in place. | |
fisherYates = (arr) -> | |
i = arr.length; | |
if i == 0 then return false | |
while --i | |
j = Math.floor(Math.random() * (i+1)) | |
tempi = arr[i] |
ENV["WATCHR"] = "1" | |
system 'clear' | |
def growl(message) | |
growlnotify = `which growlnotify`.chomp | |
title = "Watchr Test Results" | |
puts message | |
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png" | |
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'" | |
system %(#{growlnotify} #{options} &) |
<% form_for(@user) do |f| %> | |
<p> | |
<%= f.label :name %><br /> | |
<%= f.text_field :name %> | |
</p> | |
<% f.fields_for :custom, @user.custom do |custom_form| %> | |
<% custom_form.object.marshal_dump.each_key do |custom_field| %> | |
<p> | |
<%= custom_form.label custom_field %><br /> |
module ApplicationHelper | |
# Mixin for tree generation based on a nested set, just place this in your application_helper.rb | |
module TreeMethods | |
attr_accessor :child_nodes | |
attr_accessor :parent_node | |
def after_initialize | |
@child_nodes = [] | |
@parent_node = nil | |
end | |
def recursive_tree nodes=nil, level=0 |