Skip to content

Instantly share code, notes, and snippets.

Avatar

Anthony Nowell anowell

View GitHub Profile
@anowell
anowell / lib.rs
Last active Apr 17, 2019
Rust Algo Example 2
View lib.rs
use algorithmia::prelude::*;
use serde::{Serialize, Deserialize};
use std::error::Error;
#[derive(Deserialize)]
pub struct Input { name: String }
#[derive(Serialize)]
struct Output { msg: String }
@anowell
anowell / main.rs
Last active Apr 24, 2019
Rust Algo Example
View main.rs
use algorithmia::prelude::*;
use serde::{Serialize, Deserialize};
use std::error::Error;
#[derive(Deserialize)]
pub struct Input { name: String }
#[derive(Serialize)]
struct Output { msg: String }
@anowell
anowell / Cargo.toml
Last active Apr 29, 2018
Calculating equity positions
View Cargo.toml
[dependencies]
csv = { git = "https://github.com/BurntSushi/rust-csv.git" } #"1.0.0-beta.6"
serde = "1.0.38"
serde_derive = "1.0.38"
chrono = { verstion = "0.4.2", features = ["serde"] }
decimal = "2.0.4"
@anowell
anowell / current.rs
Last active Sep 7, 2017
Quasar codegen idea
View current.rs
// Current example without codegen
impl Component for TodoList {
fn onload(view: &View<Self>) {
view.query("button").expect("missing todo list button")
.on(EventType::Click, |mut evt| {
match evt.app.query("#message") {
Some(node) => {
let item = TodoItem::new(&node.get("value"));
evt.binding.data_mut().items.push(item);
}
@anowell
anowell / benchmarks
Last active Jun 13, 2018
bench iterators and loops of Zip-Map-Sum
View benchmarks
(Benchmark disclaimers apply. Don't trust the numbers without double checking my code.)
Scala (functional): 697,099 ns/iter
Scala (for loop): 20,467 ns/iter
Rust (functional): 4,984 ns/iter
Rust (for loop): 4,983 ns/iter // Note: this required adding assertions to prevent bounds checking
C (for loop): 6,172 ns/iter // Note: this used -O2 optimization
@anowell
anowell / Cargo.toml
Last active Feb 12, 2017
My preferred rust template for Algorithmia algorithms
View Cargo.toml
# You'll need at least these dependencies
[dependencies]
algorithmia = "2.0.0"
base64 = "0.3.0"
serde = "0.9.0"
serde_derive = "0.9.0"
serde_json = "0.9.0"
error-chain = "0.9.0"
@anowell
anowell / todo.rs
Last active Jan 23, 2017
Quasar To Do Concept (using maud templating)
View todo.rs
use quasar::*;
struct TodoItem {
label: String,
complete: bool,
}
struct TodoList {
items: Vec<TodoItem>,
}
@anowell
anowell / all-the-filters.sh
Created Dec 18, 2016
For a single image, generate every DeepFilter style transfer variant of that image
View all-the-filters.sh
#!/bin/bash
set -e
function die {
echo >&2 $1
exit 1
}
command -v algo >/dev/null 2>&1 || die "Have you installed the Algorithmia CLI"
@anowell
anowell / random-filters.rb
Last active Dec 21, 2016
Apply random deep style filters to a bunch of images
View random-filters.rb
#!/usr/bin/env ruby
#
# Takes an arbitrary number of files as arguments
# and randomly generates PER_IMAGE filtered versions
# of each image while using each filter an equal
# number of times (approx).
#
# It uses batch inputs to minimize API calls,
# but still expect at least 1 API call per filter
#
View gist:144f2a4b4e699a35536b0c09a43485ce
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
You can’t perform that action at this time.