Skip to content

Instantly share code, notes, and snippets.

HTTP/1.1 200
content-type: text/plain
vary: Accept-Encoding
x-request-id: ctes5cd3wt8tjd45cj9c99z1eh
x-version-id: 7.5.2.7.5.2.6eded827d979ba5811e115a0dba170de.false
content-length: 2
date: Wed, 15 Mar 2023 10:39:17 GMT
ok
@bfontaine
bfontaine / README.md
Last active May 9, 2022 14:03
Fix g++-5 error when installing eventmachine or sassc gems

Ok this is ugly but it fixes the issue and I haven’t found a better solution.

You have to have g++ installed. Then make a symlink from g++-5 to g++:

cd /usr/bin
sudo ln -s $(which g++) g++-5

And try bundle install again.

@bfontaine
bfontaine / code_golf.awk
Last active December 8, 2021 08:46
Awk code-golf tips
# save 1 char by using 'for' instead of 'while'
x=42;while(c)
for(x=42;c;)
# save 1 char by using a missing variable instead of ""
split($0,b,"")
split($0,b,X)
# use ternary operations when possible
if(c)a else b
@bfontaine
bfontaine / har2etc.jq
Last active August 24, 2020 10:25
Extract cookies off a .har file and export them for the EditThisCookie browser extension for testing purposes
# HAR to EditThisCookie converter
def domain:
.url
| sub("^https?://"; "")
| sub("/.*"; "");
def cookies:
domain as $d
| .cookies|map(. + {"domain": $d,
#! /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 November 16, 2019 13:51
Solution to Advent of Code 2018 problem 7.1 in Python3 in 163 chars. Your input file must be named "T".
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="")

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:

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:

Perl:

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

Ruby (same engine as Perl):

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

sort-by

Usage

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

Example

$ cat toto.jsons 

{"a": 1, "b": 2}