Skip to content

Instantly share code, notes, and snippets.

😅
Lucky to be here

Steve Grossi stevegrossi

😅
Lucky to be here
Block or report user

Report or block stevegrossi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stevegrossi
stevegrossi / command_parsing.ex
Created Feb 8, 2018
Elixir command parsing
View command_parsing.ex
# I've been wondering about a pattern-matching-driven approach to what we've been talking about, e.g.
def parse_command(input) do
input
|> String.strip
|> match_command
end
def match_command("north"), do: {Player, :move, [:north, player, world]}
def match_command("east"), do: {Player, :move, [:east, player, world]}
@stevegrossi
stevegrossi / string_to_integer_bench.exs
Last active Jul 21, 2017
Elixir parsing stringy integers: rescue vs. regex
View string_to_integer_bench.exs
defmodule StringToIntegerBench do
use Benchfella
@word "string"
@integer "1234"
bench "regex for word" do
if numeric_string?(@word) do
@word |> String.to_integer
else
View gist:a8a90f5db83c8a00e06e527da996ace2
Name,Email,Role,Group: Test Group 1,Group: Test Group 2,Group: Test Group 3,Custom: Test Custom Field
Test User 1,testuser1@lesson.ly,learner,yes,yes,yes,oranges
Test User 2,testuser2@lesson.ly,learner,yes,yes,yes,oranges
Test User 3,testuser3@lesson.ly,learner,yes,yes,yes,oranges
Test User 4,testuser4@lesson.ly,learner,yes,yes,yes,oranges
Test User 5,testuser5@lesson.ly,learner,yes,yes,yes,oranges
Test User 6,testuser6@lesson.ly,learner,yes,yes,yes,oranges
Test User 7,testuser7@lesson.ly,learner,yes,yes,yes,oranges
Test User 8,testuser8@lesson.ly,learner,yes,yes,yes,oranges
Test User 9,testuser9@lesson.ly,learner,yes,yes,yes,oranges
@stevegrossi
stevegrossi / jmeter.rb
Last active Mar 19, 2018
Sample JMeter test plan using the ruby-jmeter gem
View jmeter.rb
#!/usr/bin/env ruby
require 'ruby-jmeter'
test do
defaults domain: 'beta.stevegrossi.com'
cookies clear_each_iteration: true
@stevegrossi
stevegrossi / post-commit
Created Jan 10, 2014
When using git on a mac, this hook will speak your commit messages in a robot voice each time you commit. Just save this file within a git repository at .git/hooks/post-commit
View post-commit
#!/bin/bash
MESSAGE=$(git log -1 HEAD --pretty=format:%s)
say -v "Zarvox" "$MESSAGE"
@stevegrossi
stevegrossi / image.rb
Created Dec 21, 2013
How to rename a Paperclip attachment when an interpolated attribute in the Filename changes
View image.rb
class Image < ActiveRecord::Base
attr_accessible :custom_file_name
has_attached_file :attachment
after_save :rename_attached_file, if: :rename_necessary?
def rename_attached_file
(attachment.styles.keys).each do |style|
You can’t perform that action at this time.