Skip to content

Instantly share code, notes, and snippets.

View vay3t's full-sized avatar
🏴‍☠️
The quieter you become the more you are able to hear...

Vay3t vay3t

🏴‍☠️
The quieter you become the more you are able to hear...
View GitHub Profile
@cdown
cdown / gist:1163649
Last active June 16, 2024 12:47
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@revolunet
revolunet / xor.py
Created April 18, 2012 09:14
Simple python XOR encrypt/decrypt
#
# NB : this is not secure
# from http://code.activestate.com/recipes/266586-simple-xor-keyword-encryption/
# added base64 encoding for simple querystring :)
#
def xor_crypt_string(data, key='awesomepassword', encode=False, decode=False):
from itertools import izip, cycle
import base64
if decode:
@anandkunal
anandkunal / simple_reverse_proxy.go
Created September 4, 2012 21:12
Simple reverse proxy in Go.
package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
)
func main() {
@willurd
willurd / web-servers.md
Last active June 21, 2024 13:36
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
// Examples for using socat (and filan)
//"$" means normal user, "#" requires privileges, "//" starts a comment
///////////////////////////////////////////////////////////////////////////////
// similar to netcat
// connect to 10.1.1.1 on port 80 and relay to and from stdio
$ socat - TCP:10.1.1.1:80 # similar to "netcat 10.1.1.1 80"
@baojie
baojie / hello_multiprocessing.py
Created July 21, 2013 07:04
Python multiprocessing hello world. Split a list and process sublists in different jobs
import multiprocessing
# split a list into evenly sized chunks
def chunks(l, n):
return [l[i:i+n] for i in range(0, len(l), n)]
def do_job(job_id, data_slice):
for item in data_slice:
print "job", job_id, item
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@jgdoncel
jgdoncel / pdftk.bat
Created October 22, 2013 08:55
PDFTK - Comandos útiles
REM Para unir dos documentos diferentes podemos ejecutar lo siguiente desde la consola:
pdftk archivo1.pdf archivo2.pdf cat output salida.pdf
REM Tambien podemos unirlos utilizando etiquetas:
pdftk A=archivo1.pdf B=archivo2.pdf cat A B output salida.pdf
REM Y por supuesto podemos usar comodines:
pdftk *.pdf cat output salida.pdf
REM Para separar páginas de varios documentos y crear un documento nuevo con estas hacemos lo siguiente:
@sumardi
sumardi / gist:8920355
Created February 10, 2014 17:25
TP-LINK TL-WN725N working on Raspberry Pi
$ sudo apt-get install linux-headers
$ sudo ln -s /usr/src/linux-headers-3.10-3-rpi/ /lib/modules/3.10.25+/build
$ git clone https://github.com/lwfinger/rtl8188eu.git
$ cd rtl8188eu
$ make all
$ sudo make install
$ sudo ifconfig wlan0 up
@ninadsp
ninadsp / README.md
Last active August 26, 2022 15:06
Use jq to conditionally pick up fields from a JSON
  • 1.json contains data retrieved from the Instagram API. data is an array of media matching the query posted to Instagram's REST API, in a JSON array.
  • Each media element contains metadata for a photo/video posted to Instagram
  • .data[] loops over each media object in the JSON file, letting us process each element
  • | works like a regular *nix pipe, taking the output of the previous operator and passing it on to the next one.
  • select() filters through objects depending on the rule passed to it.
  • .tags[] returns an array of tags for each media. contains() returns true if the current object passed to it contains the string passed as a parameter. .tags[] | contains("100happydays") iterates over all the tags associated with the media object and returns true if the current tag matches the string 100happydays.
  • .select( .tags[] | contains("100happydays") ) filters all media objects that contain the tag 100happydays
  • .images.standard_resolution.url now