Skip to content

Instantly share code, notes, and snippets.

View leandroh's full-sized avatar
:shipit:
To deploy or not to deploy?

Leandro Pará leandroh

:shipit:
To deploy or not to deploy?
View GitHub Profile
Just in case anyone is directed to this page, rather than doing some horribly convoluted solution, the following will work on most systems (even ones that dont have bc and perl) - eg many small devices running busybox.
As ahh said - 'awk' is probably your best friend here:
# Return the value of an operation
float_val() {
echo | awk 'END { print '"$1"'; }'
}
@leandroh
leandroh / compare_decimal_maior.sh
Created March 18, 2014 11:46
Comparacao de numeros decimais
#
# Comparacao de numeros decimais
# ------------------------------------------------------------
#
# Verifica se o primeiro parametro e' maior que o segundo.
#
# Exemplo simples com retorno true/false (0/1):
#
# x=1.1.2
# y=1.0.2
@leandroh
leandroh / portable_shebang.sh
Created March 18, 2014 17:44
this script is more portable than #!/bin/bash
#!/usr/bin/env /bin/sh
@leandroh
leandroh / list_modules.sh
Last active August 29, 2015 13:57
List all modules from the Linux Kernel
#!/usr/bin/env /bin/sh
ls /lib/modules/`uname -r`/kernel/drivers
@leandroh
leandroh / rtc
Last active August 29, 2015 13:57
real time clock in linux
# Real Time Clock (RTC) Drivers for Linux: https://www.kernel.org/doc/Documentation/rtc.txt
cat /proc/driver/rtc
# ----------------------------------------x----------------------------------------
echo rtc-pcf8563 0x51 /sys/class/i2c-adapter/i2c-1/new_device
# ----------------------------------------x----------------------------------------
@leandroh
leandroh / gist:9673608
Created March 20, 2014 20:55
read from I2C/SMBus chip registers
i2cget -f -y 1 0x51 0x00
@leandroh
leandroh / remove_all_except_one.sh
Created April 2, 2014 13:29
remove all files except any one
#!/usr/bin/env /bin/sh
find . ! -name 'except_this' -delete
@leandroh
leandroh / street_address.js
Last active August 29, 2015 13:59
simple matching group using regular expressions for verifying street addresses
var re = /(.*)\, (.*)\, (.*)/;
var str = "Rua tal, 200, Pato Branco";
var newstr = str.replace(re, "$2");
console.log(newstr);
@leandroh
leandroh / token.py
Created May 14, 2014 14:08
oauth token
import urllib2
url = "http://api.example.com"
req = urllib2.Request(url)
req.add_header("Accept", "application/json")
req.add_header("Content-Type", "application/x-www-form-urlencoded")
req.add_header("Authorization", "Bearer 591768b9-a3ad-443c-a60c-33ccdabb6cce")
res = urllib2.urlopen(req)
@leandroh
leandroh / index.html
Created June 13, 2014 20:18
CSS3 2d transforms
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>html 5 minimal skeleton</title>
<style type="text/css">
body {
padding: 40px;
}
.left-side-0 {