Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / destroy.h
Created November 14, 2015 05:36
Safer way to free a variable in C
#include <stdlib.h>
/*! Frees the pointer pointed to by the parameter and then sets it to NULL */
#define destroy(pptr) do { \
__typeof__(*(pptr)) volatile* _pptr = (pptr); \
if(!_pptr) { \
break; \
} \
free(*_pptr); \
*_pptr = NULL; \
@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 / thread_local_lldb.c
Created June 26, 2016 08:16
Sample source file exhibiting incorrect debug info within Xcode
#include <stdio.h>
// Even making the pointer volatile doesn't help
__thread int* tl_ptr;
int main(void) {
int x = 0xDEAD;
// Put a breakpoint on the following line
tl_ptr = &x;
@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 / 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 / crash.swift
Created February 5, 2017 08:45
Crash the swift interpreter by entering the first part, followed by entering the second part. Must be separate copy/pastes!
// Part 1
extension UInt {
public init(bytes: Bytes) {
self = 0
for byte in bytes {
self <<= 8
self |= UInt(byte)
}
}
}
@C0deH4cker
C0deH4cker / keybase.md
Last active March 2, 2017 12:12
Keybase.io GitHub Verification

Keybase proof

I hereby claim:

  • I am c0deh4cker on github.
  • I am c0deh4cker (https://keybase.io/c0deh4cker) on keybase.
  • I have a public key ASDAYDYtqJGjVHyfmEJDXA3gw4geCBLvgpynNHx7M2t1Wgo

To claim this, I am signing this object: