Skip to content

Instantly share code, notes, and snippets.

Avatar
📚

dk davidk01

📚
View GitHub Profile
View gist:e7a5b23430bad7372fd260faa504bbea
### Keybase proof
I hereby claim:
* I am davidk01 on github.
* I am davidk01 (https://keybase.io/davidk01) on keybase.
* I have a public key ASBAp7jLS00wUB6CUR5imn_GCcQ48FhQnJYnSf_A326URgo
To claim this, I am signing this object:
@davidk01
davidk01 / gitignore
Created Mar 28, 2020
For filesystem diffing with git. Madlad logic.
View gitignore
/proc
/run
/sys
/usr/share/doc
/usr/share/man
/var/backups
/var/cache
/var/lib/apt
/var/lib/dpkg
/var/log
@davidk01
davidk01 / gist:9e0626b1024cfb9f0c2b188b6f8e7a9b
Created Oct 31, 2019
shell commands for interacting with ruby socket kv server
View gist:9e0626b1024cfb9f0c2b188b6f8e7a9b
function start_db {
local -r database="$1"
local -r socket="$2"
pushd "$( dirname "${BASH_SOURCE[0]}" )"
ruby db.rb "${database}" "${socket}"
popd
}
function get_key {
local -r socket="$1"
@davidk01
davidk01 / gist:4320f2e3730f441424cbea93fca4984a
Created Oct 31, 2019
socket base k/v store for simplifying bash scripts and variable export juggling
View gist:4320f2e3730f441424cbea93fca4984a
#!/usr/bin/env ruby
require 'yaml/store'
require 'socket'
require 'base64'
r = ->(s) { Base64.decode64(s.readline).strip }
store = YAML::Store.new('/tmp/store.yaml')
UNIXServer.open('/tmp/yaml') do |server|
loop do
s = server.accept
View cruft-remover.js
function main() {
let exclusions = [
'karaoke', 'salsa', 'formula 1', // Fill this in with your own keywords for filtering
].map(string => { return {str: string, regex: new RegExp(string, 'i')}; });
function remover(node) {
const innerText = node.innerText;
for (let i = 0; i < exclusions.length; i++) {
if (exclusions[i].regex.test(innerText)) {
node.remove();
View app.js
const express = require('express')
const app = express()
const port = 4567
app.get('/', (req, res) => res.send('Node application running in a container'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
@davidk01
davidk01 / ec2-prices.js
Last active May 13, 2018
Shaving the AWS EC2 pricing yak
View ec2-prices.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const https = require("https");
const sqlite = require("sqlite3");
const fs = require("fs");
const priceFile = 'prices.json';
const dbFile = 'prices.db';
function ec2ProductInformation() {
return new Promise((resolve, reject) => {
const baseUrl = `https://pricing.us-east-1.amazonaws.com`;
@davidk01
davidk01 / cert.sh
Created Mar 30, 2018
Generate self-signed certificate
View cert.sh
#!/bin/bash
openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -subj '/CN=localhost'
@davidk01
davidk01 / scrypt.ts
Created Mar 29, 2018
Scrypt derivation and verification functions
View scrypt.ts
import * as scrypt from 'scrypt';
const params = {N: 1, r: 1, p: 1};
export function derive(password: string) {
const key = new Buffer(password);
return new Promise<string>((fulfill, reject) => {
scrypt.kdf(key, params, (error, result) => {
if (error) {
reject(error);
@davidk01
davidk01 / testing-encryption.ts
Created Mar 29, 2018
Testing encryption process
View testing-encryption.ts
import { generatePassword } from './generate-password';
import { encryptFile } from './encrypt-file';
async function main() {
const currentFile = process.argv[1];
try {
const password = await generatePassword();
await encryptFile(currentFile, password);
} catch (error) {
console.log(error);
You can’t perform that action at this time.