Skip to content

Instantly share code, notes, and snippets.

Avatar

Antoine Mazières mazieres

View GitHub Profile
View remember.py
#!/usr/bin/env python3
import subprocess
def cli(cmd_str):
process = subprocess.Popen(cmd_str, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)
output, error = process.communicate()
output, error = [x if len(x) > 0 else None
for x in (output.decode().strip(), error.decode().strip())]
View keybase.md

Keybase proof

I hereby claim:

  • I am mazieres on github.
  • I am mazieres (https://keybase.io/mazieres) on keybase.
  • I have a public key whose fingerprint is 5C72 B759 A3D8 F135 0B23 A459 8356 48CC 0077 40FD

To claim this, I am signing this object:

@mazieres
mazieres / namograph.ipynb
Created Apr 25, 2018
Python companion to the work described here : https://namograph.antonomase.fr/
View namograph.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View flatten.py
def flatten(li):
return [item for sublist in li for item in sublist]
View progressbar.py
import progressbar
i = 0
with progressbar.ProgressBar(max_value=len(entities)) as bar:
for entity in entities:
compute_metrics(entity)
i += 1
bar.update(i)
View keybase.md

Keybase proof

I hereby claim:

  • I am mazieres on github.
  • I am mazieres (https://keybase.io/mazieres) on keybase.
  • I have a public key ASDzCRM2QkTnZ8Im0Yw210zPZZ54GykPj9xwJ6gw6bki0Qo

To claim this, I am signing this object:

View parse_github_archive.py
import json
from json.decoder import WHITESPACE
def iterload(string, cls=json.JSONDecoder, **kwargs):
decoder = cls(**kwargs)
idx = WHITESPACE.match(string, 0).end()
while idx < len(string):
try:
obj, end = decoder.raw_decode(string, idx)
idx = WHITESPACE.match(string, end).end()
@mazieres
mazieres / zb-data_collect.js
Created Oct 29, 2016
Zeitgeist Borders - Data Collection
View zb-data_collect.js
function mkAllQueries(query) {
var allRes = {}
var promises = []
for (var i = 0; i < nb_hls; i++){
promises.push($.getJSON(apiUrl, {
"client": "firefox",
"hl": hls[i],
"q": query
})
.done(function (hl, q) {
@mazieres
mazieres / ip2location.go
Created Sep 29, 2016
Lookup the location attributed to an IP by IP2Location Lite Country DB (https://lite.ip2location.com/database/ip-country)
View ip2location.go
package main
import (
"bufio"
"encoding/csv"
"errors"
"fmt"
"io"
"log"
"os"
View encodings_google.py
# dict of conversion of google's charset to python codec name
enc_google_to_python = {
"windows-1257": "cp1257",
"GB2312 ": "gb2312",
"windows-874": "cp874",
"EUC-KR": "euc_kr",
"Shift_JIS": "shift_jis",
"UTF-8": "utf_8",
"ISO-8859-2": "iso8859_2",
"ISO-8859-9": "iso8859_9",
You can’t perform that action at this time.