Skip to content

Instantly share code, notes, and snippets.

View austbot's full-sized avatar
😶‍🌫️

austbot austbot

😶‍🌫️
View GitHub Profile
import { Injectable, Inject } from '@angular/core';
@Injectable()
export class SecretService {
constructor( @Inject('ENcRYPTI0n_k3y') private key: string) {}
//public api
encode(secret: string) {
return SecretService._encodeSecret(this.key, secret);
}
function what(a, b) {
if(typeof a != 'number' ||
typeof b != 'number' ||
a === 0) {
return 0;
}
const c = a + b;
return (c / a) % b;
}
function what(a, b) {
const c = a + b;
return (c / a) % b;
}
function whatRunner(numberOfTimes, multiplier) {
const runs = [];
for(let i = 1; i <= numberOfTimes; i++) {
runs.push(what(i, multiplier * i));
}
@austbot
austbot / no_db.rb
Last active February 16, 2018 04:47
# Encrypt
key = ENV.fetch("THE_KEY_TO_MY_DATA")
binary_key = key.unpack('m')[0] #decode the base64edness of the thing
box = RbNaCl::SecretBox.new(binary_key)
nonce = RbNaCl::Random.random_bytes(box.nonce_bytes) # it feels cool to say nonce, feels like I know what I'm talking about.
payload = {"some":"hash","with":"some","data":"in it"}.to_json #doesnt have to be json, but some sort of string is nice
compress_that_junk = Zlib::Deflate.deflate(payload)
encrypted_junk = box.encrypt(nonce, compress_that_junk)
token = "#{[nonce].pack('m')}:#{[encrypted_junk].pack('m')}"
#Decrypt
@austbot
austbot / yay_a_key_in_a_file.rb
Created February 16, 2018 04:26
rbnacl store private key
#option 1
key = RbNaCl::Random.random_bytes(RbNaCl::SecretBox.key_bytes) # bunch of bytes
[key].pack('m') # outputs a base64 encoded string
#option 2
Base64.encode64(key)
@austbot
austbot / how_do_i_store_this.rb
Created February 16, 2018 04:23
rbnacl private key
key = RbNaCl::Random.random_bytes(RbNaCl::SecretBox.key_bytes) # bunch of bytes
secret_box = RbNaCl::SecretBox.new(key) #This works
#But
key = ENV.fect("PRIVATE_KEY")
secret_box = RbNaCl::SecretBox.new(key) # blah blah blach errors
@austbot
austbot / Mongo.yml
Created October 26, 2017 16:17
Mongo Db as a Statefulset, Kube 1.8
apiVersion: v1
kind: Service
metadata:
name: mongo
labels:
name: mongo
spec:
ports:
- port: 27017
targetPort: 27017
@austbot
austbot / 1_user.rb
Last active August 23, 2017 07:26 — forked from ericktai/1_user.rb
class User < ApplicationRecord
has_many :posts
has_many :comments
# id :integer not null, primary key
# name :string(50) default("")
end
//Proprietary info removed
public class DockerRunTask {
public static DockerRunContainerTask get(String name, String image, String command, Optional<String> args) {
String name = String.format("&s - %s", name, command);
DockerRunContainerTask drt = new DockerRunContainerTask()
.description(name)
.containerName(name)
.containerCommand(String.format("%s", command))
.imageName(image)
mkdir -p /opt/scala
cd /opt/scala
wget https://downloads.typesafe.com/scala/2.11.6/scala-2.11.6.tgz
mkdir /usr/lib/scala
tar -xf scala-2.11.6.tgz -C /usr/lib/scala
rm scala-2.11.6.tgz
ln -s /usr/lib/scala/scala-2.11.6/bin/scala /bin/scala
ln -s /usr/lib/scala/scala-2.11.6/bin/scalac /bin/scalac