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
| # gist: https://gist.github.com/4192325 | |
| # Calcolare quali sono gli anni con piu' giorni festivi [ruby 2.0 Enumerable#lazy] | |
| require 'date' | |
| ETERNITY = Float::INFINITY | |
| FESTE = [ | |
| { day: 1, month: 1, name: "Capodanno" }, | |
| { day: 6, month: 1, name: "Epifania" }, |
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
| // It works on a single song page like: http://soundcloud.com/halfwsr/ultra-sta-bad-insect-willow-st | |
| function play() { | |
| setTimeout(function(){ | |
| $(".haudio.large .play").click() | |
| },100) | |
| } | |
| function stopped() { | |
| return $(".haudio.large .playhead").width() == 0 |
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
| <!-- | |
| How to use Google JS Visualization Api offline, step by step | |
| this approach might work with other libraries loaded with google.load, after all it's still JavaScript!!! | |
| --> | |
| <!DOCTYPE html> | |
| <html> |
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 'net/ssh' | |
| require 'ipaddr' | |
| USER = "makevoid" | |
| PASS = File.read File.expand_path("~/.password") | |
| IPS = "192.168.0.0/24" | |
| def pings?(host) | |
| `ping -q -t 1 -c 1 #{host}`; | |
| $?.exitstatus == 0 |
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
| # http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically | |
| def hsv_to_rgb(h, s, v) | |
| h, s, v = h.to_f/360, s.to_f/100, v.to_f/100 | |
| h_i = (h*6).to_i | |
| f = h*6 - h_i | |
| p = v * (1 - s) | |
| q = v * (1 - f*s) | |
| t = v * (1 - (1 - f) * s) | |
| r, g, b = v, t, p if h_i==0 | |
| r, g, b = q, v, p if h_i==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
| map = %Q{ | |
| function() { | |
| emit(this.name, { deployments: this.deployments }) | |
| } | |
| } | |
| reduce = %Q{ | |
| function(key, values) { | |
| var result = {} | |
| values.forEach(function(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
| var parser = document.createElement('a'); | |
| parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
| parser.protocol; // => "http:" | |
| parser.hostname; // => "example.com" | |
| parser.port; // => "3000" | |
| parser.pathname; // => "/pathname/" | |
| parser.search; // => "?search=test" | |
| parser.hash; // => "#hash" | |
| parser.host; // => "example.com:3000" |
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
| { | |
| "name": "Thorrents (hosted)", | |
| "description": "Thor agrees!", | |
| "version": "1.2", | |
| "manifest_version": 2, | |
| "app": { | |
| "urls": [ | |
| "http://thorrents.com/" | |
| ], | |
| "launch": { |
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
| # simple scrape example with mechanize | |
| # | |
| # setup: gem install mechanize | |
| require 'mechanize' | |
| agent = Mechanize.new | |
| agent.user_agent = "Mac Firefox" | |
| host = "http://livescore.com/soccer/italy" |
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
| # encoding: utf-8 | |
| text = <<-LOL | |
| <!DOCTYPE html> | |
| <html class='no-js' lang='en'> | |
| <head> | |
| <meta charset='utf-8'> | |
| <title>5apps</title> | |
| <meta content='Deployment and distribution tools for HTML5 app developers' name='description'> | |
| <meta content='width=device-width, minimum-scale=1.0, maximum-scale=1.0' name='viewport'> |