Skip to content

Instantly share code, notes, and snippets.

View mgdelacroix's full-sized avatar
🎧
Working from home

Miguel de la Cruz mgdelacroix

🎧
Working from home
View GitHub Profile
@mgdelacroix
mgdelacroix / gogs.conf
Created September 11, 2014 16:34
gogs supervisor file
[program:gogs]
command=/home/<GOGS-USER>/gogs/gogs web
autostart=true
user=<GOGS-USER>
directory=/home/<GOGS-USER>/gogs
environment=HOME="/home/<GOGS-USER>",USER="<GOGS-USER>"
graph = {
("A", "yes"): "B",
("A", "no"): "C",
}
accepted_states = ("B", "C")
transitions = {
@mgdelacroix
mgdelacroix / decorator_with_arguments.py
Last active August 29, 2015 14:07
Basic example of a python decorator with arguments applied to a class method
def log(log_name):
def decorator(func):
def inner(self, nombre):
print("[%s] Logging a call to %s" % (log_name, func.__name__))
return func(self, nombre)
return inner
return decorator
class Persona:
### Keybase proof
I hereby claim:
* I am mgdelacroix on github.
* I am mcrx (https://keybase.io/mcrx) on keybase.
* I have a public key whose fingerprint is 02C3 D31C DAEB 9EAE ED10 EC99 FF33 E166 37E2 E649
To claim this, I am signing this object:
@mgdelacroix
mgdelacroix / jwt-test.groovy
Last active June 6, 2019 13:19
Simple script testing JWT with groovy
@Grab("io.jsonwebtoken:jjwt:0.4")
import io.jsonwebtoken.Jwts
import static io.jsonwebtoken.SignatureAlgorithm.HS256
def key = "2193872103019283092174917"
def token = Jwts.builder()
.setSubject("Hello World")
.signWith(HS256, key)
const NoSuchElementException = new Error("No such element exception");
class Optional<T> {
value: T;
constructor(value: T) {
this.value = value;
}
@mgdelacroix
mgdelacroix / noip.service
Last active February 2, 2018 04:55
noip2 systemd service file
[Unit]
Description=No-IP Dynamic DNS Update Client
After=network.target
[Service]
Type=forking
Restart=always
ExecStart=/usr/local/bin/noip2
[Install]
@mgdelacroix
mgdelacroix / ytdw.go
Last active January 31, 2017 11:24
Small program to read a file and use youtube-dl to download the urls contained in it
package main
import (
"fmt"
"io/ioutil"
"os/exec"
"strings"
)
func check(e error) {
@mgdelacroix
mgdelacroix / gogs-vbox.nix
Created November 6, 2017 12:27
Example VirtualBox VM with nginx and gogs
{
gogs =
{ config, pkgs, ... }:
{
deployment.targetEnv = "virtualbox";
deployment.virtualbox.memorySize = 512;
deployment.virtualbox.vcpu = 2;
deployment.virtualbox.headless = true;
};
}
@mgdelacroix
mgdelacroix / index.js
Created August 16, 2018 10:27
Simple proof of concept for nodejs SIGINT capture
let waiting = false
process.on('SIGINT', () => {
console.log('CTRL+C detected!')
if (!waiting) {
waiting = true
} else {
console.log('Was waiting, so exiting now')
process.exit(0)
}
setTimeout(() => process.exit(0), 2000)