Skip to content

Instantly share code, notes, and snippets.

Avatar

gasolin gasolin

View GitHub Profile
@gasolin
gasolin / res.py
Last active Dec 20, 2015
Gather gaia multiple resolution resources to a web page for easy debuggingUsage: `python res.py [app_name]`ex: `python res.py browser`
View res.py
import os, glob, sys
from string import Template
import datetime
template = """
<DOCTYPE html>
<html>
<body>
$table
</body>
View gaia_team_meeting_lottery
from random import shuffle
print 'gaia lottery!'
gaia_members = ['Yuren','Arthur','Dominic',
'Rex','Steve','Rudy','Alive',
'Evan','Mark','John','Fred','George','Ian','Greg','Jason']
shuffle(gaia_members)
print gaia_members
View gaia_lottery_js
//shuffles list in-place
//credit http://dtm.livejournal.com/38725.html
function shuffle(list) {
var i, j, t;
for (i = 1; i < list.length; i++) {
j = Math.floor(Math.random()*(1+i)); // choose j in [0..i]
if (j != i) {
t = list[i]; // swap list[i] and list[j]
list[i] = list[j];
list[j] = t;
@gasolin
gasolin / Script DOM element
Last active Dec 23, 2015
async download DOM and allow cross domain JS by Script DOM element
View Script DOM element
var dom = document.createElement('script');
dom.src = "http://xxx/a.js";
document.head.appendChild(dom);
@gasolin
gasolin / gist:6578631
Created Sep 16, 2013
trim string (Levithan version)
View gist:6578631
function trim(text) {
text.replace(/^\s+/, "");//.replace(/\s+$/, "");
for (var i = text.length - 1; i >= 0; i--) {
if (/\s/.test(text.charAt(i))) {
text = text.substring(0, i + 1);
break;
}
}
return text;
}
@gasolin
gasolin / relayout.py
Last active Dec 30, 2015
put this file in gaia main folder and run $ python relayout.py to replace layout breakpoint
View relayout.py
# put this file in gaia main folder and run
# python relayout.py
# 768 -> 600
originWidth = 768
targetWidth = 600
# find and replace string
import os, fnmatch
def findReplace(directory, find, replace, filePattern):
@gasolin
gasolin / pushtry.sh
Created Mar 21, 2014
script helper to push gaia branch to try server
View pushtry.sh
# https://wiki.mozilla.org/ReleaseEngineering/TryServer#Using_a_custom_Gaia
# https://wiki.mozilla.org/Gaia/Team/Taipei/BubbleTea#How_to_push_bubble-tea_to_try
hg qref -m "try: -b o -p emulator,emulator-jb,emulator-kk,linux_gecko,linux64_gecko,macosx64_gecko,win32_gecko -u gaia-unit,gaia-ui-test,gaia-integration -t none"
hg push -f try
@gasolin
gasolin / action_cmd.js
Last active Aug 29, 2015
run system execution via nodejs
View action_cmd.js
function action_cmd(cmd) {
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) {sys.puts(stdout)}
exec(cmd, puts);
}
@gasolin
gasolin / probe.js
Last active Aug 29, 2015
collecting js function performance
View probe.js
var start = new Date().getTime();
for (var n = 0; n < maxCount; n++) {
/* perform the operation to be measured *//
}
var elapsed = new Date().getTime() - start;
console.log('Measured time: ' + elapsed);
View axe1.js
var http = require("http");
var cheerio = require("cheerio");
/**
* Utility function that downloads a URL and invokes
* callback with the data.
*/
function download(url, callback) {
http.get(url, function(res) {
var data = "";