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
struct Grid<T> { | |
var array : Array<Array<T>> | |
let rows : Int | |
let columns : Int | |
init(rows : Int, columns : Int, initialValue: T) { | |
self.rows = rows | |
self.columns = columns | |
self.array = Array<Array<T>>() |
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 | |
import SpriteKit | |
import UIKit | |
extension SKColor { | |
convenience init(rgba: String) { | |
var red: CGFloat = 0.0 | |
var green: CGFloat = 0.0 | |
var blue: CGFloat = 0.0 | |
var alpha: CGFloat = 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
func getRandomColor() -> SKColor { | |
var randomRed:CGFloat = CGFloat(drand48()) | |
var randomGreen:CGFloat = CGFloat(drand48()) | |
var randomBlue:CGFloat = CGFloat(drand48()) | |
return SKColor(red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0) | |
} | |
// Usage |
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 generateRandomIndex(#lower: Int , upper: Int) -> Int { | |
return lower + Int(arc4random_uniform(UInt32(upper - lower + 1))) | |
} | |
// Usage | |
var randomDice : Int = generateRandomIndex(lower: 1, upper: 6) |
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
// Searching for a toString() method in Swift? Use the printable protocol! | |
// Implement Printable protocol and create a description variable | |
// https://developer.apple.com/library/ios/documentation/General/Reference/SwiftStandardLibraryReference/Printable.html | |
class Person : Printable { | |
var name : String! | |
init(name : String) { | |
self.name = name | |
} |
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 | |
public class PebbleConnector : NSObject, PBPebbleCentralDelegate, PBWatchDelegate { | |
public class var sharedInstance: PebbleConnector { | |
struct Singleton { | |
static let instance = PebbleConnector() | |
} | |
return Singleton.instance |
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 random = new Random(); | |
int r = random.Next(1000); | |
} | |
<p><img src="@Url.Content("~/images/records/" + Model.id + ".jpg")?time=@r" alt="Album cover" class="img-responsive" /></p> |
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" | |
} else if (components.year >= 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
1. `$ npm install gitlabhook` | |
2. Copy webhook.js in directory | |
3. Create systemd service, instructions can be found here: https://github.com/rolfn/node-gitlab-hook#installation-hints-for-linux | |
4. Or test using `node webhook.js` |
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 http = require('http'); | |
var sockets = require('./sockets'); | |
var server = http.createServer(app); | |
sockets.connect(server); | |
sockets.emit('event', { message: 'This is an event!' }); |
OlderNewer