This file contains hidden or 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
static unichar const comma = ','; | |
static unichar const semicolon = ';'; | |
static unichar const colon = ':'; | |
static unichar const tab = '\t'; | |
static unichar const space = ' '; | |
NSRegularExpression *fieldRegExForDelimiter(unichar delimiter) { | |
NSString *fieldRegExPattern = [NSString stringWithFormat:@"(?<=^|%C)(\"(?:[^\"]|\"\")*\"|[^%C]*)", delimiter, delimiter]; // Via http://stackoverflow.com/questions/3268622/regex-to-split-line-csv-file - works very good. Handles double double quotes, fields containing a delimiter and starting and ending with double quotes, delimiter after double double quotes in field that starts and ends with double quotes. | |
return [NSRegularExpression regularExpressionWithPattern:fieldRegExPattern options:0 error:nil]; | |
} |
This file contains hidden or 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 <Foundation/Foundation.h> | |
@interface NSArray (LGCSVParser) | |
+ (instancetype)arrayWithCSVString:(NSString *)csvString delimiter:(unichar)delimiter; | |
@end |
This file contains hidden or 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
/* | |
Trying to rewrite the original GitHub Markdown CSS | |
Last Update 14-01-08 by Luis Gerhorst | |
*/ | |
body { | |
font-family: Helvetica, sans-serif; | |
font-size: 15px; | |
line-height: 1.7; | |
background-color: white; |
This file contains hidden or 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
body { | |
font-family: Helvetica, sans-serif; | |
font-size: 14px; | |
line-height: 1.6; | |
padding-top: 10px; | |
padding-bottom: 10px; | |
background-color: white; | |
padding: 30px; | |
} |
This file contains hidden or 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
NSString *text = @"Text to split, with newlines, spaces and very long words."; | |
NSUInteger maxLength = 55; // max length of one line | |
NSRegularExpression *wordLengthRegExp = [NSRegularExpression regularExpressionWithPattern:[NSString stringWithFormat:@".{1,%lu}", (unsigned long)maxLength] options:0 error:nil]; | |
NSArray *inputLines = [text componentsSeparatedByString:@"\n"]; | |
NSMutableArray *lines = [NSMutableArray array]; // output | |
for (NSString *line in inputLines) { | |
if ([line length] <= maxLength) { | |
[lines addObject:line]; | |
} else { // line too long | |
NSArray *words = [line componentsSeparatedByString:@" "]; // split into words |
This file contains hidden or 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
#define COMMA ',' | |
#define SEMICOLON ';' | |
#define COLON ':' | |
#define TAB '\t' | |
#define SPACE ' ' | |
BOOL delimiterOrNothing(unichar character) { | |
return character == COMMA || character == SEMICOLON || character == COLON || character == TAB || character == SPACE || character == 0; | |
} |
This file contains hidden or 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
var toLoad = 2, // number of chunks to receive | |
data = {}; // here we'll save the data, you could also use an array or multiple vars | |
$.ajax({ | |
url: 'a.txt', | |
error: function (jqXHR, textStatus, errorThrown) { | |
// handle error | |
}, | |
success: function (dataA, textStatus, jqXHR) { | |
data['a.txt'] = dataA; // so you can later access it in chunkReceived() |
This file contains hidden or 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
function URL(href) { | |
var element = document.createElement('a'); | |
element.href = href; | |
this.protocol = element.protocol; // "http:" | |
this.hostname = element.hostname; // "example.com" | |
this.port = element.port; // "3000" | |
this.pathname = element.pathname; // "/pathname/" | |
this.search = element.search; // "?search=test" |
This file contains hidden or 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
# | |
# AppDelegate.rb | |
# Alarm | |
# | |
# Created by Luis Gerhorst on 09.09.13. | |
# | |
class AppDelegate | |
attr_accessor :window, :datePicker, :createAlarmButton, :deleteAlarmButton |
This file contains hidden or 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
slate.configAll({ | |
gridBackgroundColor: [50, 50, 50, 0.95], | |
gridRoundedCornerSize: 3, | |
gridCellBackgroundColor: [0, 0, 0, 0.5], | |
gridCellSelectedColor: [70, 150, 255, 0.5], | |
gridCellRoundedCornerSize: 3 | |
}); | |
slate.bindAll({ | |