Skip to content

Instantly share code, notes, and snippets.

View VHarisop's full-sized avatar
🤒
Out sick

Vasilis Charisopoulos VHarisop

🤒
Out sick
View GitHub Profile
using LinearAlgebra
using OSQP
using QPSReader
using SparseArrays
# Example problem from Maros-Meszaros
problem = readqps("AUG3D.QPS", mpsformat=:fixed)
m, n = problem.ncon, problem.nvar
# QPS format only stores the lower triangular part of the matrix.
P = sparse(problem.qrows, problem.qcols, problem.qvals, n, n)
@VHarisop
VHarisop / linearize_pdf.sh
Last active September 29, 2021 17:40
Strip user metadata from PDF by linearizing the output of exiftool.
#!/usr/bin/env bash
function usage() {
cat << 'EOF'
Usage:
linearize_pdf.sh --file <input_file> --output <output_file>.
Arguments:
-f, --file: Input .pdf file to be processed.
-o, --output: Name of output .pdf file.
@VHarisop
VHarisop / union_find.ml
Last active November 17, 2021 08:37
Rank Union-Find in OcaML + path compression
(*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@VHarisop
VHarisop / pytriplets
Last active August 29, 2015 14:07
Pythagorean Triplets
__author__ = 'VHarisop'
''' Pythagorean triplets are integers (a, b, c) for which the property
a^2 + b^2 = c^2 holds. '''
from math import sqrt
print filter(lambda x: round(sqrt(x[2]))**2 == x[2], [(i, j, i**2 + j**2) for i in range(1, 501) for j in range(i+1, 501)])
__author__ = 'VHarisop'
''' original idea from mpetyx <github.com/mpetyx>
Generates Hardy-Ramanujan Numbers up to 250000 in under 1 sec.
'''
import sys
rng = int(sys.argv[1])
hrs = [0] * (2 * rng ** 3 + 1)
for x in range(1, rng):