Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am nwshane on github.
  • I am nathanwshane (https://keybase.io/nathanwshane) on keybase.
  • I have a public key ASDHTFy5Jh8pbupnpnjpVOnmyDDAuuBsGZDQKBifFWPGTgo

To claim this, I am signing this object:

@nwshane
nwshane / elixir_fizz_buzz.exs
Created November 27, 2017 17:29
FizzBuzz in the Elixir language
# Tested with Elixir 1.5.2
defmodule FizzBuzz do
defp fizzbuzzify(n) do
cond do
rem(n, 15) == 0 -> "FizzBuzz"
rem(n, 5) == 0 -> "Buzz"
rem(n, 3) == 0 -> "Fizz"
true -> n
end
@nwshane
nwshane / index.js
Last active July 3, 2017 15:38
Tic Tac Toe in the Terminal
// Tested with node v8.1.1
const readline = require('readline')
const defaultState = {
players: {
1: {
isComputer: true
},
2: {
isComputer: true
Rails.application.routes.draw do
scope ':locale', locale: /#{I18n.available_locales.join("|")}/ do
resources :articles do
collection do
get 'custom_json', constraints: { format: :json }, defaults: { format: :json }
end
end
get "*path", to: redirect("/#{I18n.default_locale}") # handles /en/fake/path/whatever
end
<%- model_class = Article -%>
<% page_title "#{model_class.model_name.human.pluralize.titleize}" %>
<p><%= link_to "#{model_class.model_name.human.pluralize.titleize} CSV Download", articles_path(format: :csv) %></p>
<table class="table table-striped">
<thead>
<tr>
<th><%= model_class.human_attribute_name(:id) %></th>
<th><%= model_class.human_attribute_name(:number) %></th>
<th><%= model_class.human_attribute_name(:criminal_code_id) %></th>
<th><%= model_class.human_attribute_name(:created_at) %></th>
@nwshane
nwshane / gist:91cc68b00096e06c453f
Created February 19, 2015 10:01
Gemfile.lock with rack-test version 0.6.3
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.1.6)
actionpack (= 4.1.6)
actionview (= 4.1.6)
mail (~> 2.5, >= 2.5.4)
actionpack (4.1.6)
actionview (= 4.1.6)
activesupport (= 4.1.6)