Skip to content

Instantly share code, notes, and snippets.

@tdakkota
tdakkota / example.rs
Created October 14, 2019 10:04
example middleware
type Handler = Box<Fn(i32) -> i32>;
type Middleware = fn(Handler) -> Handler;
struct Router {
middleware: Vec<Middleware>,
}
impl Router {
pub fn new() -> Router {
Router {
@tdakkota
tdakkota / swagger.yaml
Last active April 6, 2024 08:12
Swagger file for nhentai.net API
swagger: "2.0"
info:
description: "Swagger description of nhentai.net API."
version: "1.0.0"
title: "Nhentai.net API"
host: "nhentai.net"
tags:
- name: "search"
description: "Search books at nhentai.net"
- name: "book"
— Да?
— Алё!
— Да да?
— Ну как там с дженериками?
— А?
— Как с дженериками-то там?
— Чё с дженериками?
— Чё?
— Куда ты пишешь?
— Тебе пишу.
@tdakkota
tdakkota / example_bot.go
Last active May 29, 2022 05:07
Example Telegram Go bot which uses SOCKS5 proxy
package main
import (
"golang.org/x/net/proxy"
"log"
"net/http"
"net/url"
"os"
"time"
package main
type Optional(type T) struct {
p *T
}
func OptionalFrom(type T)(value T) Optional(T) {
return Optional(T){p: &value}
}
package main
import (
"fmt"
"strings"
)
type Tuple(type A, B) interface {
Head() A
Tail() B
package main
import (
"fmt"
)
type Context struct {
Max int
Max7 int
}
@tdakkota
tdakkota / greka.hs
Last active July 9, 2020 10:36
приключения греки, описанные на лучшем в мире языке
через :: a -> a
через a = a
греку :: a -> a
греку a = a
в :: a -> a
в a = a
реке :: a -> a
var id = 1;
var users = [];
var i = 0;
while(i < 25) {
var req = API.groups.getMembers({"group_id":id,"count":1000,
"offset":i*1000,"fields":"sex, bdate, city, country, photo_50, photo_100, photo_200_orig, photo_200, photo_400_orig, photo_max, photo_max_orig, online, online_mobile, lists, domain, has_mobile, contacts, connections, site, education, universities, schools, can_post, can_see_all_posts, can_see_audio, can_write_private_message, status, last_seen, common_count, relation, relatives"});
users.push(req.items);
i = i + 1;
}
@tdakkota
tdakkota / lfu.go
Last active November 2, 2020 15:11
LFU Cache written in Go2. Playground: https://go2goplay.golang.org/p/qFlA5TGqxHb
package main
type CacheNode[K, V any] struct {
key K
value V
prev *CacheNode[K, V]
next *CacheNode[K, V]
parent *FreqNode[K, V]
}