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
@pwlin
pwlin / gist:246467
Created December 1, 2009 17:33
Ajax with ActiveX WinHTTP 5.1
// http://msdn.microsoft.com/en-us/library/aa384273(VS.85).aspx
function test_ajax(){
var ajax = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
/*
// Define the constants used by the option property.
const WinHttpRequestOption_UserAgentString = 0; // Name of the user agent
const WinHttpRequestOption_URL = 1; // Current URL
const WinHttpRequestOption_URLCodePage = 2; // Code page
@pwlin
pwlin / gist:246475
Created December 1, 2009 17:40
Calling PHP CLI from ActiveX FSO and WScript.Shell
var php = {
cmd : function(command, nWindowType){
// Obtain a Temporary File Name
var oFS ;
var RunOutput = '' ;
oFS = new ActiveXObject("Scripting.FileSystemObject");
var cFile ;
cFile = oFS.GetSpecialFolder(2).Path+'\\'+ oFS.GetTempName() ;
// Execute the command and redirect the output to the file
@pwlin
pwlin / gist:246480
Created December 1, 2009 17:43
Convert PHP $argv to $_GET
<?php
if ($argv) {
foreach ($argv as $k=>$v){
if ($k==0) continue;
$it = explode("=", $v);
if (isset($it[1])) {
$_GET[$it[0]] = $it[1];
}
}
}
@pwlin
pwlin / gist:246483
Created December 1, 2009 17:46
javascript dispatch mouse event
var button = document.evaluate("//button[text()='archive']", document, null, XPathResult.ANY_TYPE,null).iterateNext();
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
button.dispatchEvent(evt);
@pwlin
pwlin / gist:255567
Created December 13, 2009 18:59
xp style for WebBrowser Control
<meta http-equiv="MSThemeCompatible" content="Yes">
@pwlin
pwlin / gist:260001
Created December 19, 2009 07:36
building Darwin Streaming Server
#!/bin/bash
# http://cwshep.blogspot.com/2008/08/darwin-streaming-server-603-on-linux.html
sudo apt-get install build-essential wget
sudo addgroup --system qtss
sudo adduser --system --no-create-home --ingroup qtss qtss
wget http://static.macosforge.org/dss/downloads/DarwinStreamingSrvr6.0.3-Source.tar
tar -xvf DarwinStreamingSrvr6.0.3-Source.tar
mv DarwinStreamingSrvr6.0.3-Source DarwinStreamingSrvr6.0.3-Source.orig
@pwlin
pwlin / gist:261182
Created December 21, 2009 19:46
Reads ID3v1 from a MP3 file
<?php
// http://www.go4expert.com/forums/showthread.php?t=267
//Reads ID3v1 from a MP3 file and displays it
$mp3 = "1.mp3"; //MP3 file to be read
//make a array of genres
$genre_arr = array("Blues","Classic Rock","Country","Dance","Disco","Funk","Grunge",
"Hip-Hop","Jazz","Metal","New Age","Oldies","Other","Pop","R&B",
// Mozilla - Run an external process
var fileExe = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
fileExe.initWithPath("c:\\windows\\explorer.exe");
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(fileExe);
var args = [] ;
/*
var args = new Array();
<!-- XUL drop down menu without indicator -->
<popupset>
<menupopup position="after_start" id="testPopup">
<menuitem label="test"/>
</menupopup>
</popupset>
<button label="test" type="menu" popup="testPopup"
// Manual Geolocation provider for Firefox
// about:config geo.wifi.url file://
{"location": {
"latitude": 48.777025000000002,
"longitude": 9.1713909999999998,
"accuracy": 10.0}}