Skip to content

Instantly share code, notes, and snippets.

View pofat's full-sized avatar

Pofat pofat

View GitHub Profile
@pofat
pofat / archive_framework.sh
Last active June 19, 2019 07:42
A post-action to Xcode Archive to generate final universal framework
######################
# Create log file
######################
exec > ~/Desktop/tmp/UniversalBuild_Log_$(date +"%Y%m%d%H%M%S").log 2>&1
######################
@pofat
pofat / nginx_site
Created November 6, 2016 13:40
Nginx virtual host configuration on EC2
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;
@pofat
pofat / ProtocolNotofication.swift
Last active December 15, 2021 10:50
Deal with notification with protocol-oriented programing in Swift
//: 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)
@pofat
pofat / CustomUnwrapper.swift
Last active December 1, 2016 13:10
A force unwrapper for Optional type with error hint, suitable for development
// This trick is orininally from 'https://boxueio.com/'
infix operator !!
func !!<T>(optional: T?, errorMessage: @autoclosure () -> String) -> T {
if let value = optional { return value }
fatalError(errorMessage)
}
@pofat
pofat / InsertionSort.swift
Last active December 3, 2016 15:22
Implement algorithms with Swift 3
// This implementation is originally from `https://boxueio.com`
typealias Criterial<T> = (T, T) -> Bool
func insertionSortOf<T: Comparable>(_ coll: [T], byCriteria: Criterial<T> = { $0 < $1 }) -> [T] {
guard coll.count > 1 else {
return coll
}
@pofat
pofat / Get_IP_Ethernet.ino
Last active January 5, 2017 21:20
MQTT related example code of Arduino
#include <SPI.h>
#include <Ethernet.h>
// Any MAC that won't conflice with any device in your network will do
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDe, 0x02 };
EthernetClient client;
void setup() {
@pofat
pofat / .vimrc
Last active August 19, 2018 18:54
vimrc for Raspberry Pi 3
set nocompatible
set tabstop=4
set shiftwidth=4
set expandtab
set hlsearch
set incsearch
set guioptions-=e
@pofat
pofat / html5_template.html
Created February 11, 2017 03:13
HTML5 basic template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
@pofat
pofat / wordLadder.swift
Last active April 27, 2017 12:30
LeetCode: 127. Word Ladder
class Solution {
func ladderLength(_ beginWord: String, _ endWord: String, _ wordList: [String]) -> Int {
var wordSet: Set<String> = Set(wordList)
guard wordSet.contains(endWord) else {
return 0
}
// Lookup table for neighbors
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation