Skip to content

Instantly share code, notes, and snippets.

@seoh
seoh / TreeUtil.scala
Created October 12, 2012 12:25
print CodeTree of Assignment4 (FPPiS)
def mkString(tree: CodeTree): String = {
def __mkString(tree: CodeTree, depth: Int): String =
List.fill(depth)('\t').mkString + "(" + chars(tree).mkString + ") " + weight(tree) + "\n" +
(tree match {
case Fork(left, right, chars, weight) =>
__mkString(left, depth + 1) + __mkString(right, depth + 1)
case Leaf(chars, weight) =>
""
})
__mkString(tree, 0)
@seoh
seoh / evernote.html
Created November 28, 2012 07:27
Evernote clipper
<script type="text/javascript" src="http://static.evernote.com/noteit.js"></script>
<div class="evernote">
<a href="#" onclick="Evernote.doClip({providerName:'Dev the wild',contentId:'Evernote Clip'}); return false;"><img src="http://static.evernote.com/article-clipper.png" alt="Clip to Evernote" width="51" height="17" /></a>
</div>
@seoh
seoh / gist:7239983
Last active December 27, 2015 00:49
Synapsoft the second-half 2013 recruitment
function synap(number) {
var buff = [];
while( number >= 0 ) {
buff.push( String.fromCharCode(number%26 + 65) );
number = Math.floor(number/26)-1;
}
return buff.reverse().join('');
}
function fillZero(number, digit) {
@seoh
seoh / http.swift
Created July 6, 2014 10:16
SwimpleServer
#!/usr/bin/env xcrun --sdk macosx10.10 swift -i
import Foundation
println("Usage: \n\t\t\(NSURL(string:__FILE__).lastPathComponent) -- [options]")
// #TODO options
var opt = Dictionary<String, String>()
for arg in Process.arguments {
let array = arg.componentsSeparatedByString("=")
let key: String? = array[0]
@seoh
seoh / README.md
Last active August 29, 2015 14:03
Butcher protocol for head/tail of Array

butcher.swift

head/tail implementation using protocol

butcher.python.swift

another implementation inspired from python

@seoh
seoh / withExtendedLifetime.swift
Created August 5, 2014 11:59
withExtendedLifetime
/**
/// f가 리턴하기 전에 `x`가 사라지지 않았을 때만 `f(x)`를 평가하고 결과를 반환한다.
func withExtendedLifetime<T, Result>(x: T, f: (T) -> Result) -> Result
func withExtendedLifetime<T, Result>(x: T, f: () -> Result) -> Result
**/
func getClosure() -> ()->() {
@seoh
seoh / CSSSelector.swift
Created September 23, 2014 17:20
Swift Comparison and String Literal
// http://nshipster.com/swift-comparison-protocols/
import Foundation
struct CSSSelector {
let selector: String
struct Specificity {
let id: Int
let `class`: Int
@seoh
seoh / Package Control.sublime-settings
Last active August 29, 2015 14:11
Sublime Text Preferences
{
"installed_packages":
[
"AutoFileName", // 열려있는 디렉토리 기준으로 리소스의 경로 자동 완성
"Better CoffeeScript", // CoffeeScript 추가 Snippet들
"DashDoc", // Dash의 Snippet 연동
"Diffy", // 2 Column으로 파일을 열면 비교
"DocBlockr", // Doxygen 스타일 등의 주석 포맷 자동생성
"Emmet",
"FixMyJS", // 뭔가 구림. 잘 안씀.
@seoh
seoh / beholders.js
Created January 6, 2015 11:19
Find Beholders in Twitter
// Expand all of followers and execute in console.
// [followers](https://twitter.com/followers)
var users = [].slice.call(document.querySelectorAll("div[data-test-selector=ProfileTimelineUser]"));
users.filter(function(user){
return !user.querySelector("span.Icon--protected");
}).map(function(user){
user.parentNode.removeChild(user);
});
@seoh
seoh / unicode_name.js
Created June 23, 2015 12:35
get name of unicode symbol
function code(name) {
return "0x" + name.charCodeAt(0).toString(16);
}
window.open("http://unicode.org/cldr/utility/character.jsp?a=00" + code(prompt()));