Skip to content

Instantly share code, notes, and snippets.

View tiegz's full-sized avatar
👋
Working from home

Tieg Zaharia tiegz

👋
Working from home
View GitHub Profile
@tiegz
tiegz / assign_reviewer_team_to_pr.js
Created April 8, 2024 19:47
Assign a group of people to review a PR
// Add GH usernames to this list to assign them as reviewers
var team = [];
var menu = document.getElementById('reviewers-select-menu')
var summary = menu.getElementsByTagName('summary')[0]
// Open assignee modal
summary.click();
@tiegz
tiegz / mutual_tls_server.go
Last active June 9, 2021 16:06
mutual_tls_server.go
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io"
"io/ioutil"
"log"
"net/http"
@tiegz
tiegz / npm_nuget_jquery_comparison.rb
Created July 11, 2020 14:18
NPM/NuGet jQuery version comparison.
# Compares a set of npm jquery files to nuget's wrapped jquery files, for the given versions.
versions = "1.11.0,1.11.0-beta3,1.11.0-pre,1.11.0-rc1,1.11.1,1.11.1-beta1,1.11.1-rc1,1.11.1-rc2,1.11.2,1.11.3,1.12.0,1.12.1,1.12.2,1.12.3,1.12.4,1.5.1,1.6.2,1.6.3,1.7.2,1.7.3,1.8.2,1.8.3,1.9.1,2.1.0,2.1.0-beta2,2.1.0-beta3,2.1.0-rc1,2.1.1,2.1.1-beta1,2.1.1-rc1,2.1.1-rc2,2.1.2,2.1.3,2.1.4,2.2.0,2.2.1,2.2.2,2.2.3,2.2.4,3.0.0,3.0.0-alpha1,3.0.0-beta1,3.0.0-rc1,3.1.0,3.1.1,3.2.0,3.2.1,3.3.0,3.3.1,3.4.0,3.4.1,3.5.0,3.5.1"
mismatches = []
missing_on_nuget = []
versions.split(',').each do |v|
print "#{v}, "
# Nuget doesn't publish prerelease version
@tiegz
tiegz / throttled_http_requests.go
Last active May 6, 2020 16:39
Golang Concurrent HTTP Requests with Throttle
package main
import (
"fmt"
"io/ioutil"
"net/http"
"sync"
"time"
)
@tiegz
tiegz / puckjs_zoom_mute_button.js
Created March 20, 2020 18:30
Puck.js mute/unmute button for Zoom.
var kb = require("ble_hid_keyboard");
var led = 0;
LED!.write(led);
NRF.setServices(undefined, { hid : kb.report });
function btnPressed() {
// The shortcut on MacOS for mute/unmute is cmd-shift-a
kb.tap(kb.KEY.A, kb.MODIFY.SHIFT | kb.MODIFY.GUI, function() {
led = led == 0 ? 1 : 0;
LED2.write(led);
@tiegz
tiegz / advent_of_code_2018.md
Last active December 11, 2018 06:18
advent_of_code_2018.md
@tiegz
tiegz / advent_of_code_2017.md
Last active December 2, 2017 05:52
Advent of Code 2017
@tiegz
tiegz / count_loader.rb
Created November 13, 2017 21:57
CountLoader
# Param-based count loader (for params and foreign keys).
#
# Example:
# CountLoader.for(Category).load(category_id)
#
class CountLoader < GraphQL::Batch::Loader
def initialize(model, param: :id, scope: nil)
@model = model
@param = param
@scope = case scope
@tiegz
tiegz / trying_to_reproduce_numericality_bug.txt
Last active August 6, 2017 16:34
Rails 5.0 numericality with_integer: true bug
# Run in Rails 5.0 active_record folder with:
# bundle exec rake test:sqlite3 TEST=test/cases/attribute_test.rb
require 'cases/helper'
class PriceEstimate < ActiveRecord::Base
validates :price, presence: true, numericality: { only_integer: true }
# Accepts float (1.23), rounds it (1.0), stores it as integer (1).
def price=(float_val)
@tiegz
tiegz / rescue_instrumentation.rb
Created April 5, 2017 18:23
RescueInstrumentation
# This piggy-backs off RescueMiddleware by using the same exception handling
# rules you've defined using rescue_from(), and applying them to lazy fields
# (which would otherwise run after middleware has been run).
# Add this to your schema:
#
# instrument(:field, RescueInstrumentation.new)
#
class RescueInstrumentation
def instrument(type, field)
old_lazy_resolve_proc = field.lazy_resolve_proc