Skip to content

Instantly share code, notes, and snippets.

View Elevista's full-sized avatar

Elevista

  • Yanolja
  • Seoul
View GitHub Profile
const htmlparser2 = require('htmlparser2')
const define = (src, ...args) => {
if (!args.length) args.push(src)
const [configurable, enumerable] = [true, false]
args.forEach(obj => {
const keys = Object.entries(obj)
.map(([key, value]) => ({ [key]: { value, configurable, enumerable } }))
Object.defineProperties(src, Object.assign(...keys))
})
return src
function dfsXyConv (code, v1, v2) {
const { PI, tan, log, cos, pow, floor, sin, sqrt, atan, abs, atan2 } = Math
//
// LCC DFS 좌표변환을 위한 기초 자료
//
const RE = 6371.00877 // 지구 반경(km)
const GRID = 5.0 // 격자 간격(km)
const SLAT1 = 30.0 // 투영 위도1(degree)
const SLAT2 = 60.0 // 투영 위도2(degree)
const OLON = 126.0 // 기준점 경도(degree)
@Elevista
Elevista / decodeEntities.js
Created April 21, 2020 04:41
Decode HTML entities
const entities = {
lt: '<',
gt: '>',
amp: '&',
quot: '"',
apos: `'`,
cent: '¢',
pound: '£',
yen: '¥',
euro: '€',
@Elevista
Elevista / seq.js
Last active January 9, 2018 04:09
seq(1)(fn1)(fn2)(fn3).value
const _ = require('lodash')
function isPromise(result) {
return result && (typeof result.then === 'function')
}
function seq(init) {
let result = typeof init === 'function' ? init() : init
let properties = {value: {get() { return result }}}
_.forEach(['then', 'catch', 'finally'], x => { properties[x] = {get() { return (...args) => result[x](...args) }} })
@Elevista
Elevista / vueLodashArray.js
Last active December 19, 2017 16:36
lodash로 vue 모델의 배열을 다룰때 뮤테이션 감지를 시키기 위해 기본 함수를 래핑합니다.
let lodash = _.runInContext()
export let wrapLodashArrForVue = _(['pull', 'pullAll', 'pullAllBy', 'pullAllWith', 'pullAt', 'remove'])
.map(fnName => {
let fn = lodash[fnName]
return [
fnName,
function (v, …args) {
let ret = fn(v, …args)
if (v instanceof Array) v.push()
return ret
@Elevista
Elevista / Deferred.js
Last active November 7, 2017 02:14
ES6-Defer
export function Deferred () {
this.promise = new Promise((resolve, reject) => Object.assign(this, {resolve, reject}))
}
@Elevista
Elevista / REDAMD.md
Created June 4, 2016 14:04
AngularJS onScroll directive

About Directive

Bind on scroll event angular way.

Usage

<div on-scroll="scrollHdlr($direct,$event)">
angular.module("app").controller('ctrl', function ($scope) {
@Elevista
Elevista / README.md
Last active December 17, 2018 18:22
Angular Material SVG icon set

Example

Javascript

angular.module('example', ['ngMaterial'])
  .controller('DemoCtrl', function($scope) {})
  .config(function($mdIconProvider) {
    $mdIconProvider
       .defaultIconSet('material-design-icons-2.2.0.svg', 24);
   });
@Elevista
Elevista / AES256.js
Created March 14, 2016 06:11
Node crypto proxy
var crypto = require('crypto');
var SHA256 = require('./SHA256.js');
var Base64 = require('./Base64.js');
var _key = SHA256.encode('default key');
module.exports = {
encode: function (data, key) {
if (arguments.length < 2) key = _key;
var cipher = crypto.createCipher('aes-256-ctr', key); // Cipher 객체 생성
var crypted = Buffer.concat([cipher.update(new Buffer(data)), cipher.final()]);
return Base64.encode(crypted);

##Example

var p = new path('http://abc.com/aa/bb/cc');
p.cd('../../ww');
p.toString();
//returns "http://abc.com/aa/ww"
p.cd('/').toString();
//returns "http://abc.com"