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 'uri' | |
| address = '335 Rue Saint-Joseph Est, Quebec City, QC' | |
| marker_color = '4fc27d' | |
| args = { | |
| markers: "color:0x#{marker_color}|#{address}", | |
| size: '640x330', | |
| zoom: 14, | |
| language: 'en', |
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
| doThis = (deferrer) -> | |
| # do some JS nifty things | |
| deferrer.done('foo', 'bar') | |
| doThat = (deferrer) -> | |
| # Have callbacks/timeouts/async? Sure! | |
| setTimeout -> | |
| deferrer.done('foozle', 'barzle') | |
| , 5000 |
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> | |
| <meta charset="utf-8"> | |
| <title>Modular DOMReady</title> | |
| </head> | |
| <body> | |
| <header></header> | |
| <section role="main"> |
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 handleRequest = function(data) { | |
| postMessage(data) | |
| } | |
| addEventListener('message', function(e) { | |
| var xhr = new XMLHttpRequest | |
| xhr.open('GET', e.data) | |
| xhr.onreadystatechange = function(e) { | |
| if (xhr.readyState === 4 && xhr.status === 200) { | |
| handleRequest(xhr.responseText) |
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 javascript_content(file_name) | |
| Rails.application.assets[file_name].source.html_safe | |
| 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
| // Works with Zepto/jQuery | |
| $.fn.one_for_all = function(type, callback) { | |
| var $all = $(this) | |
| $all.on(type, function(e) { | |
| $all.off(type) | |
| callback(e) | |
| }) | |
| } |
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
| // Works with Zepto/jQuery | |
| $.fn.add_at_index = function(content, index) { | |
| if (index < 0) { index = 0 } | |
| this.each(function() { | |
| var $this = $(this) | |
| var $child = $this.children().eq(index) | |
| if ($child.length) { return $child.before(content) } | |
| $this.append(content) |
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 image_container(path, width, height) | |
| %(<div class="image-container" style="max-width: #{width}px"> | |
| <div style="padding-top: #{(height.to_f / width.to_f) * 100}%"> | |
| #{image_tag(path)} | |
| </div> | |
| </div>).html_safe | |
| end | |
| # Note: If you want the image to scale up, remove the `max-width` |
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
| # Rdio console: http://rdioconsole.appspot.com | |
| # Get a track: http://rdioconsole.appspot.com/#keys%3Dt[INSERT 7 DIGITS NUMBER HERE]%26method%3Dget | |
| def get_random_number | |
| 1_000_000 + Random.rand(10_000_000 - 1_000_000) | |
| end | |
| track_key = get_random_number | |
| puts track_key |
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
| tabname() { printf "\e]1;$1\a" } |