Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View christopherscott's full-sized avatar
👍
asdf

Christopher Scott Hernandez christopherscott

👍
asdf
View GitHub Profile
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@christopherscott
christopherscott / gist:1705508
Created January 30, 2012 17:17
super clean, basic api testing with node.js, vows, and coffeescript
vows
.describe("Main sections should respond with 200 ok:")
.addBatch
"get /": respondsWith 200
"get /blog": respondsWith 200
"get /portfolio": respondsWith 200
"get /about": respondsWith 200
"get /contact": respondsWith 200
.export(module)
@christopherscott
christopherscott / mongodb-cakefile.coffee
Created June 2, 2012 01:22
MongoDB start/stop Cakefile
{exec} = require 'child_process'
task "db:start", "start mongo db daemon process", ->
exec "mongod --fork --logpath ~/mongodb.log --logappend"
console.log "mongodb started"
task "db:stop", "stop mongo daemon process", ->
exec "kill -2 `ps -ef | grep 'mongod --fork' | grep -v grep | awk '{ print $2 }'`"
console.log "mongodb should be stopped"
@christopherscott
christopherscott / pow-proxy-config-ru
Created June 21, 2012 15:29
Config.ru required for pow_proxy
require 'pow_proxy'
run PowProxy.new(:host => '127.0.0.1', :port => 3000)
@christopherscott
christopherscott / wysiwym-jquery-setup
Created June 21, 2012 15:33
setting up wysiwym jquery plugin
// setup wysiwym
$(function() {
$("#post-body textarea").wysiwym(Wysiwym.Markdown, {});
// setup live preview
var showdown = new Showdown.converter();
var prev_text = "";
var update_live_preview = function() {
var input_text = $("#post-body textarea").val();
@christopherscott
christopherscott / sourcegrep
Created September 6, 2012 14:47
Grep through document source
(function() {
// change this REGEXP to whatever you need
var PATTERN = /<title>(.*)<\/title>/g;
var message = '',
results = document.documentElement.innerHTML.match(PATTERN);
message = ((results && results.length) ? results.join('\n') : 'Not found.');
window.alert(message);
@christopherscott
christopherscott / dabblet.css
Created November 11, 2012 15:39
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(35deg, #f06, yellow);
min-height:100%;
text-shadow: 4px 4px rgba(0,0,0,0.25);
@christopherscott
christopherscott / dabblet.css
Created November 11, 2012 15:44
CScott CSS/mobile logo
/**
* CScott CSS/mobile logo
*/
html {
font-family: 'Source Sans Pro', Arial, sans-serif;
background: url('http://subtlepatterns.subtlepatterns.netdna-cdn.com/patterns/noisy_grid.png');
}
#logo {
@christopherscott
christopherscott / js-inheritance-psuedo-classical
Last active December 12, 2015 10:19
Psuedo classical inheritance in JavaScript
function Person(name) {
this.name = name;
}
Person.prototype.speak = function () {
console.log(this.name);
};
function Employee(name) {
@christopherscott
christopherscott / js-inheritance-prototypical
Created February 11, 2013 22:09
Prototypical inheritance in JavaScript
var Person = {
init: function (name) {
this.name = name;
},
speak: function () {
console.log(this.name);
}
};
var Employee = Object.create(Person);