Skip to content

Instantly share code, notes, and snippets.

View andrewzah's full-sized avatar
🍊
currently working on Korean educational tools.

Andrew Zah andrewzah

🍊
currently working on Korean educational tools.
View GitHub Profile
@andrewzah
andrewzah / parse.rs
Created January 28, 2019 07:43
parse
pub fn parse_hangeul_sino(numbers: Vec<char>) -> String {
let len = numbers.len() - 1;
let mut output = String::new();
let mut iter = numbers.iter().enumerate().peekable();
while let Some((idx, input_num)) = iter.next() {
if let Some(sign) = Sign::from_char(&input_num) {
if idx != len { panic!("+ or - symbol isn't at the beginning of the input."); }
output.push_str(&sign.to_string_rev());
continue;
@andrewzah
andrewzah / auth_middleware.rs
Created April 22, 2019 08:56
auth middleware example
let auth_header = req
.headers()
.get("AUTHORIZATION")
.map(|value| value.to_str());
match auth_header {
Some(token) => match token {
Ok(t) => match decode_token(jwt_secret, &t) {
Ok(_) => Either::A(self.service.call(req)),
Err(err) =>
let auth_header = req
.headers()
.get("AUTHORIZATION")
.ok_or_else(|| ServiceError::BadRequest("t".into()))
.and_then(|value| value.to_str()
.map_err(|err| ServiceError::BadRequest(err.to_string()))
)
.map_err(|err| ServiceError::BadRequest(err.to_string()))
.and_then(|value| Authorization::from_str(value))
.map_err(|err| ServiceError::BadRequest(err.to_string()));
@andrewzah
andrewzah / config.json
Created May 19, 2019 06:45
Config for Enhance main window Anki plugin
{
"book symbol": "{",
"cap value": null,
"color empty": null,
"color empty descendant": null,
"color zero": false,
"columns": [
{
"absolute": true,
"color": "green",
@andrewzah
andrewzah / keybase.md
Created June 3, 2019 03:25
keybase.md

Keybase proof

I hereby claim:

  • I am azah on github.
  • I am andrewzah (https://keybase.io/andrewzah) on keybase.
  • I have a public key whose fingerprint is 6DA8 AD68 401E FD0D 3F86 F524 77E0 7578 29DD B540

To claim this, I am signing this object:

@andrewzah
andrewzah / compilation.md
Last active June 10, 2019 12:06
Compilation of TTMIK's "Essential Verbs" series

Compilation of TTMIK's "Essential Verbs" series

essential irregular verbs

돕다 - to help

어렵다 - to be difficult

쉽다 - to be easy

use std::fmt;
use std::result;
pub type Result<T> = result::Result<T, AppError>;
pub struct AppError(Box<ErrorKind>);
impl AppError {
pub(crate) fn new(kind: ErrorKind) -> AppError {
AppError(Box::new(kind))
{
"node_key": "...",
"queries": {
"id1": [
{"column1": "value1", "column2": "value2"},
{"column1": "value1", "column2": "value2"}
],
"id2": [
{"column1": "value1", "column2": "value2"},
{"column1": "value1", "column2": "value2"}
@andrewzah
andrewzah / Dockerfile
Last active July 21, 2019 07:50
rust build
FROM debian:stretch-slim
MAINTAINER Andrew Zah <zah@andrewzah.com>
ENV BUILD_PACKAGES curl libpq-dev build-essential
ENV PATH="/root/.cargo/bin:${PATH}"
RUN mkdir /out \
&& apt-get update \
&& apt-get install -y $BUILD_PACKAGES \
@andrewzah
andrewzah / Dockerfile
Last active July 24, 2019 00:11
alpine rust diesel musl test
## builder
FROM andrewzah/alpine-rust as build
WORKDIR /build
RUN apk add --update postgresql-dev
RUN mkdir src \
&& echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs