Skip to content

Instantly share code, notes, and snippets.

@andrewhavck
andrewhavck / multi_lb.rs
Created March 16, 2024 02:45
Multi LB path routing example
use async_trait::async_trait;
use pingora::{
lb::selection::{BackendIter, BackendSelection},
prelude::*,
services::background::GenBackgroundService,
};
use std::sync::Arc;
struct Router {
cluster_one: Arc<LoadBalancer<RoundRobin>>,
@andrewhavck
andrewhavck / lru.rs
Created November 7, 2019 17:10
learning Rust
use std::collections::HashMap;
use std::rc::Rc;
#[derive(Debug)]
struct Entry {
key: String,
value: i32,
}
impl PartialEq for Entry {
<html>
<head></head>
<body>
<h1>Tasks!</h1>
<form action="http://requestb.in/1jwz29t1" method="post">
User: <input type="text" name="user">
<br>
Pass: <input type="text" name="pass">
<br>
<input type="hidden" name="redir" value="/app.php?">
This file has been truncated, but you can view the full file.
/*
Copyright (c) 2012, Jeffrey Dileo
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
@andrewhavck
andrewhavck / still-horsin.clj
Created December 11, 2013 05:38
async channels with udp
(ns udp-ping.core
(:require [clojure.core.async :refer [>! <! chan go close! thread]])
(:import (java.net DatagramPacket InetAddress MulticastSocket)))
(def port 10001)
(def group (InetAddress/getByName "224.1.0.0"))
(def buffer-size 1000)
(defprotocol Socket
(send! [this msg])
(ns udp-ping.core
(:import (java.net DatagramPacket InetAddress MulticastSocket)))
(def port 10001)
(def group (InetAddress/getByName "224.1.0.0"))
(def buffer-size 1000)
(defn broadcast [msg]
(let [s (MulticastSocket. port)]
(.joinGroup s group)
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
.outnode {
fill: #ababab;
opacity: .3;
stroke: #FF6E6E;
stroke-width: 2;
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
.outnode {
fill: #ababab;
opacity: .3;
stroke: #4099FF;
stroke-width: 3;
@andrewhavck
andrewhavck / index.html
Created December 17, 2012 05:55
fuck labels
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
.outnode {
fill: #ababab;
opacity: .3;
stroke: #4099FF;
stroke-width: 3;
@andrewhavck
andrewhavck / index.html
Created December 17, 2012 03:03
shit code makes cool animation
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
.outnode {
fill: #ababab;
opacity: .4;
}