Skip to content

Instantly share code, notes, and snippets.

View steffex's full-sized avatar

Stefan Jansen steffex

View GitHub Profile
@steffex
steffex / AppDelegate.m
Last active January 5, 2016 20:51
Set different initial viewcontroller in storyboard
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
if (![self deviceHasCamera]) {
// the storyboard name is the part before .storyboard
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
bundle:nil];
// set the rootviewController to the viewcontroller in the storyboard above.
self.window.rootViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"noCamera"];
}
@steffex
steffex / myscene.m
Created April 25, 2014 10:36
Get usertouch
- (CGPoint)getUserTouchFromSet:(NSSet *)touches
{
UITouch *touch = [[touches allObjects] objectAtIndex:0];
CGPoint touchPoint = [touch locationInNode: self];
return touchPoint;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint userTouch = [self getUserTouchFromSet: touches];
from datetime import datetime
d = datetime.strptime("12:40 AM", "%I:%M %p")
print d.strftime("%H:%M")
//
// CJCAnonymousFacesFilter.h
// CJC.FaceMaskingDemo
//
// Created by Chris Cavanagh on 11/9/13.
// Copyright (c) 2013 Chris Cavanagh. All rights reserved.
//
#import <CoreImage/CoreImage.h>
@steffex
steffex / device_position.m
Created January 23, 2014 23:08
Method to request an AVCaptureDevice with a certain position. Method will fallback to the default AVCaptureDevice.
- (AVCaptureDevice *) getCaptureDeviceWithPosition:(AVCaptureDevicePosition)position
{
AVCaptureDevice *device;
// loop through all capture devices with video mediatype
for (AVCaptureDevice *d in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
check if the devices position is the desired one
if ([d position] == position) {
device = d;
}
@steffex
steffex / teensy-nes-gamepad.c
Last active January 3, 2016 04:49 — forked from cleure/teensy-nes-gamepad.c
Optimised code for nes controller
#include <stdint.h>
// GPIO pins used for connected gamepad
#define CLOCK 21
#define LATCH 20
#define DATA 19
#define DEVICE_METHOD_JOYSTICK 0
#define DEVICE_METHOD_KEYBOARD 1
@steffex
steffex / teensy-nes-gamepad.c
Last active January 3, 2016 04:19 — forked from cleure/teensy-nes-gamepad.c
optimised code for teensy nes controller
#include <stdint.h>
// GPIO pins used for connected gamepad
#define CLOCK 21
#define LATCH 20
#define DATA 19
enum {
NES_BUTTON_A,
NES_BUTTON_B,
#include <stdint.h>
// GPIO pins used for connected gamepad
#define CLOCK 21
#define LATCH 20
#define DATA 19
#define DEVICE_TYPE_NES 0
#define DEVICE_TYPE_SNES 1
def addOne(x):
return x+1
# prints 5
print addOne(4)
# also prints 5
print addOne(addOne(3))
@steffex
steffex / gist:5795022
Last active December 18, 2015 14:09
pause spotify and start screensaver applescript. I use this in combination with the app "Spark", to run this script when I do alt+cmd+L
if appIsRunning("Spotify") then
tell application "Spotify" to pause
end if
tell application "System Events" to start current screen saver
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning