Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
#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)
// 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) {
@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
// 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 / TriLattice.glsl
Last active March 9, 2018 22:05
TriLattice
#version 150
uniform float time;
uniform vec2 resolution;
out vec4 fragColor;
float rand(vec2 uv)
{
return fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453);
}
@yoshimax
yoshimax / 01_Circles.md
Last active March 10, 2018 15:05
Circles.glsl
@yoshimax
yoshimax / Circles2.md
Last active March 10, 2018 16:31
Circles2.glsl