Skip to content

Instantly share code, notes, and snippets.

View seebq's full-sized avatar
💭
working on @Greenzie

Charles Brian Quinn seebq

💭
working on @Greenzie
View GitHub Profile
#!/bin/sh
# From: http://www.openremote.org/display/docs/OpenRemote+2.0+How+To+-+Control+Somfy+Sunshades+with+Raspberry+Pi
PIN=$1
/usr/local/bin/gpio mode $PIN out
/usr/local/bin/gpio write $PIN 1
sleep 0.1
/usr/local/bin/gpio write $PIN 0
$ resumator_pipeline
Name: Johnny Appleseed Applied: 2013-10-18 (2 days ago) Last contact: 2013-10-20 (0 days ago)
Name: Charles Quinn Applied: 2013-10-17 (3 days ago) Last contact: 2013-10-18 (2 days ago)
Active Applicants: 2
Longest in Pipeline: 3
Longest in Pipeline without contact: 2
Average Days in Pipeline: 2.5
Average Days in Pipeline without contact: 1.0
Standard Deviation: 1.0
@seebq
seebq / rgb_to_cmyk.c
Created May 2, 2013 21:47
Simple RGB to CMYK (0-255) ranges
/*
Based on: http://www.rapidtables.com/convert/color/rgb-to-cmyk.htm
*/
#include <stdio.h>
#include <math.h>
typedef struct RGB_t { unsigned char red, green, blue; } RGB;
typedef struct CMYK_t { unsigned char cyan, magenta, yellow, black; } CMYK;
@seebq
seebq / api.rb
Created March 27, 2012 14:27 — forked from theinventor/api.rb
def unsubscribe
# using base64 encoding in the url to prevent unsubscribe abuse
@user = User.find_by_access_token(Base64.decode64(params[:token])) # find the user from the ID in url
if @user.opt_out!
redirect_to root_url, :notice => "We won't bug you with emails!" # give them a little notice that it worked
else
render :text => "Could not find your access token, did you copy-paste the correct email from the unsubscribe? Just email us at blah2blah.com"
end
end
@seebq
seebq / method_missing_fun.rb
Created December 13, 2011 02:33
Don't alter the method parameter
class Car
# http://ruby-doc.org/docs/ProgrammingRuby/html/ref_c_object.html#Object.method_missing
def method_missing(method, *args, &block)
# don't do:
method.gsub!("gasoline", "electricity")
# also don't do:
method = method.to_s
# ...
super
Sass in Rails 3.1
http://speakerdeck.com/u/chriseppstein/p/sass-the-future-of-stylesheets-in-rails-31
class Widget < ActiveRecord::Base
belongs_to :box
has_many :categorizations
has_many :categories, :through => :categorizations
# Returns a sentence of all the categories.
def category_names
if categories.empty?
class FalseClass
def affirmative?
false
end
end
class NilClass
def affirmative?
false
end
[color]
branch = auto
status = auto
diff = auto
[alias]
st = status
ci = commit
co = checkout
br = branch
tp = !rake test && git push
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @order.name %>
</p>
<p>Order contains <%= @order.boxes.size %> boxes.</p>
<ul>
<% @order.boxes.each do |box| %>