Skip to content

Instantly share code, notes, and snippets.

View andrewle's full-sized avatar

Andrew Le andrewle

View GitHub Profile
{
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"strict": true,
"noUnusedLocals": true,
"strict": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"use strict";
class Board {
constructor() {
this.width = 10;
this.height = 12;
this.grid = this._initializeToZeros();
this.grid[2][1] = 1;
}
@andrewle
andrewle / test.rb
Created October 17, 2016 16:25
Print deprecation notices to stderr after all tests have run
# I've always disliked the way deprecation notices would appear while the test
# suite is running: they break up the neat little rows of dots (or F's, as it
# may be) which causes noise and makes the notices hard to read and understand.
#
# Adding this snippet to `config/environments/test.rb` will buffer all your
# deprecation notices until the end of the test run and keep your test output
# nice and tidy.
#
Rails.application.config do
# ...
@andrewle
andrewle / a.rb
Created May 30, 2014 17:13 — forked from ahoward/a.rb
#! /usr/bin/env ruby
# this script can create a static build from virtually any rails' project. it
# has two simple requirements.
#
# 1) you have
#
# gem 'passenger'
#
# in your Gemfile
#!/bin/bash
function gitroot {
if [ "$(pwd)" != "$(git rev-parse --show-toplevel)" ]; then
go-to-git-root
elif [ $(cd .. && git rev-parse --is-inside-work-tree &> /dev/null; echo $?) -eq 0 ]; then
cd .. && go-to-git-root
fi
}
# MIT License:
#
# Copyright (C) 2012 Heroku, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
@andrewle
andrewle / custom_plan.rb
Created March 22, 2013 17:22
Zeus fix for to_json error
require 'zeus/rails'
class Fixnum
def to_json(options = nil)
to_s
end
end
class CustomPlan < Zeus::Rails
def test
@andrewle
andrewle / clever-rails.rb
Created September 20, 2012 10:04
A Rails app generator tuned my common needs
#!/usr/bin/env ruby
require 'rails/generators'
require 'rails/generators/rails/app/app_generator'
require "active_support/core_ext/string/strip"
class CleverAppGenerator < Rails::Generators::AppGenerator
class_option :skip_bundle, default: true
class_option :database, default: "postgresql"
class_option :skip_test_unit, default: true, hide: true
@andrewle
andrewle / chef-bootstrap.sh
Created July 30, 2012 00:47
Bootstrap chef on a bare Debian/Ubuntu Server
#!/bin/bash
# Bootstrap chef-solo on a server
# Install Ruby
sudo apt-get install ruby ruby-dev libopenssl-ruby rdoc ri irb build-essential wget ssl-cert curl
# Install RubyGems instead of using the system version
cd /tmp
curl -O http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
tar zxf rubygems-1.8.10.tgz
SALE RECEIPT
Store #11476 eat 01/07/10 16:01:48
Subway Sandwiches & Salads
609 N MILPAS ST
MILPAS CA 93103
805-966-3001
Trans# 137 Clerk 3 RAJVINDERPAL
Dwr1 TRDT 010710 Reg-ID REG-MAIN
Receipt # 0000103913
--- ITEM --- QTY PRICE MEMO PLU