Skip to content

Instantly share code, notes, and snippets.

View twhite96's full-sized avatar
☢️
Cookin

tiff twhite96

☢️
Cookin
View GitHub Profile
// Bonfire: Confirm the Ending
// Author: @twhite96
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending?solution=function%20end(str%2C%20target)%20%7B%0A%20%20%2F%2F%20%22Never%20give%20up%20and%20good%20luck%20will%20find%20you.%22%0A%20%20%2F%2F%20--%20Falcor%0A%0A%20%0A%20%20var%20length%20%3D%20target.length%3B%0A%20%20var%20isEqual%20%3D%20target%20%3D%3D%3D%20str.substr(-length)%3B%0A%20%20%20return%20isEqual%3B%0A%20%20%20%0A%7D%0A%0Aend(%22Bastian%22%2C%20%22n%22)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
// Bonfire: Repeat a string repeat a string
// Author: @twhite96
// Challenge: http://www.freecodecamp.com/challenges/bonfire-repeat-a-string-repeat-a-string?solution=function%20repeat(str%2C%20num)%20%7B%0A%20%20%2F%2F%20repeat%20after%20me%0A%20%20var%20newString%20%3D%20%22%22%3B%0A%20%20while%20(num%20%3E%200)%20%7B%0A%20%20%20%20newString%20%2B%3D%20str%3B%0A%20%20%20%20num--%3B%0A%20%20%7D%0A%20%20return%20newString%3B%0A%7D%0A%0Arepeat(%22abc%22%2C%203)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function repeat(str, num) {
// repeat after me
var newString = "";
while (num > 0) {
newString += str;
@twhite96
twhite96 / traffic-light-demo.pde
Created April 4, 2016 00:09
Traffic Light Sim for Arduino
/*
Traffic Light Demo
*/
bool testMode = false;
// First light
int firstLightGreen = 3;
int firstLightYellow = 4;
int firstLightRed = 5;
@twhite96
twhite96 / app.js
Created April 30, 2016 23:16
Quiz app
//Create Questions
var questions = [
new Question("Who was the first President of the United States?", [ "George Washington", "Thomas Jefferson" ], "George Washington"),
new Question("What is the answer to the Ultimate Question of Life, the Universe, and Everything?", ["Pi","42"], "42")
];
//Create Quiz
var quiz = new Quiz(questions);
//Display Quiz
@twhite96
twhite96 / image_scraping_script.py
Last active June 19, 2016 04:15
Web Image Scraper
import urllib2
resp = urllib2.urlopen('http://testurl.com')
from bs4 import BeautifulSoup
soup = BeautifulSoup(resp.read())
images = soup.find_all('img')
foreach images in image:
@twhite96
twhite96 / link_scraping_script.py
Last active June 19, 2016 04:14
Link scraper
@twhite96
twhite96 / chunky_monkey.js
Created June 18, 2016 03:28
Chunky Monkey algorithm Free Code Camp solution
function chunkArrayInGroups(arr, size) {
var newArray = [];
var oldArray = arr.length/size;
for (var i = 0; i < oldArray; i++) {
var array = arr.splice(0, size);
newArray.push(array);
}
return newArray;
@twhite96
twhite96 / download_egghead_videos.md
Created June 18, 2016 04:02 — forked from nhtera/download_egghead_videos.md
download egghead videos
@twhite96
twhite96 / slasher_flick.js
Created June 18, 2016 22:45
Slasher Flick Free Code Camp Algorithm
function slasher(arr, howMany) {
// it doesn't always pay to be first
arr.splice(0, howMany);
return arr;
}
slasher(["burgers", "fries", "shake"], 1);
@twhite96
twhite96 / mutations.js
Created June 18, 2016 23:33
Mutations Free Code Camp Algorithm
function mutation(arr) {
var arr1 = arr[1].toLowerCase();
var arr2 = arr[0].toLowerCase();
for (var i = 0; i < arr1.length; i++) {
if (arr2.indexOf(arr1[i]) < 0)
return false;
}
return true;