Skip to content

Instantly share code, notes, and snippets.

View mcfiredrill's full-sized avatar
💭
working on datafruits

Tony Miller mcfiredrill

💭
working on datafruits
View GitHub Profile
require 'rubygems'
require 'haml'
@template = File.read(ARGV[0])
@engine = Haml::Engine.new(@template)
@template_scope = Object.new
@partials = {}
Dir.glob("./src/_*.haml").each do |f|
partial_name = f.sub(/_/, '')
task :update do
system("rsync -rv build/* freedrull@freedrool.us:/var/www/freedrool.us/")
end
@mcfiredrill
mcfiredrill / cache_assertion_method.rb
Created October 26, 2011 16:37
☺ 263A 1 ☻ 263B 2 ♥ 2665 3 ♦ 2666 4 ♣ 2663 5 ♠
def assert_cache_works(key, procs)
#code that creates cache
procs[:cache].call
assert Rails.cache.exist?(key)
#code that should clear the cache
procs[:clear].call
assert !Rails.cache.exist?(key)
end
@mcfiredrill
mcfiredrill / wakabadoggle.c
Created January 14, 2012 18:20
frowneyface
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *tag(char *dest, char* tag, char* closing_tag){
char *out = malloc(1024);
printf("dest:%s\n",dest);
out = strncat(out, tag, strlen(tag));
out = strncat(out, dest, strlen(dest));
out = strncat(out, closing_tag, strlen(closing_tag));
@mcfiredrill
mcfiredrill / logggggggg.rb
Created February 29, 2012 22:22
logging from delayed_job
class MyJob
def initialize(blahblah)
@blahblah = blahblah
@logger ||= Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))
end
def perform
@logger.add Logger::INFO, "logging from delayed_job"
#do stuff
end
end
@mcfiredrill
mcfiredrill / blog.rb
Created March 27, 2012 18:23
static blog dealie to embed into sinatra
require 'yaml'
class BlogArticle
SUMMARY_SEPARATOR="READMORE"
attr_reader :date, :title, :tags, :page
def initialize(file)
f = File.read(file)
y = YAML.load(f.split("---\n")[1])
@title = y[:title]
@date = Date.parse y[:date]
@mcfiredrill
mcfiredrill / bundle update
Created April 10, 2012 20:54
undefined method `tempfile'
Using rake (0.9.2.2)
Using activesupport (3.0.10)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.10)
Using arel (2.0.10)
Using tzinfo (0.3.33)
Using activerecord (3.0.10)
Using aasm (3.0.4)
Using abstract (1.0.0)
@mcfiredrill
mcfiredrill / blog.rb
Created April 29, 2012 06:09
y u not utf-8
# encoding: utf-8
class BlogArticle
def initialize(file)
f = File.read(file)
puts "the encoding: #{f.encoding}"
y = YAML.load(f.split("---\n")[1])
end
# output:
# the encoding: US-ASCII
@mcfiredrill
mcfiredrill / foo_job.rb
Created May 8, 2012 19:05
class variables
class FooJob < JobBase
@@model_name = Foo
end
@mcfiredrill
mcfiredrill / pry
Created May 10, 2012 17:12
class variable as attr_accessor...
[2] pry(main)> b = Boo.new(2)
=> #<Boo:0x9deaa90 @stuff=2>
[3] pry(main)> b.blah
=> "thingsmorethings"