This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//At the top of the file | |
#import "mandelbrot.cl.h" | |
//Inside the @autoreleasepool in int main() | |
//1 | |
dispatch_queue_t dq = gcl_create_dispatch_queue(CL_DEVICE_TYPE_GPU, NULL); | |
if (!dq) { | |
fprintf(stdout, "Unable to create a GPU-based dispatch queue.\n"); | |
exit(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//mandelbrot.cl | |
const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST; | |
kernel void mandelbrot(write_only image2d_t output, float width, float height, int iter) { | |
size_t x = get_global_id(0); | |
size_t y = get_global_id(1); | |
float2 z, c; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def copyright(fname, year, programmer) | |
return "// #{fname} | |
// | |
// Copyright #{year} #{programmer} | |
// | |
// Licensed under the Apache License, Version 2.0 (the \"License\"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Using with an image view | |
imageView.image = [UIImage imageNamed:@"myimage"]; | |
//Using as the background to another view | |
//Note that you will need to redraw the background when resizing | |
//Therefore if you need to animate resizes it may be more sensible to add a UIImageView | |
//as the background to your view | |
UIImage * myImage = [UIImage imageNamed:@"myimage"]; | |
UIGraphicsBeginImageContextWithOptions(myView.bounds.size, NO, 0); | |
[myImage drawInRect:myView.bounds]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)registerFonts { | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
NSArray * paths = [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:@""]; | |
for (NSString * path in paths) { | |
NSURL * url = [NSURL fileURLWithPath:path]; | |
CFErrorRef error; | |
CTFontManagerRegisterFontsForURL((__bridge CFURLRef)url, kCTFontManagerScopeNone, &error); | |
error = nil; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)enumerateCharacters:(EnumerationBlock)enumerationBlock | |
{ | |
const unichar * chars = CFStringGetCharactersPtr((__bridge CFStringRef)self); | |
//Function will return NULL if internal storage of string doesn't allow for easy iteration | |
if (chars != NULL) | |
{ | |
NSUInteger index = 0; | |
while (*chars) { | |
enumerationBlock(*chars, index); | |
chars++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(float)systemVersion | |
{ | |
NSArray * versionCompatibility = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; | |
float total = 0; | |
int pot = 0; | |
for (NSNumber * number in versionCompatibility) | |
{ | |
total += number.intValue * powf(10, pot); | |
pot--; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
from HTMLParser import HTMLParser | |
class MyHTMLParser(HTMLParser): | |
entered_status_table = False | |
in_table_cell_tag = False | |
status_online = False | |
services_online = {} | |
def get_class(self, attrs): | |
v = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int numberOfSyllables (String word) | |
{ | |
int syllabeleCount = 0; | |
bool lastWasVowel = false; | |
string lowerCase = word.ToLower ().Replace ("ome", "um").Replace ("ime", "im").Replace ("imn", "imen").Replace ("ine", "in").Replace ("ely", "ly").Replace("ure", "ur").Replace("ery", "ry"); | |
for (int n = 0; n < lowerCase.Length; n++) { | |
if (isVowel (lowerCase [n])) { | |
if (!lastWasVowel) | |
syllabeleCount++; | |
lastWasVowel = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>MaxifyJS 0.1</title> | |
<style> | |
textarea | |
{ | |
height:600px; | |
max-height:600px; | |
width:49%; |
NewerOlder