Skip to content

Instantly share code, notes, and snippets.

View zaru's full-sized avatar
😍
write code

zaru zaru

😍
write code
View GitHub Profile
@zaru
zaru / app.js
Created May 25, 2012 06:47
An event is ignited from remote HTML to TitaniumMobile.
var web = Ti.UI.createWebView({
url:'http://www.example.com/event.html'
});
web.addEventListener('error', function (e) {
if (/NSErrorFailingURLKey=custom:(\S+), /.test(e.message)) {
var data = RegExp.$1;
alert(Ti.Network.decodeURIComponent(data));
}
});
@zaru
zaru / gist:3051504
Created July 5, 2012 05:19
日付のイテレーション的なもの
<?php
//PHP5.3以前
$begin = strtotime('2012-01-05');
$end = strtotime('2012-02-15') + 1;
while($begin < $end){
echo date('Y-m-d', $begin) . "\n";
$begin = strtotime("+1 day", $begin);
}
//PHP5.3以上
@zaru
zaru / gist:3225150
Created August 1, 2012 08:52
日付の差を計算する
<?php
//日付の差を月単位で計算する(PHP>=5.3)
$date1 = new DateTime('2012-08-01');
$date2 = new DateTime('2013-02-24');
$interval = $date1->diff($date2);
$diffMonth = $interval->y * 12 + $interval->m;
@zaru
zaru / base.css
Created September 6, 2012 12:46
内部リンクを抑えるつつ、全体をクリッカブルにする
html{color:#000;background:#FFF}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal}ol,ul{list-style:none}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}sup{vertical-align:text-top}sub{vertical-align:text-bottom}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit}input,textarea,select{*font-size:100%}legend{color:#000}
body{font:13px/1.231 'Hiragino Kaku Gothic Pro','Lucida Grande', Verdana, Arial, Meiryo, メイリオ, sans-serif;*font-size:small;*font:x-small}select,input,button,textarea{font:99% arial,helvetica,clean,sans-serif}table{font-size:inherit;font:100%}pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%}
.overlink{
cursor: poi
@zaru
zaru / simple320_320.png
Created September 6, 2012 12:57 — forked from azu/simple320_320.png
画像のテスト
これはgist日記
gistは日記に使えるし、質問場所にもなるし、日本語を翻訳して英語にしてくれ、コードおいておけば勝手にforkして直されて、画像もアップロードできる
@zaru
zaru / sample.php
Created September 27, 2012 06:26
iPhoneAppStoreの検索クエリ
<?php
//検索キーワード
$keyword = 'アプリ';
$uri = 'http://ax.search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?term=' . urlencode($keyword) . '&media=software';
$context = stream_context_create(array('http' => array(
'method' => 'GET',
'header' =>
'User-Agent: iTunes-iPhone/4.2.1 (2; 8GB)' . "\r\n"
. 'X-Apple-Store-Front: 143462-9,2' . "\r\n"
@zaru
zaru / gist:3805528
Created September 30, 2012 00:58
iPhoneの通信内容をキャプチャして、AppStoreに偽装アクセスする方法

iPhoneの通信内容をキャプチャして、AppStoreに偽装アクセスする方法

AppStoreの検索結果やランキングなどを取得したいと思っても、どうやってアクセスすればいいか分かりません。そこで、iPhoneで実際にAppStoreにアクセスしている通信データをキャプチャして解読することで、iPhoneに偽装してアクセスすることが可能になります。

(*)PC版のiTunesとAppStoreでは検索のアルゴリズムなどが違うためiPhoneの方がいい

Windows/Macを経由してアクセスする

iPhoneの通信をキャプチャするには、中継地点で計測する機器が必要になります。高級ルータであれば、そういった機能が付いていることもありますが、もっと手軽に目の前にあるパソコンを経由させてみましょう。

@zaru
zaru / AdminController.php
Created October 2, 2012 07:05
CakePHP2.x + Authコンポーネントで別々の認証を使う方法
<?php
App::uses('AppController', 'Controller');
class AdminController extends AppController {
public $name = 'Admin';
public $uses = array('Administrator');
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => Array('controller' => 'admin', 'action' => 'index'),
@zaru
zaru / bookmarklet.js
Created October 4, 2012 05:19
Amazonのページ情報を、Googleフォームに自動挿入するブックマークレット
//完全自分専用
javascript:(function(){
var name = encodeURI('name');
var priceObj = document.getElementById('actualPriceValue');
var price = priceObj.innerText.replace('¥','').replace(' ','').replace(',','');
var bookObj = document.getElementById('btAsinTitle');
var book = bookObj.innerText;
@zaru
zaru / cookie_curl.php
Last active December 15, 2015 09:59
cookie受け入れcURL