Skip to content

Instantly share code, notes, and snippets.

@jayzeng
jayzeng / shift.js
Created March 19, 2014 20:27
left shifting
function shift(input, pos) {
return input.slice(pos, input.length) + input.slice(0, pos);
}
console.log(shift("abcdefg", 2) === "cdefgab");
@jayzeng
jayzeng / gist:9715484
Created March 22, 2014 22:36
run docker on Mac OXS
git clone git@github.com:boot2docker/boot2docker.git
chmod +x boot2docker
sudo mv boot2docker /usr/local/bin/boot2docker
# see https://github.com/boot2docker/boot2docker/blob/master/doc/BUILD.md
build ubuntu image
cd boot2docker
# (references to https://github.com/boot2docker/boot2docker/blob/master/base/Dockerfile)
# note this step takes quite a while
@jayzeng
jayzeng / note
Created March 23, 2014 23:38
Dockerfile magic
How to call dockerfile?
Github:
docker build github_url
Locally:
docker build .
docker build <path>
Trusted builds:
@jayzeng
jayzeng / gist:9877315
Created March 30, 2014 18:23
set up hubot on heroku
- Create a new bot user and invite to the room on hipchat
- Once the bot account is created, go to https://smarttech.hipchat.com/account/xmpp
- Install coffee script and hubot
```
npm install --global coffee-script hubot
```
- Create a new hubot project, cd into the folder and install depenedncies
```
hubot --create hubot-fun
cd hubot-fun
@jayzeng
jayzeng / curl.md
Created April 20, 2014 22:38 — forked from btoone/curl.md

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
#!/bin/bash
# ========================================
# Testing completion suggest in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/hotels
curl -X PUT localhost:9200/hotels -d '
{
"mappings": {
"hotel" : {
This is an example how to perform multi-select faceting in ElasticSearch.
Selecting multiple values from the same facet will result in an OR filter between each of the values:
(facet1.value1 OR facet1.value2)
Faceting on more than one facet will result in an AND filter between each facet:
(facet1.value1 OR facet1.value2) AND (facet2.value1)
I have chosen to update the counts for each facet the selected value DOES NOT belong to since we are performing an AND between each facet. I have included an example that shows how to keep the counts if you don't want to do this (filter0.sh).
@jayzeng
jayzeng / app.js
Created April 28, 2014 22:39 — forked from egaumer/app.js
/*jshint globalstrict:true */
/*global angular:true */
'use strict';
angular.module('demo', [
'demo.controllers',
'demo.directives',
'elasticjs.service'
]);
@jayzeng
jayzeng / sqs.py
Created May 22, 2015 18:05
boto sqs hello world
import boto
import json
from boto.sqs.message import Message
sqs = boto.connect_sqs()
queue = sqs.get_queue('queue')
mess = {
"test":"hello world"
}
import subprocess
import json
import os, errno
import argparse
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(path):