Skip to content

Instantly share code, notes, and snippets.

View kongchen's full-sized avatar
💭
zhetenging

Chen Kong kongchen

💭
zhetenging
View GitHub Profile
@kongchen
kongchen / gist:d462ff443ea6a5895740c6d3ec1aa3d0
Created February 12, 2022 15:01 — forked from tayvano/gist:6e2d456a9897f55025e25035478a3a50
complete list of ffmpeg flags / commands
Originall From: Posted 2015-05-29 http://ubwg.net/b/full-list-of-ffmpeg-flags-and-options
This is the complete list that’s outputted by ffmpeg when running ffmpeg -h full.
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Getting help:
-h — print basic options
-h long — print more options
-h full — print all options (including all format and codec specific options, very long)
@kongchen
kongchen / gist:72c1ebf078e7af86b26de1b01d0a5dda
Created June 6, 2019 03:00 — forked from vdw/gist:09efee4f264bb2630345
Kill tcp connection with tcpkill on CentOS

Install tcpkill
yum -y install dsniff --enablerepo=epel

View connections
netstat -tnpa | grep ESTABLISHED.*sshd.

Block with ip tables
iptables -A INPUT -s IP-ADDRESS -j DROP

Kill connection

If you want to clone an svn repository with git-svn but don't want it to push all the existing branches, here's what you should do.

  • Clone with git-svn using the -T parameter to define your trunk path inside the svnrepo, at the same time instructing it to clone only the trunk:
  git svn clone -T trunk http://example.com/PROJECT
  • If instead of cloning trunk you just want to clone a certain branch, do the same thing but change the path given to -T:
  git svn clone -T branches/somefeature http://example.com/PROJECT
@kongchen
kongchen / gist:da38bb2432c1b7ce3849
Last active August 29, 2015 14:17
base64 javascript
(function ($) {
/**
* The base64 en/decoder that supports UTF8 characters like Chinese.
* @namespace
* @name pb.util.base64
*/
var base64 = pb.getObject("util.base64");
var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var b64tab = function (bin) {
@kongchen
kongchen / gist:941a652882d89bb96f87
Created March 18, 2015 06:09
utf8 utf16 in javascript
/**
* Convert a UTF16 string to UTF8.
* @param {String} input
* @returns {String}
*/
utf16To8: function (input) {
var _unescape = function(s) {
function d(x, n) {
return String.fromCharCode(parseInt(n, 16));
}
@kongchen
kongchen / gist:717d712c26637145a751
Last active August 29, 2015 14:10
Fix Home and End key in Mac

To get your Home and End keys working properly on Mac OS X (Tiger and up, including Mavericks), simply open the Terminal and do this:

$ cd ~/Library
$ mkdir KeyBindings
$ cd KeyBindings
$ vi DefaultKeyBinding.dict

Put these lines in that file, including the curly braces:

{
@kongchen
kongchen / setprop.sh
Last active January 3, 2023 09:29
set properties file value by key via bash shell
#!/bin/bash
############################
#script function
############################
setProperty(){
awk -v pat="^$1=" -v value="$1=$2" '{ if ($0 ~ pat) print value; else print $0; }' $3 > $3.tmp
mv $3.tmp $3
}
############################
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define :puppetmaster do |puppetmaster|
puppetmaster.vm.hostname = "puppetmaster"
puppetmaster.vm.network :private_network, ip: "192.168.33.50"
puppetmaster.vm.box = "base"