Skip to content

Instantly share code, notes, and snippets.

View travissanon's full-sized avatar
🌑
Hashing Semicolon Slasher

Travis Sanon travissanon

🌑
Hashing Semicolon Slasher
View GitHub Profile
@travissanon
travissanon / uri.js
Created May 14, 2021 07:01 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@travissanon
travissanon / README-Template.md
Created March 30, 2018 17:07 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

var, let, and const. What are the differences of the three and which ones should you use?
If you do not know what let and const are, they are basically different variations of the “variable”, derived from ES6.
Variables are absolutely essential to any programming language, but in Javascript, the var keyword does has some flaws.
Thats where ES6 variables come in.
When you declare a const = Cannot be updated
When you declare a let = The variable can only be used in the block its created in
'esversion: 6';
function myReplace(str, before, after) {
var re = new RegExp(before);
return before[0] === before[0].toLowerCase() ? str.replace(re, after)
: str.replace(re, after.charAt(0).toUpperCase() + after.slice(1));
}
myReplace("He is Sleeping on the couch", "Sleeping", "sitting");
'esversion: 6';
function translatePigLatin(str) {
var vowels = ['a', 'e', 'i', 'o', 'u'];
var string = str.split('');
var vowelFirst = false;
var vowelIndex;
vowels.map(vowel => vowel === str.charAt(0) ? vowelFirst = true : false);
for (var i = 0; i < string.length; i++) {
@travissanon
travissanon / gist:9b106dcfffeef5d334179f52e11506b4
Created September 23, 2017 00:56
freeCodeCamp Intermediat Algorithms: Wherefore Art Thou
'esversion: 6';
function whatIsInAName(collection, source) {
// Stores the name of each nameValue pair of the source object in an array
var sourceKeys = Object.keys(source);
// Iterates through the collection array
return collection.filter(item => {
// For every key in the sourceKeys variable
@travissanon
travissanon / gist:62f755d810604ac152d0f2cef9be97ae
Created September 6, 2017 14:26
freeCodeCamp Intermediate Algorithms - Diff Two Arrays
function diffArray(arr1, arr2) {
var sorted1 = arr1.filter(function(e){
return this.indexOf(e) < 0;
}, arr2);
var sorted2 = arr2.filter(function(e){
return this.indexOf(e) < 0;
}, arr1);
// Same, same; but different.
return sorted1.concat(sorted2);
}