Skip to content

Instantly share code, notes, and snippets.

View subset_operations.cpp
#ifndef SUBSETS_OPERATIONS
#define SUBSETS_OPERATIONS
// 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
dario2994 / evaluate_member_function.cpp
Created Jan 25, 2017
Function evaluating a member function for the given instance passing the given arguments.
View evaluate_member_function.cpp
template <typename T, typename ClassT, typename ...ArgT>
T EvaluateMemberFunction(ClassT& b, T (ClassT::*method)(ArgT...), ArgT... args) {
return (b.*method)(args...);
}
@dario2994
dario2994 / generate_hcn.py
Last active Jul 4, 2021
Highly composite numbers list
View generate_hcn.py
#!/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
dario2994 / PrintSector.js
Last active May 1, 2016
A simple js script that creates two html pages, suitable for printing, summarizing the information given in FalesiaOnline.it on a certain sector.
View PrintSector.js
// It must be executed in a page as http://falesiaonline.it/settorefoto/123/sector-name.html
// 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
dario2994 / Sendmail-Arch.md
Last active Sep 7, 2019
Sendmail configuration Arch
View Sendmail-Arch.md
@dario2994
dario2994 / mod_rewrite_guide.md
Last active Apr 29, 2021
Enable mod_rewrite in apache
View mod_rewrite_guide.md
  • 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
dario2994 / LatexInEmpathy
Last active Jan 1, 2016
How to have Latex in Empathy (using Mathjax).
View LatexInEmpathy
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