Skip to content

Instantly share code, notes, and snippets.

@justinleveck
justinleveck / gist:5660915
Created May 28, 2013 06:52
Project Euler - Problem 16
#215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
#What is the sum of the digits of the number 21000?
def exp(base, power)
return base**power
end
def sum_digits(digits)
sum = 0
@justinleveck
justinleveck / database.yml
Last active December 18, 2015 02:19
PG::Error: ERROR: encoding UTF8 does not match locale en_US
development:
adapter: postgresql
database: x_development
username: vagrant
pool: 5
encoding: utf8
template: template0
test:
@justinleveck
justinleveck / Ruby.tmLanguage
Last active December 18, 2015 03:28
Sublime Text 2: Ruby Syntax Customization - Added support for Rails helper methods (e.g. div_for) from rails.vim - Customized Solarized(light) theme for ST2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>
TODO: unresolved issues
text:
"p &lt;&lt; end
@justinleveck
justinleveck / gist:5737619
Last active December 18, 2015 06:09
Install Java JDK 7 on Ubuntu

###Install Java JDK 7 on Ubuntu

This package provides Oracle Java JDK 7 (which includes JRE, the Java browser plugin and JavaFX). However, you can’t only install Oracle JRE – the PPA only provides the full Oracle JDK7 package.

  1. To add our PPA and install the latest Oracle Java (JDK) 7 in Ubuntu, use the commands below:

sudo add-apt-repository ppa:webupd8team/java sudo apt-get update && sudo apt-get install oracle-jdk7-installer

  1. After the installation you have enable the jdk:
#models / concerns / create_shout.rb
module Concerns
module CreateShout
extend ActiveSupport::Concern
def create
content = build_content
shout = current_user.shouts.build(content: content)
shout.save
class DNA
attr_reader :strand
def initialize(strand)
@strand = strand
end
def hamming_distance(homologous_strand)
nucleic_acid_indexes(homologous_strand).each_with_object(0) do |nucleic_acid_index, differences_count|
if nucleic_acids_differ?(nucleic_acid_index, homologous_strand)
#!/bin/bash
#
# Install Postgres 9.2 on a clean Ubuntu 12.04
"""
LC_ALL issue
comment out the AcceptEnv LANG LC_* line in the remote /etc/ssh/sshd_config file.
sudo apt-get install language-pack-en-base
sudo dpkg-reconfigure locales
comment out the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file.
#!/bin/bash
#
# This script needs "fpm". If you dont have it,
# run "gem install fpm"
#
# You also need to "apt-get install python-setuptools" (otherwise fpm fails)
echo "[ build and install vim from source ]"
@justinleveck
justinleveck / install.sh
Last active December 21, 2015 10:19
Install PhantomJS 1.9 on Ubuntu VM run: bash -c "$(curl -fsSL https://raw.github.com/gist/6291000)"
cd ~/
wget http://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
mv ~/phantomjs-1.9.0-linux-x86_64.tar.bz2 /usr/local/share
cd /usr/local/share
sudo tar xvf phantomjs-1.9.0-linux-x86_64.tar.bz2
@justinleveck
justinleveck / gist:8549103
Last active January 4, 2016 01:29
Stash - Branch Input

Stash - Branch input box

This will hide the branch span tag and insert an input box with the git checkout branch command to allow for easy cutting & pasting

Usage

Tripple click input to copy git co branch command Double click over branch name to copy only branch name

  1. Install Chrome extension