Skip to content

Instantly share code, notes, and snippets.

View benoittgt's full-sized avatar
🏳️‍🌈

Benoit Tigeot benoittgt

🏳️‍🌈
View GitHub Profile
# make sure all expect wait for turbo before expecting
module RSpec
module Matchers
expect_old = instance_method(:expect).bind(self)
define_method(:expect) do |*args, &block|
expect_old.call(page).not_to have_selector('html[aria-busy="true"]')
expect_old.call(page).not_to have_selector('turbo-frame[busy]')
expect_old.call(*args, &block)
end
end
@minmax
minmax / pg_index_progress.sql
Created January 18, 2022 21:44
pg index progress
-- https://gitlab.com/-/snippets/2138417
select
now(),
query_start as started_at,
now() - query_start as query_duration,
format('[%s] %s', a.pid, a.query) as pid_and_query,
index_relid::regclass as index_name,
relid::regclass as table_name,
(pg_size_pretty(pg_relation_size(relid))) as table_size,
nullif(wait_event_type, '') || ': ' || wait_event as wait_type_and_event,
@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?
@searls
searls / 001_functions_and_views.sql
Created December 29, 2020 13:32
KameSame's December 2020 search overhaul
-- This all starts with some functions and a *materialized* postgres view that unnests several
-- arrays of strings of definitions into flattened rows that are easier to search. Fun fact:
-- you can even create indexes on materialized views' columns! They'll refresh whenever the view
-- is refreshed (which in my case is every time that we pull new dictionary data from WaniKani or JMDICT
-- This function will take an array of strings and convert all the double-width alphanumeric characters
-- and normalize them as half-width. That way a search query can be massaged from "OK" to "ok" easily
CREATE OR REPLACE FUNCTION array_hankakufy_romaji(character varying[])
RETURNS character varying[]
AS
@swinton
swinton / README.md
Last active May 14, 2024 10:06
Automatically sign your commits from GitHub Actions, using the REST API

Verified commits made easy with GitHub Actions

image

So you want to commit changes generated by a GitHub Actions workflow back to your repo, and have that commit signed automatically?

Here's one way this is possible, using the REST API, the auto-generated GITHUB_TOKEN, and the GitHub CLI, gh, which is pre-installed on GitHub's hosted Actions runners.

You don't have to configure the git client, just add a step like the one below... Be sure to edit FILE_TO_COMMIT and DESTINATION_BRANCH to suit your needs.

# frozen_string_literal: true
Warning.singleton_class.prepend(
Module.new do
DISABLED_WARNINGS = Regexp.union(
/_pry_ is deprecated, use pry_instance instead/,
/warning: The called method( `.+')? is defined here/,
)
def warn(warning)
Process.setproctitle("foo-parent")
ppid = Process.pid
fork do
exit if fork # You can only setsid if you're in a child process so first we fork
Process.setsid # and exit the parent then setsid in the child. Now that we have a
exit if fork # new session create a child process in it and exit the parent again.
Dir.chdir("/") # Finally, change directory to one that can't be deleted or moved.
Process.setproctitle("foo-child")
@seanh
seanh / netrw.md
Last active April 23, 2024 18:13
Netrw Cheatsheet (Vim's Built-in Directory Browser)

Netrw Cheatsheet (Vim's File Browser)

See also:

  • vinegar.vim, which makes - open netrw in the directory of the current file, with the cursor on the current file (and pressing - again goes up a directory). Vinegar also hides a bunch of junk that's normally at the top of netrw windows, changes the default order of files, and hides files that match wildignore.

    With vinegar, . in netrw opens Vim's command line with the path to the file under the cursor at the end of the command. ! does the same but also prepends ! at the start of the command. y. copies the absolute path of the file under the cursor. ~ goes to your home dir. Ctrl+6 goes back to the file (buffer) that you had open before you opened netrw.

To launch netrw:

Benchmarks for GC Compactor

GC benchmarks for trunk vs gc-compact seem to be about the same:

$ make benchmark ITEM=gc
./revision.h unchanged
/Users/aaron/.rbenv/shims/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
	            --executables="compare-ruby::/Users/aaron/.rbenv/shims/ruby --disable=gems -I.ext/common --disable-gem" \
	            --executables="built-ruby::./miniruby -I./lib -I. -I.ext/common  -r./prelude --disable-gem" \
@matthewrudy
matthewrudy / errors.out
Last active March 25, 2019 16:10
Changes required to make rspec-rails work with Rails 6
# this is what the errors looked like before
ActionView::Template::Error:
wrong number of arguments (given 2, expected 1)