Skip to content

Instantly share code, notes, and snippets.

Avatar

yagi_ yagitoshiro

View GitHub Profile
View websocket_test.js
//ブラウザ全体でWebsocketを落としたらどうなるか試験するときに使う
// https://stackoverflow.com/a/31526291/5518615
var WebSocket2 = WebSocket;
WebSocket = function(addy) {
var ws;
if (!this.blocked) {
console.log('WS: Not blocked, allowing.');
ws = new WebSocket2(addy);
this.open_sockets.push(ws);
View line_bot.js
/*
Usage: yarn add request
```
var linebot = require('./line_bot');
var LineBot = bot.new({
channelSecret: <YOUR CHANNEL SECRET>,
channelAccessToken: <YOUR CHANNEL ACCESS TOKEN>
});
```
@yagitoshiro
yagitoshiro / TiDomParser.js
Last active Jan 17, 2018
Slightly modified com.hamasyou.XML.TiDomParser
View TiDomParser.js
//Usage:
//var xml2json = require('TiDomParser');
//xml2json(Ti.XML.parseString(xmlString));
//original: http://hamasyou.com/blog/2010/09/15/titanium-xml2json-xml-json/
/**
* @author hamasyou
* Copyright (C) 2010 hamasyou, INC. All Rights Reserved.
*
@yagitoshiro
yagitoshiro / gist:572ca78198094a0c4bbe
Last active Aug 29, 2015
緯度経度から二点間距離の計算をざっくり
View gist:572ca78198094a0c4bbe
private double deg2rad(double deg) {
return (deg * Math.PI / 180.0);
}
private double rad2deg(double rad) {
return (rad * 180.0 / Math.PI);
}
@Kroll.method
public Double calcDistance(double lat1, double lon1, double lat2, double lon2, String unit){
double theta = lon1 - lon2;
View gist:2502c057cde9fa14e327
# '60s
1960 Joan Baez
1961 Judy Collins
1962 Peter, Paul and Mary
1962 Sylvie Vartan
1963 Elis Regina
@yagitoshiro
yagitoshiro / gist:d6e0e17e9566801c8eaf
Last active Aug 29, 2015
Google Play Servicesの最新版が入っているか確認する
View gist:d6e0e17e9566801c8eaf
if(Ti.Platform.osname == 'android'){
var MapModule = require('ti.map');
var rc = MapModule.isGooglePlayServicesAvailable();
if(rc != MapModule.SUCCESS){
var dialog = Ti.UI.createAlertDialog({
title: 'ご利用の前に',
message: '本アプリを快適にご利用頂くために必要なアプリがあります。インストールしますか?',
buttonNames: ['インストールする', '今回はキャンセルする']
});
dialog.addEventListener('click', function(e){
@yagitoshiro
yagitoshiro / gist:85e6bfdd5e469841814f
Created Dec 28, 2014
ActiveResourceでLoopbackを使う
View gist:85e6bfdd5e469841814f
#app/models/concerns/loopback.rb
module Loopback
extend ActiveSupport::Concern
included do
class << self
def element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}/#{id}#{query_string(query_options)}"
end
View splitWindow
var win = Ti.UI.createWindow({backgroundColor: '#FFFFFF', tabBarHidden:true, title: '素敵な右側'});
var detailNav = Ti.UI.iOS.createNavigationWindow({window:win});
var masterWindow = Ti.UI.createWindow({backgroundColor:'#FFFFFF', tabBarHidden:true, title:'ナイス左側'});
var rows = [];
for( var i = 0; i < 5; i++ ){
rows.push(Ti.UI.createTableViewRow({
title: "title " + (i+1),
hasChild: true
}));
@yagitoshiro
yagitoshiro / gist:7538879
Created Nov 19, 2013
tableView + tableViewRows + scrollableView
View gist:7538879
var rows = [];
var table = Ti.UI.createTableView({top: 20});
for(var i = 0; i < 2; i++){
var row = Ti.UI.createTableViewRow({
id: row + i.toString(), title: i.toString(), height: 110
});
rows.push(row);
}
var views = [];
views.push(Ti.UI.createImageView({height: 100, width: Ti.UI.SIZE, image:'images/black-cat.jpg'}));
@yagitoshiro
yagitoshiro / gist:7247327
Created Oct 31, 2013
support: tiapp.xml
View gist:7247327
<sdk-version>3.1.1.GA</sdk-version>
<modules>
<module platform="iphone">com.ti.calendar.permission</module>
</modules>
You can’t perform that action at this time.