Skip to content

Instantly share code, notes, and snippets.

Avatar

Hyeonseok Shin hyeonseok

View GitHub Profile
@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
@hyeonseok
hyeonseok / random.html
Created Apr 18, 2014
Random number, at the end of event.
View random.html
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>추첨기</title>
<style>
html,
body {
height: 100%;
}
@hyeonseok
hyeonseok / android_version.php
Created Dec 21, 2013
Check Android version from user agent string.
View android_version.php
<?php
$str = '~~ Android 2.2.1; ~~';
function get_android_version($str) {
$start = strpos($str, ' Android ');
if ($start === false) {
return '';
}
$remains = substr($str, $start);
$end = strpos($remains, ';');
$remains = substr($remains, 0, $end);
@hyeonseok
hyeonseok / userContent.css
Last active Apr 13, 2017
UserCSS for Firefox.
View userContent.css
/**
* UserCSS for Firefox.
* https://gist.github.com/hyeonseok/7243239
*
* ln -s ~/Dropbox/src/firefox-usercss/userContent.css /Users/hyeonseok/Library/Application\ Support/Firefox/Profiles/{USER_PROFILE}/chrome/userContent.css
*/
* {
-webkit-touch-callout: text !important;
-webkit-user-select: text !important;
View emphasis.js
function emphasisKeyword(keyword, string) {
var h = { e: "[eéê]", a: "[aáâ]" };
var matched = keyword.match(/[\S\s]/g);
var res = [];
for (var i = 0; i < matched.length; i++) {
if (h[matched[i]]) {
res.push(h[matched[i]]);
} else {
View azaa.php
<?php
function tests($expect, $actual) {
if ($expect == $actual) {
echo('PASS');
} else {
echo('FAIL');
}
echo(': ' . $expect . '/' . $actual . PHP_EOL);
}
@hyeonseok
hyeonseok / Emmet.sublime-settings
Last active Oct 9, 2020
Private setting for Emmet for Sublime text 2
View Emmet.sublime-settings
{
"snippets":
{
"css":
{
"snippets":
{
"tf": "-webkit-transform: ${1:func};\n-moz-transform: $1;\n-ms-transform: $1;\n-o-transform: $1;\ntransform: $1;",
"ts": "-webkit-transition: ${1:func};\n-moz-transition: $1;\n-ms-transition: $1;\n-o-transition: $1;\ntransition: $1;"
}
@hyeonseok
hyeonseok / right-click.js
Last active Dec 22, 2015
Small JavaScript function to allow user using context menu or selecting text on some damn web pages.
View right-click.js
(function () {
var d = document;
d.oncontextmenu = null;
d.ondragstart = null;
d.onselectstart = null;
d.body.style.MozUserSelect = '';
})();
@hyeonseok
hyeonseok / diff2html.php
Last active Dec 22, 2015
Word diff to HTML
View diff2html.php
<?php
/*
http://hyeonseok.com/soojung/dev/2013/09/02/743.html
git diff -U1 --word-diff > ../diff.txt
Execute this command from repository then run this script.
*/
$diff_file = file('diff.txt');