Skip to content

Instantly share code, notes, and snippets.

View benmccormick's full-sized avatar

Ben McCormick benmccormick

View GitHub Profile
@benmccormick
benmccormick / palindrome.coffee
Created April 14, 2013 17:40
Submission for Problem C of google code jam Qualification Round 2013 https://code.google.com/codejam/contest/2270488/dashboard#s=p2
fs = require('fs')
writevalue = (i, val)->
output += "Case #"+i+": "+val+"\n"
# is a palindrome (expects a string)
isPalindrome = (num) ->
reversed = (num).split("").reverse().join("")
num is reversed
@benmccormick
benmccormick / Palindrome.java
Created April 14, 2013 22:39
A java equivalent of my coffeescript solution for the Google Code Jam qualification problem
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Palindrome {
public static void main(String[] args) throws Exception
@benmccormick
benmccormick / knockout-revertible.js
Last active December 17, 2015 02:38
Revertible Observable
/* Small Knockout Extension to allow for canceling/confirming
* changes to the view model. Defaults to the changed option. Based on code sample from Ryan Niemeier
* http://www.knockmeout.net/2011/03/guard-your-model-accept-or-cancel-edits.html
*
* Please note: You should not use this unless you are
* explicitly confirming or resetting the values in every scenario before you
* reference them again. An unwanted revert may occur if you make changes without confirming and then cancel at a later point.
*/
//wrapper to an observable that requires accept/cancel
@benmccormick
benmccormick / knockout-protected.js
Last active December 17, 2015 02:38
Protected Observables by Ryan Niemeyer
/* Small Knockout Extension to allow for canceling/confirming
* changes to the view model Originally from:
* http://www.knockmeout.net/2011/03/guard-your-model-accept-or-cancel-edits.html
*/
//wrapper to an observable that requires accept/cancel
ko.protectedObservable = function(initialValue) {
//private variables
var _actualValue = ko.observable(initialValue),
_tempValue = initialValue;
@benmccormick
benmccormick / timsetup.sh
Last active December 17, 2015 18:09
A quick script to get tim setup on mint
#!/bin/bash
# This is a script to set up a Linux Mint environment for Tim's development this summer. It is by no means complete, but is just meant to get started with some of the basics for java development and the courage project.
#set your username here
USER=ben
#update available packages
apt-get update
#installing postgres
apt-get -y install postgresql
@benmccormick
benmccormick / minimal.vim
Last active February 26, 2022 17:09
A minimal vimrc for new vim users
" A minimal vimrc for new vim users to start with.
"
" Referenced here: http://vimuniversity.com/samples/your-first-vimrc-should-be-nearly-empty
"
" Original Author: Bram Moolenaar <Bram@vim.org>
" Made more minimal by: Ben Orenstein
" Modified by : Ben McCormick
" Last change: 2014 June 8
"
" To use it, copy it to
@benmccormick
benmccormick / software_inventory2012
Created June 10, 2014 03:32
Software Inventory
## Explanation
This was my end of 2012 software inventory. The goal was to identify all of the things I use software for, evaluate what the best software was to use for those use cases, and then commit to using that software for all of 2013. The goals were simplicity, productivity, and a more focused approach to the tools I use.
## Use Cases & Solutions
#### Web Browsing in Windows
* **Chrome** - I don't love Google's business model. And their designs are hit and miss. But they really do make some great software. In my experience Chrome is the best browser to debug with, the fastest, and handles multiple tabs & searching the best.
@benmccormick
benmccormick / .vimrc
Created July 14, 2014 02:33
vimrc Boilerplate
"<Your Name Here>
" Setup stuff
" ===========
" Use vim rather than vi settings
set nocompatible
" Plugins Setup
@benmccormick
benmccormick / contestpicker.py
Created July 27, 2014 17:26
Random Method of selecting 2 contestants from a list
import random
# Implementation of Resevoir Algorithm, see
# http://stackoverflow.com/a/3540315/1424361
def random_line(contestants):
line = next(contestants)
line2 = line
# go through each line, check to see if we
# should select it, with decreasing probability
# over time
@benmccormick
benmccormick / .jshintrc
Created October 13, 2014 02:46
My jsHint Configuration
{
"bitwise":true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef":true,
"newcap": true,
"nonew":true,
"quotmark":"single",