Skip to content

Instantly share code, notes, and snippets.

View saiday's full-sized avatar
:shipit:
su su su

Saiday saiday

:shipit:
su su su
View GitHub Profile
@saiday
saiday / private.xml
Last active December 15, 2015 15:28
KeyRemap4Macbook JIS keyboard change YEN key to `
<?xml version="1.0"?>
<root>
<item>
<name>JIS_YEN to `</name>
<identifier>private.remap.childa</identifier>
<autogen>--KeyToKey-- KeyCode::JIS_YEN, KeyCode::BACKQUOTE</autogen>
</item>
</root>
require 'rubygems'
require 'httparty'
require 'pry'
results = []
def get_device_tokens url
if url.nil?
url = "https://go.urbanairship.com/api/device_tokens/"
end
options = {:basic_auth => {:username => 'x', :password => 'x'}}
@saiday
saiday / gist:7394795
Created November 10, 2013 06:58
UITabBarController disable Title, Image align center
.h
@interface TabViewController : UITabBarController
.m
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
require 'rubygems'
require 'httparty'
require 'pry'
results = []
def get_device_tokens url
if url.nil?
url = "https://go.urbanairship.com/api/device_tokens/"
end
options = {:basic_auth => {:username => 'x', :password => 'x'}}
@saiday
saiday / UIImage+Decompression.h
Created December 3, 2013 10:22
> System only supports RGB, set explicitly and prevent context error, if the downloaded image is not the supported format. Inspired by @njdehoog
#import "UIImage+Decompression.h"
@implementation UIImage (Decompression)
+ (UIImage *)decodedImageWithImage:(UIImage *)image
{
CGImageRef imageRef = image.CGImage;
// System only supports RGB, set explicitly and prevent context error
// if the downloaded image is not the supported format
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
@saiday
saiday / ConnectionService.m
Last active January 4, 2016 16:09
Lightweight Core Data migration setup
- (void)defineCoreData
{
// Complete Core Data stack initialization
[managedObjectStore createPersistentStoreCoordinator];
NSDictionary *options = @{
NSMigratePersistentStoresAutomaticallyOption : @YES,
NSInferMappingModelAutomaticallyOption : @YES
};
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:[self propertyFromPlist:@"Settings" withKey:@"db_name"]];
NSString *seedPath = [[NSBundle mainBundle] pathForResource:@"RKSeedDatabase" ofType:@"sqlite"];
@saiday
saiday / ViewController.m
Last active August 29, 2015 13:55
setupHysteriaPlayer
- (void)setupHyseteriaPlayer
{
HysteriaPlayer *hysteriaPlayer = [HysteriaPlayer sharedInstance];
[hysteriaPlayer registerHandlerPlayerRateChanged:^{
} CurrentItemChanged:^(AVPlayerItem *item) {
} PlayerDidReachEnd:^{
@interface PlayingItems : NSObject
+ (instancetype)sharedInstance;
@property (nonatomic, strong) NSMutableArray *queueItems;
@end
@saiday
saiday / ViewController.m
Last active August 29, 2015 13:56
setupNewSourceGetter
- (void)getPreviews:(NSString *)itunesAPI
{
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:itunesAPI parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
[[HysteriaPlayerManager sharedInstance] setupNewSourceGetter:responseObject];
} failure:nil];
}
- (IBAction)PreviewU2:(id)sender
@saiday
saiday / ViewController.m
Created February 4, 2014 18:03
IBActions
- (IBAction)PreviewU2:(id)sender
{
NSString *itunesAPIU2 = @"https://itunes.apple.com/lookup?amgArtistId=5723&entity=song&limit=5&sort=recent";
[self getPreviews:itunesAPIU2];
}
- (IBAction)previewJackJohnson:(id)sender
{
NSString *itunesAPIJackJohnson = @"https://itunes.apple.com/lookup?amgArtistId=468749&entity=song&limit=5&sort=recent";