Skip to content

Instantly share code, notes, and snippets.

View laktek's full-sized avatar

Lakshan Perera laktek

View GitHub Profile
@laktek
laktek / server.js
Last active June 21, 2017 15:06 — forked from zellwk/server.js
const express = require('express')
const bodyParser = require('body-parser')
const expressValidator = require('express-validator')
const routes = require('./routes')
const middlewares = require('./middlewares')
const errorHandlers = require('./middlewares/errorHandlers')
const isProduction = process.env.NODE_ENV === 'production'
const passport = require('passport')
const mongoose = require('mongoose')
var generate_tag_helpers_with_basepath = function(basePath) {
return {
relative_path: function() {
var pathDepth = basePath.split('/').length -2;
var path = new Array(pathDepth + 1).join('../');
return path;
}
}
};
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
exit!
@laktek
laktek / httpdump
Created April 4, 2009 01:53 — forked from peterc/httpdump
# Monitor HTTP requests being made from your machine with a one-liner..
# Replace "en1" below with your network interface's name (usually en0 or en1)
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile:
# (again replace "en1" with correct network interface name)
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*""
# All the above tested only on OS X.
#!/bin/bash
# domainavailable
# Fast, domain name checker to use from the shell
# Use globs for real fun:
# domainavailable blah{1..3}.{com,net,org,co.uk}
# Inspired by foca / giles:
# http://gilesbowkett.blogspot.com/2009/02/simple-bash-domain-availability.html
trap 'exit 1' INT TERM EXIT
@laktek
laktek / snapshots.rb
Created January 8, 2009 18:39 — forked from nicksieger/snapshots.rb
script to create backup images
#!/usr/bin/ruby
class Integer
def days; hours * 24; end
def hours; minutes * 60; end
def minutes; seconds * 60; end
def seconds; self; end
end
def snapshot(name)