Skip to content

Instantly share code, notes, and snippets.

Duck Typing

Z yozx

Duck Typing
View GitHub Profile
yozx /
Created July 12, 2020 18:11
# Non-blocking script for shorten link via Api
import asyncio
import logging
from typing import Dict, Optional
from aiohttp import ClientSession
logger = logging.getLogger('bitly_app')
mikeyb /
Last active January 15, 2020 12:08
BEAM Solo Mining Guide

BEAM Solo Mining Guide

  • Adapted from Raskul's guide
  • With help from Freshminer (


  • From BEAM Downloads download the following
    • beam-wallet-cli
    • beam-node
  • Extract downloads into a folder called beam-mining
fonylew /
Last active November 14, 2022 08:08
A bunch of script to install Nvidia with CUDA10, CUDNN 7.4 and so on.
# First sudo command
sudo whoami
# Update and upgrade
sudo apt update
sudo apt upgrade -y
# Utility
chrisswanda / WireGuard_Setup.txt
Last active March 11, 2023 14:27
Stupid simple setting up WireGuard - Server and multiple peers
View WireGuard_Setup.txt
Install WireGuard via whatever package manager you use. For me, I use apt.
$ sudo add-apt-repository ppa:wireguard/wireguard
$ sudo apt-get update
$ sudo apt-get install wireguard
$ brew install wireguard-tools
Generate key your key pairs. The key pairs are just that, key pairs. They can be
bogdan-kulynych /
Last active March 16, 2023 08:27
Install CUDA 10 on Ubuntu 18.04
# WARNING: These steps seem to not work anymore!
# Purge existign CUDA first
sudo apt --purge remove "cublas*" "cuda*"
sudo apt --purge remove "nvidia*"
# Install CUDA Toolkit 10
thehesiod /
Last active December 14, 2022 09:51
Asynchronous Worker Pool, allows for limiting number of concurrent tasks
import asyncio
from datetime import datetime, timezone
import os
def utc_now():
# utcnow returns a naive datetime, so we have to set the timezone manually <sigh>
return datetime.utcnow().replace(tzinfo=timezone.utc)
class Terminator:
TariqAHassan / PandasConcatWorkaround.adoc
Last active February 1, 2023 15:39
Fast Alternative to pd.concat() for row-wise concatenation
View PandasConcatWorkaround.adoc

Pandas DataFrames are fantastic. However, concatenating them using standard approaches, such as pandas.concat(), can be very slow with large dataframes. This is a work around for that problem.

Note: this approach assumes that: (a) the goal is a row-wise concatenation (i.e., axis=0) and (b) all dataframes share the same column names.

If these assumptions are not met, this approach could still work…​but it will likely need to be modified.

stefansundin /
Last active February 21, 2023 15:26
Reusable class for Python requests library.
import requests
class RequestsApi:
def __init__(self, base_url, **kwargs):
self.base_url = base_url
self.session = requests.Session()
for arg in kwargs:
if isinstance(kwargs[arg], dict):
kwargs[arg] = self.__deep_merge(getattr(self.session, arg), kwargs[arg])
lars-tiede /
Last active January 26, 2023 16:21
asyncio + multithreading: one asyncio event loop per thread
import asyncio
import threading
import random
def thr(i):
# we need to create a new loop for the thread, and set it as the 'default'
# loop that will be returned by calls to asyncio.get_event_loop() from this
# thread.
loop = asyncio.new_event_loop()
IanHopkinson /
Created November 24, 2015 19:42
Examples of xpath queries using lxml in python
#!/usr/bin/env python
# encoding: utf-8
import lxml.etree
import lxml.html
import requests
xml_sample = """<?xml version="1.0" encoding="UTF-8"?>
<foo:Results xmlns:foo="" xmlns="">
<foo:Recordset setCount="2">