Skip to content

Instantly share code, notes, and snippets.

@kurorido
kurorido / testUpdateCouchBaseWithoutView.dart
Last active August 29, 2015 14:03
Update Couchbase Without View
void testUpdateCouchBaseWithoutView() {
print("Testing Update CouchBase without View...");
CouchClient _dbclient;
CouchClient.connect([Uri.parse("http://10.1.4.112:8091/pools")], "default", "").then((CouchClient c) {
_dbclient = c;
}).then((_) {
@kurorido
kurorido / prepareDB.dart
Last active August 29, 2015 14:03
Insert 1M records into Couchbase
void prepareCouchBase() {
print("Testing Insert CouchBase");
CouchClient _dbclient;
CouchClient.connect([Uri.parse("http://10.1.4.112:8091/pools")], "default", "").then((CouchClient c) {
_dbclient = c;
}).then((_) {
int startTime = new DateTime.now().millisecondsSinceEpoch;
@kurorido
kurorido / queryCouchBaseWithoutView.dart
Last active August 29, 2015 14:03
Test Query CouchBase Without View
void testQueryCouchBaseWithoutView() {
print("Testing Query CouchBase without View...");
CouchClient _dbclient;
CouchClient.connect([Uri.parse("http://10.1.4.112:8091/pools")], "default", "").then((CouchClient c) {
_dbclient = c;
}).then((_) {
@kurorido
kurorido / testQueryCouchBaseWithViewAndStaleFalse.dart
Last active August 29, 2015 14:03
test Query CouchBase With View And Stale False
void testQueryCouchBaseWithViewAndStaleFalse() {
print("Testing Query CouchBase with View...");
CouchClient _dbclient;
CouchClient.connect([Uri.parse("http://10.1.4.112:8091/pools")], "default", "").then((CouchClient c) {
_dbclient = c;
}).then((_) {
@kurorido
kurorido / preparePostgreSQL.dart
Created June 30, 2014 10:56
insert 1M records into postgresSQL
void preparePostgreSQL() {
print("Testing Insert into postgresql...");
var uri = 'postgres://name:password@10.1.4.112:5432/mydb';
connect(uri).then((conn) {
//conn.execute("create table data (id int, name text, description text, PRIMARY KEY(id)); ").whenComplete(() {
// conn.close();
//});
int startTime = new DateTime.now().millisecondsSinceEpoch;
List<Future> futures = new List();
String sql = "";
@kurorido
kurorido / restframework blog note
Last active August 29, 2015 14:10
restframework blog note
class ArticleSerializer(serializers.ModelSerializer):
tags = serializers.RelatedField(many=True)
class Meta:
model = Article
fields = ('title','content','tags')
owner = serializers.Field(source='owner.username')
## find out mount/partition a directory or file is on?
df -P file/goes/here | tail -1 | cut -d' ' -f 1
# delete line 135 in file, and save origin file into file.bak
sed -i.bak -e '135d' file
# Recursive find string from files
grep -R -i -n '<string>' <directory>
# nohup
# 相框效果
img {
box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
padding: 12px;
background: rgba(255,255,255,0.9);
}
# 更新時間
UPDATE table SET end_dt = DATE_ADD(end_dt, INTERVAL 15 second)
# Command Line Run SQL
mysql -u root dbname < "path.sql"
# MySQL 連線
String driver = "com.mysql.jdbc.Driver";
Class.forName(driver);
String conUrl = "jdbc:mysql://localhost/smft?user=root&password=&charset=utf8&characterEncoding=UTF-8r";
Connection con = null;
PreparedStatement ps = conn.prepareStatement(SQL);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
rs.getString("UserName");
}