Skip to content

Instantly share code, notes, and snippets.

@edwardw
edwardw / App.purs
Last active November 24, 2023 09:45
First draft of R3F purescript binding show case
e
import Prelude
import Data.Function.Uncurried (mkFn3)
import Data.Int (toNumber)
import Data.Number (abs, cos, pi, sin)
import Data.Tuple.Nested ((/\))
import Effect.Uncurried (runEffectFn1, runEffectFn2)
import React.Basic (empty)
@edwardw
edwardw / PasswordManager.purs
Created March 8, 2020 08:06
PureScript Run is fun
-- https://haskell-explained.gitlab.io/blog/posts/2019/07/28/polysemy-is-cool-part-1/
module PasswordManager where
import Prelude
import Data.Map (Map)
import Data.Map as M
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Node.Crypto.Hash (Algorithm(..), base64)
@edwardw
edwardw / adapter.rs
Last active December 29, 2019 15:07
AsyncRead adapter
//# bytes = "0.5"
//# futures = "0.3"
//# tokio = { version = "0.2", features = ["stream", "io-util"] }
//# tokio-util = { version = "0.2", features = ["codec"] }
mod adapter {
use futures::io as fio;
use std::{
pin::Pin,
task::{Context, Poll},
};
@edwardw
edwardw / Cargo.toml
Created December 20, 2019 14:42
Cycle a Rust iterator a given number of times
[package]
name = "cycle_n"
version = "0.1.0"
authors = ["whoever"]
edition = "2018"
[dependencies]
[dev-dependencies]
criterion = "0.3"
@edwardw
edwardw / gist:7587876
Created November 21, 2013 19:20
Boot to Rust in OS X

Booting to Rust by Eric Holk! It is just mind-bogglingly cool. What else can I say? His enhancement to Rust has been landed so it is time for me to try that out, in OS X. The setup of the toolchain could be a little bit challenging.

First and foremost, check out the latest Rust with win64 calling convention contributed by Eric Holk and build it.

Then prepare the cross linker.

$ wget http://ftpmirror.gnu.org/binutils/binutils-2.23.2.tar.gz
$ tar xvzf binutils-2.23.2.tar.gz
$ cd binutils-2.23.2
$ mkdir dist
@edwardw
edwardw / ClassHierarchy.java
Last active December 21, 2016 02:56
Determine java class hierarchies programmatically
import java.io.File;
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.*;
import javax.lang.model.element.*;
import javax.tools.*;
import com.sun.source.tree.*;
import com.sun.source.util.*;
@edwardw
edwardw / gist:1518116
Last active June 8, 2016 15:52
Install and start storm nimbus and supervisor

First, install storm dependencies. How do I compile jzmq for ZeroMQ on OSX? helps.

$ brew install zeromq
$ git clone https://github.com/nathanmarz/jzmq.git
$ cd jzmq
$ sudo vim /usr/share/aclocal/dirlist (sudo cat > /usr/share/aclocal/dirlist permission denied?)
/usr/local/share/aclocal
/usr/local/Cellar/pkg-config/0.25/share/aclocal/
$ export JAVA_HOME=/Library/Java/Home
@edwardw
edwardw / rust_tasks_and_macros.md
Last active December 15, 2015 00:59
Go Concurrency Challenge in Rust

An adaption of Leah Hanson's solution using Rust macros. The original go challenge goes here.

Compiled with Rust 0.5.

use core::task::spawn;
use core::pipes::{stream,Port,Chan,SharedChan};

macro_rules! compute_and_send(
    ($inp:expr, $port:ident) => (
@edwardw
edwardw / gist:5036535
Created February 26, 2013 06:59
Install octave-forge miscellaneous package in homebrew octave

There are some mysterious errors when trying to install miscellaneous package from octave-forge:

error: variable length array of non-POD element type 'Array<octave_idx_type>'

etc. This happens to homebrew-ed octave 3.6.4.

The issue seems to have something to do with clang, the default compiler homebrew uses to install octave. The solution for now is to use gcc instead:

$ export CXX=llvm-g++-4.2 
@edwardw
edwardw / gist:4138639
Created November 24, 2012 06:21
Install numpy/scipy on mountain lion

Scipy Superpack is kind nice, but it seems to be inactive for a while and I want every thing under my complete control. So I went on installing them myself under homebrew-ed python.

Prerequisite

$ brew install python
$ brew install gfortran swig

Scipy/Numpy