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
| Element.NativeEvents['DOMNodeInsertedIntoDocument'] = 2 | |
| Element.Events['addedToDom'] = { | |
| base: 'DOMNodeInsertedIntoDocument' | |
| } |
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
| ( -> | |
| selectors = {} | |
| Array.from(document.styleSheets).each (stylesheet) -> | |
| try | |
| if stylesheet.cssRules? | |
| Array.from(stylesheet.cssRules).each (rule) -> | |
| selectors[rule.selectorText] = {} | |
| Array.from(rule.style).each (style) -> | |
| selectors[rule.selectorText][style] = rule.style.getPropertyValue(style) | |
| selectors |
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
| Number.eval = (string,size) -> | |
| Number.from(eval(String.from(string).replace /(\d*)\%/g, (match,str) -> | |
| (Number.from(str)/100)*size | |
| )) |
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 Cache2 | |
| def initialize(opts={}) | |
| options = {:expiration => 24*60*60}.merge!(opts) | |
| @exp = options[:expiration] | |
| end | |
| def [](index) | |
| if @cache[index].expired? then @cache[index].refresh end | |
| @cache[index].contents | |
| end | |
| def add(index, expires=nil, &block) |
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
| current += (current+1 > length)?-length: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
| S3Bucket = "something" | |
| def urlForS3(path) | |
| if ENV['DATABASE_URL'] | |
| "http://"+S3Bucket+".s3.amazonaws.com"+path | |
| else | |
| "/local/"+path | |
| end | |
| 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
| a = new Class | |
| Alias: | |
| log: ['warn','error'] | |
| log: (msg) -> | |
| console.log msg | |
| a.log "hello" | |
| # prints hello | |
| a.warn "warning" | |
| # prints warning |
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
| window.addEvent "domready", -> | |
| scroll = new Fx.Scroll($("content")) | |
| $$("a[href^=#]").addEvent 'click', (e)-> | |
| e.stop() | |
| el = $$("a[name=#{@get('href')[1..]}]")[0] | |
| scroll.toElement(el).chain -> window.location.hash = "#"+name |
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
| new class Highlighter | |
| entities: (s) -> | |
| s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"') | |
| highlight: (code,lang) -> | |
| map = code | |
| tokens = {} | |
| uid = 0 | |
| for a in lang | |
| code.replace a.regexp, (str) -> | |
| map = map.replace str, "§"+uid |
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
| # This will not match and empty string. | |
| register_variable_type(:required, /.+/) | |
| # Password must be at least 4 characters, no more than 8 characters, and must include at least one upper case letter, one lower case letter, and one numeric digit. | |
| register_variable_type(:password, /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$/) | |
| register_variable_type(:email, /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/) |
OlderNewer