Title: Simple Sabotage Field Manual Author: Strategic Services Office of Strategic Services
This file contains 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 "UICollectionViewFlowLayoutCenterItem.h" | |
@implementation UICollectionViewFlowLayoutCenterItem | |
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity | |
{ | |
CGSize collectionViewSize = self.collectionView.bounds.size; | |
CGFloat proposedContentOffsetCenterX = proposedContentOffset.x + self.collectionView.bounds.size.width * 0.5f; | |
CGRect proposedRect = self.collectionView.bounds; |
This file contains 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
*.strings utf16 diff=localizablestrings |
This file contains 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
-(UIImage*)mmg_imageScaledToFitSize:(CGSize)fitSize | |
{ | |
// Create a vImage_Buffer from the CGImage | |
CGImageRef sourceRef = self.CGImage; | |
vImage_Buffer srcBuffer; | |
vImage_CGImageFormat format = { | |
.bitsPerComponent = 8, | |
.bitsPerPixel = 32, | |
.colorSpace = NULL, | |
.bitmapInfo = (CGBitmapInfo)kCGImageAlphaFirst, |
This file contains 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
func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { | |
let calendar = NSCalendar.currentCalendar() | |
let unitFlags = NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekOfYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitSecond | |
let now = NSDate() | |
let earliest = now.earlierDate(date) | |
let latest = (earliest == now) ? date : now | |
let components:NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: nil) | |
if (components.year >= 2) { | |
return "\(components.year) years ago" |
This file contains 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
DROP TABLE IF EXISTS test_table; | |
CREATE TABLE test_table( | |
id bigserial NOT NULL, | |
latitude double precision, | |
longitude double precision, | |
geom geometry, | |
geog geography, | |
updated_ts double precision, | |
CONSTRAINT test_table_unique_key UNIQUE (id) | |
); |
This file contains 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 CoreLocation | |
func locationVCardURLFromCoordinate(coordinate: CLLocationCoordinate2D) -> NSURL? | |
{ | |
guard let cachesPathString = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true).first else { | |
print("Error: couldn't find the caches directory.") | |
return nil | |
} | |
This file contains 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
/// Retries the given throwing `block` as a promise `tries` times, | |
/// re-calling `block` another time until exhausting the tries. | |
func retry<T>(tries count: Int, block: () throws -> T) -> Promise<T> { | |
return Promise().thenRetry(tries: count, block: block) | |
} | |
/// Retries the given promise-returning `block` as a promise `tries` times, | |
/// re-calling `block` another time until exhausting the tries. | |
func retry<T>(tries count: Int, block: () -> Promise<T>) -> Promise<T> { | |
return Promise().thenRetry(tries: count, block: block) |
This file contains 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
// Evaluates the given closure when two `Optional` instances are not `nil`, | |
// passing the unwrapped values as parameters. (Thanks, Mike Ash, Tim Vermeulen) | |
// Following the example of IEEE754 with NAN, any comparison involving | |
// .None is false | |
// | |
// See also: http://stackoverflow.com/questions/1565164/what-is-the-rationale-for-all-comparisons-returning-false-for-ieee754-nan-values | |
// Brent RG has a really interesting take here: https://gist.github.com/brentdax/60460ad4578d5d8d52a9d736240cfea6 | |
fileprivate func _flatMap2<T, U, V>(_ first: T?, _ second: U?, _ transform: (T, U) throws -> V?) rethrows -> V? { |
This file contains 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
# Before running this script execut the following command: | |
# $ pip install requests | |
# To run this script execute: | |
# $ python export_foursquare_checkins.py | |
import requests | |
import json | |
url_template = 'https://api.foursquare.com/v2/users/self/checkins?limit=250&oauth_token={}&v=20131026&offset={}' | |
# If you navigate to https://developer.foursquare.com/docs/explore, Foursquare |
OlderNewer