Skip to content

Instantly share code, notes, and snippets.

View kylemacey's full-sized avatar
💻
Writing bunches of code and stuff

Kyle Macey kylemacey

💻
Writing bunches of code and stuff
View GitHub Profile
@kylemacey
kylemacey / app-models-foo.rb
Created April 21, 2020 20:03
Generate RBI for a Mongoid Document
# typed: true
class Foo
include Mongoid::Document
include Mongoid::Timestamps
field :bar, type: String
end
@kylemacey
kylemacey / rachels_poem.rb
Created March 20, 2017 18:19
A calculator for holes in memory
class RachelsPoem
attr_accessor :holes_per_year, :years, :split_after_years
attr_reader :total_holes
def initialize(holes_per_day:3, years:23, days_per_year:365.25, split_after_years:7)
@total_holes = 0
self.holes_per_year = holes_per_day * days_per_year
self.years = years
self.split_after_years = split_after_years
end
@kylemacey
kylemacey / repo_export.rb
Last active August 29, 2015 14:27
Exports all repos for a GHE instance
require 'octokit.rb'
# export GITHUB_TOKEN=000000000000000
# export GITHUB_API_ENDPOINT=http://0.0.0.0/api/v3
# export GHE_HOST=0.0.0.0
# export GHE_PROTOCOL=https
ACCESS_TOKEN = ENV.fetch("GITHUB_TOKEN")
API_ENDPOINT = ENV.fetch("GITHUB_API_ENDPOINT")
HOST = ENV.fetch("GHE_HOST") # github.com
@kylemacey
kylemacey / Gemfile
Last active August 29, 2015 14:26 — forked from bitoiu/Gemfile
Audit Requirements
source 'https://rubygems.org'
gem 'octokit'
gem 'axlsx'
@kylemacey
kylemacey / wrap.rb
Created April 21, 2015 15:56
Wrappy thingy
array.map { |a| "<p>#{a}</p>" }.join("\n")
when using single line declaration, and a property is added later
#foo { width: 10px; }
becomes...
- #foo { width: 10px; }
+ #foo {
+ width: 10px;
+ height: 20px;
@kylemacey
kylemacey / git-bomb.sh
Last active August 24, 2021 15:42
This gist will create a custom git script that will delete any branches that are fully merged into the currently checked out branch (usually run on master)
mkdir -p ~/scripts/git
echo 'git branch --merged | grep -wiv -e "main" -e "master" | xargs -n 1 git branch -d' > ~/scripts/git/git-bomb
echo 'git remote prune origin' >> ~/scripts/git/git-bomb
chmod +x ~/scripts/git/git-bomb
sudo ln -s ~/scripts/git/git-bomb /usr/bin/git-bomb
namespace :taco do
resources :ingredients do
get :search1, on: :member
resource :search2, only: :show
end
end
search1_taco_ingredient GET /taco/ingredients/:id/search1(.:format) taco/ingredients#search1
taco_ingredient_search2 GET /taco/ingredients/:ingredient_id/search2(.:format) taco/search2s#show
<cfif thisTag.ExecutionMode is 'end'>
<cfset THISTAG.Content = THISTAG.GeneratedContent />
<cfset THISTAG.GeneratedContent = "" />
<cfparam name="to" default="#attributes.to#" />
<cfparam name="from" default="#attributes.from#" />
<cfparam name="subject" default="#attributes.subject#" />
<cfparam name="cc" default="" />
<cfparam name="bcc" default="" />