Skip to content

Instantly share code, notes, and snippets.

$ echo "pAkH5a9ubW3Etf8SDO548F6ZjuMKNc0I4Cia1lonDv0.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTM0NzkxMTYxNywicGFnZSI6eyJpZCI6IjI4NzQzNTk4MTM2OTUwNyIsImxpa2VkIjpmYWxzZSwiYWRtaW4iOnRydWV9LCJ1c2VyIjp7ImNvdW50cnkiOiJkZSIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MTMsIm1heCI6MTd9fX0" |cut -d. -f2 |base64 -d |json_pp
base64: invalid input
{
"algorithm" : "HMAC-SHA256",
"page" : {
"admin" : true,
"liked" : false,
"id" : "287435981369507"
},
"user" : {
@temoto
temoto / cp.go
Created September 17, 2012 21:35
cp benchmarks
package main
import (
"flag"
"fmt"
"io"
"os"
"path"
"runtime"
)
@temoto
temoto / gist:3745854
Created September 18, 2012 20:58
pacaur -S bup-git failure
$ pacaur -S --needed bup-git
:: Package(s) bup-git not found in repositories, trying AUR...
:: pylibacl is available in community
:: python2-pyxattr is available in community
AUR Targets (1): bup-git
Proceed with installation? [Y/n]
:: Edit bup-git PKGBUILD? [Y/n] n
@temoto
temoto / Benchmark output
Created October 2, 2012 18:58
Go index (for range) micro benchmark
BenchmarkStringIndex1First 100000000 20.0 ns/op
BenchmarkStringIndex2First 100000000 19.8 ns/op
BenchmarkStringIndex1Last 50000000 59.4 ns/op
BenchmarkStringIndex2Last 50000000 45.7 ns/op
ok indexbench 9.413s
@temoto
temoto / cat-zmq.go
Created October 14, 2012 23:44
cat to ZeroMQ in Go
package main
import (
"bufio"
"flag"
"github.com/alecthomas/gozmq"
"io"
"log"
"os"
)
@temoto
temoto / bitsquat.py
Created November 20, 2012 18:03
DNS domain bitsquat checker
#!/usr/bin/env python
from __future__ import unicode_literals
# Original idea: http://dinaburg.org/bitsquatting.html
import gevent.monkey
gevent.monkey.patch_all()
import dns.name, dns.resolver
import gevent, gevent.pool
import sys
@temoto
temoto / limitmap.go
Created November 22, 2012 10:03
Map of semaphores to limit concurrency against some string keys in Go (golang)
// Package limitmap provides map of semaphores to limit concurrency against some string keys.
//
// Usage:
// limits := NewLimitMap()
// func process(url *url.URL, rch chan *http.Response) {
// // At most 2 concurrent requests to each host.
// limits.Acquire(url.Host, 2)
// defer limits.Release(url.Host)
// r, err := http.Get(url.String())
// rch <- r
@temoto
temoto / gist:4130520
Created November 22, 2012 10:45
AUR grive-git build fail
$ pacaur -S --needed grive-git
:: Package(s) grive-git not found in repositories, trying AUR...
AUR Targets (1): grive-git
Proceed with installation? [Y/n]
:: Edit grive-git PKGBUILD? [Y/n] n
:: Building grive-git package...
==> Determining latest git revision...
diff --git a/eventlet/green/ssl.py b/eventlet/green/ssl.py
index 88c47a3..62ab51e 100644
--- a/eventlet/green/ssl.py
+++ b/eventlet/green/ssl.py
@@ -127,9 +140,11 @@ class GreenSSLSocket(__ssl.SSLSocket):
self.__class__)
amount = len(data)
count = 0
- while (count < amount):
+ while count < amount:
@temoto
temoto / example.py
Created January 14, 2013 01:21
Python pep8, long lines wrap rules, indentation
def inside():
# Good. Consistent. You know up front where to put continuation.
# Also consistently short, no matter how long is `xs = itertools.ifilter`.
xs = itertools.ifilter(fun, [very_long_name_1, very_long_name_2,
very_long_name_3, very_long_name4])
# Bad. Lots of space wasted. Rename 'xs' and you have to reindent everything.
xs = itertools.ifilter(fun,
[very_long_name_1, very_long_name_2,
very_long_name_3, very_long_name_4])