Skip to content

Instantly share code, notes, and snippets.

View jamiejohnsonkc's full-sized avatar

Jamie Johnson jamiejohnsonkc

View GitHub Profile
@jamiejohnsonkc
jamiejohnsonkc / clone_and_create_new_repo.md
Last active September 9, 2021 15:57
git clone & create new repo

First clone the repository you want to work with. This step could be skipped if you want it all to happen in the folder you are already in.

git clone file:///path/to/repo/

Cloning will bring over the remotes specified in that directory. So you'll need to remove the remotes you don't want.

git remote rm <remote>
@jamiejohnsonkc
jamiejohnsonkc / randomColor.js
Last active September 7, 2021 23:08
js generate random colors
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
@jamiejohnsonkc
jamiejohnsonkc / TimeStampOnEdit.js
Created August 30, 2021 16:13
GoogleSheets TimeStampOnEdit (js)
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Sheet1" ) { //checks that we're on Sheet1 or not
var r = s.getActiveCell();
if( r.getColumn() == 1 ) { //checks that the cell being edited is in column A
var nextCell = r.offset(0, 1);
if( nextCell.getValue() === '' ) //checks if the adjacent cell is empty or not?
nextCell.setValue(new Date()).setNumberFormat("yyyy-MM-dd" );
var nextNextCell = r.offset(0, 2);
if( nextNextCell.getValue() === '' ) //checks if the adjacent cell is empty or not?
@jamiejohnsonkc
jamiejohnsonkc / loop_output_prime_numbers.js
Last active May 28, 2021 20:39
js loop output prime numbers
// For each i in the interval {
// check if i has a divisor from 1..i
// if yes => the value is not a prime
// if no => the value is a prime, show it
// }
let n = 10;
@jamiejohnsonkc
jamiejohnsonkc / loop_repeat_until_condition_met.js
Created May 28, 2021 20:35
js loop repeat until condition is met
let num;
do {
num = prompt("Enter a number greater than 100?", 0);
} while (num <= 100 && num);
@jamiejohnsonkc
jamiejohnsonkc / even numbers.js
Last active May 28, 2021 20:35
js loop output even numbers
for (let i = 2; i <= 10; i++) {
if (i % 2 == 0) {
alert( i );
}
}
@jamiejohnsonkc
jamiejohnsonkc / guestList.js
Last active May 28, 2021 18:41
guest list
const people = ['Chris', 'Anne', 'Colin', 'Terri', 'Phil', 'Lola', 'Sam', 'Kay', 'Bruce'];
const admitted = document.querySelector('.admitted');
const refused = document.querySelector('.refused');
admitted.textContent = 'Admit: ';
refused.textContent = 'Refuse: '
for (let i = 0; i < people.length; i++) {
@jamiejohnsonkc
jamiejohnsonkc / random_string--from_array.js
Created March 31, 2021 22:09
random string from array #JS_random_string
const movesArray = ['rock', 'paper', 'scissors']
const rand = movesArray[Math.floor(Math.random() * movesArray.length)]
console.log(rand)
@jamiejohnsonkc
jamiejohnsonkc / fizzBuzz.js
Last active March 31, 2021 20:25
FizzBuzz conditional for loop #js_loop
const answer = parseInt(
prompt('Please enter the number you would like to FizzBuzz up to: ')
)
for (let i = 1; i <= answer; i++) {
if (i % 3 === 0 && i % 5 === 0) {
console.log('FizzBuzz')
} else if (i % 3 === 0) {
console.log('Fizz')
} else if (i % 5 === 0) {
console.log('Buzz')
@jamiejohnsonkc
jamiejohnsonkc / readme_simple.md
Created March 25, 2021 17:10
simple_github_readme_template.md

Project Title

Simple overview of use/purpose.

Description

An in-depth paragraph about your project and overview of use.

Getting Started