LoginSignup
1
2

More than 5 years have passed since last update.

自分用あんちょこ

Last updated at Posted at 2017-01-20

現場が変わるなどして、あまり使わなくなり、
便利なコマンドを忘れてしまう・・・
ということが多々あるので、自分用のメモであります。

Linux

ディスク書込み性能確認

 dd bs=1M count=1000 if=/dev/zero of=/HOGE/disktest oflag=direct

cookieつきwget

wget -O [output] --load-cookies="./cookie.txt" [url]

GPU状態参照

nvidia-smi

改行コードいじり

perl -p -e 's/\n/\r\n/'

ポート確認 (2017/02/01 追加)

lsof -i
lsof -i:[port]
netstat -antu

Python

cookieを設定してget

import requests
cookies = {
    'aaa': '81',
    'bbb': 'xxx'
}
res = requests.get([url], cookies=cookies)

リスト内包表記

http://qiita.com/y__sama/items/a2c458de97c4aa5a98e7

nan判定

math.iznan(xxx)

改行なしprint

print("hello", end="")

高速for

for x in[None]*xxx
for x in[0]*xxx
for x in range(xxx)

date型に変換 (2017/02/01 修正)

# pandas を使うと楽
pd.to_datetime('2015/1/1 10:00')

タイムゾーン変更 (2017/02/01 追加)

# pandas を使うと楽
pd.to_datetime('2015/1/1 10:00').tz_localize('GMT').tz_convert('Asia/Tokyo')
-> Timestamp('2015-01-01 19:00:00+0900', tz='Asia/Tokyo')

モジュールやクラスを覗く (2017/02/01 追加)

def pvars(_class):
    for _key in vars(_class).keys():
        print('[%s] %s' % (_key, vars(_class)[_key]))

DataFrame内の最大値の位置を検索 (2017/03/22 追加)

column_name = df.max().argmax()
index_name = df[column_name].argmax()
df.ix[index_name, column_name]

mongodb

型で検索

db.collection.find(xxx: {$type: 2})
    - 欠損?              0
    - Double             1
    - String             2
    - Object             3
    - Array              4
    - Null              10
    - 32-bit integer    16
    - Timestamp         17
    - 64-bit integer    18

date型の検索

db.collection.find({xxx: {$gte:ISODate("2014-11-01T00:00:00Z")}})
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2