Skip to content

Instantly share code, notes, and snippets.

View elehcim's full-sized avatar
🔭

Michele Mastropietro elehcim

🔭
View GitHub Profile
@marazmiki
marazmiki / daemon.py
Created September 4, 2012 07:53
Python daemon example
#!/usr/bin/env python
# coding: utf-8
import argparse
import os
import sys
import time
import atexit
import logging
import signal
anonymous
anonymous / Makefile
Created May 26, 2013 18:55
Laplacian operator in Julia and C.
all : laplace.so
laplace.so : laplace.h laplace.c
gcc -O3 -fopenmp -fPIC -c laplace.c
gcc -O3 -fopenmp -fPIC -shared -o liblaplace.so laplace.o
rm -f laplace.o
clean:
rm -f laplace.so
@staticfloat
staticfloat / debugging.md
Last active February 24, 2017 03:11
Julia Debugging Procedures

Julia Debugging Procedures

So you managed to break Julia. Congratulations! Collected here are some general procedures you can undergo for common symptoms encountered when something goes awry. Including the information from these debugging steps can greatly help the maintainers when tracking down a segfault or trying to figure out why your script is running slower than expected.

If you've been directed to this page, find the symptom that best matches what you're experiencing and follow the instructions to generate the debugging information requested. Table of symptoms:

@helgee
helgee / doptest.f90
Last active December 31, 2015 17:19
program doptest
implicit none
double precision :: x
double precision :: xend
double precision, dimension(1) :: rtol
double precision, dimension(1) :: atol
double precision, dimension(6) :: y
double precision, dimension(6) :: y1
@takluyver
takluyver / README.md
Created September 6, 2014 21:44
Flatten notebooks for git diff

Copy nbflatten.py to somewhere on $PATH. Then, in the root of a git repository, run these commands:

echo "*.ipynb diff=ipynb" >> .gitattributes 
git config diff.ipynb.textconv nbflatten.py

When you change a notebook and run git diff, you'll see the diff of flattened, simplified notebooks, rather than the full JSON. This does lose some information (metadata, non-text output), but it makes it easier to see simple changes in the notebook.

This doesn't help with merging conflicting changes in notebooks. For that, see nbdiff.org.

@jakevdp
jakevdp / discrete_cmap.py
Last active March 8, 2024 14:54
Small utility to create a discrete matplotlib colormap
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""
#!/bin/sh
jq -r 'def banner: "\(.) " + (28-(.|length))*"-";
("Non-cell info" | banner), del(.cells), "",
(.cells[] | ("\(.cell_type) cell" | banner),
"\(.source|add)",
if ($show_output == "1") then
"",
( select(.cell_type=="code" and (.outputs|length)>0) |
("output" | banner),
(.outputs[] |
@whizzzkid
whizzzkid / XPS-15 9560 Getting Nvidia To Work on KDE Neon
Last active December 3, 2022 15:43
[XPS 15 Early 2017 9560 kabylake] Making Nvidia Drivers + (CUDA 8 / CUDA 9 / CUDA 9.1) + Bumblebee work together on linux ( Ubuntu / KDE Neon / Linux Mint / debian )
# Instructions for 4.14 and cuda 9.1
# If upgrading from 4.13 and cuda 9.0
$ sudo apt-get purge --auto-remove libcud*
$ sudo apt-get purge --auto-remove cuda*
$ sudo apt-get purge --auto-remove nvidia*
# also remove the container directory direcotory at /usr/local/cuda-9.0/
# Important libs required with 4.14.x with Cuda 9.X
$ sudo apt install libelf1 libelf-dev
@alexanderhupfer
alexanderhupfer / main.py
Last active November 15, 2019 10:50
Display logfile in realtime with bokeh
# Plot logtime in realtime using bokeh and tail -f
# Tested with python 3.5 and bokeh 0.12.4
# OSX/Linux only
# usage:
# 1. run 'bokeh serve'
# 2. run 'python3.5 main.py logfile.csv'
# assumes a logfile.csv with format:
# min_ask,1489758134.150000,1077.00,1076.78,0.45
# max_bid,1489758139.660000,1076.56,1076.76,0.41
# min_ask,1489758142.076000,1076.95,1076.76,0.40
@MarcoBuster
MarcoBuster / Stazioni italiane.csv
Last active March 23, 2023 12:51
Lista delle stazioni ferroviarie civili italiane, fruibile da ricerca e tabella .csv
code region long_name short_name latitude longitude
S01427 1 Ardenno Masino Ardenno Masino 46.16198 9.651374
S01947 1 Arena Po Arena Po 45.082065 9.360394
S01847 1 Asola Asola 45.220454 10.402313
S01041 1 Corbetta S. Stefano Corbetta S.Stef. 45.480829 8.917457
S01424 1 Cosio Traona Cosio Traona 46.135564 9.525498
S01207 1 Gazzada Schianno Morazzone Gazzada Schian.M 45.77862 8.824815
S02381 1 Gazzo Di Bigarello Gazzo Di Bigarel 45.176648 10.894005
S01841 1 Ghedi Ghedi 45.409439 10.280506
S02382 1 Castel D`Ario Castel D'Ario 45.183399 10.97531