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
<!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 / 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
@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 / 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>
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 / 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();
});
a = {preventDefault:function(){}};

Keybase proof

I hereby claim:

  • I am travelingtechguy on github.
  • I am travelingtechguy (https://keybase.io/travelingtechguy) on keybase.
  • I have a public key whose fingerprint is 518E C8E2 5D29 429C C77A 810A 5861 AB01 E38A 8CA4

To claim this, I am signing this object:

@TravelingTechGuy
TravelingTechGuy / ensureUnique.js
Created March 14, 2017 21:14
Ensure an array contains unique elements, using a Set
let arr = [2, 3, 5, 2, 1, 3];
arr = [...new Set(arr)]; //arr now contains [2, 3, 5, 1]