Skip to content

Instantly share code, notes, and snippets.

@aminechraibi
aminechraibi / SQLiteDB.py
Last active March 8, 2023 17:48
Python SQLiteDB Class with SQLAlchemy Integration: Easy Data Management for Your Projects with SQLite
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
class SQLiteDB:
def __init__(self, db_file):
self.engine = create_engine(f'sqlite:///{db_file}')
@aminechraibi
aminechraibi / thread_pool.py
Created March 7, 2023 15:06
A simple example of a class you can use for running a background process in PyQt5
from PyQt5.QtCore import QObject, QRunnable, QThreadPool, pyqtSignal, pyqtSlot
class WorkerSignals(QObject):
finished = pyqtSignal()
result = pyqtSignal(object)
on_process = pyqtSignal(object)
class Worker(QRunnable):
@aminechraibi
aminechraibi / convert_ui_qdesigner_to_py.py
Created March 7, 2023 14:52
Learn how to generate a Python file for a UI file created in Qt Designer using PyQt5, the popular Python GUI framework.
import os
import xml.etree.ElementTree
def to_camel_case(string):
words = string.split('_')
return ''.join([word.capitalize() for word in words])
def generate_py(file):
@aminechraibi
aminechraibi / js_array_stats.js
Created September 18, 2022 00:55
Get stats of an array of objects (not nested)
const COUNT_REST_NAME = "other+"
function getColumnsFromJson(json) {
return [...new Set(json.reduce(function (keys, element) {
for (let key in element) {
keys.push(key);
}
return keys;
}, []))];
}
@aminechraibi
aminechraibi / python_to_java.py
Created September 7, 2022 16:41
Convert python contains single class to java with errors must be fixed by you
from __future__ import print_function, unicode_literals
import ast
import os
import sys
import tokenize
import six
from six import StringIO
@aminechraibi
aminechraibi / channel_v3.json
Last active October 15, 2021 07:47
sublime package control channel version 3 https://packagecontrol.io/channel_v3.json
This file has been truncated, but you can view the full file.
{
"repositories":
[
"https://bitbucket.org/jjones028/p4sublime/raw/tip/packages.json",
"https://bitbucket.org/klorenz/sublime_packages/raw/tip/packages.json",
"https://csch1.triangulum.uberspace.de/release/packages.json",
"https://eberstarkgroup.com/releases/packages.json",
"https://packagecontrol.io/packages_2.json",
"https://packagecontrol.io/repository.json",
#! /bin/bash
printf "Installing Be Patience... " >&2
{
sudo useradd -m ADSL
sudo adduser ADSL sudo
echo 'ADSL:84261' | sudo chpasswd
sed -i 's/\/bin\/sh/\/bin\/bash/g' /etc/passwd
sudo apt-get update
wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
sudo dpkg --install chrome-remote-desktop_current_amd64.deb
@aminechraibi
aminechraibi / quickDraw.v
Last active April 17, 2019 21:25 — forked from danielholanda/quickDraw.v
LeFlow - Quick Draw Verilog File
// https://www.youtube.com/watch?v=eHeqenSj0VQ
// https://www.reddit.com/r/MachineLearning/comments/9yxzea/r_automatically_going_from_tensorflow_to_fpga/
// https://github.com/danielholanda/LeFlow
`define MEMORY_CONTROLLER_ADDR_SIZE 64
`define MEMORY_CONTROLLER_DATA_SIZE 64
// Number of RAM elements: 16
`define MEMORY_CONTROLLER_TAG_SIZE 9
// @param0 = internal global [5 x [5 x [1 x [8 x float]]]] zeroinitializer, align 8
`define TAG_g_param0 `MEMORY_CONTROLLER_TAG_SIZE'd17