Skip to content

Instantly share code, notes, and snippets.

View alexdean's full-sized avatar
🍩

Alex Dean alexdean

🍩
View GitHub Profile
# in this test, i want to define a custom N1 segment which adds an extra element to the standard N1.
#
# it seems that the code somehow continues to reference the built-in N1 definition.
# i see errors saying that "N1 segment has only 6 elements" (the original number of elements in N1)
# even when my custom N1 defines 7 elements.
#
# see lines 103-111 below for more details on the error i see.
require "bundler/inline"
@alexdean
alexdean / signal_handler_disconnect_not_working.py
Last active May 14, 2021 16:04
demonstrating a problem with the OBS python method signal_handler_disconnect
import obspython as obs
obs_signal_handler = obs.obs_get_signal_handler()
# tested in OBS 25.0.6 on OSX. July 26, 2020.
def script_description():
return """
Debug signal_handler_disconnect.
video = Video.first
save_method = video.method(:save)

save_method.class
# => Method

save_method.source_location 
# => an Array with [file, line]
@alexdean
alexdean / 00_README.md
Last active November 26, 2022 04:41
changes in ActiveModel::Dirty tracking during ActiveRecord lifecycle callbacks in rails 5.2

This script reports on how the behavior of ActiveModel::Dirty methods have changed during various lifecycle callbacks in ActiveRecord instances.

The report shows the output of various ActiveModel::Dirty methods within a number of different callbacks, under different versions of ActiveRecord.

The script used to create this output is below, and can be used/modified to get information on other dirty-state methods.

fun stuff

this script was kinda fun to put together. i got to poke in a few areas of ruby I don't typically touch.

from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
def on_start(self):
""" on_start is called when a Locust start before any task is scheduled """
self.login()
def on_stop(self):
""" on_stop is called when the TaskSet is stopping """
self.logout()
@alexdean
alexdean / 01_rvm_bundler_global_gemset_error.sh
Last active April 25, 2018 17:36
error related to running bundler from rvm global gemset
rm -Rf /tmp/error
mkdir -p /tmp/error
cd /tmp/error
cat > Gemfile <<EOF
source "http://rubygems.org"
EOF
rvm use 2.5.1@global
gem install bundler --no-ri --no-rdoc
class TempModelBuilder
def self.build(sql, size)
final_table_name = "tmp_#{Digest::MD5.hexdigest(sql)}"
clazz = Class.new(ActiveRecord::Base)
clazz.table_name = final_table_name
# do stuff to create & populate the table
clazz
@alexdean
alexdean / wunderground.coffee
Created December 20, 2016 18:06
wunderground script for hubot
# Description:
# None
#
# Dependencies:
# None
#
# Configuration:
# HUBOT_WUNDERGROUND_API_KEY Sign up at http://www.wunderground.com/weather/api/.
# HUBOT_WUNDERGROUND_USE_METRIC Set to arbitrary value to use forecasts with metric system units
#
@alexdean
alexdean / file.md
Last active September 30, 2020 00:22
updating a youtube video with an invalid language code results in a deceptive invalidVideoMetadata error

overview

YouTube's API will return a confusing error code if you use a language code which YT does not support.

request

PUT https://www.googleapis.com/youtube/v3/videos?part=snippet&key={YOUR_API_KEY}

{
language_code name
af Afrikaans
am Amharic
ar Arabic
arq Algerian Arabic
art-x-bork Swedish Chef
as Assamese
ast Asturian
az Azerbaijani
be Belarusian