This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use argon2::{Argon2, PasswordHash}; | |
use axum_extra::extract::cookie::{Cookie, SameSite}; | |
use axum_extra::extract::CookieJar; | |
async fn login_user( | |
ctx: State<ApiContext>, | |
Json(data): Json<LoginUser>, | |
) -> Result<(CookieJar, Json<LoginResponse>)> { | |
let user = models::user::get_user_pass_hash(&ctx.db, &data.email) | |
.await? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// All themes need a file called `ui-variables` that extends from the base | |
// variables and overrides colors, padding, etc. Other plugins import | |
// `ui-variables` to make their custom CSS react to the current theme. | |
@import 'base/ui-variables'; | |
@goldenrod: #e8aa14; | |
@sapphire: #006494; | |
@magenta: #bf1363; | |
@onyx: #404040; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use algorithmia::prelude::*; | |
use serde::{Serialize, Deserialize}; | |
use std::error::Error; | |
#[derive(Deserialize)] | |
pub struct Input { name: String } | |
#[derive(Serialize)] | |
struct Output { msg: String } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use algorithmia::prelude::*; | |
use serde::{Serialize, Deserialize}; | |
use std::error::Error; | |
#[derive(Deserialize)] | |
pub struct Input { name: String } | |
#[derive(Serialize)] | |
struct Output { msg: String } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use quasar::*; | |
struct TodoItem { | |
label: String, | |
complete: bool, | |
} | |
struct TodoList { | |
items: Vec<TodoItem>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
NewerOlder