Skip to content

Instantly share code, notes, and snippets.

View elhoyos's full-sized avatar

Juan Hoyos elhoyos

View GitHub Profile
@elhoyos
elhoyos / gist:42d88b1104ab198599986c95c7439122
Last active December 17, 2016 16:44
House electricity controller
I want to leave electronics plugged in the outlets without worrying about they're using unnecessary electricity.
Idea:
Place an electricity controller in-between the breakers and the rest of the wires going to the outlets.
This controller will serve as a relay switch that let current pass in certain conditions (e.g. time of the day, demand, etc).
I don't need the switching mechanism to be per outlet. Usually, breakers distribution are well made and a relay for every breaker will do just fine for my needs. During the day all house outlets should be off minus the one affecting the fridge. Rest of them I want them to be turned on, initially, by demand.
What's out there?
Home Automation outlets
Smart outlets
@elhoyos
elhoyos / foo.sh
Created November 21, 2016 04:42
cat a remote file and print first column only if matches
ssh host "cat file.log" | awk -v re="*" '$0 ~ re {print $1}'
@elhoyos
elhoyos / clear_history.sh
Created May 21, 2016 03:39
Clear history and exit
$ cat /dev/null > ~/.bash_history && history -c && exit
@elhoyos
elhoyos / utils.sql
Last active April 27, 2016 15:17
Postgres useful commands
-- Stop query
SELECT pg_cancel_backend(pid of the postgres process);
-- Get the type of the column
SELECT pg_typeof(column);
-- Get locks on 'relation'
SELECT locks.relation::regclass,
locks.mode,
@elhoyos
elhoyos / restart-forever-processes.sh
Created September 23, 2015 18:01
Restart all the forever list processes
$ ssh server "forever list | awk 'NR <= 2 {next} \$3 "\!"~ /something-i-dont-want/ {print \$3}' | xargs -L1 forever restart"
@elhoyos
elhoyos / log_with_bunyan.js
Last active July 9, 2016 22:13
Bunyan logging
var bunyan = require('bunyan');
var logger = bunyan.createLogger({
name: 'myapp',
serializers: bunyan.stdSerializers
});
// When using standard serializers, an Error object can be passed in "err"
logger.fatal({err: new Error('Something wrong'), payload: payload}, 'Ooops');
// The simplest
@elhoyos
elhoyos / gist:21ed2beccf6e5e088881
Created July 6, 2015 22:22
Kill all node processes
$ kill -9 `ps -ef | grep oraxpo | grep -v grep | awk '{print $2}'`
@elhoyos
elhoyos / gist:dc4ce4506f75ff896626
Created June 19, 2015 16:28
Disable ssh host key verification
ssh user@host -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
@elhoyos
elhoyos / gist:a3a75969ec01370e6ae3
Created May 22, 2015 00:21
Update specific number of jobs and return their ids
-- In psql
UPDATE jobs
SET isRunning = true
WHERE
id IN (
SELECT id
FROM jobs
WHERE
providerid = "foo" AND
@elhoyos
elhoyos / gist:df5e96b28694bf23d292
Created January 19, 2015 02:48
Measure webserver's response time with wget
time wget http://www.aip.im -q --output-document=/dev/null
# See more at: http://www.aip.im/2012/05/how-to-measure-web-sites-response-time-with-wget/#sthash.rNHN1Dyp.dpuf