Skip to content

Instantly share code, notes, and snippets.

View carmelopellegrino's full-sized avatar

Carmelo Pellegrino carmelopellegrino

  • Bologna
View GitHub Profile
@carmelopellegrino
carmelopellegrino / index-ferm-01.html
Last active October 25, 2019 09:44
Wrapper page to automatically reload a monitor page
<!DOCTYPE html>
<html>
<head>
<script>
i = 0;
f = function() {
i += 1;
document.getElementById('remote').innerHTML = '<iframe src="https://iatw.cnaf.infn.it/eee/monitor/dqm2/datatransfer/eventdisplay/FERM-01last.html?i='+i+'" style="position:absolute; top:0px; left:0px; width:100%; height:100%; border: none;"></iframe>';
setTimeout(f, 50000);
}
@carmelopellegrino
carmelopellegrino / benford.cpp
Last active July 17, 2017 14:16
Benford distribution simulation
#include <iostream>
#include <numeric>
#include <array>
auto first_of(auto x) {
auto tmp = x / 10;
while (tmp != 0) {
x = tmp;
tmp /= 10;
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
int main()
{
while (1) {
char* const x = readline("prompt> ");
@carmelopellegrino
carmelopellegrino / solution.cpp
Last active January 13, 2017 14:51
farest-nearest
#include <iostream>
#include <math.h>
#include <vector>
#include <fstream>
#include <algorithm>
#include <stdint.h>
#include <cassert>
struct point {
double dist;
%define major 0
%define major1 1
%define libname %mklibname %{name} %{major}
%define libnamellvm %mklibname %{name}llvm %{major}
%define libname1 %mklibname %{name} 2.0 %{major1}
%define libnamedev %mklibname -d %{name}
%define bootstrap 0
%{?_with_bootstrap: %{expand: %%global bootstrap 1}}
%define monodir %_prefix/lib/mono
@carmelopellegrino
carmelopellegrino / strsignal.c
Created January 17, 2015 15:34
Easy way to convert signal number to human readable string
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
if (argc == 2) {
int const n = atoi(argv[1]);
printf("Signal %d corresponds to %s\n", n, strsignal(n));
}
@carmelopellegrino
carmelopellegrino / tabsort.c
Last active August 29, 2015 14:13 — forked from codebrainz/tabsort.c
include corrected
#include <geany/geanyplugin.h>
GeanyData *geany_data;
GeanyPlugin *geany_plugin;
GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(211);
PLUGIN_SET_INFO("Tab Sort",
"Automatically keeps document tabs sorted",