Skip to content

Instantly share code, notes, and snippets.

View ivelin's full-sized avatar
🎯
Focusing

Ivelin Ivanov ivelin

🎯
Focusing
View GitHub Profile
@kidd
kidd / duckdb.sql
Last active June 1, 2024 14:57
arg_max example in duckdb
D create table test as SELECT i as i ,random() as r, i%4 as gr from generate_series(1,100) t(i);
D select * from test;
┌───────┬──────────────────────┬───────┐
│ i │ r │ gr │
│ int64 │ double │ int64 │
├───────┼──────────────────────┼───────┤
│ 1 │ 0.14984029697949075 │ 1 │
│ 2 │ 0.20274345139105418 │ 2 │
│ 3 │ 0.07478489612107744 │ 3 │
@yorickdowne
yorickdowne / HallOfBlame.md
Last active June 19, 2024 18:17
Great and less great SSDs for Ethereum nodes

Overview

Syncing an Ethereum node is largely reliant on IOPS, I/O Per Second. Budget SSDs will struggle to an extent, and some won't be able to sync at all.

This document aims to snapshot some known good and known bad models.

For size, 4TB comes recommended as of mid 2024. The smaller 2TB drive should last an Ethereum full node until early 2025 or thereabouts, with crystal ball uncertainty. Remy wrote a migration guide to 4TB.

High-level, QLC and DRAMless are far slower than "mainstream" SSDs. QLC has lower endurance as well. Any savings will be gone when the drive fails early and needs to be replaced.

@fahofmeister
fahofmeister / readme.md
Created June 22, 2021 12:08
VS Code settings to work with Python Virtual Environment

Remarks

"python.pythonPath": folder for the venv Python interpreter

"python.terminal.activateEnvironment": activates venv automatically in a new terminal

"terminal.integrated.cwd": set the working directory for new terminal windows

"python.teminal.executeInFileDir": run a file in file's directory instead of the current folder

@asaboor-gh
asaboor-gh / LICENSE
Last active February 5, 2024 08:24
JSON Encoder/Decode for Numpy Objects
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@iwatake2222
iwatake2222 / detection_PC.py
Last active October 10, 2023 21:58
Object detection using MobileNet SSD with tensorflow lite (with and without Edge TPU)
# -*- coding: utf-8 -*-
import cv2
import tensorflow as tf
import numpy as np
# https://www.tensorflow.org/lite/guide/hosted_models
# http://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip
def detect_from_camera():
// This is universal, works with Infura -- set provider accordingly
const ethers = require('ethers')
//const provider = ethers.getDefaultProvider('rinkeby')
const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL)
function hex_to_ascii(str1) {
var hex = str1.toString();
var str = '';
for (var n = 0; n < hex.length; n += 2) {
@jdhao
jdhao / resize_and_pad_image_to_square
Last active June 15, 2023 04:12
this script will resize and pad an image to desired square size and keep its aspect ratio unchanged. Before running the script, please change the size and image path to valid value.
from PIL import Image, ImageOps
import cv2
desired_size = 368
im_pth = "/home/jdhao/test.jpg"
# im = Image.open(im_pth)
# old_size = im.size # old_size[0] is in (width, height) format
# ratio = float(desired_size)/max(old_size)
@mihow
mihow / load_dotenv.sh
Last active June 14, 2024 02:15
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@sagivo
sagivo / gist:3a4b2f2c7ac6e1b5267c2f1f59ac6c6b
Last active June 19, 2024 09:12
webRTC stun / turn server list
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,
@joepie91
joepie91 / random.md
Last active June 2, 2024 19:56
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's