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 'test_helper' | |
| require 'ripper' | |
| # see http://svenfuchs.com/2009/7/5/using-ruby-1-9-ripper | |
| # Only finds contants which are referenced or defined via class | |
| # does not find constants which are defined inline i.e. X=true | |
| class ConstParser < Struct.new(:source) | |
| def consts | |
| consts = [] |
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
| function pipe(src){ | |
| var value = src; | |
| return function(){ | |
| for(var i = 0; i < arguments.length; i++){ | |
| var fn = arguments[i]; | |
| value = fn.call(null, value); | |
| } | |
| return value | |
| } |
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
| $('article').attr('class','current').css({position: 'relative', margin: 10, padding: '20px',top: 0, left: 0, height: 'auto', width: 'auto'}), $('#help').remove(), document.removeEventListener('keydown', handleBodyKeyDown), $('h2').css({position:'static'}) |
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
| // just a sketch to put away for now | |
| // these are weeding functions | |
| // the goal is to remove lables on a graph that are too close together (ie weed out overlapping labels) | |
| function weed(array, x, y){ | |
| var f = array[0] | |
| , l = array[array.length -1] | |
| , ex = d3.extent(array, function(d){ return d.y }) | |
| , hiLo = array.filter(function(d){ return d.y == ex[0] || d.y == ex[1]}); | |
| return _.uniq([f,l].concat(hiLo)); |
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
| package main | |
| import ( | |
| eventsource "github.com/antage/eventsource/http" | |
| redis "github.com/vmihailenco/redis" | |
| "log" | |
| "net/http" | |
| ) | |
| func haltOnErr(err error){ |
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
| (function(){ | |
| /* | |
| flex-image: javascript for image replacement based on screen size | |
| by John Weir http://famedriver.com | |
| Usage, where `*` will be replaced by the image size. | |
| <img data-src='/path-to-image/image-*.jpg' data-sizes='320:480,481:960' class='flex-image'/> | |
| Thanks to Aurélien Delogu & Molt for the inspiration -> https://github.com/pyrsmk/molt |
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
| # thank you http://www.mysqlperformanceblog.com/2008/02/04/finding-out-largest-tables-on-mysql-server/ | |
| SELECT CONCAT(table_schema, '.', table_name), | |
| CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows, | |
| CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA, | |
| CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx, | |
| CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size, | |
| ROUND(index_length / data_length, 2) idxfrac | |
| FROM information_schema.TABLES | |
| ORDER BY data_length + index_length DESC | |
| LIMIT 10; |
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
| #!/usr/bin/env ruby | |
| # Script to load GPS and CO2 data and normalize the data | |
| # the position data in a file "run.xml" | |
| # pollution in a file "pollution.txt" | |
| require 'nokogiri' | |
| require 'fastercsv' | |
| require 'active_support' |
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
| # Oh, if only this were possible. I know it is not in JS, but still would be cool | |
| z = 'a key' | |
| x = | |
| "#{z}" : 1 |
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
| class MigrateTaggings < ActiveRecord::Migration | |
| def up | |
| change_table :taggings do |t| | |
| t.references :tagger, :polymorphic => true | |
| t.string :context, :limit => 128 | |
| t.index [:taggable_id, :taggable_type, :context] | |
| end | |
| ActsAsTaggableOn::Tagging.all.each {|t| t.update_attribute :context, 'tags'} | |
| end |