Skip to content

Instantly share code, notes, and snippets.

View shackra's full-sized avatar

Jorge Araya Navarro shackra

View GitHub Profile
@parente
parente / runinenv.sh
Created February 15, 2011 01:54
run a command in virtualenv, useful for supervisord
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
echo "Executing $@ in ${VENV}"
exec "$@"
@errzey
errzey / llist_db_move.py
Created September 23, 2011 17:20
An interesting technique for creating a linked list like structure using SQL with minimal overhead.

I wrote this a long time ago as a proof-of-concept for a vaporware project. Recently I have had the need to something which seems easy at a high-level standpoint, but is actually quite hard to implement.

The original purpose for this concept was to easily maintain a strict order of data held within the rows, while still having the option to reorder the rows in an efficient manner (one table, no joins, no special embedded scripts etc).

A little insight into what I was doing: I once worked on a network security team for a tier-1 ISP. A coworker and myself had already written some really nice code to deal with the thousands (yes, thousands) of firewalls we dealt with on a daily basis. We created an API which generated abstracted structures of firewall configurations; by abstracting I mean creating a singular data-structure which represented rules, and rule-sets (a nice side-effect of this method was we could morph one firewall syntax structure to another. E.g., juniper filters -> netscreen rules. Needless to s

@zyxar
zyxar / exercise.tour.go
Last active January 15, 2025 06:09
tour.golang exercise solutions
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)
@joaopizani
joaopizani / .screenrc
Created May 17, 2012 11:55
A killer GNU Screen Config
# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off
@jboner
jboner / latency.txt
Last active April 23, 2025 18:02
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@petarov
petarov / ArchLinux-USB-Powersave.md
Last active June 11, 2023 10:58
Arch Linux Hints and Tricks

Mouse and Keyboard power off

Do you use an usb mouse and keyboard and have laptop_mode installed under your Arch linux ? Then maybe you have the same problems as me - mouse and keyboard getting inactive every 2 seconds or so.

To solve this, go to /etc/laptop-mode/conf.d and copy usb-autosuspend.conf to /etc/laptop-mode/conf.d/board-specific. After that run lsusb and get the ID of the usb device you want, e.g., 093a:2500 .

Open the board-specific/usb-autosuspend.conf file and find the AUTOSUSPEND_USBID_BLACKLIST conf option. Put the desired usb IDs there. You might need to run sudo laptop_mode afterwards to reload the configs.

@jhubert
jhubert / colors.sh
Created February 24, 2013 17:53
Generates a table of the `tput setaf` and `tput setab` colors in bash. Based on Daniel Crisman's script from the Bash Prompt HOWTO on Colours: http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
#!/bin/bash
T='gYw' # The test text
for FGs in 0 1 2 3 4 5 6 7;
do FG=${FGs// /}
echo -en " $FGs $(tput setaf $FG) $T "
for BG in 0 1 2 3 4 5 6 7;
do echo -en "$EINS $(tput setaf $FG)$(tput setab $BG) $T $(tput sgr0)";
done
@jshaw
jshaw / byobuCommands
Last active March 19, 2025 11:37
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
@hSATAC
hSATAC / gist:5343225
Created April 9, 2013 05:38
Http Redirect in Golang
package main
import (
"log"
"net/http"
)
func redirect(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "http://www.google.com", 301)
@pjvds
pjvds / wercker.yml
Last active January 11, 2019 11:41
A wercker.yml file that enables an virtual display at the beginning of the build. This should solve the following errors: * cannot connect to X server
box: wercker/ubuntu12.04-ruby1.9.3
services:
- wercker/postgresql
build:
# The steps that will be executed on build
steps:
- script:
name: Enable virtual display
code: |-
# Start xvfb which gives the context an virtual display