Skip to content

Instantly share code, notes, and snippets.

View kzhangworks's full-sized avatar

Kefeng Zhang kzhangworks

  • Axway
  • Beijing, PRC
View GitHub Profile
@kzhangworks
kzhangworks / delete_all_object_versions.sh
Created November 7, 2018 03:07 — forked from weavenet/delete_all_object_versions.sh
Delete all versions of all files in s3 versioned bucket using AWS CLI and jq.
#!/bin/bash
bucket=$1
set -e
echo "Removing all versions from $bucket"
versions=`aws s3api list-object-versions --bucket $bucket |jq '.Versions'`
markers=`aws s3api list-object-versions --bucket $bucket |jq '.DeleteMarkers'`
@kzhangworks
kzhangworks / rs-connect.js
Created January 11, 2018 14:05 — forked from chrisckchang/rs-connect.js
replica set connection with nodejs native
/**
* MongoDB NodeJS Driver Production Connection Example
*
* Copyright (c) 2015 ObjectLabs Corporation
* Distributed under the MIT license - http://opensource.org/licenses/MIT
*/
var MongoClient = require('mongodb').MongoClient;
/**
@kzhangworks
kzhangworks / howto.md
Created February 8, 2017 02:22 — forked from npkumar/howto.md
Setting up registry server, security server and appc cli for on-premise deployment with local dashboard
@kzhangworks
kzhangworks / README.md
Created November 6, 2015 00:22 — forked from hwdsl2/.MOVED.md
IPsec L2TP VPN Auto Install Script for Ubuntu 14.04 & 12.04 and Debian 8
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28

Inspired on this other gist

function hook(callback){
  
  var oldWrite = process.stdout.write;
  var output = { str : '' };

  return {
    restore : function(){
var util = require('util')
function hook_stdout(callback) {
var old_write = process.stdout.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
callback(string, encoding, fd)
}
#!/bin/bash
set -e
cd ~/
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.65.tar.gz
tar -zxf mysql-5.1.65.tar.gz
cd mysql-5.1.65
./configure '--prefix=/usr' '--exec-prefix=/usr' '--libexecdir=/usr/sbin' '--datadir=/usr/share' '--localstatedir=/var/lib/mysql' '--includedir=/usr/include' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-system-type=debian-linux-gnu' '--enable-shared' '--enable-static' '--enable-thread-safe-client' '--enable-assembler' '--enable-local-infile' '--with-fast-mutexes' '--with-big-tables' '--with-unix-socket-path=/var/run/mysqld/mysqld.sock' '--with-mysqld-user=mysql' '--with-libwrap' '--without-readline' '--with-ssl' '--without-docs' '--with-extra-charsets=all' '--with-plugins=max' '--with-embedded-server' '--with-embedded-privilege-control'
make
@kzhangworks
kzhangworks / gist:4036677
Created November 8, 2012 03:54 — forked from erkde/gist:1233435
Rake tasks to list, export & import Mongo DB collections
namespace :mongo do
def db_name
Mongoid.database.name
end
def db_connection_options
host, port = Mongoid.database.connection.host_to_try
auths = Mongoid.database.connection.auths