Skip to content

Instantly share code, notes, and snippets.

(function(){
var node = document.createElement('DIV');
var human_link = 'http://example.com/new-landing';
node.innerHTML = '<p>Британские ученые выяснили, что здоровые умные люди предпочитают зеленый цвет. Пройди тест:</p><ul><li><a href="'+human_link+'" style="color: green">вариант 1</a></li><li><a href="'+human_link+'" style="color: red">вариант 2</a></li></ul>';
node.style.position = 'absolute';
node.style.left = '0';
node.style.top = '0';
node.style.width = '100%';
node.style.height = '100%';
node.style.background = 'white';
@temoto
temoto / aes-cfb-example.go
Created February 27, 2013 22:37
Example of AES (Rijndael) CFB encryption in Go. IMHO, http://golang.org/pkg/crypto/cipher/ could benefit a lot from similar snippet.
package main
import (
"crypto/aes"
"crypto/cipher"
"fmt"
)
func EncryptAESCFB(dst, src, key, iv []byte) error {
aesBlockEncrypter, err := aes.NewCipher([]byte(key))
@temoto
temoto / stork-deploy-init.bash
Last active December 14, 2015 05:39
Super awesome, simple, fast and robust deploy system. It has only 2 drawbacks: flexible by changing code and user must know what he does. Part 1 - prepare access to target machine.
#!/bin/bash
# Stop on errors
set -e
# Config
: ${user=stork-deploy}
: ${ssh_public_key="ssh-dss AAAAB3NzaC1kc3MAAACBAIbzNCxj+N8ZGcEeel1jMfy9MpBOoLUQXR+fxgqsXYiFkAB6e2deqKHXh+TuntWQwsoPcXi2/0UaWZkgR3JmJxrqFM3/aAeUUupDFLnUFSuz+L2y4hke8GAeLHuzaZ30HfvDU+AO4uQF6obLl5xs88H5BYPvmzhxQcPdOiwkK1XDAAAAFQCwh2kXaGbJGWE+Jaw78cxKNq+JHQAAAIA4X3JfuQ6eYm0N1EWPcWf46rTT0O0TNnBXlhNRhSQNnxbcLjF8ZYG/tYLRJA/J8dMgi/4ZojW4Hq7CluYq68ycf2FOS3S60vdoEv++q7oq8jKHyfQtzo+Jq8q0yMXd+PBnHp7s4v8AHK7ifz/LotCfg7d9+XAbCt//qjwZgPTulQAAAIBzptzN3d+yLu63MraeVdvz5nYDCwiy94FKaSSfPbHWH9iKb8jyJ1smrsM4SV9/ongsMAnDIA340HYFZqBY/iZEak84BTnjA89sZmUP/8E1Ou7WL/Lsx/kMfLuh4zANoqzMbwir7zm69x5ZqRhSqBs2J8iLx2hCX5zwWhoDnpVIUg== stork deploy"}
: ${sudoers_conf="/etc/sudoers.d/$user"}
version=1
@temoto
temoto / test-imul-shl.c
Last active December 12, 2015 05:28
Benchmark IMULQ against SHL on x86-64
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
/*
Compile with:
gcc -g -O0 -Wall -Werror
*/
static int64_t mul_imul(int64_t n) {
asm __volatile__ (
@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])
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 / 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...
@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 / 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 / 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"
)