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
| 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 |
| <!-- | |
| 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> |
| // 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 |
| # 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" }, |
| # 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 |
| # 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: | |
| # |
| 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 |
| #! /usr/bin/ruby | |
| # jsdl | |
| # | |
| # download js libraries for you | |
| # | |
| # usage: jsdl jquery | |
| # configs |
| # 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 |