2014/04/08 10:40:15(火曜日)
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, MongoDB
2014/04/08 09:26:18(火曜日)
tarコマンドでパーミッション保持したまま圧縮/解凍するには「p」オプションを付ける
また解凍時はroot権限などでないとパーミッションを持ったまま解凍できない模様。
# パーミッション保持したまま圧縮
tar cvzfp xxxxx.tar.gz ディレクトリ名
# パーミッション保持したまま解凍
tar xvzfp xxxxx.tar.gz
カテゴリ Linux
2014/04/08 09:21:53(火曜日)
外部URLのJSONを直接配列として読み込む。
require 'open-uri'
require 'json'
json_parse_object = JSON.parse(open("https://graph.facebook.com/me/friends?access_token=XXX").read)
カテゴリ Ruby
2014/04/08 09:17:28(火曜日)
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
カテゴリ Titanium