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
// this code does work, but since it's from a 'secret' project, I can't display | |
// the other code. Implement it in your own project, it'll work. | |
// | |
// LOCAL.swift | |
// Wildcard | |
// | |
// Created by Samuel Beek on 08/07/15. | |
// Copyright (c) 2015 Wildcard. All rights reserved. | |
// |
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
// | |
// LogHelper.swift | |
// | |
// Created by Samuel Beek on 24/06/15. | |
// Copyright (c) 2015 Samuel Beek. All rights reserved. | |
// http://twitter.com/samuelbeek | |
/// Logs objects | |
func log<T>(object: 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
// My way of doing constants in Swift. | |
// Usage example: if(Constants.debug) { println("debug message") } | |
struct Constants { | |
// App wide things: | |
static let debug = true | |
static let production = true | |
static let appVersion = "iOS-0.1.0b300" | |
static let apiBase = "http://api.com/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
// just add random-backgroundcolor to the element you want to give a random background color | |
app.directive("randomBackgroundcolor", function () { | |
return { | |
restrict: 'EA', | |
replace: false, | |
link: function (scope, element, attr) { | |
//generate random color | |
var color = '#' + (Math.random() * 0xFFFFFF << 0).toString(16); | |
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
// backgrounds: | |
.bgRed { | |
background-color: rgba(255,0,0,0.5)!important; | |
} | |
.bgYellow { | |
background-color: rgba(255,204,0,0.5)!important; | |
} | |
.bgGreen { |
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 isSmaller(smaller: CGSize, bigger: CGSize) -> Bool { | |
if(smaller.width >= bigger.width) { return false } | |
if(smaller.height >= bigger.height) { return false } | |
return true | |
} |
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
// | |
// DistanceHelper.Swift | |
// Wildcard | |
// | |
// Created by Samuel Beek on 01-05-15. | |
// Copyright (c) 2015 Wildcard. All rights reserved. | |
// | |
import Foundation |
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
// movieService can be used in a controller like this: | |
// movieService.getMovieDetails("Pulp Fiction").success(function (data) { | |
// $scope.movie = data | |
// } | |
app.factory('movieService', ['$http', function ($http) { | |
return { | |
getMovieDetails: function (title) { | |
var getData = { | |
method: 'jsonp', | |
url: 'http://www.omdbapi.com/?t=' + title, //add +'&apikey=YOUR_API_KEY' if you have one. |
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
// Verification code is at least for digit long | |
let verificationCode = String(1000+arc4random_uniform(8999)) |
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 Alamofire // installation instructions for Alamofire can be found here: https://github.com/Alamofire/Alamofire | |
// Sends text message to phone number | |
func sendText(phoneNumber: String, message: String) { | |
let apiKey = "AccessKey YOUR_ACCES_KEY" | |
let originator = "YOUR_NAME" | |
// create a new manager instance (so you don't overwrite any other API's authorization) | |
var manager = Manager.sharedInstance |