Skip to content

Instantly share code, notes, and snippets.

@bafu
bafu / pubkey_to_wallet.js
Last active August 10, 2022 17:37
Convert compressed public key to Ethereum wallet address
const { ethers } = require("ethers");
/* Compressed public key stored in 264 bits (66 hex digits)
* https://www.oreilly.com/library/view/mastering-bitcoin-2nd/9781491954379/ch04.html
*/
const compressedPubkey = "0x03aced43f9dddc120291f5cdf73580fbb592b5b21054ce61eb73cbaf98efcbe82e";
const pubkey = ethers.utils.computePublicKey(compressedPubkey);
const walletAddress1 = ethers.utils.computeAddress(pubkey);
const walletAddress2 = ethers.utils.computeAddress(compressedPubkey);
@bafu
bafu / iso_datetime_to_unix_timestamp.py
Last active November 5, 2020 15:21
Python ISO datetime and UNIX timestamp
import argparse
from datetime import datetime
from dateutil import parser as dparser
def datetime_iso_to_unix(iso_datetime_string):
target_datetime = dparser.isoparse(iso_datetime_string)
unix_timestamp = int(target_datetime.timestamp())
return unix_timestamp
{
"data": {
"ancestors": [
{
"data": "/fotoweb/data/a/5000.wxkilZbXJiepciwEgVI5dneZC9M_N2v8LXyGH7N0E_M/",
"href": "/fotoweb/archives/5000-Starling/",
"name": "Starling"
}
],
"archiveHREF": "/fotoweb/archives/5000-Starling/",
@bafu
bafu / camerax-example.log
Last active February 25, 2020 03:11
mediant-issue-6
20-02-25 11:02:20.519 23521-23521/com.example.camerax I/example.camera: Late-enabling -Xcheck:jni
2020-02-25 11:02:20.519 23521-23521/com.example.camerax I/example.camera: VMHOOK: rlim_cur : 0 pid:23521
2020-02-25 11:02:20.714 23521-23521/com.example.camerax W/example.camerax: type=1400 audit(0.0:28300): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=15153 scontext=u:r:untrusted_app:s0:c214,c256,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-02-25 11:02:20.714 23521-23521/com.example.camerax I/chatty: uid=10214(com.example.camerax) identical 4 lines
2020-02-25 11:02:20.714 23521-23521/com.example.camerax W/example.camerax: type=1400 audit(0.0:28304): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=15153 scontext=u:r:untrusted_app:s0:c214,c256,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-02-25 11:02:20.721 23521-23521/com.example.camerax D/Camera2Initializer: CameraX initia
@bafu
bafu / cafe_install.sh
Created August 13, 2019 08:41
Installs a Textile cafe node on Linux
#!/usr/bin/env bash
#
# Textile Cafe node installation script.
#
# This script helps install and run a Cafe node on Amazon EC2 instance.
#
# You also need to enable these inbound TCP ports in the security group
# of the instance:
#
# 4001 - Swarm TCP; should be exposed to the public
@bafu
bafu / generate_class_color.py
Created August 28, 2018 14:13
Generate N RGB tuples
def generate_class_color(class_num=20):
"""Generate a RGB color set based on given class number.
Args:
class_num: Default is VOC dataset class number.
Returns:
A tuple containing RGB colors.
"""
colors = [(1, 0, 1), (0, 0, 1), (0, 1, 1),
@bafu
bafu / colorimg.py
Created August 28, 2018 09:58
Create pure color image by given RGB values.
"""
Create pure color JPEG by given RGB values.
"""
import cv2
import numpy as np
def paint_it_color(rgb=(0, 0, 0), shape=(720, 1280, 3), filename='black'):
img = np.zeros(shape)
@bafu
bafu / pixelviewer.py
Last active March 5, 2018 14:39
Display RGB values in image's pixels
#!/usr/bin/python3
# Display RGB values in image's pixels.
import sys
import cv2
def main():
fpath = sys.argv[1]
@bafu
bafu / remake_pyconly_wheel.py
Created January 18, 2018 10:56 — forked from tanbro/remake_pyconly_wheel.py
A small tool Re-Pack a Python Wheel to a PYC-Only One
# -*- coding: utf-8 -*-
"""
Re-Pack `Wheel` to a PYC-Only One
"""
from __future__ import print_function, unicode_literals
import argparse
import compileall
@bafu
bafu / darkflow-app-example.patch
Created April 22, 2017 10:21
Darkflow Python Application Example
diff --git a/darkflow/net/flow.py b/darkflow/net/flow.py
index a5b8ceb..bb60704 100644
--- a/darkflow/net/flow.py
+++ b/darkflow/net/flow.py
@@ -90,7 +90,8 @@ def return_predict(self, im):
"y": tmpBox[2]},
"bottomright": {
"x": tmpBox[1],
- "y": tmpBox[3]}
+ "y": tmpBox[3]},