Skip to content

Instantly share code, notes, and snippets.

package com.atlassian.stash.plugin.webook;
import com.atlassian.stash.event.pull.PullRequestRescopedEvent;
import com.atlassian.stash.hook.repository.AsyncPostReceiveRepositoryHook;
import com.atlassian.stash.hook.repository.RepositoryHookContext;
import com.atlassian.stash.nav.NavBuilder;
import com.atlassian.stash.pull.PullRequestRef;
import com.atlassian.stash.repository.RefChange;
import com.atlassian.stash.repository.RefChangeType;
import com.atlassian.stash.repository.Repository;
@xaviershay
xaviershay / migration_sql.rb
Created August 14, 2015 21:21
Get SQL output from a Rails migration
#!/usr/bin/env ruby
require_relative 'config/environment'
path = ARGV.shift || raise("specify migration as first argument")
require_relative path
filename = File.basename(path, ".rb")
timestamp, name = filename.split("_", 2)
@xaviershay
xaviershay / gccc.md
Last active August 28, 2022 00:17
Request for services - Geelong Cross Country Club Handicapping System

Request for services - Geelong Cross Country Club Handicapping System

Context

The Geelong Cross Country Club (an established non-profit running group) uses a rails application to manage race results and handicaps for members. It was written by me in 2014 and has seen sporadic maintenance and features since. The codebase is relatively standard rails running against postgres on heroku. GCCC have requested some changes that I am unable to get to in a timely manner, so they are looking to engage a (paid) contractor. The app is also due for a round of upgrades.

@xaviershay
xaviershay / app.rb
Created November 24, 2011 19:14
Simple rack app with routing. Is this possible with http_router?
require 'rack/request'
require 'rack/response'
class App
attr_accessor :provider
# This constructor DI is not possible in Sinatra(?), since the framework
# creates the new instance for you.
def initialize(provider)
@provider = provider
@xaviershay
xaviershay / check-for-fixes.rb
Created July 24, 2021 23:20
Script to find issues referenced in a repo and check whether they're fixed or not
#!/usr/bin/env ruby
require 'tmpdir'
require 'net/http'
require 'openssl'
require 'uri'
require 'json'
require 'date'
def file_cache(key)
@xaviershay
xaviershay / spec.json
Last active October 9, 2020 04:27
contribution-vs-interest
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "Plots two functions using a generated sequence.",
"width": 600,
"height": 300,
"title": "Figure out what monthly contribution is equivalent to what savings rate",
"data": [{
"name": "month",
"values": [
@xaviershay
xaviershay / spec.json
Created October 9, 2020 00:10
interest-exploration
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "Plots two functions using a generated sequence.",
"width": 600,
"height": 300,
"data": [{
"name": "month",
"values": [
],
@xaviershay
xaviershay / repro-1489.sh
Last active July 25, 2020 22:27
Sample repro script for bundler issues
#!/bin/bash
set -ex
mkdir -p /tmp/repro-1489
cd /tmp/repro-1489
bundle env
# Bundler 1.3.5
# Ruby 2.0.0 (2013-06-27 patchlevel 247) [x86_64-darwin12.4.0]
@xaviershay
xaviershay / transform_hash.rb
Created December 4, 2011 22:56
Ruby puzzle
describe '#transform_hash' do
it 'transforms a single entry hash' do
transform_hash(a: [1, 0]).should == [[1], [0]]
end
it 'transforms a double entry hash' do
transform_hash(a: [1, 0], b: [0, 1]).should == [[1, 0], [0, 1]]
end
it 'transforms a multiple entry hash' do
@xaviershay
xaviershay / http_client_spec.rb
Created December 13, 2011 02:19
Running a rack app in a thread for integration tests.
require 'integration_helper'
require 'rack'
require 'rack/handler/webrick'
describe HttpClient do
before :all do
@server = WEBrick::HTTPServer.new(
:Port => 9293,
:Logger => Rails.logger,
:AccessLog => Rails.logger