Skip to content

Instantly share code, notes, and snippets.

View abarth500's full-sized avatar

Shohei Yokoyama abarth500

  • Tokyo Metropolitan University
  • Tokyo Japan
View GitHub Profile
@abarth500
abarth500 / gist:55b9a02bc0f2590558c7
Last active August 29, 2015 14:08
node.jsからmongoDBへの接続コード例
/* mongoDB */
use data_eng
db.winelist.insert({name:"シャブリ",color:"white"})
db.winelist.insert({name:"ジュヴレシャンベルタン",color:"red"})
db.winelist.insert({name:"サンテミリオン",color:"red"})
db.winelist.insert({name:"オーメドック",color:"red"})
db.winelist.insert({name:"サンセール",color:"white"})
db.winelist.find({color:"red"})
@abarth500
abarth500 / gist:430d6d58cfddda677c89
Last active August 29, 2015 14:08
mongodb接続モジュールのインストール
#nodeのインストール
sudo sh -c "curl -sL https://rpm.nodesource.com/setup | bash -"
sudo yum install gcc-c++ make
sudo yum install nodejs
sudo yum install npm
#モジュールのインストール
#プログラムのおいてあるディレクトリのみ有効にする場合
npm install mongodb
// AVLTree ///////////////////////////////////////////////////////////////////
// This file is originally from the Concentré XML project (version 0.2.1)
// Licensed under GPL and LGPL
//
// Modified by Jeremy Stephens.
// Pass in the attribute you want to use for comparing
function AVLTree(n, attr) {
this.init(n, attr);
}
@abarth500
abarth500 / gist:6ccba3ca80f9fe2c5f72
Last active August 29, 2015 14:02
[CS実験I] デフォルトストレージエンジンの設定 (/etc/my.conf)
default-storage-engine=Aria
@abarth500
abarth500 / gist:5c9976517f819e4a0fe5
Last active August 29, 2015 14:02
[CS実験I] 表紙画像取得SQL
--もし学籍番号が70310051の場合
SELECT * FROM geotag WHERE id = (
SELECT id FROM geotag
ORDER BY id
LIMIT 1
OFFSET 310051);
-- ^^^^^^---ここに学生番号の先頭の70をとった数値を入れる。
@abarth500
abarth500 / gist:1d805a75b68f1de2908b
Created June 10, 2014 10:17
[CS実験I] /etc/php.iniの開発用設定
#ブログラムのタイムアウトの設定
#以下の行を見つける
max_execution_time = 30
#次のように書きかえる
max_execution_time = 300
#--------------------------------
#画面へのエラー表示の設定
@abarth500
abarth500 / gist:8fee93102f1672734d29
Last active August 29, 2015 14:02
[CS実験I] テーブルのデータ量を見てみる (インデクス作成後)
--メタデータを保持しているDBへ移動
use information_schema;
select table_name,data_length,index_length from partitions where table_name='geotag' or table_name='tag';
--実験用DBへ戻る
use CSexp1DB;
-- ^^^^^^^^これは皆さん個人のデータベース名に読み替えてくださいね。
@abarth500
abarth500 / gist:dbbfe2809247884e2ce1
Last active August 29, 2015 14:02
[CS実験I] テーブルのデータ量を見てみる (インデクス作成前)
--メタデータを保持しているDBへ移動
use information_schema;
select table_name,data_length,index_length from partitions where table_name='geotag' or table_name='tag';
--実験用DBへ戻る
use CSexp1DB;
-- ^^^^^^^^これは皆さん個人のデータベース名に読み替えてくださいね。
@abarth500
abarth500 / gist:1a96ec6d241826e20923
Created June 10, 2014 08:11
[CS実験I] SELECT文の試行2
--インデクスを強制的に使用しないで問い合わせをする方法
SELECT * FROM geotag IGNORE INDEX (PRIMARY) WHERE id = 7738073352;
--PRIMARYは主キーに自動で付けられるインデクスの名前
--この場合は検索に時間がかかります。
@abarth500
abarth500 / gist:817cd2719e68d2b721d0
Last active August 29, 2015 14:02
[CS実験I] SELECT文の試行
--インデクスを作成しているフィールドで検索
SELECT * FROM geotag WHERE id = 7738073352;
-- 0secで結果が返ってきます
--インデクスを作成していないフィールドで検索
SELECT * FROM geotag WHERE latitude = 38.9466;
-- 14sec程度かかります