Skip to content

Instantly share code, notes, and snippets.

View dizcza's full-sized avatar
🏠

Danylo Ulianych dizcza

🏠
View GitHub Profile
@dizcza
dizcza / format_sdcard.c
Last active April 26, 2024 19:37
ESP32 Arduino format an SD card
#include "ff.h"
#include "vfs_fat_internal.h"
/**
* Usage:
*
* Arduino:
* SD.begin();
* format_sdcard();
*
@dizcza
dizcza / correlate_sparse.py
Created November 14, 2019 08:51
Cross-correlation of two 1-dimensional sparse CSR matrices.
import numpy as np
import scipy.sparse
def correlate_sparse(matrix1, matrix2, mode='valid'):
"""
Cross-correlation of two 1-dimensional sparse CSR matrices.
Drop-in replacement for `np.correlate`.
Parameters
@dizcza
dizcza / ukrlib.py
Last active September 21, 2019 20:57
Download best books from ukrlib
import time
import urllib.request
from pathlib import Path
from bs4 import BeautifulSoup
from tqdm import trange, tqdm
url_page_template = "https://ukrlib.com.ua/books/rating.php?so=1&page={page_id}"
url_download_template = "https://ukrlib.com.ua/books/getfile.php?tid={tid}&type=3"
BEST_BOOKS_DIR = Path(__file__).parent / "best"
@dizcza
dizcza / RingByteBuffer.java
Last active July 13, 2019 21:29
Ring buffer to hold the UART data
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Ring buffer (fixed size queue) implementation using a circular array (array
* with wrap-around).
*/
public class RingByteBuffer implements Iterable<Byte> {
@dizcza
dizcza / pyserial-uart.py
Created April 16, 2019 18:18
Capture UART messages
import time
import serial
ser = serial.Serial(
port='/dev/ttyACM0', # dmesg | grep tty
baudrate=115200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
```
warn: ExtCore.WebApplication[0]
Error loading assembly 'SQLitePCLRaw.bundle_green'
warn: ExtCore.WebApplication[0]
System.IO.FileNotFoundException: Could not load file or assembly 'SQLitePCLRaw.bundle_green, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'SQLitePCLRaw.bundle_green, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
@dizcza
dizcza / checkwifi.sh
Created June 9, 2018 08:57
Ubuntu restart WiFi service automatically
#!/bin/bash
# sudo crontab -e
# @reboot /home/dizcza/Programs/checkwifi.sh
# sudo update-rc.d cron defaults
/bin/sleep 30
while true; do
/usr/bin/wget -T5 -q --spider google.com
@dizcza
dizcza / digits8.py
Last active March 25, 2018 14:04
20k most probably used WPA passwords of digits of length 8+2
from datetime import date
from dateutil.rrule import rrule, DAILY
import itertools
masks = (
# same
'aaaaaaaa',
'aaaaaaaaa',
'aaaaaaaaaa',
@dizcza
dizcza / docker_install.sh
Last active January 3, 2018 11:17
Install docker in Ubuntu
#!/usr/bin/env bash
# based on tutorial: https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-using-the-repository
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
@dizcza
dizcza / python-nvidia-smi.py
Last active May 25, 2020 09:16
set CUDA_VISIBLE_DEVICES env from available GPUs
import subprocess
import os
class GpuInfo(object):
def __init__(self, index, memory_total, memory_used, gpu_load):
"""
:param index: GPU index
:param memory_total: total GPU memory, Mb
:param memory_used: GPU memory already in use, Mb