Skip to content

Instantly share code, notes, and snippets.

@touren
touren / exportAvatarImage.sh
Last active March 19, 2019 14:52
Retrieve your account's avatar image in a MacBook
## Get current user's avatar.
export USER_HOME=~
dscl . -read $USER_HOME JPEGPhoto | tail -1 | xxd -r -p > ~/Desktop/avatar.jpg
@touren
touren / get_cert.bat
Last active December 7, 2018 04:32
Get let's encrypt certificate in Windows.
#####
# 1. Make sure the link, http://www.yourdomain.com/.well-known/acme-challenge/, works.
************************************************
* For apache httpd, add below to httpd.conf
*************************************************
# Let's encrypt folder
Alias "/.well-known/acme-challenge" "/letsencrypt/acme-challenge"
<Directory "/letsencrypt/acme-challenge">
Options Indexes
@touren
touren / renew_bitnami_wordpress_cert_by_certbot.sh
Last active May 8, 2018 02:43
Renew Bitnami WordPress server's certifications using cerbot.
#!/bin/bash
## Install cerbot, which can automatically generate, renew and deploying Let's Encrypt certificates.
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot
## NOTE: Before proceeding with this step, ensure that your domain name points to the public IP address of the Bitnami application host.
@touren
touren / self_sign_certificate.sh
Last active February 17, 2017 21:42
Creating a Self-Signed SSL Certificate
# From: https://devcenter.heroku.com/articles/ssl-certificate-self
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
openssl req -new -key server.key -out server.csr
// Common Name (e.g. server FQDN or YOUR name) []:localhost
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
@touren
touren / GIF-Screencast-OSX.md
Last active March 19, 2019 14:53 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@touren
touren / add_postfix.sh
Created December 10, 2016 08:49
append postfix to files by checking it's content.
for f in `ls`
do
xxd -l 16 $f > xxd_result
if grep -q Exif xxd_result; then
echo $f.jpg
mv $f $f.jpg
else
if grep -q ftypqt xxd_result; then
echo $f.mov
mv $f $f.mov
sudo apt-get install nginx
WEB_ROOT=/var/www/html
sudo rm -f ${WEB_ROOT}/*.m3u8
sudo rm -f ${WEB_ROOT}/*.ts
gst_pid=`ps -A | grep gst-launch-1. | awk '{print $1}'`
sudo kill -9 ${gst_pid}
sudo gst-launch-1.0 videotestsrc is-live=true ! clockoverlay shaded-background="true" font-desc="Sans, 24" \
sudo apt-get install -y build-essential libtool autotools-dev automake
sudo apt-get install -y libsoup2.4-dev libjson-glib-dev libssl-dev autopoint gtk-doc-tools libgstreamer1.0-dev
sudo apt-get install -y gstreamer1.0-tools gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly
gst-inspect-1.0 videotestsrc
gst-inspect-1.0 decodebin
gst-launch-1.0 filesrc location=test.mp4 ! decodebin ! fakesink
# will generate playlist.m3u8 and segment[nnnnn].ts live in current folder,
# server these files by HTTP server will get the hls stream.
gst-launch-1.0 videotestsrc is-live=true ! x264enc ! mpegtsmux ! hlssink
@touren
touren / .gitconfig
Last active January 9, 2020 16:18
config file of git
[gui]
[user]
email = [email protected]
name = Tao Ren
[merge]
summary = true
[alias]
co = checkout
br = branch
ci = commit