Skip to content

Instantly share code, notes, and snippets.

View RyanKung's full-sized avatar
🏠
Working from home

Elder Ryan RyanKung

🏠
Working from home
View GitHub Profile
@RyanKung
RyanKung / poll.py
Last active December 26, 2023 05:20
poll.py
import platform
import re
import time
import cffi
from eth_account.messages import encode_defunct
from web3 import Web3
import simplejson as json
import asyncio
current_os = platform.system()
@RyanKung
RyanKung / test.py
Created November 5, 2020 18:13
test
import requests
from lxml import html
from PIL import Image
import io
from itertools import starmap
def grab_list(url):
title_path = '//td[@class="huanhang"]/a/text()'
link_path = '//td[@class="huanhang"]/a/@href'
raw_data = html.fromstring(requests.get(url).text)
@RyanKung
RyanKung / Makefile
Last active July 21, 2020 10:19
Makefile
# ref: https://medium.com/better-programming/writing-ios-apps-without-xcode-89450d0de21a
# MetaData
CLANG = /usr/bin/clang
CLANG_OBF = /usr/local/opt/llvm/bin/clang
PROJECT_NAME = Test
SOURCE_DIR = Test
BUNDLE_DIR = ${PROJECT_NAME}.app
TEMP_DIR = _BuildTemp
@RyanKung
RyanKung / Dockerfile
Last active June 4, 2020 10:36
elk-apm-docker
FROM docker.elastic.co/apm/apm-server:7.7.0
COPY apm-server.yml /usr/share/apm-server/apm-server.yml
USER root
RUN chown root:apm-server /usr/share/apm-server/apm-server.yml
USER apm-server
@RyanKung
RyanKung / patth.py
Created June 4, 2020 03:58
Record Elastic APM Python Agent requests
def monkey_patch_transport():
from functools import wraps
import gzip
from elasticapm.transport.http import Transport
Transport.origin_send = Transport.send
@wraps(Transport.send)
def _(self, data):
print("{url: '%s', data: '%s', method: '%s', gzip: 1}" % (self._url, gzip.decompress(data.tobytes()) , 'POST'))
return Transport.origin_send(self, data)
@RyanKung
RyanKung / config.py
Created May 2, 2020 16:05
Trace a gunicorn worker performance with pyinstrument
from pyinstrument import Profiler
from pyinstrument.renderers import JSONRenderer
def pre_request(worker, req):
worker.profiler = Profiler()
worker.profiler.start()
def post_request(worker, req, environ, resp):
@RyanKung
RyanKung / test.rs
Last active November 22, 2018 08:39
md5 bench test
use md5;
use std::time::SystemTime;
use rayon::prelude::*;
fn main() {
let now = SystemTime::now();
(13200000000 as i64 .. 18900099999 as i64).into_par_iter().map(
|d| {
print!("[{:?}]{} with hash: {:?}\n",
SystemTime::now().duration_since(now).unwrap(),
@RyanKung
RyanKung / note.org
Last active September 10, 2018 13:48
Functor, Applicative, Monad, Semigroup, Monoid in Haskell and Rust

Functor

class Functor f where
    fmap :: (a -> b) -> f a -> f b
@RyanKung
RyanKung / diction.el
Created August 16, 2018 06:49
diction.el --- minor mode to interface the command diction
;;; diction.el --- minor mode to interface the command diction
;;; Copyright Sven Utcke <[email protected]>
;; Emacs Lisp Archive Entry
;; Filename: diction.el
;; Version: $Id: diction.el,v 1.8 2005/09/29 12:55:52 utcke Exp $
;; Keywords: diction, style
;; Author: Sven Utcke <[email protected]>
;; Maintainer: Sven Utcke <[email protected]>
import gzip
import time
import simplejson as json
import websockets
import asyncio
from aioreactive.core import subscribe
from aioreactive.core import AsyncObservable, AsyncIteratorObserver
HUOBI_PRO: str = "wss://api.huobi.pro/ws"