Skip to content

Instantly share code, notes, and snippets.

Avatar

Josenivaldo Benito Junior jrbenito

View GitHub Profile
@jrbenito
jrbenito / setdisplay bash function
Last active Jan 26, 2017
Set display variable when reconnect to a tmux terminal on a server with many users (display can change on each ssh section)
View setdisplay bash function
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 — forked from spacemonkey/.gitignore
.gitignore for Hexo powered websites
View .gitignore
.DS_Store
Thumbs.db
db.json
*.log
node_modules/
public/
.deploy*/
@jrbenito
jrbenito / parseINI.sh
Created Mar 22, 2016
This code will generate bash variables like $NameParameterNameSession for each item on INI file
View parseINI.sh
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 Aug 23, 2016 — forked from bclinkinbeard/release.sh
Bash script to automate the Git Flow tag/release process
View release.sh
#!/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 Dec 10, 2015
Google Apps Scripts to access Flukso.net data. This can be used in a Google Spreadsheet.
View flukso.gs
/**
* 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;
You can’t perform that action at this time.