Skip to content

Instantly share code, notes, and snippets.

@imazine
imazine / get-npm-package-version
Created October 26, 2021 20:11 — forked from DarrenN/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@imazine
imazine / fix_github_https_repo.sh
Created June 28, 2021 02:11 — forked from m14t/fix_github_https_repo.sh
Convert HTTPS github clones to use SSH
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
exit
fi
const half = n => n >>> 1;
const odd = n => !!(n & 0x1);
const even = n => !!!(odd(n));
const multify1 = (a, b, doubled) => {
doubled = doubled + 1;
if (a === 1) return b;
res = multify1(half(a), b + b, doubled);
if (odd(a)) res = res + b;
console.info('[multiFy1]Interim result', a, b, 'doubled', doubled, 'times returns', res);
@imazine
imazine / uri_parser.js
Last active November 16, 2017 01:55 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"

Docker 치트 시트

한국어 번역(초벌) : nacyot

왜 Docker를 사용해야하는가?

Why Should I Care (For Developers)

"나에게 Docker의 매력은 간단히 격리된 환경을 만들 수 있다는 것과, 그러한 환경을 재사용할 수 있다는 점이다."런타임 환경을 한 번 만들어 패키지로 만들면, 이 패키지를 다른 어떤 머신에서도 다시 사용할 수 있다. 또한 여기서 실행되는 모든 것은 마치 가상머신과 같이 호스트로부터 격리되어있다. 무엇보다도 이런 모든 일들이 빠르고 간단히 가능하다.

@imazine
imazine / zenDecoder.js
Created October 12, 2014 09:30
JavaScript Simple Zen Decoder
function zenDecode (str) {
var
tokenStr = str.replace(/\s/g, ''),
fragment = document.createDocumentFragment(),
zenStack = tokenStr.split('>').reverse();
console.log(tokenStr);
return (zenTokenize(zenStack, fragment));
}
@imazine
imazine / jsfp.js
Last active August 29, 2015 14:07
JavaScript Floating point issue.
function actualNumber(num) { return ((num * 10000) >> 0 ) * 0.0001; }
function actualNatural(num) { return parseInt(num * 10000) * 0.0001; }
function actualCasting(num) { return parseFloat(num.toFixed(4)); }
function test(number, iterator){
console.log('----------------------------------------------');
console.log('Test method : ', iterator);
var start = performance.now();
@imazine
imazine / gist:9804988
Created March 27, 2014 10:58
git watch shell script
#!/bin/bash
if [ "$#" -ne 1 ]; then
n=24
else
n=$1
fi
watch -i 5 "clear && git --no-pager lol -n $n"
@imazine
imazine / gist:7443611
Created November 13, 2013 04:16
Insert BASE64 encoded image at CSS.
background: url(data:image/jpg;base64,) repeat;