Skip to content

Instantly share code, notes, and snippets.

View exhuma's full-sized avatar
🐢
Slowly advancing on hobby projects

Michel Albert exhuma

🐢
Slowly advancing on hobby projects
View GitHub Profile
@exhuma
exhuma / README.md
Created February 26, 2016 07:04
Flask-Security not working with non-standard id attribute

When using a non-standard id attribute, flask-login does not seem to work. See also pallets-eco/flask-security-3.0#472

This gist contains two examples. One is working, the other one isn't. To test, run the app and go to http://localhost:5000

Login: [email protected] Password: admin

When using working.py, you should see an 'OK' message.

When using broken.py the login will simply not work, and you'll be presented with a new login page.

@exhuma
exhuma / list.rst
Last active December 29, 2015 22:30
Total Biscuit GOTY

Total Biscuit - TOP 10 of the Year

10 - Mad Max

  • Open World
  • Car-Shooter

9 - Sunless Sea

#!/bin/bash
#
# Script to find lingering PostgreSQL data files.
#
# Those files can usually be safely removed from disk.
#
# Use at your own risk!
#
# Based on http://dba.stackexchange.com/a/121876/34652
@exhuma
exhuma / 3col.grid
Created November 7, 2015 09:21
GridMove setup for 3 Columns per screen
[Groups]
NumberOfGroups = 9
[1]
TriggerTop = [Monitor1Top]
TriggerRight = [Monitor1Left] + [Monitor1Width] / 3
TriggerBottom = [Monitor1Bottom]
TriggerLeft = [Monitor1Left]
[2]
@exhuma
exhuma / Main.java
Created May 15, 2015 15:04
"Flowing" RecyclerView
public class LostMobile extends Activity {
// [... snip ...]
mMainRecycler = (RecyclerView) findViewById(R.id.mainList);
mMainRecycler.setHasFixedSize(true);
mMainRecycler.setLayoutManager(new LinearLayoutManager(this));
mMainListAdapter = new MyAdapter(this, remoteMap);
// [... snip ...]
mMainRecycler.setAdapter(mMainListAdapter);
@exhuma
exhuma / tester.py
Created September 12, 2014 20:30
Cluster Tester
from __future__ import print_function
from difflib import SequenceMatcher
def mean(numbers):
"""
Returns the arithmetic mean of a numeric list.
see: http://mail.python.org/pipermail/python-list/2004-December/294990.html
"""
return float(sum(numbers)) / float(len(numbers))
@exhuma
exhuma / README.rst
Last active August 29, 2015 14:01
Closure RTE as part of a larger Component.

README

This example shows the use of a richtext-editor component as part of another, larger component.

The Problem

While the component shows up properly, the rendered IFRAME does not take up the full width of the editor. A wild guess is that the IFRAME is rendered before the width is available.

@exhuma
exhuma / idioms.rst
Last active August 29, 2015 13:55
Useful Python Idioms/caveats you might find useful if coming from another language.
┌─[10:15:19] michel@PC12-331
└─~/tmp› cat fabfile.py
import fabric.api as fab
fab.env.roledefs['staging'] = ['bbs-evolution.ipsw.dt.ept.lu']
fab.env.roledefs['prod'] = ['bbs-arbiter.ipsw.dt.ept.lu']
@fab.task
@exhuma
exhuma / colourised_log_example.py
Last active September 1, 2017 12:04
Simple python log formatter for colourised terminal output.
"""
Example for a colourised logging output.
This example uses "blessings" to handle console escape sequences. ``blessings``
itself is a very harmless package in that it does not have any external
dependencies. And it's code-base is very clean and small.
The example extends the core logging formatter (logging.Formatter) and
colourises the complete line. This takes advantage of any upstream updates
related to logging. When writing this against Python 2.7, the parent code