Skip to content

Instantly share code, notes, and snippets.

@peteroid
peteroid / # opencv3 - 2016-04-24_11-38-59.txt
Created April 24, 2016 18:56
opencv3 (homebrew/science/opencv3) on Mac OS X 10.11.4 - Homebrew build logs
Homebrew build logs for homebrew/science/opencv3 on Mac OS X 10.11.4
Build date: 2016-04-24 11:38:59
@peteroid
peteroid / Spark-random-nums.scala
Created July 2, 2016 03:51
Generate random numbers and save to hdfs
import scala.util.Random;
var NUM_SAMPLES = 2000000000;
val count = sc.parallelize(1 to NUM_SAMPLES).map{ _ => Random.nextLong };
var sum = count;for (_ <- 1 to 20){sum = sum ++ count};
sum.saveAsTextFile("hdfs://10.0.72.14:54310/data/big_num_700g.txt");
@peteroid
peteroid / singleton.js
Last active July 26, 2016 21:32
Node JS Simple Singleton used by require()
var singleton = function () {
// all are public
var someVariable = "some value" // acts like states
var otherVariable = 123 // acts like states
return {
someFunction: function (someArg) {
// expressions go here, change state
return "other value"
},
@peteroid
peteroid / vertical-align.css
Created August 3, 2016 17:20
An example implementing the vertical alignment
/* absolution position + transform approach */
.parent {
height: 100vh;
position: relative;
.children {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
@peteroid
peteroid / SparkBench.scala
Created August 3, 2016 23:42
A simple scala object for benchmarking Spark app
import java.text.SimpleDateFormat
import java.util.Date
import scala.collection._
import sys.process._
import java.io._
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
import org.apache.spark.scheduler._
var getTenPinBowlingScore = function (result) {
// construct the array from string
var resultArr = result.split(',').map(s => {
return parseInt(s)
})
var calculatedResult = resultArr.reduce((preVal, curVal, curIdx, arr) => {
// calcualte any extra score
@peteroid
peteroid / unity-arduino-mpu6050.cs
Last active December 16, 2017 12:30
Get the quaternion from arduino output string with filter
// !!! Attention !!!
void initPort (SerialPort port) {
// set this encoding to extend the ascii range
port.Encoding = System.Text.Encoding.GetEncoding(28591);
}
// Take a string and parse the quaternion and corresponding index
// return:
// quat = Quaternion.identity if packet is invalid
// index = -1 if packet is invalid
@peteroid
peteroid / unity-arduino-mpu6050.c
Last active October 27, 2016 04:20
Arduino side of this
...
// modify the initiator of the packet
uint8_t teapotPacket[20] = { '$', 0x02,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0,
0x00, 0x00, '\r', '\n' };
...
loop() {
...
// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class
// 10/7/2011 by Jeff Rowberg <[email protected]>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
// 2013-05-08 - added multiple output formats
// - added seamless Fastwire support
// 2011-10-07 - initial release
/* ============================================
// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class
// 10/7/2011 by Jeff Rowberg <[email protected]>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
// 2013-05-08 - added multiple output formats
// - added seamless Fastwire support
// 2011-10-07 - initial release
/* ============================================