This file contains hidden or 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
//: Playground - noun: a place where people can play | |
import UIKit | |
// This is for dmoe, you can use a generice type to limit your observer to an UIViewController for common usage. | |
protocol Notifiable { | |
var name: Notification.Name { get } | |
func observe(by observer: Any, withSelector selector: Selector, object: Any?) | |
func post(object: Any? ,userInfo: [AnyHashable: Any]?) | |
static func remove(observer: Any) |
This file contains hidden or 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
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
server_name <YOUR_PUBLIC_IP>; | |
root "/var/www/${PROJECT_ROOT}"; | |
index index.html index.htm index.php; | |
charset utf-8; |
This file contains hidden or 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
###################### | |
# Create log file | |
###################### | |
exec > ~/Desktop/tmp/UniversalBuild_Log_$(date +"%Y%m%d%H%M%S").log 2>&1 | |
###################### |
This file contains hidden or 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
// Using UInt8 as Byte | |
typealias Byte = UInt8 | |
enum Bit: Int { | |
case zero, one | |
} | |
extension Data { | |
var bytes: [Byte] { | |
var byteArray = [UInt8](repeating: 0, count: self.count) | |
self.copyBytes(to: &byteArray, count: self.count) |
This file contains hidden or 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
// Get array address | |
func getBufferAddress<T>(of array: [T]) -> String { | |
return array.withUnsafeBufferPointer { buffer in | |
return String(describing: buffer.baseAddress) | |
} | |
} | |
// Realize copy-on-write | |
var fiverInts = [1,2,3,4,5] | |
let copyFive = fiverInts |
This file contains hidden or 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
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'VundleVim/Vundle.vim' | |
" All of your Plugins must be added before the following line | |
Plugin 'tpope/vim-vinegar' |
This file contains hidden or 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
"-------------- Color config -------------- | |
colorscheme atom-dark " My Vim GUI color scheme | |
"--------------------UI tweaks-------------------- | |
set vb t_vb= " Disable bell after GUI startemd | |
" Some tweaks of the atom-dark theme | |
" Normal fg and bg color | |
hi Normal guifg=#eeeeee guibg=#252b3a | |
" fg and bg color of visual mode |
This file contains hidden or 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
set nocompatible " Make vim behave more usefule way | |
so ~/.vim/plugins.vim " Manage plugins by vundle | |
"-------------- Indentation ------------ | |
set tabstop=4 " Number of space per tab | |
set shiftwidth=4 " Indent 4 columns for << and >> operations | |
set expandtab " Replace tab with space | |
set autoindent " Indent at the same level of the previous line | |
"-------------- Searching -------------- |
This file contains hidden or 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
typealias Distance = Double | |
/// A struct to represent real position of the ship | |
struct Position { | |
var x: Double | |
var y: Double | |
} | |
extension Position { | |
/// Calculate if this position lies in the given range |
This file contains hidden or 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
MyUITextField: UITextField { | |
// Whatever you like | |
let padding = UIEdgeInsets(top: 5, left: 5, bottom: 6, right: 6); | |
// Paddging for place holder | |
override func placeholderRectForBounds(bounds: CGRect) -> CGRect { | |
return UIEdgeInsetsInsetRect(bounds, padding) | |
} | |
// Padding for text | |
override func textRectForBounds(bounds: CGRect) -> CGRect { | |
return UIEdgeInsetsInsetRect(bounds, padding) |