Skip to content

Instantly share code, notes, and snippets.

@julien-h
julien-h / Dockerfile
Created January 13, 2021 18:50
Run Ganache GUI in a docker container
FROM debian:stable-slim
RUN apt-get update
RUN apt-get install -y wget libgtk-3-dev libgtkextra-dev libgconf2-dev libnss3 libasound2 libxtst-dev libxss1 libx11-6 libx11-xcb-dev
RUN wget https://github.com/trufflesuite/ganache/releases/download/v2.5.4/ganache-2.5.4-linux-x86_64.AppImage
RUN chmod +x ganache-2.5.4-linux-x86_64.AppImage
RUN ./ganache-2.5.4-linux-x86_64.AppImage --appimage-extract
RUN rm ganache-2.5.4-linux-x86_64.AppImage
ENV DISPLAY=host.docker.internal:0
EXPOSE 7545

Tests

I wrote tests to make sure the code before and after the refactoring produced the same results. The tests are not perfect, and I don't consider them as a product of my work to be shipped with the refactored code. Rather, they were a tool that enabled me to work faster and more safely.

As the code was tightly coupled to the GUI and the I/O (writing files rather than returning data), I had to write end-to-end tests that simulate mouse input and check the resulting files. On the time budget that I allowed myself, I couldn't get pytest-qt to work on the lab's machines, and ended up running the test on my own machine, which is not Ubuntu based. Since pytest-qt simulates mouse input, the tests are tightly coupled to the window's size and my screen resolution, they are platform dependent, machine dependent, and require significant setup to be run on another machine.

I found no easy way to make the tests sufficiently robust to be useful for everyone. They break often for reasons independent from t

@julien-h
julien-h / deepfly_refactoring_report.md
Created December 9, 2019 10:02
Preliminary report for my semester project about the refactoring of `deepfly`, a python application.
title category date tags summary
Refactoring a graphical application: DeepFly3D
technical blog
2019.12.03
python

Abstract

@julien-h
julien-h / python-signals.py
Last active December 27, 2018 21:12
How to catch and handle signals in python3
#
# https://scripting.tips/complete-guide-to-writing-command-line-tools.html
#
# How to handle signals in python
# Use ctrl+c to send SIGINT and ctrl+z to send SIGTSTP (then `fg` to send SIGCONT)
#
import signal, time, sys, os
import logging
from logging import info
@julien-h
julien-h / mouse_tracker.cpp
Last active June 17, 2021 15:40
This gist show how to use LowLevelMouseProc to print mousemove events. You can find a detailed article about it on this website: https://scripting.tips/
/*
* How to track the mouse using LowLevelMouseProc on Windows
* With proper error handling and resources cleaning.
*
* Copyright (C) 2018 Julien Harbulot
* Produced for https://scripting.tips
*
* LICENCE
* You may do whatever you want with this code as long as you
* credit me and keep the link to https://scripting.tips in the notice.
@julien-h
julien-h / send-email.py
Last active January 15, 2022 18:57
Template to send emails using the python-emails library. Install it with `pip install emails`.
# Sending emails from python.
# Template provided by https://Scripting.Tips
# You may freely reuse, modify and share this piece of code
import emails
# Here goes the configuration of your email provider.
# Look online to find it.
# For instance for Yahoo!Mail:
@julien-h
julien-h / BeautifulSoup scraping in python3
Created June 11, 2018 07:10
Scrapping with urllib and BeautifulSoup / python3
# First, use URLLIB to fetch HTML files
# -----------------------------------------------------------------------
from urllib.request import Request, urlopen
from urllib.error import URLError
def get_html(url):
# construct an http request for the given url
req = Request(url,
data=None,
@julien-h
julien-h / Basic scrapping in python
Last active June 30, 2018 23:31
Basic script to scrap a website with python using the standard library. More error checking should go into it.
# -----------------------------------------------------------------------
from urllib.request import Request, urlopen
from urllib.error import URLError
def get_html(url):
# construct an http request for the given url
req = Request(url,
data=None,
headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3)'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Math Book Template
% Features:
% - Boxed theorem, definition, etc.
% - Clever references using page number and hyperlink
% - French encoding
%
% Author: Julien HARBULOT
% Licence: MIT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@julien-h
julien-h / gaussian_distribution_approximation_graph
Last active March 17, 2018 14:00
Python3 code to show the convergence of a function to the Gaussian distribution using matplotlib animations
#
# Animated graph of two functions whose difference tends to 0 as n -> inf
# Using matplotlib.animation
#
# author: Julien Harbulot
# article url: http://julienharbulot.com/data-science/bernoulli-urn/
# licence: MIT Licence
#
%matplotlib inline