Skip to content

Instantly share code, notes, and snippets.

View akerouanton's full-sized avatar

Albin Kerouanton akerouanton

View GitHub Profile
#!/usr/bin/env node
const Remarkable = require('remarkable');
const toc = require('markdown-toc');
const fs = require('fs');
const puppeteer = require('puppeteer');
const express = require('express');
const generateHtml = (file, serverAddress) => {
const md = new Remarkable({
@akerouanton
akerouanton / list.go
Last active March 1, 2018 00:00
ls and mv (partially) rewritten in go (without perf issues on directory with hundreds of thousands of files)
package main
import (
"os"
"log"
"fmt"
)
func main() {
dir, err := os.Getwd()
<?php
require __DIR__ . '/vendor/autoload.php';
use hollodotme\FastCGI\Client;
use hollodotme\FastCGI\SocketConnections\NetworkSocket;
use hollodotme\FastCGI\SocketConnections\UnixDomainSocket;
use hollodotme\FastCGI\Requests\GetRequest;
if ($argc < 3) {
<?php
require __DIR__ . '/vendor/autoload.php';
$snappy = new \Knp\Snappy\Pdf('/home/knplabs/.config/composer/vendor/bin/wkhtmltopdf-amd64');
for ($i = 0; $i < 1500; $i++) {
$snappy->generateFromHtml('<html>aze</html>', tempnam('/tmp/out/repro235', $i), ['page-size' => 'A4', 'footer-right' => 'Page [page] of [toPage]'], true);
}
<?php
require __DIR__ . '/vendor/autoload.php';
$snappy = new \Knp\Snappy\Pdf('/home/knplabs/.config/composer/vendor/bin/wkhtmltopdf-amd64');
$snappy->generateFromHtml('<html>aze</html>', '/tmp/out/repro216.pdf', ['page-size' => 'A4', 'footer-right' => 'Page [page] of [toPage]'], true);
@akerouanton
akerouanton / todo.md
Last active December 4, 2017 00:21
Disable Ubuntu trackers

Disable Ubuntu trackers

It's totally useless, put your privacy at risk and might hogs your CPU (usually up to one core)... Citing the official documentation, using bullshit words to describe it:

Tracker is a synergy of technologies that are designed to provide a highly sophisticated, innovative and integrated desktop.

You can't uninstall tracker because the package ubuntu-gnome-desktop itself requires it (believe me, it'll deinstall gnome if you try to do it). Still, you can prevent it from autostarting when you open your session:

for file in `ls /etc/xdg/autostart/tracker*`; do

tracker=$(basename ${file/.desktop//})

@akerouanton
akerouanton / README.md
Last active August 22, 2017 14:11
wkhtmltopdf - installation guide and frequent issues

wkhtmltopdf - Installation guide and frequent issues

wkhtmltopdf is a rather complex software, with multiple ways of installing it, many dependencies and many options. It's generally hard to find the perfect configuration to get rid of every issues. This document summarizes the way you can install it, frequent issues and how to solve them.

Introduction

Linux

There're currently two versions available in the download section of wkhtmltopdf.org:

  • Stable version (0.12.x), based on a patched version of Qt4, using a pretty old version of WebKit ;

Keybase proof

I hereby claim:

  • I am nir- on github.
  • I am nisr (https://keybase.io/nisr) on keybase.
  • I have a public key ASDpaTxeqpdXZG4BIC7ejeQwZhrogrqaJVBTF572oIaSbwo

To claim this, I am signing this object:

# ldd /usr/bin/wkhtmltopdf
/lib/ld-musl-x86_64.so.1 (0x560c028d2000)
libwkhtmltox.so.0 => /usr/lib/libwkhtmltox.so.0 (0x7fda8f3ee000)
libQt5Widgets.so.5 => /usr/lib/libQt5Widgets.so.5 (0x7fda8ec6e000)
libQt5Core.so.5 => /usr/lib/libQt5Core.so.5 (0x7fda8e58a000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7fda8e23a000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7fda8e027000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x560c028d2000)
libQt5WebKitWidgets.so.5 => /usr/lib/libQt5WebKitWidgets.so.5 (0x7fda8dde8000)
libQt5WebKit.so.5 => /usr/lib/libQt5WebKit.so.5 (0x7fda8c0d0000)
@akerouanton
akerouanton / cleanup.sh
Created July 2, 2017 23:06
Cleanup Gaufrette buckets
#!/bin/bash
set -o nounset
set -o errexit
# set -o xtrace
buckets=($(aws --profile knplabs s3api list-buckets | awk '{print $3}' | grep gaufrette))
echo "${#buckets[@]} buckets found."
for bucket in ${buckets[@]}