Skip to content

Instantly share code, notes, and snippets.

View timothy's full-sized avatar
🎯
Focusing

Timothy timothy

🎯
Focusing
View GitHub Profile
@timothy
timothy / Count in a Circle Loop
Created July 12, 2017 11:29
circular count within a loop
//circular count within a loop example
std::string key = "12345";
for (int i = 0, j = 0; i < 30; ++i)
{
std::cout << j;
j = (int) ((j + 1) % key.length());
}
sudo apt-get update # Fetches the list of available updates
sudo apt-get upgrade # Strictly upgrades the current packages
sudo apt-get dist-upgrade # Installs updates (new ones)
sudo apt autoremove # Removes unused packages
google-chrome --disable-web-security
chromium-browser --disable-web-security --user-data-dir
//for caching git credentials...
git config --global credential.helper 'cache --timeout 3600'
@timothy
timothy / HTML View of Console.log output
Created April 19, 2017 20:10
show console output on web page
<pre id="log"></pre>
<script>
(function() {
var old = console.log;
var logger = document.getElementById('log');
console.log = function() {
for (var i = 0; i < arguments.length; i++) {
if (i > 0) {
logger.innerHTML += " ";
}
@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
function Clamp(x, min, max) {
return x < min ? min: (x > max ? max: x);
}
/**
* Author https://github.com/timothy
* @return {number}
*/
function Factorial(num) {
return num <=1 ? 1 : num * Factorial(num - 1);
}
console.log(Factorial(8));
@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
/**
* 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;
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…
-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