RSSAmplifier

Blog

Julien Palard

Python Developer and Trainer

mdk.frRSS feed ↗45 posts

Latest posts

A checkbox to enable the Django debug toolbar

I like having my Django debug toolbar in production, but that only me can enable...

How I use Sieve

I've been a sieve user since many years, I'm not a sieve ninja, I just use it.

Black screen at boot on my PinePhone

My phone was no longer booting…

Finding a lost iPhone owner, the hard way

My parents found an iPhone, couldn't locate its owner. What I tried next.

Releasing pipe v2.0

Introducing partially parametrized pipes!

How to install any distrib on a Gandi VPS

I needed to install BBB, which requires Ubuntu 18.0.4, but they only had Ubuntu 20.0.4...

How APT does its fancy progress bar

It uses good old VT100 instructions.

HackInScience hits 10k solved exercices per month!

HackInScience is my litlle side-project to teach Python at scale. Last month, ~1000 persons solved ~10k exercices on it.

How I use bash

This is how I use bash, as I presented it at « En attendant la PyCon Fr ».

Reversing a coffee machine key

At $DAYJOB, a long time ago, we had big a coffee machine allowing us to store money in NFC keys…

Python Translation Workshop 3

I'm organizing a 3rd workshop to translate the Python Documentation on 2018-09-20!!! TL;DR, register on meetup.com . The goal is mainly to translate a bit of the documentation, so indirectly to help newcomers with the tools (github / git / poedit / ...). We'll be hosted by Budget Insight, and Pizzas will be …

La PyCon Fr 2018 approche !

La PyCON Fr 2018 c'est dans 4 mois, mine de rien c'est pas si loin, c'est le moment de l'ajouter sur son calendrier. L' appel à présentations est ouvert aussi, vous pouvez y proposer des ateliers, des sprints, ou des présentations (25 mn ou 50 mn). Si vous n'êtes jamais …

Atelier de traduction de la doc de Python

C'est parti, j'ai le GO de la PSF et de NUMA Paris , le 9 janvier 2018 on va faire un atalier pour traduire la documentation de Python en fraçais, ce sera un peu la suite de l'atelier de septembre de la PYCON FR . On en est déjà à 28% traduit …

Compose Key vs Dead Key

L'AFNOR à lancé autour de juin 2017 un appel à commentaires à propos de la normalisation du clavier français , réunissant 3725 retours. Parmis ces retours certains mentionnent la compose key : […] il est possible de composer une quantitée de symboles bien plus grande qu'avec une dead key […] et éventuellement une touche …

Python Documentation Translation

This is an overview of what is done, what we're doing, and what's needs work about the translation of Python documentation. Historical context The first step to ensure every other steps are worth it was to officialize the translations. This is now done with the PEP 545 . PEP 545: TL …

A JustInTime class

I discovered in my code a redundant pattern : private SomeType _something ; private SomeType something { get { if ( _something == null ) _something = new SomeType (....); return _something ;} } Usefull in Silverlight, when your Blender always say "Can't compile ! Strange errors ! but compiles when i comment your WebClient... in ctor of that class..." So i use …

ashttp: vt100 screen scraping exported over HTTP

Originally written for logtop I just wrote a vt100 screen scraper that listen to a port and serve the screen over HTTP. Basically, you want a top (or logtop ;-) ) to be displayed in your website back office ? But top outputs in your terminal and you don't know how to capture …

Automating GNU screen startup

At work I use GNU screen with one window per server (ssh connection), and when I loose my screen, it takes minutes to rebuild the naming and the ssh connections ... So I searched and found a PHP version on Jon's blog but I don't like PHP and don't want a …

[Bashism] How to generate random number without $RANDOM ?

There is a common bashism, that is to use $RANDOM . Typically you'll have to remove bashism while rewriting your scripts for dash or sh. There is a lot of solutions to generate random numbers in many different ways, but I'm not here to pollute the internet demonstrating 42 differents ways …

C# Using alias directives

Just found in section 9.4.1 of the C# language specification: The using keyword can be used to alias a namespace or a type name: using-alias-directive: using identifier = namespace-or-type-name ; You can read more about that here : csharp language specification.doc , Or just try to use it: // As the specification …

Cisco CheatSheet

Misc Get privileges router>enable router# Enter configuration mode router # configure terminal Enter configuration commands , one per line . End with CNTL / Z . router ( config ) # Reset router #copy flash:clean-config startup-config router #reload Configuration router ( config ) # router < protocol > < nbr > router ( config ) # show ip protocols router ( config ) # show running - config auto…

Combinatory logic from scratch

Cause it's sooooo sexy, let's speak about Combinatory Logic! Rule 1: You don't talk about Combinatory Logic Rule 2: You don't talk about Combinatory Logic Rule 3: Combinatory Logic is based on Lambda Calculus (see Wikipedia for both) Rule 4: A combinator is a Lambda expression taking One and only …

Covariance and Contravariance in C#3

A short introduction to Covariance and Contravariance in C# 3 preparing you to an article about that in C# 4 . So what is covariance? Covariance is basically using a method which returns something derived from the expected type. An exemple? It's safe to have a method returning a cat when …

echo and backslash-escaped caracters / new lines: how to write portable scripts ?

While writing shell scripts you are using a lot of echo but did you think about portability of this simple statement? Can you say what will be diplayed, without testing, on your shell, the following tests: echo \n \c '\n' '\c' "\n" "\c" echo -e \n \c '\n' '\c' "\n …

emacs: Highlighting errors for c, python, and other languages

This is a deprecated article about flymake, you should check for flycheck instead. Hi! Today we'll see how to highlight syntax errors in emacs, with exemples for C and Python. First you should learn about flymake-mode In a nutshell Flymake is a minor mode to perform on the fly checks …

Emacs: replace tabs with spaces

When you want to replace tab with spaces or vice versa don't use M-% (query-replace) but M-x tabify or M-x untabify . They work on the current selection so if you want it to be applied to a whole buffer, try C-x h (mark-whole-buffer) before to select the whole buffer.

emacs: standard input is not a TTY

Did you ever tried something like : $ find -name '*.c' | xargs emacs or $ grep -rl snmp . | xargs emacs and got the error "emacs: standard input is not a tty" ? That's normal, as the stdin for emacs is here the pipe, not your tty, you need a workaround to leave the normal …

Exclude directories from recursive grep

How often are you using grep in subversionned folders like that: grep -rni foobar . | grep -v .svn Upgrade to grep 2.5.3 and use (alias it ?) grep -rni --exclude-dir .svn foobar . (or ... stop using SVN !!!)

How to check if a string is valid utf-8

Every day (at least) I'm facing a problem: how to check if a string is valid in utf-8 ? So I wrote a little C program, that I put on my github . Just be aware that pure ASCII is valid UTF-8 and that's not a bug: my program is checking if …

Howto invoke an event via reflection

Why this article ? Because of this note found on the MSDN's EventInfo page: EventInfo is not intended to be used to raise events. An object raises events as dictated by its internal state. Let's try to raise an event with reflection ... Firstly, let's search, but not in GetEvent , in GetField …

Integrating google bookmarks in google chrome

As every developer, you have 42 computers, 8 browsers, and spend a lot of time asking why Google Chrome does not integrate Google Bookmarks? Here is a solution: First add the "Add to Google Bookmarks" bookmarklet from here http://www.google.com/support/chrome/bin/answer.py?hl=en&answer …

Javascript Foncteur

I just discovered, this morning, how to create a Visitor in Javascript: A visitor is an objet who can be used like a function: var my_foncteur = new A_Foncteur (); my_foncteur . can_have_methods ( 42 ); my_foncteur ( "Can be called like a function" ); Implementing it in C++ is extremly easy, using operator overloading, so overloading …

Lazy Loading in php with spl_autload

Today, a very short post about the lazy loading in PHP: spl_autoload . I'll not expose everything about it here, cause it's already done here: http://php.net/autoload . Basically, a Lazy Loading allow you to predifine some paths where PHP should seek for classes to include, this allow you to …

nfsmount: rpc failed: 2

For those, here on the internet, asking themselves what is this fscking rpc failed: 2 while mounting an NFS, it's possible that the response is here: Your NFS client trying to mount the NFS share will use RPC to communicate with the serveur, il will go like: > PORTMAP GETPORT(Program …

Numeric arguments in emacs

I'm starting an 'emacs trick of the day' sequence with: Function name: universal-argument Typical Key binding: C-u How to get help: C-h f universal-argument Usage: C-u Receive a numeric argument that is given to the next called function, when no numeric argument is typed, the value defaults to 4 . So …

Pipe: Infix syntax for Python

Pipe is a Python module enabling infix syntax in Python. For those asking "Why ?" let's take an example: Compare the readability of the classical prefix syntax: sum ( select ( where ( take_while ( fib (), lambda x : x < 1000000 ) lambda x : x % 2 ), lambda x : x * x )) And the infix syntax: fib () | take_while ( lambda …

Post data lost on 301 Moved Permanently

What the hell with 301 Moved Permanently HTTP header!? I'll take an exemple to explain my ugly problem, take, a (very ugly cause it's PHP) index.php , it could be retrieved by using: http://example.com/directory/index.php Got the page, 200 OK or http://example.com/directory/ Got …

Python: Consulting PEPs from command line, while being offline

One day I wished I could read PEPs in the tube on my laptop... so I searched for a convenient way to do so, and I didn't found ... So I wrote a very simple shell script you can found here : https://github.com/julienpalard/pep I'm currently packaging it for …

Python coroutines with async and await

This is a short introduction of the basic vocabulary and knowledge needed to start with async and await , we'll go from "scratch", but not from the whole "let's use generators" era, when everything started, but from a contemporary (Python 3.5) point of view with natives coroutines , async , await . Coroutine …

Python: Introducing ppipe : Parallel Pipe

/!\ this was highly experimental code written in 2011. Today you should NOT use it, just look at it if the subject amuses you. Better take a look at asyncio if you want this kind of tools. I'll speak about my pipe python module so if you didn't know it, you …

Searching and replacing in emacs

Day two of my serie about emacs, about searching and replacing. Function name: isearch-forward Typical Key binding: C-s How to get help: C-h f isearch-forward isearch-forward let you type a string to be searched incrementally in the current buffer, successive following C-s will jump to the next match. Function name …

squid: (101) Network is unreachable when DNS returns IPv6

If you have a Squid proxy configured on a machine that have no IPv6 connectivity, and try to reach an IPv6 compatible site, you squid will try to reach the site using IPv6 (I use squid 3.1.6 from Debian Squeeze) and will fail without even trying IPv4, displaying …

The art of Events

The art of using events to build more independent classes. /* Found a better example */ Imagine you have a class A and a class B. A builds B, and B have to communicate with A (call methods ... ?) Some developers (Boooo (I've done it ... (Booo >> me))) will pass a reference of A …

The ?? operator aka the Null Coalescing Operator

If are familiar to the use of ternary operators, you must have encountered several situations like this one : :::csharp string pageTitle = getTitle() ? getTitle() : "Default Title"; You would want to call getTitle() only once, but then you wouldn't have a simple one-lined initialization of you variable. Actually there is a simple …

YAUIB : Yet another useless IRC Bot !

After 2 years of... non blogging... I'm back! This time I stopped C# (Oh yeah !) and I'm writing a lot of Python! (Oh YEAH !) So to say HELLO I'll present something useless: My Python IRC Bot. But this article should be usefull, so I'll speak about the Unix Philosophy: As …