Skip to content

Instantly share code, notes, and snippets.

@eusonlito
eusonlito / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@eusonlito
eusonlito / hdd-wakeup.sh
Last active December 4, 2015 11:59
Used on Raspberry Pi installation to avoid access problems with sleep and energy save policies. Installed as cron every minute.
#!/bin/bash
# crontab -e
# * * * * * /root/scripts/hdd-wakeup.sh >> /root/logs/hdd-wakeup.log 2>&1
devices=$(mount -l | grep -o '/dev/sd[a-z][0-9]')
if [ "$devices" == "" ]; then
echo "$(date "+%Y-%m-%d %H:%M:%S") No HDD mounted"
exit 1
@eusonlito
eusonlito / svn-add.sh
Last active December 12, 2015 08:48
Add all new files (no directories) to the next svn commit
#! /bin/sh
add=`svn status |\
grep ? |\
grep '\.[a-z]\{2,4\}$' |\
grep -v '\.sql$' |\
grep -v '\.sh$' |\
grep -v '\.gz' |\
grep -v '\.tar' |\
grep -v '\.swp' |\
@eusonlito
eusonlito / svn-del.sh
Created February 9, 2013 17:43
Remove from svn repository all deleted files
#! /bin/sh
del=`svn status | grep ! | grep -v localhost | awk -F' ' '{print $2}'`
if [ "$del" != '' ]; then
svn del $del
fi
#!/bin/bash
echo ''
case "$1" in
'bootstrap')
alias="$1"
url='https://github.com/twbs/bootstrap/trunk/dist'
;;
'fontawesome'|'font-awesome')
@eusonlito
eusonlito / generate-bootanimation
Last active January 2, 2016 11:49
Bulk pictures processing to fit it into a canvas
#!/bin/bash
# Put this file into a folder with PNG pictures with transparent background
# ----- Default values ----- #
ext='.png' # Original pictures have this extension
prefix='frame-' # Final pictures name with this prefix
background='white' # Final pictures background color
padding=100 # Do not fit to max width/height, leave some padding
@eusonlito
eusonlito / goaccess.sh
Last active September 27, 2016 11:01
Goaccess install into Ubuntu Xenial
# Add goaccess repository
echo "deb http://deb.goaccess.io/ xenial main" > /etc/apt/sources.list.d/goaccess.list
# Add repository keys
gpg --keyserver keyserver.ubuntu.com --recv-key 742483B7B222C443
gpg -a --export 742483B7B222C443 | apt-key add -
# Update apt
apt-get update
#include <EEPROM.h> // libreria para gardar datos na eeprom
#include <OneWire.h> // libreria para comunicación do sensor de temperatura
#include <DallasTemperature.h> // libreria do sensor de temperatura
#include <NewPing.h> // libreria do sensor de ultrasonidos
#include <LiquidCrystal.h> // libreria das pantallas lcd
#include <Wire.h> // libreria para comunicacións
#include "RTClib.h" // libreria do reloxo
#define TRIGGER_PIN 7 // pin do Arduino conectado á patilla Trigger do sensor de ultrasonidos
#define ECHO_PIN 6
@eusonlito
eusonlito / ubuntu-kernel-update.bash
Last active November 24, 2016 19:26
Download and install last kernel deb packages from http://kernel.ubuntu.com/~kernel-ppa/mainline
#/bin/bash
e() {
echo ""
echo "$1"
echo ""
}
if [ "$(whoami)" != "root" ]; then
e "Only allowed for root"
@eusonlito
eusonlito / reload-location-send-form.js
Last active October 1, 2017 11:27
Refresh document HTML and send an existing form without reload window.
setInterval(function() {
var formId = ''; // Form ID to send
var interval = 120; // Seconds
var xhr;
function log(message) {
console.log(new Date(), message);
}
function ajax(method, url, data, callback) {