Skip to content

Instantly share code, notes, and snippets.

View ccampo133's full-sized avatar

Chris Campo ccampo133

View GitHub Profile
@ccampo133
ccampo133 / CurrencyFormatting.kt
Last active April 24, 2023 07:38
Currency formatting
import java.math.BigDecimal
import java.text.NumberFormat
import java.util.Currency
import java.util.Locale
fun main(args: Array<String>) {
val locales = listOf(
Locale.FRANCE,
Locale.GERMANY,
Locale.UK,
@ccampo133
ccampo133 / install_helm2.sh
Created April 8, 2020 15:10
Installing Helm 2 on Mac (w/ Homebrew)
brew install helm@2
brew link --force helm@2
@ccampo133
ccampo133 / merge_channels.go
Created September 12, 2022 19:19
Generic function to merge multiple channels into a single channel (fan-in)
package main
import (
"sync"
)
// Adapted from https://go.dev/blog/pipelines
func mergeChannels[T any](channels ...<-chan T) chan T {
var wg sync.WaitGroup
wg.Add(len(channels))
@ccampo133
ccampo133 / ULID.kt
Last active August 24, 2022 19:06
ULID in Kotlin
/**
* Adopted from https://github.com/JonasSchubert/kULID
*
* MIT License
*
* Copyright (c) 2021 GuepardoApps (Jonas Schubert), Christopher J. Campo
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@ccampo133
ccampo133 / CHANGE_MAC_COMPUTER_NAME.md
Last active May 2, 2022 14:50
Change Mac computer and host name

Change a Mac computer name:

sudo scutil --set ComputerName "newname"
sudo scutil --set LocalHostName "newname"
sudo scutil --set HostName "newname"
dscacheutil -flushcache

Reboot.

@ccampo133
ccampo133 / README.md
Created May 4, 2021 21:21
SQS Exponential Backoff

Usage

I recommend using a virtualenv:

$ python -m venv venv
# ... assuming that 'python' points to a Python 3.7 installation

Then activate it:

$ source venv/bin/activate

@ccampo133
ccampo133 / InfiniteRetry.kt
Last active January 20, 2021 04:13
Infinite retry with exponential backoff in Kotlin using co-routines
/**
* Copyright 2018 C.J. Campo
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@ccampo133
ccampo133 / bbpr
Last active July 10, 2020 14:38
Script to create Bitbucket Cloud PR
#!/usr/bin/env sh
# Create a Bitbucket Cloud PR from the command line. Expects the following
# environment variables:
# * BITBUCKET_CLIENT_ID
# * BITBUCKET_CLIENT_SECRET
#
# These can be obtained by creating a Bitbucket "OAuth Consumer". See:
# https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud
#
@ccampo133
ccampo133 / dynamic_version.md
Created May 11, 2020 15:28
Dynamically set a Maven project version from the command line

Here's a little trick to set a Maven project's version from the command line and environment variables, using a build profile.

Assuming your POM looks something like this:

<artifactId>example</artifactId>
<version>${project.version}</version>
...
<properties>
 1.0.0
#!/bin/bash
sophosPID=$(ps -ax | grep Sophos | awk '{print $1}')
kill -9 $sophosPID
sudo rm -R /Library/Sophos\ Anti-Virus/
sudo rm -R /Library/Application\ Support/Sophos/
sudo rm -R /Library/Preferences/com.sophos.*
sudo rm /Library/LaunchDaemons/com.sophos.*
sudo rm /Library/LaunchAgents/com.sophos.*