Skip to content

Instantly share code, notes, and snippets.

@nerdpruitt
nerdpruitt / gist:fdd44c70fb6054ef405f
Created July 15, 2015 13:13
Sublime Text Settings
{
"Seti_sb_tree_miny": true,
"Seti_tabs_med": true,
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 50,
"auto_complete_selector": "source - comment",
"auto_complete_size_limit": 4194304,
"auto_complete_triggers":
[
@nerdpruitt
nerdpruitt / gist:e023dff48cd81a52db11
Last active August 29, 2015 14:08
Start Jekyll from Gulp using vanilla Node
gulp.task('jekyll', function(){
return require('child_process').spawn('jekyll', ['serve', '--watch'], { stdio: 'inherit' });
});
gulp.task('default', ['jekyll']);
@nerdpruitt
nerdpruitt / SassMeister-input-HTML.html
Created March 20, 2014 19:58
Generated by SassMeister.com.
<div class="tooltip">
<span class="tooltip__icon"></span>
<h2 class="tooltip__heading">This is the heading</h2>
<p class="tooltip__text">This is some body text that can get kinda long sometimes.</p>
<div class="tooltip__meta">Created today</div>
</div>
<br><br>
<div class="tooltip--below">
// 1. Write a class to support the following code:
function Person(name){
this.name = name;
}
var thomas = new Person('Thomas');
var amy = new Person('Amy');
thomas.name // --> "Thomas"
// 2. Add a getName() method to all Person objects, that outputs
// A tracing version:
Function.prototype.cached = function(){
var self = this, cache = {};
return function(arg){
if(arg in cache) {
console.log('Cache hit for '+arg);
return cache[arg];
} else {
console.log('Cache miss for '+arg);
Function.prototype.cached = function(){
// reference original function and create cache
var self = this, cache = {};
return function(arg){
// is this argument already in the cache?
if(arg in cache) return cache[arg];
// if not add it
return cache[arg] = self(arg);
}
}
function Car(color,make) {
this.color = color;
this.make = make;
this.log = function(){
console.log("My car is a " + this.color + " " + this.make + ".");
};
}
(new Car('blue','BMW')).log();
(new Car('green','Ferrari')).log();
var mercedes = ({ color: 'red', make: 'Mercedes' });
var ferrari = ({ color: 'red', make: 'Ferrari' });
function logCar(car){
return "I'm a " + car.color + " " + car.make;
}
logCar(mercedes);
logCar(ferrari);
function logCar(obj, objName) {
var result = "";
// Object.keys(obj).length
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
result += obj[i] + " ";
}
}
console.log("My car is a " + result);
}
// Exercise 2 - Closures
// Wrap the following code in a closure and export only the "countdown" function.
// Code
var countdown = (function(){
var index;
function log(){
console.log(index);
}