Skip to content

Instantly share code, notes, and snippets.

View bobfirestone's full-sized avatar
⛷️
Would rather be skiing

Bob Firestone bobfirestone

⛷️
Would rather be skiing
View GitHub Profile
@bobfirestone
bobfirestone / trump_sort.rb
Last active October 29, 2017 17:15
Ruby implementation of Trump Sort
class TrumpSort
def initialize(arr)
@arr = arr
@wall = nil
@sorted = []
end
def sort
@arr.each {|n| looper(n)}
@sorted
@bobfirestone
bobfirestone / trump_sort.exs
Created July 13, 2017 17:11
Elixir implementation of Trump Sort
defmodule TrumpSort do
def sort([h|tail]) do
[ h | sort(tail,h) ]
end
def sort([], _wall) do
[]
end
def sort([h|tail], wall) when h > wall do
@bobfirestone
bobfirestone / two_15.erl
Created March 22, 2017 20:50
Palindrome problem for week 2 section 15 of FUNCTIONAL PROGRAMMING IN ERLANG THE UNIVERSITY OF KENT
-module(two_15).
-export([palindrome/1]).
palindrome(String)->
Fs = formattedString(String),
Fs == lists:reverse(Fs).
formattedString(String) ->
% remove all spaces & non-word chars
re:replace(string:to_lower(String), "\\s+|\\W", "", [global,{return,list}]).
@bobfirestone
bobfirestone / two_nine.erl
Created March 20, 2017 21:35
My code for week 2 section 9 of FUNCTIONAL PROGRAMMING IN ERLANG THE UNIVERSITY OF KENT
-module (two_nine).
-export ([double/1,evens/1,median/1,modes/1]).
double([H]) -> [H * 2];
double([H|T]) ->
[H * 2 | double(T)].
evens([H]) when 0 == H rem(2) -> [H];
evens([H|T]) ->
@bobfirestone
bobfirestone / bits.erl
Created March 17, 2017 15:24
Part 2 of my submission for the shapes portion of the 1st assignment of FUNCTIONAL PROGRAMMING IN ERLANG THE UNIVERSITY OF KENT
-module(bits).
-export([bits/1,tests/0]).
bits(N) when N >= 0 ->
% convert N into a base 2 list then back into a base 10 number
bits(list_to_integer(integer_to_list(N,2)),0).
bits(0, Acc) -> Acc;
bits(N,Acc) ->
@bobfirestone
bobfirestone / shapes.erl
Last active March 17, 2017 15:25
Part 1 of my submission for the shapes portion of the 1st assignment of FUNCTIONAL PROGRAMMING IN ERLANG THE UNIVERSITY OF KENT
-module(shapes).
-export([area/1, enclose/1, perimeter/1, tests/0]).
% The area, enclose , and perimeter functions each take a tuple
% formatted {shape, {dimensions}}. The functions pattern match
% against the shape atom and use the dimensions to do the calculations.
% At the bottom of the file there is a test/0 function that
% calls functions to test the math of the various calculations
@bobfirestone
bobfirestone / basic-react-component-demo.html
Created March 2, 2017 17:43
This is the html file used to create the examples & code snippets for my presentation on building react.js components to the DTC web & mobile developer group. Presentation given 3/1/17
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Pure React Example</title>
</head>
<body>
<div id="react-container">
<!-- This is the div react is binding to -->
</div>

Presentation Topic Ideas For DTC Ruby Group

  1. ReactRails
  2. Deep dive into the rails asset pipeline (sprockets & asset compilation)
  3. Setting up your environment (RVM/RBENV, various installer tools)
  4. What are design patterns
  5. Draper & the decorator pattern
  6. Data structures
  7. Blocks & how yield works
  8. Efficient ruby. writing ruby that runs faster
@bobfirestone
bobfirestone / elixir.md
Last active October 4, 2015 05:23
My elixir notes

What is elixir

  • functional programming language
  • data is imutable
  • key philosophy is everything runs around data transformations not mutating and managing state
    • pass returned value from function to function never changing the value of the original input
  • funcitons should take an input & always return the same value like a math formula
  • uses pattern matching for function calling
    • used to assign variables in the function
    • multiple function declerations and determines what version shold get called based on the params matching
@bobfirestone
bobfirestone / vim.md
Last active September 24, 2015 18:51
My VIM notes

Why am I learning to use vim?

  • I am tired of buying text editor licenses & having the new version never come out
  • Vim is installed on every *nix computer
  • Vim is free

normal mode

*the repeater all commands can be prepended with a number of times to do the command

  • h = left 1 char