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 / flatten.py
Created July 13, 2018 00:51
Flatten array in Python
def flatten(arr):
resp = []
for i in arr:
if type(i) == list:
temp = flatten(i)
resp.extend(temp)
else:
resp.append(i)
return resp
@rdleon
rdleon / stopwatch.sh
Created June 2, 2017 23:40
Bash based stop watch
#!/bin/bash
# sets stdin to no echo and give a char every tenth of a sec.
# found on the internet, I don't claim ownership.
# http://www.thelinuxdaily.com/2012/03/simple-stopwatch-script/
stty -echo -icanon time 1 <&0
chkspace () {
if ! read -t 0 ; then return 1 ; fi # no char pressed
@rdleon
rdleon / liblist.c
Last active April 22, 2017 21:47
liblist: Simple Queue+Stack for C
/*
* liblist.c
* A simple list library that implements Queue and Stack behavior
*/
#include <stdlib.h>
struct Node {
void *value;
struct Node *next;
struct Node *previous;
@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
#!/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 / 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;
@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 / 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 / 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
#include <avr/io.h>
#include <util/delay.h>
void spi_init(void)
{
/*
* PB0: RST
* PB2: CS #1
* PB3: MOSI
* PB4: MISO