Skip to content

Instantly share code, notes, and snippets.

View H2CO3's full-sized avatar
🦀

Árpád Goretity  H2CO3

🦀
View GitHub Profile
@H2CO3
H2CO3 / main.m
Created August 3, 2013 22:14
Patch for https://github.com/xslim/mobileDeviceManager to support copying files *from* the device. Insert this at line 75 into Source/main.m.
} else if ([option isEqualToString:@"copyFrom"]) {
NSLog(@"Copying...");
AFCApplicationDirectory *appDir = [device newAFCApplicationDirectory:[arguments stringForKey:@"app"]];
AFCFileReference *infile = [appDir openForRead:[arguments stringForKey:@"from"]];
if (!infile) {
NSLog(@"Error: %@", [appDir lasterror]);
}
char buf[0x10000];
int outfile = open([arguments stringForKey:@"to"].UTF8String, O_CREAT | O_WRONLY, 0777);
@H2CO3
H2CO3 / guardhdr.sh
Created October 12, 2013 06:00
This script appends an automatically generated include guard to a specified header file. Optionally, you can provide a prefix that will be added to the guard macro.
#!/bin/bash
if [ "$#" = "0" ]; then
echo "at least one argument is required"
exit 1
fi
FILE=$1
GUARD="$2$(printf "%s" $FILE | tr '.' '_' | tr '[[:lower:]]' '[[:upper:]]')"
@H2CO3
H2CO3 / p89
Last active December 26, 2015 02:09
Sparkling demo: solution to Project Euler problem #89
/*
* Created by Árpád Goretity on 21/10/2013
*
* Sparkling demo: solution to Project Euler problem #89
* (http://projecteuler.net/problem=89)
*
* For demonstration purposes only -- please don't abuse or cheat.
*/
function int2roman(r)
@H2CO3
H2CO3 / p42.spn
Created December 10, 2013 21:15
Project Euler problem #42 solution in Sparkling
/*
* p42.spn
* Solution to Project Euler problem #42
*
* Created by Arpad Goretity on 10/12/2013
*/
function FileSize(file)
{
fseek(file, 0, "end");
@H2CO3
H2CO3 / p92.spn
Created December 11, 2013 23:18
Solution to Project Euler problem #92 as suggested by Daniel Silverstone.
/*
* p92.spn
*
* a solution to Project Euler problem #92
* using the Sparkling scripting language
*/
function next(n)
{
var s = 0;
//
// derive.c
// just because
// (just because I wanted to demonstrate what the Sparkling API is good for)
//
// created by H2CO3 on 31/01/2014
// use for good, not for evil
//
#include <stdio.h>
var six_factorial = function(f, x) {
return f(f, x);
}(function(f, x) {
return x < 2 ? 1 : x * f(f, x - 1);
}, 6);
@H2CO3
H2CO3 / bf.spn
Last active August 29, 2015 13:56
//
// bf.spn
// a Brainfuck parser and interpreter in Sparkling
//
// by Arpad Goretity (H2CO3)
// The "zeroise" optimization is based on the idea of Daniel Silverstone
// run as: spn bf.spn foo.bf
//
global ins_incrmt = 0,
function rrot(a, begin, k) {
var n = k - 1;
var tmp = a[begin + n];
for var i = n; i > 0; i-- {
a[begin + i % k] = a[begin + (i - 1) % k];
}
a[begin] = tmp;
}
function toFact(n, ndigs) {
function curry(fn) {
let curry_argc = argc - 1;
var curry_args = {};
for var i = 0; i < curry_argc; i++ {
curry_args[i] = #i;
}
return function() {
for var i = 0; i < argc; i++ {