Skip to content

Instantly share code, notes, and snippets.

{
"inbounds": [
{
"tag": "socks-in",
"protocol": "socks",
"listen": "0.0.0.0",
"port": 10708,
"settings": {
"auth": "noauth"
}
@khajavi
khajavi / LoadBalancer.scala
Created October 6, 2025 09:21
Load Balancer with Graceful Shutdown
import zio._
trait LoadBalancer[A] {
def submit(work: A): Task[Unit]
def shutdown: Task[Unit]
def shutdownGracefully(timeout: Duration): Task[Unit]
}
object LoadBalancer {
@khajavi
khajavi / example.yaml
Last active November 4, 2024 05:12
Generate Anki Deck From Directory of Examples
- sentence: "The weather is sort of chilly, but it's not too cold for a walk."
explanation: "This sentence uses 'sort of' to mean it’s a bit chilly but not very cold."
- sentence: "I sort of understand the concept, but I need more practice."
explanation: "Here, 'sort of' implies partial understanding but a need for more clarity."
@khajavi
khajavi / DuckTypingExample.go
Created December 24, 2016 11:19
Duck Typing Example in Golang
package main
import "fmt"
type Speaker interface {
Say(string)
}
type Person struct {

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x

A sample cla file.

@khajavi
khajavi / convert_float_to_ieee754.c
Created May 29, 2013 10:42
example of conveting float numbers to ieee 754 in single and double precison format.
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
/*
* See also : http://class.ece.iastate.edu/arun/CprE281_F05/ieee754/ie5.html
*/
union FloatingPointSinglePrecisionIEEE754 {
struct {
@khajavi
khajavi / Makefile
Created June 1, 2013 11:21
Example of getting attribute value of xml node by using libxml2 library.
CC = gcc
CLIBS = `pkg-config libxml-2.0 --cflags --libs`
retrieve_attribute_value: retrieve_attribute_value_example.c
$(CC) retrieve_attribute_value_example.c -o retrieve_attribute_value_example.bin $(CLIBS)
clean:
rm -f *.o *.bin
@khajavi
khajavi / FileServer.java
Last active June 22, 2021 18:15
Create File Server With Jetty
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html