Skip to content

Instantly share code, notes, and snippets.

View darccio's full-sized avatar
🏠
Working from home

Dario Castañé darccio

🏠
Working from home
View GitHub Profile
@darccio
darccio / so-cutter.go
Created December 28, 2011 17:57
Solution for question "Reading image from HTTP request's body in Go" at SO
package main
import (
"fmt"
"http"
"io"
)
var client = http.Client{}
@darccio
darccio / pearson-hashing.c
Last active April 11, 2023 13:14
Pearson hashing (just for fun). Includes Ruby and Golang versions for RFC 3074 and original variants.
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
/*
* Pearson hashing (from Wikipedia)
*
* Pearson hashing is a hash function designed for fast execution on processors with 8-bit registers.
* Given an input consisting of any number of bytes, it produces as output a single byte that is strongly
* dependent on every byte of the input. Its implementation requires only a few instructions, plus a
@darccio
darccio / lean-vagrant-box.md
Last active December 14, 2015 16:09
My vagrant base box.
@darccio
darccio / why.md
Created May 22, 2013 22:05
Why Eclipse is "unable to resolve target 'android-X' until the SDK is loaded"?
Unable to resolve target 'android-X' until the SDK is loaded

If you find this cryptic error in your Eclipse while working with a new cloned project, you must update your SDK through Android SDK Manager and install ADT's last version through Eclipse update.

Note: in "Preferences window > Android" appears a more clear message.

This Android SDK requires Android Developer Toolkit version 22.0.0 or above. Current version is 21.0.1.v201212060256-543035. Please update ADT to the latest version.

@darccio
darccio / ytff.sh
Created August 21, 2014 21:00
How to broadcast to Youtube Live using ffmpeg (only audio with still image)
mkfifo $pipe
cat $pipe | ffmpeg -y
-loop 1 -i cover.png
-i pipe:0
-c:v libx264 -preset ultrafast -pix_fmt yuv420p -minrate 6000k -maxrate 6000k -bufsize 12000k -b:v 6000k
-r 30 -g 30 -keyint_min 60 -x264opts "keyint=60:min-keyint=60:no-scenecut"
-s 1920x1080 -tune zerolatency
-b:a 128k -c:a aac -ar 48000
-strict experimental
-f flv rtmp://a.rtmp.youtube.com/live2/$broadcast_id
@darccio
darccio / ansible_vagrant_facts.sh
Created October 31, 2014 21:37
ansible setup for Vagrant box
# list all your box's facts
ansible -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory all -m setup --private-key=~/.vagrant.d/insecure_private_key -u vagrant
@darccio
darccio / pci_dss.md
Created October 13, 2015 07:09 — forked from diyan/pci_dss.md
PCI DSS. Useful resources
from copy import copy
import random
import numpy
import math
def generate_candidates(length, gender_quota):
k = 0
results = {}
quota = int(math.ceil(length * gender_quota / 100))
for i in xrange(length):
@darccio
darccio / mnt-data.mount
Created August 15, 2017 14:53
Post-provision initial setup for Scaleway's Debian Stretch image
[Unit]
Description=Mount Data Volume at boot
[Mount]
What=UUID="$(blkid)"
Where=/mnt/data
Type=ext4
Options=defaults
[Install]
@darccio
darccio / pidshield.sh
Last active August 23, 2017 22:15
PID Shield: protect your commands against parallel execution
#!/bin/bash
##
## PID Shield: protect your commands against parallel execution
##
## Author: Dario Castañé <[email protected]>
##
## License: Public domain; do as you wish
##