Skip to content

Instantly share code, notes, and snippets.

Avatar

Hans Roman snahor

  • Wakanda
View GitHub Profile
@mholt
mholt / keypairs.js
Created Jun 25, 2021
Generate key pairs and PEM-encode them using vanilla JS and browser Crypto API
View keypairs.js
//
// Convert an ArrayBuffer into a string.
// From https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
function arrayBufToString(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
}
function pemEncode(label, data) {
const base64encoded = window.btoa(data);
@seratch
seratch / go.mod
Last active Mar 25, 2022
Slack Socket Mode in Go
View go.mod
module socket-mode-app
go 1.15
require github.com/slack-go/slack v0.8.0
@nevesnunes
nevesnunes / set-tmux-title.sh
Created Jul 6, 2020 — forked from florianbeer/set-tmux-title
Set tmux pane title to short hostname on ssh connections
View set-tmux-title.sh
ssh() {
# grep -w: match command names such as "tmux-2.1" or "tmux: server"
if ps -p $$ -o ppid= \
| xargs -i ps -p {} -o comm= \
| grep -qw tmux; then
# Note: Options without parameter were hardcoded,
# in order to distinguish an option's parameter from the destination.
#
# s/[[:space:]]*\(\( | spaces before options
# \(-[46AaCfGgKkMNnqsTtVvXxYy]\)\| | option without parameter
View clusters.makefile
# Cluster management tools.
# See https://github.com/grampelberg/k8s-clusters for updates and documentation.
export CLUSTER_NAME ?= $(shell cat tmp/current 2>/dev/null || echo $$(whoami)-dev)
export MACHINE_TYPE ?= n1-standard-2
export DISK_SIZE ?= 100
export MAX_NODES ?= 10
export NETWORK ?= dev
export PROJECT ?= foobar
export VERSION ?= latest
View stack-elastic.yml
# Maintainer: Jakub Hajek, jakub.hajek@cometari.com
#
# docker stack deploy -c stack-elastic.yml elastic
#
# The stack creates Elasticsearch cluster consiting of
# - 3 dedicated master nodes in order to keep quorum
# - 4 dedicated data nodes to manage CRUD,
# - 2 coordination node acting like kind of load balancer in multi instance environments
#
#
View ffreplaygain.sh
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set +e
ffmpeg -version > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "ffmpeg must be installed"
exit 1
fi
@NotMedic
NotMedic / Instructions.txt
Created Dec 2, 2018
Siri -> HomeBridge -> HomeBridge-ssh -> iptables
View Instructions.txt
This is a pretty simple setup:
Siri is used to control Homebridge using the HomeKit protocol.
Homebridge has a module named Homebridge-ssh that allows you to run commands over ssh.
There is a shell script on an OpenWrt box to enable, disable, and check the status of a MAC Address block in the FORWARD table.
1. Install node on your platform. I went with 8.9 for no specific reason other than I initially had issues with 10 that probably weren't related..
2. Install homebridge and homebridge-ssh. You should probably also put hombridge-config-ui-x on there too... I used the unsafe-perm parameter after getting a significant number of errors:
sudo -i npm install -g homebridge --unsafe-perm
sudo -i npm install -g homebridge-ssh --unsafe-perm
View jwtex_test.go
package jwtex
import (
"encoding/base64"
"encoding/json"
"fmt"
"strings"
"testing"
)
@elritsch
elritsch / export-node-stats.md
Last active May 6, 2022
Setup prometheus-node-exporter and push stats to Pushgateway with cron job
View export-node-stats.md

(Assuming a Debian 8-like system)

  • Install prometheus-node-exporter

    $ sudo apt update && sudo apt install prometheus-node-exporter
  • Configure prometheus-node-exporter to expose metrics only to localhost, not on to all networks. Modify file /etc/default/prometheus-node-exporter:

Set the command-line arguments to pass to the server.

@kentcdodds
kentcdodds / create-required-context.js
Created May 15, 2018
create react context that has a validated consumer.
View create-required-context.js
// create a React context Provider/Consumer pair that
// validates the consumer is rendered within a provider
function createRequiredContext(name) {
const Context = React.createContext()
function Consumer(props) {
return (
<Context.Consumer {...props}>
{val => {
if (!val) {