Skip to content

Instantly share code, notes, and snippets.

View lonsty's full-sized avatar
😜
= ̄ω ̄=

Allen Shaw lonsty

😜
= ̄ω ̄=
View GitHub Profile
@lonsty
lonsty / git_log_formatted.md
Last active December 26, 2020 08:29
Aliases to format git log

How to

Add following aliases to ~/.zshrc:

alias glo='f() { x=${1-16}; length=`expr $x`; git log --graph --pretty=format:"%>|($length)%C(yellow)%h%Creset %C(cyan)-%Creset %<(52,trunc)%s %C(cyan)%<(12,trunc)%cr%Creset %C(magenta)%<(10,trunc)%an%Creset (%cd)%C(red)%d%Creset" --date=format:"%a %b %d %H:%M %Y"}; f'
alias glor='f() { x=${1-16}; length=`expr $x`; git log --reflog --graph --pretty=format:"%>|($length)%C(yellow)%h%Creset %C(cyan)-%Creset %<(52,trunc)%s %C(cyan)%<(12,trunc)%cr%Creset %C(magenta)%<(10,trunc)%an%Creset (%cd)%C(red)%d%Creset" --date=format:"%a %b %d %H:%M %Y"}; f'

then,

@lonsty
lonsty / remove_bad_interpreter.py
Created December 26, 2020 13:03
Remove broken bin files
#!/usr/bin/env python3.7
# @Author: eilianxiao
# @Date: Dec 26 19:35 2020
"""删除找不到 Python 解释器的执行文件"""
import os
import subprocess
BIN_DIR = '/usr/local/bin'
found = subprocess.run(f'find {BIN_DIR} -type f', shell=True, stdout=subprocess.PIPE)
@lonsty
lonsty / rename_files.py
Created December 28, 2020 02:24
Rename files in bulk
from os import listdir, rename
from os.path import isfile, join
from sys import argv
mypath = argv[1]
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
for file in sorted(onlyfiles, reverse=True):
first, name = file.split(']')
index = int(first[1:])
@lonsty
lonsty / .vimrc
Last active March 2, 2021 06:33
vimrc simple template
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Amir Salihefendic — @amix3k
"
" Awesome_version:
" Get this config, nice color schemes and lots of plugins!
"
" Install the awesome version from:
"
" https://github.com/amix/vimrc
@lonsty
lonsty / initial_installations_on_powershell.md
Last active April 11, 2021 09:07
Development on PowerShell

Installations on PowerShell

Git

# Prerequisites: run as Administrator
Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned -Force

# Install for current user
Install-Module posh-git -Scope CurrentUser -Force
@lonsty
lonsty / m3u8-to-mp4.md
Created April 21, 2022 18:41 — forked from tzmartin/m3u8-to-mp4.md
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4