Skip to content

Instantly share code, notes, and snippets.

View heartonbit's full-sized avatar

Minkyu Shim heartonbit

View GitHub Profile
@heartonbit
heartonbit / fix_ghost_neo4j_proc.md
Created June 13, 2021 08:56
Fix ghost Neo4j process issue
$ sudo neo4j status`
Neo4j is not running
`$ sudo ps -aux | grep org.neo4j.server.CommunityEntryPoint | head -n1 | awk -F ' ' '{print $2}' | sudo tee /var/run/neo4j/neo4j.pid`
24831
$ sudo neo4j status
Neo4j is running at pid 24831
$ sudo neo4j stop
Stopping Neo4j.. stopped
$ sudo neo4j start
@heartonbit
heartonbit / alias
Created April 4, 2021 07:38
GCP Alias
alias gssh='gcloud compute ssh'
alias gci='gcloud compute instances'
@heartonbit
heartonbit / gist:dea706c49a713f6c36c23f10abce2cd6
Created December 29, 2020 16:25
Select a certain number of files randomly and copy them to a specific location
shuf -zn10 -e *.txt | xargs -0 cp -vt ../targetdir/
@heartonbit
heartonbit / gist:e74264b1ed61529401c53dc3c016b094
Last active November 19, 2020 08:46
[Dockerfile] Install python3 on Ubuntu
# Install python
RUN apt-get update \
&& apt-get install -y python3-pip python3-dev git \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip
@heartonbit
heartonbit / find_n_delete
Last active November 14, 2020 20:43
find and delete
find . -type f -name "*.bak" -delete
or
find . -name "FILE-TO-FIND" -exec rm -rf {} \;
# Default nohup.out
nohup myprogram &
# Custom output file
nohup myprogram > myprogram.out &
# Redirect stderr to stdout
nohup myprogram > myprogram.out 2>&1 &
# Multiple commands
device_name = tf.test.gpu_device_name()
if device_name != '/device:GPU:0':
raise SystemError('GPU device not found')
print('Found GPU at: {}'.format(device_name))
print("GPU Available: ", tf.test.is_gpu_available())
import concurrent.futures
def do(params):
return "hello"
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
future = executor.submit(do, params)
for future in concurrent.futures.as_completed(future_to_url):
url = future_to_url[future]
def predict_score(model_pickle_path, target_filepath, n_meta_columns, n_feature_columns):
"""
model_pickle_path :
target_filepath : target gene expression examples with meta
n_meta_columns : number of meta columns
n_feature_columns : number of feature(gene)s
return score DataFrame
"""
df0 = pd.read_csv(target_filepath, header=-1)
x_header = df0.iloc[:, 0:n_meta_columns]
def cosine_distances(X, Y):
"""
X : Target example score vector DataFrame with inst_id as the first column
Y : All example score vector DataFrame with inst_id as the first column
return pair-wise cosine distance DataFrame
"""
from sklearn.metrics import pairwise
x_header = X.iloc[:, 0].values
X = X.iloc[:, 1:]
y_header = Y.iloc[:, 0].values