Skip to content

Instantly share code, notes, and snippets.

View b-luu's full-sized avatar

Brice Luu b-luu

  • Disbatch
  • Paris, France
View GitHub Profile
@b-luu
b-luu / LinkedInPostsDateExtractor.js
Created November 9, 2023 10:23
Extract the absolute date of a LinkedIn post, in a human readable format. This is based on interpreting the activity ID, which starts with a binary encoding of the post's timestamp.
// Adapted from https://github.com/Ollie-Boyd/Linkedin-post-timestamp-extractor
function getPostId(linkedinURL) {
// const linkedinURL= document.querySelector("#url").value;
const regex = /([0-9]{19})/;
const postId = regex.exec(linkedinURL).pop();
return postId;
}
function extractUnixTimestamp(postId) {
#! /usr/bin/env python3
import sys
HUMAN_READABLE_UNITS = {1: 'K', 2: 'M', 3: 'G', 4: 'T'}
def format_float(number, decimal=1):
if f"{number:.{decimal}f}"[-1] == "0" and decimal > 0:
return format_float(number, decimal - 1)
return f"{number:.{decimal}f}"
@b-luu
b-luu / persist_live_usb.sh
Created June 6, 2018 09:24
How to make a live usb with persistance from the CLI
## First off, download a (any) distro's ISO/IMG (prefer torrent downloading for robustness...)
# from https://docs.fedoraproject.org/quick-docs/en-US/creating-and-using-a-live-installation-image.html
## Identify the name of the USB drive partition
lsblk -f
## Unmount all mounted partition from that device. This is very important, otherwise the written image might get corrupted. You can unmount all mounted partitions from the device with
sudo umount /dev/sdX* # where X is the appropriate letter, e.g. umount /dev/sdc*.
## Write the ISO file to the device
@b-luu
b-luu / ew_timer.py
Last active May 21, 2018 08:39
(wall) Timing with registry that displays exponentially weighted mean and standard deviation of duration per invocation
"""
example usage:
import time
from math import sqrt
def display_out(timer, func, display=print, erase=False):
if erase:
display = lambda message: print(f"\r{message}", end='')
display(
f"[{timer.name}|{func.__name__}] {timer.iteration}. "
Update-ExecutionPolicy RemoteSigned
Disable-MicrosoftUpdate
Disable-UAC
Disable-BingSearch
Disable-GameBarTips
Move-LibraryDirectory "Personal" "E:\Documents"
Move-LibraryDirectory "My Video" "E:\Videos"
Move-LibraryDirectory "My Pictures" "E:\Photos"
import os
def find_repo_root(start_dir='.'):
start_dir = os.path.abspath(start_dir)
if '.git' not in os.listdir(start_dir):
assert start_dir != '/', "No Git repo found in given folder or its parents."
return find_repo_root(os.path.join(start_dir, '..'))
return start_dir
def get_branch_name(start_dir='.'):

Keybase proof

I hereby claim:

  • I am b-luu on github.
  • I am bluu (https://keybase.io/bluu) on keybase.
  • I have a public key whose fingerprint is 285E 9B2D 4998 0199 CCB7 A756 51F6 2513 CE3F 9F68

To claim this, I am signing this object:

@b-luu
b-luu / RTExport
Created May 20, 2016 04:09 — forked from xurizaemon/RTExport
RescueTime Data Export
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# RescueTime Data Exporter
# Dan Nixon 18/09/2011
# Chris Burgess 03/08/2015
# Brice Luu 20/05/2016
import urllib
import sys