Skip to content

Instantly share code, notes, and snippets.

View ryanhanwu's full-sized avatar
🎯
Focusing

Ryan Wu ryanhanwu

🎯
Focusing
View GitHub Profile
@ryanhanwu
ryanhanwu / Example_result
Last active August 29, 2015 14:08
Use this script to list all your Amazon S3 bucket's region
Bucket: myffevents ( us-west-1 ) - Fri Oct 24 2014 09:36:46 GMT+0800 (CST)
Bucket: myfflogs ( eu-west-1 ) - Fri Oct 24 2014 09:40:17 GMT+0800 (CST)
{ countries : [
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@ryanhanwu
ryanhanwu / createIndex.js
Created December 15, 2014 09:36
Fast create bitbucket wiki page index. Run this script on the console, it will create a new window with index markdown inside it
(function(window) {
var url = document.URL;
var headers = jQuery("h3,h4","#repo-content");
var result;
for (var i = 0; i < headers.length; i++) {
var header = headers[i];
var elem = header.nodeName;
var link = ['<pre>', elem === 'H3' ? ' * ' : ' * ' ,'[', header.textContent ,'](',url,'#', header.id,')' ,'\n','</pre>' ];
result += link.join('');
@ryanhanwu
ryanhanwu / README.md
Last active August 29, 2015 14:12
Trine 2 saved game location on Mac DirectDownload/Steam/App Store

Trine 2 Saved game location on Mac

Old Path

~/Library/Trine2

Steam

~/Library/Application Support/Steam/userdata/[yoursteamID]/35720
@ryanhanwu
ryanhanwu / bridge.js
Last active August 29, 2015 14:17
FBAppKit.bundle/bridge.js
(function() {
if (!window.__fbNative) {
var e = {
_iframe: null,
callNative: function(a, b) {
e._iframe && document.body.removeChild(e._iframe);
var c = document.createElement("iframe");
c.style.width = c.style.height = "1px";
c.style.position = "absolute";
c.style.borderStyle = "none";
@ryanhanwu
ryanhanwu / resize.js
Last active August 29, 2015 14:18
Convert @6x to @4x, @3x, and @2x (xhdpi to hdpi, mdpi, and ldpi) - For Android assets/resource
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
var gm = require('gm');
var fs = require('fs');
var path = require('path');
function getFiles(dir, files_) {
files_ = files_ || [];
@ryanhanwu
ryanhanwu / encode.js
Created May 18, 2015 11:02
EncodeUriQuery #Google #Angular.jS
function encodeUriQuery(val, pctEncodeSpaces) {
return encodeURIComponent(val).
replace(/%40/gi, '@').
replace(/%3A/gi, ':').
replace(/%24/g, '$').
replace(/%2C/gi, ',').
replace(/%20/g, (pctEncodeSpaces ? '%20' : '+'));
}
@ryanhanwu
ryanhanwu / agg.coffee
Last active August 29, 2015 14:26 — forked from lawrencejones/agg.coffee
Projection generator for mongodb
_ = require 'underscore'
# Given an array of elements ELEM and a matching KEY value,
# will build the apprpriate projection to generate sortable
# weights for a mongo aggregator.
#
# ELEM: An array of values upon which to match against KEY
# KEY: The document field key to match against
# I: Default 0, index into array at which to begin
#
@ryanhanwu
ryanhanwu / linkify.js
Created August 19, 2015 15:34
Linkify
if(!String.linkify) {
String.prototype.linkify = function() {
// http://, https://, ftp://
var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim;
// www. sans http:// or https://
var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
// Email addresses
@ryanhanwu
ryanhanwu / docwrite.js
Created April 13, 2012 17:11
Do not use document write to create script tag
//Do not use docwrite
document.write('<script src="' + src + '" type="text/javascript"><\/script>'):
//Use Async
var newScript = document.createElement("script");
newScript.async = true;
newScript.src = "http://xxxxxxxxxxxxxxxxxxxx.js";
var s0 = document.getElementsByTagName('script')[0];
s0.parentNode.insertBefore(newScript, s0);