See
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace bamthread | |
| { | |
| typedef std::unique_ptr<boost::asio::io_service::work> asio_worker; | |
| // the actual thread pool | |
| struct ThreadPool { | |
| ThreadPool(size_t threads) :service(), working(new asio_worker::element_type(service)) { | |
| for ( std::size_t i = 0; i < threads; ++i ) { | |
| auto worker = boost::bind(&boost::asio::io_service::run, &(this->service)); | |
| g.add_thread(new boost::thread(worker)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1. Disable centered look & animation: | |
| // 1.1. Subclass NSSearchFieldCell and add: | |
| - (BOOL)isCenteredLook | |
| { | |
| return NO; | |
| } | |
| // 1.2. Subclass NSSearchField and add: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| /** | |
| Determine whether Optional collection is nil or an empty collection | |
| :param: collection Optional collection | |
| :returns: true if collection is nil or if it is an empty collection, false otherwise | |
| */ | |
| public func isNilOrEmpty<C: CollectionType>(collection: C?) -> Bool { | |
| switch collection { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #=============================================================================== | |
| # Filename: boost.sh | |
| # Author: Pete Goodliffe | |
| # Copyright: (c) Copyright 2009 Pete Goodliffe | |
| # Licence: Please feel free to use this, with attribution | |
| # Modified version | |
| #=============================================================================== | |
| # | |
| # Builds a Boost framework for iOS, iOS Simulator, and OSX. | |
| # Creates a set of universal libraries that can be used on an iOS and in the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| class CountAndroidMethods | |
| def count(path) | |
| full_folder_path = File.expand_path(path) | |
| total_count = 0 | |
| # Traverse the folder | |
| Dir.entries(full_folder_path).each {|file| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A much better version of C#-style Async/Await. It can return values! | |
| import Cocoa | |
| struct Await<T> { | |
| // private | |
| let group: dispatch_group_t | |
| let getResult: () -> T | |
| // public | |
| func await() -> T { return getResult() } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5] | |
| func partition(v: Int[], left: Int, right: Int) -> Int { | |
| var i = left | |
| for j in (left + 1)..(right + 1) { | |
| if v[j] < v[left] { | |
| i += 1 | |
| (v[i], v[j]) = (v[j], v[i]) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension Array { | |
| func contains<U: Equatable>(object:U) -> Bool { | |
| return (self.indexOf(object) != nil); | |
| } | |
| func indexOf<U: Equatable>(object: U) -> Int? { | |
| for (idx, objectToCompare) in self.enumerate() { | |
| if let to = objectToCompare as? U { |