Skip to content

Instantly share code, notes, and snippets.

Avatar
✏️
on Wikipedia

Baptiste Fontaine bfontaine

✏️
on Wikipedia
View GitHub Profile
@bfontaine
bfontaine / har2etc.jq
Last active Aug 24, 2020
Extract cookies off a .har file and export them for the EditThisCookie browser extension for testing purposes
View har2etc.jq
# HAR to EditThisCookie converter
def domain:
.url
| sub("^https?://"; "")
| sub("/.*"; "");
def cookies:
domain as $d
| .cookies|map(. + {"domain": $d,
View stitch.sh
#! /bin/bash -e
# https://wiki.panotools.org/Panorama_scripting_in_a_nutshell
# http://hugin.sourceforge.net/tutorials/scans/en.shtml
# This is a tool to vertically stitch together screenshots of black and white
# scans.
#
# Install:
#
# brew cask install hugin
@bfontaine
bfontaine / aoc2018-p07.py
Last active Nov 16, 2019
Solution to Advent of Code 2018 problem 7.1 in Python3 in 163 chars. Your input file must be named "T".
View aoc2018-p07.py
G={}
for L in open("T"):a,b=L[5::31];G={a:set(),**G};G[b]=G.get(b,{a})|{a}
while G:C=min(c for c in G if not G[c]);G={c:G[c]-{C}for c in G if c!=C};print(C,end="")
View impots.py
# -*- coding: UTF-8 -*-
# get data from https://www.data.gouv.fr/fr/datasets/audiences-quotidiennes-des-principaux-sites-web-gouvernementaux/
# and drop CSVs in the current directory: 2016.csv, 2017.csv, etc.
# also, pip install numpy scipy
import csv
import numpy as np
from scipy import stats
View README.md

Estimate the number of lines in a large file

Get the size of the file:

$ wc -c myfile.jsons
104431233268 myfile.jsons

Then pipe it through head to take only e.g. 1/1000th of the file:

View keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

View replace.md

Perl:

"test" =~ s/(.*)$/\1s/gr # => "testss

Ruby (same engine as Perl):

"test".gsub(/(.*)$/, "\\1s") # => "testss"
@bfontaine
bfontaine / README.md
Created Oct 10, 2017
Sort lines by some command
View README.md

sort-by

Usage

cat ... | sort-by your command ...

Example

$ cat toto.jsons 
{"a": 1, "b": 2}
View README.md

1. Install virtualenv

wget https://git.io/vdcF4 -O install_virtualenv.sh && chmod +x install_virtualenv.sh
./install_virtualenv.sh

2. Create your virtual env

View meq.sh
#! /bin/bash
# meq = multi-line eq
# See https://github.com/jonase/eq#eq-edn-query
EQ=eq
while read line; do echo "$line" | $EQ $@ ; done
You can’t perform that action at this time.