Skip to content

Instantly share code, notes, and snippets.

View iolo's full-sized avatar

Dongsu Jang iolo

View GitHub Profile
@iolo
iolo / NFC.py
Created June 20, 2024 05:56
맥에서 만들어져서 풀어쓰기(NFD) 파일 이름을 모아쓰기(NFC) 파일 이름으로 변경(python버전)
import os
import sys
import unicodedata
def scan_files(base_dir, recursive=True, dry_run=True):
for (root, dirs, files) in os.walk(base_dir):
for f in files:
new_name = unicodedata.normalize('NFC', f);
if new_name != f:
print(f'{root}/{f} -> {new_name}')
@iolo
iolo / NFC.java
Last active June 20, 2024 05:56
맥에서 만들어져서 풀어쓰기(NFD) 파일 이름을 모아쓰기(NFC) 파일 이름으로 변경(java버전)
import java.io.File;
import java.text.Normalizer;
import java.util.Set;
public class NFC {
public static void scanFiles(File dir, boolean recursive, boolean dryRun) {
for (File file: dir.listFiles()) {
var oldName = file.getName();
var newName = Normalizer.normalize(file.getName(), Normalizer.Form.NFC);
if (!oldName.equals(newName)) {
@iolo
iolo / binary-incr.mjs
Created April 21, 2023 15:54
proof-of-concept Turing Machine Emulator
import { TuringMachine } from './turing-machine.mjs';
const transitionFunction = {
q0: {
0: ['q0', '0', 'R'],
1: ['q0', '1', 'R'],
END: ['q1', 'END', 'L'],
},
q1: {
0: ['q2', '1', 'R'],
@iolo
iolo / to_camel_case.js
Created November 25, 2016 09:35
convert snake case(underscore or dash separated) string into camel case
var SNAKE_CASE_REGEXP = /[_-]([a-z])/g;
function toCamelCase(str) {
return String(str)
.replace(SNAKECASE_REGEXP, function (match, match1) {
return match1.toUpperCase();
});
}
@iolo
iolo / CryptoUtil.java
Created June 23, 2015 09:54
aes encrypt/descrypt both java and node.js
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
@iolo
iolo / parseQueryString.js
Created May 21, 2015 02:32
parse query string on browser
function parseQueryString() {
return location.search.substring(1).split('&')
.map(function(s){
return s.split('=');
})
.reduce(function (r, x) {
r[x[0]] = x[1];
return r;
}, {});
}
@iolo
iolo / parseCookies.js
Created May 21, 2015 02:23
parse cookies on browser
function parseCookies() {
return document.cookie.split(';')
.map(function(s){
return s.split('=');
})
.reduce(function (r,x) {
r[x[0]] = x[1];
return r;
}, {});
}
@iolo
iolo / SimpleLRUMap.java
Created March 8, 2015 07:02
초간단 LRU 맵 구현
package kr.iolo.common.collection;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* LRU 정책에 근거하여 맵의 항목을 유지하는 초간단 LRU 맵 구현.
*
* @author iolo
*/
@iolo
iolo / pom.xml
Created November 24, 2014 12:30
maven dependencies for phoenix-core
<project>
<dependencyManagement>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-core</artifactId>
<version>4.2.1</version>
<exclusions>
<exclusion>
<artifactId>hbase-testing-util</artifactId>
<groupId>org.apache.hbase</groupId>
@iolo
iolo / typeahead.js
Created October 14, 2014 14:02
simple angular directive to support twitter's typeahead.js
angular.module('io.utils', [])
module.directive('ioTypeahead', [
'$parse',
function ($parse) {
return {
restrict: "AE",
replace: true,
transclude: false,
compile: function (element, attrs) {
var modelAccessor = $parse(attrs.ioTypeahead);