Skip to content

Instantly share code, notes, and snippets.

View thirdj's full-sized avatar

Choi, Jaehee thirdj

View GitHub Profile
@thirdj
thirdj / git-init.sh
Created March 21, 2017 08:47 — forked from cyberswat/git-init.sh
Initialize git repo and make first commit
# switch to the jenkins user
[root@li220-252:~] su jenkins
jenkins@li220-252:/root$
# Move into the jenkins directory
jenkins@li220-252:~$ cd /var/lib/jenkins/
# Intialize a git repository
jenkins@li220-252:~$ git init
Initialized empty Git repository in /var/lib/jenkins/.git/
@thirdj
thirdj / css_colors.js
Created October 17, 2016 08:43 — forked from bobspace/css_colors.js
All of the CSS Color names as an array in javascript.
// CSS Color Names
// Compiled by @bobspace.
//
// A javascript array containing all of the color names listed in the CSS Spec.
// The full list can be found here: http://www.w3schools.com/cssref/css_colornames.asp
// Use it as you please, 'cuz you can't, like, own a color, man.
var CSS_COLOR_NAMES = ["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","Darkorange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory"
@thirdj
thirdj / nodejs-tcp-example.js
Created October 12, 2016 06:40 — forked from tedmiston/nodejs-tcp-example.js
Node.js tcp client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
var employees=[];
employees[0]={name:"George", age:32, retiredate:"March 12, 2014"};
employees[1]={name:"Edward", age:17, retiredate:"June 2, 2023"};
employees[2]={name:"Christine", age:58, retiredate:"December 20, 2036"};
employees[3]={name:"Sarah", age:62, retiredate:"April 30, 2020"};
// sort by employee age
employees.sort(function(a, b){
return a.age-b.age
});
@thirdj
thirdj / templating.js
Created December 9, 2013 08:56
// Simple JavaScript Templating // John Resig - http://ejohn.org/ - MIT Licensed
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
tmpl(document.getElementById(str).innerHTML) :
@thirdj
thirdj / firstClassName.js
Created December 9, 2013 07:09
how to get jquery first class http://jsbin.com/aLERidIF/1/edit
$(function(){
var first = $('div').attr('class').replace(/^(\S*).*/, '$1');
var second = $('div').attr('class').split(' ')[0];
var third = $('div').attr('class').split(' ').shift();
var ArrayData = $.map($('div').attr('class').split(' '), function(value){
return value;
});
var thirdFirst = $('div').attr('class').split(' ').pop();
/**
* Protect window.console method calls, e.g. console is not defined on IE
* unless dev tools are open, and IE doesn't define console.debug
*/
(function(exports) {
if (!exports.console) exports.console = {};
// union of Chrome, FF, IE, and Safari console methods
var m = [
"log", "info", "warn", "error", "debug", "trace", "dir", "group",
@thirdj
thirdj / textareaReplace.js
Created December 9, 2013 05:22
How to replace \n with <br /> in JavaScript? http://jsfiddle.net/ZmW45/
$('textarea').val().replace(/\n/g, '<br />');
@thirdj
thirdj / getTextLength.js
Created December 9, 2013 00:14
검색해보니 한글 포함 문자열의 길이를 구하는 로직에 대해 정리해둔 블로그가 있다. 텍스트 내 캐릭터를 escape() 함수를 이용해 인코딩하여 그 값의 길이가 6일 경우 한글로 판단하여 2byte로 계산해주는 로직이다. (예: escape('가') --> %uAC00) http://programmingsummaries.tistory.com/239 좋은 자료
/**
* 한글포함 문자열 길이를 구한다
*/
function getTextLength(str) {
var len = 0;
for (var i = 0; i < str.length; i++) {
if (escape(str.charAt(i)).length == 6) {
len++;
}
len++;
$.ajaxSetup({
error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');