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
package main | |
import ( | |
"fmt" | |
) | |
type IPAddr [4]byte | |
func (ip IPAddr) String() string { | |
str := "" |
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
package main | |
import "fmt" | |
// fibonacci is a function that returns | |
// a function that returns an int. | |
func fibonacci() func() int { | |
numbers := make([]int, 2) | |
return func() 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
package main | |
import ( | |
"golang.org/x/tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
countForWord := make(map[string]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
package main | |
import ( | |
"golang.org/x/tour/pic" | |
) | |
func Pic(dx, dy int) [][]uint8 { | |
// Create pixels | |
pixels := make([][]uint8, dy) |
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
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func Sqrt(x float64) float64 { | |
guess := 1.0 |
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
//: Bitcoin Script Interpreter | |
import Foundation | |
/** Script Operation | |
*/ | |
enum Operation { | |
case checkMultisig | |
case checkSig | |
case dup |
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 UIKit | |
/** Alert controller that can be presented in any context and it will appear on top | |
*/ | |
class GlobalAlertController: UIAlertController { | |
// MARK: - Properties (Private Mutable) | |
/** Window to present alert controller in | |
*/ | |
private lazy var _window: UIWindow = { |
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 UIKit | |
/** Helper methods for CGAffineTransform | |
*/ | |
extension CGAffineTransform { | |
/** Make a vertical flip transformation | |
*/ | |
static func flipVertical() -> CGAffineTransform { | |
return CGAffineTransformMakeScale(1, -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
func localizedStringForNumber(number: Int) -> String { | |
let numberFormatter = NSNumberFormatter() | |
numberFormatter.locale = NSLocale.currentLocale() | |
numberFormatter.numberStyle = .NoStyle | |
return numberFormatter.stringFromNumber(number) ?? String(number) | |
} |
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
var (hue, saturation, brightness, alpha) = (CGFloat(0.0), CGFloat(0.0), CGFloat(0.0), CGFloat(0.0)) | |
let originalColor = UIColor.redColor() | |
if originalColor.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha) { | |
let grayscale = UIColor(hue: hue, saturation: 0, brightness: brightness, alpha: alpha) | |
} |