Skip to content

Instantly share code, notes, and snippets.

View adsteel's full-sized avatar

Adam Steel adsteel

View GitHub Profile
@adsteel
adsteel / git_zsh_profile_helpers.zsh
Created May 19, 2023 15:54
Git ZSH profile helpers
alias gm="git commit -m "
alias grim="git rebase -i main"
alias gcom="git checkout main"
alias gam="git commit --amend"
alias grc="git rebase --continue"
alias gra="git rebase --abort"
alias gsoft!="git reset --soft HEAD^"
alias gcp="git cherry-pick"
alias gcpc="git cherry-pick --continue"
alias gcpa="git cherry-pick --abort"
@adsteel
adsteel / search_for_the_perfect_service.rb
Last active August 17, 2022 16:12
Search for the Perfect Service Object
# PROBLEM
# Service objects are almost always just functions defined as classes. They should not be initialized, as they are not
# used to manage internal state. They accept parameters and return values. In Ruby, this creates a lot of boilerplate.
# How can we trim that down? Here are some explorations.
require 'pry'
require 'securerandom'
# A simple factory for uniform service object definition
def StructServiceBase(*args, keyword_init: false)
@adsteel
adsteel / bst.ex
Created July 28, 2017 21:44
Elixir Binary Search Tree
defmodule BSTNode do
@null "NULL"
defstruct [:value, :left, :right]
def new(value, left \\ BSTNode.empty, right \\ BSTNode.empty) do
%{value: value, left: left, right: right}
end
def empty do
@adsteel
adsteel / ruby_from_scratch.md
Last active April 29, 2016 20:46
Build Ruby from Scratch on OSX

Build ruby from scratch on OSX

  1. Download ruby from github.

  2. Run configure ($ ./configure) per the readme, but with flags:

    a) point the destination to your desired file (--prefix=/Users/asteel/.rvm/rubies/ruby-2.4.0)

    b) if you're on OSX with brew installed openssl, (--with-openssl-dir="$(brew --prefix openssl)"

@adsteel
adsteel / testing_rails_on_a_device.md
Last active February 9, 2016 18:48
Testing Local Rails App on a Device

Connect your device to localhost

1. listen on all interfaces

$ rails s --binding=0.0.0.0 or rails s -b 0.0.0.0

2. Ensure firewall is off/permissive

3. Get ip address from preferences/network

@adsteel
adsteel / run_circle_ci_locally.md
Last active March 28, 2019 21:43
Run CircleCI Locally

SSH into the tests, run them locally in a browser

Get dependencies

$ brew install caskroom/cask/brew-cask
$ brew cask install chicken

Run tests in SSH on CircleCI

  • Rebuild your tests from the rebuild drop menu, selecting "Rebuild with SSH"
@adsteel
adsteel / debug_circle_ci.md
Last active February 17, 2020 15:15
Remote SSH into Circle CI

SSH into your CircleCI tests, run them locally in a browser

  1. Use these instructions as a supplement to the CircleCI instructions https://circleci.com/docs/ssh-build

  2. Get dependencies

$ brew install caskroom/cask/brew-cask
$ brew cask install chicken
@adsteel
adsteel / splat_v_double_splat.md
Last active August 29, 2015 14:23
Splat and Double Splat

##Order Dependencies in Ruby's Splat & Double Splat Arguments

Ruby's splat and double splat arguments allow for some pretty flexible coding.

def print_arguments(*single, **double)
  p single
  p double
end