Skip to content

Instantly share code, notes, and snippets.

View spencerdcarlson's full-sized avatar

Spencer spencerdcarlson

View GitHub Profile
@spencerdcarlson
spencerdcarlson / git-pr
Last active August 7, 2018 18:55
Shortcut to open the GitHub link to open a pull request (Mac)
#!/usr/bin/env ruby
url = `git config --get remote.origin.url`.chomp
if url.include? '@'
url = "https://#{url.sub(':','/').split('@')[1]}"
end
url.slice!('.git')
url += "/compare/#{ARGV[0]}...#{ARGV[1]}"
`open #{url}`

Keybase proof

I hereby claim:

  • I am spencerdcarlson on github.
  • I am spencerdcarlson (https://keybase.io/spencerdcarlson) on keybase.
  • I have a public key ASBtgO8xQn3bqh5xoRcEjRAKHLeh0xFfjFCUYwVrOnoA9go

To claim this, I am signing this object:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Starter Template for Bootstrap</title>
<!-- Bootstrap -->
@spencerdcarlson
spencerdcarlson / Car.java
Last active October 6, 2015 17:58
POJO example
public class Car {
private int year;
private String make;
private String model;
private double fuel;
private Boolean drivable;
public Car()
{
@spencerdcarlson
spencerdcarlson / Circle.java
Created September 26, 2012 02:58
Polymorphism
import java.awt.Graphics;
public class Circle extends Shape {
int x;
int y;
int width;
int height;
@spencerdcarlson
spencerdcarlson / SORR.rb
Created May 12, 2012 07:00
Second Order Recurrence Relations
# PROJECT: Second Order Recurrence Relations
$LOAD_PATH << '../lib'
require 'parseFile.rb'
class Sorr
def initialize(inputs)
s1 = inputs["S(1)"]; s2 = inputs["S(2)"]
c1 = inputs['C1']; c2 = inputs['C2']
r1,r2 = quadratic(c1,c2)
@spencerdcarlson
spencerdcarlson / FORR.rb
Created May 12, 2012 06:15
First order Recurrence Relations
# PROJECT: First Order Recurrence Relations
$LOAD_PATH << '../lib'
require 'parseFile.rb'
class Forr
def initialize(inputs)
$s1 = ( inputs.has_key?('S(1)') && inputs['S(1)'] )
$c = ( inputs.has_key?('C') && inputs['C'] )
$gn = ( inputs.has_key?('G(N)') && inputs['G(N)'] )
@spencerdcarlson
spencerdcarlson / Fibonacci.rb
Created April 30, 2012 08:12
Three different versions of the Fibonacci sequence
class Fibonacci
def initialize(num)
@n = num
@info = {
"Origional" => num, "Fib" => fib(@n),
"FibTwo" => fibTwo(@n), "FibFast" => fibFast(@n) }
end
def fib(x)
@spencerdcarlson
spencerdcarlson / InterpreterPath.rb
Created April 30, 2012 06:43
Ruby Interpreter Path
# Print Interpreter path
require 'rbconfig'
puts RbConfig.ruby()
# Add sum, mean, & median to Array class
class Array; def sum; inject(:+) end end
class Array; def mean; sum.to_f / size end end
class Array
def median(arry)
sorted = arry.sort
medpt = arry.length / 2
medpt1 = ( ( arry.length - 1 ).to_f / 2 )
(sorted[medpt] + sorted[medpt1]).to_f / 2
end