Skip to content

Instantly share code, notes, and snippets.

View smartinov's full-sized avatar
🦉
Causing Problems

Stefan Martinov smartinov

🦉
Causing Problems
View GitHub Profile
@smartinov
smartinov / vaut-server.sh
Last active February 5, 2018 10:18
Initialize and unlock a local vault instance
#!/usr/bin/env bash
# Starts or stops a new vault instance
# Example: vault-server.sh start vaults/production ${VAULT_KEY} ${VAULT_TOKEN}
# Parameters:
# $1 - (start/stop)
# $2 - Directory where the vault is located
# $3 - Vault Key
# $4 - Vault Token
@smartinov
smartinov / gist:645135216a20df8cf27184b8073c612c
Created July 21, 2017 11:14
Hashicorp Local Filesys .gitignore
# Ignores local-generated files for hasicorp vault
**/db/sys/policy
**/db/sys/accessor
**/db/core/cluster
**/db/core/wrapping
**/db/core/_local*
@smartinov
smartinov / RandomEnum.java
Created November 28, 2016 08:39
java random enum
import java.util.Random;
public class RandomEnum {
public static <T extends Enum<?>> T from(Class<T> clazz) {
int x = new Random().nextInt(clazz.getEnumConstants().length);
return clazz.getEnumConstants()[x];
}
}
@smartinov
smartinov / microsoft-hex-guid
Last active January 5, 2016 14:16
Microsoft Python HexToGuid and GuidToHex
def hex_to_guid(hex):
swapper = lambda A, n=2: [A[i:i + n] for i in range(0, len(A), n)]
segments = [hex[0:8], hex[8:12], hex[12:16], hex[16:20], hex[20:]]
for i in xrange(3):
segments[i] = "".join(list(reversed(swapper(segments[i]))))
return "-".join(segments)
def guid_to_hex(guid):
swapper = lambda A, n=2: [A[i:i + n] for i in range(0, len(A), n)]