Skip to content

Instantly share code, notes, and snippets.

View nicksieger's full-sized avatar

Nick Sieger nicksieger

View GitHub Profile
@nicksieger
nicksieger / ruby-3.0.x.patch
Created September 25, 2024 21:48
Patch to build ruby-3.0.x on Sequoia
--- ext/bigdecimal/bigdecimal.c.orig 2024-09-25 16:24:50
+++ ext/bigdecimal/bigdecimal.c 2024-09-25 16:25:15
@@ -65,7 +65,7 @@
static ID id_half;
/* MACRO's to guard objects from GC by keeping them in stack */
-#define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
+#define ENTER(n) volatile VALUE vStack[n];int iStack=0
#define PUSH(x) (vStack[iStack++] = (VALUE)(x))
#define SAVE(p) PUSH((p)->obj)
#!/usr/bin/env bash
#
# Convert a .mov or .mp4 to a .gif using ffmpeg and gifsicle.
#
# Tools install: https://gist.github.com/dergachev/4627207#installation
#
# Sources:
# 1. https://discovergrid.com/animated-gif-with-ffmpeg-palettegen/
# Use ffmpeg with a generated palette to map colors better
# 2. https://gist.github.com/dergachev/4627207
@nicksieger
nicksieger / tilt-updown.sh
Created December 6, 2021 15:18
Runs `tilt up`, then `tilt down` upon interrupt
#!/bin/bash
#
# Wrap tilt so that a Ctrl-C will call `tilt down` when done.
tilt=
do_auto_down() {
echo "Interrupt; killing $tilt"
kill -INT $tilt
tilt down
exit 0
@nicksieger
nicksieger / tiltnotify
Last active November 18, 2021 16:03
Publish Tilt resource statuses as macOS notifications
#!/bin/bash
#
# Send a message to OSX Notification Center when Tilt finishes building resources
#
# usage: tiltnotify [options]
#
# Options are passed as command-line arguments to `tilt get` (e.g., --port).
notify() {
local title= subtitle= message=
#!/bin/bash
#
# Homebrew has removed openssl 1.0 from the core repo, making the default
# openssl 1.1. We still have a number of packages that rely on openssl 1.0
# (including ruby 2.2.7), so we need to bring it back.
# Commit 0349a7ca76f483483c6d5c1d4cfe6b458dee2665 is the commit that removed 1.0
# from the repo. Commit 30fd2b68feb458656c2da2b91e577960b11c42f4 is its parent
# commit that still has 1.0.
# Uninstall 1.1 if it is currently installed as 'openssl'
#!/bin/bash
#
# Zoom.us full uninstall script
#
# - Download this file locally
# - Run `chmod 755 ./remove_zoom_us_macos.sh`
# - Run `./remove_zoom_us_macos.sh`
echo Cleaning Zoom…

Keybase proof

I hereby claim:

  • I am nicksieger on github.
  • I am nicksieger (https://keybase.io/nicksieger) on keybase.
  • I have a public key ASAKaesWsfKP6c93QgldTDwIJ7KU-pTzATtZIO_g7gh5UQo

To claim this, I am signing this object:

JQ Commands

Here are some handy jq scripts that I've found useful.

With AWS CLI

Since the AWS CLI outputs JSON this is a natural fit. Sometimes the built-in --query doesn't quite go far enough.

Examples:

@nicksieger
nicksieger / request_store_plugin.rb
Last active July 18, 2018 14:08
Propagate RequestStore contents across a Delayed Job boundary
class RequestStorePlugin < ::Delayed::Plugin
callbacks do |lifecycle|
lifecycle.before(:enqueue) do |job|
obj = job.payload_object
obj.instance_variable_set(:@_request_store, RequestStore.store)
job.payload_object = obj # reserialize the job
end
lifecycle.before(:perform) do |worker, job, &block|
request_store = YAML.load(job.handler).instance_variable_get(:@_request_store) || {}
@nicksieger
nicksieger / delayed_job_990_monkeypatch.rb
Last active July 29, 2017 17:54
Monkeypatch DJ to make payload_object exception-safe
## Monkeypatch payload_object like https://github.com/collectiveidea/delayed_job/pull/990
module Delayed
module Backend
class InvalidPayload
ParseObjectFromYaml = %r{\!ruby/\w+\:([^\s]+)} # rubocop:disable ConstantName
def initialize(handler, exception)
@handler = handler
@exception = deserialization_error(exception)
end