Skip to content

Instantly share code, notes, and snippets.

@adekau
adekau / machine.js
Last active March 3, 2021 19:48
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
[[-115.4160865098238,73.4052467867732],[40.85090852017345,5.571382320759293],[14.800126367183484,0.13940308612847316],[6.978377599803844,-19.79938267674734],[21.30069182974779,-5.793648276820867],[3.1374865035093764,3.8711969531065447],[15.078288703516023,-1.6967283539038864],[-3.7924976238938246,-16.069302052404755],[3.76919451449852,1.212054652208496],[-0.15306161423040415,-2.9254968881886882],[0.6902321979051833,9.845695569756888],[-3.2591011401257726,2.9115316729575307],[-3.262071105685652,-0.41348137022052395],[-0.19432452369413566,0.6025557508896777],[1.681618056408128,-1.8461169969391036],[-0.9408365246362107,-0.08773137406981371],[-2.22486961761246,-2.1083512948104355],[-1.5448223718740075,-2.5228939969303887],[-0.17559403197603196,-1.983213748618189],[1.8829381478053733,-2.1157166358450845],[2.8380508003182254,-1.3740761859640833],[2.072473984893263,-0.5476964389274416],[-1.4196138016249766,0.9971150024751302],[-0.2687141238871119,0.7290876934219535],[1.147821832418176,0.4068996945810608],[1.79458034
coeffs = Import["/Users/alexanderdekau/coeffs.json"];
pts = Import["/Users/alexanderdekau/pts.json"];
L = pts // Length;
toComplex[z_] := z[[All, 1]] + I z[[All, 2]];
Cpts = toComplex@pts;
\[Omega][k_, n_] := -2 Pi I k n / L;
Coeff[k_] := 1/L Sum[Cpts[[j]] Exp[\[Omega][k, j - 1]], {j, 1, L}];
mcoeffs = Table[Coeff[k - 1], {k, 1, L}];
coeffs = toComplex@coeffs;
idxed = MapIndexed[{First[#2], #1} &, coeffs];
@adekau
adekau / llama_p5.ts
Last active March 29, 2020 17:18
Llama using Javascript (Typescript)
import * as M from 'mathjs';
let points = [];
let pts = [];
let complexPts = [];
let coeffs = [];
let time = 0;
export class Llama {
public load() {
pts = await this.sampleSvgPoints(text, this.samples);
@adekau
adekau / t.rs
Last active October 11, 2017 15:49
ERROR:
error[E0308]: mismatched types
--> src/api.rs:132:20
|
39 | Ok((host, result)) => {
| ^^^^^^^^^^^^^^ expected enum `std::result::Result`, found tuple
|
= note: expected type `std::result::Result<(std::string::String, auth_key::AuthKeyStatus), std::string::String>`
found type `(_, _)`
@adekau
adekau / question.rs
Last active September 1, 2017 18:11
error[E0277]: the trait bound `std::rc::Rc<std::cell::RefCell<tokio_core::reactor::Inner>>: std::marker::Send` is not satisfied in `tokio_core::reactor::Core`
--> src/api.rs:115:26
|
115 | let handle = thread::spawn(move || {
| ^^^^^^^^^^^^^ `std::rc::Rc<std::cell::RefCell<tokio_core::reactor::Inner>>` cannot be sent between threads safely
|
The struct being impl'd:
ERROR:
error[E0502]: cannot borrow `*self` as mutable because `self.config` is also borrowed as immutable
--> src/api.rs:46:19
|
41 | let hosts = self.config.get_hosts().unwrap();
| ----------- immutable borrow occurs here
...
46 | match self.check_host_availability(elem) {
| ^^^^ mutable borrow occurs here
...
error[E0477]: the type `[closure@src/jobs.rs:12:19: 21:6 available_hosts:std::sync::Arc<std::sync::Mutex<std::vec::Vec<std::string::String>>>, config:&config::Config, tx:std::sync::mpsc::Sender<std::string::String>]` does not fulfill the required lifetime
--> src/jobs.rs:12:5
|
12 | thread::spawn(move || {
| ^^^^^^^^^^^^^
|
= note: type must satisfy the static lifetime