Skip to content

Instantly share code, notes, and snippets.

// The class SubsetFunction<T> represents a function on the subsets of
// {0, 1, ..., N-1} (or equivalently the integers [0, 2^N)) with values in T
// and offers a variety of standard operations (i.e. xor-convolution).
// The time complexities of the various operations are optimal.
// Even if not heavily optimized (in order to maintain a good readability),
// these implementations shall be fast enough in all situations.
dario2994 / evaluate_member_function.cpp
Created January 25, 2017 23:58
Function evaluating a member function for the given instance passing the given arguments.
template <typename T, typename ClassT, typename ...ArgT>
T EvaluateMemberFunction(ClassT& b, T (ClassT::*method)(ArgT...), ArgT... args) {
return (b.*method)(args...);
dario2994 /
Last active May 4, 2024 16:39
Highly composite numbers list
#!/usr/bin/env python3
# This program prints all hcn (highly composite numbers) <= MAXN (=10**18)
# The value of MAXN can be changed arbitrarily. When MAXN = 10**100, the
# program needs less than one second to generate the list of hcn.
from math import log
MAXN = 10**18
dario2994 / PrintSector.js
Last active May 1, 2016 20:09
A simple js script that creates two html pages, suitable for printing, summarizing the information given in on a certain sector.
// It must be executed in a page as
// Two files will be downloaded: the first is a photo of the sector with routes outlines, the second is a list of all the routes with grades and lengths.
function DownloadHtml(FileName, source) {
// Adding sector name to the source
var PossibleElements = document.getElementsByClassName("name-cell");
var SectorName = '';
for (var it in PossibleElements) {
var SectorTd = PossibleElements[it];
if (SectorTd.tagName == 'TD') {
dario2994 /
Last active January 24, 2023 13:56
Sendmail configuration Arch
dario2994 /
Last active April 6, 2024 18:18
Enable mod_rewrite in apache
  • Apache configuration file

    • ubuntu -> /etc/apache2/apache2.conf
    • arch -> /etc/httpd/conf/httpd.conf
  • Add mod_rewrite and .htaccess support for your site At the end of the configuration files add these lines:

    #My site mod_rewrite configuration
    <Directory "/ABSOLUTE/PATH/YourSite">
      AllowOverride All
dario2994 / LatexInEmpathy
Last active January 1, 2016 18:38
How to have Latex in Empathy (using Mathjax).
This guide explains how to modify the classic theme of empathy (minimal one... the best one!) in order to have latex in empathy's chat windows.
The two files PATCH_Info.plist, PATCH_Content.html are in this same gist.
First of all install mathjax:
sudo apt-get install libjs-mathjax libjs-mathjax-doc fonts-mathjax fonts-mathjax-extras
Open /usr/share/adium/message-styles
Make a copy of Classic.AdiumMessageStyle in the same folder and rename it LatexClassic.AdiumMessageStyle
Open /LatexClassic.AdiumMessageStyle/Contents
Modify Info.plist substituting its content with the content of PATCH_Info.plist