Skip to content

Instantly share code, notes, and snippets.

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

Andreas sneakykiwi

🏠
Working from home
View GitHub Profile
package main
import "sync"
var webhooks = make(chan Webhook)
type Webhook struct{
//build the webhook struct
}
func CreateBmak(site string, apipublickey string) bmak {
b := bmak{
Ver: 1.68,
KeCntLmt: 150,
MmeCntLmt: 100,
MduceCntLmt: 75,
PmeCntLmt: 25,
PduceCntLmt: 25,
TmeCntLmt: 25,
TduceCntLmt: 25,
type bmak struct {
Browser Browser
start_ts int64
ke_vel int
me_vel int
te_vel int
doe_vel int
dme_vel int
pe_vel int
init_time int
func CreateBmak(site string, apipublickey string) bmak {
b := bmak{
Ver: 1.68,
KeCntLmt: 150,
MmeCntLmt: 100,
MduceCntLmt: 75,
PmeCntLmt: 25,
PduceCntLmt: 25,
TmeCntLmt: 25,
TduceCntLmt: 25,
type Browser struct {
gorm.Model
Navigator struct {
Appcodename string `json:"appCodeName"`
Appname string `json:"appName"`
Appversion string `json:"appVersion"`
Language string `json:"language"`
Languages pq.StringArray `json:"languages" gorm:"type:text[]"`
Useragent string `json:"userAgent"`
Vendor string `json:"vendor"`
package main
import (
"fmt"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/proxy"
"time"
)
type Proxy struct {
@sneakykiwi
sneakykiwi / broadcash.go
Last active August 23, 2021 22:34
Just a broadcaster that has been really valuable to me. It doesn't use the conventional channels, instead it uses Cond from the sync package
type Broadcaster struct {
cond *sync.Cond
subscribers map[interface{}]func(interface{})
message interface{}
running bool
}
// SetupBroadcaster gives the broadcaster object to be used further in messaging
func SetupBroadcaster() *Broadcaster {
@sneakykiwi
sneakykiwi / async_scheduler.py
Last active July 23, 2021 01:04
An async scheduler that takes in a max queue size, workers and a function to run. You spawn a scheduler instance and then await functions, they run in the loop concurrently.
class Scheduler:
def __init__(self, max_workers: int, queue_maxsize: int = None):
self.max_workers = max_workers
self._queue_maxsize = queue_maxsize
self.queue = None
async def _execute(self, func, args, kwds):
try:
return await func(*args, **kwds)
finally: