Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
GW=`/sbin/ip route list | grep default | awk '{print $3}'`
if ping -c 2 $GW | grep -o Unreachable; then
echo down;
echo `date`": reconnected to wlan" >> /var/log/wlan0-detail
ifdown wlan0
sleep 5
ifup wlan0
fi
@fermuch
fermuch / loop.rb
Created March 10, 2013 03:48
stop loop in ruby
5.times do |i|
puts i
break if i == 3
end
@fermuch
fermuch / test.opal.rb
Created February 6, 2013 15:31
Testing Opal with Opal-JQuery :)
class Vehicle
attr_accessor :name, :wheels
end
class Car < Vehicle
def initialize(name)
self.name = name
self.wheels = 4
end
end
var MIN_CHROME_VER = 24;
if(parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2]) >= MIN_CHROME_VER){
// el loco sabe y usa chrome!
$('#alert').hide();
}
@fermuch
fermuch / hexconverter.js
Created January 17, 2012 13:58
Library for Hexadecimal working with Javascript. I based this on a lib that I found in a blog, but I don't remember the blog, so I'm sorry.
var HexConverter = {
hexDigits : '0123456789ABCDEF',
dec2hex : function( dec )
{
return( this.hexDigits[ dec >> 4 ] + this.hexDigits[ dec & 15 ] );
},
hex2dec : function( hex )
{
@fermuch
fermuch / main.py
Created August 27, 2011 05:40
Script para obtener resultados de Arduino
# -*- coding: utf-8 -*-
import sys
import time
from commands import getoutput
from arduino import Arduino
# definir dispositivo
out = getoutput("ls /dev/ | grep -i ttyUSB").split()
class MiClase:
a = 0
b = 13
def asd (b):
b = b
self.a = b
return self.a + " y " + self.b
@fermuch
fermuch / arduinotest.py
Created August 23, 2011 10:05
Arduino Test
# -*- coding: utf-8 -*-
import sys
import time
from commands import getoutput
from arduino import Arduino
out = getoutput("ls /dev/ | grep -i ttyUSB").split()
try:
out[0]