Skip to content

Instantly share code, notes, and snippets.

Avatar

Tao Deng devtdeng

  • Pivotal
  • Paris, France
View GitHub Profile
View gist:81b7d99e00bef7fe2a03ba12afb51284
$ brew update
$ brew cask install minikube
$ brew install kubernetes-cli
$ brew install docker-machine-driver-hyperkit
# docker-machine-driver-xhyve need root owner and uid
$ sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-hyperkit/bin/docker-machine-driver-hyperkit
$ sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-hyperkit/bin/docker-machine-driver-hyperkit
$ minikube start --logtostderr --vm-driver=hyperkit
View load_test.rb
require 'net/http'
require 'uri'
def func
uri = URI.parse("http://test-target.cfapps-11.haas-59.pez.pivotal.io")
response = Net::HTTP.get_response(uri)
end
$i = 0
$num = 150000
@devtdeng
devtdeng / verify_certificate.go
Last active Sep 27, 2020
Verify a certificate with chain with golang crypto library
View verify_certificate.go
package main
import (
"crypto/x509"
"encoding/pem"
"io/ioutil"
"log"
"os"
)
@devtdeng
devtdeng / TestAMQP.java
Last active Apr 17, 2017
RabbitMQ Java Client Sample
View TestAMQP.java
package dev.tdeng.onlinechat;
import java.io.IOException;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Consumer;
import com.rabbitmq.client.DefaultConsumer;
View manifest.yml
---
applications:
- name: redispubsub
memory: 256M
instances: 4
host: <any unique string here>
path: ./
buildpack: nodejs_buildpack
services:
- redis-instance
View test.js
var serverName = process.env.VCAP_APP_HOST ? process.env.VCAP_APP_HOST + ":" + process.env.VCAP_APP_PORT : 'localhost:3000';
=>
var serverName = process.env.CF_INSTANCE_IP + ":" + process.env.CF_INSTANCE_PORT;
var sub = redis.createClient();
var pub = redis.createClient();
=>
var vcap_services_object = JSON.parse(process.env.VCAP_SERVICES);
var host = vcap_services_object.rediscloud[0].credentials.hostname;
@devtdeng
devtdeng / image.rb
Last active Jul 4, 2016
Edit /home/tempest-web/.bosh_init/installations/<guid>/packages/bosh_openstack_cpi/vendor/bundle/ruby/2.1.0/gems/fog-1.34.0/lib/fog/openstack/image.rb or replace it with this one, please keep file owner/group/permission unchanged. Raw Raw
View image.rb
require 'fog/openstack/core'
module Fog
module Image
class OpenStack < Fog::Service
SUPPORTED_VERSIONS = /v1(\.(0|1))*/
requires :openstack_auth_url
recognizes :openstack_auth_token, :openstack_management_url,
:persistent, :openstack_service_type, :openstack_service_name,
View gist:bf655c74e5fb27715d0b25f619fa8d05
#Profile
web: uwsgi --http :$PORT --wsgi-file hello-tdeng.py
#hello.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"]
View gist:1d49652cd45f7177a09e
var data_collection;
for (var i in jsonbody.rest)
{
jsonbody.rest[i]["savedtime"] = new Date().toISOString();
data_collection.save(jsonbody.rest[i] , function(err, saved) {
if( err || !saved ) console.log("Rest not saved: " + err);
else ;
});
View gist:18cc99467c02ff3c28e8
# group tickets to users
group_tickets = (msg, results) ->
if results.count <= 0
return
assigned_tickets = {}
unassinged = 0
for result in results
if result.assignee_id?
assignee_id = result.assignee_id
You can’t perform that action at this time.