Skip to content

Instantly share code, notes, and snippets.

View ialexpovad's full-sized avatar
:electron:
I may be slow to respond.

nystagmus ialexpovad

:electron:
I may be slow to respond.
View GitHub Profile
@ialexpovad
ialexpovad / diophantine.py
Created March 14, 2024 09:17
Methods for solving the diophantine type equation: "X^2=NY^2 - 1".
from sympy import sqrt, Rational
def solve_equation_brute_force(n):
'''
Brute Force Method:
This method involves iterating through possible values of xx and yy until a solution is found.
'''
solutions = []
for y in range(1, 10000): # Adjust the range as needed
x_squared = n * y * y - 1
int wang_hash(int seed)
{
seed = (seed ^ 61) ^ (seed >> 16);
seed *=9;
seed = seed ^ (seed >> 4);
seed *= 0x27d4eb2d;
seed = seed ^ (seed >> 15);
return seed;
}
@ialexpovad
ialexpovad / Building OpenSSL 1.1.1(b) Notes
Created July 8, 2023 08:27 — forked from csm10495/Building OpenSSL 1.1.1(b) Notes
Building OpenSSL 1.1.1(b) Notes (Windows)
Required: Visual Studio 2015 or 2017 (or probably later works)
Setup
1. Clone/download OpenSSL 1.1.1 source to a folder
2. Download / install Perl (They recommend Active perl)
I recommend using Chocolatey so for me: choco install activeperl
3. Ensure Perl is in the system path. (Choco appears to do this by default)
4. Download / install NASM
I recommend using Chocolatey so for me: choco install nasm
5. Ensure NASM is in the system path. (For me the directory to add was C:\Program Files\NASM)
@ialexpovad
ialexpovad / dectobin.h
Created June 27, 2023 06:26
Decimal to binary format on C.
#include <cmath>
inline void dectobin(int indec, int len) {
using namespace std;
long ndec = indec % (long)(pow(2.0, len)); // truncating to max length!
for (int i = len - 1; i >= 0; i--)
{
long pw = (long)pow(2.0, i);
if (ndec - pw >= 0) {
printf("1");
@ialexpovad
ialexpovad / CustomModel.cpp
Last active June 22, 2023 06:12
To open a certain HTML file and display its contents to the right of the QTreeView when an item is selected, you can use a QPlainTextEdit or QTextBrowser widget. Here's an example of how you can achieve this:
// CustomModel.cpp
#include "custommodel.h"
CustomModel::CustomModel(QObject *parent)
: QAbstractItemModel(parent), m_rootItem(nullptr)
{
// Create the root item
m_rootItem = new TreeItem("Root");
// Populate the model with data
@ialexpovad
ialexpovad / MainWindow.cpp
Created June 21, 2023 05:55
Drag and drop with darkened area on qt (c++)
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "form.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ialexpovad
ialexpovad / logMLE.cpp
Created June 10, 2023 13:49
MLE of parameters in 2-class logistic regression
#include <vector>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <numeric>
#include <string>
#include <Eigen/Dense>
using namespace Eigen;
@ialexpovad
ialexpovad / lenregmle.cpp
Created June 10, 2023 13:39
Linear Regression using MLE
#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Geometry>
#include <fstream>
#include <Eigen/StdVector>
#include <cmath>
using namespace std;
template <typename T>
using Matrix = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>;
@ialexpovad
ialexpovad / qsettings-xml.hpp
Created June 9, 2023 19:21 — forked from ianmac45/qsettings-xml.hpp
XML Format for QSettings
#pragma once
//TODO include appropriate headers
#include <QtCore/QtCore>
#include <QtXml/QtXml>
bool readSettingsXml(QIODevice &device, QMap<QString, QVariant> &map);
bool writeSettingsXml(QIODevice &device, const QMap<QString, QVariant> &map);
static const QSettings::Format xmlFormat = QSettings::registerFormat("xml", &readSettingsXml, &writeSettingsXml);
static const QString rootName = "config";