Skip to content

Instantly share code, notes, and snippets.

View elegantcoder's full-sized avatar

Constantine Kim 김현진 elegantcoder

View GitHub Profile
@elegantcoder
elegantcoder / iso-639-1.js
Last active December 25, 2015 14:49
ISO639; 2 Letter codes
module.exports = [
"ab",
"aa",
"af",
"ak",
"sq",
"am",
"ar",
"an",
"hy",
@elegantcoder
elegantcoder / gist:7095440
Last active December 26, 2015 04:39
Synap apply
log = (input) ->
Math.log(input) / Math.log(26)
getColName = (input) ->
temp = input
char = ''
result = ''
# temp -= temp / temp^power
# console.log power
// 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 = {
# case 1
module.exports = function (options) {
options.blah;
}
# case2
module.exports = function () {
var options = require('../config.js');
options.blah
}
{
"aar":
{
"int":["Afar"],
"native":["Afaraf"]
},
"aa":
{
"int":["Afar"],
"native":["Afaraf"]
@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;
}
});
# 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 / 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
/*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 / 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