This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import time | |
from twisted.web import client, error as web_error | |
from twisted.python import failure | |
from cStringIO import StringIO | |
import gzip | |
port = 8098 | |
def uncompress(compressed_data): | |
sio = StringIO(compressed_data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import time | |
from twisted.web import client, error as web_error | |
from twisted.python import failure | |
from twisted.internet import task, defer | |
from cStringIO import StringIO | |
import gzip | |
import random | |
port = 8098 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import reactor, defer | |
from twisted.web.http import HTTPChannel | |
from twisted.application import internet, service | |
from twisted.web.server import Site, NOT_DONE_YET | |
from twisted.web.resource import Resource | |
class SlowResource(Resource): | |
isLeaf = True | |
waiting_requests = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express() | |
var http = require('http') | |
var server = http.createServer(app) | |
var sio = require('socket.io'); | |
var io = sio.listen(server); | |
var request = require('request'); | |
var connectedSockets = {}; | |
var clientCounter = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from sqlalchemy import create_engine | |
import json | |
app = Flask("jsonapi") | |
engine = create_engine('mysql://root:@localhost:3306/testdb') | |
@app.route("/") | |
def item(): | |
result = engine.execute("select * from lookups").fetchall() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cache = {} | |
def cache_result(result, key): | |
cache[key] = result | |
return result | |
def cached(f): | |
def wrapped(*args): | |
if key(args) in cache: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage ./notify.sh [path to folder] [command line to execute on change] | |
while true | |
do | |
set -e | |
inotifywait -q -r --exclude ".git|.idea" -e close_write,moved_to,create $1 > /dev/null | |
set +e | |
eval ${*:2} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String getRandomTwoLetterHexDigest(UUID timebased) { | |
checkArgument(timebased.version() == 1); | |
long timestamp = UUIDs.unixTimestamp(timebased); | |
ByteBuffer buffer = ByteBuffer.allocate(8); | |
buffer.putLong(timestamp); | |
// could add clocksequence as well | |
byte[] digest = DigestUtils.getSha256Digest().digest(buffer.array()); | |
return String.valueOf(Hex.encodeHex(digest)).substring(0, 2); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static com.google.common.base.Preconditions.checkArgument; | |
public class MyObject { | |
public final String name; | |
public final String wat; | |
private MyObject(String name, String wat) { | |
this.name = name; | |
this.wat = wat; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import hashlib | |
import hmac | |
import struct | |
import sys | |
import time | |
def get_hotp_token(secret, intervals_no): | |
key = base64.b32decode(secret, True) |
OlderNewer