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 / boolsel.py
Last active December 5, 2018 11:07
Extract items from an iterable based on a boolean condition
def boolean_selector(iterable, condition):
"""Extract the next item of a conditional group out of an iterable.
Given an iterable and a condition function over its elements, this function
returns two iterators which can be used to pick the next element out of
the iterable based on the desired boolean condition function.
Example:
div5, non_div5 = boolean_selector(range(100), lambda x: x % 5 == 0)
@akiross
akiross / Pipfile
Last active December 5, 2018 11:45
Basic json-log viewer with filtering
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[dev-packages]
neovim = "*"
[packages]
flask = "*"
@akiross
akiross / view_rotation.py
Created December 3, 2018 09:53
Plot rotation against x,y (similar to gnuplot surface rotation)
# This is a pseudocode tbh
def on_mouse_move(self, pos):
# Normalized distance of cursor motion
dist = (pos - self.last_mouse_pos) / (win_w, win_h)
# Build rotation matrices around
# y axis (when moving mouse horizontally)
rot_x = rotation_matrix(260 * dist.x(), 0, 1, 0)
# x axis (when moving mouse vertically)
rot_y = rotation_matrix(260 * dist.y(), 1, 0, 0)
@akiross
akiross / file-hdf5.py
Created November 29, 2018 14:33
GIMP Python plugin to load and save HDF5 files
#!/usr/bin/env python2
#
# GIMP Plug-in for HDF5 files
# https://www.hdfgroup.org/solutions/hdf5/
#
# Copyright 2018 by Alessandro Re <[email protected]>
#
# 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
@akiross
akiross / fedora_remote.md
Last active November 6, 2018 22:41
Remoting Fedoring

This is just a draft, I'm writing down few notes and I'll try to make this workable knowledge when I'll have actually tested it thoroughly.

Remote working with Fedora (among Fedora)

Assuming you got a decent version. I'm running F28, but F29 is out since a few days. With GNOME 3.30 you should have your life easier.

@akiross
akiross / sdl.go
Created November 1, 2018 14:17
sdl surface as drawable image
type Surface sdl.Surface
func (s *Surface) ColorModel() color.Model {
switch s.Format.Format {
case sdl.PIXELFORMAT_ARGB8888, sdl.PIXELFORMAT_ABGR8888:
return color.RGBAModel
case sdl.PIXELFORMAT_RGB888:
return color.RGBAModel
default:
@akiross
akiross / dropbox_upload_large.py
Last active October 25, 2018 11:18 — forked from PetrGlad/dropbox_upload_large.py
Upload large files to dropbox
#!/usr/bin/env python3
# This tool helps uploading (large) files on your dropbox, without having to install it.
# First, be sure to create an app for this to run and generate a token:
# https://www.dropbox.com/developers/apps
# Setting up example
# $ python3 -m venv venv_dbx
# $ . ./venv_dbx/bin/activate
@akiross
akiross / pipetest.py
Created October 15, 2018 13:53
A demo code to show what happens when pipe buffer get filled.
"""This code runs a subprocess that produces a large amount of data, while
the main process reads the data at a slower pace. What happens on the long run?
This program is a demo showing what happens when a pipe buffer gets filled.
"""
import io
import sys
import time
import textwrap
import tempfile
"""Given a root directory, search for Pipfiles in it and
produce the corresponding pipenv names.
This script can be useful to find lost project directories.
Python 3.6 is required (for f-strings).
This code is public domain.
"""
import os
import sys
@akiross
akiross / checkboxes.html
Last active June 17, 2018 17:11
A collaborative checklist using SwellRT
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Collaborative checklist</title>
</head>
<body>