This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function what(a, b) { | |
if(typeof a != 'number' || | |
typeof b != 'number' || | |
a === 0) { | |
return 0; | |
} | |
const c = a + b; | |
return (c / a) % b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: mongo | |
labels: | |
name: mongo | |
spec: | |
ports: | |
- port: 27017 | |
targetPort: 27017 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ApplicationRecord | |
has_many :posts | |
has_many :comments | |
# id :integer not null, primary key | |
# name :string(50) default("") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |