Skip to content

Instantly share code, notes, and snippets.

View theothertomelliott's full-sized avatar

Tom Elliott theothertomelliott

View GitHub Profile
@theothertomelliott
theothertomelliott / otel_filter_grpc_healthchecks.go
Created November 13, 2022 00:13
How to filter gRPC health checks from opentelemetry incerceptors
import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/filters"
// ...
grpc.UnaryInterceptor(
otelgrpc.UnaryServerInterceptor(
otelgrpc.WithInterceptorFilter(
filters.Not(
filters.HealthCheck(),
@theothertomelliott
theothertomelliott / actiontiming.yaml
Created August 1, 2020 16:46
GitHub Actions Workflow to record scheduled action timing
name: 'Scheduled'
on:
schedule:
- cron: '*/5 * * * *'
jobs:
scheduled:
name: Scheduled Job
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
@theothertomelliott
theothertomelliott / migrate-gitrepo.sh
Last active April 29, 2020 16:54
Migrate a Git repo
#!/bin/sh
# Source and Destination as parameters
SRC=$1
DST=$2
# Clone source repo into a working directory
git clone $SRC working
cd working
@theothertomelliott
theothertomelliott / listeningports.go
Last active September 6, 2016 00:17
Get a list of ports open on the current host
package main
import (
"fmt"
"github.com/shirou/gopsutil/net"
"github.com/shirou/gopsutil/process"
)
func main() {
@theothertomelliott
theothertomelliott / sharedInstanceMethod.m
Created September 28, 2015 20:57
Thread-safe Objective-C singleton sharedInstance method.
+ (instancetype)sharedInstance {
static id sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[[self class] alloc] init];
});
return sharedInstance;
}
@theothertomelliott
theothertomelliott / XcodePackages.md
Last active October 6, 2015 18:32
List of handy Xcode Packages

A package manager for Xcode that you can use to manage installation of all subsequent packages.

Create stubs for Javadoc method documentation automatically. Just type "///"!

@theothertomelliott
theothertomelliott / AsyncTestingPrimer.m
Created September 8, 2015 16:25
A primer for testing asynchronous calls with XCTest in Objective-C
#import <XCTest/XCTest.h>
@interface AsyncTestingPrimer : XCTestCase
@end
@implementation AsyncTestingPrimer
/*
* This is how not to test async calls
@theothertomelliott
theothertomelliott / Add Border to UIViews
Created August 31, 2015 16:27
How to add a border to a UIView programatically. This is extremely handy for debugging view layouts. Example in both Swift and Objective-C.
// Objective-C
view.layer.borderColor = [UIColor redColor].CGColor;
view.layer.borderWidth = 3.0f;
// Swift
view.layer.borderColor = UIColor.redColor().CGColor;
view.layer.borderWidth = 3.0f;
@theothertomelliott
theothertomelliott / PrettyRainbowUITableView.m
Last active August 29, 2015 14:27
Pretty Rainbow UICollectionView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Get your cell here
cell.backgroundColor = [UIColor colorWithHue:(float)indexPath.row/[collectionView numberOfItemsInSection:indexPath.section] saturation:0.8 brightness:1 alpha:1];
// Do more stuff here
}