Skip to content

Instantly share code, notes, and snippets.

@edwios
edwios / particle-photon-aes-encryption-demo.ino
Last active November 12, 2016 20:06 — forked from towynlin/spark-aes-encryption-demo.ino
Demo Particle (formerly Spark) Photon firmware using AES-128-CBC
#include "application.h"
#include "spark_protocol.h"
#include "tropicssl/rsa.h"
#include "tropicssl/aes.h"
void sixteenRandomBytes(unsigned char buf[16]) {
for (int i = 0; i < 16; i++) {
buf[i] = rand() & 0xff;
}
}
@edwios
edwios / OLED_Photon.ino
Last active September 26, 2015 13:04
OLED Driver for Particle-Photon
/****************************************************************************
*****************************************************************************
**************************** OLED Driver *********************************
*** 1.3" 12864 OLED with SH1106 and Simplified Chinese IC for Spark Core ***
*****************************************************************************
****************************************************************************/
int Rom_CS = A2;
unsigned long fontaddr=0;
char dispCS[32];
@edwios
edwios / Particle-Core MQTT template.ino
Last active September 7, 2016 10:49
Maintain MQTT connection even after network disconnects/reconnects
// This #include statement was automatically added by the Particle IDE.
#include "MQTT/MQTT.h"
#define RECONNECT 15*1000
#define CLIENT_NAME "MagicLight-Spark"
byte server[] = { 10,0,1,250 };
MQTT client(server, 1883, callback);
bool init = true;
@edwios
edwios / calculateDays.py
Created February 24, 2016 00:10
Calculate the number of days a battery would last given various operation characteristics
#!/usr/local/bin/python3
#DEEP SLEEP MODE
#System.sleep(SLEEP_MODE_DEEP,60) **~61uA**
#STOP MODE
#System.sleep(long seconds) **~ 2.8mA!**
def findDays(cb, ti, iq, ta, ia):
@edwios
edwios / osx-mongodb-rlimits-fix.md
Created July 1, 2017 06:10 — forked from tamitutor/osx-mongodb-rlimits-fix.md
Fix Mongodb "soft rlimits" Warning On Mac OS X (Yosemite)

If you are seeing Mongo soft rlimits warnings in your logs, or a WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 when you login to mongo shell via mongo from the commandline, or any mysterious/unexplained mongo connection errors... follow this how-to exactly and it will resolve the issue for you.

(Source of this how to found at basho/basho_docs#1402)

First file: sudo vi /Library/LaunchDaemons/limit.maxfiles.plist

...containing:

@edwios
edwios / install_caffe_osx.sh
Last active September 14, 2017 17:04 — forked from soobrosa/install_caffe_osx.sh
Caffe install + benchmark script for OSX
# tested on Macbook Air 13", early 2015, 1,6 Ghz Intel Core i5, 8Gb RAM running macOS Sierra
# tested on MacBook Pro 13" Touchbar, 2016, 3.3 GHz Intel Core i7, 16GB RAM running macOS Sierra 10.12.6
# if you don't have brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
# dependencies
brew install -vd snappy leveldb gflags glog szip lmdb
brew tap homebrew/science
@edwios
edwios / install_caffe_rpi.sh
Last active September 26, 2017 14:02 — forked from soobrosa/install_caffe_rpi.sh
Caffe install + benchmark script for Raspbian Jessie
# tested on a Raspbery Pi 3 running a Raspbian Jessie July 2017
# Install OpenCV 3.3
# See: https://gist.github.com/edwios/5410ceabca579bed7ff1d1b62ee395a1
# dependencies
apt-get update
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
@edwios
edwios / install_opencv_rpi.sh
Last active September 26, 2017 14:01 — forked from soobrosa/install_opencv_rpi.sh
Install OpenCV on a Raspbian Jessie
# thanks to
# https://medium.com/r/?url=https%3A%2F%2Fncsforum.movidius.com%2Fdiscussion%2Fcomment%2F299%2F%23Comment%5C_299
# https://ahmedibrahimvt.wordpress.com/2017/02/19/fatal-error-hdf5-h-no-such-file-or-directory/
# http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
@edwios
edwios / Makefile.config
Created September 26, 2017 14:08
Makefile.config to build Caffe on Raspberry Pi RASPBIAN STRETCH LITE (2017-09-07)
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!
# Configured for Raspberry Pi 3 running Raspian Stretch Lite 2017-09-07
# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1
@edwios
edwios / MovidiusNCSRPi3.txt
Last active November 1, 2017 02:51
Notes on installing Movidius NCS onto Raspberry Pi 3
# Instructions on how to install Movidius NCS on the Raspberry Pi 3
# To do on Host computer
## Install Toolkit and API on Host computer
Follow the instructions here https://developer.movidius.com/start
## Move files to RPi3
Copy the directory ncapi/ from Host computer to RPi3
# To do on RPi3