Skip to content

Instantly share code, notes, and snippets.

💭
working on datafruits

Tony Miller mcfiredrill

💭
working on datafruits
Block or report user

Report or block mcfiredrill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:1157928
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(/_/, '')
View gist:1160972
task :update do
system("rsync -rv build/* freedrull@freedrool.us:/var/www/freedrool.us/")
end
@mcfiredrill
mcfiredrill / cache_assertion_method.rb
Created Oct 26, 2011
☺ 263A 1 ☻ 263B 2 ♥ 2665 3 ♦ 2666 4 ♣ 2663 5 ♠
View cache_assertion_method.rb
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
View wakabadoggle.c
#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 Feb 29, 2012
logging from delayed_job
View logggggggg.rb
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 Mar 27, 2012
static blog dealie to embed into sinatra
View blog.rb
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 Apr 10, 2012
undefined method `tempfile'
View bundle update
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)
View blog.rb
# 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
View foo_job.rb
class FooJob < JobBase
@@model_name = Foo
end
@mcfiredrill
mcfiredrill / pry
Created May 10, 2012
class variable as attr_accessor...
View pry
[2] pry(main)> b = Boo.new(2)
=> #<Boo:0x9deaa90 @stuff=2>
[3] pry(main)> b.blah
=> "thingsmorethings"
You can’t perform that action at this time.