Ryusuke Fuda's Tech Blog

Softweare Enginier about Web, iOS, Android.

gitとsubversionのコマンド比較

git

■ 変更ファイルを戻そうとsvn revertをgitでしようとgit revertしていたら、gitではrevertではなくcheckoutだった。revertはsvnでいう逆マージっぽい。■ ここの表がわかりやすい。 http://blog.cyclogy.com/2011/05/05/git_subversion/

Titanium環境構築 Android実機でビルドできない

■ エラー文 Timed out waiting for device to be ready, you may try reconnecting the USB cable■ どうやらUSB接続のドライバがPCにインストールされていないのが原因っぽい。 メーカーサイトからダウンロードしてもいいが、 タップナウ(http://www.tapnow.…

Titanium環境構築 Kitchen Sink インポートできない

■ エラー文 We were unable to find a git executable version 1.6.0 or greater, if you have an older version of git you may need to update.■ gitがインストールされてないのが原因 http://git-scm.com/ ここからgitインストール■ Kitcen Sinkインポー…

要素が取得できなくてclick等のイベントが使えないとき

■ ajaxで取得してきたデータをappendでhtml生成しているとき、その下に$('.data').clickをかいてもappendは後から呼ばれるので、$('.data')が取得できず反応しない。■ delegateをつかう $('body').delegate('.data', 'click', function() { console.log($(th…

Express 認証ページ Basic Authentication

■ node.js expressで認証付きのページをつくる(管理ページなどでよく使う)■ ルーティングのapp.jsに追加するだけ。Basic認証を使う。 app.all('/admin/*', express.basicAuth(function(user, password) { return user === 'username' && password === 'passw…

ubuntu ディレクトリの所有者、グループ変更

■ 現状確認、このapacheディレクトリの権限を変更 drwxr-xr-x 2 root root 4096 Sep 13 12:45 apache/■ 権限変更 chown {ユーザー名}:{グループ名} apache/

ubuntu グループ作成,

■ programというgroup作成(番号はかぶってなければなんでもいい) groupadd program -g 4001■ 追加されてるか確認 tail /etc/group■ programグループにユーザー追加 gpasswd -a {ユーザー名} program

amazonアソシエイト、サーチへ飛ばすURL

■ amazon search api を使わずにサーチ結果へ飛ばすURLを調べてみた http://www.amazon.co.jp/s/?field-keywords={エンコードされたキーワード}&tag={アソシエイトID} これでいけそう■ 念の為amazonが提供してるチェックツールでURL確認 https://affilia…

githubリポジトリ作成

git

■ リポジトリ作成 git init■ 全ファイルadd git add .■ コミット git commit -m"initial commit"■ githubへいき、create a new repo でリポジトリつくる■ リモートリポジトリを加える git remote add origin git@github.com:{ユーザー名}/{作ったリポジトリ…

ムームードメインのシステムをロリポップサーバーからさくらvpsへ切り替える

■ ムームードメイン x ロリポップサーバーで運営していたシステムをさくらに移行したので、ドメインの切り替えをと。■ コントロールパネルメニュー > ドメイン操作 > ネームサーバ設定変更 ここの通り http://blog.earthyworld.com/archives/sakura-vps-mumu…

node.jsが動いてるサーバにapache追加

■ apacheインストール sudo yum -y install httpd■ phpインストール yum -y install php php-cli php-common php-mbstring php-mysql php-pdo php-readline php-xml php-pear php-pecl-memcache php-pecl-apc■ ついでにmysqlもインストール yum -y install m…

github環境構築 さくらvps

git

■ 公開鍵生成 ssh-keygen■ github右上 -> acount setting -> SSH Keys でid_rsa.pubを追加 vim ~/.ssh/id_rsa.pub //中身をまるまるコピーし貼り付ける■ 鍵交換できたか確認 ssh -T git@github.comHi {USERNAME}! You've successfully authenticated, but Gi…

ubuntu 13.04 git インストール

■ パッケージインストール sudo apt-get install git-core

node.js passport facebook認証でcallbackにパラメータをつける

■ コールバックにリダイレクトさせるURLをパラメータとしてつけたい 45 app.get('/auth/facebook/', function(req,res,next) { 46 passport.authenticate( 47 'facebook', 48 {callbackURL: '/auth/facebook/callback/?url=' + req.query.url} 49 )(req,res,…

ubuntu 13.04 rpmパッケージインストール

■ ubuntuにalienパッケージインストール apt-get install -y alien■ alienを使ってrpm -> deb 変換 sudo alien {Package}.rpm■ エラーがきた(64bitでalienコマンド使うにはオプションいるっぽい) {Package}.rpm is for architecture i386 ; the package cann…

Ubuntu memcached インストール php設定 (memcache)

■ ubuntuにmemcacheインストール apt-get install memcachedapt-get install php5-devpecl install memcache■ phpのモジュールにmemcache があるか確認 root@ubuntu:~# php -m■ memcache.iniに一行追加 vim /etc/php5/conf.d/memcache.ini extension=memcach…

Vmware ubuntu server13.04 構築 IP固定 (ubuntu)

■ ubuntuサーバーの設定ファイルひかく前にVmwareの設定を見直す 仮想マシンの設定のネットワークアダプタが"NUTS"になっていたら"ホストオンリー"を追加して、"NUTS"を削除する。■ windowsのコマンドプロンプトからVmwareで使われてるIPを確認する ipconfig…

ubuntu環境構築パッケージインストール(ubuntu)

①ユーザーのままでいい系■ vim のパッケージインストール sudo apt-get install vimvimの設定もしておく vim .vimrc 1 syntax on 2 set number 3 set tabstop=4 4 set autoindent 5 set expandtab 6 set shiftwidth=4 7 set foldenable 8 set foldmethod=mar…

Vmware ubuntu Server13.04 構築 (ubuntu)

■ UbuntuのサイトのServerからUbuntuのイメージ(.iso)ダウンロード 60分くらいかかる。■ VMwareダウンロード VMware Player for Windows 32-bit and 64-bit■ VMware起動して"新規仮想マシンの作成" 案内に従って作成→すべてデフォルト値■ 仮想マシンの再生 …

include_partial と include_component の違い (symfony)

■結果 簡単に言うと、actionを必要とするかしないか。■include_partial アクションを必要としないテンプレートの断片 include_partial('<モジュール名>/<パーシャル名>', array(<パーシャル内で必要となる変数の配列>)); ※パーシャルのモジュールが同…

サーバーのdiskの容量確認しsymfony cache をクリアする(shell)

サーバーに tv,video,gameというシステムがあり、サーバーのディスクの使用量が85%以上かつディスクの残量が10GB切ったらsymfonyのキャッシュをクリアする。lists_system.txt SYSTEMS=("tv" "video" "game") cache_clear.sh 1 #!/bin/sh 2 # 3 #@(#)cache…

一行で任意の文字列から任意の文字を抜き出す方法(php)

php

$url = http://abcdefge?appid=55555&alt=json //55555を抽出したい $id = substr($url, strpos($url, 'appid=', 0)+6, 5); var_dump($id); //55555となるstrposでappid=の開始位置(int)を取得 それにappid=の6文字を足した位置から5文字文をsubstrで抜き出…

subversion で毎回パスワードを聞かれなくする

~/.subversion/configこのファイルの2行をyesにする。 store-passwords = yes store-auth-creds = yes

mongoDB基本コマンド

/* DB */ db.help(); db.stats(); show dbs; use videodb; db.dropDatabase(); //connect しているDBを削除 /* collection */ db.createCollection("videos"); show collections; db.videos.drop(); //collectionの削除 db.videos.renameCollection("movies"…

javascriptで配列をシャッフル(Javascript)

JSにはPHPのような配列をシャッフルする関数が用意されていない。 自分で関数を作るしかない。■ 方法① var test = new Array(a,b,c,d,e,f); test = arrayShuffle(test); //shuffle array function arrayShuffle(list){ var d, c, b = list.length; while(b){…

node.js ドメインのポート番号なくす

ポート80のサーバーを作り、プロキシサーバとしてそこにアクセスが来るようにして、そこから各ポートへ飛ばす。■app.jsを作る。 var url = require('url'), http = require('http'); var port = 80; http.createServer(function(serverRequest, serverRespon…

正規表現、デリミタ(PHP)

正規表現を使ってpreg_replaceを行うとき、http://などがあると、エラーになり、nullを返す。 $title = preg_replace("/($searchWord)/", "<strong>$1</strong>", $titleOrg); $searchWordにhttp://が入ってきた時におこる それを回避するときはパターンを delimiters で囲む…

fgetcsv() の注意点

php

fgetcsv()でcsvファイルを読み込む時に""で囲まれていない1バイト以外の文字(日本語など)は正常に読み込まれない。 setlocale(LC_ALL,'ja_JP.UTF-8'); を使うと読み込まれる。 setlocale(LC_ALL,'ja_JP.UTF-8'); $handle = fopen($csv, 'r'); while (($data …

forever使用時の注意 node.js

node.js のバージョンが変わるとforeverも再インストールする必要がある。 npm -g install forever ※ -g グローバルでインストール forever -vバージョンが出ていればOK forever list動いているnodeがあるか確認 forever stop 0あれば一度止める node app.js…

node.js,Express,MongoDBを使ってAPI作成

参考) https://github.com/jaredhanson/passport-twitter/blob/master/examples/signin/app.js http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/