Skip to content

Instantly share code, notes, and snippets.

View twidi's full-sized avatar
🕶️

Stéphane "Twidi" Angel twidi

🕶️
View GitHub Profile
@twidi
twidi / dataql_example.py
Created June 15, 2015 16:46
Example file showing how to use dataql
from datetime import datetime, date
from dataql.parser.parsers import DataQLParser
from dataql.solvers.registry import Registry, EntryPoints
# Declare our classes
class User:
users = []
@twidi
twidi / ._README.md
Last active April 10, 2023 06:24
Pycharm and virtualenvwrapper, with postactivate

The problem

PyCharm has support for virtual environment.

But there are two problems:

  1. the virtual environment is not activated in the terminal (it is only in the python console)
  2. it doesn't support virtualenvwrapper and so doesn't run the postactivate file.

This gist is the solution I found to resolve these two problems.

@twidi
twidi / About
Last active August 29, 2015 14:17
Find all non-builtins import in a python project
- we use `ack` (`ack-grep`)
- we assume builtins are marked so, or in a `python*` directory in a `lib` one, but not in `*packages*` (`site-packages for example`)
- everything that cannot be imported is not a builtin package
If your python is not in a "lib/pythonX.Y" directory, you can change the path.
PS: on my machine, it works in a virtualenv
### from Exirel
# Ce que je voudrais
SELECT AVG(last_updated_at - created_at) FROM monapp_item;
# Ceci fonctione
Item.objects.extra(select={'delta': 'last_update_at - created_at'})
# Mais pas ça
Item.objects.extra(select={'delta': 'last_update_at - created_at'}).aggregate(Avg('delta'))
@twidi
twidi / manage_dropbox_images.sh
Last active August 29, 2015 14:06
manage_dropbox_images.sh: The goal of this script is to reduce the size of the dropbox folder where are automatically uploaded images taken with a smartphone, by linking to the same images found in other folders (for example if all images of your smartphone are regularly uploaded to a specific folder)
#!/bin/bash
# The goal of this script is to reduce the size of the dropbox folder
# where are automatically uploaded images taken with a smartphone, by
# linking to the same images found in other folders (for example if all
# images of your smartphone are regularly uploaded to a specific folder)
DIR_CHARG=~/Dropbox/Chargements\ appareil\ photo/
DIR_IMG=~/Dropbox/Photos/Images/
@twidi
twidi / keybase.md
Created September 22, 2014 20:13
keybase.md

Keybase proof

I hereby claim:

  • I am twidi on github.
  • I am twidi (https://keybase.io/twidi) on keybase.
  • I have a public key whose fingerprint is 3905 1403 EAF3 06A4 0464 18CD E4A4 4103 3000 5942

To claim this, I am signing this object:

A journey to python 3: porting redis-limpyd

Introduction

A few weeks ago, I - Twidi - made a proposal to talk about redis-limpyd at Pytong.

And it was accepted. But... the main subject of Pytong is "After python 2".

redis-limpyd currently only works on python 2.6 and 2.7, and as I said during my lightning talk at PyconFR in October 2013 (start at 47:50), "porting to python 3 is on it's way"... but the only thing that was done at this time - and it's still the case as I'm writing these lines - was a simple run of the 2to3 command to see the things that needed to be done, by Yohan Boniface, original author of the project.

jsWarrior.turn = function(warrior) {
// init status
if (!warrior._initialized) {
warrior._side_done = false;
warrior._last_health = 20;
warrior._initialized = true;
}
// check conditions
var health = warrior.getHealth(),
@twidi
twidi / gist:6452666
Created September 5, 2013 16:34
Pleurer...
$('.more-option-search-btn').on('click', function(){
if ($('.navbar-inner .btn.btn-navbar').hasClass('collapsed')) {
$('.view #content').css('width','974px');
$('#menu').hide();
$('.navbar-inner .btn.btn-navbar').removeClass('collapsed');
$('.option-collapse').css('padding','0px');
$('.option-collapse').css('border','none');
$('.view .navbar.navbar-inverse .navbar-inner button i').removeClass('icon-caret-left');
$('.view .navbar.navbar-inverse .navbar-inner button i').addClass('icon-caret-right');
$('.seemore-view-one').removeClass('collapse');
@twidi
twidi / gist:4978998
Created February 18, 2013 17:22
test2
foobar