Skip to content

Instantly share code, notes, and snippets.

View hongry18's full-sized avatar

hongry hongry18

View GitHub Profile
@hongry18
hongry18 / array.prototype.foreach.md
Created October 17, 2017 07:41
javascript array.prototype.foreach
if (!Array.prototype.forEach) {

  Array.prototype.forEach = function(callback, thisArg) {

    var T, k;

    if (this === null) {
      throw new TypeError(' this is null or not defined');
    }
@hongry18
hongry18 / javascriptAddEvent.md
Last active October 17, 2017 06:36
javascriptAddEvent
function addCustomEvent(el, e, c) {
    if (el.attachEvent) {
        return el.attachEvent('on'+e, c);
    } else {
        return el.addEventListener(e, c, false);
    }
}

addCustomEvent(element, 'eventName', callback);
@hongry18
hongry18 / javascript.pagination.md
Last active August 20, 2017 05:01
javascript pagination script

Javascript Pagination

The number of Block, list items is a limit variable

function _pagination(curPage, limit, founds) {
    if (curPage < 1) {
        curPage = 1;
    }
    if (limit < 1) {
        limit = 1;
    }
@hongry18
hongry18 / eclipse.ini.md
Created August 17, 2017 06:58
eclipse.ini.md
; workspace의 경로를 윈도우 타이틀바에 출력
-showlocation

; 클래스 유효성 검사 생략, 그러나 나중에 어딘서 오류나는지 확인하기 위해 사용 추천
;-Xverify:none

; jdk 버전으로 설정하면 속도 향상
-Dosgi.requiredJavaVersion=1.6
@hongry18
hongry18 / datetime.format.md
Created August 8, 2017 04:30
javascript datetime format
var dateFormat = function () {
    var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
        timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
        timezoneClip = /[^-+\dA-Z]/g,
        pad = function (val, len) {
            val = String(val);
            len = len || 2;
            while (val.length < len) val = "0" + val;
            return val;
@hongry18
hongry18 / string.format.md
Last active July 24, 2020 08:47
javascript String format
if (!String.prototype.format) {
    String.prototype.format = function() {
        var args = arguments;
        return this.replace(/{(\d+)}/g, function(match, number) {
            return typeof args[number] != 'undefined'
                ? args[number]
                : match
            ;
 });
@hongry18
hongry18 / CentOS.firewall.md
Created July 3, 2017 00:45
CentOS Firewall

Firewall Setting

CentOS 6.x

iptables

  • chain
    • input: 들어오는 모든 패킷
    • output: 나가는 모든 패킷
    • forward: 라우터로 사용되는 패킷
  • match
    • --source, -s: 출발지
@hongry18
hongry18 / replace.regex.str.md
Last active November 8, 2017 00:42
replace regular expression String

Replace Regular Expression

Linux Find exec

find ./ -name '*.ext' -exec sed -i '%s/old/new/g' {} ;

find & xargs

find ./ -name '*.ext' | xargs sed -i '%s/old/new/g'

sed include newline

sed ':a;N;$!ba;s/\n/ /g' file

@hongry18
hongry18 / java.jwt.md
Last active June 27, 2017 07:12
java jwt sample

JWT Sample

reference

https://jwt.io

nodeJS

dependency (npm)

npm install --save express body-parser jsonwebtoken