Skip to content

Instantly share code, notes, and snippets.

View angristan's full-sized avatar
:shipit:
o(≧▽≦)o

Stanislas angristan

:shipit:
o(≧▽≦)o
View GitHub Profile
@angristan
angristan / rename.rb
Created December 1, 2018 14:44
Ruby script ro rename all of a dir's files with random names
directory = 'directory/'
new_base_filename_length = 10
Dir.glob(directory + '*').sort.each do |old_filename|
new_base_filename = ('a'..'z').to_a.shuffle[0, new_base_filename_length].join
new_filename = directory + new_base_filename + File.extname(old_filename)
File.rename(old_filename, new_filename)
end
@angristan
angristan / test.sh
Created February 9, 2019 12:52
Lint shell executables with shellcheck
#!/bin/bash
set -e
set -o pipefail
ERRORS=()
# find all executables and run `shellcheck`
for f in $(find . -type f -not -iwholename '*.git*' | sort -u); do
if file "$f" | grep --quiet shell; then
{
@angristan
angristan / rankmirrors.sh
Created February 13, 2019 12:39
Get fast pacman mirrors on Arch
#!/bin/bash
country=FR
cd /tmp
wget "https://www.archlinux.org/mirrorlist/?country=${country}&protocol=http&protocol=https&ip_version=4&ip_version=6" -O mirrorlist.tmp
sed -i 's/^#Server/Server/' mirrorlist.tmp
rankmirrors mirrorlist.tmp > mirrorlist
sudo cp mirrorlist /etc/pacman.d/mirrorlist
@angristan
angristan / psql_migration.md
Last active February 16, 2019 21:57
Mastodon DB migration

Migrating the Mastodon database

On the old server

postgres@postgresql:~$ pg_dump -Fc mastodon -f mastodon.dump

OR

@angristan
angristan / mysql-cheatsheet.md
Last active June 27, 2019 21:33
MySQL cheatsheet

Manage databases

Create database

CREATE DATABASE database;

Delete database

{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"fill": 1,
"gridPos": {
"h": 9,
"w": 12,
@angristan
angristan / install-arch.sh
Last active February 12, 2020 17:51
Install Arch Linux
# Prepare env
timedatectl set-ntp true
timedatectl set-timezone Europe/Paris
# Partition disk
parted /dev/sda mklabel gpt
parted -a optimal /dev/sda mkpart primary fat32 0% 512MB
parted /dev/sda set 1 esp on
parted -a optimal /dev/sda mkpart primary linux-swap 512MB 2560MB
parted -a optimal /dev/sda mkpart primary ext4 2560MB 100%
import ply.yacc as yacc
import ply.lex as lex
from genereTreeGraphviz2 import printTreeGraph
tokens = (
'NUMBER', 'MINUS',
'PLUS', 'TIMES', 'DIVIDE',
'LPAREN', 'RPAREN', 'PRINT',
'EQUALS', 'NAME', 'IF', 'SEMICOLON',
'GTH', 'LTH', 'GTHOREQUAL', 'LTHOREQUAL', 'EQUALEQUAL', 'NOTEQUAL', )
@angristan
angristan / hosts
Last active May 31, 2020 15:00
Windows 10 Privacy Hosts file
0.0.0.0 choice.microsoft.com
0.0.0.0 choice.microsoft.com.nsatc.net
0.0.0.0 df.telemetry.microsoft.com
0.0.0.0 diagnostics.support.microsoft.com
0.0.0.0 feedback.microsoft-hohm.com
0.0.0.0 feedback.search.microsoft.com
0.0.0.0 feedback.windows.com
0.0.0.0 oca.telemetry.microsoft.com
0.0.0.0 oca.telemetry.microsoft.com.nsatc.net
0.0.0.0 onesettings-bn2.metron.live.com.nsatc.net
@angristan
angristan / fixpngdate.py
Created September 19, 2020 11:43
Fix PNG file date from file name
import datetime
import os
import re
import sys
import time
import piexif
def fix(directory):