Skip to content

Instantly share code, notes, and snippets.

View forkata's full-sized avatar

Chris Todorov forkata

View GitHub Profile
#!/usr/bin/env ruby
# Place in your project (don't forget to chmod +x):
# bin/autoload-check
# Allow these files to be fixed later
allowlist = [
"ExampleClass" # why?
]
@ericgross
ericgross / 20230517213020_create_rls_functions.rb
Created May 20, 2023 23:07
Enabling multi-tenant Solidus using RLS on Postgres
class CreateRlsFunctions < ActiveRecord::Migration[7.0]
def self.up
connection.execute <<-SQL
-- This function returns the id of the current user or NULL if not set
-- this varaible is set on a connection basis before every action
-- If it is not set, it will return NULL and all non-public tables will seem empty.
CREATE FUNCTION current_user_id() RETURNS BIGINT AS $$
SELECT NULLIF(current_setting('rls.user_id', TRUE), '')::BIGINT;
$$ LANGUAGE sql SECURITY DEFINER STABLE COST 10;
-- This function returns the id of the current tenant or NULL if not set
@curz46
curz46 / XM3-GUIDE.md
Last active January 29, 2025 09:56
Sony WH-1000XM3 Headphones not working on Windows?

Edit: This method usually works but there is an easier way explained by @Instinctlol in the comments below. You might want to try that way first!

Introduction

When I first got these headphones they worked perfectly with my phone but trying to get them to connect to my Windows pc seemed hopeless. In my case, they paired & pressing 'connect' showed the headphones as connected, but the audio device was disabled & disconnected in sound settings. I later realised that they instantly connected & worked properly with my newer laptop, so the following guide was produced by imitating the setup my laptop automatically configured. This is something you should only have to do once when initially pairing the device.

Method

  1. First ensure that you are attempting to pair the device as WH-1000XM3 and not LE_WH-1000XM3. I'm not sure what the latter is for but it will not let you connect/play s
[merge]
tool = mymeld
conflictstyle = diff3
[mergetool "mymeld"]
# Shows three-pane merge view with central output directly being the merged file to save
cmd = $MANISHMELD $LOCAL $BASE $REMOTE --output=$MERGED
#cmd = meld "$LOCAL" "$BASE" "$REMOTE"
@troyfontaine
troyfontaine / 1-setup.md
Last active May 15, 2025 22:58
Signing your Git Commits on MacOS

Methods of Signing Git Commits on MacOS

Last updated March 13, 2024

This Gist explains how to sign commits using gpg in a step-by-step fashion. Previously, krypt.co was heavily mentioned, but I've only recently learned they were acquired by Akamai and no longer update their previous free products. Those mentions have been removed.

Additionally, 1Password now supports signing Git commits with SSH keys and makes it pretty easy-plus you can easily configure Git Tower to use it for both signing and ssh.

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing your commits with GPG.

require 'aws-sdk'
require 'timeout'
def wait_for_completion(opsworks, result)
status = 'running'
Timeout::timeout(300) do
while (status == 'running') do
sleep(5)
response = opsworks.describe_deployments(
deployment_ids: [result.deployment_id]
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 15, 2025 22:49
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@danieleggert
danieleggert / GPG and git on macOS.md
Last active March 6, 2025 20:45
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@alexblackie
alexblackie / pivotal_deliverance.rb
Created November 3, 2015 20:46
Meant to be run in a Jenkins job; marks stories in Pivotal as "Delivered" if their IDs are mentioned in a commit that's part of the current Jenkins build changeset.
require "net/http"
require "json"
require "pry"
# Wrapper around the Jenkins JSON API
class Jenkins
# @param [string] jenkins_user - a Jenkins user with at least read access
# @param [string] token - Jenkins API token for the user
# @param [string] job - Jenkins job name
def initialize(jenkins_user, token, job)
@gvaughn
gvaughn / description.md
Last active September 28, 2015 23:44
Address changes

What's up with Address and UserAddressBook?

It's a domain level refactoring. Address is now readonly with copy on write semantics, so once it's in the db, it doesn't change. If you use the typical nested attributes for addresses in Orders (and now Users and CreditCards) it'll just work. If you need to create them manually Address.factory and Address.immutable_merge are your new friends. UserAddressBook is foundational work to ultimately allow users a richer set of addresses to use for pre-fill during checkout.

Background

I was asked to add what seemed like a fairly simple new feature to our custom frontend code, but upon digging I found that it would require some fairly large refactoring to do it well. That new feature was to allow the user to manage a list of addresses in their account section of our frontend. Those will be used as options to pre-fill during checkout. The things that I found that I wanted to refactor were some missing and misplaced address associations, plus a lot of unn