head/tail implementation using protocol
another implementation inspired from python
| 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) |
| <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> |
| 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) { |
| #!/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] |
| /** | |
| /// 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() -> ()->() { | |
| // http://nshipster.com/swift-comparison-protocols/ | |
| import Foundation | |
| struct CSSSelector { | |
| let selector: String | |
| struct Specificity { | |
| let id: Int | |
| let `class`: Int |
| { | |
| "installed_packages": | |
| [ | |
| "AutoFileName", // 열려있는 디렉토리 기준으로 리소스의 경로 자동 완성 | |
| "Better CoffeeScript", // CoffeeScript 추가 Snippet들 | |
| "DashDoc", // Dash의 Snippet 연동 | |
| "Diffy", // 2 Column으로 파일을 열면 비교 | |
| "DocBlockr", // Doxygen 스타일 등의 주석 포맷 자동생성 | |
| "Emmet", | |
| "FixMyJS", // 뭔가 구림. 잘 안씀. |
| // 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); | |
| }); |
| function code(name) { | |
| return "0x" + name.charCodeAt(0).toString(16); | |
| } | |
| window.open("http://unicode.org/cldr/utility/character.jsp?a=00" + code(prompt())); |