Skip to content

Instantly share code, notes, and snippets.

@eng
eng / craps.rb
Created November 16, 2015 15:26
Craps!
@roll = []
@pass_line_wins = 0
@pass_line_losses = 0
def roll_finished
puts @roll.inspect
puts "Pass line wins #{@pass_line_wins}, pass line losses #{@pass_line_losses}"
@roll = []
end
@eng
eng / index.html
Last active September 29, 2016 19:16
Bootstrap Starter
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Me</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
@eng
eng / gist:10670661
Last active August 29, 2015 13:59
Ridiculously Simple Public API Consumption – Node.js Demo

Install Node.js from http://nodejs.org/

Create a folder for your project

mkdir weather
cd weather

Install require modules

@eng
eng / TSLDevOps.md
Last active August 29, 2015 13:57
Prep for The Starter League DevOp Classes and Workshops

There are just a couple of things you'll have to do in advance, in order to get your environment ready to be able to follow along. This takes about 30 minutes (of mostly waiting) so be sure to carve out some time to do this.

VirtualBox and Vagrant are two tools that we'll be using to emulate a production environment on your local machine. Install the latest version of VirtualBox from https://www.virtualbox.org/wiki/Downloads. Install Vagrant from http://www.vagrantup.com/downloads.html.

Once VirtualBox and Vagrant are installed, issue the following commands from Terminal:

vagrant box add precise32 http://files.vagrantup.com/precise32.box
#!/bin/sh
# Security
sudo adduser deploy --ingroup sudo
su deploy
cd ~
# Exit immediately upon error
set -e
set -x
@eng
eng / gist:5768334
Created June 12, 2013 19:27
Skip asset pre-compilation
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
@eng
eng / gist:2025984
Created March 13, 2012 01:15
Make a local copy of Mephisto posts
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'yaml'
require 'redcloth'
require 'rdiscount'
class Mephisto
QUERY = "SELECT id, permalink, body, published_at, title, filter \
FROM contents \
@eng
eng / gist:1627933
Created January 17, 2012 18:17
Bash prompt with git and rvm info
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo " ⚡"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ → \1$(parse_git_dirty)/"
}
rvm_current() {
if [ "$(~/.rvm/bin/rvm-prompt v g)" != "" ]; then echo " → $(~/.rvm/bin/rvm-prompt v g)"; fi
require 'rubygems'
require 'open-uri'
require 'mechanize'
require 'pp'
site_dashboard_url = 'http://www.tumblr.com/dashboard'
email = 'YOUR EMAIL'
password = 'YOUR PASSWORD'
agent = Mechanize.new
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>The Greatest Flash Message Ever</title>
<style type="text/css" media="screen">
html, body {
margin: 0;
padding: 0;