Skip to content

Instantly share code, notes, and snippets.

@toshiyukihina
toshiyukihina / backtracable.rb
Created Mar 29, 2016
utility module for backtrace
View backtracable.rb
module Backtracable
def self.included(klass)
klass.class_eval do
include InstanceMethods
end
end
module InstanceMethods
def backtrace(e: nil, logger: Rails.logger, method: :warn)
View login_using_superagent.js
let request = require('superagent');
let agent = request.agent();
let account = {username: 'xxxx@company.com', password: 'xxxxx'};
const URI = 'http://xxx:3000/api/v1';
request.post(`${URI}/user_session`).send(account).type('json')
.end((err, res) => {
agent.saveCookies(res);
View github.css
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
View gist:9835ce08928308f9add3
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
View example_uploading_gw_package.json
{
"get" : "https://path/to/get",
"put" : "https://path/to/post",
"type" : "none"
}
View sample_of_resource_type.json
{
# ...(snip)...
"myResourceField" : {
"get" : "https://my.resource.url?with=parameter",
"put" : "https://my.resource.url?with=parameter",
"type" : "sandbox.type.net"
},
# ...(snip)...
}
View typical_model_desc.json
"MyModel" : {
"array" : true,
"shared" : false,
"attributes" : {
"my16bitIntField" : {"type" : "int16"},
"my32BitIntField" : {"type" : "int32"},
"my64BitIntField" : {
"type" : "int64",
},
"myBooleanField" : {"type" : "boolean"},
View index.html.erb
<% @devices.each do |d| %>
<div class="container">
<table class="table-condensed">
<tr>
<td><h3>Gateway: <%= d.name %></h3></td>
<td>
<%= link_to({controller: "dashboard", action: "start_blink", name: d.name}, class: 'btn btn-info') do %>
Start Blink <i class='icon-play-circle'></i>
<% end %>
</td>
View moat-rest-client-dev-account-setting.rb
module Moat
REST_URI = "https://sandbox.service-sync.com"
REST_PATH = "/moat/v1"
PACKAGE_ID = "blink-rgx-led"
APPLICATION_ID = "<Your Application ID>"
API_CLIENT_ID = "<Your Client ID>"
API_CLIENT_SECRET = "<Your Client Secret>"
View blink-rgx-led.c