Instantly share code, notes, and snippets.

View git-tag-semver.sh
#!/bin/bash
# Replace git tags to semantic version
# e.g. v1.0.0 -> 1.0.0
for vtag in $(git tag -l | awk '$0 ~ /^v/')
do
tag=$(echo $vtag | sed -e 's/^v//')
git tag $tag $vtag
git tag -d $vtag
git push origin :refs/tags/v$tag
View xcode-version-and-build-number-auto-increment-runscript.sh
#!/bin/bash
# Auto increment Version number when Archive
if [ $CONFIGURATION == Release ]; then
VERSIONNUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
NEWSUBVERSION=`echo $VERSIONNUM | awk -F "." '{print $3}'`
NEWSUBVERSION=$(($NEWSUBVERSION + 1))
NEWVERSIONSTRING=`echo $VERSIONNUM | awk -F "." '{print $1 "." $2 ".'$NEWSUBVERSION'" }'`
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $NEWVERSIONSTRING" "${PROJECT_DIR}/${INFOPLIST_FILE}"
View .zshrc
# https://gist.github.com/devxoul/541252cef3207088fd5e
# Path to your oh-my-zsh installation.
export ZSH=/Users/xoul/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
View design.swift
////////////////////////////////////////////////////////////////////////////////
// Usage //
////////////////////////////////////////////////////////////////////////////////
struct JoinForm {
var emailField: FormField
var usernameField: FormField
init(email: String?) {
self.emailField = FormField(value: email)
View wtf_required_if.py
class RequiredIf(object):
"""Validates field conditionally.
Usage::
login_method = StringField('', [AnyOf(['email', 'facebook'])])
email = StringField('', [RequiredIf(login_method='email')])
password = StringField('', [RequiredIf(login_method='email')])
facebook_token = StringField('', [RequiredIf(login_method='facebook')])
"""
View GitHub3.css
/*
* GitHub CSS for MacDown
* https://gist.github.com/devxoul/8df5792ce330985a633b
* http://sindresorhus.com/github-markdown-css/
*/
@font-face {
font-family: octicons-link;
src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYF
View UIWebViewBackground.swift
self.webView.rx.didFinishLoad
.subscribe(onNext: { [weak self] in
guard let `self` = self else { return }
let script = "window.getComputedStyle(document.body).backgroundColor;"
guard let result = self.webView.stringByEvaluatingJavaScript(from: script) else { return }
let optionalComponents = result
.components(separatedBy: "(").safe[1]?
.components(separatedBy: ")").safe[0]?
.components(separatedBy: ",")
.map { $0.trimmingCharacters(in: .whitespaces) }
View building-funnels-with-google-bigquery.sql
#standardSQL
WITH events AS (
SELECT "A" AS user, 100 AS time, "view" AS event
UNION ALL SELECT "B", 200, "click"
UNION ALL SELECT "B", 300, "view"
UNION ALL SELECT "A", 400, "click"
UNION ALL SELECT "A", 500, "click"
UNION ALL SELECT "A", 600, "buy"
),
View kb_balance.py
# -*- coding: utf-8 -*-
from datetime import datetime
import urllib2
def kb_balance(account, password, resident, username):
"""
국민은행 계좌 잔액 빠른조회. 빠른조회 서비스에 등록이 되어있어야 사용 가능.
빠른조회 서비스: https://obank.kbstar.com/quics?page=C018920
View swift4.1-openurl-workaround.diff
- func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
+ func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any?) -> Bool