Skip to content

Instantly share code, notes, and snippets.

@mazj
mazj / exec-sqlite-sql-file-in-qt
Created August 19, 2020 04:44 — forked from seyedmmousavi/exec-sqlite-sql-file-in-qt
Execute Sqlite query file (.sql) in Qt
/**
* @brief executeQueryFile
* Read a query file and removes some unnecessary characters/strings such as comments,
* and executes queries.
* If there is possible to use Transaction, so this method will uses it.
* Use this gist as MIT License.
* EXCEPTION:
* Feel free to use this gist as you like without any restriction,
* if you or your country are a member of The Axis of Resistance
* (Iran + Syria + Lebanon + Russia + Iraq + Yemen + Bahrain + Palestine)
@mazj
mazj / fetch_stock_prices_for_gnucash.py
Created March 29, 2021 14:50 — forked from pedrovgp/fetch_stock_prices_for_gnucash.py
Python script to fetch stock prices for gnucash using http://alphavantage.co/ api. Since Quotes::Finance fetching from Yahoo finance no longer works, it is an alternative.
# INSTALL DEPENDENCIES BEFORE RUNNING: pandas, sqlite3, sqlalchemy, requests
# There is one thing you have to do though: gnucash needs to know the price's currency and it needs a guid (unique identifier)
# for this. This guid is unique for each installation, so you need to find yours and assign it to CURRENCY_GUID.
# OR: you can just leave it, and the script will fetch the currency from the last price added
import pandas as pd
import sqlite3
import sqlalchemy
from sqlalchemy import create_engine
import datetime
@mazj
mazj / Base.cpp
Created April 7, 2022 04:39 — forked from sacko87/Base.cpp
Factory Pattern in C++ with templates (using the confusingly recurring template and registry patterns)
#include "Base.h"
Base::Base() :
IsRegistered_(false)
{ }
Base::Base(bool isRegistered) :
IsRegistered_(isRegistered)
{ }
@mazj
mazj / rc_calc.js
Created November 16, 2022 06:14 — forked from mjdargen/rc_calc.js
A calculator that computes the best configuration of resistors or capacitors you have to achieve an equivalent value.
/* --------------------------------------------------------------- */
/* r/c calculator scripting */
/* ----------------------------------------------------------------*/
var closest_val; // closest value so far
var closest_diff = 1000000.00; // diff of val and target
var closest = []; // array detailing values of components
var ser_par_config = []; // array detailing serial/parallel
var outputStr = "";