Skip to content

Instantly share code, notes, and snippets.

View cdaz5's full-sized avatar

Chris D'Ascoli cdaz5

View GitHub Profile
@cdaz5
cdaz5 / Closure
Created September 15, 2017 14:39
function test() {
let x = 5;
function closure() {
console.log( x );
}
return closure;
}
//Question 1
function isIsogram(string) {
let nonIso = []
let arry = string.toLowerCase().split(' ')
for (let i = 0; i < arry.length; i++) {
let word = arry[i].split('')
let hashTable = {}
for (j = 0; j < word.length; j++) {
if (!hashTable[word[j]]) {
//Question 2
//g makes it global and the \b keeps it to only words that have a boundry (space between).
function cocknify(input) {
return input.replace(/\bh/g, '\`')
}
// Question 3
//refactored so the for loop doesnt have = to eliminating the need for the idx - 1
@cdaz5
cdaz5 / gist:047e7f9ceecdc751bc9c49e7cadafa64
Last active September 23, 2017 13:42
HackerRank Anagram Solution
function main() {
// provided by hackerrank
var a = readLine();
var b = readLine();
// split the input into an array
aArray = a.split('')
bArray = b.split('')
// declare a variable set equal to an empty object
function main() {
// provided by hackerrank.
var n_temp = readLine().split(' ');
var n = parseInt(n_temp[0]);
var k = parseInt(n_temp[1]);
a = readLine().split(' ');
a = a.map(Number);
function largestSet() {
// grabs the specific paragraph you mention in the job description and splits it into an array
// (including white spaces as per your example) and sets it equal to a variable.
let charArry = document.querySelector('#content > div > div > div > div.col-md-9 > div > p:nth-child(3)').innerText.split('')
// check to make sure the paragraph is long enough for what we are trying to achieve. In this
// scenario we know it's longer than 50, but if we want to reuse this fn later this check is necessary.
if (charArry.length < 100) {
return 'not possible w/o dropping below 50 in length'
}
@cdaz5
cdaz5 / gist:36c8db26ab676dcdcbbece434922f159
Last active October 8, 2017 16:11
.replace blog post
function cocknify(input) {
// Couple things involving Regex:
// 1. The \b matches a word boundary (in other words where a word character is not
// followed or preceded by another word character). This will match only words
// that start with 'h' and not touch any internal h's.
// 2. The h is our search value.
// 3. The g makes the search global rather than just repalcing the first h it comes
// across and returning (keep in mind the \b stops it from effecting any internal h's).
// 4. The i makes it case in-sensitive so 'H' and 'h' are replaced.
// 5. Lastly, the backslash before the backtick is needed to escape the quotes.
fetch('http://api.wynd-staging.com/v3/orders', {
method: 'GET',
headers: {
'Authorization': '{YOUR_JSON_TOKEN}'
}
})
@cdaz5
cdaz5 / gist:24db857b2b062f6edf311f318ee4a042
Last active February 8, 2018 15:52
react-native-debugger install cmd
$ brew update && brew cask install react-native-debugger
$ yarn add redux-devtools-extension --dev