This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/python | |
import paho.mqtt.publish as publish | |
from paho.mqtt.client import MQTTv311 | |
import time | |
for i in xrange(10): | |
publish.single("testing", time.asctime() + ' hello ' + str(i), hostname="localhost",port=1883,protocol=MQTTv311) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.mllib.linalg.{Vector, Vectors} | |
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS} | |
import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS} | |
def time[R](block: => R): R = { | |
val t0 = System.nanoTime() | |
val result = block // call-by-name | |
val t1 = System.nanoTime() | |
println("Elapsed time: " + (t1 - t0)/1000000.0 + "ms") | |
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# You will need the following enviromnet variables contiang the your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY | |
# $ env AWS_ACCESS_KEY_ID=<ACCESS_ID> AWS_SECRET_ACCESS_KEY=<SECRET_KEY> ruby ec2.rb | |
# This creates an instance on AWS using the t2.nano and it will perform the following steps: | |
# 1. *WARNING* It will remove all existing internet gateways, subnets, vpcs and assiocated resources | |
# 2. Because t2.nano/micro must be created in a VPC, the internet gateway and security group must be configured: | |
# http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Scenario1.html | |
# 3. Wait for the instance to be made available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Given an integer array and a number T, find all *unique* pairs of (a, b) whose sum is equal to T | |
# O(n), however is not ordered | |
def find_pairs(arr, target): | |
# https://www.ics.uci.edu/~pattis/ICS-33/lectures/complexitypython.txt | |
# Convert to hash, O(n) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EMR is not supported by terraform yet | |
// https://github.com/hashicorp/terraform/issues/2098 | |
// This script will bootstrap the necessary VPC and related configs first. | |
provider "aws" { | |
#access_key = "ACCESS_KEY_HERE" | |
#secret_key = "SECRET_KEY_HERE" | |
region = "ap-southeast-1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#http://guifreelife.com/blog/2016/06/16/Deploy-Hawkular-Metrics-in-CDK-2.0-OpenShift-3.1 | |
#https://docs.openshift.com/enterprise/3.2/install_config/install/deploy_router.html | |
oc project openshift-infra | |
oc delete all --selector="metrics-infra" | |
oc delete sa --selector="metrics-infra" | |
oc delete templates --selector="metrics-infra" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
require 'json' | |
servername = 'cf' | |
username = 'admin' | |
password = 'smartvm' | |
url = "https://#{servername}/api/providers" | |
post_params = { |