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;
/**
1. Enable the more verbose logging can be enabled here in /opt/appcelerator/360/conf/default/partners/acs.js on line 16. nodeAcsDebugApiCalls,
change it to nodeAcsDebugApiCalls: true,
You will get following Error:
```
GET /api/v1/org/env 200 59.349 ms - 506
[Node.ACS] API call: {"method":"GET","uri":"https://admin.mbaas.perf.api.enedis.fr/admin/apps/777887479634955","timeout":30000,"headers":{"x-auth-token":"25NwQ6IvZsDoS8outJBz2b7aaZ58dQ"}}
{ [Error: Hostname/IP doesn't match certificate's altnames]
__cached_trace__:
[ { receiver: [Object], fun: [Function], pos: 39197 },
{ receiver: [Object], fun: [Function: emit], pos: 3276 },
@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)
}
@kzhangworks
kzhangworks / gist:52a580d27a21e7e2abfa
Created November 26, 2014 07:18
PUT to /v1/admins/apps/emails/setting to set MessageGears for app
curl -b cookies.txt -c cookies.txt -X PUT -F "apikey=***" -F "accountid=***" -F 'sender_email=test@appcelerator.com' -F 'sender_name=support team' -F 'provider=message_gears' -F 'endpoint=https://api.messagegears.net/3.1/WebService' "http://api-local.cloud.appcelerator.com/v1/admins/apps/emails/setting?key=xAP777Rw7uOSlOyRwW7F1BgqBJCsP9S9&pretty_json=true"
{
"meta": {
"code": 200,
"status": "ok",
"method_name": "setAppEmailSettings"
},
"response": {
"apps": [
@kzhangworks
kzhangworks / gist:771106e7d70e37828cda
Created November 26, 2014 07:13
PUT to /v1/admins/apps/emails/smtp set smtp for app
curl -b cookies.txt -c cookies.txt -X PUT -F "address=smtp.gmail.com" -F "tls=true" -F "username=****" -F "password=*****" -F "port=587" -F "use_sender=false" "http://api-local.cloud.appcelerator.com/v1/admins/apps/emails/smtp?key=xAP777Rw7uOSlOyRwW7F1BgqBJCsP9S9&pretty_json=true&pretty_json=true"
{
"meta": {
"code": 200,
"status": "ok",
"method_name": "setSMTP"
},
"response": {