Skip to content

Instantly share code, notes, and snippets.

@deltheil
deltheil / list.c
Created June 5, 2012 16:43
Manipulate lists of records the Redis way via Tokyo Cabinet B+ Tree database
#include <stdio.h>
#include <tcbdb.h>
#include <tcutil.h>
int main(int argc, char *argv[]) {
TCBDB *db = tcbdbnew();
tcbdbopen(db, "list.db", BDBOWRITER | BDBOCREAT | BDBOTRUNC);
/* The B+ Tree database features record duplication for a given key
(see `tcbdbputdup`) which means we can easily append data for a
@deltheil
deltheil / gist:2888680
Created June 7, 2012 12:57
moreutils (errno): auto-generated errno-s header file via the preprocessor
# Taken from http://joeyh.name/code/moreutils/ Makefile
# See http://blog.liw.fi/posts/errno/ for all the details about `errno` CLI tool
errno.o: errnos.h
errnos.h:
echo '#include <errno.h>' > dump.c
$(CC) -E -dD dump.c | awk '/^#define E/ { printf "{\"%s\",%d},\n", $$2, $$3 }' > errnos.h
rm -f dump.c
# On errno.c side this auto-generated header is used as follow
# --
@deltheil
deltheil / gist:2916633
Created June 12, 2012 09:54
JPEG images: EXIF orientation
# 1/ Read EXIF orientation flag
identify -format "%[EXIF:orientation]" myimage.jpg
# NOTE: jhead can be used too
# see http://www.sentex.net/~mwandel/jhead/
jhead -exifmap myimage.jpg | grep Ori
# 2/ Remove EXIF orientation
# i.e. rotate the image accordingly and reset the orientation
# flag to 1 (default, i.e. origin = TopLeft)
@deltheil
deltheil / gist:2960752
Created June 20, 2012 16:19
Xcode xcrun command-line tools examples
# Find the right Clang path for iOS cross-compilation
xcrun -sdk iphoneos -find clang
# Pick the right tool and run the command (here list #define-s)
xcrun -sdk iphoneos clang -E -dM - < /dev/null
@deltheil
deltheil / b64.c
Created July 28, 2012 14:26
base64url without padding decoding (with TC)
/**
* How to use it
* --
* brew install tokyo-cabinet
* clang -o b64 b64.c -Wall -Werror -I/usr/local/include -L/usr/local/lib -ltokyocabinet
* ./b64
* ./b64 Zm9v
*/
#include <stdio.h>
@deltheil
deltheil / mobiledev-wanted.md
Created September 21, 2012 14:10
Moodstocks is looking for a Mobile developer

We are looking for a Lead Mobile Developer to join our core team. Let's be clear: you will be THE mobile guy here at Moodstocks designing, developing and maintaining apps, bindings and plugins on-top of our core scanning SDK.

Mission

We have a lot of stuff to do including:

  • maintaining, documenting and improving the Moodstocks SDK by focusing on the Objective-C and Java / JNI bindings, the Moodstocks Scanner application, the demo app

  • taking our brand-new Qrumble scanning app to the next level,

@deltheil
deltheil / gist:3788263
Created September 26, 2012 14:07
clang -arch armv7 vs. armv7s
--- armv7.txt 2012-09-26 16:03:39.000000000 +0200
+++ armv7s.txt 2012-09-26 16:03:45.000000000 +0200
@@ -3,8 +3,9 @@
#define __APPLE_CC__ 5621
#define __APPLE__ 1
#define __ARMEL__ 1
-#define __ARM_ARCH_7A__ 1
+#define __ARM_ARCH_7S__ 1
#define __ARM_NEON__ 1
+#define __ARM_VFPV4__ 1
@deltheil
deltheil / jparse.c
Created September 27, 2012 12:51
Checking parsing error with json-parser (https://github.com/udp/json-parser/)
#include <stdio.h>
#include <string.h>
#include <json-parser/json.h>
int main(int argc, char *argv[]) {
char *str[] = { "{\"foo\": \"bar\"}" /* ok */, "{\"foo\": \"bar}" /* ko */ };
for (int i = 0; i < 2; i++) {
json_settings settings;
memset(&settings, 0, sizeof(json_settings));
@deltheil
deltheil / jsmn.sh
Created October 4, 2012 20:25
Android NDK basic example: build jsmn C parser w/ the Standalone Toolchain
# 1. Use the tools from the Standalone Toolchain
export PATH=/tmp/my-android-toolchain/bin:$PATH
export SYSROOT=/tmp/my-android-toolchain/sysroot
export CC="arm-linux-androideabi-gcc --sysroot $SYSROOT"
export AR=arm-linux-androideabi-ar
# 2. Clone the Github mirror
git clone git://github.com/noct/jsmn.git; cd jsmn
# 3. Build for the ARMv7 ABI
@deltheil
deltheil / msgpack.sh
Created October 4, 2012 20:58
Android NDK advanced example: build msgpack w/ the Standalone Toolchain
export NDK=/tmp/android-ndk-r8b
# 1. Use the tools from the Standalone Toolchain
export PATH=/tmp/my-android-toolchain/bin:$PATH
export SYSROOT=/tmp/my-android-toolchain/sysroot
export CC="arm-linux-androideabi-gcc --sysroot $SYSROOT"
export CXX="arm-linux-androideabi-g++ --sysroot $SYSROOT"
export CXXSTL=$NDK/sources/cxx-stl/gnu-libstdc++/4.6
# 2. Clone the Github repo and run the bootstrap actions