Skip to content

Instantly share code, notes, and snippets.

@jodell
jodell / nah_xcode_uncrustify.rb
Created February 20, 2012 04:34 — forked from mnem/nah_xcode_uncrustify.rb
Script file to be run as an Xcode 4 behaviour which uncrustifies the project source using reasonable Objective-C formatting defaults. Alternatively, you can run it and pass a path to uncrustify.
#!/usr/bin/env ruby
###########################################################################
# Script to be called as an Xcode 4 behaviour which will attempt to
# uncrustify all source files in the open project.
#
# (c) Copyright 2012 David Wagner.
#
# Complain/commend: http://noiseandheat.com/
#
#*************************************************************************#
@TonnyXu
TonnyXu / gcdSemaphor.md
Created August 7, 2012 06:23
Using GCD to let a thread/queue wait, an alternative way for `sleep(n)`

Before GCD

Almost the only option for us is sleep(n) (if you are familiar with SIGNAL, you can also use it). We are familiar with it, so let's pass it.

After GCD

There is resource called semaphore, use it can make your code more robust and more efficient.

 NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.google.com"]];
@kimhunter
kimhunter / compare_dispatch_apply.m
Created November 6, 2012 22:56
Compare Dispatch Concurrent to for loop
#import <Foundation/Foundation.h>
#define LOGV(V) NSLog(@"%s = %@", #V, V);
#define LOGD(I) NSLog(@"%s = %d", #I, I);
int main(int argc, const char * argv[])
{
@autoreleasepool
{
dispatch_queue_t dqueue = NULL;
@tanner0101
tanner0101 / NSDataExtensions.swift
Last active February 3, 2017 04:18
Convert to and from NSData for common Swift types. Includes Eddystone URL conversion.
//
// NSData.swift
// Pods
//
// Created by Tanner Nelson on 9/15/15.
//
//
import Foundation
@nilium
nilium / WorkQueue.swift
Last active February 15, 2021 14:47
Basic Swift enum to wrap different types of work queues.
//
// Copyright Noel Cower 2014.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
import Foundation
/// Asynchronous WorkQueue scheduling operator.
@mipstian
mipstian / UICollectionView+ReloadItemsAnimated.h
Created January 19, 2013 10:53
UICollectionView category to disable animation on reloadItemsAtIndexPaths:
#import <UIKit/UIKit.h>
@interface UICollectionView (ReloadItemsAnimated)
- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths animated:(BOOL)animated;
@end
@miketsprague
miketsprague / DeviceRaisedToEarListener.swift
Created November 3, 2015 18:47
Swift class that lets you know when the user's device was raised to their ear
import Foundation
import CoreMotion
// Warning: This class assumes no one else is currently using the CMMotionManager.
class DeviceRaisedToEarListener: NSObject {
private let deviceQueue = NSOperationQueue()
private let motionManager = CMMotionManager()
private var vertical: Bool = false
private(set) var isRaisedToEar: Bool = false {
@bdkjones
bdkjones / safesleep.txt
Created November 12, 2012 00:00
Disabling Safe Sleep After November, 2012
In early November, 2012, Apple issued a graphics update for all mid-2012 MacBooks. In a continued streak of stupidity, however, this update forces your Mac to use "Safe Sleep". This means that the entire contents of your RAM is written to your disk every time you put your Mac to sleep.
This is retarded on the scale of the Titanic's navigational plan for two reasons:
1) Your Mac likely has 8 or 16GB of RAM. This is a ton of wasted disk space; especially on MacBook Airs that ship with only 256GB SSDs to begin with.
2) SSDs wear out as you write to them. Each cell of a SSD can only be written to a certain number of times before it becomes read-only. If you put your computer to sleep many times a day, OS X is slowly but surely destroying your SSD with unneeded write cycles.
Worst of all, the graphics update makes it IMPOSSIBLE to turn off safe sleep using the standard approach you'll find on Google:
@rob-murray
rob-murray / set_agv_ver.sh
Last active July 1, 2022 01:31
Use agvtool to set Xcode project build number
#!/bin/bash
#
# Use agvtool to set Xcode project build number and create git tag
# Note: requires Xcode project configured to use Apple Generic Versioning and git
#
# Usage: set_agv_ver.sh 123
#
# src: https://gist.github.com/rob-murray/8644974
#
@ideabucket
ideabucket / README.md
Last active December 30, 2022 15:53
BBEdit text filter to replace Markup → Tidy → Reflow XML

As of BBEdit 13.1, the HTML Tidy built-ins are back and you should use those instead. This gist is so old it refers to "OS X", c’mon!

If for some reason you are using this, note @ryanfrancesconi’s comment about the correct place to put the file when using sandboxed versions of BBEdit.