Skip to content

Instantly share code, notes, and snippets.

View koffeinfrei's full-sized avatar

Alexis Reigel koffeinfrei

View GitHub Profile
koffeinfrei / generate_many_runner_tags.rb
Last active December 11, 2018 09:00
generate a lot of random ActsAsTaggableOn::Tag
require 'bulk_insert'
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
model = WhateverModel.find_by(whatever: 'something')
tag_names = ('a'..'i')
tag_names_count = tag_names.count
max_id = ActsAsTaggableOn::Tag.maximum(:id)
koffeinfrei / .ruby-version
Created March 14, 2018 08:11 — forked from aishfenton/serializer_benchmarks.rb
Performance comparison of different ruby serializer methods
koffeinfrei / active_record_base_spec.rb
Last active March 6, 2016 12:01
has_many dependent spec
# File: spec/models/base_spec.rb
require 'rails_helper'
RSpec.describe 'All ActiveRecord::Base models' do
context 'has_many with :dependent key' do
each_active_record_model do |model|
has_many_relations(model).each do |has_many_relation|
it "has :dependent defined on the #{model}##{} relation" do
expect(has_many_relation.options[:dependent]).not_to be_nil
koffeinfrei /
Last active December 23, 2023 03:43
Idempotent seed helper for rails -> THIS IS NOW A GEM

Idempotent seed helper for rails

  • The first model argument is the model class
  • The second argument find_or_create_by is a hash of attributes that are used for finding a record. If the record doesn't exist, it will be created. This hash is like the unique identifier of a seed record.
  • The third argument update_with is a hash of attributes that will be always set on the record, whether the record already exists or has to be created. This is useful when the seeds are extended and you want to update existing records with new attributes.

Example usage

Keybase proof

I hereby claim:

  • I am koffeinfrei on github.
  • I am koffeinfrei ( on keybase.
  • I have a public key whose fingerprint is 26F1 300F 4F40 F679 66F0 A62D B0B7 DE56 128A 5B8F

To claim this, I am signing this object:

koffeinfrei /
Last active December 11, 2018 09:13
koffeinfrei /
Last active September 22, 2017 09:11
git relevant contributors ->
# Help output
help() {
echo "Usage: git-fame [options] <repository_path>"
echo " -m Machine readable output"
echo " -h Print this help"
exit 1
koffeinfrei / .gitignore
Last active May 26, 2021 15:09
Ruby system call benchmark
koffeinfrei /
Last active August 29, 2015 14:06 — forked from busterbenson/markov_tweets.rb
Horse koffeinfrei (markov twitter bot)

Getting started

  1. Setup new horse twitter account
  • Create a new Twitter account that you'd like to have your auto-tweets posted to
  • Go to, create a new application with Read+Write permissions
  • Create an access token + secret for the account and copy that and the consumer key and secrets.
  1. Get your twitter archive
  • Go to -> Settings -> Download Archive.
  • The tweets.csv file is in the top directory. Put it in the same directory as this script.
koffeinfrei / svn_authors.rb
Last active August 29, 2015 14:03
svn authors
# Koffeinfrei svn_authors.rb
# Copyright (C) 2011 Alexis Reigel
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of