Skip to content

Instantly share code, notes, and snippets.

#ifndef ma_concurrent_queue_h
#define ma_concurrent_queue_h
// Based on code from http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html
// Original version by Anthony Williams
// Modifications by Michael Anderson
#include "boost/thread.hpp"
#include <deque>
@vixvix
vixvix / pop back 2 controllers on the stack to the setup screen
Created October 30, 2013 14:32
pop back 2 controllers on the stack to the setup screen
http://stackoverflow.com/questions/4985816/how-do-i-pop-the-view-controller-underneath-a-pushed-view-controller
// pop back 2 controllers on the stack to the setup screen
//
// locally store the navigation controller since
// self.navigationController will be nil once we are popped
//
UINavigationController *navController = self.navigationController;
@vixvix
vixvix / obj-c singleton
Created October 30, 2013 14:56
obj-c singleton
+ (id)sharedManager {
static MyManager *sharedMyManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedMyManager = [[self alloc] init];
});
return sharedMyManager;
}
@vixvix
vixvix / Remove all subviews
Created November 7, 2013 20:20
objective-c remove all subviews
For NSView (desktop Mac development only), you can simply use the following:
[someNSView setSubviews:[NSArray array]];
For UIView (iOS development only), you can safely use makeObjectsPerformSelector: because the subviews property will return a copy of the array of subviews:
[[someUIView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
http://stackoverflow.com/questions/2156015/remove-all-subviews
@vixvix
vixvix / button on tableViewCell
Created November 15, 2013 22:33
button on tableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
...
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
...
// set the button's target to this table view controller so we can interpret touch events and map that to a NSIndexSet
[button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];
...
cell.accessoryView = button;
@vixvix
vixvix / python twitter
Last active December 28, 2015 22:59
python twitter
https://github.com/sixohsix/twitter
https://github.com/ryanmcgrath/twython
https://github.com/bear/python-twitter
https://github.com/joshthecoder/tweepy
@vixvix
vixvix / noSQL for iOS
Created December 21, 2013 02:51
noSQL for iOS
http://docs.couchbase.com/couchbase-lite/cbl-ios/
https://github.com/couchbase/couchbase-lite-ios
https://github.com/tciuro/NanoStore
@vixvix
vixvix / gist:8567432
Created January 22, 2014 21:13
diable/enable osx dashboard
disabled:
defaults write com.apple.dashboard mcx-disabled -boolean YES && killall Dock
enabled:
defaults write com.apple.dashboard mcx-disabled -boolean NO && killall Dock
http://apple.stackexchange.com/questions/91722/can-i-disable-dashboard-in-mountain-lion
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@vixvix
vixvix / gist:8794985
Created February 4, 2014 00:00
Xcode 4 .xib Create iPad Version
Make a copy of the .xib in the Finder.
Open the copied file in a text editor.
Change "com.apple.InterfaceBuilder3.CocoaTouch.XIB" to "com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB".
Change all instances of "IBCocoaTouchFramework" to "IBIPadFramework".
Search for sizes like {480, 320} and edit them. Or just reopen the file in Xcode and use the GUI to resize items as needed.
http://stackoverflow.com/questions/5347198/xcode-4-xib-create-ipad-version