Skip to content

Instantly share code, notes, and snippets.

@sooop
sooop / DragTableController.swift
Created February 9, 2017 06:07
NSTableView reordering row with drag and drop
//
// ViewController.swift
// DragTable
//
// Created by Anna Kim on 2017. 2. 9..
// Copyright © 2017년 Anna Kim. All rights reserved.
//
import Cocoa
@sooop
sooop / StreamReader.swift
Last active June 23, 2024 22:49
Read a large text file line by line - Swift 3
import Foundation
class StreamReader {
let encoding: String.Encoding
let chunkSize: Int
let fileHandle: FileHandle
var buffer: Data
let delimPattern : Data
var isAtEOF: Bool = false
@sooop
sooop / Monads.swift
Last active February 3, 2020 16:20
Monad in Swift : 모나드 개념을 Swift로 구현해본다.
/*
모나드는 특정한 타입을 감싸는 타입이며,
raw한 값을 감싸는 함수와
raw한 값을 모나드 값으로 바꾸는 어떤 함수에 바인딩된다.
이를 바탕으로 모나드 프로토콜을 정의하면 다음과 같다.
*/
protocol Monad {
@sooop
sooop / ai2jpg.js
Created July 23, 2013 15:46
convert all .ai files in a folder into jpg files
// Adobe Illustrator Javascript to save multiple ai files into JPEG file.
// code by sooop
var defaultFolder = new Folder('C:/'); // 폴더 선택창에서 디폴트 폴더
var targetFolder = new Folder();
var sourceFiles;
@sooop
sooop / ANSI-C.sublime-build.json
Last active December 14, 2015 20:19
ANSI-C Build System for win32
{
"cmd": ["gcc", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c",
"variants":
[
{
"name": "Run",
@christian-oudard
christian-oudard / gfm.py
Created June 29, 2010 18:51
Github Flavored Markdown in Python
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5(matchobj.group(0)).hexdigest()
extractions[digest] = matchobj.group(0)
return "{gfm-extraction-%s}" % digest