Skip to content

Instantly share code, notes, and snippets.

View benjaminchodroff's full-sized avatar

Benjamin Evans Chodroff benjaminchodroff

View GitHub Profile
Verifying that +benjaminchodroff is my blockchain ID. https://onename.com/benjaminchodroff
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@benjaminchodroff
benjaminchodroff / main.py
Created February 18, 2017 05:55
LoPy LoRa range test - listener
# Benjamin Chodroff, 2017
# This is the main listening gateway
# It's job is to receive LoRa messages and, if a color, set the LED to that color
# Otherwise, it will set unknown messages or errors as "white"
import machine
button=machine.Pin("G17",machine.Pin.IN, pull=machine.Pin.PULL_UP)
led=machine.Pin("G16", machine.Pin.OUT)
led.value(1)
#If the dev button is not pressed (0) then run this device in broadcast mode
if button():
@benjaminchodroff
benjaminchodroff / node1.py
Created February 18, 2017 05:57
LoPy LoRa range test - transmitter
import socket
import time
import struct
from network import LoRa
import pycom
pycom.heartbeat(False)
pycom.rgbled(0x000fff) #blue
# A basic package header, B: 1 byte for the deviceId, B: 1 bytes for the pkg size
_LORA_PKG_FORMAT = "BB%ds"
_LORA_PKG_ACK_FORMAT = "BBB"
@benjaminchodroff
benjaminchodroff / alarmdetect.py
Created February 18, 2017 06:35
raspberry pi microphone alarm detection
#!/usr/bin/env python
import pyaudio
from numpy import zeros,linspace,short,fromstring,hstack,transpose,log
from scipy import fft
from time import sleep
#Volume Sensitivity, 0.05: Extremely Sensitive, may give false alarms
# 0.1: Probably Ideal volume
# 1: Poorly sensitive, will only go off for relatively loud
SENSITIVITY= 1.0
import rpy2.robjects.lib.ggplot2 as ggplot2
import rpy2.robjects as ro
from rpy2.robjects.packages import importr
from rpy2.robjects import pandas2ri
pandas2ri.activate()
predprice = pd.DataFrame({"Predicted": [x for x in pred], "Actual": [y for y in price], "Color": [z for z in color], "Clarity": [x for x in clarity]})
yourdiamond = pd.DataFrame({"Predicted": [ypred],"Actual": [ypri]})
ro.globalenv['dataframe'] = predprice
pp = ggplot2.ggplot(predprice)
@benjaminchodroff
benjaminchodroff / oandamomentumv20.ipynb
Created March 7, 2017 03:05
OANDA v20 API with Time Series Momentum Strategy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am benjaminchodroff on github.
  • I am benjaminchodroff (https://keybase.io/benjaminchodroff) on keybase.
  • I have a public key whose fingerprint is 7D04 501A 9446 11CD 602E 6F55 790B FC19 96BC 3A53

To claim this, I am signing this object:

@benjaminchodroff
benjaminchodroff / qingcloudVPCCreateDestroy.txt
Last active March 28, 2017 19:48
QingCloud automated VPC bastion host creation and deletion
pip install --upgrade qingcloud-cli
# CLI documentation: https://docs.qingcloud.com/cli/index.html
# API documentation: https://docs.qingcloud.com/api/index.html
# CLI Source: https://github.com/yunify/qingcloud-cli
# Python SDK Source: https://github.com/yunify/qingcloud-sdk-python
#Provision SubAccount in master account manual - log in, create an access key, and install the python CLI for qingcloud with your key, secret, and zone set in ~/.qingcloud/config.yaml
#Create security group
securitygroup=$( qingcloud iaas create-security-group --security_group_name "securitygroup-0000" | python -c 'import json,sys;print(json.load(sys.stdin)["security_group_id"]);' )
#Add security group rules (Ping and SSH)
@benjaminchodroff
benjaminchodroff / minimal-aliyun.tf
Created April 3, 2017 05:09
Minimal VPC ECS instance with Security Groups in Aliyun
# Create a new ECS instance for classic
resource "alicloud_security_group" "vpc" {
name = "tf_test_foo"
vpc_id = "${alicloud_vpc.vpc.id}"
}
resource "alicloud_security_group_rule" "allow_ssh" {
type = "ingress"
ip_protocol = "tcp"
nic_type = "intranet"