Skip to content

Instantly share code, notes, and snippets.

@lalyos
lalyos / etcd-list-keys.md
Last active March 27, 2023 10:40
k8s etcd list keys
View etcd-list-keys.md

You can demostrate how kubernetes stores everything in etcd (v3):

One-liner

You can exec etcdctl rigth in the etc pod:

kubectl exec -it \
  -n kube-system etcd-minikube \
  -- sh -c 'ETCDCTL_CACERT=/var/lib/localkube/certs/etcd/ca.crt \
 ETCDCTL_CERT=/var/lib/localkube/certs/etcd/peer.crt \
@lalyos
lalyos / save-all-images.sh
Created November 21, 2014 20:43
script to save all docker image, and load them back
View save-all-images.sh
reload() {
source ${BASH_SOURCE[0]}
}
alias r=reload
get-image-field() {
local imageId=$1
local field=$2
: ${imageId:? reuired}
@lalyos
lalyos / README.md
Last active February 28, 2023 03:38
proxy docker /var/run/docker.sock to port 2375 with socat
View README.md

The new Docker daemon uses port: 2376 with TLS enable by default. Sometimes I want to play with curl on the old plain http port 2375. The trick is: use socat in a container to proxy the unix socket to a real port.

docker run -d \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --name docker-http \
  deb socat -d -d TCP-L:2375,fork UNIX:/var/run/docker.sock
@lalyos
lalyos / README.md
Last active December 16, 2022 11:44
install golang to ubuntu/debian one-linet
View README.md

Install latest golang

curl -Ls http://bit.ly/go_installer | bash

Overview

If you want to install golang, normally you are following the description on the official dowload page

@lalyos
lalyos / README.md
Last active October 19, 2022 15:39
Recording bash's standard out
View README.md

If you want to store all stdout while runing an interactive bash:

Install

curl -Lo /usr/local/bin/cybash https://gist.githubusercontent.com/lalyos/94cef8ca8bb3087387312f7f3e775e3b/raw/cybash
chmod +x /usr/local/bin/cybash

Usage

@lalyos
lalyos / Dockerfile
Last active October 19, 2022 05:50
Test figlets
View Dockerfile
FROM alpine
RUN apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing lolcat curl
CMD curl -sL https://gist.githubusercontent.com/lalyos/99341041e6b513a05ac945c897ef518e/raw/network.txt | lolcat
@lalyos
lalyos / README.md
Last active September 30, 2022 13:32
LZ-string decoder in go flems.io
View README.md

LZ-string decoder in go

I was playing with https://flems.io/ and wondered how it stores data.

  • locally it uses localstorage
  • but state is preserved in url (bookmarkable POC)

Example link: http://flems.io

Usage

@lalyos
lalyos / sudo-forever.sh
Created November 13, 2014 11:41
sudo forever
View sudo-forever.sh
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
@lalyos
lalyos / index.html
Created March 28, 2022 10:17
JS Countdown Timer
View index.html
<div id="app"></div>
@lalyos
lalyos / index.pug
Created March 27, 2022 19:21
Quick pure CSS counter
View index.pug
- let d = 100, o = -.5*d;
- let sw = .1*d, r = .5*(d - sw);
- let len = 2*Math.PI*r;
.countdown
svg(viewBox=[o, o, d, d].join(' ') stroke-width=sw)
circle(r=r)
circle(r=r stroke-dasharray=len stroke-dashoffset=`${len}px`)