Skip to content

Instantly share code, notes, and snippets.

@weilu
weilu / null.sql
Created October 16, 2013 02:09
PostgreSQL NULL comparison
=# select (1!=1);
?column?
----------
f
(1 row)
=# select (1=1);
?column?
----------
t
@weilu
weilu / proxy.sh
Created September 12, 2013 16:04
Proxy: Have you tried turning it off and on again on Mac OS X?
# on
sudo networksetup -setsocksfirewallproxy "Wi-Fi" localhost 1080
ssh -D 1080 -i ~/.ssh/proxy.pem [remote-user]@[remote-server]
# off
sudo networksetup -setsocksfirewallproxystate "Wi-Fi" off

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);
@weilu
weilu / Cheffile
Last active December 18, 2015 09:39 — forked from neo-common/Cheffile
site 'http://community.opscode.com/api/v1'
cookbook 'sprout-osx-base',
:git => 'git://github.com/pivotal-sprout/sprout.git',
:path => 'sprout-osx-base'
cookbook 'pivotal_workstation',
:git => 'git://github.com/pivotal-sprout/sprout.git',
:path => 'pivotal_workstation'
import java.util.*;
class Programmer {
private String name;
private int age;
private List<String> languages;
public Programmer(String name) {
this.name = name;
this.languages = new ArrayList<String>();

Definitely

  • Have professors help with the publicity
  • Keep workshop interactive
  • More variety of drinks
  • Spend more time on Koans
  • Provide vegan options for lunch
  • Introduce handy standarded lib functions
  • Bring Neo banner along
  • Make sure venue has pairing-friendly tables
@weilu
weilu / spec_helper.rb
Created November 10, 2012 08:12
Configure database_cleaner for a test suite that contains Capybara js specs.
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
end
config.before(:each) do
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation
@weilu
weilu / edit_post_spec.rb
Created November 5, 2012 13:03
Turn off transactional fixtures only for Capybara javascript specs
# requests/edit_post_spec.rb
require 'spec_helper'
feature 'editing a post', js: true do
let(:post) { create :post }
let(:user) { post.creator }
before { sign_in user }