This file contains 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 fs = require('fs'), | |
util = require('util'), | |
Stream = require('stream').Stream; | |
/** | |
* Create a bandwidth limited stream | |
* | |
* This is a read+writeable stream that can limit how fast it | |
* is written onto by emitting pause and resume events to | |
* maintain a specified bandwidth limit, that limit can |
This file contains 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
/** | |
* GOZORK Text Adventure Game | |
* by apoc <http://apoc.cc> | |
* | |
* Inspired by the infamous beginning of Zork I. | |
* Reading the source will obviously spoil the game. | |
* The goal is to somehow kill the troll. | |
* Oh yeah and: This is my first GO program! Which would be | |
* my perfect excuse for the bad code quality1! | |
* Here is a solution/transcript: |
This file contains 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
require 'socket' | |
## | |
# Pings a minecraft server and returns motd and playercount. | |
# Works with ruby >=1.9.3/2.0.0 | |
# | |
# More information and sample code here: | |
# http://wiki.vg/Server_List_Ping | |
## | |
class MinecraftPing |
This file contains 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
#include <boost/format.hpp> | |
void LogMessage(boost::format& message) { | |
std::cout << message.str() << std::endl; | |
} | |
template<typename TValue, typename... TArgs> | |
void LogMessage(boost::format& message, TValue arg, TArgs... args) { | |
message % arg; | |
LogMessage(message, args...); |
This file contains 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
#include <iostream> | |
#include <vector> | |
#include <functional> | |
class WorkingClass { | |
public: | |
typedef const std::function<void (int)> handler_t; | |
void AddHandler(handler_t& h) { | |
handlerList.push_back(&h); | |
} |
This file contains 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
'use strict'; | |
const mongoose = require('mongoose'); | |
const Schema = mongoose.Schema; | |
const ObjectId = Schema.Types.ObjectId; | |
const MongooseBuffer = mongoose.Types.Buffer; | |
const uuid = require('node-uuid'); | |
const db = require('../lib/database'); |
This file contains 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
ffmpeg \ | |
-i INPUT_FILE \ | |
-re \ | |
-r 23.976 \ | |
-s 480x204 \ | |
-aspect 2.35 \ | |
-acodec libfaac \ | |
-ac 2 \ | |
-ar 44100 \ | |
-ab 128k \ |
This file contains 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 uuid import uuid4 | |
from time import time | |
from datetime import datetime, timedelta | |
import lmdb | |
def get_random(size): | |
def get_bytes(): | |
return bytearray(size) | |
return get_bytes |
This file contains 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
def fun(a=0, b=0): | |
print(a, b) | |
fun(**{'b': 2}, a=1) # <--- breaks in 3.4 | |
fun(a=1, **{'b': 2}) # works in 3.5 |
This file contains 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 jose | |
from json import dumps | |
from Crypto.PublicKey import RSA | |
key = RSA.generate(2048) | |
private_key = key.exportKey('PEM').decode('utf-8') | |
public_key = key.publickey().exportKey('PEM').decode('utf-8') | |
from jwcrypto import jwk, jwe | |
from jwcrypto.common import json_encode |
NewerOlder