Skip to content

Instantly share code, notes, and snippets.

sagan

Block or report user

Report or block sagan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sagan
sagan / tver.jp_helper.js
Last active Mar 7, 2019
tver.jp helper
View tver.jp_helper.js
// 全屏播放时,按↓(箭头下)彻底隐藏视频信息栏,以方便截图。再次按↑恢复。
// 按←,→ 后退/前进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 Sep 17, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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 Aug 29, 2015
Java 版本的 php strtr 函数 ( replace 是 Map<String, String> 模拟的关联数组 ) / Java version of php "strtr" function
View Strtr.java
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;
View transcode_append_utf8_bom.sh
#!/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)
View transcode_gbk.sh
#!/bin/bash
if [[ $# < 1 ]]
then
printf "Usage: transcode_gbk <FILE>\n"
exit 1
fi
FILE="$1"
View nodejs_iconv.js
// 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 Dec 6, 2012
更改OpenVPN端口。。蛋疼。。
View change_openvpn_port.sh
#!/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
You can’t perform that action at this time.