Skip to content

Instantly share code, notes, and snippets.

@zhangpengGenedock
zhangpengGenedock / min-char-rnn.py
Created September 16, 2017 11:07 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@zhangpengGenedock
zhangpengGenedock / mongo_export
Created September 21, 2017 07:55
mongo_export
mongoexport --db mongo_db --collection gdtask_daily_stats --out gdtask_daily_stats.json
@zhangpengGenedock
zhangpengGenedock / waya-dl-setup.sh
Created September 23, 2017 14:09 — forked from mjdietzx/waya-dl-setup.sh
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
#!/bin/bash
# install CUDA Toolkit v8.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get -y install cuda
db.gdtask_daily_stats_all_regions_summary.createIndex({"task_id":1, "Region":1},{ unique: true })
@zhangpengGenedock
zhangpengGenedock / git-checkout-previous-branch
Created October 12, 2017 03:45
git-checkout-previous-branch
git checkout -
或者
git co -
@zhangpengGenedock
zhangpengGenedock / use_apply_in_pandas
Created October 13, 2017 07:12
use_apply_in_pandas
In [43]: df['Value'] = df.apply(lambda row: my_test(row['a'], row['c']), axis=1)
In [44]: df
Out[44]:
a b c Value
0 -1.674308 foo 0.343801 0.044698
1 -2.163236 bar -2.046438 -0.116798
2 -0.199115 foo -0.458050 -0.199115
3 0.918646 bar -0.007185 -0.001006
4 1.336830 foo 0.534292 0.268245
@zhangpengGenedock
zhangpengGenedock / PyCharm change working directory of console Ask
Created October 13, 2017 09:28
PyCharm change working directory of console Ask
Settings -> Build Execution Deployment -> Console -> Python Console
@zhangpengGenedock
zhangpengGenedock / df某一列从bool类型转为整型
Created October 18, 2017 06:25
df某一列从bool类型转为整型
df.somecolumn = df.somecolumn.astype(int)
@zhangpengGenedock
zhangpengGenedock / git clone specific commit branch
Created October 19, 2017 03:52
git clone specific commit branch
What else can you do?
How to clone repository to a specific commit? (full clone)
# Create empty repository to store your content
git clone <url>
git reset <sha-1> --hard
More info:
How to clone single branch?
@zhangpengGenedock
zhangpengGenedock / datetime extract and subtract
Last active October 20, 2017 06:49
datetime extract and subtract
import datetime
d = '2017-10-16'
df = datetime.datetime.strptime(d, '%Y-%m-%d')
df
Out[6]: datetime.datetime(2017, 10, 16, 0, 0)
df = df - datetime.timedelta(days=1)
df
Out[8]: datetime.datetime(2017, 10, 15, 0, 0)
df.strftime('%Y-%m-%d')