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
extension String { | |
/// Returns substring starting from given numeric index to the end of the string. | |
func substring(fromNumericIndex numericIndex: Int) -> String { | |
return self.substring(from: self.index(self.startIndex, offsetBy: numericIndex)) | |
} | |
} |
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
/// Returns a sequence of Fibonacci numbers. | |
/// | |
/// The sequence is [1, 1, 2, 3, 5, 8, 13, ...]. | |
/// | |
/// The sequence is not infinite; it terminates when | |
/// the next value would be greater than | |
/// `Int.max`. | |
/// | |
/// - returns: A sequence of Fibonacci numbers. | |
public func fibonacciSequence() -> AnySequence<Int> { |
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 Foundation | |
extension FileHandle { | |
/// Return an iterator over the bytes in the file. | |
/// | |
/// - returns: An iterator for UInt8 elements. | |
public func bytes() -> FileHandleByteIterator { | |
return FileHandleByteIterator(fileHandle: self) | |
} |
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 CoreGraphics | |
extension CGPath { | |
/// Call the given closure on each element of the path. | |
func forEach(_ body: @escaping (CGPathElement) -> Void) { | |
var info = body | |
self.apply(info: &info) { (infoPtr, elementPtr) in | |
let opaquePtr = OpaquePointer(infoPtr!) | |
let body = UnsafeMutablePointer<(CGPathElement) -> Void>(opaquePtr).pointee | |
body(elementPtr.pointee) |
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 CoreGraphics | |
extension CGPoint { | |
/// Calculate Y-axis distance between a point and a line segment. | |
/// | |
/// - parameter endpointA: One endpoint of the line segment. | |
/// - parameter endpointB: The other endpoint of the line segment. | |
/// | |
/// - returns: Distance, or `nil` if this point's x-coordinate is not between those of the endpoints. |
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
---------- | |
2016-10-25 | |
---------- | |
06:15 AM - F.B.I. Story, The (1959) | |
Description: A dedicated FBI agent thinks back on the agency's battles against the Klan, organized crime and Communist spies. | |
Genres: Drama, Crime, Adaptation | |
Directed by: Mervyn LeRoy, David Silver, Gil Kissel, Jack Boland | |
Written by: Richard L. Breen, John Twist |
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
#!/usr/bin/env node | |
const request = require('request'); | |
// See <http://www.tcm.com/tcmws/v1/docs/welcome.html> | |
const url_base = 'http://www.tcm.com/tcmws/v1' | |
function showWhatsOnNow() { | |
request(`${url_base}/schedule/whatsOnNow/us.json`, (error, response, body) => { | |
if (error) { |
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
set nocompatible | |
" Global variables {{{1 | |
" | |
let g:kj_foldcolumn=4 | |
let g:kj_quickfix_is_open = 0 | |
" Options {{{1 |
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
#!/bin/bash | |
# | |
# Given a source image, create icons in all sizes needed for an Android launcher icon. | |
# | |
# First (required) argument is path to source file. | |
# | |
# Second (optional) argument is the filename to be used for the output files. | |
# If not specified, defaults to "ic_launcher.png". | |
# | |
# Third (optional) argument is path to the GraphicsMagick gm executable. |
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
#!/bin/bash | |
# | |
# Given a source image, create icons in all sizes needed for an iOS app icon. | |
# See <https://developer.apple.com/library/ios/qa/qa1686/_index.html> for details. | |
# | |
# First (required) argument is path to source file. | |
# | |
# Second (optional) argument is the prefix to be used for the output files. | |
# If not specified, defaults to "app_icon_". | |
# |