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
<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> |
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; |
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) { |
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, ','); |
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); |
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 { |
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); | |
} |
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 = ''; | |
})(); |
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'); |
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) { |