Skip to content

Instantly share code, notes, and snippets.

View debuti's full-sized avatar

Borja Garcia debuti

  • Spain
View GitHub Profile
import argparse
from math import *
from dxfwrite import DXFEngine as dxf
parser = argparse.ArgumentParser(description='Generate Vogel Spiral ps file')
parser.add_argument('-p', dest='points', type=int, action='store', help='the number of points to plot', default=100)
parser.add_argument('-s', dest='radius_start', type=int, action='store', help='the radius starting length', default=0)
debuti / rclone-mount.wsf
Created June 6, 2021 22:31
rclone mount launch on boot for windows
<script language="VBScript">
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Call WshShell.Run("C:\path\to\bin\rclone\rclone mount db: B:", 0, False)
debuti /
Created September 18, 2020 15:13
Arguments printout
#!/usr/bin/env python
import os
import sys
import datetime
path=os.path.join(os.path.expanduser("~"), "Desktop", fname)
with open(path, "w") as f:
f.write(" ".join(sys.argv))
print("Wrote \"{}\" with \"{}\"".format(path," ".join(sys.argv)))
debuti /
Last active May 5, 2020 15:54
Playing around with window manager in linux

Get screen dimensions

SWIDTH=$((cd /tmp/.X11-unix && for x in X*; do DISPLAY=":${x#X}" xdpyinfo | grep dimensions; exit 0; done) | grep -oP '[0-9]+x[0-9]+(?= pixels)' | cut -f1 -dx)
SHEIGHT=$((cd /tmp/.X11-unix && for x in X*; do DISPLAY=":${x#X}" xdpyinfo | grep dimensions; exit 0; done) | grep -oP '[0-9]+x[0-9]+(?= pixels)' | cut -f2 -dx)

Current desktop

wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" "
debuti / Makefile
Last active March 30, 2020 15:48
Lamport's bakery in C
PROG = bakery
all: clean $(PROG)
$(PROG): $(PROG).c
gcc -g -o $@ -pthread -O0 $(CFLAGS) $<
-rm $(PROG)
debuti / .bashrc
Last active April 12, 2022 14:25
.gitconfig and .bashrc
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
if [ "$color_prompt" = "yes" ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
unset color_prompt
debuti /
Last active November 13, 2019 19:02 — forked from rust-play/
Rust Playground: multiple mutable references to mutexed struct fields
use std::sync::{Arc, Mutex};
pub struct Foo {
pub a: i32,
pub b: i32,
pub fn function(foo: Arc<Mutex<Foo>>){
let foo = &mut *(foo.lock().unwrap());
inner(&mut foo.a, &mut foo.b);
debuti / test.c
Last active August 5, 2019 15:22
Loop on generic type len array
#include <stdio.h>
#define LOOP_ON_GENERIC(T, A, AL, I) \
T* I = NULL; \
T** I##_p = NULL; \
if (A) \
for(I##_p = A, I = *I##_p; \
I##_p < A + AL; \
I##_p++, I = (I##_p < A + AL ? *I##_p:NULL))
debuti /
Last active August 22, 2019 07:45 — forked from alexellis/
ffmpeg time-lapse

Convert sequence of JPEG images to MP4 video

ffmpeg -r 24 -pattern_type glob -i '*.JPG' -s hd1080 -vcodec libx264 timelapse.mp4

  • -r 24 - output frame rate
  • -pattern_type glob -i '*.JPG' - all JPG files in the current directory
  • -s hd1080 - 1920x1080 resolution

Slower, better quality

#include <stdio.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#define STRFY(A) #A
#define SIZEOFI(T,MIN,MAX) printf("%-20s\t%5zu\t%20lld\t%20llu\n", STRFY(T), sizeof(T), (long long)MIN, (unsigned long long)MAX);
#define SIZEOFFP(T,MIN,MAX,RES) printf("%-20s\t%5zu\t%20Lg\t%20Lg\t%20Lg\n", STRFY(T), sizeof(T), (long double)MIN, (long double)MAX, (long double)RES);
void main() {