Skip to content

Instantly share code, notes, and snippets.

View komuw's full-sized avatar

Komu Wairagu komuw

View GitHub Profile
@komuw
komuw / install NVM and nodeJS.yml
Created November 20, 2014 17:40
Ansible task to install nvm and nodeJS
#first seen here: http://www.snip2code.com/Snippet/63701/Ansible-task-to-install-nvm-and-node
# Here is how to install nvm and node in an Ansible task.
# I tried a bunch of different things, and as usual it's simple, but you have to get it right.
# The important part is that you have to shell with /bin/bash -c and source nvm.sh
---
- name: Install nvm
shell: >
curl https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh
creates=/home/{{ ansible_user_id }}/.nvm/nvm.sh
@komuw
komuw / erasure_encoding.go
Last active August 3, 2023 08:40
use erasure encoding to survive data loss
package main
import (
"fmt"
"os"
"github.com/klauspost/reedsolomon"
)
// You can use erasure encoding to;
@komuw
komuw / pycrypto_DES3.py
Last active March 28, 2023 06:35
python DES3(triple DES encryption)
`pip install pycrypto`
from Crypto.Cipher import DES3
from Crypto import Random
key = 'Sixteen byte key'
iv = Random.new().read(DES3.block_size) #DES3.block_size==8
cipher_encrypt = DES3.new(key, DES3.MODE_OFB, iv)
plaintext = 'sona si latine loqueri ' #padded with spaces so than len(plaintext) is multiple of 8
encrypted_text = cipher_encrypt.encrypt(plaintext)
@komuw
komuw / python_named_pipe.py
Created November 1, 2018 15:23
python named pipe
import os
import errno
import time
"""
The linux pipe buffers are implemnted as circular buffers[1].
A consequence of the circular buffer is that when it is full and a subsequent write is performed:
(a) then it starts overwriting the oldest data[2].
(b) Alternatively, the routines that manage the buffer could prevent overwriting the data and return an error or raise an exception.
@komuw
komuw / terminal_VPN_client
Last active November 26, 2022 21:53
commandline VPN client
If for any reason you don't have a GUI VPN client(you like running headless ubuntu
or have ubuntu installed on a chromebook). You can use vpnc as a command line VPN client
#this is a comment
#install vpnc
$ sudo apt-get install network-manager-vpnc
#look to see if you have vpnc installed
$ sudo vpnc --help #use sudo to run vpnc command
#if not installed, install it:
$ sudo apt-get install vpnc
@komuw
komuw / fake_crd.yaml
Created November 16, 2022 17:26
fake crd status/health
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: komucrontabs.stable.example.com
spec:
# group name to use for REST API: /apis/<group>/<version>
group: stable.example.com
# list of versions supported by this CustomResourceDefinition
versions:
@komuw
komuw / encrypt_decrypt.go
Last active July 6, 2022 19:32
encrypt and decrypt in Go
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"errors"
"fmt"
@komuw
komuw / rabbit_pash_hash.py
Created May 2, 2017 00:51 — forked from lukebakken/rabbit_pash_hash.py
rabbitMQ password hashing algo
# rabbitMQ password hashing algo as laid out in: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-May/012765.html
from __future__ import print_function
import base64
import os
import hashlib
import struct
# This is the password we wish to encode
password = 'simon'