Skip to content

Instantly share code, notes, and snippets.

View PierreSelim's full-sized avatar

Pierre-Selim PierreSelim

  • Toulouse
View GitHub Profile
@PierreSelim
PierreSelim / claim.md
Created August 24, 2016 11:58
Pywikibot claim
# -*- coding: utf-8  -*-
import pywikibot
site = pywikibot.Site("wikidata", "wikidata")
repo = site.data_repository()
# Q42 has P19 Q350
item = pywikibot.ItemPage(repo, u"Q42")
claim = pywikibot.Claim(repo, u'P19')
target = pywikibot.ItemPage(repo, u"Q350")
claim.setTarget(target)
@PierreSelim
PierreSelim / python-batteries.md
Last active August 26, 2016 15:13
Python batteries

List of must known useful libraries in python

  • requests (http client for humans)
  • mysqlclient (using mysql)
  • attrdict (dict as object and object as dict)

requests

Probably the most famous http client for python.

Project page: http://docs.python-requests.org/en/master/

@PierreSelim
PierreSelim / Preferences.sublime-settings
Created July 18, 2016 09:03
My Sublime Text 3 configuration
{
// Line endings
"show_line_endings": true,
"alert_when_line_ending_is": [ "Windows" ],
"auto_convert_line_endings_to": "Unix",
"ensure_newline_at_eof_on_save": true,
// Spaces and indentation
"detect_indentation": true,
"draw_white_space": "all",
@PierreSelim
PierreSelim / parallel-workers-python.md
Last active May 6, 2016 20:23
Parallel Workers in Python

To read: https://gist.github.com/mangecoeur/9540178

Parallel computing can be done in many ways including:

  • using multiple processus, based on fork(). This will yield different result on Windows because Windows do not have fork() system call. I would recommand not using this if you want compatibility on Windows.
  • using multiple threads.

Most python libraries for parallel computing provides a way to use a pool of work in order to map a given list x with a function f. The computation of all the f(x[i]) will be automatically scheduled on the pool of worker (and done in parallel if possible).

Here is two simple ways to use this map methods.

Python Crash Course

If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea.

-- The Zen of Python PEP20

What is Python ?

  • A modern high level programming language
  • with standard types (integer, float, string, list, dictionaries)
@PierreSelim
PierreSelim / git.md
Last active October 26, 2020 14:00
gitcheatsheet

Cheat sheet pour git.

Une page interessante à visiter avant https://gist.github.com/aquelito/8596717

Ne pas laisser git gérer vos sauts de ligne

git config --global core.autcrlf false

Historique propre

Pour éviter les commit de merge lié à vos pull: