Skip to content

Instantly share code, notes, and snippets.

View TravelingTechGuy's full-sized avatar
💭
Looking for my next project...

Guy Vider TravelingTechGuy

💭
Looking for my next project...
View GitHub Profile
@TravelingTechGuy
TravelingTechGuy / npm-install.sh
Created November 17, 2011 19:59
Install npm on a mac
#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
@TravelingTechGuy
TravelingTechGuy / InstantPost.js
Created June 12, 2012 17:41
Post values to an HTML page using jQuery
(
$("<form/>",{"action":"index.php","method":"post"}).append(
$("<input/>", {"type":"hidden", "name":"logout", "value":"1"})
)
).submit();
@TravelingTechGuy
TravelingTechGuy / curl.php
Created September 7, 2012 21:47
Posting to service using CURL from 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_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);
@TravelingTechGuy
TravelingTechGuy / .jshintrc
Created August 13, 2014 14:50
Chrome extension .jshintrc
{
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`

##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
TravelingTechGuy / adhoc form.js
Last active December 14, 2015 09:59
create ad-hoc form and submit it - using jQuery
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();
}
@TravelingTechGuy
TravelingTechGuy / AjaxSpinner.js
Created April 22, 2013 03:52
Show a spinner when starting a jQuery AJAX call, and hide when the call is done
$(document)
.ajaxSend(function() {
$('#spinner').show();
})
.ajaxStop(function() {
$('#spinner').hide();
})
.ajaxError(function() {
$('#spinner').hide();
$('#message').text('Error occurred');
@TravelingTechGuy
TravelingTechGuy / node_process_name.js
Created May 16, 2013 18:00
Make the process name the one in the package.json (great for 'ps' or 'top' commands)
process.title = require('./package').name;
@TravelingTechGuy
TravelingTechGuy / RequireJS_Bootstrap_jQuery.js
Last active December 17, 2015 11:59
Use RequireJS to load Bootstrap and jQuery
'use strict';
requirejs.config({
shim: {
'bootstrap': {
deps: ['jquery']
}
},
paths: {
'jquery': [
@TravelingTechGuy
TravelingTechGuy / updatePorts.sh
Created June 3, 2013 06:51
Update all Mac Ports - run with `sudo`
#!/usr/bin/env bash
# This a simple bash script outlining the procedures to get macports on OS X
# to auto update weekly via the ~/Library/LaunchAgents/net.ipatch.macportsUpdate.plist
# The first step is to update the port files
echo "Step 1: Update port tree"
port selfupdate
# The second step is to upgrade the outdated