Skip to content

Instantly share code, notes, and snippets.

@pingyen
pingyen / gtranslateLanguages.json
Created Mar 17, 2021
Google Translate Languages
View gtranslateLanguages.json
{
"af": "Afrikaans",
"am": "Amharic",
"ar": "Arabic",
"az": "Azerbaijani",
"be": "Belarusian",
"bg": "Bulgarian",
"bn": "Bengali",
"bs": "Bosnian",
"ca": "Catalan",
@pingyen
pingyen / jsonBeautifier.php
Last active Sep 24, 2019
Beautify JSON files
View jsonBeautifier.php
<?php
$path = call_user_func(function() {
global $argv;
return isset($argv[1]) === true ?
$argv[1] :
'.';
});
function findJSONFiles($path) {
@pingyen
pingyen / dedupLines.php
Created Sep 17, 2019
Remove duplicate lines in a file
View dedupLines.php
<?php
$targets = array_slice($argv, 1);
foreach ($targets as $target) {
$map = array();
foreach (explode("\n", file_get_contents($target)) as $line) {
if (isset($map[$line]) === true) {
continue;
}
@pingyen
pingyen / base.js
Created Sep 20, 2012
WinJS base.js
View base.js
/// <loc filename="Metadata\base_loc_oam.xml" format="messagebundle" />
/*!
© Microsoft. All rights reserved.
This library is supported for use in Windows Store apps only.
Build: 1.0.9200.20498.win8_ldr.120817-1716
Version: Microsoft.WinJS.1.0
*/
@pingyen
pingyen / googleNewsLangRegionList.json
Created Jan 9, 2019
Google News Language & Region List
View googleNewsLangRegionList.json
[
[
"CN:zh-Hans",
"中文 | 中国",
"CN",
"zh-Hans"
],
[
"TW:zh-Hant",
"中文 | 台灣",
@pingyen
pingyen / console.js
Last active Dec 6, 2018
Simple JavaScript console.log for Browsers without console
View console.js
(function() {
var div = document.createElement('div');
div.style.cssText = [
'position: fixed',
'bottom: 10px',
'right: 10px',
'padding: 10px',
'background: yellow',
'z-index: 2147483647'
@pingyen
pingyen / twd97Conv.php
Last active Nov 11, 2018
Transform TWD97 to Latitude Longitude
View twd97Conv.php
<?php
function twd97_to_latlng($x, $y) {
$a = 6378137.0;
$b = 6356752.314245;
$lng0 = 121 * M_PI / 180;
$k0 = 0.9999;
$dx = 250000;
$dy = 0;
$e = pow((1 - pow($b, 2) / pow($a, 2)), 0.5);
View plurkBot.php
<?php
define('NICKNAME', 'abc');
define('PASSWORD', 'iamabc');
define('USER_ID', '123456');
$message = 'Hello World!';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
@pingyen
pingyen / countries.csv
Created Sep 18, 2018
Country Name, 2-Letter, 3-Letter Code CSV
View countries.csv
Afghanistan AF AFG
Aland Islands AX ALA
Albania AL ALB
Algeria DZ DZA
American Samoa AS ASM
Andorra AD AND
Angola AO AGO
Anguilla AI AIA
Antarctica AQ ATA
Antigua and Barbuda AG ATG
@pingyen
pingyen / touchEventLogger.bookmarklet.js
Last active Sep 10, 2018
Bookmarklet of Touch Events Logger
View touchEventLogger.bookmarklet.js
javascript:(function(){var a=document.createElement("div");a.style.cssText="position: fixed;bottom: 10px;right: 10px;padding: 10px;background: yellow;z-index: 2147483647";window.console={log:function(e){a.innerHTML+=e+"<br />\n"}};"loading"!==document.readyState?document.body.appendChild(a):document.addEventListener("DOMContentLoaded",function(){document.body.appendChild(a)},!1)})();
"touchstart touchmove touchend touchcancel pointerdown pointermove pointerup pointercancel click dblclick mousedown mouseup mousemove".split(" ").forEach(function(a){document.addEventListener(a,function(a){var d=a.type,b,c;switch(d){case "touchstart":b=a.touches;break;case "touchmove":case "touchend":case "touchcancel":b=a.changedTouches}void 0===b?(c=1,b=a):(c=b.length,b=b[0]);console.log([d,b.button,b.buttons,c,a.target.nodeName,b.pageX,b.pageY,Date.now()].join(", "))},!0)});