Skip to content

Instantly share code, notes, and snippets.


Mauro Panigada shintakezou

View GitHub Profile
shintakezou / systemd-240-my.patch
Last active Oct 19, 2019
A patch for Ubuntu 19.04 (disco)'s systemd v240 issue with the memlock (systemd 240-6ubuntu5.7)
View systemd-240-my.patch
--- a/src/core/main.c 2019-10-19 18:11:23.000000000 +0200
+++ b/src/core/main.c 2019-10-19 17:41:36.465000943 +0200
@@ -1265,6 +1265,7 @@
static int bump_rlimit_nofile(struct rlimit *saved_rlimit) {
+ struct rlimit new_rlimit;
int r, nr;
shintakezou /
Last active May 20, 2019
Run two canoes to solve Italian's magazine puzzle "Quesito con la Susi n. 959"
class Canoa
private double pos; // m
private double vel; // m/s
public Canoa(double init_pos, double v) {
this.vel = v;
this.pos = init_pos;
shintakezou / multidyndispatch.cpp
Created Apr 16, 2019
Dynamic dispatch not just on the first argument (at least C++14)
View multidyndispatch.cpp
// see
// credits to
// I've modified it so that it can be compiled with a C++14 compliant compiler, plus minor style
// modifications, e.g., I've changed the syntax auto x()->ReturnValue in function declaration and defines,
// since there's no point in using it.
#include <array> // std::array
#include <functional> // std::function
#include <iostream>
#include <map> // std::map
shintakezou /
Created Apr 14, 2019
Nested functions/procedures in Ada, and count unique according to a certain idea of equality.
package Counting is
type Element is
S : String (1 .. 3);
E1 : Integer;
E2 : Integer;
end record;
type Elements is array (Positive range <>) of Element;
View counter.hs
module Counter
countUnique2) where
data Element = Element { s :: String,
e1 :: Int,
e2 :: Int } deriving (Show, Eq)
shintakezou / counter2.f03
Created Apr 14, 2019
Nested functions in Fortran (2003, 2008…)
View counter2.f03
module counter2
implicit none
type element
character(len=16) :: s
integer :: e1, e2
end type element
function count_unique(s) result(c)
shintakezou / Element.cpp
Created Apr 14, 2019
Lambda used as nested functions.
View Element.cpp
#include "Element.hpp"
#include <vector>
#include <string>
size_t count_uniques(const std::vector<SElement> v)
size_t c = 0;
bool found;
shintakezou / elements.c
Created Apr 14, 2019
Couting unique elements, with a peculiar definition of equality.
View elements.c
#include "elements.h"
#include <stddef.h>
#include <stdbool.h>
static int compare(const element *a, const element *b)
if (a->e2 == b->e2)
return 0;
else if (a->e1 != b->e1)
shintakezou / dyndis.hs
Created Jan 13, 2019
tests of "dynamic overloading" (or alike) in several languages
View dyndis.hs
-- interpreter of + and .
data StackEl = Onum Integer | Ostr String
instance Show StackEl where
show (Onum a) = show a
show (Ostr s) = "\"" ++ s ++ "\""
plus (Onum a) (Onum b) = Onum $ a+b
plus (Onum a) (Ostr b) = Ostr $ (show a) ++ b
shintakezou / dynamic_dispatch.cpp
Created Jan 12, 2019
Dynamic overloading simple poc test (dynamic dispatching)
View dynamic_dispatch.cpp
#include <iostream>
// likely you'd like to use this someway; instead, this code
// simply ignores and accepts memory leaks.
//#include <memory>
#include <string>
#include <stack>
#include <sstream>