This file contains 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
String.prototype.isCreditCard() { | |
if (this.length > 19) | |
return (false); | |
return (parseInt(this) % 10 === 0) | |
} |
This file contains 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
// Exercise 2 - Closures | |
// Wrap the following code in a closure and export only the "countdown" function. | |
// Code | |
(function(){ | |
var index; | |
function log(){ | |
console.log(index); | |
} |
This file contains 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
// Exercise 1 - OO || !OO | |
// Define a data structure for cars (make and color), and a function | |
// that logs a string like "I'm a red Mercedes" to the console. | |
// Make two versions: a functional version, and a object-oriented version. | |
// Example call for functional version: | |
var Car = function(make, color) { | |
this.log = function() { |
This file contains 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
// 1. Write a class to support the following code: | |
// var thomas = new Person('Thomas'); | |
// var amy = new Person('Amy'); | |
// thomas.name // --> "Thomas" | |
// 2. Add a getName() method to all Person objects, that outputs | |
// the persons name. |
This file contains 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.prototype.memoized = function(key) { | |
var originalFunction = this; | |
if (!('cache' in originalFunction)) | |
originalFunction.cache = {}; | |
if (key in originalFunction.cache) { | |
console.log('returning cached value ' + originalFunction.cache[key] + ' for ' + key); | |
return originalFunction.cache[key]; | |
} else { | |
console.log('adding value to cache for ' + key); | |
return originalFunction.cache[key] = originalFunction(key); |
This file contains 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
ssh -f user@remote.com -L localport:local:remoteport -N |
This file contains 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
mysql --max_allowed_packet=100M -u root -p database < dump.sql | |
set global net_buffer_length=1000000; | |
set global max_allowed_packet=1000000000; |
This file contains 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
for f in *.jpeg; do mv $f ${f%.*}.jpg; done |
This file contains 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
select | |
TABLE_SCHEMA as 'database', | |
concat(table_name, '.', column_name) as 'foreign key', | |
concat(referenced_table_name, '.', referenced_column_name) as 'references' | |
from | |
information_schema.key_column_usage | |
where | |
referenced_table_name is not null; |
This file contains 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
gc <file> | out-file -enc utf8 <file> |
OlderNewer