Skip to content

Instantly share code, notes, and snippets.

@squarism
squarism / hi_spec.rb
Last active August 29, 2015 14:14
Hi spec
# I know what you are saying about the composition.
# I know that this simple example doesn't represent the
# composability that you probably trying to do.
# But this is how I would do what you want.
# You already know all this so I'm wasting your time actually.
# =>
# hi!
# hi!
# hello!
@squarism
squarism / lunch_spec.rb
Last active August 29, 2015 14:14
Lunch Spec
# RSpec really does have an identity crisis. It's not quite ruby and it's
# not quite English. But what if we really made our tests complicated
# with shared_examples that behave like mixins sorta? How bad would this be?
# rspec --format doc lunch_spec.rb
shared_examples "charge" do
let(:cash_register) { "ding!" }
it "charges a price" do
@squarism
squarism / hi_guy.txt
Created April 8, 2015 20:40
Sometimes Things Have Their Own Purpose
Guy at coffee shop. I'm playing with my adafruit goggles, trying to make a part list.
Guy: What's that.
Me: LED Goggles.
Guy: Do they let you see in 3D.
Me: No.
Guy: Do they let you ride your bike at night?
Me: They aren't that bright.
Guy: Do they let you read better.
Me: Actually they sort of blind you.
@squarism
squarism / docker_cheet_sheet.md
Last active August 29, 2015 14:19
Docker Cheat Sheet (wip)

Remove old containers.

docker ps -a | grep 'weeks ago' | awk '{print $1}' | \

xargs --no-run-if-empty docker rm

@squarism
squarism / whitespace.rb
Created June 17, 2015 18:33
Stripping leading whitespace in ruby heredocs
# <<foo doesn't trim leading whitespace. No problem. :cake:
<<EOS
hi
EOS
=> " hi\n"
# I thought the difference between << and <<- was the leading whitespace trimming.
<<-EOS
hi
EOS
@squarism
squarism / postgres.md
Created June 26, 2015 04:35
postgres is pretty sweet

Postgres is pretty awesome

blog post draft

Basics

Get up and running. Install it. I'm sure you know how. But then maybe you are used to mysql>? Where is the database? How do I even start?

  1. sudo -u postgres -i - This is your system account that pg runs as. Switch to it and we'll create a sandbox database.
  2. createuser name - Where "name" is your normal user account you use.
  3. createdb name -O name - Where "name" is your normal user account you use.
@squarism
squarism / boolfail.py
Last active September 21, 2015 23:15 — forked from tlehman/boolfail.py
Redefine true and false in python
# Python boolean fail
# Or how to redefine True and False and win any argument on the internet!
# Love, @tlehman
from unittest import TestCase
class BoolFail(TestCase):
def test_false(self):
True = False
assert True == False
@squarism
squarism / watchr.rb
Created February 3, 2011 03:28
Watchr config file for ruby programs with growl
# run me with watchr watchr.rb in a ruby project
# don't run me in a rails project. :)
# run me with test unit.
# don't run me with rspec or cucumber, check out my other watchr gists
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
@squarism
squarism / watchr_rspec.rb
Created February 3, 2011 03:58
A watchr.rb file for use with rspec for continuous ruby (not rails) testing.
# this is a watchr script for command line programs
# not rails. @squarism
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
passed = message.include?('0 failures')
@squarism
squarism / wtchr
Created February 10, 2011 20:18
A watchr one-liner shell script, perfect for single .rb projects
#!/usr/bin/env bash
# wtchr shell script - @squarism
# INSTALL
# gem install watchr
# cp wtchr ~/bin
# chmod u+x ~/bin/wtchr
# Run with: wtchr foo.rb