Skip to content

Instantly share code, notes, and snippets.

๐Ÿ 
Busy
Working from home

Redgoose redgoose-dev

View GitHub Profile
View printf.js
/**
* printf
*
* @param {String} str
* @param {String} values
* @return {String}
*/
export function printf(str, ...values)
{
for (let i = 0; i < values.length; i++)
@redgoose-dev
redgoose-dev / findIndexWithKey.js
Last active Oct 17, 2017
Object, Array utils
View findIndexWithKey.js
/**
* find index with key in array
* ๋ฐฐ์—ด์†์— ๋“ค์–ด์žˆ๋Š” ๊ฐ์ฒด์˜ ๊ฐ’์„์ฐพ๋Š” ํ•จ์ˆ˜
*
* @param {Array} array
* @param {String} key key name
* @param {String} search search value
* @return {Number}
*/
function findIndexWithKey(array=[], key='', search='')
@redgoose-dev
redgoose-dev / index.html
Created Dec 27, 2016
printf function with javascript
View index.html
<section>
<h1>Command</h1>
<pre class="source">printf('apple:{0}, banana:{1}, mango:{2}', 'red', 'yellow', 'green');</pre>
</section>
<section>
<h1>Result</h1>
<pre class="result"></pre>
</section>
@redgoose-dev
redgoose-dev / resizeImageInCanvas.js
Last active Nov 10, 2016
Resize image in canvas
View resizeImageInCanvas.js
function log(o) {console.log(o);}
function Canvas(width, height, bgColor)
{
this.el = document.createElement('canvas');
this.ctx = this.el.getContext('2d');
var size = {
width : (width) ? width : 150,
height : (height) ? height : 100
View DisabledTouchscroll.js
/**
* Disabled touch scroll for ios
* ios ๋””๋ฐ”์ด์Šค์—์„œ์˜ ์Šคํฌ๋กค์€ ํŠ•๊ธฐ๋Š” ๋ฐฉ์‹ ๋•Œ๋ฌธ์— html,body์—˜๋ฆฌ๋จผํŠธ์—์„œ overflow:hidden์„ ์ ์šฉํ•ด๋ดค์ž ํŠ•๊ธฐ๋Š” ์Šคํฌ๋กค์„ ๋ง‰์„ ํ•„์š”๊ฐ€ ์žˆ์—ˆ๋Š”๋ฐ ์Šคํฌ๋ฆฝํŠธ๋กœ ํ„ฐ์น˜๋ฅผ ๋ง‰์•„๋ฒ„๋ฆฌ๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค๊ฒŒ ๋˜์—ˆ๋‹ค.
* ํŠนํžˆ ์‚ฌ์ด๋“œ๋ฐ” ๋„ค๋น„๊ฒŒ์ด์…˜์„ ์‚ฌ์šฉํ• ๋•Œ ์‚ฌ์šฉํ•˜๋ฉด ๋„์›€์ด ๋ ๊ฒƒ์ด๋‹ค.
* body ์—˜๋ฆฌ๋จผํŠธ ์Šคํฌ๋กค์„ ๋ง‰๋Š” ์—ญํ• ์„ ํ•œ๋‹ค. ๋‹ค๋ฅธ ํŠน์ • ์—˜๋ฆฌ๋จผํŠธ๋Š” -webkit-overflow-scrolling: auto;๋กœ ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค๊ณ  ๋ด„
*/
function DisabledTouchscroll()
{
var self = this;
var $body = $(document.body);
@redgoose-dev
redgoose-dev / CSS3.js
Last active Jan 18, 2016
CSS3 Util class
View CSS3.js
/**
* CSS3 class
*/
var CSS3 = {
eventNames : {
WebkitTransition : 'webkitTransitionEnd',
MozTransition : 'transitionend',
OTransition : 'oTransitionEnd otransitionend',
transition : 'transitionend'
@redgoose-dev
redgoose-dev / hairline.html
Created Jul 23, 2015
border hair line. border-width: 0.5px
View hairline.html
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>hair line demo</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="./style.css"/>
</head>
<body>
View rg-icon.html
<section>
<h1>Icons</h1>
<ul class="items">
<li>
<div>
<span class="rg-icon hamburger"><i>list</i></span>
</div>
</li>
<li>
<div><span class="rg-icon cross"><i>add/close</i></span></div>
@redgoose-dev
redgoose-dev / copyClipboard.js
Last active Aug 29, 2015
Copy the text to the clipboard
View copyClipboard.js
/**
* Copy the text to the clipboard
*
* @Param {String} : copy text
* @Param {String} : prompt message
* @Return void
*/
var copyClipboard = function(str, msg)
{
if (window.clipboardData)
You canโ€™t perform that action at this time.