Skip to content

Instantly share code, notes, and snippets.

View haf's full-sized avatar
💹
currently succeeding...

Henrik Feldt haf

💹
currently succeeding...
View GitHub Profile
@haf
haf / LICENSE
Last active February 14, 2024 11:15
Setting up a digitalocean proxy
https://www.gnu.org/licenses/gpl-3.0.en.html
GNU GENERAL PUBLIC LICENSE v3
@haf
haf / Colourized PowerShell
Created October 25, 2011 16:18
Colourized PowerShell ls command
#First in your powershell profile in
#C:\Users\<<username>>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
set-location D:\code
. "C:\Users\<<username>>\Documents\WindowsPowerShell\Get-ChildItemColor.ps1" # read the colourized ls
set-alias ls Get-ChildItemColor -force -option allscope
function Get-ChildItem-Force { ls -Force }
set-alias la Get-ChildItem-Force -option allscope
#Then in:
namespace ChironB.Benchmarks
open Chiron
open BenchmarkDotNet.Attributes
open Newtonsoft.Json
open Newtonsoft.Json.Linq
module Bench =
open System.IO
open System.Text
@haf
haf / install-git.sh
Created August 22, 2012 14:38
Installing git and git-subtree from source in ubuntu as packages
# use with: curl -L https://raw.github.com/gist/3426227 | bash
# get git binary, then git with git
sudo apt-get install git -y
git clone https://github.com/git/git.git
# remove your binary/package
sudo apt-get remove git -y
sudo apt-get install make checkinstall libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc -y
@haf
haf / gist:2843680
Created May 31, 2012 14:19
Get SSH working on Vagrant/Windows/Git

If you are using vagrant, you probably-statistically are using git. Make sure you have its binary folder on your path, because that path contains 'ssh.exe'.

Now, modify C:\vagrant\vagrant\embedded\lib\ruby\gems\1.9.1\gems\vagrant-1.0.3\lib\vagrant\ssh.rb to comment out the faulty Windows check and add a real SSH check:

# if Util::Platform.windows?
  # raise Errors::SSHUnavailableWindows, :host => ssh_info[:host],
                                       # :port => ssh_info[:port],
                                       # :username => ssh_info[:username],
 # :key_path =&gt; ssh_info[:private_key_path]
@haf
haf / consul-cluster.md
Created February 10, 2017 16:02
Getting a broken consul cluster up

Consul: 0.7.2

You may have crashed your cluster so that all Consul servers have been offline at some point. You may be running on Kubernetes. The default 96 hours didn't pass, so there was no reaping of Consul servers. Restarting it all doesn't work. You've read this issue five times over and nothing works. On top of it all, which makes it harder, you're running a StatefulSet on Kubernetes, so you need to do kubectl delete pods/consul-1 to make the container arguments (kubectl replace consul/consul.yml) bite. On top of this, if you kubectl exec -it consul-1 and then kill -9 5, Kubernetes goes into a crash loop with exponential backoff, eating into your time.

Sounds like a Friday pleasure, right?

The tools you have at your disposal are:

  • -bootstrap
  • kubectl replace consul/consul.yml
@haf
haf / gist:412666c5d230528e610f8353a15d9d79
Last active April 29, 2020 12:41
My YAML snippet in vscode for kubernetes
{
// Place your snippets for yaml here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"kind: PodDisruptionBudget": {
"prefix": "poddisruptionbudget",
"body": [
"apiVersion: policy/v1beta1",
@haf
haf / dirprofile.plugin.zsh
Last active September 21, 2019 09:08
Dirprofile ZSH plugin — loads a different script depending on active directory
# Similar to https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/profiles/profiles.plugin.zsh
# but adapted to suit my needs; basically, source the profile or dotfile if it exists:
# cd ~/dev/qv2
# => /Users/h/.oh-my-zsh/custom/profiles/qv2
# => /Users/h/.oh-my-zsh/custom/profiles/dev.qv2
# => /Users/h/.oh-my-zsh/custom/profiles/h.dev.qv2
# => /Users/h/.oh-my-zsh/custom/profiles/Users.h.dev.qv2
# cd ~/dev/qv2
@haf
haf / circularBuffer.js
Last active February 23, 2019 19:18
Circular buffer in JS
import { List } from "immutable";
export default class CircularBuffer {
constructor(capacity) {
if (capacity < 1) {
throw new Error("Invalid argument: capacity; must ≥1")
}
this.len = 0 // tracks current size
this.pos = 0 // points to most recent value
this.capacity = capacity
@haf
haf / Dockerfile
Last active January 27, 2019 13:18
Using multi-stage docker build with smart caching of dependencies
FROM microsoft/dotnet:2.2-sdk as build
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y locales && \
locale-gen C C.UTF-8 && \
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales && \
DEBIAN_FRONTEND=noninteractive apt-get install -y git vim libczmq4 libprotobuf-c-dev libprotobuf-dev libprotobuf10 ca-certificates
ENV LC_ALL=C.UTF-8
WORKDIR /build/
COPY paket.dependencies paket.lock ./