Skip to content

Instantly share code, notes, and snippets.

@masato
masato / deploy.py
Last active November 29, 2016 07:22
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
from libcloud.compute.deployment import ScriptDeployment
from libcloud.compute.deployment import MultiStepDeployment
import os
import time
$ ./deploy.py
start salt
end salt, eplapsed: 195.698220968
start minion1
end minion1, eplapsed: 180.300945044
start minion2
end minion2, eplapsed: 165.452461958
@masato
masato / file0.txt
Created January 6, 2015 04:09
Docker開発環境のIonicとRippleをnpmからインストールして使う ref: http://qiita.com/masato/items/41deb2174c07966dadf2
$ npm install -g cordova ionic
$ npm install -g ripple-emulator
meshblu:
image: octoblu/meshblu:0c3e5bd
volumes:
- .:/var/www
- ./docker:/etc/supervisor/conf.d
- /opt/docker_apps/certs/meshblu:/opt/meshblu/certs
environment:
- PORT=80
- MQTT_PORT=1883
- MQTT_PASSWORD=skynetpass
#!/bin/sh -
set -o nounset
# Docker
wget -qO- https://get.docker.com/ | sh
# Docker Compose
curl -L https://github.com/docker/compose/releases/download/1.2.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose; chmod +x /usr/local/bin/docker-compose
# SSL Certificate
@masato
masato / bme280_publish.py
Last active August 29, 2015 14:24
BME280のMQTT publishサンプル
#!/usr/bin/python
# -*- coding: utf-8 -*-
import paho.mqtt.client as mqtt
from time import sleep
import json
import sys
import bme280
from config import conf
def sensing():
@masato
masato / config.py
Last active August 29, 2015 14:24
freeboardの設定ファイルサンプル
conf = {
"IDCF_CHANNEL_URL": "210-140-167-168.jp-east.compute.idcfcloud.com",
"TRIGGER_UUID": "9ca04922-88a3-404e-8709-f6a544763c35",
"TRIGGER_TOKEN": "89ad09fd",
"ACTION_UUID": "a1e99a5f-acb6-4210-87c4-d195ea3d9f69",
"FREEBOARD_UUID": "8eb3a4c0-5fb0-456c-9b90-44e59c40f5ad"
}
function md5cycle(x, k) {
var a = x[0], b = x[1], c = x[2], d = x[3];
a = ff(a, b, c, d, k[0], 7, -680876936);
d = ff(d, a, b, c, k[1], 12, -389564586);
c = ff(c, d, a, b, k[2], 17, 606105819);
b = ff(b, c, d, a, k[3], 22, -1044525330);
a = ff(a, b, c, d, k[4], 7, -176418897);
d = ff(d, a, b, c, k[5], 12, 1200080426);
c = ff(c, d, a, b, k[6], 17, -1473231341);
{"formatVersion":"1.0","tagData":{"name":"myThings","icon":"./res/x2/default_icon.png","description":"入力を受けてIDCFチャンネルのトリガーを発火します。","functions":[{"id":"function_0","name":"Trigger","connector":{"inputs":[{"label":""}],"outputs":[{"label":""}]},"properties":[{"name":"uuid","referenceName":"myTriggerUuid","type":"string","defaultValue":"60bd1824-xxxx-xxxx-xxxx-xxxxxxxxxxxx"},{"name":"token","referenceName":"myTriggerToken","type":"string","defaultValue":"1d6f9xxx"},{"name":"endpoint","referenceName":"myEndpoint","type":"string","defaultValue":"210.140.xxx.xxx"}],"extension":{"initialize":"","receive":"","execute":"var endPointURL = 'http://'+properties.myEndpoint + '/data/'+properties.myTriggerUuid;\n\n\najax ({\n url : endPointURL,\n type : 'post',\n data : 'from MESH',\n timeout : 5000,\n\theaders: {\n\t\t'meshblu_auth_uuid': properties.myTriggerUuid,\n\t\t'meshblu_auth_token': properties.myTriggerToken\n\t},\n success : function ( contents ) {\n\t\tlog('success');\n callbackSuccess( {\n
@masato
masato / spark-hdp-install
Last active November 29, 2015 10:26
spark-hdp-install for spark-1.5.1-bin-hadoop2.6
#!/bin/bash
: ${SPARK_VERSION:=1.5.1}
: ${SPARK_DIST_PREFIX_VERSION:=2.6}
: ${SPARK_HADOOP_VERSION:=2.6.0}
SPARK_DIST_VERSION=$SPARK_VERSION-bin-hadoop$SPARK_DIST_PREFIX_VERSION
SPARK_ASSEMBLY_VERSION=$SPARK_VERSION-hadoop$SPARK_HADOOP_VERSION
set-spark-envs() {