Skip to content

Instantly share code, notes, and snippets.

@C0deH4cker
C0deH4cker / hacky.c
Created September 19, 2013 08:00
Hackiest preprocessor macros I may have ever written, yet they surprisingly work for every test case I've thrown at them. Enjoy ;)
/*
hacky.c
Written on 9/19/13 by @C0deH4cker for reasons unknown.
Inspired by http://carolina.mff.cuni.cz/~trmac/blog/2005/the-ugliest-c-feature-tgmathh/
DISCLAIMER:
No preprocessors were harmed in the creation of this code.
*/
/*
@C0deH4cker
C0deH4cker / savevid.py
Last active January 1, 2016 07:09
Run this on a Mac with an iPhone plugged in and then view a video snap. It will be saved to the current directory. To stop, press Control-C. Requires iFuse. Works without a jailbreak. Clearly not affiliated with Snapchat in any way.
#!/usr/bin/env python
import sys, os
import subprocess
from shutil import copyfile
def main():
mnt = os.path.expanduser("~/mnt")
snap = mnt + "/snapchat"
@C0deH4cker
C0deH4cker / sierpinski.cpp
Created January 18, 2014 04:05
Solution to a problem from a local programming contest.
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
struct Block {
vector<vector<bool> > grid;
int size;
@C0deH4cker
C0deH4cker / Property.h
Created February 2, 2014 11:31
C# style properties in C++
//
// Property.h
//
// Created by C0deH4cker on 2/2/14.
// Copyright (c) 2014 C0deH4cker. All rights reserved.
//
#ifndef _PROPERTY_H_
#define _PROPERTY_H_
@C0deH4cker
C0deH4cker / 2d.fsn
Last active August 29, 2015 13:56
Various programs in the Fission programming language
R'Hello, di'\
+'!snoisnem'/
O.........../
@C0deH4cker
C0deH4cker / printsegs.c
Created January 15, 2015 20:52
Example for parsing a mach-o using the ITERCMDS macro (best thing ever!)
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <mach-o/loader.h>
/* Get the next load command from the current one */
@C0deH4cker
C0deH4cker / macho_extractor.c
Last active November 2, 2023 14:47
Program that will extract a segment from a mach-o file. Should even work on Linux/BSD/UNIX?
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
/* For supporting Linux and other systems that don't have mach-o headers */
@C0deH4cker
C0deH4cker / wordshift.cpp
Created February 11, 2015 21:18
Determine all possible valid words that can be formed by shifting a valid word by one on a keyboard
//
// wordshift.cpp
// WordShift
//
// Created by C0deH4cker on 2/11/15.
// Copyright (c) 2015 C0deH4cker. All rights reserved.
//
#include <iostream>
#include <fstream>
@C0deH4cker
C0deH4cker / with.h
Created June 10, 2015 08:34
Python's with statement, implemented in C++ via macros
// Just like C#'s using statement and Python's with statement.
// This allows use of a resource within a code block, after which
// the declared object's destructor will clean up.
// There's nothing about `with` that doesn't work in C, but it is
// pointless in standard C as there are no destructors.
// Multiple with statements can be nested as well, so it works as
// you'd expect. If for some bizarre reason you need to put multiple
// using statements on the same line, I've added another version,
// defined below as with_inline.
//
@C0deH4cker
C0deH4cker / patternhooker.c
Last active January 19, 2022 02:04
Example of hooking a function from a Substrate tweak by searching for a byte pattern in the app's code segments. UNTESTED CODE
//
// patternhooker.c
// PatternHooker
//
// Finds a function by searching for a byte pattern and hooks it with CydiaSubstrate.
//
// Created by C0deH4cker on 7/26/15.
// Copyright (c) 2015 C0deH4cker. All rights reserved.
//