Skip to content

Instantly share code, notes, and snippets.

Looking for my next project...

Guy Vider TravelingTechGuy

Looking for my next project...
View GitHub Profile
TravelingTechGuy / NodeSqlite.js
Created Aug 1, 2011
Using SQLite from Node.js
View NodeSqlite.js
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");"DELETE FROM lorem", function(error) {
if (error)
TravelingTechGuy / DisplayJSFunctionName1.js
Created Aug 27, 2011
Display JavaScript function name
View DisplayJSFunctionName1.js
var fname = /^function\s+([^(]+)/.exec(arguments.callee.toString())[1];
TravelingTechGuy / DisplayJSFunctionName2.js
Created Aug 27, 2011
Display JavaScript function name
View DisplayJSFunctionName2.js
function reportName() {
var fname = /^function\s+([^(]+)/.exec(reportName.caller.toString())[1];
function MyFunctionHAsALongName() {
//Do some stuff
TravelingTechGuy / fuzzyclock.rb
Created Aug 27, 2011
Create a fuzzy, verbal clock
View fuzzyclock.rb
#!/usr/bin/env ruby
hour, minute ='%I').to_i,
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]}"
TravelingTechGuy /
Created Aug 28, 2011
Test JSON service using python
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 | sudo sh
TravelingTechGuy / InstantPost.js
Created Jun 12, 2012
Post values to an HTML page using jQuery
View InstantPost.js
$("<input/>", {"type":"hidden", "name":"logout", "value":"1"})
TravelingTechGuy / curl.php
Created Sep 7, 2012
Posting to service using CURL from PHP
View curl.php
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_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
View php54_php53_pear_macports.markdown

##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

TravelingTechGuy / adhoc form.js
Last active Dec 14, 2015
create ad-hoc form and submit it - using jQuery
View adhoc form.js
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
You can’t perform that action at this time.