Skip to content

Instantly share code, notes, and snippets.

@ismasan
ismasan / concurrent_processing.rb
Last active August 27, 2024 21:59
Practical Railway-oriented Pipeline for Ruby
# A Pipeline extension to process steps concurrently
# Example
# class ConcurrentPipeline < Pipeline
# include ConcurrentProcessing
# end
#
# MyPipeline = ConcurrentPipeline.new do |pl|
# pl.step ValidateInput
#
# # These steps run concurrently
from marvin import ai_fn
@ai_fn
def generate_people(n: int) -> list[dict]:
"""Generates a list of n people with random names and ages."""
generate_people(n=2) # [{'name': 'Olivia', 'age': 30}, {'name': 'Ethan', 'age': 22}]
@amit
amit / db.rake
Last active May 7, 2024 04:11 — forked from hopsoft/db.rake
Update for rails 7.0.X and handle postgres password
# apt install postgresql-client
# apt-get -y install bash-completion wget
# wget --no-check-certificate --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
# echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
# apt-get update
# apt-get -y install postgresql-client-12
namespace :db do
desc "Dumps the database to backups"
@cmtsij
cmtsij / tailscale
Last active March 20, 2024 09:14
tailscale completion
#!/bin/bash
# tailscale completion -*- shell-script -*-
_tailscale()
{
local cur prev words cword
_init_completion -n = || return
if [[ $cword -eq 1 ]]; then
SUBCOMMANDS=$(tailscale --help 2>&1 | awk '/SUBCOMMANDS/{ f = 1; next } /FLAGS/{ f = 0 } f{print $1}')
@searls
searls / whereable.rb
Created September 4, 2021 16:06
The initial implementation of a Whereable query filter for KameSame.
class Whereable
def initialize(where:, model: Item, ranking_conditions: [], valid: true, data_source: nil)
@model = model
@where = where
@data_source = data_source
@ranking_conditions = ranking_conditions
@valid = valid
end
def valid?
@eminetto
eminetto / rfc.md
Created May 22, 2021 13:04
Template of RFCs

Title

Problem description

We must explain the problem clearly and identify additional details that the team needs to know. We must here describe the context, what we did so far, and the current state.

The description also serves as a trail that we can go back to in the future to understand the reasoning we had at the time and see what restrictions and requirements have changed.

Possible approaches

@ijoseph
ijoseph / option_remappers.json
Created November 9, 2020 06:06
Option-G to Option-Command-G MacOS
{
"title": "Remap Useless Option Symbol Keys",
"rules": [
{
"description": "Remap Option-G to Option-Command-G",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "g",
@danba340
danba340 / server.js
Last active October 20, 2022 16:43
import { Application } from "https://deno.land/x/oak/mod.ts";
import { applyGraphQL, gql } from "https://deno.land/x/oak_graphql/mod.ts";
const app = new Application();
const types = gql`
type Dino {
name: String
image: String
}
@fabiolimace
fabiolimace / UUIDv6.sql
Last active November 17, 2024 13:46
Functions for generating UUIDv6 and UUIDv7 on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023-2024 Fabio Lima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
require 'dotenv/tasks'
Rake.application.options.trace = false
Dotenv.load('.env.production.cluster')
namespace :kube do
desc 'Rollout a new deployment'
task :deploy do