Skip to content

Instantly share code, notes, and snippets.

View wouterds's full-sized avatar
:octocat:
Hello world!

Wouter De Schuyter wouterds

:octocat:
Hello world!
View GitHub Profile
@wouterds
wouterds / gist:4306113
Created December 16, 2012 10:21
Centeren nativeWindow
stage.nativeWindow.x = (Screen.mainScreen.bounds.width - stage.nativeWindow.width) * .5;
stage.nativeWindow.y = (Screen.mainScreen.bounds.height - stage.nativeWindow.height) * .5;
@wouterds
wouterds / gist:4316802
Created December 17, 2012 08:55
Font embedding
// Embedding
[Embed(source="/../media/fonts/DINPro-Medium.otf", embedAsCFF="false", fontFamily="DinProMedium")]
public static const DinProMedium:Class;
[Embed(source="/../media/fonts/OpenSans-Regular.ttf", embedAsCFF="false", fontFamily="OpenSansRegular")]
public static const OpenSansRegular:Class;
[Embed(source="/../media/fonts/OpenSans-Semibold.ttf", embedAsCFF="false", fontFamily="OpenSansSemibold")]
// Usage
Config.OpenSansRegular;
@wouterds
wouterds / HomeController.php
Created December 28, 2012 00:45
Cake inserting data
$data = array(
'Author' => array(
'ip' => $ip,
'ua' => $ua
)
);
if($this->Author->save($data))
debug('SAVED NEW AUTHOR');
else
@wouterds
wouterds / AuthorsController.php
Last active December 10, 2015 06:18
Shurl CakePHP AuthorsController
<?php
App::uses('AppController', 'Controller');
/**
* Authors Controller
*
* @property Author $Author
*/
class AuthorsController extends AppController {
public static function getId() {
@wouterds
wouterds / HomeController.php
Last active December 10, 2015 06:18
Shurl CakePHP HomeController
<?php
App::uses('AppController', 'Controller');
class HomeController extends AppController {
public function index() {
// Load Author model
$this->loadModel('Author');
// Load Authors controller
@wouterds
wouterds / api.php
Created February 20, 2013 12:38
Slim framework used in a class
<?php
session_start();
define('WWW_ROOT', dirname(__FILE__) . DIRECTORY_SEPARATOR);
require_once WWW_ROOT . 'includes' . DIRECTORY_SEPARATOR . 'functions.php';
require_once WWW_ROOT . 'classes' . DIRECTORY_SEPARATOR . 'Config.php';
require_once(WWW_ROOT . 'dao' . DIRECTORY_SEPARATOR . 'UserDAO.php');
require_once(WWW_ROOT . 'dao' . DIRECTORY_SEPARATOR . 'EventDAO.php');
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app /Applications/iPhone\ Simulator.app
@wouterds
wouterds / AppDelegate.m
Created April 30, 2013 12:45
Enumerate loaded fonts in Objective-C
- (void)enumerateFonts {
NSLog(@"[AppDelegate.enumerateFonts] Start enumerating fonts");
for(NSString *fontFamilyStrings in [UIFont familyNames]) {
NSLog(@"[AppDelegate.enumerateFonts] Font family: %@", fontFamilyStrings);
for(NSString *fontStrings in [UIFont fontNamesForFamilyName:fontFamilyStrings]) {
NSLog(@"[AppDelegate.enumerateFonts] Font: %@", fontStrings);
}
}
NSLog(@"[AppDelegate.enumerateFonts] End enumerating fonts");
}
// delegate
#define UIAppDelegate (AppDelegate *)[[UIApplication sharedApplication] delegate]
#define APPDELEGATE ((AppDelegate *)[[UIApplication sharedApplication] delegate])
// system
#define IS_IPHONE_4INCH (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height==568)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
// screen size
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
@wouterds
wouterds / .htaccess
Last active December 17, 2015 00:19
Webfonts
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff