Skip to content

Instantly share code, notes, and snippets.

View miwillhite's full-sized avatar

Matthew Willhite miwillhite

View GitHub Profile
f1 = Fiber.new { sleep 1; puts '1' }
f2 = Fiber.new { sleep 0.1; puts '2' }
f1.resume; f2.resume
# => 1
# => 2
@miwillhite
miwillhite / swift_tips.md
Last active August 29, 2015 14:07
Gettin Switty Wit It

UIButton

Button handlers cannot be private

For-in

Cast the collection (which also casts the item) by appending as Type

__weak typeof(self) weakSelf = self;
[[NSNotificationCenter defaultCenter] addObserverForName:ACAccountStoreDidChangeNotification
object:nil
queue:nil
usingBlock:^(NSNotification *note) {
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf requestProfileInformation];
}];
// The declaration
@property (nonatomic, readonly, getter = hasTrackingEnabled) BOOL trackingEnabled;
// The spec
[[[targetMock expect] andReturnValue:@YES] hasTrackingEnabled];
// The failure
// Return value does not match method signature; signature declares 'B' but value is 'c'.
Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0x181baad0 {NSFilePath=/var/mobile/Applications/C0EB75DC-B716-4404-82AF-02C24C631B69/Library/Application Support/assets/packages/thumbs/atmosphere_cats@2x.png, NSUnderlyingError=0x181ba6a0 "The operation couldn’t be completed. No such file or directory"}
%div{ 'ng-controller' => 'StoreCtrl' }
%a{ href: '#/stores' } Back to Stores
%h1 {{ store.name }}
%section.installations
%accordion{ 'close-others' => 'false' }
%accordion-group{ 'ng-repeat' => 'installation in store.installations' }
%accordion-heading {{ installation.name }}
%pane{ 'installation' => 'installation' }
#store_installations{ 'ng-show' => 'stores' }
%h3 Your stores
%ul
%li{ 'ng-repeat' => 'store in stores' }
{{ store.name }}
storeControllers.directive('newPane', function() {
return {
restrict: 'E',
scope: {
},
controller: ['$scope, InstallationType',
function($scope, InstallationType) {
$scope.installation_types = InstallationType.query();
}],
templateUrl: '<%= asset_path 'assets/templates/stores/new-pane.html' %>'
ClearMocks(mockPackage, mockAsset)
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
typedef enum {
helloBlahType,
byeBlahType
} BlahType;
BlahType blah = 999999;