Skip to content

Instantly share code, notes, and snippets.

@andrewdavidcostello
andrewdavidcostello / server.js
Created August 1, 2017 10:36
Express Hello World
var express = require('express'),
app = express(),
port = process.env.PORT || 3000;
var listener = app.listen(port, () => {
console.info("==> ✅ Server is listening");
console.info("==> 🌎 Go to localhost:%s", port);
});
app.route('/')
@andrewdavidcostello
andrewdavidcostello / tools.md
Last active September 22, 2016 15:44
JS Tools
@andrewdavidcostello
andrewdavidcostello / gist:38c0458a319a9dddb066
Created August 7, 2014 19:45
codebase-capistrano-3-task
namespace :codebase do
desc "Logs the deployment of your Codebase 4 repository"
task :log_deployment do
previous_revision = fetch :previous_revision
current_revision = fetch :current_revision
if previous_revision == current_revision
puts "\e[31m The old revision & new revision are the same - you didn't deploy anything new. Skipping logging.\e[0m"
next
@andrewdavidcostello
andrewdavidcostello / monthly_intervals.php
Created October 16, 2012 10:36
PHP Calculate Monthly Intervals
<?php
$start_at = '2012-11-15';
$end_at = strtotime('2012-11-15');
$final_date = strtotime('2013-01-22');
$dates = array();
# Calculate intervals.
while($end_at < $final_date){
@andrewdavidcostello
andrewdavidcostello / cartesian.rb
Created March 17, 2012 21:25
SaaS-Class: Homework 2
class CartesianProduct
include Enumerable
def initialize(a,b)
@values = []
@values = a.product(b) unless b.empty?
end
def each(&block)
@values.each {|v| yield v}
@andrewdavidcostello
andrewdavidcostello / advanced_oop.rb
Created March 7, 2012 21:03
SaaS-Class: Homework 1
class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s # make sure it's a string
attr_reader attr_name # create the attribute's getter
attr_reader attr_name + "_history" #create history getter
class_eval %{
def #{attr_name}=(val)
@#{attr_name} = val
@#{attr_name}_history = [nil] if @#{attr_name}_history.nil?