Skip to content

Instantly share code, notes, and snippets.

View kkc's full-sized avatar
🌴
On vacation

Kakashi Liu kkc

🌴
On vacation
View GitHub Profile
from kombu import Connection, Exchange, Queue
import logging
LOG = logging.getLogger(__name__)
cvworker_exchange = Exchange('cvworker', 'direct', durable=True)
queue = Queue('video', exchange=cvworker_exchange, routing_key='model1')
return_queue = Queue('return_queue')
@kkc
kkc / aws-sns-event-template-with-actual-ses-deliverynotification-sns-message Lambda function to process a Amazon SES Delivery Notification message from a SNS Topic into a DynamoDB Table
{
"Records": [
{
"EventSource":"aws:sns",
"EventVersion":"1.0",
"EventSubscriptionArn":"arn:aws:sns:us-west-2:xxxx:xxxx",
"Sns": {
"Type":"Notification",
"MessageId":"88B1B251-2E92-4FC3-BFAA-E3BBD0BAB10A",
"TopicArn":"arn:aws:sns:us-west-2:881222951025:survey-tool-ses-delivery",
@kkc
kkc / gist:a2c5328fe1d8d68ea0b45751b1a2e250
Created May 18, 2016 11:33
etcd cluster by using docker-machine
docker-machine create -d virtualbox etcd0
docker-machine create -d virtualbox etcd1
docker-machine create -d virtualbox etcd2
eval $(docker-machine env etcd0)
docker $(docker-machine config etcd0) run -d \
--restart="always" \
-p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd quay.io/coreos/etcd \
-name etcd0 \
@kkc
kkc / .vimrc
Created April 14, 2016 00:14
vimrc
set nocompatible
set backspace=2
filetype off
syntax on
set t_Co=256
set foldmethod=marker
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
@kkc
kkc / function.js
Created April 12, 2016 20:29 — forked from vgeshel/function.js
AWS Lambda function for forwarding SNS notifications to Slack
console.log('Loading function');
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = 'https://hooks.slack.com/services/...';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};
@kkc
kkc / install-mongodb.sh
Created April 8, 2016 04:14 — forked from w0rldart/install-mongodb.sh
Installing MongoDB on Ubuntu 15.04
#!/bin/sh
##
## Bash install script for mongo 3.2 for Ubuntu 15.04, because of
## the replacement of upstart with systemd
##
## - AUTHOR: Alexandru Budurovici <https://w0rldart.com>
## - VERSION: 1.0
##
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
pageSettings: {
loadImages: false, // The WebPage instance used by Casper will
loadPlugins: false, // use these settings
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'
}
});
@kkc
kkc / s3etag.sh
Created January 12, 2016 08:45 — forked from emersonf/s3etag.sh
A Bash script to compute ETag values for S3 multipart uploads on OS X.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 file partSizeInMb";
exit 0;
fi
file=$1
if [ ! -f "$file" ]; then
@kkc
kkc / aws-multipartUpload.js
Created January 12, 2016 06:19 — forked from sevastos/aws-multipartUpload.js
Example AWS S3 Multipart Upload with aws-sdk for Node.js - Retries to upload failing parts
// Based on Glacier's example: http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/examples.html#Amazon_Glacier__Multi-part_Upload
var fs = require('fs');
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./aws-config.json');
var s3 = new AWS.S3();
// File
var fileName = '5.pdf';
var filePath = './' + fileName;
var fileKey = fileName;
@kkc
kkc / docker.md
Created December 1, 2015 12:30
docker

Docker#

Basic

Build image

In the directory including Dockerfile

docker build -t image_name .