Skip to content

Instantly share code, notes, and snippets.

Mauro Panigada shintakezou

Block or report user

Report or block shintakezou

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shintakezou
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;
assert(saved_rlimit);
@shintakezou
shintakezou / Canoa.java
Last active May 20, 2019
Run two canoes to solve Italian's magazine puzzle "Quesito con la Susi n. 959"
View Canoa.java
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
shintakezou / multidyndispatch.cpp
Created Apr 16, 2019
Dynamic dispatch not just on the first argument (at least C++14)
View multidyndispatch.cpp
// see https://www.reddit.com/r/cpp_questions/comments/afp4ae/dynamic_argumentbased_dispatch_will_it_ever_be/eeh8qe7/
// credits to https://www.reddit.com/user/alfps
// 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
shintakezou / counter.ads
Created Apr 14, 2019
Nested functions/procedures in Ada, and count unique according to a certain idea of equality.
View counter.ads
package Counting is
type Element is
record
S : String (1 .. 3);
E1 : Integer;
E2 : Integer;
end record;
type Elements is array (Positive range <>) of Element;
View counter.hs
module Counter
(Element(..),
countUnique,
countUnique2) where
data Element = Element { s :: String,
e1 :: Int,
e2 :: Int } deriving (Show, Eq)
@shintakezou
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
contains
function count_unique(s) result(c)
@shintakezou
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
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
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
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>
You can’t perform that action at this time.