Skip to content

Instantly share code, notes, and snippets.

View timothy's full-sized avatar
🎯
Focusing

Timothy timothy

🎯
Focusing
View GitHub Profile
@timothy
timothy / node v5 ubuntu 15.10
Last active January 17, 2016 19:31
install latest node js v5 in ubuntu 15.10
sudo apt-get install npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
node -v
v5.0.0
//find all global packages
https://www.googleapis.com/books/v1/volumes?q=isbn:9781451648546
http://www.programmableweb.com/category/library/apis?category=20272&data_format=21190
http://www.programmableweb.com/apis/directory
http://xisbn.worldcat.org/xisbnadmin/doc/api.htm
https://developers.google.com/books/docs/v1/using#ids
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
-g //this means global
--save-dev // save to the davDependencies in package.json
--save // save to the Dependencies in package.json
//find all global packages
npm list -g --depth=0
//Install packages for a specific project locally. Install as dev dependency.
npm install --save-dev package-name
Step by step to create a new app from scratch
1. Build simple Requirements doc
2. Extract Use Cases from Requirements Doc
3. Find Use Case Dependencies. i.e. use case 5 cannot be done until 2 is complete…
4. Order Use Cases. Start with the most essential use case that has no dependencies.
5. Find all Core use cases. i.e. Adds to the structure of the app and adds data to app. Then find supporting use cases to implement to test…
Sketch out User experience. i.e. what will the site look like…
/**
* this takes in a number and returns
* an array of unique random numbers
* starting from o to the amount given.
* @param {number} amount this is the range and the amount of random numbers
* @returns {Array} unique random numbers between 0 and amount
*/
function uniquRand(amount) {
var uRandA = [];
var random = 0;
@timothy
timothy / DOM Manipulation
Created June 14, 2016 18:06
DOM Manipulation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM Manipulation</title>
</head>
<body>
<script type="text/javascript">
/**
* Add new DOM elements
/**
* Author https://github.com/timothy
* @return {number}
*/
function Factorial(num) {
return num <=1 ? 1 : num * Factorial(num - 1);
}
console.log(Factorial(8));
function Clamp(x, min, max) {
return x < min ? min: (x > max ? max: x);
}
@timothy
timothy / Google chrome dev session instance
Last active March 1, 2017 20:51
Creates new temp/dev Chrome session with security disabled
##This example is for Windows OS.
1. Create chrome shortcut.
2. Go to shortcut properties and add the below to the end of the shortcut target.
3. add as many other flags to the end as you need. i.e. --disable-web-security
--args --user-data-dir="/tmp/chrome_dev_session" --disable-web-security --ignore-certificate-errors --allow-running-insecure-content
or enter... to cmd...
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --args --user-data-dir="/tmp/chrome_dev_session" --disable-web-security --ignore-certificate-errors --allow-running-insecure-content
"Put the file location of chrome.exe for your system in the quotes..." --args --user-data-dir="/tmp/chrome_dev_session" --disable-web-security --ignore-certificate-errors --allow-running-insecure-content