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 lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>postMessage</title> | |
| </head> | |
| <body> | |
| <div id="container"> | |
| iFrame | |
| <button>post message</button> |
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
| # the common thinking when you are transforming some data to a non-nil value is use map | |
| a = { foo: 'bar', bar: 'baz' } | |
| [:foo, :bar, :baz, :foobar].map { |k| a[k] } | |
| # => ['bar', 'baz', nil, nil] | |
| # to drop nil cases | |
| [:foo, :bar, :baz, :foobar].map { |k| a[k] }.compact | |
| # => ['bar', 'baz'] |
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 | |
| require 'socket' | |
| test_file = ARGV[0] | |
| socket = UNIXSocket.new('testing.sock') | |
| socket.write(test_file) | |
| socket.close_write |
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
| #!/bin/bash | |
| # Run the script as root user | |
| # | |
| # copy the script to the /root and chmod +x to the file. | |
| # | |
| # $ ./rbenv-install-system-wide.sh | |
| # | |
| # and wait |
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 quotes = [{ symbol: 'MSFT', price: 27.01 }, | |
| { symbol: 'INTC', price: 21.75 }, | |
| { symbol: 'MSFT', price: 27.96 }, | |
| { symbol: 'MSFT', price: 31.21 }, | |
| { symbol: 'INTC', price: 22.54 }, | |
| { symbol: 'INTC', price: 20.98 }, | |
| { symbol: 'MSFT', price: 30.73 }] | |
| function priceIncrease(w) { | |
| return w[1].price / w[0].price - 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
| # gem install mar | |
| # this only checks at runtime, so it doesn't verify the type at compilation | |
| require 'mar' | |
| def type_check(type, value) | |
| value.is_a?(type) or raise "#{value} is not type of #{type}" | |
| end | |
| def type_signature(*types) |
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
| /* Performs a pooling with a timeout limit and throttle frequency. | |
| fn - a function that returns a promise of an async computation | |
| timeout - time in milliseconds to cancel pooling (default 10s) | |
| throttle - the minimumm time between pollings | |
| Use throttle if the async computation is too fast and you want | |
| that occurrances happens in intervals. | |
| */ | |
| var polling = function(fn, timeout, throttle) { |
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
| # a2enmod headers expires | |
| SetEnv no-gzip | |
| <LocationMatch "^/assets/.*\.(css|js)$"> | |
| RewriteEngine on | |
| # Make sure the browser supports gzip encoding before we send it, | |
| # and that we have a precompiled .gz version. | |
| RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b |
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>Hello world</title> | |
| <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.3.0/pure-min.css"> | |
| </head> | |
| <body> | |
| <div class="pure-g-r" id="layout"> | |
| <div class="pure-u-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
| (function(window, $) { | |
| var containers = []; | |
| // Public: position a container overlayed close to the target | |
| // | |
| // container - the container id | |
| // callback - a function callback that receives 'container' and 'target' | |
| // | |
| // Examples | |
| // |