Skip to content

Instantly share code, notes, and snippets.

@et4te
et4te / rust-nightly.nix
Created December 11, 2015 17:30
This works because it downloads rust dist rather than rustc
{ stdenv, lib, fetchzip, zlib }:
# rustc and cargo nightly binaries
let
target = if stdenv.system == "i686-linux"
then "i686-unknown-linux-gnu"
else if stdenv.system == "x86_64-linux"
then "x86_64-unknown-linux-gnu"
else if stdenv.system == "i686-darwin"
@et4te
et4te / rust-nightly.nix
Created December 11, 2015 17:47
Final variant
{ stdenv, lib, fetchzip, zlib }:
# rustc and cargo nightly binaries
let
target = if stdenv.system == "i686-linux"
then "i686-unknown-linux-gnu"
else if stdenv.system == "x86_64-linux"
then "x86_64-unknown-linux-gnu"
else if stdenv.system == "i686-darwin"
@et4te
et4te / generate_keys.rs
Created March 28, 2017 17:19
JWK Rust Simple RSA
#[macro_use] extern crate serde_derive;
extern crate rustc_serialize;
extern crate openssl;
extern crate dotenv;
extern crate serde;
extern crate serde_json;
use rustc_serialize::base64::{self, ToBase64};
use std::path::Path;
@et4te
et4te / perfomEventAsync.hs
Last active August 26, 2017 14:08
An example of performEventAsync use Reflex
performHash :: (MonadWidget t m) => (Either String Hash -> IO ()) -> Event t Text -> m (Event t (Either String Hash))
performHash cb e = do
evHash <- performEventAsync $ ffor e $ \p cb -> void $ newHash p $ liftIO . cb
return evHash
where
newHash p = liftIO . hash (defaultOptions p "some_salt")
#[derive(Debug)]
enum BinaryTree<T: Ord> {
Leaf {
lhs: Box<BinaryTree<T>>,
rhs: Box<BinaryTree<T>>,
val: (T, Value),
},
Empty,
}
@et4te
et4te / salsa20_hash.rs
Created October 5, 2017 19:25
salsa20
#![feature(slice_patterns)]
pub fn quarter_round(y: [u32; 4]) -> [u32; 4] {
let z1 = y[1] ^ (y[0].wrapping_add(y[3])).rotate_left(7);
let z2 = y[2] ^ (z1.wrapping_add(y[0])).rotate_left(9);
let z3 = y[3] ^ (z2.wrapping_add(z1)).rotate_left(13);
let z0 = y[0] ^ (z3.wrapping_add(z2)).rotate_left(18);
[z0, z1, z2, z3]
}
@et4te
et4te / install_nix.md
Last active June 23, 2018 17:14
Preparing for betanet launch with Nix and the Ledger Nano S

Preparing for betanet launch with Nix and Ledger Nano S

This guide is for users of the Nix package manager and assumes you have a Ledger Nano S updated with the latest firmware (at this time 1.4.2).

NOTE If you are not on NixOS, skip the sections which have NixOS at the start of the heading.

NixOS Binary Cache Configuration

To hasten the build process (it could take days to build without this), add the following to /etc/nixos/configuration.nix if you are on NixOS.

@et4te
et4te / htlc.ml
Last active August 5, 2018 09:36
Tezos Atomic Swap
[%%version 0.3]
type storage =
{ version : string;
secret_hash : bytes;
issuer : address;
issuer_hash : key_hash;
recipient_hash : key_hash;
timeout : timestamp;
}
@et4te
et4te / michelson-mode.el
Created August 4, 2018 16:40
Removed lexical-lets from the source (doesn't work on later versions of emacs than 24.1)
;; Major mode for editing Michelson smart contracts.
(require 'cl-lib)
(require 'deferred)
(require 'font-lock)
(defvar michelson-mode-hook nil)
(defgroup michelson nil
"Major mode for editing Michelson smart contracts."
@et4te
et4te / timeout.ml
Created December 12, 2018 01:29
Times out if can't read
open Lwt
open Lwt_unix
let read fd =
let maxlen = 1024 in
let buf = Bytes.create maxlen in
Lwt.catch
(fun _ ->
Lwt_log.info "reading" >>= fun () ->
Lwt.pick [