Skip to content

Instantly share code, notes, and snippets.

class DeliciousToken < ConsumerToken
DELICIOUS_SETTINGS = {
:site => 'https://api.login.yahoo.com',
:http_method => :get,
:scheme => :query_string,
:request_token_path => '/oauth/v2/get_request_token',
:access_token_path => '/oauth/v2/get_token',
:authorize_path => '/oauth/v2/request_auth',
}
@nofxx
nofxx / serialize.rb
Created June 28, 2010 23:07
JSON vs BSON
#!/usr/bin/env ruby
require 'benchmark'
require 'json'
require 'bson'
T = 100_000
[{ :foo => 2 }, { :foo => 2, :bar => 3, :baz => "long very very long and big and uncut string" },
{ :foo => 2, :bar => 3, :baz => "long very very long and big and uncut string",
psql -U postgres
create database template_postgis with template = template1;
UPDATE pg_database SET datistemplate = TRUE where datname = 'template_postgis';
\c template_postgis
CREATE LANGUAGE plpgsql;
# arch
\i /usr/share/postgresql/contrib/postgis-1.5/postgis.sql
\i /usr/share/postgresql/contrib/postgis-1.5/spatial_ref_sys.sql;
@nofxx
nofxx / Makefile
Created February 9, 2011 17:49
AVR Makefile
DEVICE = atmega32 #90s2313
AVRDUDE = avrdude -c usbasp -p $(DEVICE)
# Choose your favorite programmer and interface above.
COMPILE = avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=$(DEVICE) #-DDEBUG_LEVEL=2
# NEVER compile the final product with debugging! Any debug output will
# distort timing so that the specs can't be met.
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
@nofxx
nofxx / color-theme-fxx.el
Created March 5, 2011 18:55
Emacs color theme
;; Fxx Colour Theme for Emacs.
;;
;; Defines a colour scheme resembling that of the original TextMate Fxx colour theme.
;; To use add the following to your .emacs file (requires the color-theme package):
;;
;; http://wiki.nofxx.com/_detail/x:xxx2tmscreen.png
;;
;; (require 'color-theme)
;; (color-theme-initialize)
;; (load-file "~/.emacs.d/fxx-emacs/color-theme-fxx.el")
@nofxx
nofxx / spec_helper.rb
Created October 15, 2011 08:01
Finally working spec_helper spork/mongoid/fabrication/capybara
require 'pry'
require 'spork'
# Loading more in this block will cause your tests to run faster.
# if you change any configuration or code from libraries loaded
# need to restart spork for it take effect.
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require 'rails/application'
@nofxx
nofxx / rspec_spec.rb
Created October 15, 2011 08:17
Spork on Rails 3/ActiveRecord/Fabrication
require 'spork'
Spork.prefork do
ENV['RAILS_ENV'] ||= 'test'
require 'rails/application'
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'database_cleaner'
@nofxx
nofxx / project_default_scope_mongoid.rb
Created October 19, 2011 03:41
Mongoid bug default_scope test
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("foo_#{Time.now.to_i}")
end
class Project
include Mongoid::Document
field :name
field :state, :default => 'active'
@nofxx
nofxx / c
Created October 19, 2011 04:42
rc1
main()
int x = 1;
float y = 22.5;
char c = 'C';
char[] = "Take this " + c + "!";
printf("x to i: %d\n", x);
@nofxx
nofxx / barcode.rgin
Created November 1, 2011 17:00
RGhost Tests
(type.ps) runlibfile
(unit.ps) runlibfile
(IsoLatin.enc) runlibfile
/default_encoding IsoLatin def
<< /Duplex false /Tumble false >> setpagedevice
/pagesize [595 842] def
/margin 3 dict def margin begin /top 1 cm def /right 1 cm def /bottom 1 cm def /left 1 cm def end
(paper.ps) runlibfile
[ /Producer (Ruby Ghostscript - RGhost v0.8.7) /DOCINFO pdfmark /rows_per_page 80 def /count_pages 10 def /row_height 0.4 cm def /row_padding 0.1 cm def (basic.ps) runlibfile
(cursor.ps) runlibfile