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
| " Set the title of the Terminal to the currently open file | |
| function! SetTerminalTitle() | |
| let titleString = expand('%:t') | |
| if len(titleString) > 0 | |
| let &titlestring = expand('%:t') | |
| " this is the format iTerm2 expects when setting the window title | |
| let args = "\033];".&titlestring."\007" | |
| let cmd = 'silent !echo -e "'.args.'"' | |
| execute cmd | |
| redraw! |
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 isPalindrome (str) { | |
| if (typeof str !== 'string') { | |
| return false; | |
| } | |
| var n, | |
| letters = str.split(''), | |
| len = letters.length - 1; | |
| for (n = 0; n <= len; n++) { | |
| if (n !== len - n && letters[n] !== letters[len - n]) { | |
| return false; |
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
| // in order for this to work, you need a yummly dev account. | |
| function makePie (response) { | |
| var match = JSON.parse(response).matches[0], | |
| yourPie = ["you could bake a delicious ", | |
| match.recipeName, | |
| " using "]; | |
| match.ingredients.forEach(function (ingredient) { | |
| yourPie.push("[" + ingredient + "]"); | |
| }); |
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
| Array.prototype.fakeMap = function (fn, context) { | |
| var out = this instanceof Array ? [] : {}, | |
| context = context || this, | |
| result, | |
| n; | |
| if (typeof fn !== "function") { | |
| return []; | |
| } | |
| for (n in this) { | |
| if (this.hasOwnProperty(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
| Array.prototype.rammstein = function () { | |
| var phrase = '', rammsteined = []; | |
| this.forEach( function ( word ) { | |
| phrase += word.toUpperCase() + ' '; | |
| rammsteined.push( phrase ); | |
| }); | |
| return rammsteined; | |
| } |
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 | |
| vowels = ['a', 'e', 'i', 'o', 'u', 'y'], | |
| consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'], | |
| letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; | |
| function name (nameLength, numberOfNames) { | |
| var names = []; | |
| if (nameLength > 14) return 'too long!'; | |
| if (numberOfNames > 100 || numberOfNames < 0 || typeof numberOfNames !== 'number') numberOfNames = 1; | |
| var |
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
| // In a recent interview I was stumped by a question about JS's native | |
| // function.apply() and function.call() methods. I resolved to learn more | |
| // about why these methods are useful to a JS developer. Here's what I now | |
| // understand: | |
| // let's make a simple function that introduces an individual. | |
| // We pass arguments defining the interests of the individual. | |
| // The greeting is personalized by the value of this.name. | |
| function introduceMe (interest1, interest2) { | |
| var that = this; |
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
| { | |
| "name" : "Fun Song", | |
| "instruments" : { | |
| "funSound" : { | |
| "sources" : { | |
| "1" : "sine", | |
| "2" : "sine", | |
| }, | |
| "envelope": { | |
| "attack" : 0, |
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
| /* | |
| I created a Google Sheet to organize short bursts of lesson plan content across grade and content levels at Dever School. | |
| Script automatically deletes out-of-date entries. | |
| Script will also sort the page after deleting duplicates so that up-to-date information appears first. | |
| */ | |
| function removeDuplicates(){ | |
| Logger.clear(); | |
| Logger.log("starting over..."); | |
| var ss = SpreadsheetApp.openById(**ID NUMBER HERE **); //get spreadsheet |
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
| /* | |
| projecteuler.net | |
| Amicable numbers | |
| Problem 21 | |
| Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). | |
| If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers. | |
| For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220. | |
| Evaluate the sum of all the amicable numbers under 10000. |