Skip to content

Instantly share code, notes, and snippets.

View macmade's full-sized avatar
🦄
I may be slow to respond.

JD Gadina macmade

🦄
I may be slow to respond.
View GitHub Profile
@macmade
macmade / strict-aliasing-bug.c
Created April 2, 2014 21:38
An example of C99 strict aliasing issue...
#include <stdio.h>
struct s1
{
int i;
};
struct s2
{
int i;
@macmade
macmade / CF
Created March 8, 2014 16:53
CoreFoundation Example
{
/* First of all, we need a C array to store our dictionary keys */
CFStringRef keys[ 2 ];
/*
* Let's create the dictionary keys. First key is straightforward because
* of the CFSTR macro, while the second one is less...
*/
keys[ 0 ] = CFSTR( "key-1" );
keys[ 1 ] = CFStringCreateWithCString
@macmade
macmade / CFPP
Created March 8, 2014 16:53
CoreFoundation++ Example
{
CF::Number number = 42;
CF::URL url = externalURL;
CF::Array array;
/* Adds number and URL to the array */
array << number << url;
CF::Data data
(
@macmade
macmade / gist:6250215
Created August 16, 2013 14:03
Objective-C singleton macros
#ifdef OBJC_ARC
#define SingletonImplementation( name ) \
\
static name * __sharedInstance = nil; \
\
+ ( id )sharedInstance \
{ \
static dispatch_once_t token; \
\
@macmade
macmade / gist:6183970
Created August 8, 2013 11:53
Clang - List predefined macros
clang -x c /dev/null -dM -E
@macmade
macmade / generate-types.awk
Created August 1, 2013 02:32
AWK - Generate types header file
BEGIN {
RS = ""
FS = "@XEOS"
TYPE = ""
NAME = ""
DEF = ""
CONTENT = ""
GUARD = ""
}
{
@macmade
macmade / gist:4254411
Created December 10, 2012 23:44
XEOS: Buddy physical memory allocator
--------------------------------------------------------------------------------
XEOS: Buddy physical memory allocator
Total memory: 1024 MB (1073741824 B) at 0x101000000
--------------------------------------------------------------------------------
Memory zone 1 - Length: 639 KB
- Pages: 159
- Buddy 0: 159 blocks of 4 KB
- Buddy 1: 79 blocks of 8 KB
- Buddy 2: 39 blocks of 16 KB
- Buddy 3: 19 blocks of 32 KB
@macmade
macmade / Clang - LLVM MakeFile
Created June 11, 2012 20:05
Clang - LLVM MakeFile
#-------------------------------------------------------------------------------
# Build settings
#-------------------------------------------------------------------------------
PREFIX = /usr/local/my-llvm/
#-------------------------------------------------------------------------------
# Software
#-------------------------------------------------------------------------------
@macmade
macmade / GenericViewController
Created January 24, 2012 20:44
GenericViewController
@interface GenericViewController: UIViewController
{}
@end
@implementation GenericViewController
{
- ( id )init
{
NSString * className;
@macmade
macmade / girlfriend.class.php
Created January 3, 2012 06:53
A PHP class representing a girl...
<?php
require_once( 'city.class.php' );
abstract class core_girlFriend
{
private $_mood = false;
private $_wrongMoods = array( 'busy', 'anxious', 'worried', 'working', 'sad', 'melancholic' );
private $_city = null;