Skip to content

Instantly share code, notes, and snippets.

Avatar

Dingyuan Wang gumblex

  • Shanghai, China
View GitHub Profile
@gumblex
gumblex / progress-all.sh
Created May 3, 2017
Find out each file position opened by a process
View progress-all.sh
#!/bin/bash
for fd in /proc/$1/fd/*; do
if [ ! -f "$fd" ]; then continue; fi
fdnum=$(basename "$fd")
fdinfo=/proc/$1/fdinfo/$fdnum
name=$(readlink "$fd")
size=$(stat -c "%s" "$name" 2>/dev/null || stat -c "%s" "$fd")
progress=$(grep ^pos "$fdinfo" | awk '{print $2}')
if [ $size -eq "0" ]; then
echo '['$fdnum']' "$name"':' $progress'/'$size
@gumblex
gumblex / urlrename.py
Created Feb 16, 2017
Simple script to get rid of url escaped filenames.
View urlrename.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import urllib.parse
for f in sys.argv[1:]:
os.rename(f, urllib.parse.unquote_plus(f))
@gumblex
gumblex / ssl.py
Created Jul 23, 2016
Patched ssl.py for PyPy3.3 with modern OpenSSL
View ssl.py
# Wrapper module for _ssl, providing some additional facilities
# implemented in Python. Written by Bill Janssen.
"""This module provides some more Pythonic support for SSL.
Object types:
SSLSocket -- subtype of socket.socket which does SSL over the socket
Exceptions:
@gumblex
gumblex / copytime.sh
Created May 22, 2016
Recursively restore file mtime from backup
View copytime.sh
#!/bin/bash
find . -type f -print0 | while IFS= read -r -d $'\0' filename; do
if [ -f "$1/$filename" ]; then
echo touch -r "$1/$filename" "$filename"
touch -r "$1/$filename" "$filename"
else
echo "$1/$filename" not exist
fi
done
@gumblex
gumblex / rezip.sh
Created May 15, 2016
Re-zip hacg's encrypted rars
View rezip.sh
#!/bin/bash
cd "$1"
find . -name "*.rar" -type f -print0 | while IFS= read -r -d $'\0' filename; do
basefn=$(basename "$filename")
basefncut="${basefn%.*}"
unar -p 扶她奶茶 -o /tmp -d "$filename"
7za a -tzip -mx=9 "${filename%.*}".zip /tmp/"$basefncut"/*
rm -rf /tmp/"$basefncut"/
done
@gumblex
gumblex / ansi_mandelbrot.py
Created May 5, 2016
Mandelbrot ASCII art from PyPy (independent version)
View ansi_mandelbrot.py
import os
import sys
import colorsys
"""
Black 0;30 Dark Gray 1;30
Blue 0;34 Light Blue 1;34
Green 0;32 Light Green 1;32
Cyan 0;36 Light Cyan 1;36
Red 0;31 Light Red 1;31
@gumblex
gumblex / screenshot.py
Created Apr 24, 2016
Volatility 'screenshot' plugin SVG version
View screenshot.py
# Volatility
# Copyright (C) 2007-2013 Volatility Foundation
# Copyright (C) 2010,2011,2012 Michael Hale Ligh <michael.ligh@mnin.org>
# Copyright (C) 2009 Brendan Dolan-Gavitt
#
# This file is part of Volatility.
#
# Volatility is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@gumblex
gumblex / WWStarClone.py
Last active May 4, 2016
Clone of WWStar, an ancient Classical Chinese translator.
View WWStarClone.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
'''
Clone of WWStar, an ancient Classical Chinese translator.
usage: python3 WWStarClone.py [dir]
@gumblex
gumblex / imgfill.py
Last active Mar 6, 2016
Fill a canvas with a given image of different sizes.
View imgfill.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import random
from PIL import Image
'''
Copyright (c) 2016 gumblex
@gumblex
gumblex / ip.sh
Last active Mar 1, 2016
CGI script: Show visitor's IP and User Agent
View ip.sh
#!/bin/bash
echo 'Status: 200 OK'
echo 'Content-Type: text/html; charset=utf-8'
echo
echo '<!DOCTYPE html>'
echo '<html><head>'
echo '<meta http-equiv="content-type" content="text/html; charset=UTF-8">'
echo '<meta name="description" content="'"$HTTP_USER_AGENT"'">'
# we use CloudFlare
You can’t perform that action at this time.