Skip to content

Instantly share code, notes, and snippets.

View crallen's full-sized avatar

Chris Allen crallen

View GitHub Profile
@crallen
crallen / semver_test.go
Last active October 26, 2021 15:26
Testing semver parsing
package main
import (
"testing"
"github.com/Masterminds/semver/v3"
)
type testCase struct {
Name string

Keybase proof

I hereby claim:

  • I am crallen on github.
  • I am crallen (https://keybase.io/crallen) on keybase.
  • I have a public key ASDMiswcuTplLAOhzsTqir2R-cPY3vfilT9m8HG9sxGWOwo

To claim this, I am signing this object:

@crallen
crallen / create-kubeconfig.sh
Last active May 4, 2020 19:56
Create kubeconfig using service account credentials
#!/bin/bash -e
display_usage() {
echo -e "\nCopies settings from a kubeconfig context on the current machine to a new"
echo "kubeconfig file using a designated service account for credentials."
echo -e "\nUsage:"
echo " $0 [options] <serviceaccount>"
echo " $0 -h | --help"
echo -e "\nOptions:"
echo -e " -h --help Show this help text"
@crallen
crallen / docker_prune.sh
Created March 30, 2020 13:13
Script to stop and prune all Docker images
#!/bin/bash
CONTAINERS=$(docker container ls -aq)
if [ -n "$CONTAINERS" ]; then
docker -l debug container stop $CONTAINERS
docker -l debug container rm $CONTAINERS
fi
docker -l debug system prune -af
@crallen
crallen / SnakeCaseContractResolver.cs
Created February 26, 2014 20:46
Json.NET contract resolver that uses Ruby-style lowercase with underscore naming conventions.
using Newtonsoft.Json.Serialization;
namespace ConsoleApplication3
{
public class SnakeCaseContractResolver : DefaultContractResolver
{
protected override string ResolvePropertyName(string propertyName)
{
return GetSnakeCase(propertyName);
}
require 'find'
def copy_dir_tree(src_dir, dest_dir, ignored_exts)
Find.find(src_dir) do |file|
next if ignored_exts.include?(File.extname(file))
if File.directory?(file)
mkdir File.join(dest_dir, file)
else
cp file, File.join(dest_dir, file)
end
@echo off
REM Batch file used for task scheduler, calls Ruby script
C:\Ruby\bin\ruby.exe reset_build_numbers.rb
# Simple Ruby script to reset TeamCity build numbers
USER_DIR = ENV['USERPROFILE'].gsub('\\', '/')
# If the .BuildServer directory for TeamCity is located elsewhere on your machine, change this constant to match
TC_BUILDSERVER_CONFIG = File.join(USER_DIR, '.BuildServer', 'config', '**', '*.buildNumbers.properties')
Dir.glob(TC_BUILDSERVER_CONFIG).each do |file|
buffer = File.new(file, 'r').read.gsub(/next.build=\d+/, 'next.build=1')
File.open(file, 'w') { |f| f.write(buffer) }