This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var works = [ | |
{ | |
title: "First Project", | |
pic: "http://www.animal-photography.com/thumbs/red_tabby_long_hair_kitten_~AP-0UJFTC-TH.jpg" | |
}, | |
{ | |
title: "Second Project", | |
pic: "img/silver_kitten.jpg" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// twitter follow button | |
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https'; | |
if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js'; | |
fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs'); | |
$(document).ready(function(){ | |
// smooth scrolling | |
var $root = $('html, body'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find the longest string in an array | |
words = ["fun", "time", "ab"] | |
# Simply calling words.sort would sort based on the alphabetic position of the first letter of each word. | |
puts words.sort_by{ |word| word.length}.last | |
#The above method can be rewritten with ampersand as | |
puts words.sort_by(&:length).last |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################################# | |
# Write a function fib() that a takes an integer "n" and returns the n-th fibonacci number | |
# fib(0) # => 0 | |
# fib(1) # => 1 | |
# fib(2) # => 1 | |
# fib(3) # => 2 | |
# fib(4) # => 3 | |
# ... | |
def fib(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const list = [ | |
{ | |
n: 1, | |
children: [{ | |
n: 11, | |
children: [] | |
}, { | |
n: 12, | |
children: [] | |
}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function balancedParens(string) { | |
return !string.split("").reduce((previous, char) => { | |
if (previous < 0) { return previous; } | |
if (char === "(") { return ++previous }; | |
if (char === ")") { return --previous }; | |
return previous; | |
}, 0); | |
} | |
// test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const coins = { | |
'penny': 1, | |
'nickel': 5, | |
'dime': 10, | |
'quarter': 25 | |
} | |
const coinsByAmount = Object.keys(coins).reverse(); | |
function getChange(amount) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Redux from 'redux'; | |
const reducer = (state = [], action) => { | |
if (action.type === 'split_string') { | |
return action.payload.split(''); | |
} else if (action.type === 'add_character') { | |
return [...state, action.payload]; | |
} | |
return state; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const files = event.dataTransfer ? event.dataTransfer.files : event.target.files; | |
const fileToUpload = files[0]; | |
let xhr = new XMLHttpRequest(), | |
formData = new FormData(); | |
formData.append("test", fileToUpload, fileToUpload.name); | |
xhr.onreadystatechange = () => { | |
if(xhr.readyState == 4) { | |
if(xhr.status >= 200 && xhr.status < 300) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StoreHelpers { | |
constructor() { | |
// This should never run because StoreHelpers is a class of static methods. | |
// Sanity check: throw an exception if the main application tries to instantiate | |
throw new Error('ERROR: Unexpected instantiation of static class StoreHelpers.'); | |
} | |
static cloneDeep(obj) { | |
var out, v, key; | |
out = Array.isArray(obj) ? [] : {}; |