Skip to content

Instantly share code, notes, and snippets.

View aaronpearce's full-sized avatar

Aaron Pearce aaronpearce

View GitHub Profile
@aaronpearce
aaronpearce / gist:8223366
Created January 2, 2014 18:02
.gitignore
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
@aaronpearce
aaronpearce / dA Symbols - Simple to New Conversion Table
Last active December 24, 2015 10:49
Conversion table of old dA symbols to new symbols.
New symbols use a custom font, these are the Unicode codes for each icon.
"~" => "" // normal member
"*" => "\uE001" // premium member
"=" => "\uE002" // beta tester
"`" => "\uE000" // senior
"$" => "\uE00C" // staff
"^" => "\uE006" // volunteer
":" => "\uE005" // hell freezes over premium member | icon is color: rgba(216, 108, 42, 0.8)/#D76B29
"." => "\uE004" // hell freezes over beta tester | icon is color: rgba(216, 108, 42, 0.8)/#D76B29
#!/usr/bin/env ruby
# Require gems needed to run
require 'oauth2'
require "socket"
require 'net/http'
require 'uri'
require 'net/http/post/multipart'
require 'launchy'
@aaronpearce
aaronpearce / Base36 Converter
Created June 28, 2013 05:47
Just a small script to help me convert between base10 and base36 as needed
#!/usr/bin/env ruby
toValue = ARGV[0].to_i
idValue = ARGV[1]
if(!toValue || !idValue)
puts "You must supply your base-N number, either 10 or 36 and the value to be converted!\nExample: baseChange 36 2410189243882429"
else
if(toValue === 10)
puts idValue.to_i(36)
// loading
NSString *jsonString = [SSKeychain passwordForService:@"info" account:@"info"];
if(jsonString)
[array addEntriesFromDictionary:[NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]];
// saving
NSString *jsonString = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:nil] encoding:NSUTF8StringEncoding];
[SSKeychain setPassword:jsonString forService:@"info" account:@"info"];
@aaronpearce
aaronpearce / gist:4632348
Last active December 11, 2015 17:08
dM2 Packet Parser
-(NSMutableDictionary *)parser:(NSString *)packet:(NSInteger)depth {
NSMutableArray *partsArr = [NSMutableArray arrayWithArray:[packet componentsSeparatedByString:@"\n\n"]]; // Split by \n\n
NSMutableArray *headArr = [NSMutableArray arrayWithArray:[[partsArr objectAtIndex:0] componentsSeparatedByString:@"\n"]]; // Split by \n
[partsArr removeObjectAtIndex:0];
NSMutableArray *cmdArr = [NSMutableArray arrayWithArray:[[headArr objectAtIndex:0] componentsSeparatedByString:@" "]];
[headArr removeObjectAtIndex:0];
NSString *cmd = [cmdArr objectAtIndex:0];
@aaronpearce
aaronpearce / gist:4632341
Last active December 11, 2015 17:08
dAmnObj-C Packet Parser Method
-(SYPacket*)initWithString:(NSString *)string {
if(self = [super init]) {
// set up basic alpha char set
NSCharacterSet *alphaCharSet = [NSCharacterSet alphanumericCharacterSet];
// Retain raw packet string
self.raw = [string copy];
// Set up scanner
NSScanner *scanner = [NSScanner scannerWithString:string];
+(void)runCommand:(NSString *)command withParameters:(NSDictionary *)params {
// create class name
command = [[command componentsSeparatedByString:@" "] objectAtIndex:0];
command = [NSString stringWithFormat:@"SYEvent_%@", [command capitalizedString]]; // capitalize
Class class = NSClassFromString(command);
if([class respondsToSelector:@selector(run:)])
[class performSelector:@selector(run:) withObject:params];
}
// checks if class exists for command
presetning this onto a normla view controller. Comes as a pagesheet everytime I think
NSString *storyboardName = @"MainStoryboard_iPhone";
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) storyboardName = @"MainStoryboard_iPad";
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
UINavigationController *walkThrough = [storyBoard instantiateViewControllerWithIdentifier:@"walkthroughNav"];
walkThrough.modalPresentationStyle = UIModalPresentationFormSheet;
self.tableView.backgroundView = nil;
self.tableView.backgroundColor = [UIColor colorWithRed:0.961 green:0.961 blue:0.961 alpha:1.000];