Skip to content

Instantly share code, notes, and snippets.

View tjsingleton's full-sized avatar

TJ Singleton tjsingleton

View GitHub Profile
function lazyCompileFactory(id, html) {
crunch.global.templates[id] = function(context) {
var compiled = Handlebars.compile(html);
crunch.global.templates[id] = compiled;
return compiled(context);
}
}
$('script[type="text/x-handlebars-template"]').each(function() {
var text = this.textContent;
@tjsingleton
tjsingleton / watch.rb
Last active December 16, 2015 04:19
watch a dir for new files and do some work
require 'listen'
require 'rb-fsevent'
LISTEN_PATH = '/tmp/m'
consumer, producer = IO.pipe
Dir["#{LISTEN_PATH}/*"].each {|n| producer.puts n }
2.times do
require 'benchmark/ips'
Benchmark.ips do |x|
RESULT = [1]
x.report('first') do |times|
i = 0
while i < times
id = RESULT.first
i += 1
require 'benchmark/ips'
require_relative '../config/environment'
Benchmark.ips do |x|
x.report("without patch - by slug") {
User.uncached do
User.find("tj-singleton")
end
}
CREATE TABLE report (
account_id INT UNIQUE,
classification VARCHAR(11)
);
CREATE TABLE report_temp (
account_id INT UNIQUE,
classification VARCHAR(11)
);
cl = ContentLicense.last
cl.content.object_id == cl.presentation.content.object_id
#=> false
cl.reload
cl.association(:content).target = cl.presentation.content
>> cl.content.object_id == cl.presentation.content.object_id
#=> true
names = [
"ERock560",
"jeep19950",
"meltin-BARRELS",
"RMAN2010",
"maden471",
"zeSPACE_NAZl",
"mud-racer2005",
"RICHIEJMONEY",
"yotamallcrawler",
@tjsingleton
tjsingleton / dig_cube.lua
Created August 4, 2012 03:16
makes the turtle dig a cube
turn_right = true
function dig_forward()
turtle.dig()
turtle.forward()
end
function dig_down()
turtle.digDown()
turtle.down()
require 'pathname'
ROOT = Pathname.pwd
SIZES = %W[
1056x792
1162x871
1278x958
1406x1054
1546x1160
1701x1276
@tjsingleton
tjsingleton / test.c
Created June 19, 2012 21:54
test type conversion
#include <stdio.h>
int main() {
unsigned long dword;
char converted;
dword = 255L;
converted = (char) dword;
printf("value is: %lu\n", dword);
printf("value is: %lu\n", converted);