Skip to content

Instantly share code, notes, and snippets.

Hyeonseok Shin hyeonseok

Block or report user

Report or block hyeonseok

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hyeonseok
hyeonseok / Scene.js
Last active Feb 15, 2017
Scene slide
View Scene.js
/*
#scenes .scene.animate{transition: left 0.7s;}
#scenes .scene.in{left:0;}
#scenes .scene.left{left:-100%;}
#scenes .scene.right{left:100%;}
*/
var Scene = (function () {
var scenes = [];
var sceneSequence = '0';
@hyeonseok
hyeonseok / base.css
Last active Nov 15, 2018
Default style which removes brower specific designs. Suitable for most of RWD sites.
View base.css
/* reset */
html {
-webkit-text-size-adjust: 100%;
}
button {
-webkit-tap-highlight-color: rgba(255,255,255,0);
-webkit-tap-highlight-color: transparent;
outline: 0 none;
}
button::-moz-focus-inner {
@hyeonseok
hyeonseok / today.js
Last active Sep 23, 2018
Now in "Ymd His" format.
View today.js
const now = new Date();
const YMD = `${now.getFullYear()}-${`0${now.getMonth() + 1}`.slice(-2)}-${`0${now.getDate()}`.slice(-2)}`;
const His = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`
@hyeonseok
hyeonseok / console.log.to.div.html
Last active Feb 1, 2016
console.log to screen, for those who debugs on old browser.
View console.log.to.div.html
<div id="trace" style="position: absolute; z-index: 99999; top: 0; right: 0; border: 2px solid #0c0; background: #fff; color: #0c0; font: 11px monospace;"></div>
<script>
var console = {
log: function trace() {
var msg = Array.prototype.slice.call(arguments).join(' ');
document.getElementById('trace').innerHTML += msg.toString() + '<br>';
}
}
console.log(navigator.userAgent);
</script>
@hyeonseok
hyeonseok / setPhotoSize.js
Created Jan 20, 2016
Fit image to the container while cropping given ratio.
View setPhotoSize.js
_setPhotoSize: function($image) {
var cropPortion = 1.2,
imageWidth = $image.width(),
imageHeight = $image.height(),
imageRatio = imageWidth / imageHeight,
windowWidth = LayoutManager().getScreenWidth(),
windowHeight = LayoutManager().getScreenHeight(),
windowRatio = windowWidth / windowHeight,
width, height, top = 0, left = 0;
@hyeonseok
hyeonseok / layerOpen.js
Created Jan 15, 2016
Open layer, then close layer by clicking document.
View layerOpen.js
// TODO: Add complete HTML document.
$layer: $('.layer'),
$button: $('.button'),
_initialize: function() {
$(document).on('click', this._onClick.bind(this));
},
_onClick: function(event) {
@hyeonseok
hyeonseok / ajax.js
Last active Dec 12, 2015
Minimal Ajax function
View ajax.js
// Minimal Ajax function https://gist.github.com/hyeonseok/604812e389aa9e74d346
function ajax(u,c,d){var x=new(this.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP");x.onreadystatechange=function(){this.readyState^4||c(this)};if(d){x.open('POST',u);x.setRequestHeader('Content-type','application/x-www-form-urlencoded')}else{x.open('GET',u)}x.send(d)}
/*
GET request
ajax('whatever.php?foo=bar', function (xhr) {
console.log(xhr.responseText);
});
POST request
ajax('whatever.php', function (xhr) {
@hyeonseok
hyeonseok / SwapScroll.js
Last active Aug 2, 2018
Swap window scroll from main content to modal window, and vise versa.
View SwapScroll.js
// Needs to be clean up.
var mainContent = document.getElementById('main');
var open = function (target) {
var closeButton = target.querySelector('p.button button');
mainContent.style.top = -1 * document.body.scrollTop + 'px';
mainContent.style.position = 'fixed';
target.setAttribute('aria-hidden', 'false');
document.body.scrollTop = 0;
closeButton.addEventListener('click', close);
View transparent-data-uri.gif.txt
# blank
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
# 10% black
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURQkJCQC1BbgAAAABdFJOUxq9hCEcAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==
# 20% black
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURQoKBSBopAkAAAABdFJOUzP/NrlwAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==
# 30% black
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURQ0JBpcDsPUAAAABdFJOU01Ii+VLAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==
# 40% black
You can’t perform that action at this time.