Skip to content

Instantly share code, notes, and snippets.

@tungpt247
tungpt247 / sublime_text_3_license_key
Created February 5, 2015 07:52
Sublime Text 3 License Key (Build 3065)
—– BEGIN LICENSE —–
K-20
Single User License
EA7E-940129
3A099EC1C0B5C7C5 33EBF0CF BE82FE3B
//
// UINavigationBar+CustomHeight.h
//
// Copyright (c) 2014 Maciej Swic
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@tungpt247
tungpt247 / dissmiss keyboard in Swift
Last active August 29, 2016 02:04
Diss miss keyboard when tab on view
// tap anywhere on the view
var viewTab = UITapGestureRecognizer(target: self, action: "dismissKeyboard")
view.addGestureRecognizer(viewTab)
func dismissKeyboard() {
view.endEditing(true)
}
@tungpt247
tungpt247 / Make delay tasks in special time in Swift
Last active August 29, 2016 02:06
execute a block code after a specified delay
func delay(delay: Double, closure: ()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(delay * Double(NSEC_PER_SEC))
),
dispatch_get_main_queue(),
closure
)
}
@tungpt247
tungpt247 / xcode-autocompletion
Last active August 29, 2016 02:07
Xcode: Native Fuzzy Autocompletion
You can turn it on manually if you want. Just quit Xcode first, open terminal and paste:
defaults write com.apple.dt.Xcode IDECodeCompletionFuzzyMode 3
@tungpt247
tungpt247 / xcode7-error-running-playground
Created October 26, 2015 03:22
xcode 7. Error running playground. Unable to find suitable target device. (iOS Swift)
Quit Xcode
Delete the folder /Users/<username>/Library/Developer/CoreSimulator/Devices.
For example, in Terminal: rm -rf ~/Library/Developer/CoreSimulator/Devices
In Terminal: killall -9 com.apple.CoreSimulator.CoreSimulatorService (or just reboot).
@tungpt247
tungpt247 / commandline-testing-iphone-app
Created October 30, 2015 03:14
Run Testing you app on Commandline
xcodebuild \
-scheme your-project-name \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1' \
test | xcpretty --test --color
@tungpt247
tungpt247 / delete-derived-data
Last active November 7, 2015 03:08
Delete derived data
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf /Users/your-name/Library/Developer/Xcode/DerivedData/*
rm -rf ~/.rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install --list
rbenv install 2.2.3
import UIKit
struct Person { // Entity (usually more complex e.g. NSManagedObject)
let firstName: String
let lastName: String
}
struct GreetingData { // Transport data structure (not Entity)
let greeting: String
let subject: String