Skip to content

Instantly share code, notes, and snippets.

View elegantcoder's full-sized avatar

Constantine Kim 김현진 elegantcoder

View GitHub Profile
@elegantcoder
elegantcoder / extract_korean_initials.rb
Last active July 22, 2018 14:44
한글 초성 분리기
# 삼성전자 => ㅅㅅㅈㅈ, 유안타제3호스팩 => ㅇㅇㅌㅈ3ㅎㅅㅍ
def extract_korean_initials(keyword)
initials = ['ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ']
# hangul_range = '가'..'힣'
hangul_first = 44032 # '가'.ord
size = 588 # '까'.ord - '가'.ord
keyword.split('').collect do |k|
#!/bin/sh
mkdir -p ~/Library/KeyBindings
echo '{
"₩" = ("insertText:", "`");
}' > ~/Library/KeyBindings/DefaultkeyBinding.dict
@elegantcoder
elegantcoder / active_record_2_yaml.rb
Created September 16, 2016 16:59
for generating Rails test fixture
require 'yaml'
def active_record_2_yaml(active_record)
hash = Array.wrap(active_record).as_json.reduce({}) {|memo, item|
memo["id_#{item['id']}"] = item
memo
}
hash.to_yaml
end
/*cordova-deviceready-$q*/
'use strict';
angular.module('elcoCordova', [])
.factory('elcoCordova.onDeviceReady', [
'$q',
'$log',
function ($q, console) {
console.log('elcoCordova.onDeviceReady');
var deferred = $q.defer();
@elegantcoder
elegantcoder / gist:54ba041b31d9536a8364
Created June 19, 2015 17:44
GA Spam Hosts Pattern
event-tracking.com|4webmasters.org|trafficmonetize.org|semalt.semalt.com|social-buttons.com|best-seo-offer.com|buttons-for-website.com|free-share-buttons.com|buttons-for-your-website.com
# hashids (https://www.npmjs.org/package/hashids) make to support encrypt/decrypt string, json.
hashIds = new Hashids(secret);
hashIds.encryptString = (str) ->
hashIds.encrypt([].slice.call(new Buffer(str)));
hashIds.decryptString = (encrypted) ->
new Buffer(hashIds.decrypt(encrypted)).toString()
hashIds.encryptJSON = (obj) ->
hashIds.encrypt([].slice.call(new Buffer(JSON.stringify(obj))));
@elegantcoder
elegantcoder / sidebar-isActive.js
Created July 30, 2014 05:02
sidebar-isActive.js
angular.module('sidebar', [])
.controller('SidebarCtrl', function ($scope, $route) {
$scope.isActive = function (url) {
return $route.current.$$route.controller === $route.routes[url].controller;
}
});
{
"aar":
{
"int":["Afar"],
"native":["Afaraf"]
},
"aa":
{
"int":["Afar"],
"native":["Afaraf"]
# case 1
module.exports = function (options) {
options.blah;
}
# case2
module.exports = function () {
var options = require('../config.js');
options.blah
}
// watch - translate - assign other member of scope
// check out how it works at http://jsfiddle.net/SWe4r/1/
var app = angular.module('watcherApp', []);
app.controller('watcherController', function ($scope) {
$scope.source = 'aaaaaa';
$scope.foo = {
bar: 'aaa'
};
$scope.bar = {