Skip to content

Instantly share code, notes, and snippets.

newQuad.bl.textureVertex = CGPointMake(0, 0);
newQuad.br.textureVertex = CGPointMake(1, 0);
newQuad.tl.textureVertex = CGPointMake(0, 1);
newQuad.br.textureVertex = CGPointMake(1, 1);
@clooth
clooth / resizyr.coffee
Created October 17, 2013 20:48
WebGL Photo resizer example
#
# Resizyr - WebGL Image Resizer
#
# Extensions
# This allows us to do for example the following:
# 5.times () -> console.log "foo"
#
Number::times = (fn) ->
do fn for [1..@valueOf()]
// Create dummy click event for automation
var click = new MouseEvent('click', { 'clientX': 1,'clientY': 1 });
// Create button boilerplate
function createButton(title, action) {
var button = document.createElement('button');
button.innerText = title;
button.onclick = function(e) {
e.preventDefault();
action(e);
@clooth
clooth / Macros.h
Created November 12, 2013 02:52
Objective-C Macros
// Constants
#define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
#define APP_NAME [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]
#define APP_DELEGATE [[UIApplication sharedApplication] delegate]
#define USER_DEFAULTS [NSUserDefaults standardUserDefaults]
#define APPLICATION [UIApplication sharedApplication]
#define BUNDLE [NSBundle mainBundle]
#define MAIN_SCREEN [UIScreen mainScreen]
#define FILE_MANAGER [NSFileManager defaultManager]
#define DOCUMENTS_DIR [[FILE_MANAGER URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]
- (void)keyboardWasShown:(NSNotification *)notification {
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
// Screen size
CGSize screenSize = [[UIApplication sharedApplication] delegate].window.frame.size;
// Viewport size
CGFloat viewportHeight = screenSize.height - keyboardSize.height;
}
javascript:(function(d){els=d.querySelectorAll('*');for(i=0;i<els.length;i++){e=els[i];e.style.color='transparent';e.style.backgroundImage='none';if(e.nodeName=='IMG')e.style.visibility='hidden';}})(document);
//
// AccountsViewController.h
//
// Created by Nico Hämäläinen on 28/03/14.
//
#import <UIKit/UIKit.h>
@interface AccountsViewController : UIViewController
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *contents = [fileManager contentsOfDirectoryAtPath:directoryPath error:NULL];
NSEnumerator *e = [contents objectEnumerator];
NSString *filename;
while ((filename = [e nextObject])) {
NSString *filePath = [directoryPath stringByAppendingPathComponent:filename];
if ([[filePath pathExtension] isEqualToString:@"jpg"]) {
// jpegitz
// Splitter view recognizer should only begin if we're truly touching something inside the splitter view
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer == _splitterPanRecognizer) {
CGPoint location = [gestureRecognizer locationInView:self.view];
BOOL didHitView = NO;
NSArray *hitTestViews = @[_splitterView];
hitTestViews = [hitTestViews arrayByAddingObjectsFromArray:_splitterView.subviews];
#import <Foundation/Foundation.h>
@interface IOSTools : NSObject
- (NSString *)getCountry;
@end