Skip to content

Instantly share code, notes, and snippets.

@syang
syang / gist:d7ff47b216919fcce93ffb47f278b35f
Created June 5, 2017 17:40
Can we avoid this two level callback hell?
exports.getQuestionDetails = (event, context, callback) => {
var keys = event.pathParameters.questionId.split("-");
console.log("keys: ", keys);
var result = {};
// Let first query the question table and retrive the question
let params = {
TableName: tableName,
Key: {
category: keys[0],
@syang
syang / gist:3bbdbd2b4f6e33c9ae5fcff352787ebf
Created April 6, 2017 17:44
a working react-router with navbar
// snippets in index.js (where everything gets started)
// ....
render(
(
<BrowserRouter>
<div>
<Navbar/>
<Route exact path="/" component={Feeds}/>
<Route path="/repo" component={Repos}/>
@syang
syang / gist:206e539c8892de43c051444bf070385e
Created April 6, 2017 17:41
a not working react-router (have not figured out why)
// index.js (where everything gets started)
// ...
render(
(
<BrowserRouter>
<Route path="/" component={App}>
<IndexRoute component={Feeds} />
<Route path="/repos" component={Repos}/>
<Route path="/about" component={About}/>
</Route>
@syang
syang / gist:302d170a9e97110143bc
Created March 27, 2015 23:32
ansible aws error
shuoy$ ansible-playbook playbook.yml -vvvv
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
<ec2-54-69-200-11.us-west-2.compute.amazonaws.com>
<ec2-54-186-137-176.us-west-2.compute.amazonaws.com>
<ec2-54-148-175-129.us-west-2.compute.amazonaws.com>
<ec2-54-186-66-105.us-west-2.compute.amazonaws.com>
@syang
syang / gist:dfc9b4fbc0bf94568d9a
Created March 27, 2015 21:03
zookeeper client error logs
vagrant@host4:/opt/zookeeper/bin$ ./zkCli.sh -server 192.168.33.12:2181
Connecting to 192.168.33.12:2181
2015-03-27 21:01:44,786 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2015-03-27 21:01:44,791 [myid:] - INFO [main:Environment@100] - Client environment:host.name=host4.example.org
2015-03-27 21:01:44,791 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.7.0_75
2015-03-27 21:01:44,795 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2015-03-27 21:01:44,795 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
2015-03-27 21:01:44,796 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/opt/zookeeper/bin/../build/classes:/opt/zookeeper/bin/../build/lib/*.jar:/opt/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper/bin/../lib/netty-3.7.
- name: run zookeeper server
command: >
docker.io rm "{{ zookeeper_container_name }}";
docker.io run -d
-p "{{ ZOOKEEPER_PORT1 }}:{{ ZOOKEEPER_PORT1 }}"
-p "{{ ZOOKEEPER_PORT2 }}:{{ ZOOKEEPER_PORT2 }}"
-p "{{ ZOOKEEPER_PORT3 }}:{{ ZOOKEEPER_PORT3 }}"
--name "{{ zookeeper_container_name }}"
"{{ ZOOKEEPER_DOCKER_IMAGE_REPO }}"
- name: run zookeeper server
docker:
docker_api_version: "1.10"
name: Zookeeper
image: "{{ ZOOKEEPER_DOCKER_IMAGE_REPO }}"
#expose: "{{ ZOOKEEPER_LINKED_PORTS }}"
state: running
sudo: yes
-----------------------------
@syang
syang / gist:3cba2bd7e1b74503f151
Last active August 29, 2015 14:17
error when running ansible with vagrant boxes
huoy$ ansible -m ping masters -i test_inventory.yml -vvvv
<192.168.33.12>
<192.168.33.11>
<192.168.33.12>
<192.168.33.13>
<192.168.33.11>
<192.168.33.13>
<192.168.33.12> IdentityFile=/Users/shuoy/.vagrant.d/insecure_private_key ConnectTimeout=10 PasswordAuthentication=no KbdInteractiveAuthentication=no User=vagrant ControlPath=/Users/shuoy/.ansible/cp/ansible-ssh-%h-%p-%r PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey StrictHostKeyChecking=no ControlMaster=auto ControlPersist=60s
<192.168.33.11> IdentityFile=/Users/shuoy/.vagrant.d/insecure_private_key ConnectTimeout=10 PasswordAuthentication=no KbdInteractiveAuthentication=no User=vagrant ControlPath=/Users/shuoy/.ansible/cp/ansible-ssh-%h-%p-%r PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey StrictHostKeyChecking=no ControlMaster=auto ControlPersist=60s
<192.168.33.13> IdentityFile=/Users/shuoy/.vagrant.d/insecure_private_key ConnectTimeout=10 PasswordAuthentication=no KbdInteractiveAuthentication=n
@syang
syang / gist:c7b84e97988aaa63b1f9
Created March 19, 2015 22:50
Ansible can't ssh to vagrant boxes
shuoy$ ansible -m ping -i test_inventory.yml all -i test_inventory.yml -vvvv
<192.168.33.11>
<192.168.33.12>
<192.168.33.13>
<192.168.33.11>
<--->
<192.168.33.14>
<192.168.33.13>
<--->
<192.168.33.14>
@syang
syang / Vagrantfile
Created April 4, 2014 00:13
Vagrantfile for CentOS 6.5
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#config.vm.box = "Centos65"
#config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box"
config.vm.box = "sinergi/centos-65-x64"