Skip to content

Instantly share code, notes, and snippets.

@jkp
jkp / websocketserver.py
Created July 18, 2012 13:28
A simple WebSockets server with no dependencies
import struct
import SocketServer
from base64 import b64encode
from hashlib import sha1
from mimetools import Message
from StringIO import StringIO
class WebSocketsHandler(SocketServer.StreamRequestHandler):
magic = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
@vogonistic
vogonistic / repl_bot.js
Created January 25, 2013 04:15
REPL example bot for mineflayer. Allows testing javascript over CLI to speed up development.
// REPL example bot for mineflayer
//
// Connects to server but doesn't have any built in logic. The terminal where
// it was started is now a REPL (Read-Eval-Print-Loop). Anything typed will be
// interpreted as javascript printed using util.inspect. Don't forget to try
// tab completion. These variables are exposed as local:
//
// var mineflayer = require('mineflayer');
// var bot = mineflayer.createBot({ username: 'REPL' });
//
@Dinnerbone
Dinnerbone / gist:5662824
Created May 28, 2013 13:38
As an essential step towards the Minecraft modding API, and also for sanity's sake in our own code, we're removing Texture Packs and replacing them with a new Resource Pack system. Ultimately, every mod/plugin will be its own resource pack, vanilla will be a resource pack by itself, and users will be able to apply multiple resource packs at once…
{
"//comment": "All metainfo files will be ORIGINAL_FILE.mcmeta. For example, textures/blocks/portal.png.mcmeta. The format is, of course, JSON.",
"animation": {
"//comment": "This block will be required for animated textures. It can be an empty block, but it will be needed to detect an animation.",
"frames": [
1,
{"index": 2, "time": 4},
3,
4
],
@floer32
floer32 / tupperware.py
Last active September 26, 2022 12:13
recursively convert nested dicts to nested namedtuples, giving you something like immutable object literals
from UserDict import IterableUserDict
import collections
__author__ = 'github.com/hangtwenty'
def tupperware(mapping):
""" Convert mappings to 'tupperwares' recursively.
@mwotton
mwotton / stupid axe ad
Created August 3, 2013 23:45
whee, i made their pointless C compile!
typedef struct {
int girlfriend;
} holder;
typedef struct {
holder a;
} toplevel;
typedef struct {
int this;
/sayraw {"text":"Want to reset the current minigame? ", "extra": [{"text":"Click here!", "clickEvent":{"action":"run_command", "value":"/scoreboard players set minigame_resetting 1"}}]}
{
"text": "Want to reset the current minigame? ",
"extra": [
{
"text": "Click here!",
"clickEvent": {
"action": "run_command",
@rjeczalik
rjeczalik / building-static-nginx.txt
Created October 19, 2013 15:37
Notes on building nginx as a static binary.
# Building static nginx for teh lulz
#
# basic dependencies
sudo apt-get install libxslt1-dev libxml2-dev zlib1g-dev libpcre3-dev libbz2-dev libssl-dev
# download nginx and openssl
wget http://nginx.org/download/nginx-1.5.6.tar.gz
tar xf nginx-1.5.6.tar.gz; cd nginx-1.5.6
# From Minecraft Overviewer (https://github.com/overviewer/Minecraft-Overviewer)
# png-it.py script -- modified version which works with mapcrafter maps
"""
Outputs a huge PNG file using the tiles from a overviewer map.
"""
from optparse import OptionParser
from PIL import Image
from os.path import join, split, exists
@lostcoaster
lostcoaster / websocketserver.py
Last active August 29, 2015 14:03 — forked from jkp/websocketserver.py
Make it compatible with python 3.4
#!python 3
import struct
import socketserver
from base64 import b64encode
from hashlib import sha1
import email
class WebSocketsHandler(socketserver.StreamRequestHandler):
magic = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'