Skip to content

Instantly share code, notes, and snippets.


Simon graetzer

View GitHub Profile
graetzer / client.cpp
Created Apr 16, 2018
C++ Simple HTTP Client
View client.cpp
/// Copyright 2018 Simon Grätzer
#include "client.h"
#include "defer.h"
#include <http_parser.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
graetzer / aql-geo-test.js
Created Jun 8, 2017
Benchmark Arango Geo index
View aql-geo-test.js
/*jshint globalstrict:false, strict:false, maxlen: 500 */
/*global assertEqual */
/// @brief tests for query language, geo queries
/// @file
graetzer /
Last active May 6, 2021
PJSIP 2.6 iPhone iOS 9.0 build script
echo "Building pjsip:"
# change this to whatever DEVPATH works
# if you get make errors, maybe redownload pjsip and try again
export DEVPATH=/Applications/
MIN_IOS="-miphoneos-version-min=9.0" ARCH="-arch i386" CFLAGS="-O2 -m32 -mios-simulator-version-min=9.0 -fembed-bitcode" LDFLAGS="-O2 -m32 -mios-simulator-version-min=9.0 -fembed-bitcode" ./configure-iphone
graetzer / hdkf.m
Created Sep 19, 2014
Provides HKDF with sha256 as hash function
View hdkf.m
#import <CommonCrypto/CommonCrypto.h>
// ...
NSData * HKDF_SHA256(NSData *seed, NSData *info, NSData *salt, int outputSize) {
char prk[kCCHmacAlgSHA256] = {0};
CCHmac(CC_SHA256_DIGEST_LENGTH, [salt bytes], [salt length], [seed bytes], [seed length], prk);
int iterations = (int)ceil((double)outputSize/(double)CC_SHA256_DIGEST_LENGTH);
NSData *mixin = [NSData data];
NSMutableData *results = [NSMutableData data];
graetzer / key_parts.m
Last active Aug 29, 2015
Extract modulus and exponent from public key
View key_parts.m
// Create the keys with SecKeyGeneratePair
// Look at
NSData* keyData = [self _getPublicKeyBits];
NSLog(@"Public Key: %@", [keyData hexadecimalString]);
const char *buffer = keyData.bytes;
NSData* modulus;
NSData* exponent;
// Check for correct ASN.1 DER start
graetzer / pbkdf2_hmac_sha256.m
Last active Aug 29, 2015
Generate keys from passwords using PBKDF2-HMAC-SHA256
View pbkdf2_hmac_sha256.m
#import <CommonCrypto/CommonCrypto.h>
// ...
// This is the method specified by RSA's PKCS #5 standard.
// Compatible to
NSData * PBKDF2_HMAC_SHA256(NSData *data,NSData *salt, int iter, int keylen) {
unsigned char digtmp[CC_SHA256_DIGEST_LENGTH], *p, *buffer, itmp[4];
NSInteger cplen, j, k, tkeylen;
graetzer / gist:7972341
Created Dec 15, 2013
404 - The requested document is no more
View gist:7972341
var tl=new Array(
"The requested document is no more.",
'No file found.',
"Even tried multi.",
"Nothing helped.",
"I'm really depressed about this.",
"You see, I'm just a web server...",
"-- here I am, brain the size of the universe,",
"trying to serve you a simple web page,",
graetzer /
Created Apr 19, 2012
Android FragmentTabsPager with Actionbarsherlock
import java.util.ArrayList;
import android.content.Context;
import android.os.Bundle;