Skip to content

Instantly share code, notes, and snippets.

View gmolveau's full-sized avatar

Grégoire MOLVEAU gmolveau

View GitHub Profile
@gmolveau
gmolveau / brew-tkinter.md
Created February 27, 2022 20:10
mac os tkinter python3 install brew

ModuleNotFoundError: No module named '_tkinter'

Fix :

brew install python-tk
@gmolveau
gmolveau / cron_timezone.md
Last active May 5, 2022 07:34
cron/crontab with correct local time

cron with correct timezone

sudo apt-get install tzdata
# if already installed use :
sudo dpkg-reconfigure tzdata 

# verify that the time is correct
timedatectl
@gmolveau
gmolveau / tinyRules.css.md
Created January 13, 2022 15:13 — forked from paceaux/tinyRules.css.md
Tiny rules for how to name things in CSS and JS

Tiny rules for how to name stuff

CSS

How to name CSS classes

Stateful Class names

Is it a state that is only one of two conditions? (i.e. a boolean)

@gmolveau
gmolveau / gregouz.zsh-theme
Last active May 8, 2022 13:48
oh-my-zsh theme gregouz
# always use single quote for PROMPT and RPROMPT
# PROMPT = '' on the left
# RPROMPT = '' on the right
# see every numeric color : for code in {000..255}; do print -P -- "$code: %F{$code}Color%f"; done
# text colors : %F{cyan}text%f
# background color : %K{white}%k
# unicode caracter (eg. star) : \u2b50
# Reset both text and background color: %{$reset_color%}
# exit code : %(?.ok.%F{red}nok%f)
# standout : %Stext%s
@gmolveau
gmolveau / LICENSE
Created July 7, 2021 20:55
This license applies to all public gists https://gist.github.com/gmolveau
MIT License
Copyright (c) 2021 Grégoire MOLVEAU
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@gmolveau
gmolveau / spongebob.sh
Created May 23, 2021 21:04
spongebob meme bash function string converter
#!/usr/bin/env bash
set -euo pipefail
input="$*"
length="${#input}"
charindex=0
spongebob_str=""
while [ $charindex -lt $length ]; do
@gmolveau
gmolveau / linux_server_trash.md
Last active May 9, 2021 15:03
linux/ubuntu server trash shell function/command

Put this in your .bashrc or .zshrc :

function abspath() {
    if [ -d "$1" ]; then
        # dir
        (cd "$1"; pwd)
    elif [ -f "$1" ]; then
        # file
 if [[ $1 = /* ]]; then
@gmolveau
gmolveau / asyncio_ex1.py
Last active March 26, 2021 09:34
examples async/await asyncio concurrency python3
import asyncio
async def c1():
print("c1 begin")
await asyncio.sleep(1)
print("c1 end")
return
async def c2():
print("c2 begin")
@gmolveau
gmolveau / flask_separate_thread.py
Last active March 6, 2023 07:27
run a flask application in a separate thread
# please use python3 and flask > 1.0
# run this with : python3 flask_separate_thread.py
# https://web.archive.org/web/20210329135424/https://pymotw.com/3/threading/
# https://web.archive.org/web/20210329135553/https://eli.thegreenplace.net/2011/08/22/how-not-to-set-a-timeout-on-a-computation-in-python
import time
import threading
from flask import Flask
app = Flask(__name__)
@gmolveau
gmolveau / python_move_cursor_to_beginning.py
Last active March 23, 2021 14:00
python3 move cursor to beginning of line terminal and print
# https://stackoverflow.com/a/7715690
# try it on : https://repl.it/languages/python3
# print('ok', end='\r ', flush=True)
for i in range(100):
print(f'\t string {i}', end='\r ', flush=True)