Skip to content

Instantly share code, notes, and snippets.

View tadejm's full-sized avatar

Tadej Murovec tadejm

  • Uplisting
  • Ljubljana, Slovenia
  • X @tadejm
View GitHub Profile
@tadejm
tadejm / db_guidelines.md
Created September 7, 2022 11:54 — forked from adamrdavid/db_guidelines.md
the darndest things
@tadejm
tadejm / benchmark.rb
Created March 9, 2018 13:24
Benchmark JSON serialization
require 'benchmark/ips'
require "json"
require "oj"
require "hanami/utils/json"
require "multi_json"
MultiJson.adapter = :oj
puts "MultiJson.current_adapter => #{MultiJson.current_adapter}"
@tadejm
tadejm / steps.txt
Created November 27, 2017 09:22
Step by step guide for Heroku Postgres upgrade, 9.5 to 9.6
Heroku DB upgrade notes
heroku addons:create heroku-postgresql:standard-0 -r production
heroku ps:scale web=0 worker=0 -r production
heroku maintenance:on -r production
heroku pg:backups:capture -r production
heroku pg:copy DATABASE_URL __NEW_DB_URL__ -r production
heroku pg:promote __NEW_DB_URL__ -r production
heroku ps:scale web=1 worker=1 -r production
heroku maintenance:off -r production
@tadejm
tadejm / slack_delete.rb
Last active September 24, 2017 19:04 — forked from jamescmartinez/slack_delete.rb
This Ruby script will bulk remove all non starred Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@tadejm
tadejm / circle.yml
Created August 2, 2017 16:38
Installs the latest Firefox and geckodriver on CircleCI. Works with `selenium-webdriver-3.4.4`
dependencies:
pre:
- pip install mozdownload mozinstall
- mozdownload --version latest --destination firefox.tar.bz2
- mozinstall firefox.tar.bz2
- wget -O geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
- gunzip -c geckodriver.tar.gz | tar xopf -
- chmod +x geckodriver && mv geckodriver /home/ubuntu/bin/
machine:
environment:
@tadejm
tadejm / Gemfile
Last active October 29, 2016 20:29
fetch & collect cpu benchmarks
# frozen_string_literal: true
source "https://rubygems.org"
gem "oga"
gem "pry"
@tadejm
tadejm / duplicate_files.rb
Last active August 29, 2015 14:10
Finds duplicate files and moves them to Trash.
#!/usr/bin/ruby
require 'digest'
require 'set'
require 'pathname'
require 'fileutils'
uniques = Set.new
user = `whoami`.sub("\n","")
trash = Pathname.new("/Users/#{user}/.Trash/")
@tadejm
tadejm / .rubocop.yml
Created April 8, 2014 23:51
Styleguide translated to Rubocop
AllCops:
Exclude:
- script/*
- db/*
- tmp/*
- vendor/*
Include:
- tasks/*.rake
RunRailsCops: true
@tadejm
tadejm / Guardfile
Last active August 29, 2015 13:58
Guard, red green refactor with Rubocop
group :red_green_refactor, halt_on_fail: true do
guard :rspec, failed_mode: :keep, all_after_pass: true do
watch('spec/spec_helper.rb') { "spec" }
watch('spec/factories/factories.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  • add prepare-commit-msg it to ./.git/hooks/
  • Make it executable (chmod +x filename)

It should prepend [#STORY_ID] into your commit message when the editor pops up. Your branch must be in this format to work: branch-description-blabla-STORY_ID

it skips the prepaend if:

  • The branch doesn't end in a story id (integer)
  • The original commit message starts with "Merge"