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
a = {preventDefault:function(){}};
@TravelingTechGuy
TravelingTechGuy / DisablePaste.js
Last active August 9, 2016 19:55
Disable paste event
//1. Plain JavaScript
document.getElementById("txtPassword").addEventListener("paste", function(e) {
e.preventDefault();
});
//2. If jQuery is used on the page, it might look like this:
$('#txtPassword').bind("paste", function(e) {
e.preventDefault();
});
0 info it worked if it ends with ok
1 verbose cli [ '/opt/local/bin/node', '/opt/local/bin/npm', '-g', 'update' ]
2 info using npm@1.3.23
3 info using node@v0.10.24
4 verbose cache add [ 'express', '*' ]
5 verbose cache add name="express" spec="*" args=["express","*"]
6 verbose parsed url { protocol: null,
6 verbose parsed url slashes: null,
6 verbose parsed url auth: null,
6 verbose parsed url host: null,
@TravelingTechGuy
TravelingTechGuy / copyrightYear.html
Last active January 2, 2016 00:39
Add the current year to copyright notice/footer
<!-- Assuming you have the text &copy <span id="year"></span> in your footer -->
<!-- Without jQuery, add to bottom of page -->
<script>document.getElementById('year').textContent = (new Date()).getFullYear();</script>
<!-- If you're using jQuery, add this to $(document).ready() or $(function()) -->
$('#year').text((new Date()).getFullYear());
<!-- One line in the HTML page -->
<footer>copyright © <script>document.write((new Date()).getFullYear());</script></footer>
@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
requirejs(['cordova.js'],
function () {
// start of require
// cordova is now available globally
var exec = cordova.require('cordova/exec');
var app = {
// Application Constructor
<!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>
@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