Archives for the Month of 4月, 2014

【Linux】【MongoDB】 MongoDBでのバックアップとリストアについて

mongodump/mongorestoreコマンドを用いてMongoDBをバックアップとリストアする。 ・localhostのtest_dbをバックアップする mongodump –host localhost –db test_db ・localhostのtest_dbにあるtest_collectionをバックアップする mongodump –host localhost –db test_db –collection test_collection ・localhostのtest_dbにあるtest_collectionのユーザ”akio”をクエリ指定してバックアップする mongodump –host localhost –db test_db –collection test_collection -q {userName : ‘akio’} ・バックアップしたtest_dbを全てリストアする mongorestore –host localhost –db test_db ./dump/test_db ・バックアップしたtest_dbのtest_collectionをリストアする mongorestore –host localhost –db test_db –collection test_collection ./dump/test_db/test_collection.bson

【Linux】 tarコマンドでパーミッション保持したまま圧縮/解凍する

tarコマンドでパーミッション保持したまま圧縮/解凍するには「p」オプションを付ける また解凍時はroot権限などでないとパーミッションを持ったまま解凍できない模様。 # パーミッション保持したまま圧縮 tar cvzfp xxxxx.tar.gz ディレクトリ名 # パーミッション保持したまま解凍 tar xvzfp xxxxx.tar.gz

【Ruby】 外部URLのJSONからデータを読み込む

外部URLのJSONを直接配列として読み込む。 require ‘open-uri’ require ‘json’ json_parse_object = JSON.parse(open(“https://graph.facebook.com/me/friends?access_token=XXX”).read)

【Titanium】 WebViewを用いて値をPOSTする

Ti.Network.createHTTPClient()を使用して値をPOSTし、返答されたhtmlをwebviewに入れ込む。 var win1 = Titanium.UI.createWindow({ title:’Tab 1′, backgroundColor:’#fff’ }); var webview = Ti.UI.createWebView(); win1.add(webview); var xhr = Ti.Network.createHTTPClient(); xhr.open(‘POST’, ‘http://www.snee.com/xml/crud/posttest.cgi’); xhr.onload = function () { webview.html = this.responseText; }; xhr.send({ fname: ‘value’, lname: ‘value_two’ }); win1.open(); 参考:http://developer.appcelerator.com/question/121380/post-variable-to-webview