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
yozx / bitly_shorten_app.py
Created July 12, 2020 18:11
bitly_shorten_async
# Non-blocking script for shorten link via https://bit.ly Api
import asyncio
import logging
from typing import Dict, Optional
from aiohttp import ClientSession
logger = logging.getLogger('bitly_app')
@mikeyb
mikeyb / beam_solo_mining.md
Last active January 15, 2020 12:08
BEAM Solo Mining Guide

BEAM Solo Mining Guide

  • Adapted from Raskul's guide
  • With help from Freshminer (sunpool.top)

Installation

  • From BEAM Downloads download the following
    • beam-wallet-cli
    • beam-node
  • Extract downloads into a folder called beam-mining
@fonylew
fonylew / install-local-server.sh
Last active August 31, 2023 12:50
A bunch of script to install Nvidia with CUDA10, CUDNN 7.4 and so on.
#!/bin/bash
# First sudo command
sudo whoami
# Update and upgrade
sudo apt update
sudo apt upgrade -y
# Utility
@chrisswanda
chrisswanda / WireGuard_Setup.txt
Last active May 2, 2024 01:13
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
MacOS
$ brew install wireguard-tools
Generate key your key pairs. The key pairs are just that, key pairs. They can be
@bogdan-kulynych
bogdan-kulynych / install-cuda-10-bionic.sh
Last active December 5, 2023 10:26
Install CUDA 10 on Ubuntu 18.04
# WARNING: These steps seem to not work anymore!
#!/bin/bash
# Purge existign CUDA first
sudo apt --purge remove "cublas*" "cuda*"
sudo apt --purge remove "nvidia*"
# Install CUDA Toolkit 10
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
@thehesiod
thehesiod / async_worker_pool.py
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:
pass
@TariqAHassan
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
stefansundin / requests_api.py
Last active April 11, 2024 16:23
Reusable class for Python requests library.
# http://docs.python-requests.org/en/master/api/
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
lars-tiede / asyncio_loops.py
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
IanHopkinson / lxml_examples.py
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="http://www.foo.com" xmlns="http://www.bah.com">
<foo:Recordset setCount="2">