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 / sortedObjectPropertiesCaseInsensitive
Last active January 1, 2016 20:59
Returns an array of one property from each item in a JSON array, sorted by name, regardless of case. This sample uses LoDash (can be used with Underscore)
//0. given:
var _ = require('lodash');
var items = [
{
name: 'dfsdfd',
value: null
},
{
name: 'Abc',
value: null,
@TravelingTechGuy
TravelingTechGuy / multiple_heroku.md
Last active December 25, 2015 02:39
How to use multiple Heroku accounts, configure the app for production, and websockets
  1. Create a new SSH key pair: ssh-keygen -t rsa -C "your user email"
  2. Call the key pair something unique: mynewheroku_rsa
  3. In the app folder, add Procfile
  4. Add the regular heroku remote: git remote add heroku git@heroku.com:<appname>.git
  5. Edit the file ~/.ssh/config
    Host mynewheroku
        HostName heroku.com
        IdentityFile ~/.ssh/mynewheroku_rsa
 IdentitiesOnly yes
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
requirejs(['cordova.js'],
function () {
// start of require
// cordova is now available globally
var exec = cordova.require('cordova/exec');
var app = {
// Application Constructor
@TravelingTechGuy
TravelingTechGuy / string.js
Created June 4, 2013 01:51
String manipulation functions (and polyfills) - to be used with RequireJS
"use strict";
//String functions
define([], function() {
var addFunctionToString = function(name, value) {
if(!String.prototype.hasOwnProperty(name)) {
Object.defineProperty(String.prototype, name, {
enumerable: false,
configurable: false,
writable: false,
value: value
@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
@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 / 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 / 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 / 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();
}