[ Launch: hello ] 5205458 by jugglebird
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
| # Turning a string into a class. | |
| def class_from_string(class_string) | |
| clazz = class_string.split("::").inject(Object) { |obj, const| obj.const_get(const) } | |
| instance = clazz.new | |
| 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
| >> "day_threshold".camelize.constantize | |
| => DayThreshold | |
| >> "day_threshold".camelize.constantize.new | |
| => #<DayThreshold:0xb7a6cbd0> | |
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 Report < ActiveRecord::Base | |
| %w[hits uniques].each { |const| const_set(const.upcase, const) } | |
| 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
| var inject = function(iterable, initial, func) { | |
| var cur = initial | |
| for(var i = 0;i < iterable.length;i++) { | |
| cur = func(cur, iterable[i]) | |
| } | |
| return cur | |
| } | |
| var map = function(arr, func) { | |
| return inject(arr, [], function(memo, val) { |
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
| # Factory girl, relaxed. | |
| # | |
| # Factory.define :user do |f| | |
| # f.login 'johndoe%d' # Sequence. | |
| # f.email '%{login}@example.com' # Interpolate. | |
| # f.password f.password_confirmation('foobar') # Chain. | |
| # end | |
| # | |
| # Factory.define :post do |f| | |
| # f.user { Factory :user } # Blocks, if you must. |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <!-- SVG web to turn svg into flash for IE | |
| This might not be working on bl.ocks.org for the following reasons: | |
| 1) MIME types not added to the bl.ocks.org webserver: | |
| AddType text/x-component htc | |
| AddType application/x-shockwave-flash swf | |
| AddType image/svg+xml svg |
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
| <?xml version="1.0" encoding="utf-8"?><gexf version="1.1" | |
| xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gexf.net/ | |
| 1.1draft/viz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance"> | |
| <graph defaultedgetype="directed" mode="static"> | |
| <nodes> | |
| <node id="A" label="A" /> | |
| <node id="B" label="B" /> | |
| </nodes> | |
| <edges> |
[ Launch: Word wrap with foreignObject ] 5365132 by jugglebird[ Launch: SVG resize to containe ] 5320723 by biovisualize[ Launch: SVG resize to containe ] 5052807 by biovisualize[ Launch Inlet ]Gist #3200444
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($) { | |
| // multiple plugins can go here | |
| (function(pluginName) { | |
| var defaults = { | |
| color: 'black', | |
| testFor: function(div) { | |
| return true; | |
| } | |
| }; | |
| $.fn[pluginName] = function(options) { |
OlderNewer