Skip to content

Instantly share code, notes, and snippets.

@wcharczuk
wcharczuk / sort.go
Created February 10, 2022 18:21
Generic chained sorter
package sortutil
import (
"constraints"
"sort"
)
// Sort sorts a list of elements by a given list of comparers.
func Sort[T any](elems []T, comparers ...SorterComparer[T]) {
if len(comparers) == 0 {
@wcharczuk
wcharczuk / arasaka.sh
Created November 21, 2021 17:57
Arasaka terminal prompt
#! /bin/sh
echo " ";
echo " .=*#%%%%%%%%%%#+-. ";
echo " :*%@%*=-=*#%##*=-+#%@%+: ";
echo " =@@%=. #@@@@@@@@+ :+%@%- ";
echo " -%@*. #@@@@@@@@@@= :%@#. ";
echo " =@@: :===-.-%@@@@@@@@%::-==-. =@@: .=*#%@@@%#=. *%%%@@@@@@@@@@%%#: .=*#%@@@%#=. -@@@@@*-. -+#%@@@@%*: *%%%- .-+%@@@%####%@@@@%*: "
@wcharczuk
wcharczuk / vscode.json
Created July 24, 2021 15:00
My vscode settings (2021-07-24)
{
"workbench.colorTheme": "GitHub Dark",
"workbench.activityBar.visible": false,
"editor.fontSize": 14,
"editor.minimap.enabled": false,
"editor.lineNumbers": "on",
"editor.lightbulb.enabled": false,
"editor.wrappingStrategy": "simple",
"go.lintTool": "golangci-lint",
// indentation defaults
@wcharczuk
wcharczuk / awair.go
Last active September 27, 2020 21:14
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"os"
@wcharczuk
wcharczuk / sysprom.ini
Created July 2, 2020 19:34
A rainmeter sidebar plugin that shows time/date, network (rx/tx), cpu (histo, core %), ram (histo, in use / total), disk space, disk throughput (histo)
[Rainmeter]
Update=500
AccurateText=1
DynamicWindowSize=1
MiddleMouseDownAction=!Execute [!RefreshApp]
[Metadata]
Name=SysProm
Author=Will Charczuk, based on idk a lot of other themes
Version=1.0
@wcharczuk
wcharczuk / compare.intcode
Created December 8, 2019 06:00
A small intcode example; takes a user input, and returns -1 if its < 8, 0 if its == 8, and 1 otherwise
.limit
.userInput
.temp
add 0 8 .limit
input .userInput
equals &.userInput &.limit .temp
jump-if-false &.temp pc(6)
print 0
jump-if-false 0 sym(-1)
less-than &.userInput &.limit .temp
package main
import (
"encoding/csv"
"fmt"
"io"
"log"
"os"
"strconv"
)
{
// editor stuff
"editor.formatOnSave": true,
"editor.codeLens": false,
"editor.autoClosingBrackets": false,
"editor.quickSuggestionsDelay": 250,
"editor.roundedSelection": false,
"editor.fontFamily": "Source Code Pro",
"editor.fontSize": 13,
"editor.glyphMargin": true,
@wcharczuk
wcharczuk / check.go
Created May 8, 2018 01:51
A very simple healthcheck loop
package main
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
"time"
@wcharczuk
wcharczuk / etcd.service
Created February 20, 2018 04:28
Local Ubuntu etcd systemd service
[Unit]
Description=etcd
Documentation=https://github.com/coreos/etcd
Conflicts=etcd.service
Conflicts=etcd2.service
[Service]
Type=notify
Restart=always
RestartSec=5s