Skip to content

Instantly share code, notes, and snippets.

View CGA1123's full-sized avatar
🛰️

Christian Gregg CGA1123

🛰️
View GitHub Profile
@CGA1123
CGA1123 / bubbleSort.sml
Created December 1, 2015 18:34
Bubble Sort implementation in smlnj
(* General function that checks if an int list is sorted *)
fun issorted [] = true |
issorted [x] = true |
issorted (x::y::t) = x <= y andalso issorted(y::t);
(* Function that does the bubbling *)
fun bubble [] = [] |
bubble [x] = [x] |
bubble (x::y::t) = if (x > y) then y::(bubble (x::t))
else x::(bubble (y::t));
@CGA1123
CGA1123 / 100doors.sml
Created December 15, 2015 21:20
100 Doors Problem in SML
(* 100 doors *)
fun listOf 0 _ = []
| listOf n e = e::(listOf (n-1) e);
fun invert x = not x;
fun flip _ _ [] = []
| flip 0 _ _ = []
| flip s n (h::t) = if (s=n) then (invert h)::(flip s 1 t) else h::(flip s (n+1) t);
@CGA1123
CGA1123 / catalan.sml
Last active December 15, 2015 21:43
Catalan Numbers in SML
(* Catalan Numbers *)
open LargeInt;
fun fact 0 = 1
| fact n = n * (fact (n-1));
fun catalan n = let val factofn = fact n
in (fact (2 * n)) div (((n+1) * factofn) * (factofn)) end;
fun firstn f 0 = [f 0]
| firstn f n = (f n)::(firstn f (n-1));
@CGA1123
CGA1123 / dbms.sql
Last active March 3, 2016 19:29
database setup for F28DM CW1
-- Creates table for holding customer information
CREATE TABLE DBCustomer (
customerId INT PRIMARY KEY,
mainAddress VARCHAR(100) NOT NULL,
postCode VARCHAR(10) NOT NULL,
phoneNumber VARCHAR(15) NOT NULL,
email VARCHAR(50) NOT NULL
) ENGINE=INNODB;
-- Customer Mandatory Or with Consumer or Business
<?xml version="1.0" encoding="UTF-8"?>
<deliveries>
<customers>
<customer id="1">
<mainAddress>238 Aliquam Rd</mainAddress>
<postCode>K6L 8XT</postCode>
<phoneNumber>07096527084</phoneNumber>
<email>[email protected]</email>
</customer>
<customer id="2">
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="deliveries">
<xs:complexType>
<xs:sequence>
<xs:element name="customers">
<xs:complexType>
<xs:sequence>
<xs:element name="customer" maxOccurs="unbounded">

Le Setup

zsh

  • oh-my-zsh - theme: agnoster

vim

  • vim-sensible
  • vim-bufferline
  • vim-airline
  • vim-airline-themes
  • nerdtree
Prefix Verb URI Pattern Controller#Action
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET

Keybase proof

I hereby claim:

  • I am CGA1123 on github.
  • I am cga1123 (https://keybase.io/cga1123) on keybase.
  • I have a public key whose fingerprint is 16B0 A27D BA2F 9F35 D8C6 B32B 59A9 F8CA 7DBA BDF0

To claim this, I am signing this object:

@CGA1123
CGA1123 / bin_test_script.rb
Created December 28, 2016 18:06
Simple Rails Test Script, Resets Database, Runs RSpec, & Rubocop
#!/usr/bin/env ruby
require 'pathname'
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
test_env = 'test'
puts "Application Environment: #{test_env}"