Skip to content

Instantly share code, notes, and snippets.

View miharekar's full-sized avatar

Miha Rekar miharekar

View GitHub Profile
miharekar / .rubocop.yml
Last active January 4, 2024 14:31
My RuboCop standard
rubocop-rails-omakase: rubocop.yml
- rubocop-performance
- rubocop-rails
NewCops: enable
TargetRubyVersion: 3.3
miharekar / Stripe Webhook Upgrader
Last active October 23, 2023 13:10
Stripe Webhook Upgrader
Since you can't update Stripe API version on a webhook, the only way to do it, is to disable one, and create a new one.
miharekar / Enable Rails cache for one unit
Created March 24, 2023 11:09
Enable Rails cache for one unit

#rails #minitest #testing

Add to test/test_helper.rb

    def with_cache
      @original_cache_store = Rails.cache
      Rails.cache =
 Rails.cache = @original_cache_store
miharekar / Prevent email sending in
Last active February 24, 2023 14:33
Prevent email sending in

#rails #actionmailer #callbacks

Callbacks for mailers are implemented using AbstractController::Callbacks.

This has a terminator lambda:

AbstractController::Base defines performed? as: return response_body

So - as soon as we set any response body, no other callbacks or actions will occur.

miharekar / obsidian-web-clipper.js
Last active November 9, 2022 08:00 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([
]).then(([{ default: Turndown }, { default: Readability }]) => {
const vault = "";
const folder = "quick";
const tags = "#clippings";
function getSelectionHtml() {
var html = "";
miharekar / gps.rb
Created August 24, 2021 10:07
Copy GPS coordinates of a dropped in photo to clipboard
loop do
puts "Gimme photo\n"
path = gets
exifdata = value = `exiftool -c "%+.10f" #{path} `
line = exifdata.split("\n").find{|l| l.include?("GPS Position")}
if line.nil?
puts exifdata
puts "\nNO GPS 🤷‍♂️"
miharekar / benchmark.rb
Last active September 22, 2020 06:20
Starts with benchmark
require 'benchmark/ips'
Benchmark.ips do |x|
records = []
10_000.times do |i|
records << "#{['abc', 'rec', 'air'].sample}-#{i}-#{['abc', 'rec', 'air'].sample}-#{i}"
AIRTABLE_ID_REGEX = /rec(?!_)/.freeze
miharekar / quotes.json
Last active November 29, 2023 09:34
Stoic Quotes JSON
This file has been truncated, but you can view the full file.
{"quotes":[{"text":"We have two ears and one mouth, so we should listen more than we say.","author":"Zeno of Citium, as quoted by Diogenes Laërtius"},{"text":"Man conquers the world by conquering himself.","author":"Zeno of Citium"},{"text":"The goal of life is living in agreement with Nature.","author":"Zeno"},{"text":"if being is many, it must be both like and unlike, and this is impossible, for neither can the like be unlike, nor the unlike like","author":"Zeno"},{"text":"Well-being is attained little by little, and nevertheless is no little thing itself.","author":"Zeno of Citium"},{"text":"The reason why we have two ears and only one mouth is that we may listen the more and talk the less.","author":"Zeno"},{"text":"When a dog is tied to a cart, if it wants to follow, it is pulled and follows, making its spontaneous act coincide with necessity. But if the dog does not follow, it will be compelled in any case. So it is with men too: even if they don't want to, they will be compelled to follow what is desti
miharekar / .gitignore
Last active September 9, 2023 06:08
Stoic quotes from Goodreads
miharekar / Gemfile
Last active January 28, 2019 14:49
UPN QR to N26 and Toshl
# frozen_string_literal: true
source ''
gem 'sinatra'
gem 'twentysix'