Skip to content

Instantly share code, notes, and snippets.

View justgage's full-sized avatar

Gage Peterson justgage

View GitHub Profile
@justgage
justgage / README.md
Last active August 29, 2015 14:23
Clojure solution to hackerrank anagram challenge
[debug] Processing by Vanpool.PageController.index/2
Parameters: %{"format" => "html"}
Pipelines: [:browser]
[debug] SELECT v0."id", v0."number", v0."capacity", v0."come_time", v0."go_time", v0."description", v0."inserted_at", v0."updated_at" FROM "vans" AS v0 [] OK query=0.6ms
[debug] SELECT r0."id", r0."dir", r0."userid", r0."vanid", r0."date", r0."keys", r0."inserted_at", r0."updated_at" FROM "riding" AS r0 WHERE (r0."userid" = $1) ["U051NJ6S6"] OK query=0.4ms
[info] Sent 500 in 23ms
[error] #PID<0.1837.0> running Vanpool.Endpoint terminated
Server: vanpool.dev:4000 (http)
Request: GET /
** (exit) an exception was raised:
def index(conn, _params) do
user = Plug.Conn.get_session(conn, :current_user)
token = Plug.Conn.get_session(conn, :access_token)
vans = Repo.all(Van)
# how to get today :P
{date, _} = :calendar.local_time
date = Ecto.Date.from_erl date
render(conn, "index.html", user: user, vans: vans, token: token, date: date)
end
@justgage
justgage / rock_paper_sinners.rs
Created October 29, 2015 23:38
An implementation of rock, paper, scissors that mostly cheats. (part 1)
use std::io;
use std::io::Write;
fn prompt() -> String {
let input = io::stdin();
println!("Welcome to Rock, Paper, and Sinners!");
@justgage
justgage / git-instructions.md
Last active January 2, 2016 21:59
How to use Git on BYU-I's servers

step 1: do the normal setup with git adding a SSH key to git NOTE: the ssh test they have will FAIL! This is ok.

step 2: make a repo (or use one you already have)

step 3: go to the repo and find the clone link FOR HTTPS.

step 4: add this to your ~/.bashrc (use emacs or vim to edit that file, add it if it doesn't exist) -> unset SSH_ASKPASS

step 5: Edit the link adding username@ to the in front of the github.com

package main.scala
object HelloWorld {
def hello(name: String = "World") = "Hello, " + name;
// sudo tests
def main(args: Array[String]):Unit = {
println(hello())
println(hello("Gage"))
}
...
type: 7
player
Score: 0
numLives: 3
about to reset state
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffef95f700 (LWP 26178)]
0x0000000000403aad in std::__cxx11::list<GameObject*, std::allocator<GameObject*> >::begin (this=0x0)
@justgage
justgage / gage-lab00.cpp
Created April 20, 2016 01:54
A program to prove that I can C++
/***********************************************************************
* Program:
* Lab 00, Practice Lab Submission
* Brother Jones, CS345
* Author:
* Gage Peterson
* Summary:
* This is the first lab. It will count the number of lines the user
* enters that begin a capital letter
************************************************************************/
@justgage
justgage / myShell.cpp
Created May 17, 2016 06:36
A simple Linux shell
/***********************************************************************
* Program:
* Lab UnixShell
* Brother Jones, CS 345
* Author:
* Gage Peterson
* Summary:
* This is a tiny unix shell made for my operating systems class
************************************************************************/
@justgage
justgage / ResultValue.rb
Created January 16, 2017 20:25
A simple result monad in ruby
# This class helps to captue possible errors as a value. While you could capture these conditions as
# `nil` it's easy to forget to check for it everywhere.
#
# ResultValue helps with this by making the only way to get at the value is with #case_of.
class ResultValue
# This will rescue any exceptions and return it as an "errored" ResultValue
# if there was none it will return it as an "ok" ResultValue with the value
# wrapped inside
def self.capture_result