Skip to content

Instantly share code, notes, and snippets.

View cgrothaus's full-sized avatar

Christoph Grothaus cgrothaus

View GitHub Profile
@cgrothaus
cgrothaus / replicated_con_cache.ex
Last active December 13, 2023 09:22
A replicated cache in 60 lines using ConCache and Phoenix PubSub
defmodule MyApp.ReplicatedConCache do
@moduledoc """
Utility to replicate local ConCache operations via Phoenix.PubSub.
Only those ConCache functions that we need are replicated.
Prerequisites:
- for all relevant cache ids, there is a ConCache instance running on
each node connected to the PubSub system
- these ConCache instances are all configured same (TTL etc.)
@cgrothaus
cgrothaus / .gitignore
Last active March 18, 2022 15:57
SAP OData metadata documentation generator
# Local environment variables like secrets
.env
# Bundler directory
.bundle
# Cached rubocop files
.rubocop-http*
# Intermediate output file
#!/bin/zsh
KEEP_FORMULAS=(asdf bat fd fzf git htop httpie hub iftop jq ncdu neovim p7zip ruby-build the_silver_searcher tig tmux watch yq z zsh)
declare -A visited_formulas
for formula ($KEEP_FORMULAS); do
echo "Keeping $formula"
visited_formulas[$formula]=1
done
@cgrothaus
cgrothaus / set_game_kata.rb
Created August 25, 2018 14:39
SET game kata
require 'set'
##
# One solution for the set game kata. It is all about "SET", a card game.
# For details on task to solve and the rules of the game, see
# https://www.codewars.com/kata/set-the-card-game/
module SetGame
ATTRIBUTES = %i[color shape number shading].freeze
COLORS = %i[red green blue].freeze
@cgrothaus
cgrothaus / namespace-issue-swagger-spec.yaml
Last active June 5, 2018 14:51
Swagger specification showing a name shadowing issue when generating ruby code with swagger-codegen 2.3.1, see https://github.com/swagger-api/swagger-codegen/issues/8283
swagger: "2.0"
info:
version: "1.0"
title: "Namespace issue demo swagger spec"
produces:
- application/json
paths:
require 'digest'
require 'io/console'
require 'net/http'
# Proxy setup here
http = Net::HTTP # use this for no proxy or if you are fine with ENV var http_proxy
# http = Net::HTTP::Proxy('myproxy.local', '8080') # use this for explicit configuration of proxy within this ruby script
puts '+++++ PASSWORD CHECKER +++++'
print 'Please enter password: '