Skip to content

Instantly share code, notes, and snippets.

View polyrand's full-sized avatar

Ricardo Ander-Egg polyrand

View GitHub Profile
@ines
ines / streamlit_prodigy.py
Created October 3, 2019 20:37
Streamlit + Prodigy
"""
Example of a Streamlit app for an interactive Prodigy dataset viewer that also lets you
run simple training experiments for NER and text classification.
Requires the Prodigy annotation tool to be installed: https://prodi.gy
See here for details on Streamlit: https://streamlit.io.
"""
import streamlit as st
from prodigy.components.db import connect
from prodigy.models.ner import EntityRecognizer, merge_spans, guess_batch_size
create table tweet (
id serial,
in_reply_to integer references tweet(id)
);
insert into tweet (id, in_reply_to)
values (1, NULL),
(2, NULL),
(3, 2),
(4, 3),
@simonw
simonw / deepest.sql
Created October 6, 2019 17:15
Query a twitter-to-sqlite database and find the "deepest" tweets in a reply thread, adapted from https://gist.github.com/robinhouston/f689a4b833dc027a3fd97e3de855927b
with recursive thread as (
select id, in_reply_to_status_id, 0 as depth
from tweets
where in_reply_to_status_id is null
union
select tweets.id, tweets.in_reply_to_status_id, 1 + thread.depth as depth
from thread join tweets on tweets.in_reply_to_status_id = thread.id)
select * from thread order by depth desc
@dabeaz
dabeaz / README.txt
Created October 15, 2019 20:10
PyCon India 2019, Code from Keynote Presentation by @dabeaz
Code from PyCon India 2019 Keynote Talk
David Beazley (https://www.dabeaz.com)
======================================
This code is presented "as is" and represents what was live-coded
during my closing keynote presentation at PyCon India, Chennai,
October 13, 2009. I have made no changes to the files.
Requires: Python 3.6+, numpy, pygame
@Orenoid
Orenoid / cache.py
Last active October 17, 2024 18:07
Python lru_cache with expiration
import datetime
import time
from _thread import RLock
from functools import update_wrapper, _make_key, _CacheInfo
# Check the example at the end of this script.
class Node:
"""node of the circular doubly linked list"""
@PaulSec
PaulSec / nginx.conf
Created January 26, 2020 07:27
Nginx example (proxy-pass) + simple static page
user www-data;
worker_processes 4;
pid /run/nginx.pid;
http {
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
return 301 https://$host$request_uri;
@sevaa
sevaa / MurMur.sql
Last active July 7, 2020 17:28
MurMurHash64B in MySQL dialect of SQL
drop function if exists MurmurHash64B;
delimiter $$
create function MurmurHash64B(s longblob, seed int unsigned)
returns bigint unsigned
deterministic no sql
begin
declare m int unsigned default 0x5bd1e995;
declare r int default 24;
declare len int default length(s);
@florimondmanca
florimondmanca / README.md
Last active July 10, 2025 22:02 — forked from imbolc/httpx_aiohttp.py
HTTPX vs aiohttp (over HTTPS)

Usage

  • Generate TLS certificates for localhost:
pip install trustme-cli
trustme-cli
  • Run wrk on each endpoint, eg:
@PaulSec
PaulSec / now.json
Created March 30, 2020 06:58
Zeit.co now.json configuration file
{
"version": 2,
"name": "android-version-checker",
"public": false,
"builds": [{ "src": "main.py", "use": "@now/python" }],
"routes": [
{ "src": "/", "dest": "main.py" },
{ "src": "/app/(.*)", "dest": "main.py" }
]
}
I was drawn to programming, science, technology and science fiction
ever since I was a little kid. I can't say it's because I wanted to
make the world a better place. Not really. I was simply drawn to it
because I was drawn to it. Writing programs was fun. Figuring out how
nature works was fascinating. Science fiction felt like a grand
adventure.
Then I started a software company and poured every ounce of energy
into it. It failed. That hurt, but that part is ok. I made a lot of
mistakes and learned from them. This experience made me much, much