Skip to content

Instantly share code, notes, and snippets.

View sailors.sql
-- to start SQLite3 (worked on my Mac and on CAEN)...
-- sqlite3 sailors.db
-- to run this file in SQLite3...
-- .read this_filename.sql
drop table if exists Sailors;
create table Sailors (
sid integer primary key,
name varchar(100),
View app.js
var express = require('express');
var app = express();
app.all('*', function(req, res, next) {
var youAreAllowed = Math.random() < 0.5; // example
if (youAreAllowed)
EvanHahn /
Created Dec 4, 2013 is undefined in Connect apps
connect = require 'connect'
app = connect()
# find-replace "connect" with "express" and will be a boolean rather than undefined.
app.use (req, res) ->
res.setHeader 'Content-Type', 'text/plain'
res.end "Secure: #{}"
EvanHahn / intermediate132.rb
Last active Dec 21, 2015
Solution to Reddit's r/dailyprogrammer challenge #132.
View intermediate132.rb
'and' => {
0x00 => [:address, :address],
0x01 => [:address, :literal]
'or' => {
0x02 => [:address, :address],
0x03 => [:address, :literal]
'xor' => {
EvanHahn / miniclass.js
Created Aug 20, 2013
MiniClass, minified. 338 bytes uncompressed.
View miniclass.js
(function(){var b=function(){};b.extend=function(c){c||(c={});var d=this,b=c.initialize,e=function(){b?b.apply(this,arguments):d.apply(this,arguments)},a;for(a in d)"prototype"!=a&&(e[a]=d[a]);for(a in d.prototype)e.prototype[a]=d.prototype[a];for(a in c)e.prototype[a]=c[a];return e};module.exports?module.exports=b:this.MiniClass=b})();
EvanHahn / gist:6106033
Created Jul 29, 2013
Add this to Pocket to make the sans-serif font family consistent with the mobile apps.
View gist:6106033
#page_reader[font="sans"] .reader_content {
font-family: "ProximaNova", Helvetica, Arial, sans-serif;
EvanHahn / app.js
Last active Mar 27, 2020
Do you love anime?
View app.js
// Start Express
const express = require('express')
const app = express()
// Set the view directory to /views
app.set('views', __dirname + '/views')
// Let's use the Jade templating language
app.set('view engine', 'pug')
EvanHahn / server.js
Last active Dec 17, 2015
Express server that looks for files in /common, then figures out the useragent and goes somewhere else.
View server.js
// Load dependencies
var express = require('express');
var is = require('browseris');
var fs = require('fs');
// Build me an app!
var app = express();
app.set('port', process.env.PORT || 3000);
EvanHahn / gist:4945775
Last active Dec 13, 2015
A friend asked for help on some basic Java homework, and so here it is.
View gist:4945775

Let's first talk about booleans, which you might already know, so I apologize if this is review. If you think you understand booleans completely, skip this puppy.


A boolean is a variable type in many programming languages. It usually that something can be true or false, yes or no, on or off, 0 or 1.

I imagine booleans like lightswitches. They can either be on or off -- true or false.

Most languages have true and false, but they vary somewhat. C++ writes true and false, where Python has capitalized True and False. CoffeeScript supplements the classics and adds yes, no, on, and off. C kinda doesn't have them built-in, you have to make your own.

EvanHahn / gist:4498026
Last active Dec 10, 2015
Example page that does its best to disable copy-paste. For more: <>
View gist:4498026
<!DOCTYPE html>
<style type="text/css">
body {
-webkit-user-select: none;
-khtml-user-drag: none;
-khtml-user-select: none;
-moz-user-select: none;