Skip to content

Instantly share code, notes, and snippets.

@senthilvs7
senthilvs7 / Fastfile
Created February 20, 2016 15:52 — forked from pdesantis/Fastfile
An example Fastfile
# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "1.41.0"
default_platform :ios
platform :ios do
before_all do
ENV["SLACK_URL"] = "https://hooks.slack.com/services/MoneyWithWings"
@senthilvs7
senthilvs7 / StringSize.swift
Last active September 21, 2015 13:36 — forked from plumhead/StringSize.swift
String extension to find the layout size of a String with specified attributes.
extension String {
func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect {
let storage = NSTextStorage(string: self)
let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height))
let layout = NSLayoutManager()
layout.addTextContainer(container)
storage.addLayoutManager(layout)
storage.addAttributes(attrs, range: NSMakeRange(0, storage.length))
container.lineFragmentPadding = 0.0
let _ = layout.glyphRangeForTextContainer(container)
@senthilvs7
senthilvs7 / generate_personal_podcast.rb
Last active August 29, 2015 14:28 — forked from kelan/generate_personal_podcast.rb
A script for generating a personal podcast feed from mp3 files in a public Dropbox folder.
#!/usr/bin/env ruby -wKU
#
# by Kelan Champagne
# http://yeahrightkeller.com
#
# A script to generate a personal podcast feed, hosted on Dropbox
#
# Inspired by http://hints.macworld.com/article.php?story=20100421153627718
#
# Simply put this, and some .mp3 or .m4a files in a sub-dir under your Dropbox
@senthilvs7
senthilvs7 / CSV.swift
Last active August 29, 2015 14:27 — forked from airspeedswift/CSV.swift
CSV-parsing code in Swift
// after http://www.cocoawithlove.com/2009/11/writing-parser-using-nsscanner-csv.html
import Foundation
extension NSScanner {
func scanUpToCharactersFromSet(set: NSCharacterSet) -> String? {
var str: NSString?
return self.scanUpToCharactersFromSet(set, intoString: &str)
? str as? String
: nil
@senthilvs7
senthilvs7 / URL.swift
Last active August 29, 2015 14:27 — forked from mattt/URL.swift
struct URL {
var scheme: String?
var user: String?
var password: String?
var host: String?
var port: Int?
var path: String?
var query: String?
var fragment: String?
@senthilvs7
senthilvs7 / shapes.swift
Last active August 29, 2015 14:27 — forked from wintermuted/shapes.swift
Swift Shapes exercises
// Playground - noun: a place where people can play
import UIKit
import XCPlayground
var str = "Hello, playground"
class Shape: UIView {
var color:UIColor
@senthilvs7
senthilvs7 / remoteDataTableView.swift
Last active August 29, 2015 14:27 — forked from Starefossen/remoteDataTableView.swift
Remote JSON Data to tableView in iOS 8.0 (Swift)
import UIKit
import Foundation
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely()
class RemoteAPI {
func getData(completionHandler: ((NSArray!, NSError!) -> Void)!) -> Void {
let url: NSURL = NSURL(string: "http://itunes.apple.com/search?term=Turistforeningen&media=software")
let ses = NSURLSession.sharedSession()
@senthilvs7
senthilvs7 / geocode.swift
Last active August 29, 2015 14:27 — forked from pocketkk/geocode.swift
Swift - Retrieve Lat and Long from Geocode.us
import UIKit
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely(continueIndefinitely: true)
class Geocode {
var url : NSURL!
var request : NSURLRequest!
let queue : NSOperationQueue = NSOperationQueue()
@senthilvs7
senthilvs7 / simulation.swift
Last active August 29, 2015 14:27 — forked from binishkaspar/simulation.swift
iPhone View Simulation on Playground
import XCPlayground
import UIKit
import QuartzCore
let zoom:CGFloat = 0.5
let deviceSize = CGSize(width: 640*zoom, height: 1136*zoom)
let statusBarHeight:CGFloat = 48*zoom
let navBarHeight:CGFloat = 88*zoom
let tabBarHeight:CGFloat = 98*zoom
let bgColor = UIColor(white: 0, alpha: 0.01)
import UIKit
import XCPlayground
extension UIView {
public override func canBecomeFirstResponder() -> Bool {
return true
}
var firstSubview: UIView? {
if let f = self.subviews.first {