Skip to content

Instantly share code, notes, and snippets.


Austin Story Austio

View GitHub Profile

How to create a Ruby gem that adds Rake tasks

Create a gem

One way to do this is to use bundler to scaffold our gem:

bundler gem my_gem

Add rake tasks to our gem

I prefer to put tasks meant to manage the gem itself in lib/tasks, and tasks the gem is meant to provide to gem users in lib/my_gem/tasks.

Austio / The Many Meanings of Event-Driven
Created Apr 26, 2021 — forked from xpepper/The Many Meanings of Event-Driven
My notes on the talk "The Many Meanings of Event-Driven Architecture" by Martin Fowler (GOTO 2017)
View The Many Meanings of Event-Driven

GOTO 2017 • The Many Meanings of Event-Driven Architecture - Martin Fowler

(the video is here, the original talk notes are here)

At least one of those four patterns are in play when you talk about "event-driven" architectures:

  1. Event Notification: components communicating via events
  2. Event-carried State Transfer: allowing components to access data without calling the source
  3. Event Sourcing: using an event log as the primary record for a system
  4. CQRS: having a separate component for updating a store from any readers of the store
Austio / pundit_example.rb
Created Feb 19, 2021 — forked from rmosolgo/pundit_example.rb
Example of GraphQL::Pro pundit_integration with node field
View pundit_example.rb
require "bundler/inline"
gemfile do
gem "pundit", "2.1.0"
gem "graphql", "1.12.5"
source "" do
gem "graphql-pro", "1.17.6"
View gist:dfc5bd1acd7c3cd799fa604cec7ee638
<!DOCTYPE html>
// Object.assign
if (typeof Object.assign != 'function') {
Object.assign = function(target) {
'use strict';
Austio / Rails.rd
Created Nov 28, 2020
Rails 1 file reproduction template
View Rails.rd
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source ""
git_source(:github) { |repo| "{repo}.git" }
# Activate the gem you are reporting the issue against.
Austio / tellmeyoursecrets.js
Created Nov 20, 2019 — forked from woodwardtw/tellmeyoursecrets.js
google script that lists a lot of info about the files in a particular folder/sub folder structure including viewers, editors, and sharing permissions
View tellmeyoursecrets.js
function listFolders(folder) {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "Sharing Access", "Sharing Permission", "Get Editors", "Get Viewers", "Date", "Size", "URL", "Download", "Description", "Type"]); //writes the headers
var folder = DriveApp.getFolderById("YOUR_FOLDER_ID");//that long chunk of random numbers/letters in the URL when you navigate to the folder
var files = folder.getFiles();//initial loop on loose files w/in the folder
var cnt = 0;
var file;
Austio / gist:c5d83deec7e8ff2d1a44998ef01e3edb
Created Nov 15, 2019 — forked from chanks/gist:7585810
Turning PostgreSQL into a queue serving 10,000 jobs per second
View gist:c5d83deec7e8ff2d1a44998ef01e3edb

Turning PostgreSQL into a queue serving 10,000 jobs per second

RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.

On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.

So, many developers have started going straight t

Austio / tmux-test-runner.vim
Created Nov 14, 2019 — forked from codenamev/tmux-test-runner.vim
Run specs from vim in another tmux pane.
View tmux-test-runner.vim
map <silent> <Leader>rl :w<cr>:silent call RunCurrentLineInTest('!ts bundle exec rspec')<cr>:silent redraw!<cr>
map <silent> <Leader>rt :w<cr>:silent call RunCurrentTest('!ts bundle exec rspec')<cr>:silent redraw!<cr>
" Test runner helpers
function! RunCurrentTest(rspec_type)
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1
if in_test_file
call SetTestFile()
if match(expand('%'), '\.feature$') != -1
Austio / ioread.c
Created Feb 24, 2019
memory safe get io
View ioread.c
#include <stdio.h>
#include <string.h>
#define OK 0
#define NO_INPUT 1
#define TOO_LONG 2
#define SMALL_BUFF 3
static int getLine (char *prmpt, char *buff, size_t sz) {