Skip to content

Instantly share code, notes, and snippets.

// Pub Sub On Node.js
var awsIot = require('aws-iot-device-sdk');
var device = awsIot.device({
keyPath: 'keys/XXXXX.private.key',
certPath: 'keys/XXXXX.cert.pem',
caPath: 'keys/aws-iot-rootCA.crt',
clientId: 'max-1',
host: 'AAAAA.iot.us-east-1.amazonaws.com'
@yoshimax
yoshimax / ViewController.swift
Created May 30, 2017 20:36
Upload to FlashAir from macApp via Alamofire
// upload to FlashAir from macosApp via Alamofire
import Alamofire
class ViewController: NSViewController {
@IBAction func GetFileSelectClicked(_ sender: Any) {
let file: NSOpenPanel = NSOpenPanel()
file.allowsMultipleSelection = false
file.canChooseFiles = true
file.canCreateDirectories = true
// Alamofire4 / Swift3 multipart data + prams upload
Alamofire.upload(multipartFormData:{ multipartFormData in
multipartFormData.append(self.imageNSURL, withName: "room[image]")
let roomText:String = self.roomName.text! as String
let bodyText = self.roomIntroduction.text
if let data = roomText.data(using: String.Encoding.utf8) {
multipartFormData.append(data, withName: "room[title]")
}
if let data = bodyText?.data(using: String.Encoding.utf8) {
#coding:utf-8
# http://taizo.hatenablog.jp/entry/2016/06/28/072112
# http://qiita.com/lrf141/items/ff1462c5c6b7b3207775
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
cap.set(3, 640)
@yoshimax
yoshimax / gist:5751fb133d300fed3f03
Created May 29, 2014 11:50
RaspberryPi_I2C_BlinkM
1.
/etc/module
i2c-dev
2.
/etc/modprobe.d/raspi-blacklist.conf
#blacklist i2c-bcm2708
reboot
@yoshimax
yoshimax / paperclipSetupMemo
Last active August 29, 2015 14:01
Papercilp Setup Memo
1.AWS S3 Make Bucket
2.AWS S3 Setup User
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
@yoshimax
yoshimax / resource_owner_auth
Last active December 27, 2015 01:59
Using Resource Owner Password Credentials setting with doorkeeper + devise
Doorkeeper.configure do
resource_owner_authenticator do |routes|
current_user || warden.authenticate!(:scope => :user)
end
resource_owner_from_credentials do |routes|
request.params[:user] = {:email => request.params[:username], :password => request.params[:password]}
request.env["devise.allow_params_authentication"] = true
request.env["warden"].authenticate!(:scope => :user)
end
@yoshimax
yoshimax / gist:6972474
Created October 14, 2013 08:10
Inset for iOS7
- (void)orientationChanged:(NSNotification *)notification {
NSLog(@"%s", __func__);
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
CGRect statusBarViewRect = [[UIApplication sharedApplication] statusBarFrame];
float statusBarHeight = (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) ? statusBarViewRect.size.width : statusBarViewRect.size.height;
float heightPadding = statusBarHeight + self.navigationController.navigationBar.frame.size.height;
[self.tableView setContentInset:UIEdgeInsetsMake(heightPadding, self.tableView.contentInset.left, self.tableView.contentInset.bottom, self.tableView.contentInset.right)];
}
#include <Arduino.h>
#include <SPI.h>
#include "ble.h"
#include <Wire.h>
#include "BlinkM_funcs.h"
// blinkM
#define blinkm_addr 0x00
@yoshimax
yoshimax / BLE Shield + BlinkM
Created May 5, 2013 00:09
Arduino BLEShield SDK Chat_Sketch Text send 'r' BlinkM fade to 'Red' Sketch https://github.com/RedBearLab/Release/tree/master/BLEShield
#include <Arduino.h>
#include <SPI.h>
#include "ble.h"
#include <Wire.h>
#include "BlinkM_funcs.h"
#define blinkm_addr 0x00