Skip to content

Instantly share code, notes, and snippets.

View akiross's full-sized avatar
🥷
Ninja

Alessandro Re akiross

🥷
Ninja
View GitHub Profile
@akiross
akiross / qt_event_loop
Last active August 29, 2015 14:17
Event loop with QtQuick
#!/usr/bin/env python3
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtQuick import *
from PyQt5.QtWidgets import *
import sys
class Rect(QQuickPaintedItem):
def __init__(self, parent=None):
#!/usr/bin/env python3
from deap import gp, base, creator, tools, algorithms
import itertools
import operator
import random
import math
def converter(value):
return value / 100
def generate_rec(pset, min_, max_, condition, type_=None):
'''This is a recursive generation function for STGP, which will
try to generate trees without giving errors for missing primitives.
Basically, if a primitive fails, it removes it from the
list of primitives and try again.'''
height = random.randint(min_, max_)
def _rec_gen(type_, depth, is_term):
if is_term:
try:
@akiross
akiross / contents_scale_test.py
Last active June 11, 2021 09:10
Zooming QtQuick Painted item using contents size
#!/usr/bin/env python3
from PyQt5.QtGui import QPainter
from PyQt5.QtCore import *
from PyQt5.QtQuick import *
from PyQt5.QtWidgets import *
class Item(QQuickPaintedItem):
def __init__(self, useBoundRect, parent=None):
super().__init__(parent)
@akiross
akiross / yin_yang.py
Created June 2, 2015 23:15
Drawing the yin-yang with Python3 turtle.
from turtle import *
RAD = 100
RAD2 = RAD / 2
RAD6 = RAD / 6
degrees() # Switch to degrees
# Draw the circle, radius 100, half black
fillcolor('black')
begin_fill()
@akiross
akiross / llfuse_tutorial.md
Last active January 18, 2018 04:31
A simple step-by-step tutorial for llfuse in Python3

llfuse tutorial in python3

The only package I have for FUSE + Python3 is python3-llfuse (llfuse for short). I wanted to start easily, but who cares: I'll go the hard way. Sadly, Fedora uses an outdated version (as 30 Sept 2015): 0.40, which is from 2013, but llfuse had some nice updated lately, so I want the pip version. dnf install fuse-devel libattr-devel are enough (here) to make pip3 install llfuse smoothly.

I am now using the version 0.41.1, but other changes have been made.

Before continuing: let make me clear that I am not a fuse expert, I am not a kernel expert, I am not a filesystem expert or database expert. This is my first experience with fuse.

What's the deal: the llfuse python package uses the low-level FUSE API, which means that it's a lil bit harder, because instead of providing very practical functions to work on your filesystem, you will have to work with various inodes and structures. Well, I don't care right now, I am learning about fuse, so...

@akiross
akiross / wawe.py
Last active December 2, 2015 15:59
Waving circles (atoms?) with turtle
#!/usr/bin/env python3
import turtle as t
from collections import defaultdict
# Parameters
count = 10
spacing = 25
radius = 0.3
step_rot = 3
#!/usr/bin/env python3
from collections import Counter
import sys
def subset(a, b):
'''Checks if a is subset of b'''
for k in a:
if k not in b or b[k] < a[k]:
return False
@akiross
akiross / imgaverage.py
Created January 18, 2016 14:13
A very simple tool for making average of similar images
#!/usr/bin/env python3
import os
import re
import numpy as np
from ast import literal_eval as make_tuple
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
@akiross
akiross / bunch_downloader.gs
Last active April 13, 2016 12:00
This is a Google App Script that "downloads" many attachment at once to Google Drive. Label the mails to download with "GmailDownload" and run the script.
function onOpen() {
// Setup the drive folder
var date = new Date();
var fold = DriveApp.createFolder("GmailDownload-" + date.toISOString());
var log = "";
// Get the label with gmail threads
var label = GmailApp.getUserLabelByName("DriveDownload");