Skip to content

Instantly share code, notes, and snippets.

@CjS77
CjS77 / day4.txt
Created December 4, 2020 07:37
Day 4 input
hcl:#6b5442 ecl:brn iyr:2019
pid:637485594 hgt:171cm
eyr:2021 byr:1986
eyr:2025 iyr:1938 byr:2014 hcl:#341e13
hgt:66cm
pid:70195175
hcl:#efcc98
iyr:2011 ecl:hzl
@CjS77
CjS77 / key_sign.js
Created February 5, 2020 10:02
Node.js use of tari crypto
let tari_crypto = require('./pkg');
let assert = require('assert');
let KeyRing = tari_crypto.KeyRing;
console.log(`Tari crypto. Version ${tari_crypto.version()}`);
// The WASM module holds the keys in a vector (keyring), which means that we can get at all the cryptoey goodness
// without having to expose tons of functions with unsafe pointers, or continuously do de- and serialisation to hex
// or base64.
const keys = KeyRing.new();
@CjS77
CjS77 / futures.py
Last active December 12, 2019 08:03
Python futures demo
import urllib.request
import concurrent.futures
import time
# Takes a url, downloads the content, then does something with it. Returns
# True if everything went fine
def process_web_request(url):
try:
with urllib.request.urlopen(url) as response:
html = response.read()
@CjS77
CjS77 / main.rs
Last active April 9, 2019 14:00
Raid ID demo
use tari_crypto::{
ristretto::{RistrettoSecretKey, RistrettoPublicKey, RistrettoSchnorr},
keys::{PublicKey, SecretKey},
challenge::{Challenge},
common::*,
};
use tari_utilities::*;
use digest::Digest;
use rand::rngs::OsRng;
@CjS77
CjS77 / raid_id.py
Created March 12, 2019 09:05
Proposed RAID_ID algorithm
# -*- coding: utf-8 -*-
from hashlib import blake2b
import bitcoin.base58 as base58
import string
import random
def create_raid(fqdn = None, prefix=0x62):
s = fqdn if fqdn else "NO_FQDN"
b = bytes(map(ord, s))
hash = blake2b(b, digest_size=10).digest()
@CjS77
CjS77 / Cargo.toml
Last active January 24, 2019 21:27
You can't use Curve25519 as is for Pederson commitments
[package]
name = "dalek-demo"
version = "0.1.0"
authors = ["CjS77"]
edition = "2018"
[dependencies]
digest = "0.7.6"
rand = "0.5.5"
curve25519-dalek = "1.0.2"
pub trait Commitable<Class=Self:Insertable> {
type Committed:Queryable, table;
pub fn commit(&self, conn: PgConnection) -> Result<Committed,DatabaseError> {
DatabaseError::wrap(diesel::insert_into(table).values(self).get_result(conn))
}
}
#[derive(Queryable)]
struct Artist {..}
@CjS77
CjS77 / githide.sh
Created July 2, 2018 09:36
Add intelliJ files to git/.exclude to avoid polluting .gitignore
#!/bin/bash
# I stick this in ~/.local/bin (which is part of my path), then simply running `githide` in the project folder
# will clean up your git status
echo ".DStore" >> .git/info/exclude
echo ".idea" >> .git/info/exclude
echo "*.iml" >> .git/info/exclude

Keybase proof

I hereby claim:

  • I am CjS77 on github.
  • I am cayle (https://keybase.io/cayle) on keybase.
  • I have a public key whose fingerprint is 22EB C075 EEC6 FE54 98BE FC51 3EB1 1AD2 06A4 2CF1

To claim this, I am signing this object:

@CjS77
CjS77 / cascade.js
Created January 7, 2016 11:52
Loopback cascade mixin gist
/* jshint node:true */
'use strict';
/**
* There is an incubating feature to cascade the deletes to the relational tables. see
* https://github.com/strongloop/loopback-datasource-juggler/issues/88
*/
var lazy = require('lazy.js');
var async = require('async');
var log = require('debug')('mixins:cascade');