Skip to content

Instantly share code, notes, and snippets.

@zjn4530
zjn4530 / letsencrypt-jetty.sh
Created December 15, 2017 09:35 — forked from xkr47/letsencrypt-jetty.sh
How to use Letsencrypt certificate & private key with Jetty
# input: fullchain.pem and privkey.pem as generated by the "letsencrypt-auto" script when run with
# the "auth" aka "certonly" subcommand
# convert certificate chain + private key to the PKCS#12 file format
openssl pkcs12 -export -out keystore.pkcs12 -in fullchain.pem -inkey privkey.pem
# convert PKCS#12 file into Java keystore format
keytool -importkeystore -srckeystore keystore.pkcs12 -srcstoretype PKCS12 -destkeystore keystore.jks
# don't need the PKCS#12 file anymore
@zjn4530
zjn4530 / liverecord.groovy
Created April 10, 2017 04:29 — forked from sunny00123/liverecord.groovy
recording of bilibili live streams
#!/usr/bin/env groovy
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
def OPTIONS = [
UID : 276904, // B站UID
ROOMID : 131985, // 直播间的房间编号,不是地址编号
OUTPUTDIR : "/home/live", // 录制文件输出目录,/D:\ffmpeg\bin/
FFMPEG : "/usr/bin/ffmpeg", // ffmpeg可执行程序位置,/D:\ffmpeg\bin\ffmpeg.exe/
CHECK_INTERVAL: 60, // 直播检测线程的间隔,单位:秒
@zjn4530
zjn4530 / AutoSummaryListPreference
Created February 20, 2017 02:44 — forked from Sloy/AutoSummaryListPreference
Android custom ListPreference which shows its selected value as summary, as suggested in the official guidelines. No need to use OnPreferenceChangeListener in the Activity or anything like that. Only assign entries and entryValues.
package com.your.package;
import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
/**
* Created by Rafa Vázquez on 29/06/13.
*
* ListPreference item that shows its selected value as summary.
@zjn4530
zjn4530 / code
Created February 10, 2017 02:18 — forked from fyhack/code
解决 sdk 4.0 以上屏蔽系统输入法以后不显示光标的Bug; Shielding system soft keyboard does not display the EditText cursor Bug.
if (android.os.Build.VERSION.SDK_INT <= 10) { //2.3版本之前使用此方法
edit.setInputType(InputType.TYPE_NULL);
} else { //2.3版本以后用反射方法设置setSoftInputShownOnFocus(4.0)的值解决
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
try {
Class<EditText> cls = EditText.class;
Method setSoftInputShownOnFocus;
setSoftInputShownOnFocus = cls.getMethod("setSoftInputShownOnFocus", boolean.class);
setSoftInputShownOnFocus.setAccessible(true);
setSoftInputShownOnFocus.invoke(edit, false);
@zjn4530
zjn4530 / HLS_dvr.sh
Created October 8, 2016 07:40 — forked from John07/HLS_dvr.sh
A small script to make recording http live streams (HLS, those streams that work on iOS devices) nicer on a Mac. Script records the stream for a defined period of time and sends the user notifications if anything goes wrong and once it's done.
# required: ffmpeg (e.g. from homebrew), terminal-notifier from https://github.com/alloy/terminal-notifier
# you can schedule this with launchd to run e.g. weekly
# Specify in seconds how long the script should record (default here is 1 hour).
seconds=3600
# Date format for the recording file name
DATE=`date "+%d-%m-%y_%H-%M"`
# start ffmpeg recording
@zjn4530
zjn4530 / nicovideo.py
Created September 27, 2016 07:07 — forked from athoik/nicovideo.py
Livestreamer live.nicovideo.jp plugin
from livestreamer.compat import unquote, urlparse
from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http
from livestreamer.stream import RTMPStream
from livestreamer.utils import parse_xml
PLAYER_API = "http://ext.live.nicovideo.jp/api/getplayerstatus"
class Nicovideo(Plugin):
@zjn4530
zjn4530 / nginxproxy.md
Created June 21, 2016 14:44 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@zjn4530
zjn4530 / SSHA512_gen.py
Created April 28, 2016 00:58 — forked from garrettreid/SSHA512_gen.py
Create a salted SHA512 password hash for use with Dovecot
#!/usr/bin/python
import os
import hashlib
import getpass
import base64
password1 = None
password2 = None