Skip to content

Instantly share code, notes, and snippets.

View makevoid's full-sized avatar

Francesco 'makevoid' Canessa makevoid

View GitHub Profile
@makevoid
makevoid / ping_and_ssh_subnet.rb
Created October 25, 2012 17:46
Ping and SSH test all hosts in a given subnet
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
@makevoid
makevoid / gchart_offline.html
Created November 2, 2012 10:09
GChart offline example
<!--
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>
@makevoid
makevoid / looplay_soundcloud.js
Created November 2, 2012 21:13
Loop play Soundcloud
// 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
@makevoid
makevoid / holidays_lazy.rb
Created December 3, 2012 02:59
Calculate years with most holidays (ITA) using Ruby2.0 Enumberable#lazy
# 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" },
@makevoid
makevoid / Readme.md
Created December 14, 2012 02:51
use Mechanize persisting the cookie jar

EptiMecha

example on how to use mechanize with cookie jars, basically:

agent.cookie_jar.save_as "cookies.yml"
agent.cookie_jar.load "cookies.yml"

to try it:

  • download this zip
@makevoid
makevoid / obfuscator.rb
Created February 12, 2013 16:50
Script to replace sensible database datas
# obfuscates the db removing sensible values
# ruby obfuscate.rb
# mysqldump -u root gbc > gbc_safe.sql
# tar cvfz gbc_safe.tgz gbc_safe.sql
require 'bundler/setup'
Bundler.require :default
class Obfuscate
@makevoid
makevoid / mhash.rb
Last active December 14, 2015 19:59
Mhash: defines accessors methods for each hash key
# Mhash
#
# defines accessors methods for each hash key
#
#
# why?
# to enhance syntactic sugar and to let the refactoring transition to a real object easier
#
# usage:
#
@makevoid
makevoid / app_delegate.rb
Last active December 15, 2015 06:09
Hello (UIViewController) world - RubyMotion
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
player_controller = MainController.alloc.init
window = UIWindow.alloc.initWithFrame UIScreen.mainScreen.bounds
window.rootViewController = player_controller
window.rootViewController.wantsFullScreenLayout = true
window.makeKeyAndVisible
true
end
end
@makevoid
makevoid / jsdl.rb
Created April 3, 2013 11:53
jsdl - Javascript Libraries Downloader
#! /usr/bin/ruby
# jsdl
#
# download js libraries for you
#
# usage: jsdl jquery
# configs
@makevoid
makevoid / lapse_rename.rb
Created May 4, 2013 17:06
Time lapse tools
# run ruby lapse_rename.rb
# then:
# avconv -f image2 -i lapse_%04d.jpg -s hd1080 -threads 8 out.mp4
files = Dir.glob("*.JPG")
files.sort.each_with_index do |file, idx|
idx += 1