Skip to content

Instantly share code, notes, and snippets.

View pwlin's full-sized avatar
🎧
Listening to Africa by Toto

pwlin pwlin

🎧
Listening to Africa by Toto
View GitHub Profile
// access window object from XUL
function pageLoaded(){
alert("the page has been loaded")
}
window.addEventListener("load", function () {
gBrowser.addEventListener("load", pageLoaded, true);
}, false);
// create XUL element
function createToolbarButton() {
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var anitem = document.createElementNS(XUL_NS, "toolbarbutton");
anitem.setAttribute("id", "Testing-Doit-Button2");
anitem.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional");
anitem.setAttribute("label", "label");
anitem.setAttribute("tooltiptext", "Do it!");
anitem.setAttribute("oncommand", "testing_doit();");
return anitem;
<?php
// get the callee in PHP
$backtrace = debug_backtrace();
return $backtrace[1]['function'];
?>
// Mozilla preferences helper library
// Components.classes['@mozilla.org/preferences-service;1'] .getService(Components.interfaces.nsIPrefService) .savePrefFile(null);
var $Prefs = {
_getBranch : Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch),
_getService : Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService),
set : function(pref_name, pref_value) {
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
str.data = pref_value.replace(/^\s*|\s*$/g,'');
(this._getBranch).setComplexValue(pref_name, Components.interfaces.nsISupportsString, str);
@pwlin
pwlin / gist:370185
Created April 18, 2010 11:54
SQLite helper library for Mozilla
// SQLite helper library for Mozilla
var $sqlite = {
storageService: [],
mDBConn: [],
_initService : function(file){
var db = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
db.append(file);
this.storageService[file] = Components.classes["@mozilla.org/storage/service;1"].getService(Components.interfaces.mozIStorageService);
// Opening window/tab helper library for Mozilla
var $window = {
open_in_new_tab: function(url){
getBrowser().selectedTab = getBrowser().addTab(url);
},
open_in_same_tab: function(url){
top.content.document.location = url;
},
// UTF8 encode/decode
var $utf8 = {
encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n=0, k=string.length; n < k; n++) {
var c = string.charCodeAt(n);
// Mozilla export coordinates to a .kml file (for Google Earth)
var $google = {
_exampleLocation : {
'name':'Tokyo',
'latitude':35.65444,
'longitude':139.74472
// Other data:
//'heading' : 0 ,
//'tilt' : 0 ,
2 exe communicating vb6
project MainApp:
on the form place controls as follows:
place a frame on form, set the caption to frame1 = Communicate to Receiver
insert in frame1 a Text box, leave default name(Text1), set index to 0
place another frame on form, set the caption to frame2 = Send This Message
@pwlin
pwlin / gist:370195
Created April 18, 2010 12:01
shell exec
' wsh shell execute and return output
' MsgBox RunOutput("COMMAND /C DIR C:\", 0)
Function RunOutput(cProgram, nWindowType)
'-- Obtain a Temporary File Name
Dim oFS
Set oFS = CreateObject("Scripting.FileSystemObject")
Dim cFile
cFile = oFS.GetSpecialFolder(2).Path & "\" & oFS.GetTempName