Skip to content

Instantly share code, notes, and snippets.

View dinigo's full-sized avatar

Daniel Iñigo dinigo

View GitHub Profile
# Store and retrieve an uuid as if it was a cookie
function get_uuid() {
local client_id_file=${1:-$HOME/.uuid}
local client_id=""
if [[ -f $client_id_file ]]; then
client_id=$(cat $client_id_file)
else
client_id=$(od -x /dev/urandom | head -1 | awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}')
echo "$client_id" > $client_id_file
@dinigo
dinigo / tryout.js
Last active May 18, 2017 17:22
Very basic timeoutCheck based javascript data watcher
w = 2;
var watcher = new Watcher(
'utag.handler.iflag',
function(name, o, n, t){
console.log('name: ' + name + ' old: ' + o + ' new: ' + n);
if(n === 1){
clearTimeout(t);
console.log('exito');
}
},
@import url('https://fonts.googleapis.com/css?family=Roboto');
body {
background: #e2e1e0;
text-align: center;
}
.card {
padding: 16px;
font-family: 'Roboto', sans-serif;
background: #fff;
@dinigo
dinigo / .vimrc
Last active December 22, 2016 10:04
Current virmc
set nocompatible " desabilita compatibilidad con vi
filetype off " desactiva reconocimiento de archivo por el momentoju
" añade Vundle al runtime para poder ejecutarlo
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" repositorio de vundle para comprobar las propias actualizaciones
Plugin 'VundleVim/Vundle.vim'
@dinigo
dinigo / build.sh
Last active August 4, 2016 11:54
Build a docker image, spinn it and connect to an inside prompt.
#!/bin/bash
USER=$(whoami)
EXPOSE=3000
CONTAINER=$(basename $(pwd))
[ -d node_modules ] && rm -rf node_modules
if grep -q $CONTAINER <<< $(docker ps -a); then
echo detiene el contenedor
docker stop $CONTAINER
@dinigo
dinigo / build.sh
Created August 4, 2016 11:31
Build a docker image, spinn it and connect to an inside prompt.
#!/bin/bash
USER=$(whoami)
EXPOSE=3000
CONTAINER=$(basename $(pwd))
[ -d node_modules ] && rm -rf node_modules
if grep -q $CONTAINER <<< $(docker ps -a); then
echo detiene el contenedor
docker stop $CONTAINER
@dinigo
dinigo / banksel.asm
Last active December 14, 2015 16:40
Exercices for a PIC programming subject at University
;________________________________________________________________________
; Selects the bank the variable is in before operating with it.
;
; The 'banksel' directive is a macro that MPASM assembles changing the
; bits RP from the STATUS register.
;
; As there are 4 banks, if this is not performed, data will be written
; in te wrong bank
;________________________________________________________________________
#include "p16F877.inc"
@dinigo
dinigo / for-loop.asm
Created October 30, 2015 17:30
Collection of usefull assembly loops and functions
;=====================================================;
; This piece of code runs certain times depending on ;
; how many nested loops you create. Each loop can ;
; count up to 255. ;
; We declare a variable for each loop and preload ;
; them with the default value (maxium FFh or 255d ;
; For demonstration purposes we're using just 3 ;
; nested loops executing a total of 845.325 times ;
;=====================================================;
@dinigo
dinigo / split.py
Last active August 29, 2015 14:21
Split pdf pages wich contains slides so that every page contains just one slide. It only works with two slides per page, either horizontal or vertical.
#!/usr/bin/env python
# Based on http://unix.stackexchange.com/a/12483
# To use it you have to give it execution privilleges
# with the command:
# chmod u+x split.py
# Then you can use it like this:
# ./split.py <slides.pdf >split.pdf
import copy, sys
from pyPdf import PdfFileWriter, PdfFileReader
@dinigo
dinigo / addmediauser.sh
Created January 12, 2015 19:05
Add a user, with a home directory but without shell access, to the Samba and Time Machine services
#!/bin/sh
# Call this script as root like:
# ./addmediauser.sh myusername mypassword
# Password will be shown in plain text (obviously)
# so watch out for shoulder surfers!
USERNAME=$1
PASSWORD=$2
useradd --create-home --groups samba timemachine --shell /bin/false $USERNAME