Skip to content

Instantly share code, notes, and snippets.

@simonw
simonw / recover_source_code.md
Last active June 21, 2024 00:11
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@isopropylcyanide
isopropylcyanide / littlechecker.py
Last active January 7, 2024 16:50 — forked from rajarsheem/littlechecker.py
A little code checker tool in python for Java,C,Cpp. Handles compile error, runtime error, accepted, wrong, TLE.
import os
import filecmp
import re
codes = {200: 'success', 404: 'file_name not found',
400: 'error', 408: 'timeout'}
class program:
"""Class that handles all nitty gritties of a user program"""
@elraro
elraro / AsyncDbQueue.java
Created April 12, 2016 21:14 — forked from aikar/AsyncDbQueue.java
Empire Minecraft DB Wrapper - EmpireDb - Released as MIT
/*
* Copyright (c) 2015. Starlis LLC / dba Empire Minecraft
*
* This source code is proprietary software and must not be redistributed without Starlis LLC's approval
*
*/
package com.empireminecraft.systems.db;
import com.empireminecraft.util.Util;
@studiofuga
studiofuga / bluezutils.py
Last active March 25, 2021 07:24
Bluetooth agent that performs pairing with a fixed pin ("0000").
import dbus
SERVICE_NAME = "org.bluez"
ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter1"
DEVICE_INTERFACE = SERVICE_NAME + ".Device1"
def get_managed_objects():
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.freedesktop.DBus.ObjectManager")
anonymous
anonymous / WynncraftSkinChangerScript.java
Created December 29, 2014 21:48
Wynncraft skin changing script for the people who want to know
package net.crunkle.membrane;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.EnumChatVisibility;
import net.minecraft.server.v1_7_R4.TileEntity;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
@return1
return1 / bitcoin-cpuminer.sh
Last active June 24, 2024 16:39
install a bitcoin cpuminer on ubuntu/debian
# install dependencies
sudo apt-get install libcurl4-openssl-dev libncurses5-dev pkg-config automake yasm
# clone cpuminer
git clone https://github.com/pooler/cpuminer.git
# compile
cd cpuminer
./autogen.sh
./configure CFLAGS="-O3"
@johntyree
johntyree / getBlockLists.sh
Last active June 4, 2024 12:30
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# Download lists, unpack and filter, write to stdout
curl -s https://www.iblocklist.com/lists.php \
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#'