Skip to content

Instantly share code, notes, and snippets.

@sagan
sagan / tver.jp_helper.js
Last active August 19, 2020 05:57
tver.jp helper
// 全屏播放时,按↓(箭头下)彻底隐藏视频信息栏,以方便截图。再次按↑恢复。
// 按←,→ 后退/前进5秒。按空格播放/暂停。
window.addEventListener("keydown", e => {
if (document.activeElement && document.activeElement.tagName == "INPUT") {
return;
}
let v = document.querySelector("video");
let a = document.querySelector(".video-js .vjs-dock-text"),
b = document.querySelector(".video-js .vjs-control-bar");
@sagan
sagan / 0_reuse_code.js
Last active September 17, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sagan
sagan / Strtr.java
Last active August 29, 2015 14:06
Java 版本的 php strtr 函数 ( replace 是 Map<String, String> 模拟的关联数组 ) / Java version of php "strtr" function
package fuck.you.java;
import java.util.*;
public class Strtr {
/*
from php strtr
*/
static public String strtr(String str, Map<String, String> replace_arr) {
int maxlen = 0; int minlen = 1024*128;
#!/bin/bash
if [[ $# < 1 ]]
then
printf "Usage: transcode_append_utf8_bom <FILE>\n"
exit 1
fi
UTF8_BOM=$(echo "0xef0xbb0xbf" | xxd -r)
FILEHEAD=$(head --bytes=3 $1)
#!/bin/bash
if [[ $# < 1 ]]
then
printf "Usage: transcode_gbk <FILE>\n"
exit 1
fi
FILE="$1"
// npm -g install iconv
var Iconv = require('iconv').Iconv;
var fs=require("fs");
// convert string from GBK to UTF-8
var iconv = new Iconv('GBK', 'UTF-8');
var filename = "file";
var content_buffer = fs.readFileSync(filename);
var content_buffer_utf8 = iconv.convert(content_buffer);
@sagan
sagan / change_openvpn_port.sh
Created December 6, 2012 05:24
更改OpenVPN端口。。蛋疼。。
#!/bin/sh
if [ $# -lt 2 ]
then
echo "Usage: change_openvpn_port <CONF_FILE> <PORT>"
exit 1
fi
sed -ire "s/^port[ \t]*[0-9]*/port $2/i" $1
sed -ire "s/^remote[ \t]*\([a-zA-Z0-9\.]*\)[ \t]*[0-9]*/remote \1 $2 /i" $1