Skip to content

Instantly share code, notes, and snippets.

View christianroman's full-sized avatar

Christian Roman christianroman

  • Mexico
View GitHub Profile
//
// ViewController.m
// AVPlayerCaching
//
// Created by Anurag Mishra on 5/19/14.
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer
//
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@Takhion
Takhion / ArcUtils.java
Last active April 11, 2022 02:29
Collection of methods to achieve better circular arc drawing, as Canvas.drawArc() is unreliable. See the related article: https://medium.com/p/9155f49166b8
/**
* ArcUtils.java
*
* Copyright (c) 2014 BioWink GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is

CocoaPods + Xcode Continuous Integration

Script:

cd ${SRCROOT}
if [ -e "Pods" ]
then
pod install
else
touch Pods
@steipete
steipete / Macros.h
Last active January 6, 2024 07:24
Declare on your main init that all other init methods should call. It's a nice additional semantic warning. Works with Xcode 5.1 and above. Not tested with earlier variants, but should just be ignored. A reference to this macro shortly appeared in https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObj…
#ifndef NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#endif
#endif
@emad-elsaid
emad-elsaid / chat.rb
Created March 1, 2014 13:18
creating simple network chat using ruby
require 'sinatra' # gem install sinatra --no-rdoc --no-ri
set :port, 3000
set :environment, :production
html = <<-EOT
<html><head><style>
#text{width:100%; font-size: 15px; padding: 5px; display: block;}
</style></head><body>
<input id="text" placeholder="Write then press Enter."/>
<div id="chat"></div>
-(NSArray*)objectForKeyedSubscript:(NSString*)pattern
{
NSError *error;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
NSAssert( ! error, @"regex processing error");
NSMutableArray *strings = [NSMutableArray new];
NSArray *matches = [regex matchesInString:self options:0 range:self.fullRange];
for(NSTextCheckingResult *match in matches) {
for (NSInteger i = 0; i < match.numberOfRanges; i++) {
@mattt
mattt / Emoji.plist
Created December 30, 2013 17:26
Emoji grouped by category, as extracted by by private APIs on the iPhone simulator, via [Cédric Luthi](https://github.com/0xced).
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>People</key>
<array>
<string>😄</string>
<string>😃</string>
<string>😀</string>
<string>😊</string>
@steipete
steipete / PSPDFThreadSafeMutableDictionary.m
Created December 2, 2013 09:00
Dictionary subclass whose primitive operations are thread safe. Most of the time you don't want locking at the collection level, but there are valid use cases for this, and it's interesting how to properly subclass the NSDictionary class cluster. We're using SpinLocks here, since it's highly unlikely that any of the operation locks for more than…
@interface PSPDFThreadSafeMutableDictionary : NSMutableDictionary
@end
#import "PSPDFThreadSafeMutableDictionary.h"
#import <libkern/OSAtomic.h>
@implementation PSPDFThreadSafeMutableDictionary {
OSSpinLock _lock;
NSMutableDictionary *_dictionary; // Class Cluster!
//
// UINavigationItem+KVO.m
// Feeder
//
// Created by Brent Royal-Gordon on 7/5/13.
// Copyright (c) 2013 Architechies. All rights reserved.
//
#import "UINavigationItem+KVO.h"
@nicklockwood
nicklockwood / gist:7447381
Last active February 14, 2017 09:31
Why I still prefer nibs to storyboards.

Storyboard Segues initially seem like a pretty cool way to construct interfaces using minimal glue code. But actually, ordinary nibs already support this, and in a much more flexible way.

Certainly, a Storyboard lets you bind a button action up to display a view controller with no code, but in practice you will usually want to pass some data to the new controller, depending on which button you used to get there, and this means implementing the -prepareForSegue:sender: method, which rapidly becomes a giant if/elseif statement of doom, negating most of the benefit of the codeless segue:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"modalSegue"])
    {
        ModalViewController *controller = (ModalViewController *)segue.destination;

controller.someProperty = someValue;