Skip to content

Instantly share code, notes, and snippets.

View DuckSoft's full-sized avatar
🌟
Ex nihilo ad astra

DuckSoft DuckSoft

🌟
Ex nihilo ad astra
View GitHub Profile
@graninas
graninas / What_killed_Haskell_could_kill_Rust.md
Last active June 22, 2024 07:05
What killed Haskell, could kill Rust, too

At the beginning of 2030, I found this essay in my archives. From what I know today, I think it was very insightful at the moment of writing. And I feel it should be published because it can teach us, Rust developers, how to prevent that sad story from happening again.


What killed Haskell, could kill Rust, too

What killed Haskell, could kill Rust, too. Why would I even mention Haskell in this context? Well, Haskell and Rust are deeply related. Not because Rust is Haskell without HKTs. (Some of you know what that means, and the rest of you will wonder for a very long time). Much of the style of Rust is similar in many ways to the style of Haskell. In some sense Rust is a reincarnation of Haskell, with a little bit of C-ish like syntax, a very small amount.

Is Haskell dead?

@DuckSoft
DuckSoft / naiveproxy-uri-specs.md
Last active June 2, 2023 00:39
NaiveProxy URI Specification

Basic

  • NaiveProxy URIs should be standard URIs, not something using JSON and Base64 encoding, etc.
  • https / quic schemes shouldn't be used directly, since they can be confusing with the real protocols.

Rules

  • schema := naive+https | naive+quic
  • username, password := basic auth info. when there's no auth, omit both.
  • host := target host
  • port can be omitted if it's 443, or specify it explicitly
  • queries:
@mtilson
mtilson / main.go
Last active June 5, 2023 18:31
how to use context for graceful shutdown [golang]
package main
import (
"context"
"log"
"net"
"os"
"os/signal"
"time"
)
@DuckSoft
DuckSoft / kotlin-md5-snipplet.md
Created October 5, 2018 22:10
Kotlin MD5 Snipplet

Code

@Suppress("SpellCheckingInspection")
fun ByteArray.toHexStringLCase(): String = "0123456789abcdef".let { hexChars ->
    StringBuilder(this.size * 2).also { s ->
        this.forEach { byte ->
            byte.toInt().also { int ->
                s.append(hexChars[int shr 4 and 0x0f])
                s.append(hexChars[int and 0x0f])
 }
@dlaptev
dlaptev / push_notifications_to_telegram.md
Last active June 16, 2024 15:13
Programmatically send push notifications to telegram from python
  1. Create a new Telegram bot:
    1. start a chat with BotFather;
    2. type /newbot, select a name (to be shown in chats) and handle for your bot;
    3. note the bot token to access HTTP API - a long string with a colon in the middle (later referred to as <token>);
    4. optionally /setdescription and /setuserpic.
  2. Add the bot to the chat/channel and note its id:
    1. add the bot to a new or existing chat or group - this is where your bot will send notifications to;
    2. go to https://api.telegram.org/bot<token>/getUpdates (replace <token> with your token);
    3. within the chat part, find and note the id field - a positive or negative number (later referred to as <chat_id>).
  3. Programmatically send notifications:
@stoewer
stoewer / ToSnakeCase.go
Last active March 29, 2022 16:59
Convert camel case to snake case in Go http://play.golang.org/p/9ybqJat1Hr
import (
"fmt"
"strings"
"regexp"
)
var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
@yowu
yowu / HttpProxy.go
Last active June 8, 2024 06:10
A simple HTTP proxy by Golang
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"strings"
)
@b1naryth1ef
b1naryth1ef / enum.py
Last active February 8, 2022 09:21
PeeWee Postgres Enum Field
from peewee import *
class BModel(Model):
class Meta:
database = db
@classmethod
def create_table(cls, *args, **kwargs):
for field in cls._meta.get_fields():
if hasattr(field, "pre_field_create"):
@sartak
sartak / a.md
Last active June 26, 2024 04:59
Anki 2 annotated schema