Skip to content

Instantly share code, notes, and snippets.

// As a function or class, the following can be used to execute
// command-line programs from Firefox. When used with executing
// a batch file with arguments as at
// http://gist.github.com/221161/ , Firefox can be made to pipe
// success or error output to a file and then retrieve the file
// (e.g., to make a FF extension which works as a command-line,
// allowing copy-and-paste, logging, etc.)
/**
* Execute a file on the command line with the given arguments
:: Don't hold me accountable if this is not safe! This is my first batch
:: file beyond just opening programs...
:: When used in conjunction with http://gist.github.com/221159 , Firefox
:: can call this file with the first argument being a file to which to log
:: output (error or otherwise), thus enabling applications like command-line
:: emulators in Firefox
:@echo off
:: First argument is the output file, the second argument is the command (e.g., "svn"), and the other arguments up to the last are arguments to be passed after the command, and the last argument is the argument count and is ignored
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test replacing PHP.JS blocks</title>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
// This solution had been posted to http://phpjs.org earlier, but not archived there or at archive.org; only found record at http://tubeurl.com/spider/phpjs.org
<!--
How about a templating system which looked like this?
Inspired by http://code.google.com/p/mjst/ and my earlier
http://gist.github.com/250870
Could use PHPTAL-style attributes as well, but the use of "j"
attributes is for simple, not-so-ugly use and addresses the problem
that processing instructions cannot occur within tags/attributes
This solution does not necessitate any string or regular expression
processing whatsoever; all can be handled by the DOM
A pity there are no namespaces with processing instructions (and a pity
(function () {
function _addClick(browser, textboxID) {
return function (e) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
function loaded () {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var urlbarURL = browser.getUserData('urlbarURL');
<xbl xmlns="http://www.w3.org/ns/xbl" xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ib="http://brett-zamir.me/ns/ibrowser">
<binding element="ib|browser" id="browser">
<template allow-selectors-through="true" apply-author-sheets="true">
<div id="wrapper">
<h:div>
<h:a href="javascript:void(0);" id="back">&lt;</h:a> &#160;
<h:a href="javascript:void(0);" id="forward">&gt;</h:a> &#160;
<h:input id="urlBar" type="text" size="30" />
<h:input type="button" id="go" value="Go!" />
</h:div>
/*globals exports*/
(function () {
// Todo: Note to self: Integrate research from JML
// Todo: Add tests
// Todo: Allow building of generic XML (pass configuration object)
/*
1) String element name (or array of 1-4)
2) Optional object with attributes
3) Optional array of text nodes and child elements
// Get first canvas tag on page
var ctx = C2D2();
// Wrap a specific canvas DOM element
var ctx = C2D2(myCanvas);
// Use existing canvas tag (by string ID)
var ctx = C2D2('cnv');
// Single argument array; creating a new canvas and context and adding canvas to the body
// Use property name as a function (but without arguments) to get the value
var strokeStyle = C2D2(c).strokeStyle("rgb(50,110,210)").strokeStyle();
// Chaining is usable for custom methods or direct canvas wrappers:
var ctx = C2D2([1000, 450])
.$shadow({color:'green', blur:2, offset:[5, 10]})
.$line({color:'red', width:5, xy:[[75, 50], [100,75], [100,25]]})
.$fill({color:'blue', xy:[[175, 150], [200,175], [200,125]]});