Skip to content

Instantly share code, notes, and snippets.

View bennyyip's full-sized avatar
🚫
This account has been suspended.

BenYip bennyyip

🚫
This account has been suspended.
View GitHub Profile
import os
import sys
from os.path import getsize, join
from pathlib import Path
from subprocess import DEVNULL, PIPE, Popen
rootpath = sys.argv[1]
audio_suffices = [".mp3", ".flac", ".m4a", ".aac"]
for root, dirs, files in os.walk(rootpath):
if len(files) == 0:
@bennyyip
bennyyip / streetvoice.py
Last active May 2, 2021 04:39
streetvoice mp3 downlaod (need ffmpeg)
import youtube_dl
writethumbnail = True
postprocessors = []
postprocessors.append({"key": "FFmpegMetadata"})
postprocessors.append(
{"key": "EmbedThumbnail", "already_have_thumbnail": writethumbnail}
)
ydl_opts = {
@bennyyip
bennyyip / .tridactylrc
Last active June 21, 2020 09:44
tridactyl config
" General Settings
set incsearch true
set smoothscroll true
set theme default
set editorcmd gvim
set searchurls.gh https://github.com/search?utf8=✓&q=
set searchurls.douban https://www.douban.com/search?q=
#!/usr/bin/env python3
import sys
import os
jpg = sys.argv[1]
with open(jpg, "rb") as f:
b = f.read()
start_of_archive = b.find(b"\xff\xd9") + 2
out_fname = os.path.splitext(jpg)[0] + ".zip"
with open(out_fname, "wb") as f:
<!-- https://codepen.io/jessenwells/pen/pJrJjp -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src=
"https://static.codepen.io/assets/editor/live/console_runner-1df7d3399bdc1f40995a35209755dcfd8c7547da127f6469fd81e5fba982f6af.js"></script>
<script src=
"https://static.codepen.io/assets/editor/live/css_reload-5619dc0905a68b2e6298901de54f73cefe4e079f65a75406858d92924b4938bf.js"></script>
<meta name="robots" content="noindex">
/*
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under both the BSD-style license (found in the
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in the root directory of this source tree).
* You may select, at your option, one of the above-listed licenses.
*/
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
ConstructorInitializerIndentWidth: 4
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
@bennyyip
bennyyip / crates2pkgbuild
Last active December 10, 2018 06:52
crates2pkgbuild
#!/usr/bin/env python3
import json
import urllib.request
import sys
template = '''\
# Maintainer: BennyYip <yebenmy@protonmail.com>
pkgname={pkgname}
_pkgname={name}
@bennyyip
bennyyip / fasd_to_z.py
Last active December 10, 2018 06:50
fasd_to_z
#!/usr/bin/env python
import os
fasd = os.path.expandvars('$HOME/.fasd')
z = os.path.expandvars('$HOME/.z')
with open(fasd) as in_f, open(z, 'w') as out_f:
for line in in_f:
x = line.split('|')
if not os.path.isdir(x[0]):
continue
x[1] = str(int(float(x[1])))
@bennyyip
bennyyip / build-vim.sh
Last active September 19, 2018 08:19
vim build script for old server
#!/bin/sh
rm -f src/auto/config.cache
make clean || true
make distclean || true
CFLAGS='-g -O2' STRIP=true ./configure --prefix=$HOME/.local --localstatedir=$HOME/.local/var/lib/vim --mandir=$HOME/.local/share/man --enable-acl --disable-gui --without-x --disable-fontset --disable-xsmp --enable-pythoninterp --enable-perlinterp=dynamic --enable-cscope --enable-multibyte --with-features=huge --enable-terminal --enable-fail-if-missing
echo 'Building...'