Skip to content

Instantly share code, notes, and snippets.

View sra448's full-sized avatar
💭
Statin'

Florian Unternährer sra448

💭
Statin'
View GitHub Profile
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
coffee: {
compileWithMaps: {
expand: true,
src: ["src/*.coffee"],
dest: "js/",
@sra448
sra448 / tail.py
Created November 9, 2011 16:44
sublime text 2 command for tailing and greping the rails logfile
import sublime, sublime_plugin, os
class TailCommand(sublime_plugin.TextCommand):
def run(self, edit):
from datetime import datetime
filtertext = "FLO"
# open sublime console
self.view.window().run_command("show_panel", { "panel": "console", "toggle": "true" })
@sra448
sra448 / backbone-localdatabase.js
Created September 28, 2011 22:05
local database wrapper
// Override `Backbone.sync` to use delegate to the model or collection's
// *localStorage* property, which should be an instance of `Store`.
Backbone.sync = function(method, model, options) {
"use strict";
var store = model.store || model.collection.store;
var cb = function(transaction, data) {
options.success(model);
};
var cb_create = function(transaction, data) {
@sra448
sra448 / test_performance_array_methods.rb
Created September 26, 2011 15:41
test performance of method vs method!
require 'benchmark'
def test_extended
test_array = [1, 2, 3, [ 1, 2, 3, 4, [1, 2, 3, 4, 5, 6, 7], 8, [9]], 10]
test_methods = ['collect', 'compact', 'flatten', 'map', 'reject', 'reverse', 'shuffle', 'sort', 'uniq']
Benchmark.bm(10) do |bm|
test_methods.each do |method|
bm.report(method) { 100000.times { test_array.send(method) } }
bm.report(method+ "!") { 100000.times { test_array.send(method + "!") } }
@sra448
sra448 / performance_test.rb
Created September 21, 2011 12:13
test performance of flatten vs flatten!
def test_preformance(name, *args)
start = Time.new
100000.times do |i|
yield(args)
end
time = (Time.new - start) * 1000
puts "#{name} time: #{time} ms"
return time
end