Skip to content

Instantly share code, notes, and snippets.

View yagitoshiro's full-sized avatar

yagi_ yagitoshiro

View GitHub Profile
@yagitoshiro
yagitoshiro / transport.py
Created February 7, 2011 09:32
マルチバイトのディレクトリ名が混ざっていても動作するようにした
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Make an iOS project transportable so that it can be zipped and
# sent to another machine
#
import os, sys, shutil, codecs, glob
template_dir = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename))
//ブラウザ全体で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);
@yagitoshiro
yagitoshiro / TiDomParser.js
Last active January 17, 2018 11:30
Slightly modified com.hamasyou.XML.TiDomParser
//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 / line_bot.js
Last active April 14, 2017 23:20
LINE API v2
/*
Usage: yarn add request
```
var linebot = require('./line_bot');
var LineBot = bot.new({
channelSecret: <YOUR CHANNEL SECRET>,
channelAccessToken: <YOUR CHANNEL ACCESS TOKEN>
});
```
@yagitoshiro
yagitoshiro / push_notifications.js
Last active August 13, 2016 17:29
apple push notification sample (Titanium Mobile)
//////////////////////push_notifications.js///////////////////////
var apns = function(){
var pref = require('preferences').preferences;
Titanium.Network.registerForPushNotifications({
types: [
Titanium.Network.NOTIFICATION_TYPE_BADGE,
Titanium.Network.NOTIFICATION_TYPE_ALERT
],
success:function(e)
@yagitoshiro
yagitoshiro / app.js
Created January 29, 2012 15:17
Titanium m3u audio streaming test
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
@yagitoshiro
yagitoshiro / gist:7538879
Created November 19, 2013 01:48
tableView + tableViewRows + scrollableView
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 October 31, 2013 10:13
support: tiapp.xml
<sdk-version>3.1.1.GA</sdk-version>
<modules>
<module platform="iphone">com.ti.calendar.permission</module>
</modules>
@yagitoshiro
yagitoshiro / gist:7105452
Last active December 26, 2015 06:09
P.O.C: Hide TabBar with Titanium SDK 3.x...
//app.js excerpt
var ApplicationTabGroup;
if(Ti.Platform.osname == 'android'){
ApplicationTabGroup = require('ui/common/AndroidTabGroup'); // <- これを追加
}else{
ApplicationTabGroup = require('ui/common/ApplicationTabGroup');
}
new ApplicationTabGroup(Window).open();
//ui/common/AndroidTabGroup.js
@yagitoshiro
yagitoshiro / gist:6738602
Created September 28, 2013 05:13
ページ遷移しながらデータを次のWindowに引き渡し、ついでに自分を消して戻れなくするパターン。実際には、Question.jsとAnswer.jsがほぼ同じ内容なので、外観に関わる部分を外に出してrequireして、共通化する方がいいと思います。
//試験を開始するWindowにて
var Window, window;
Window = require('ui/handheld/Question');
window = new Window(1);
window.containingTab = self.containingTab;
self.containingTab.open(window);
//ui/handheld/Question.js
function Question(id){
var self, button;