Skip to content

Instantly share code, notes, and snippets.

@c12i
c12i / listen.py
Created March 6, 2022 19:50 — forked from kissgyorgy/listen.py
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
@c12i
c12i / public-stun-list.txt
Created January 30, 2022 12:47 — forked from mondain/public-stun-list.txt
Public STUN server list
23.21.150.121:3478
iphone-stun.strato-iphone.de:3478
numb.viagenie.ca:3478
s1.taraba.net:3478
s2.taraba.net:3478
stun.12connect.com:3478
stun.12voip.com:3478
stun.1und1.de:3478
stun.2talk.co.nz:3478
stun.2talk.com:3478

Raw File Handling

A file upload service to demo use of the browser FileReader API and http request streaming with node http

WebSockets

Another chat app ...

@c12i
c12i / README.md
Last active August 1, 2021 17:16
WebSockets with native WebSocket API
@c12i
c12i / README.md
Last active August 1, 2021 17:23 — forked from LukeMathWalker/audit.yml
GitHub Actions - Rust setup

GitHub Actions

Rust setup

@c12i
c12i / README.txt
Created May 3, 2021 12:33
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.17+commit.d19bba13.js&optimize=false&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
@c12i
c12i / 3_way_round_robin_proxy.conf
Last active December 30, 2020 11:09
Bare minimum to serve static files
http {
upstream backend {
# ip_hash;
server 127.0.0.1:3000;
server 127.0.0.1:3100;
server 127.0.0.1:5000;
}
server {
listen 80;
@c12i
c12i / httparse.rs
Created November 10, 2020 14:32
Parse http request with httparse
use std::net::tcplistener;
use std::io::read;
use httparse;
fn main() {
let listener = tcplistener::bind("127.0.0.1:9000").unwrap();
println!("server running on http://localhost:9000");
loop {