Skip to content

Instantly share code, notes, and snippets.

View dbl0null's full-sized avatar
👁️‍🗨️

Sergey Shiganov dbl0null

👁️‍🗨️
  • Saint Petersburg, Russia
View GitHub Profile
@dbl0null
dbl0null / channels.go
Created December 20, 2022 15:29 — forked from quasilyte/channels.go
Channel vs mutex vs atomic for synchronized counter
package benchmark
import (
"context"
"runtime"
"sync"
"sync/atomic"
"testing"
"time"
)
package transcoder
import (
"errors"
"fmt"
"log"
"time"
"github.com/dbl0null/rt/internal/cgo/ffmpeg"
"github.com/deepch/vdk/av"
@dbl0null
dbl0null / osxvpnrouting.markdown
Created March 15, 2022 12:11 — forked from taldanzig/osxvpnrouting.markdown
Routing tips for VPNs on OS X

Routing tips for VPNs on OS X

When VPNs Just Work™, they're a fantastic way of allowing access to a private network from remote locations. When they don't work it can be an experience in frustration. I've had situations where I can connect to a VPN from my Mac, but various networking situations cause routing conflicts. Here are a couple of cases and how I've been able to get around them.

Specific cases

Case 1: conflicting additional routes.

In this example the VPN we are connecting to has a subnet that does not conflict with our local IP, but has additional routes that conflict in some way with our local network's routing. In my example the remote subnet is 10.0.x.0/24, my local subnet is 10.0.y.0/24, and the conflicting route is 10.0.0.0/8. Without the later route, I can't access all hosts on the VPN without manually adding the route after connecting to the VPN:

extern crate http;
#[macro_use]
extern crate json;
extern crate lili_agent;
#[macro_use]
extern crate log;
extern crate simple_server;
//
//use std::borrow::Borrow;
//use std::ops::Sub;
@dbl0null
dbl0null / micro.js
Created September 30, 2019 10:37
micro example
/* legacy code here */
async function handlerA(data) { /* ... */ }
async function handlerB(data) { /* ... */ }
/* micro.js related code goes here */
const micro = require('micro')
async function dispatch(message) {
try {
@dbl0null
dbl0null / login.html
Created December 3, 2017 15:40 — forked from guillaumevincent/login.html
Basic authentication on Tornado with a decorator
<div id="main-container">
<div id="main">
<h1>
<img alt="scubabook logo" src="{{ static_url("img/logo.png") }}">
</h1>
<div id="login-form">
<form action="/auth/login/" method="post" id="login_form">
<fieldset>
<label for="username">Username</label>
<input autocapitalize="off" autocorrect="off" class="text-input" id="username" name="username" tabindex="1" type="text" value="">
@dbl0null
dbl0null / tree.md
Created December 2, 2017 04:23 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@dbl0null
dbl0null / events.py
Created December 2, 2017 01:11 — forked from szastupov/events.py
websocket/long polling event bus
import logging
from tornado.websocket import WebSocketHandler
from tornado.web import asynchronous
from tornado.ioloop import PeriodicCallback
from helpers.event_bus import bus
from helpers.api import CommonHandlerMixin
from helpers.auth import http_token
from functools import partial
from . import routes
@dbl0null
dbl0null / build-pex.sh
Created November 30, 2017 10:10 — forked from dln/build-pex.sh
#!/bin/bash
set -ex
rm -rf build
mkdir build
python -m virtualenv ./build/venv/
./build/venv/bin/pip install --upgrade wheel pex setuptools
./build/venv/bin/python setup.py bdist_wheel
./build/venv/bin/pex --cache-dir build/pex-cache --repo dist/ -r myprogram -e myprogram:main -o dist/myprogram
@dbl0null
dbl0null / pex-build.py
Created November 30, 2017 10:10 — forked from dlamotte/pex-build.py
Using pex to build a single python executable (minimal requirements)
#!/usr/bin/env python2.7
from pex.pex_builder import PEXBuilder
from pex.resolvable import resolvables_from_iterable
from pex.resolver import CachingResolver
from pex.resolver_options import ResolverOptionsBuilder
import argparse
import os
import shutil
import sys