Skip to content

Instantly share code, notes, and snippets.

View ohgyun's full-sized avatar

Ohgyun Ahn ohgyun

View GitHub Profile
@ohgyun
ohgyun / Gruntfile-livereload.js
Last active December 15, 2015 23:39
Gruntfile for livereload.
module.exports = function (grunt) {
// 라이브리로드를 위한 코드 파일
// https://github.com/gruntjs/grunt-contrib-livereload
var path = require('path');
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var folderMount = function folderMount(connect, point) {
return connect.static(path.resolve(point));
};
@ohgyun
ohgyun / makeeventable.js
Last active December 15, 2015 20:09
Make an object eventable.
function makeEventable(obj) {
var getEventMap = function () {
this.__eventMap = this.__eventMap || {};
return this.__eventMap;
},
validateEventExistence = function (name) {
var eventMap = getEventMap.call(this);
if (typeof eventMap[name] === 'undefined') {
@ohgyun
ohgyun / makepropertiable.js
Last active December 15, 2015 20:09
Make an object propertiable.
function makePropertiable(obj) {
var getProps = function () {
this.__props = this.__props || {};
return this.__props;
},
emptyGet = function (currentValue) {
return currentValue;
},
emptySet = function (newValue) {
@ohgyun
ohgyun / bash_monitor.bash
Last active December 11, 2015 04:19
A bash file monitor. Watch a bashfile and run if it changed.
#!/bin/bash
# Watch a bashfile and run it if changed
function bash_monitor () {
if [[ -z "$1" ]]; then
echo "usage: bash_monitor <bashfilename>"
exit 1
fi
@ohgyun
ohgyun / what-forces-layout.md
Created October 8, 2015 06:30 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@ohgyun
ohgyun / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ohgyun
ohgyun / README.md
Last active August 29, 2015 14:10 — forked from evandrix/README.md

Here are a list of headless browsers that I know about:

  • [HtmlUnit][1] - Java. Custom browser engine. JavaScript support/DOM emulated. Open source.
  • [Ghost][2] - Python only. WebKit-based. Full JavaScript support. Open source.
  • [Twill][3] - Python/command line. Custom browser engine. No JavaScript. Open source.
  • [PhantomJS][4] - Command line/all platforms. WebKit-based. Full JavaScript support. Open source.
  • [Awesomium][5] - C++/.Net/all platforms. Chromium-based. Full JavaScript support. Commercial/free.
  • [SimpleBrowser][6] - .Net 4/C#. Custom browser engine. No JavaScript support. Open source.
  • [ZombieJS][7] - Node.js. Custom browser engine. JavaScript support/emulated DOM. Open source.
  • [EnvJS][8] - JavaScript via Java/Rhino. Custom browser engine. JavaScript support/emulated DOM. Open source.
@ohgyun
ohgyun / trello.point.js
Created April 23, 2014 07:57
트렐로 추정 시간 표시
(function () {
var rPoint = /\[([0-9.]+)\]/g;
$('.list').each(function (i, list) {
var $title = $(list).find('.list-card-title:visible');
var total = 0;
$title.each(function (j, title) {
var str = $(title).text();
while (rPoint.test(str)) {
@ohgyun
ohgyun / isChosungMatch.js
Created April 3, 2014 06:54
초성 비교 (초성과 완성된 문자열을 비교한다)
function isChosungMatch(query, target) {
var lq = query.length; // length of query
var lt = target.length; // length of target
var ldiff = lt - lq; // length diff
var it = 0; // index of target
var iq = 0; // index of query
var cq; // character of query
var ct; // character of target
// 쿼리가 없으면 모두 매칭했다고 본다