Skip to content

Instantly share code, notes, and snippets.

View meoow's full-sized avatar

Ang Li meoow

  • Beijing University
  • homeless
View GitHub Profile
@meoow
meoow / downxnviewmp.sh
Created August 9, 2014 11:54
Download XnView MP
#!/bin/bash
ver=$(curl -s -L http://www.xnview.com/en/xnviewmp/|sed -n -E '/Version/{s/.*Version ([\.0-9]+).*/\1/;s/\.//;p;q;}')
header='http://download.xnview.com/XnViewMP-'
files=(
win.exe
win-x64.exe
mac.tgz
@meoow
meoow / extract_all_subtitles.cmd
Last active January 5, 2023 02:30
Extract all subtitles using powershell, ffprobe.exe and ffmpeg.exe
powershell -noprofile -command "& {Param([string]$f);[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;[Console]::WindowHeight=5;[Console]::BufferHeight=10;[Console]::WindowWidth=40;[Console]::BufferWidth=40;$fpath = Get-ChildItem $f;$subtitles=(ffprobe.exe -v 0 -show_streams -of json -i $fpath | ConvertFrom-Json).streams | Where-Object codec_type -eq """"subtitle""""; if ( $subtitles.GetType().BaseType.ToString() -eq """"System.Object"""") { if($subtitles.codec_name -eq """"ass"""") { $ext=""""ass"""" } else { $ext=""""srt"""" }; $stfile = """"{0}\{1}.{2}"""" -f $fpath.DirectoryName,$fpath.BaseName,$ext; Write-Output (""""{0}.{1}"""" -f $fpath.BaseName,$ext); ffmpeg.exe -v error -i $fpath -map 0:$($subtitles.index.ToString()) -y $stfile; } elseif ($subtitles.GetType().BaseType.ToString() -eq """"System.Array"""") { foreach ($subtitle in $subtitles) { if($subtitle.codec_name -eq """"ass""""){ $ext=""""ass"""" } else { $ext=""""srt"""" }; $name = $subtitle.tags.title; if($name -eq $null -or $name -eq ''){
@meoow
meoow / voltageshifter.go
Created January 5, 2023 02:22
A wrap for voltiageshift
package main
import (
"flag"
"os"
"path/filepath"
"syscall"
)
func main() {
flag.Parse()
ex, err := os.Executable()
@meoow
meoow / jscript-interpolate.js
Last active January 5, 2023 02:19
.interpolate method for formating jscript string
String.prototype.replSubStr = function(startat, endat, replacement) {
return this.substring(0, startat) + replacement + this.substring(endat+1);
}
String.prototype.interpolate = function() {
var str = this.toString();
var dict = new Object();
if (arguments.length) {
for(var k=0;k<arguments.length;k++) {
if(typeof arguments[k] === "object") {
@meoow
meoow / shExpMatch.js
Last active February 15, 2022 08:04
This is the shExpMatch function for autoconfig pac. Normally the host machine that supports pac should have shExpMatch function built-in, but a piece of software I use reads pac file with lack of implementing this function, I ended up implemented by myself.
function shExpMatch(url, pat) {
var pcharcode0;
var ucharcode0;
var pcharcode1;
if (pat.length === 0) {
if (url.length === 0) {
return true;
} else {
@meoow
meoow / bdcurl.sh
Last active August 19, 2021 11:46
百度云命令行(bash)上传下载脚本
#!/bin/bash
# Baidu Yun Command Line Interface
# Depends: bash, curl, grep, awk, sed, od
# (They are basicly builtin tools of any *nix system.)
# Additionally, fastupload depends: head, wc, md5sum or md5, cksum
# (Which are also builtin tools)
#### Variables ####
@meoow
meoow / aria2rpc.py
Created August 9, 2014 11:56
Aria2 RPC interface
#!/usr/bin/env python
import json, urllib2, sys, os
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('-c', '--cookie', help='use cookies', type=str,
default='', metavar='COOKIES', dest='cookies')
parser.add_argument('-o', '--output', help='output name', type=str,
default='', metavar='NAME', dest='output')
@meoow
meoow / bashrc
Last active March 6, 2021 02:22
append / prepend / remove path from PATH
addpath() { #{{{
local method path
if (($#==0));then
cat <<_EOF_
addpath [+|_|-] path [... pathN]
+ append path (default)
- remove path
_ prepend path
_EOF_
@meoow
meoow / write-clip-down.applescript
Last active October 6, 2018 23:03
write text from the clipboard to text file inside path finder or finder's current directory
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
on writeclipdown(filepath)
try
set f to open for access file filepath with write permission
set eof of f to 0
set olddel to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return & linefeed, return, linefeed, character id 8233, character id 8232}
set newText to text items of (get the clipboard)
@meoow
meoow / ffgif.py
Created April 10, 2018 17:03
Python wrapper of ffmpeg for creating high quality GIF from video clip
#!/usr/bin/env python2.7
import subprocess as subp
import tempfile
import os,os.path
import sys
def ffgif(input, output, fps=None, start=None, end=None, resize=None,ffmpeg_args=[]):
pipeyuvArgList = ['ffmpeg', '-loglevel', 'error', '-ss', start, '-i', input]