Skip to content

Instantly share code, notes, and snippets.

@crast
crast / junk removal script.md
Last active June 4, 2022 02:48
Windows junk removal

Windows 10 Junk Removal

This is a powershell script that does a number of things to remove some extra fluff from even fresh windows installs though you can also run it on existing windows installs. If you run this before ever hooking up ethernet and then reboot, you can even avoid Candy Crush etc from showing up in the first place.

I use this script regularly on all new installs but read the script and run at your own risk

Summary

@crast
crast / bashrc.sh
Last active January 31, 2018 05:36
_chpwd() {
if [[ "$PWD" == */src/* || "$PWD" == */src ]]; then
GPNEW=$(echo $PWD | sed -e 's#/src.*##')
elif [ -d src ]; then
GPNEW=`pwd`
fi
if [[ "$GPNEW" != "" && "$GPNEW" != "$GOPATH" ]]; then
export GOPATH="$GPNEW"
echo "GOPATH=$GOPATH"
@crast
crast / fanout_test.go
Created January 27, 2018 21:05
Benchmarking Reflect Channel Ops
// This is a test where I was trying to isolate how much we lost to `reflect`
// with channel operations in a tight loop.
//
// PREAMBLE
// We do a lot of processing of stream data where ordering with respect to a
// shard indicator like user ID matters. We've done this a few times where we
// implement fanout based on hashing into an slice/array of channels, and it's
// lightning fast but it ends up leaving a lot of boilerplate in your code.
//
// So I started writing a library that would do the non-critical boilerplate
package main
import (
"fmt"
"log"
"os"
"os/signal"
cluster "github.com/bsm/sarama-cluster"
)
@crast
crast / instructions.md
Last active September 26, 2017 00:17
multi-consumer-example

run the following:

export CONSUMER_GROUP=temp-1
export TOPICS=topic1,topic2
export ADDRS=host1:9092,host2:9092
export NUM_CONSUMERS=<number of concurrent Consumer to run>
go run multi-consumer-example.go

You'll find that when NUM_CONSUMERS > 1, things get really weird... tried with 30 initially, lowered to 2 to make the logs less spammy, same issue.

@crast
crast / commit-example.go
Created September 21, 2017 20:20
Committer example
package main
import (
"container/heap"
"log"
"time"
"github.com/Shopify/sarama"
"github.com/crast/sarama-cluster"
)
// blahService is the core blah API.
service BlahService {
// Ping operation for determining service health
rpc Ping(PingRequest) returns (PongResponse) {
option (google.api.http) = {
get: "/ping"
};
}
// Write to a range within a single series address
@crast
crast / native_program.py
Last active January 25, 2017 22:56
Native program example
import sys
import struct
import socket
import json
class MyApp(object):
def __init__(self):
self.connection = socket.socket(shit I forgot the parameters)
def main():
package main
import (
"fmt"
"log"
"net/http"
)
/**
* This is a production-ready, horizontally shardable, super fast HTTPS-redirector.
package main
import (
"sync"
"testing"
)
// probably not necessary, but whatever
type message struct {
arbitrary []byte