Skip to content

Instantly share code, notes, and snippets.

View codegoalie's full-sized avatar

Chris Marshall codegoalie

View GitHub Profile
require 'benchmark'
n = 500_000
Benchmark.bm(7) do |x|
x.report('append:') do
a = ''
n.times { a << 'a' }
end
x.report('+=:') do
@codegoalie
codegoalie / all_fixed.sh
Last active December 12, 2015 07:48
Help! I lost a commit from days ago!!! post
chrismar035:super_sweet_project(master) $ git lg
* 99f0b00 - LOST COMMIT!!! (just now) <Chris Marshall>
* faa7737 - Merge branch 'features/sweet_feat' (1 day ago) <Chris Marshall>
|\
| * 3ce8e66 - Commit after the lost one (1 day ago) <Chris Marshall>
| * 9418734 - Commit before the lost one (1 day ago) <Chris Marshall>
|/
* b67ec4c - Other unrelated commit (2 days ago) <Chris Marshall>
...
<html>
<head>
<title>John Doe's web page</title>
</head>
<body>
<script type="text/javascript">
// Use a popup box here to read the user name
// and write a personalized greeting
{
var name=prompt("Please enter your name","Harry Potter");
@codegoalie
codegoalie / alter.sh
Created May 17, 2011 01:08
Shell Alert for long running commands
# I didn't write this and I'm not sure where it came from...
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
if [ -n "$PS1" ] ; then
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
require 'fileutils'
require 'rubygems'
require 'pony'
# Set absolute path for config file directory
conf_path = "/home/auto-responses"
#for each config file (autoresponder)
Dir.new(conf_path).each do |response_file|
@codegoalie
codegoalie / bingo.rb
Created February 5, 2011 23:45
Computes pseudo-random bingo cards to fill with a list of items
puts "How many players?"
players = gets.chomp.to_i
puts "How many items?"
items = gets.chomp.to_i
(1..players).each do |i|
puts "card #{i}"
card = Array.new
(1..5).each do |row|
print " "
(1..5).each do |col|
@codegoalie
codegoalie / nachos-java on Ubuntu
Created October 27, 2010 18:48
These are the steps I took to get nachos-java working on UBuntu 10.10
Setting up NACHOS in Ubuntu Linux
1) Download and Extract the nachos-java.tar.gz
2) Install sun-java6-jdk package. (sudo apt-get install sun-java6-jdk)
3) Add the nachos executable to your PATH, by adding the following lines to your ~/.profile file.
if [ -d "$HOME/nachos/bin" ] ; then
PATH="$HOME/nachos/bin:$PATH"
fi
@codegoalie
codegoalie / Firefox Entensions
Created March 16, 2010 12:32
Firefox Extensions
Foxmarks
Tree Style Tabs
Greasemonkey
Greasefire
Firebug
Enter Selects
Delicious Bookmarks
Download Statusbar
FlashBlock
@codegoalie
codegoalie / Vimrc
Created January 31, 2010 22:01
.vimrc - Vim Config Script
" Modified from An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2008 Dec 17
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc