##Given Apache 2 and MySQL are already installed.
#Update MacPorts sudo port selfupdate;sudo port -u upgrade outdated
#Install PHP 5.4.* sudo port install php54 php54-apache2handler ##Activate Apache Module cd /opt/local/apache2/modules
var sqlite3 = require('sqlite3').verbose(); | |
var db = new sqlite3.Database('guy.sqlite'); //':memory:' | |
db.serialize(function() { | |
db.get("SELECT name FROM sqlite_master WHERE type='table' AND name='lorem'", function(error, row) { | |
if (row !== undefined) { | |
console.log("table exists. cleaning existing records"); | |
db.run("DELETE FROM lorem", function(error) { | |
if (error) | |
console.log(error); |
var fname = /^function\s+([^(]+)/.exec(arguments.callee.toString())[1]; | |
console.log(fname); | |
//alert(fname); |
function reportName() { | |
var fname = /^function\s+([^(]+)/.exec(reportName.caller.toString())[1]; | |
console.log(fname); | |
} | |
function MyFunctionHAsALongName() { | |
reportName(); | |
//Do some stuff | |
} |
#!/usr/bin/env ruby | |
hour, minute = Time.now.strftime('%I').to_i, Time.now.min | |
ones = %w{ nil one two three four five six seven eight nine } | |
teens = %w{ ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen } | |
tens = %w{ nil nil twenty thirty forty fifty } | |
minute_str = case minute | |
when 0 then 'o-clock' | |
when 1..9 then "o-#{ones[minute]}" |
import urllib2 | |
import json | |
url = '<INSERT URL>' | |
data = { | |
'aaa': '7673336666', | |
'bbb': ['4544444445','xxxxxxx','334tttt890'], | |
'ccc': { | |
'ddd': 'on', | |
'eee': 5 |
#To get the sudo password prompt | |
sudo ls | |
#Pay attention - the sudo is on the 'sh', not the 'curl' | |
curl http://npmjs.org/install.sh | sudo sh |
( | |
$("<form/>",{"action":"index.php","method":"post"}).append( | |
$("<input/>", {"type":"hidden", "name":"logout", "value":"1"}) | |
) | |
).submit(); |
public static function callService($url, $postData) { | |
if(stripos($_SERVER['HTTP_HOST'], "localhost") !== FALSE) | |
$postData .= "&XDEBUG_SESSION_START=netbeans-xdebug"; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // return into a variable | |
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); | |
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REMOTE_ADDR']); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_POST, TRUE); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); |
##Given Apache 2 and MySQL are already installed.
#Update MacPorts sudo port selfupdate;sudo port -u upgrade outdated
#Install PHP 5.4.* sudo port install php54 php54-apache2handler ##Activate Apache Module cd /opt/local/apache2/modules
var postForm = function(destination, fields) { | |
var form = $("<form/>",{"action":destination,"method":"post"}); | |
$.each(fields, function(name, value) { | |
form.append($("<input/>", {"type":"hidden", "name":name, "value":value})); | |
}); | |
//for this to work in FF, form must be appended to body - not necessary in WebKit | |
$("body").append(form); | |
form.submit(); | |
} |