Skip to content

Instantly share code, notes, and snippets.

View yozx's full-sized avatar
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 August 31, 2023 12:50
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 April 16, 2024 12:18
Stupid simple setting up WireGuard - Server and multiple peers
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 December 5, 2023 10:26
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 June 30, 2023 11:01
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 November 6, 2023 22:57
Fast Alternative to pd.concat() for row-wise concatenation

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 April 11, 2024 16:23
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 April 3, 2024 15:28
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">