View random.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ko"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>추첨기</title> | |
<style> | |
html, | |
body { | |
height: 100%; | |
} |
View ajax.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
View diff2html.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); |
View right-click.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var d = document; | |
d.oncontextmenu = null; | |
d.ondragstart = null; | |
d.onselectstart = null; | |
d.body.style.MozUserSelect = ''; | |
})(); |
View azaa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tests($expect, $actual) { | |
if ($expect == $actual) { | |
echo('PASS'); | |
} else { | |
echo('FAIL'); | |
} | |
echo(': ' . $expect . '/' . $actual . PHP_EOL); | |
} |
View emphasis.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 android_version.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
View AddCommaToNumber.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'1234567890.1234567890'.replace(/\B(?=(?=\d*\.)(\d{3})+(?!\d))/g, ','); |
View layerOpen.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: Add complete HTML document. | |
$layer: $('.layer'), | |
$button: $('.button'), | |
_initialize: function() { | |
$(document).on('click', this._onClick.bind(this)); | |
}, | |
_onClick: function(event) { |
View setPhotoSize.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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; |
OlderNewer