Skip to content

Instantly share code, notes, and snippets.

View rdleon's full-sized avatar

Rafael Díaz de León rdleon

View GitHub Profile
@rdleon
rdleon / path.js
Created October 28, 2011 19:09
Gets an array of tree paths and populates a tree.
/* This function needs that the path arrays invoke the function
* in order, else it will duplicate some nodes
*/
function populate(tree, path) {
var node = {};
var label = path.shift();
var p_node = tree[tree.length - 1] || {};
if (!tree.length || p_node.label != label) {
node.label = label;
@rdleon
rdleon / gist:4739992
Created February 8, 2013 16:08
Sample of a quick and dirty jquery plugin for drawing comments
/*
* Copyright (c) 2012 R. Diaz de Leon <leon@elinter.net>
*
* comments.js
* ver 5.0a
*
* Requires:
* jQuery
*
* Use:
@rdleon
rdleon / comment.js
Created February 8, 2013 16:29
Old community script, messy and impolite.
/* comments.js
* ver 3.0
* Requires jQuery
*
* Use:
* comments.init( options );
*
* Options:
* selector: <jquery_selector>
*/
#include <avr/io.h>
#include <util/delay.h>
void spi_init(void)
{
/*
* PB0: RST
* PB2: CS #1
* PB3: MOSI
* PB4: MISO
@rdleon
rdleon / convert.sh
Created November 8, 2015 20:01
Get right side audio with avconv
#!/bin/sh
for i in *.flac; do
avconv -y -i "${i}" -filter_complex 'channelsplit=channel_layout=2[FL][FR]' -map '[FL]' "instrumental/${i}" -map '[FR]' /tmp/tmp.flac
done
@rdleon
rdleon / tomates.sh
Created March 8, 2017 06:23
Quick shell pomodoro timer
#!/bin/sh
title="tomates"
pomodoro=25m
rest=5m
for i in `seq 3`; do
echo "Work Time"
sleep $pomodoro
notify-send $title "Take a short rest"
@rdleon
rdleon / friday.sh
Last active March 10, 2017 22:32
It's friday night and you don't have a care in the world
#!/bin/sh
if [ $EUID -ne 0 ]; then
echo "Run it as root, you silly goose!"
exit 1
fi
for dir in $(find / -name .git -type d); do
cd $dir/..
git add *
@rdleon
rdleon / queue.c
Last active May 4, 2023 11:50
A simple queue implementation in C
#include <stdlib.h>
#include "queue.h"
static struct Node {
void *value;
struct Node *next;
};
struct Queue {
int size;
#!/bin/bash
dev0=eth0
vpnconf="forticlient"
nameserver="8.8.4.4"
runfile="/var/run/vpnc.pid"
if [ $(id -u) != "0" ]
then
echo "Must be run as root" >&2
@rdleon
rdleon / vimrc
Created March 30, 2017 17:51
Vim configuration
execute pathogen#infect()
syntax on
set smartindent
colorscheme monochrome
autocmd FileType html setlocal smartindent expandtab shiftwidth=2 tabstop=2
autocmd FileType yaml setlocal smartindent expandtab shiftwidth=2 tabstop=2
autocmd FileType javascript setlocal smartindent expandtab shiftwidth=4 tabstop=4