Skip to content

Instantly share code, notes, and snippets.

View vesan's full-sized avatar

Vesa Vänskä vesan

View GitHub Profile
@amkisko
amkisko / cleanup_apollo_schema_variants.rb
Last active November 24, 2022 15:01
Apollo Studio graph variants cleanup script (uses git branches for matching existing variants)
#!/usr/bin/env ruby
# USAGE:
# APOLLO_SCHEMA_KEY=service:... APOLLO_SCHEMA_NAME=Project-Name ./cleanup_apollo_schema_variants.rb
require "pry"
require "uri"
require "json"
require "net/http"
@kaspth
kaspth / routes.rb
Last active April 6, 2023 16:57
`draw` method to explore routes in the console
# All these requires are just for running via `irb`, if using `bin/rails console` you probably just need the method.
require "active_support/all" # Got an inflector NoMethodError, so I'm just being lazy here.
require "action_dispatch"
require "action_dispatch/routing/route_set"
require "action_dispatch/routing/inspector"
require "action_controller" # For the ActionController::Parameters autoload, which any route helper uses.
# Console helper play around with the routing DSL and tweak an individual route you're building.
@peteristhegreat
peteristhegreat / MacOS-colima-docker.md
Last active November 22, 2023 15:17
Colima 0.4.4 on MacOS, Attempt #2

Back in January, I tried colima and hit a snag on getting onto AWS ECR boxes. It ends up it was probably an issue with not being able to use the existing credentials file and I could have fixed it...

Today (Aug 2022) I am giving it another college try.

brew upgrade colima
ls -l $(which docker)
brew install docker
ln -s /Applications/Docker.app/Contents/Resources/bin/docker /usr/local/bin/docker-desktop
brew link --overwrite docker

brew install docker-credential-helper

@amkisko
amkisko / active_job_sidekiq_running.rb
Last active August 25, 2022 12:13
ActiveJob extension for checking if sidekiq job is running or awaiting in queues
# filepath: app/lib/sidekiq_running.rb
# source_url: https://github.com/eljojo/sidekiq-running
# usage: `include ActiveJobSidekiqRunning` to job class
module ActiveJobSidekiqRunning
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
@amkisko
amkisko / noko_importer.rb
Last active October 15, 2023 08:44
Noko entries importer
# AUTHOR: Andrei Makarov (github.com/amkisko)
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "noko"
gem "dotenv"
gem "active_support"
@janko
janko / application_controller.rb
Last active November 7, 2023 21:25
Implementing Devise groups in Rodauth
class ApplicationController < ActionController:Base
extend ControllerMacros
end
@amkisko
amkisko / _rails-tuples-readme.md
Last active March 10, 2022 11:30
Rails tuples

Rails tuples

Simple key-value storage with data types and expiration control.

Session 1:
1 Prior Analytics (∼350 BCE) 1
2 The True Method (1677) 5
3 Sketch of the Analytical Engine (1843) 9
4 An Investigation of the Laws of Thought on Which Are Founded the Mathematical Theories of Logic and Probabilities (1854) 27
5 Mathematical Problems (1900) 45
Session 2:
6 On Computable Numbers, with an Application to the Entscheidungsproblem (1936) 51

Beautiful Bash

until something is true

if "creation" command fails, sleep 1

while true; do
  kubectl get namespace mynamespace && break
 kubectl create namespace mynamespace || sleep 1
# Rails production setup via SQLite3 made durable by https://litestream.io/
# Copy this to Dockerfile on a fresh rails app. Deploy to fly.io or any other container engine.
#
# try locally: docker build . -t rails && docker run -p3000:3000 -it rails
#
# in production you might want to map /data to somewhere on the host,
# but you don't have to!
#
FROM ruby:3.0.2