This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + "!") } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
coffee: { | |
compileWithMaps: { | |
expand: true, | |
src: ["src/*.coffee"], | |
dest: "js/", |