Skip to content

Instantly share code, notes, and snippets.

View terry90's full-sized avatar
🏠
Working from home

Terry Raimondo terry90

🏠
Working from home
  • GetPro
  • 07:25 (UTC +01:00)
View GitHub Profile
use rocket::http::Status;
use rocket::{
http::ContentType,
response::{self, Responder},
Request,
};
use rocket_contrib::json::Json;
use std::collections::HashMap;
#[derive(Debug)]
@terry90
terry90 / _.rb
Created September 30, 2019 22:04
medium_answer_build_scss
def compile_scss(compress = true)
puts cyan 'Compiling Sass files...'
files = Dir[File.join(__dir__, 'src/**/*.scss')].reject { |name| name.split("/").last[0] == '_'}
system(": > ./static/app.css")
files.each do |file|
compress ?
system("sass #{file} -s compressed | uglifycss >> ./static/app.css") :
system("sass #{file} >> ./static/app.css")
end
puts green 'Sass files compiled'
@terry90
terry90 / http_client.rs
Created September 11, 2019 10:30
WASM Yew HttpClient
use serde::Deserialize;
use serde::Serialize;
use serde_qs as qs;
use uuid::Uuid;
use yew::callback::Callback;
use yew::format::Text;
use yew::services::fetch::{FetchService, FetchTask, Request, Response, StatusCode};
use yew::services::storage::{Area, StorageService};
use yew::ComponentLink;
@terry90
terry90 / routes.rs
Created September 11, 2019 10:28
WASM routes file
use lazy_static::lazy_static;
use std::marker::PhantomData;
use crate::app::services::http_client::Method;
pub enum Api {
Licenses,
Auth,
}
@terry90
terry90 / main.rs
Created September 4, 2019 10:22
main.rs - Yew
mod app;
fn main() {
yew::start_app::<app::Model>();
}
@terry90
terry90 / app.rs
Created September 4, 2019 10:19
app.rs - yew
use log::info;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
use crate::app::modules::Header;
use crate::app::root::Model as Root;
pub struct Model {}
impl Component for Model {
type Message = ();
@terry90
terry90 / main.rs
Last active June 21, 2019 16:27
rs-simple-proxy usage
extern crate simple_proxy;
mod middlewares;
use middlewares::auth::Auth;
use simple_proxy::middlewares::{Cors, Health, Logger, Router};
use simple_proxy::SimpleProxy;
fn main() {
let config = config::Config::new();
@terry90
terry90 / logger.rs
Created June 21, 2019 16:19
Example middleware rs-simple-proxy
use chrono::{DateTime, Utc};
use hyper::{Body, Request, Response};
use serde_json;
use crate::proxy::error::MiddlewareError;
use crate::proxy::middleware::MiddlewareResult::Next;
use crate::proxy::middleware::{Middleware, MiddlewareResult};
use crate::proxy::service::{ServiceContext, State};
#[derive(Clone, Default)]
@terry90
terry90 / dockerbuild.rb
Last active November 24, 2021 10:46
Docker build/push script with semantic versioning
#!/usr/bin/env ruby
# coding: utf-8
# Colors utils
GREY = "\e[38;5;247m".freeze
GREEN = "\e[0;92m".freeze
YELLOW = "\e[0;93m".freeze
CYAN = "\e[0;96m".freeze
RED = "\e[0;91m".freeze
@terry90
terry90 / dicobuild
Created June 5, 2019 14:05
Codename
abaque
abat
abats
abatte
abattu
abbaye
aberra
aberre
abject
abjura