Skip to content

Instantly share code, notes, and snippets.

View lynxluna's full-sized avatar
🎯
Focusing

Didiet lynxluna

🎯
Focusing
View GitHub Profile
#!/usr/bin/env python
# encoding: utf-8
'''
This code is using binary shift and tricks to create powerset and also generator
'''
def powerset( l ):
''' This code make a powerset list by using grey code'''
# Anggaplah index item itu adalah binary
@lynxluna
lynxluna / main.c
Created February 9, 2011 21:46
Some hello world using foundation on C and objective-c
id pool=objc_msgSend((id)NSClassFromString(CFSTR("NSAutoreleasePool")), NSSelectorFromString(CFSTR("alloc")));
pool=objc_msgSend(pool, NSSelectorFromString(CFSTR("init")));
id bundle=objc_msgSend((id)NSClassFromString(CFSTR("NSBundle")), NSSelectorFromString(CFSTR("alloc")));
bundle=objc_msgSend(bundle, NSSelectorFromString(CFSTR("initWithPath:")), bundlePath);
objc_msgSend(bundle, NSSelectorFromString(CFSTR("load")));
objc_msgSend(bundle, NSSelectorFromString(CFSTR("autorelease")));
objc_msgSend(pool, NSSelectorFromString(CFSTR("release")));
@lynxluna
lynxluna / gist:837445
Created February 21, 2011 18:08
Code to make your coordinate cartesian, the 0,0 is in the middle of the view
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGSize sz = [self bounds].size;
CGContextTranslateCTM(ctx, 0.0f, sz.height);
CGContextScaleCTM(ctx, 1.0f, -1.0f);
CGContextTranslateCTM(ctx, sz.width * 0.5f, sz.height * 0.5f);
@lynxluna
lynxluna / gist:867133
Created March 12, 2011 08:39
OpenGL version 2.0
---------------------------
GLEW Extension Info
---------------------------
GLEW version 1.5.8
Running on a Intel GMA X3100 OpenGL Engine from Intel Inc.
OpenGL version 2.0 APPLE-1.6.26 is supported
GL_VERSION_1_1: OK
---------------
@lynxluna
lynxluna / example.com.conf
Created June 28, 2011 10:16
NginX configuration for CodeIgniter Apps with PATH_INFO and subdomain
server
{
# GENERAL CONFIGS
listen 8000;
server_name example.com .example.com;
root /var/example/current/site;
index index.html index.htm index.php;
include mime.types;
@lynxluna
lynxluna / fastinvsqrt.c
Created January 21, 2012 13:12
Fast Inverse Square Root Without Pointer Casting
/* See http://en.wikipedia.org/wiki/Fast_inverse_square_root for
For original implementation
*/
typedef union {
long l;
float f;
} LongFloat;
static inline float InvSqrt( const float v ) {
@lynxluna
lynxluna / .vimrc
Created February 18, 2012 00:36
My VimRC
syn on
set cindent
set smartindent
set autoindent
set expandtab
set tabstop=4
set shiftwidth=4
set cinkeys=0{,0},:,0#,!^F
call pathogen#infect()
filetype plugin indent on
@lynxluna
lynxluna / armv5.armv6.diff
Created March 5, 2012 11:25
Apple clang 4.2 dump predefined macros
< #define __ARM_ARCH_5TEJ__ 1
---
> #define __ARM_ARCH_6K__ 1
101d100
< #define __SOFTFP__ 1
110a110
> #define __VFP_FP__ 1
port -dfn uninstall perl5.12 apr apr-utils
port -d install perl5.12 apr apr-utils
port -d upgrade subversion-bindings
@lynxluna
lynxluna / gist:2132396
Created March 20, 2012 07:16
Web clipping code
javascript:(function(){EN_CLIP_HOST='http://www.evernote.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){location.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);}})();