Skip to content

Instantly share code, notes, and snippets.

View anthonygelibert's full-sized avatar
🦄

Anthony Gelibert anthonygelibert

🦄
View GitHub Profile
@anthonygelibert
anthonygelibert / generateTags.sh
Created February 25, 2021 21:03
Generate tags using `ctags` from classical C/C++ system headers
#!/bin/sh
FILES="/usr/include/stddef.h \
/usr/include/stdint.h \
/usr/include/stdio.h \
/usr/include/stdlib.h \
/usr/include/string.h \
/usr/include/errno.h \
/usr/include/math.h \
/usr/include/pthread.h \
@anthonygelibert
anthonygelibert / exportRL.py
Created February 25, 2021 21:02
Export Safari ReadingList
#!/usr/bin/env python3.8
# coding=utf-8
""" Export Safari ReadingList. """
import os
import plistlib
from pathlib import Path
INPUT_FILE = Path(os.environ['HOME']) / 'Library' / 'Safari' / 'Bookmarks.plist'
@anthonygelibert
anthonygelibert / addZero.sh
Created February 25, 2021 21:00
Add zero host entry to `/etc/host` from given URL
#!/bin/bash
cp /etc/hosts /etc/hosts.tmp
echo "# $1" >> /etc/hosts
echo "$1" | sed -r 's_https?://([^/]*)/.*_0.0.0.0 \1_' >> /etc/hosts
@anthonygelibert
anthonygelibert / upHosts.sh
Last active February 25, 2021 20:58
Update /etc/hosts with the "Zero Hosts" file
#!/bin/sh
# wget -O /etc/hosts.tmp https://someonewhocares.org/hosts/zero/hosts
wget -O /etc/hosts.tmp https://sebsauvage.net/hosts/hosts
icdiff -U 0 /etc/hosts /etc/hosts.tmp
sudo mv /etc/hosts{.tmp,}
@anthonygelibert
anthonygelibert / opml2html.php
Created May 28, 2016 21:16
OPML to HTML converter
#!/usr/bin/php
<?php
function usage()
{
return "Usage: php convert.php /path/to/opml_file.opml > output.html\r\n";
}
# Print usage if need be.
if(count($argv) < 2) die(usage());
# Grab the file path.
$f = $argv[1];
@anthonygelibert
anthonygelibert / getJO.sh
Created May 28, 2016 21:11
Script to automate the downloading of French JO
#!/bin/sh
YEAR=`date +%Y`
MONTHDAY=`date +%m%d`
COMPLETE=`date +%Y%m%d`
DAY=`date +%j`
WEEK=`date +%V`
CHRONO_CORRECT=0
CHRONO_NB=`expr ${DAY} - ${WEEK} - ${CHRONO_CORRECT}`
CHRONO=$(jot -w "%04i" - $CHRONO_NB $CHRONO_NB)
@anthonygelibert
anthonygelibert / cleanTempFiles.sh
Created May 28, 2016 21:08
Clean all the temporary files in my OS X
#!/usr/bin/env zsh
cd /var/log
# Clean all the old logs
rm -v **/*.bz2
rm -v **/*.gz
rm -v **/*.log.[0-9]
TODAY="$(date "+%Y.%m.%d")"
TODAY2="$(date "+%Y%m%d")"
@anthonygelibert
anthonygelibert / cleanSQLiteDB.sh
Created May 28, 2016 21:06
Clean SQLite databases (using VACUUM command)
#!/usr/bin/env zsh
for i in **/*.(db|db3|apdb|alfdb|sqlite|sqlite3|dsidx|gcdata|xcindexdb)(.D); do
if [[ -z "$(file $i | grep SQLite)" ]]; then
continue
fi;
local -i initialSize="$(du "$i" | cut -f1)"
sqlite3 "$i" "VACUUM;" 2> /dev/null
[ $? -ne 0 ] && echo "\\033[31mProblem with: $i\\033[0m" && continue
local -i newSize="$(du $i | cut -f1)"
@anthonygelibert
anthonygelibert / cleanLatex.sh
Created May 28, 2016 21:04
Clean LaTeX files
#!/usr/bin/env sh
for i in "$@"; do
sed -i'.tmp'\
-e 's/« /\\og{}/g' \
-e 's/ »/\\fg{}/g' \
-e 's/ ?/~?/g' \
-e 's/ :/~:/g' \
-e 's/ ;/~;/g' \
-e 's/« /\\og{}/g' \

Keybase proof

I hereby claim:

  • I am anthonygelibert on github.
  • I am anthonygelibert (https://keybase.io/anthonygelibert) on keybase.
  • I have a public key whose fingerprint is 61ED 1E01 E78A 7558 8671 6DA0 8F70 71D9 A11C 2587

To claim this, I am signing this object: