Skip to content

Instantly share code, notes, and snippets.

View fbeneventi's full-sized avatar

Francesco Beneventi fbeneventi

  • University of Bologna
  • Bologna, Italy
View GitHub Profile
@fbeneventi
fbeneventi / simple-https-python-server.py
Created September 16, 2022 17:00 — forked from Alexufo/simple-https-python-server.py
Simple Python https server example py 3.10+
import http.server
import socket
import ssl
import os
server_address = ('0.0.0.0', 9000)
hostname = socket.gethostname()
local_ip = socket.gethostbyname(hostname)
print("Open https://localhost:9000")
@fbeneventi
fbeneventi / status2json.py
Created September 8, 2022 20:50 — forked from alexwright/status2json.py
Parse the Nagios status.dat and poop out some JSON
#!/usr/bin/env python
import re
import json
STATUS_FILE_PATH = "/var/cache/nagios3/status.dat"
def read_status():
hosts = {}
services = {}
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Raycaster</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
</head>
<body>
<div class="container-fluid fixed-top header disable-selection">
@fbeneventi
fbeneventi / kairosdb-stress.yaml
Created September 22, 2020 13:18 — forked from tzach/kairosdb-stress.yaml
cassandra-stress for KairosDB
### DML ###
# Keyspace Name
keyspace: kairos
# The CQL for creating a keyspace (optional if it already exists)
keyspace_definition: |
CREATE KEYSPACE kairos WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2};
# Table name
@fbeneventi
fbeneventi / tmux.md
Created May 5, 2020 19:27 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@fbeneventi
fbeneventi / object_pool.py
Created December 5, 2019 14:24 — forked from pazdera/object_pool.py
Example of `object pool' design pattern in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `object pool' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@fbeneventi
fbeneventi / clean-up-boot-partition-ubuntu.md
Created November 19, 2019 11:15 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@fbeneventi
fbeneventi / simple_python_datasource.py
Last active August 23, 2020 01:12 — forked from linar-jether/simple_python_datasource.py
Grafana python datasource - using pandas for timeseries and table data. inspired by and compatible with the simple json datasource
from flask import Flask, request, jsonify, json, abort
from flask_cors import CORS, cross_origin
import pandas as pd
import numpy as np
app = Flask(__name__)
cors = CORS(app)
@fbeneventi
fbeneventi / PySpark DataFrame from many small pandas DataFrames.ipynb Convert a RDD of pandas DataFrames to a single Spark DataFrame using Arrow and without collecting all data in the driver.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fbeneventi
fbeneventi / gist:c380bfc2cee14aac4e4e0d5692d1f66c
Created April 29, 2019 23:42 — forked from mdbecker/gist:1309633
multiprocess && gevent example
from multiprocessing import Pool as MPool
from time import sleep
import datetime
import multiprocessing
import random
def time_request():
from gevent import monkey; monkey.patch_socket
from jsonrequester import JsonRequester