Skip to content

Instantly share code, notes, and snippets.

@sooop
sooop / gist:8dc424e13c6fe2e2a663
Last active April 18, 2024 04:40
Steve Losh's VIMRC
" .vimrc
" Author: Steve Losh <steve@stevelosh.com>
" Source: http://bitbucket.org/sjl/dotfiles/src/tip/vim/
"
" This file changes a lot. I'll try to document pieces of it whenever I have
" a few minutes to kill.
" Preamble ---------------------------------------------------------------- {{{
" Dear /bin/bash: fuck you and your bullshit, arcane command-line behaviour.
@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 / StreamReader.swift
Last active May 28, 2023 13:00
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
function EditorInstance(key)
{
// class variables
var _self = this;
this.key = key || _newKey();
this.wrapper = null;
this.editor = null;
this.fileManager = null;
// internal property
@sooop
sooop / img2asc.py
Last active August 30, 2022 06:44
import argparse
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("-w", "--width", dest="width", type=int, default=80)
parser.add_argument("-l", "--level", dest="level", type=int, default=16)
@sooop
sooop / menu_popup2.vim
Last active August 25, 2022 14:28
vim8 popup menu with custom filter function
vim9script
var x = '[A]pple [B]anana [C]herry [O]range'->split()
def MyMenuHandler(winid: number, result: any)
popup_notification("you selected " .. x[result - 1] .. '.', { pos: 'center', time: 1000 })
enddef
def MyMenuFilter(winid: number, key: string): bool
var i = match('AaBbCcOo', key)
@sooop
sooop / vid2gif.bat
Last active August 18, 2022 15:05
convert video file to animated gif with ffmpeg
@echo off
@setlocal
set infile=%1
set outfile=%2
shift & shift
set fps=10
set w=320
:loop
IF NOT "%1"=="" (
IF "%1"=="-fps" (
@sooop
sooop / hangulSound.js
Created February 15, 2013 06:48
한글 초/중/종성을 구하는 자바스크립트 함수
/**
초성 중성 종성 분리 하기
유니코드 한글은 0xAC00 으로부터
초성 19개, 중상21개, 종성28개로 이루어지고
이들을 조합한 11,172개의 문자를 갖는다.
한글코드의 값 = ((초성 * 21) + 중성) * 28 + 종성 + 0xAC00
(0xAC00은 'ㄱ'의 코드값)
@sooop
sooop / arr_of_string.c
Created March 14, 2013 05:44
이중포인터를 사용하여 문자열의 배열을 동적으로 할당하고 해제하는 예제.
#include <stdio.h>
#include <stdlib.h> // for calloc()
#include <string.h> // for strcpy() . not necessary because compiler will automatically include string.h. (with warning)
#define MAXNUM 50
int main(void)
{
char **arrs; // declare arrs with pointer of char pointer.
arrs = (char**)calloc(MAXNUM, sizeof(char*)); // allocate 50*4bytes to arrs. it holds address of each string array.
@sooop
sooop / braille.py
Last active May 12, 2021 07:43
Convert Image to Braille Unicode text (using PIL)
'''Convert image to braille text'''
import argparse
from PIL import Image
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--th", default=127, type=int, dest="threadh")
parser.add_argument("-w", "--width", default=120, type=int, dest="width")