Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
#-*- coding:utf-8 -*-
##############################################################
# Lempel-Ziv-Stac decompression
# BitReader and RingList classes
#
# Copyright (C) 2011 Filippo Valsorda - FiloSottile
# filosottile.wiki gmail.com - www.pytux.it
#
@FiloSottile
FiloSottile / watch_and_build.py
Created February 4, 2013 21:51
This small python script makes use of watchdog (and sh) to monitor your code directory (recursively) and build less and CoffeeScript files upon edit.
#!/usr/bin/env python2
import watchdog.events
import watchdog.observers
import sh
import time
import os
# Detach
if os.fork(): os._exit(0)
@FiloSottile
FiloSottile / archive_GH.py
Created February 4, 2013 21:54
Dump an user's public GitHub data into current directory.
#!/usr/bin/env python3
# This is free and unencumbered software released into the public domain.
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
# In jurisdictions that recognize copyright laws, the author or authors
@FiloSottile
FiloSottile / pin_to_star.py
Last active February 28, 2019 07:07
Before GitHub implemented Stars I used to bookmark interesting repos on Pinboard with a 'github-repo' tag. This script leverages GH and Pinboard APIs to star the bookmarked repo, and if the bookmark only had that tag and the star action succeeded deletes the bookmark.
# depends on python-pinboard and github3.py
import pinboard
from getpass import getpass
import re
from github3 import login
p = pinboard.PinboardAccount(token="FiloSottile:REDACTED")
user = 'FiloSottile'
@FiloSottile
FiloSottile / gist:5872198
Created June 26, 2013 22:10
YT cipher s tests
"qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]}|:;?/>.<"
"J:|}][{=+-_)(*&;%$#@>MNBVCXZASDFGH^KLPOIUYTREWQ0987654321mnbvcxzasdfghrklpoiuytej"
"qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$^&*()_-+={[]}|:;?/>.<"
"!?;:|}][{=+-_)(*&^$#@/MNBVCXZASqFGHJKLPOIUYTREWQ0987654321mnbvcxzasdfghjklpoiuytr"
"qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[|};?/>.<"
"ertyuioplkjhgfdqazxcvbnm1234567890QWERT}UIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[|/;?Y"
"qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[};?/>.<"
>>> plaintext = 1337
>>> key = 4242
>>> ciphertext = plaintext ^ key
>>> ciphertext
5547
>>> ciphertext ^ key
1337
>>> ciphertext ^ plaintext
4242
@FiloSottile
FiloSottile / How to dump the iOS simulator memory.md
Last active October 5, 2022 06:55
How to dump the iOS simulator memory

Dumping the iOS simulator memory

To audit memory or to debug with external tools it can be useful to get a dump of the running memory of an app.

To do so on a device you'll need a Jailbreak, SSH access, and gdb. See this or this.

If instead you're up to a simulated app, things are easier: apps running in the simulator are actually just native processes on your Mac OS X.

So, how to get a core dump of a Mac OS X process? Sadly gdb can't do so. Mac OS X Internals comes to the rescue with this article.

@FiloSottile
FiloSottile / gist:6668770
Created September 23, 2013 10:28
opensn0w with iPhone3,1 and iOS 7.0 segfault
opensn0w 2.0, free your devices.
version: opensn0w-2.0.0/DEVELOPMENT_X86_64(clang)
Compiled on: Sep 23 2013 10:38:05
Registering patch "iBSS_SignatureCheck" with size 12 for ARMv0 to patch list 0x7fdbfb40a860
Registering patch "iBEC_SignatureCheck" with size 12 for ARMv0 to patch list 0x7fdbfb40a860
Registering patch "iBoot_SignatureCheck" with size 14 for ARMv0 to patch list 0x7fdbfb40a860
Registering patch "iBoot_BootArgsConditional" with size 6 for ARMv0 to patch list 0x7fdbfb40a860
Registering patch "iBoot_gBootArgs" with size 39 for ARMv0 to patch list 0x7fdbfb40a860
@FiloSottile
FiloSottile / unchroot.c
Last active January 18, 2023 08:54
Code for my article about chroot jail escaping
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
int dir_fd, x;
setuid(0);
mkdir(".42", 0755);
dir_fd = open(".", O_RDONLY);
chroot(".42");
@FiloSottile
FiloSottile / crontab
Last active December 26, 2015 01:59
Shell script to run @Neal's savethemblobs in a cronjob https://github.com/Neal/savethemblobs
0 5 * * 1 bash -c "cd ~/shsh-blobs/; ./savethem.sh"