Skip to content

Instantly share code, notes, and snippets.

@intijk
intijk / pp-iptables.py
Created October 22, 2022 16:27 — forked from djoreilly/pp-iptables.py
Pretty print iptables output. Align columns and strip out comments.
#!/usr/bin/python3
import re
import sys
from tabulate import tabulate
comments_re = re.compile(r'/\*.*\/')
in_chain, eof = False, False
headers, table = [], []
@intijk
intijk / lsf
Created August 30, 2019 17:48
ls file with full path
#!/bin/bash
echo "$PWD/$1"
# usage
# ~/tmp$ ls tmp
# a b c
# ~/tmp$ lsf a
# /home/example/tmp/a
@intijk
intijk / update_blender.py
Last active March 29, 2020 09:00
Download new blender 2.8 from website
#!/usr/bin/env python3
import os
import re
import shutil
import subprocess
#path definition
#install_target: ${HOME}/prog/
#tar_file_path: install_target/blender-2.83-a24f52c51cff-linux64.tar.xz
#blender_foldername: blender-2.83-a24f52c51cff-linux64
@intijk
intijk / gsong.py
Created September 18, 2012 15:06
Grab the music file from your chrome cache.
#!/usr/bin/env python2
#encoding=utf8
#first, you should go some online music website, like xiami, to listen music until the cache download finish. #Then run this command, input the artist name and song name.
import pyid3lib
import glob
import os
#cacheDir= os.environ['HOME'] + '/.cache/google-chrome/Default/Cache/'
cacheDir= os.environ['HOME'] + '/.cache/chromium/Default/Cache/'
#make a list sort by time inversely
fl = sorted(glob.glob(cacheDir + 'f*'), key=lambda f:os.stat(f).st_mtime, reverse=True)
@intijk
intijk / fillid3v2.py
Created August 21, 2012 19:36
Modify your id3 v2 info
#!/usr/bin/env python2
import pyid3lib
import sys
if len(sys.argv) < 2 or len(sys.argv) > 3:
sys.exit('Usage: %s filename' % sys.argv[0])
print("Modify file:\n" + sys.argv[1])
f=pyid3lib.tag(sys.argv[1])
#Title
print("")
@intijk
intijk / conxbox
Created August 21, 2012 18:51
将一个视频转换成xbox360上可以播放的格式
#!/bin/bash
#给出一个简体的mp4文件名,给出一个繁体的avi文件名
s2t(){
#把文件名存储进一个文件内
srcf=`mktemp`
destf=`mktemp`
#对文件内容进行转码
@intijk
intijk / fillid3
Created April 3, 2012 16:13
方便你添加id3信息的一个脚本,
#!/usr/bin/python2.7
#encoding=utf8
#Usage example : ./fillid3 run.mp3
#This tool aim to tackle id3 v1 tags, v1 only support ISO-8859-1 encoding!
#Want other language support, convert to id3 v2 format.
from mutagen.mp3 import MP3
from mutagen.id3 import ID3, TRCK, TIT2, TPE1, TALB, TDRC, TCON, COMM
from mutagen.easyid3 import EasyID3
import sys
if len(sys.argv)<2:
@intijk
intijk / convmp3
Created April 3, 2012 16:06
转换各种音频文件为mp3格式
#!/bin/bash
#Usage example: ./convmp3 *.wma
while [ ! $# -eq 0 ]
do
affix=`echo $1|perl -pe 's|(.*)(\..*?)$|\2|'`
echo $affix
inTmpFile=`cat /dev/urandom | strings -n 5 | head -n 1`$affix
outTmpFile=`cat /dev/urandom | sed 's/[^a-zA-Z0-9]//g' | strings -n 5 | head -n 1`.mp3
ln -s "$1" $inTmpFile
outputFile=`echo $1 | perl -pe 's|(.*\.).*?$|\1mp3|'`