Skip to content

Instantly share code, notes, and snippets.

View jrbenito's full-sized avatar

Josenivaldo Benito Junior jrbenito

View GitHub Profile
@jrbenito
jrbenito / setdisplay bash function
Last active January 26, 2017 18:55
Set display variable when reconnect to a tmux terminal on a server with many users (display can change on each ssh section)
function setdisplay ()
{
USERID=$(id -u);
# list all connections by numeric (don´t wait slow DNS)
# and filter by current user´s listening ports on localhost
# that that is in the range of 6000 ~ 6999 (generally X ports)
PORTA=$(netstat -ane|grep "LISTEN "|grep "$USERID"|sort -k8n|sed -n -e "s/.*127\.0\.0\.1:6.\(..\) .*/\1/p"|tail -n 1);
export DISPLAY="localhost:$PORTA.0"
}
@jrbenito
jrbenito / .gitignore
Last active May 5, 2016 17:15 — forked from spacemonkey/.gitignore
.gitignore for Hexo powered websites
.DS_Store
Thumbs.db
db.json
*.log
node_modules/
public/
.deploy*/
@jrbenito
jrbenito / parseINI.sh
Created March 22, 2016 21:19
This code will generate bash variables like $NameParameterNameSession for each item on INI file
while IFS='= ' read var val
do
if [[ $var == \[*] ]]
then
section=$var
elif [[ $val ]]
then
declare "$var$section=$val"
fi
done < ./filename.ini
@jrbenito
jrbenito / release.sh
Last active August 23, 2016 13:35 — forked from bclinkinbeard/release.sh
Bash script to automate the Git Flow tag/release process
#!/bin/bash
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# v1.0.0, v1.5.2, etc.
versionLabel=v$1
# establish branch and tag name variables
devBranch=develop
@jrbenito
jrbenito / flukso.gs
Last active December 10, 2015 05:38
Google Apps Scripts to access Flukso.net data. This can be used in a Google Spreadsheet.
/**
* Access Flukso API server returning a JSON
*
*/
function getJSON(sensor, token, query) {
var sheetname = "test";
//var aUrl = "http://api.flukso.net/sensor/c1411c6b4f9910bbbab09f145f8533b9?version=1.0&token=d8a8ab8893ea73f768b66b45234b5c3a&interval=month&unit=watt";
var api="1.0";
var aUrl = "http://api.flukso.net/sensor/"+sensor+"?version="+api+"&token="+token+query;