Skip to content

Instantly share code, notes, and snippets.

View Austio's full-sized avatar

Austin Story Austio

View GitHub Profile
@Austio
Austio / create-ruby-gem-that-adds-rake-tasks.md
Created September 26, 2022 21:34 — forked from ntamvl/create-ruby-gem-that-adds-rake-tasks.md
How to create a Ruby gem that adds Rake tasks

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
Austio / The Many Meanings of Event-Driven Architecture.md
Created April 26, 2021 21:19 — forked from xpepper/The Many Meanings of Event-Driven Architecture.md
My notes on the talk "The Many Meanings of Event-Driven Architecture" by Martin Fowler (GOTO 2017)

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
Austio / pundit_example.rb
Created February 19, 2021 18:06 — forked from rmosolgo/pundit_example.rb
Example of GraphQL::Pro pundit_integration with node field
require "bundler/inline"
gemfile do
gem "pundit", "2.1.0"
gem "graphql", "1.12.5"
source "https://gems.graphql.pro" do
gem "graphql-pro", "1.17.6"
end
end
@Austio
Austio / gist:dfc5bd1acd7c3cd799fa604cec7ee638
Created January 29, 2021 14:48
consola_reproduction.html
<!DOCTYPE html>
<html>
<body>
<h1>Before</h1>
<script>
// Object.assign
if (typeof Object.assign != 'function') {
Object.assign = function(target) {
'use strict';
@Austio
Austio / Rails.rd
Created November 28, 2020 13:48
Rails 1 file reproduction template
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
@Austio
Austio / tellmeyoursecrets.js
Created November 20, 2019 12:41 — 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
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
Austio / gist:c5d83deec7e8ff2d1a44998ef01e3edb
Created November 15, 2019 03:54 — forked from chanks/gist:7585810
Turning PostgreSQL into a queue serving 10,000 jobs per second

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
Austio / tmux-test-runner.vim
Created November 14, 2019 15:34 — forked from codenamev/tmux-test-runner.vim
Run specs from vim in another tmux pane.
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
Austio / ioread.c
Created February 24, 2019 09:13
memory safe get io
#include <stdio.h>
#include <string.h>
#define OK 0
#define NO_INPUT 1
#define TOO_LONG 2
#define SMALL_BUFF 3
// https://stackoverflow.com/questions/2430303/disadvantages-of-scanf
static int getLine (char *prmpt, char *buff, size_t sz) {