Skip to content

Instantly share code, notes, and snippets.

@pingyen
pingyen / appFiguresRequestToken.php
Created August 25, 2016 13:33
AppFigures OAuth 2.0 Request Token PHP Example
<?php
define('CLIENT_KEY', 'abcdef0123456789abcdef0123456789');
define('SECRECT_KEY', '9876543210fedcba9876543210fedcba');
parse_str(
file_get_contents('https://api.appfigures.com/v2/oauth/request_token?oauth_consumer_key=' . CLIENT_KEY . '&oauth_callback=oob&oauth_signature_method=PLAINTEXT&oauth_signature=' . SECRECT_KEY . '%26'),
$output
);
print_r($output);
@pingyen
pingyen / console.js
Last active December 6, 2018 03:16
Simple JavaScript console.log for Browsers without console
(function() {
var div = document.createElement('div');
div.style.cssText = [
'position: fixed',
'bottom: 10px',
'right: 10px',
'padding: 10px',
'background: yellow',
'z-index: 2147483647'
@pingyen
pingyen / rel2abs.php
Created August 5, 2016 13:45
Convert relative path to absolute path
<?php
function absolute($base, $relative) {
$stack = explode('/', $base);
array_pop($stack);
foreach (explode('/', $relative) as $part) {
if ($part === '.') {
continue;
}
@pingyen
pingyen / ascii.js
Created January 15, 2016 06:50
Get ASCII code of characters in a string
var a = [];
'abcdefghijk'.split('').forEach(function(c) {
a.push(c.charCodeAt(0));
});
console.log(a);
@pingyen
pingyen / googlePlayLangs.json
Created January 6, 2016 03:17
Google Play Language List
[
"Afrikaans – af",
"Amharic – am",
"Arabic – ar",
"Armenian – hy-AM",
"Azerbaijani – az-AZ",
"Basque – eu-ES",
"Belarusian – be",
"Bengali – bn-BD",
"Bulgarian – bg",
@pingyen
pingyen / regionCountryLanguage.json
Created January 5, 2016 07:12
Apple App Store regionCountryLanguage.json
{
"data":[
{
"region":"EUR",
"storeFronts":[
{
"storeFront":"Albania",
"country":"AL",
"supportedLocaleCodes":[
"en-GB"
@pingyen
pingyen / countryName.json
Created January 4, 2016 03:41
Country Code to Country Name Map
{
"BD":"Bangladesh",
"BE":"Belgium",
"BF":"Burkina Faso",
"BG":"Bulgaria",
"BA":"Bosnia and Herzegovina",
"BB":"Barbados",
"WF":"Wallis and Futuna",
"BL":"Saint Barthelemy",
"BM":"Bermuda",
@pingyen
pingyen / countryCodes.json
Created January 4, 2016 03:39
Country Name to Country Code Map
{
"Bangladesh":"BD",
"Belgium":"BE",
"Burkina Faso":"BF",
"Bulgaria":"BG",
"Bosnia and Herzegovina":"BA",
"Barbados":"BB",
"Wallis and Futuna":"WF",
"Saint Barthelemy":"BL",
"Bermuda":"BM",
@pingyen
pingyen / formatJSON.php
Created August 11, 2015 06:22
JSON Formatter
<?php
$path = '/path/to';
foreach(scandir($path) as $file) {
if (substr($file, -5) === '.json') {
$path2 = "$path/$file";
file_put_contents($path2, shell_exec("cat $path2 | python -m json.tool"));
}
}
?>
@pingyen
pingyen / xgettext.text
Created June 10, 2015 15:22
xgettext Example
$ xgettext -L PHP *.php includes/*.php -p languages/zh-Hant-TW/LC_MESSAGES -n --default-domain=default --from-code=UTF-8