Skip to content

Instantly share code, notes, and snippets.

View bachkukkik's full-sized avatar
:octocat:
Unable to comply, building in progress

Bachkukkik bachkukkik

:octocat:
Unable to comply, building in progress
View GitHub Profile
import os
import sys
import argparse
from fasthtml.components import html2ft
def main():
# Set up the argument parser
parser = argparse.ArgumentParser(description='Process an HTML file and output a Python file.')
parser.add_argument('filename', help='The name of the HTML file (without extension) located in the src folder.')
parser.add_argument('--output-dir', default='.', help='Optional output directory for the .py file (default is root).')
@pedrovgp
pedrovgp / upsert_df.py
Last active August 22, 2024 05:32
Allow upserting a pandas dataframe to a postgres table (equivalent to df.to_sql(..., if_exists='update')
# Upsert function for pandas to_sql with postgres
# https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/8702291#8702291
# https://www.postgresql.org/docs/devel/sql-insert.html#SQL-ON-CONFLICT
import pandas as pd
import sqlalchemy
import uuid
import os
def upsert_df(df: pd.DataFrame, table_name: str, engine: sqlalchemy.engine.Engine):
@MBing
MBing / install_wlan_dongle.sh
Last active October 15, 2024 22:51
install TP-Link-WN725N Nano USB Wifi on Raspberry Pi with Kernel 5.10+
# DO NOT PUT THE WIFI DONGLE IN THE DEVICE BEFORE MENTIONED EXPLICITLY BELOW
# Brief note, after this the UI will not show the usb dongle,
# the wifi does work and I get an IP address, so all works,
# but I don't go into detail of making it show on the Raspbian UI.
# (for this purpose I don't care about the UI)
# For the use of this I connected my device to an ethernet connection and through the Router could see the IP which I can SSH into.
## STEP 1: Prepare machine and install packages needed
@Ebycow
Ebycow / .md
Created March 16, 2021 17:08
NVIDIA Jetson Nano ccminer
$ sudo apt upgrade

$ sudo apt install libssl-dev libcurl4-openssl-dev

$ git clone -b linux https://github.com/tpruvot/ccminer

$ cd ccminer

$ ./build.sh
@ryderdamen
ryderdamen / gce-to-gcs-uploads.md
Created December 4, 2018 15:43
Uploading Files from Google Compute Engine (GCE) VMs to Google Cloud Storage (GCS)

Uploading Files from Google Compute Engine (GCE) VMs to Google Cloud Storage (GCS)

I had a bit of trouble trying to configure permissions to upload files from my Google Compute Engine instance to my Google Cloud Storage bucket. The process isn't as intuitive as you think. There are a few permissions issues that need to be configured before this can happen. Here are the steps I took to get things working.

Let's say you want to upload yourfile.txt to a GCS bucket from your virtual machine. You can use the gsutil command line tool that comes installed on all GCE instances.

If you've never used the gcloud or gsutil command line tools on this machine before, you will need to initialize them with a service account.

@bact
bact / thai_strftime.py
Last active September 6, 2024 16:25
Thai date and time string formatter
# thai_strftime()
# Thai date and time string formatter
# Formatting directives similar to datetime.strftime()
#
# จัดรูปแบบข้อความวันที่และเวลา แบบเดียวกับ datetime.strftime()
# โดยจะใช้ชื่อเดือนเป็นภาษาไทย และปีเป็นพุทธศักราช
# (ไม่รองรับปีก่อน พ.ศ. 2484 - ก่อนการเปลี่ยนวันปีใหม่ไทย)
#
# No Rights Reserved
# PUBLIC DOMAIN or CC0 1.0 Universal
@rllola
rllola / gist:0e46feae5a41cb7d29352a84fb388304
Created June 3, 2018 11:11
Dogecoin 1.14-branding install ubuntu 18.04
# Clone the repo
git clone [email protected]:dogecoin/dogecoin.git
# Pick the correct branch/version
cd dogecoin
git checkout 1.14-branding
# Install dependencies
sudo apt install build-essential libtool autotools-dev autoconf pkg-config libssl-dev
@dannguyen
dannguyen / README.md
Last active September 10, 2024 19:41
Using Python 3.x and Google Cloud Vision API to OCR scanned documents to extract structured data

Using Python 3 + Google Cloud Vision API's OCR to extract text from photos and scanned documents

Just a quickie test in Python 3 (using Requests) to see if Google Cloud Vision can be used to effectively OCR a scanned data table and preserve its structure, in the way that products such as ABBYY FineReader can OCR an image and provide Excel-ready output.

The short answer: No. While Cloud Vision provides bounding polygon coordinates in its output, it doesn't provide it at the word or region level, which would be needed to then calculate the data delimiters.

On the other hand, the OCR quality is pretty good, if you just need to identify text anywhere in an image, without regards to its physical coordinates. I've included two examples:

####### 1. A low-resolution photo of road signs

@obstschale
obstschale / octave.md
Last active June 8, 2024 19:46
An Octave introduction cheat sheet.