F13

Month

June 2013

4 posts

RubyMotionでSimulatorを指定

以下の様にiOSバージョン、RetinaのSimulatorかどうを指定出来る。

$ rake target=6.1 retina=true
Jun 11, 2013
#rubymotion
RubyMotionで実機動かそうとした時にProvisioning Profileが見つからないと言われた場合

個別で指定することが出来る。

Rakefileに以下の様に指定する。

Motion::Project::App.setup do |app|
  # Use `rake config' to see complete project settings.
  app.name = 'HelloMotion'


  app.provisioning_profile='/Users/[ID}/Library/MobileDevice/Provisioning Profiles/XXXXX.mobileprovision'
  app.codesign_certificate='iPhone Developer: XXXXXXXXX (XXXXXXXXXXX)'

end

ちなみに、この設定をしなかった場合に以下の様に表示されてしまった。

rake device
     Build ./build/iPhoneOS-6.1-Development
   Compile ./app/app_delegate.rb
    Create ./build/iPhoneOS-6.1-Development/TestTest.app
      Link ./build/iPhoneOS-6.1-Development/TestTest.app/TestTest
    Create ./build/iPhoneOS-6.1-Development/TestTest.app/Info.plist
    Create ./build/iPhoneOS-6.1-Development/TestTest.app/PkgInfo
      Copy ./resources/Default-568h@2x.png
    Create ./build/iPhoneOS-6.1-Development/TestTest.dSYM
    Create ./build/iPhoneOS-6.1-Development/TestTest.app/ResourceRules.plist
    Create ./build/iPhoneOS-6.1-Development/TestTest.app/embedded.mobileprovision
    ERROR! Can't find a provisioning profile named `(?-mix:iOS Team Provisioning Profile)'
Jun 11, 2013
#rubymotion
Xcode5 Developer Previewを入れてRubyMotionが動かなくなった場合の対処

Titaniumのときとかもそうだったけど、以下のコマンドでアクティブなXcodeを変更する

$ sudo xcode-select --switch /Applications/Xcode.app

ちなみに、このコマンド実行前に、RubyMotionでSimulatorを起動しようとした場合、以下のように表示された。

$ rake
    ERROR! RubyMotion doesn't support any of these SDK versions: 7.0
Jun 11, 2013
#rubymotion
ambiguous matches in iphone developer

とでてしまった場合の対処。

Keychainを起動して、iPhoneで検索。 このときにInvalidなCertificateが見つかった場合はそれを削除。

iPhone Developerの有効期限(1年)が切れてしまって、登録しなおした際に不要なCertificateが残ってしまったようだ。(たぶん)

Jun 2, 2013

April 2013

1 post

PyCharmがバージョンアップ後に動かなくなってしまった時の対処

PyCharmを起動しようとすると一瞬Dockにアイコンが見えるような感じがしてすぐ終了してまうという現象になってしまった。

Terminalから以下のコマンドで起動しようとすると、以下の様に言われてしまった。

$ open /Applications/PyCharm.app
LSOpenURLsWithRole() failed with error -10810 for the file /Applications/PyCharm.app.

調べて見ると、パーミッションがおかしいようであった。

以下の様なコマンドでめでたく解消された。

$ chmod +x /Applications/PyCharm.app/Contents/MacOS/pycharm
Apr 23, 2013

March 2013

1 post

HomebrewのUpdateでエラーが出たので対処

Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master


$ sudo chown root:staff /usr/local                                            
$ sudo chmod -R 775 /usr/local
Mar 30, 2013

January 2013

1 post

UIActionSheetをTabBarを使ったView上に出す

https://gist.github.com/4539137

Jan 15, 2013

November 2012

1 post

CURLで取得したJSONをフォーマットした状態で表示

単にcurlしただけだと、読みにくかったり、Unicodeになっていたりする。 そんなときに、以下のようにaliasを登録しておくと、”| pjson”とつけるだけで、読みやすくなる。

https://gist.github.com/4063316

Nov 13, 2012
#tech

October 2012

3 posts

便利!MarkedをreStructuredTextのプレビューワーとして使う
概要

Marked

という、MarkdownのプレビューをしてくれるMac用のAppがある。

これを今回、reStructuredTextのプレビューを行うように設定を変更する。

方針

MarkedはMarkdownの処理系を、設定で変更することが出来る。

ここに、reStructuredTextをHTMLに変換する”rst2html.py”を設定してやる。

rst2html.pyのインストール

ターミナルから以下のコマンドで、docutilsとsphinxを入れてあげる。

$ sudo pip install docutils sphinx
Markedに設定

Markedを起動し、PreferencesのBehaviorタブを開く。

Custom Markdown Processorに以下を設定する

/usr/local/bin/rst2html.py

あとは、プレビューしたいreStrucuturedTextを開けばプレビューされる。

Oct 22, 20121 note
#mac #app
Storyboardで次のViewControllerが呼ばれる前に値を設定する

何も難しいことは何もないのだが、すぐ忘れてしまうのでメモ。

https://gist.github.com/3902937

Oct 16, 20121 note
Homebrewをインストールする
インストール

以下のコマンドでHomebrewをインストール

$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
環境の確認

インストール後に、以下のコマンドを行い正しく環境が設定されているか確認

$ brew doctor
    Your system is raring to brew.

ということなので、大丈夫そうだ。

Oct 9, 2012
#mac #homebrew

September 2012

4 posts

UITableViewのtableHeaderViewをリサイズする

UITableViewのtableHeaderViewをリサイズする方法ではまったのでメモ。

まず、headerViewそのものサイズを変更し、tableHeaderViewに再設定すればよかったみたいだ。

https://gist.github.com/3797277

Sep 27, 2012
#objective-c #ObjC
Tumblrでgistのソースを表示させる

そもそも、gistにはembedするためのスクリプトが用意されているがTumblrに貼り付けてもうまく動かない。

そこで、以下のGistを使用するとうまく表示することが出来る。感謝!

https://gist.github.com/1395926

あとは自分のレイアウトにあわせて、cssを定義するだけだ。

https://gist.github.com/3792895

Sep 27, 20121 note
dartsliveのデータ取得スクリプト

最近よくダーツをやっているので、DartsliveからRating等を取得できないかと思いスクリプトを書いてみた。

https://gist.github.com/3792790

Sep 27, 20123 notes
#python #darts
App EngineのUnit Testでxmppなapi proxyがないと怒られてしまった

以下のようなメッセージで、Unit Testが動かなくなってしまった。

No api proxy found for service “xmpp”

Channel APIを使うようにしたのだが、それの影響でどうやら、XMPPのStubを登録しておく必要があるみたいだ。

ということで、Unit Testの最初の方で以下のように登録してあげる。

from google.appengine.api import apiproxy_stub_map
from google.appengine.api.xmpp import xmpp_service_stub

apiproxy = apiproxy_stub_map.APIProxyStubMap()
apiproxy.RegisterStub('xmpp', xmpp_service_stub.XmppServiceStub()) 
Sep 24, 2012
#gae #python

August 2012

2 posts

# WebkitのNotification(通知)を使ってGMAILのようなデスクトップ通知を表示してみる

ということで、ChromeだとGmailのNotificationのような通知を結構簡単にできる。

注意点としては、requestPermissionはユーザのアクションによる呼び出しでないとうまく動かない。

<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    </head>
    <body>
        <ul>
            <li><a href="#" >Allow notification</a></li>
            <li><a href="#" >Show notification</a></li>
        </ul>
        <script>
var notify = function(message) {
    if(window.webkitNotifications.checkPermission() != 0) {
        return;
    }
    var n = window.webkitNotifications.createNotification('favicon.ico', 'Alert', message);
    n.show();
    // close after 3000 ms
    setTimeout(function(){
        n.close();
    }, 3000);
};

$('#permission').click(function(e) {
    window.webkitNotifications.requestPermission(function() {
        notify('Notification Allowed');
    });
});

$('#notification').click(function(e) {
    notify('Message');
});

        </script>
    </body>
</html> 
Aug 29, 20121 note
#html5 #chrome
TextMate 2をソースからコンパイルしてみる
準備

コンパイルに必要なものをインストールする

Brewを使う。(オフィシャルにはPortを使った方法も書いてある)

$ brew install ragel boost multimarkdown hg ninja

※hg(mercurial)はSCMのライブラリのテストに使うだけなのでSkip出来る。

ninjaが見つからないと言われてしまった、Formulaが古かったようなのでアップデート

$ brew update
$ brew install ragel boost multimarkdown hg ninja

Lionを使っている場合は、pgrep と pkill のためにproctoolsをインストールする必要がある。

これもBrewを使ってさくっとインストール

$ brew install proctools

他にも、Xcode 4.4 以上が入ってない場合は、clangをインストールする必要がある。

試していないが、以下のコマンドで入れられるらしい。

$ brew install --HEAD llvm --with-clang
ソースの取得

ソースコードをGithubからCloneしてくる。

$ git clone https://github.com/textmate/textmate.git
$ git submodule update --init
コンパイル

準備ができたらコンパイルを行う。

$ ./configure && ninja

コンパイルに成功するとそのまま、TextMateが起動する。

Aug 21, 20128 notes
#textmate

July 2012

12 posts

NSErrorで、Potential null dereference エラー

NSErrorで、以下の様なメッセージが出て怒られてしまった。

Potential null dereference. Accordning to coding standards in ‘Creating and Returning NSError Objects’ the parameter maybe null

以下の様な実装をしていたのだが、

- (void)testHoge:(NSError *__autoreleasing *)error {
    ...
    *error = [NSError errorWithDomain:@"ErrorDomain" code:1 userInfo:nil];

}

errorがNullの可能性があるので、errorにNSErrorを代入する前にチェックが必要だった。

if (error) *error = [NSError errorWithDomain:@"ErrorDomain" code:hasLength userInfo:nil];
Jul 25, 2012
#ios #tech #nserror
jinja2のMacroのなかで、Contextに定義した関数が使えなかった

標題の通りはまってしまったのでメモ。

Macroとは

以下の様に、テンプレート内で共通の表示部分をまとめることができる。

{% macro input(name, value='', type='text') -%}
    <input type="{{ type }}" value="{{ value|e }}" name="{{ name }}">
{%- endmacro %} 

そして、以下の様にMacroを呼び出すことができる。

{% import 'forms.html' as forms %}
{{ forms.input('username') }} 

非常に便利なのだが、Macroから、Contextに定義した関数がが使えなかったのだ。

というのにちょっとだけ、はまったのだがドキュメントを見たら書いてあった。

importする際に”with context”を付けてあげる必要がある。

先ほどの例だと以下の様にすれば大丈夫だった。

{% import 'forms.html' as forms with context%}
{{ forms.input('username') }} 
Jul 18, 2012
#jinja2 #python #tech
UIViewにグラデーションを設定

UIViewの子クラスを使い、以下の様にawakeFromNibでグラデーションを設定

- (void)awakeFromNib {
    CAGradientLayer *gradient = [CAGradientLayer layer];
    gradient.frame = self.bounds;
    gradient.colors = [NSArray arrayWithObjects:(id)[
        [UIColor whiteColor] CGColor], 
        (id)[[UIColor colorWithRed:0.69 green:0.769 blue:0.871 alpha:1] CGColor], nil];
    [self.layer insertSublayer:gradient atIndex:0];
}
Jul 15, 20121 note
#ios #tech
Next page →
2012 2013
  • January 1
  • February
  • March 1
  • April 1
  • May
  • June 4
  • July
  • August
  • September
  • October
  • November
  • December
2011 2012 2013
  • January
  • February
  • March 1
  • April 33
  • May 20
  • June 17
  • July 12
  • August 2
  • September 4
  • October 3
  • November 1
  • December
2010 2011 2012
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
2009 2010 2011
  • January 3
  • February 7
  • March 2
  • April 2
  • May 3
  • June
  • July
  • August
  • September
  • October
  • November
  • December
2008 2009 2010
  • January 8
  • February 5
  • March
  • April
  • May
  • June 6
  • July 8
  • August 1
  • September
  • October
  • November 19
  • December 7
2007 2008 2009
  • January
  • February
  • March 5
  • April 6
  • May 5
  • June 3
  • July 1
  • August 6
  • September 1
  • October
  • November
  • December 1
2006 2007 2008
  • January 6
  • February 6
  • March 5
  • April
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
2006 2007
  • January
  • February
  • March
  • April
  • May
  • June
  • July
  • August
  • September 7
  • October 5
  • November 3
  • December 2