Skip to content

Instantly share code, notes, and snippets.

😅
what's up?

Mendelson Gusmão mendelgusmao

😅
what's up?
Block or report user

Report or block mendelgusmao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mendelgusmao
mendelgusmao / gist:2356310
Created Apr 11, 2012
high performance URL shortener on steroids using nginx, redis and lua
View gist:2356310
# based on http://uberblo.gs/2011/06/high-performance-url-shortening-with-redis-backed-nginx
# using code from http://stackoverflow.com/questions/3554315/lua-base-converter
# "database scheme"
# database 0: id ~> url
# database 1: id ~> hits
# database 2: id ~> [{referer|user_agent}]
# database 3: id ~> hits (when id is not found)
# database 4: id ~> [{referer|user_agent}] (when id is not found)
# database 5: key "count" storing the number of shortened urls; the id is generated by (this number + 1) converted to base 62
@mendelgusmao
mendelgusmao / gist:5823291
Last active Jul 13, 2019
BTSync / BitTorrent Sync behind nginx
View gist:5823291
# take one
# subdirectory (one server, multiple services)
location /btsync/ {
rewrite ^/btsync/gui(.*) /btsync$1 last;
proxy_pass http://127.0.0.1:8888/gui/;
proxy_redirect /gui/ /btsync/;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@mendelgusmao
mendelgusmao / main.go
Last active Dec 16, 2018
.zsh_history merge+remove duplicate lines
View main.go
package main
import (
"fmt"
"io/ioutil"
"os"
"regexp"
"sort"
"strconv"
"strings"
@mendelgusmao
mendelgusmao / btsync
Last active Sep 10, 2017
init.d script for btsync (based on another script built to run dropbox)
View btsync
#!/bin/sh
### BEGIN INIT INFO
# Provides: btsync
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of btsync.
@mendelgusmao
mendelgusmao / wa.random.rb
Last active Jul 10, 2017
Random Winamp playlist using ActiveWinamp, Ruby and Win32OLE
View wa.random.rb
require "win32ole"
count = 100
ttl = 86400
cache_file = "wa.random.cache"
query = [
'type = "0"',
'length > "2:00"',
'title NOTHAS "intro"',
View fan.sh
minSpeed=1500
maxSpeed=5500
highTemp=70
normalTemp=40
output=/sys/devices/platform/applesmc.768/fan1_output
manual=/sys/devices/platform/applesmc.768/fan1_manual
currentSpeed=$(cat $output)
View shared_struct_test.go
package xml
import (
"testing"
)
var (
fooXML = `
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root xmlns="urn:ietf:params:xml:ns:root-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:root-1.0 root-1.0.xsd">
@mendelgusmao
mendelgusmao / gist:6076361
Last active Dec 20, 2015
updates /etc/hosts whenever a host ip changes useful for creating host aliases usage: update-hosts <host_alias> <host_ip>
View gist:6076361
hosts=/etc/hosts
host=$1
ip=$2
if [ "$ip" = "" ]; then
ip=$(wget -qO- http://checkip.dyndns.org | cut -f2 -d":" | cut -f1 -d"<" | sed "s/ //")
fi
line=$(grep $host $hosts)
View chinelada.no.rasmus.php
<?php
// ...
$sets = array_map(
function($set) {
return explode(",", end(explode(": ", $set)));
},
array_filter(
explode("\n", file_get_contents($url)),
View autoap.sh
#!/bin/sh
##############################################################################################
## ##
## AutoAP Next Gen by kuthulu/Iron, supported by wo-fo, infusion, drats, cid12, mathilda ##
## This script is inspired by the autoap script that stoped working after the command ##
## set of the "wl" was reduced in the DD-WRT V2.4 Beta firmware on the 18th of June 2007 ##
## ##
## http://sourceforge.net/projects/autoap ##
## ##
## AutoAP NG is a script that enables users to automatically log into different AP's ##
You can’t perform that action at this time.