Skip to content

Instantly share code, notes, and snippets.

Barney Gale barneygale

Block or report user

Report or block barneygale

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:f1d782f1aff6dc5d3eb17d75a49d57ae
{
"redirect": null,
"suggestions": null,
"type": 0,
"has_command": false,
"children": [
{
"redirect": null,
"suggestions": null,
"has_command": true,
View sudo.py
import sys, marshal, functools, subprocess
child_script = """
import marshal, sys, types;
fn, args, kwargs = marshal.load(sys.stdin)
marshal.dump(
types.FunctionType(fn, globals())(*args, **kwargs),
sys.stdout)
"""
View maintenance.py
import sys
import json
import SocketServer
SocketServer.TCPServer.allow_reuse_address = True
class MCHandler(SocketServer.BaseRequestHandler):
@classmethod
def pack_varint(cls, d):
@barneygale
barneygale / check_mode.py
Last active Nov 27, 2016
Check if a minecraft server is in offline or online mode
View check_mode.py
import json
import socket
### Helper functions
# Read n bytes from the socket
def read(sock, n):
o = ""
while len(o) < n:
o += sock.recv(n-len(o))
View gist:9453761
from __future__ import division, print_function, unicode_literals
import types
import dis
import os
import struct
import sys
def _unpack(s):
@barneygale
barneygale / throttlepatch.py
Created Mar 6, 2013
This script will patch a minecraft_server.jar to have a connection-throttle of zero. This is useful to folks running behind proxies. It requires python 2.7 and the java runtime environment (specifically the `jar` binary)
View throttlepatch.py
from os import chdir, path
from tempfile import mkdtemp
from shutil import rmtree
from struct import pack
from subprocess import check_output
def jar_contents(j_path):
return check_output(['jar', 'tf', j_path]).split("\n")
def jar_extract(j_path):
View mcdowntime.py
#!/usr/bin/python
import struct
from twisted.internet import protocol, reactor
PR_VERSION = "51"
MC_VERSION = "1.4.7"
class DowntimeProtocol(protocol.Protocol):
def __init__(self, message):
View gist:4240851
import java.io.*;
import javax.crypto.*;
import java.util.*;
import javax.crypto.spec.*;
import java.net.*;
public class decrypt {
static String DESpassword = "passwordfile";
static byte[] salt = { 12, -99, 74, -28, 30, -125, 21, -4 };
public static void main(String[] args) {
View gist:3762487
#Shortcut to /mod-broadcast
*:/mb $ = >>>
_assertperm('mod', 0)
assign(@mods, _get_mods())
foreach(@mods, @mod,
tmsg(@mod, concat('[', color(red), 'Mod - ', player(), color(white), '] ', color(green), $))
)
<<<
View gist:3659371
def steps():
a = 1
dx = 0
dy = 0
x = 0
y = 0
while True:
a += 1
dx = ((1+a) & 1) - (2 if (a % 4) == 0 else 0)
dy = (a & 1) - (2 if (a % 4) == 1 else 0)
You can’t perform that action at this time.