Skip to content

Instantly share code, notes, and snippets.

@aic25
aic25 / bash.sh
Last active January 15, 2019 02:10
Shell memo
file transfer
rsync -uvr -e ssh Study/* server:/home/me/Study/
scp ~/.ssh/id_rsa.pub darvader@deathstar.empire.gov:
sshpass -p "password" scp -r user@example.com:/some/remote/path /some/local/path
or
sshpass -f "/path/to/passwordfile" scp -r user@example.com:/some/remote/path /some/local/path
pscp .\Documents\DummyF\Dummy-d.txt server:DummyFolder/
apt-cache show zim | grep '^Recommends:'
find (can execute on files found), locate (easier to use), ln -s targetfile linkname
@aic25
aic25 / ssh.sh
Last active December 6, 2018 01:36
Docker setup
nvidia-docker run -it --rm -p 8870:8870 -p 8880:8880 -p 8890:8890 -p 5000:5000 --name me.test -v /home/me/Study/:/notebooks tensorflow/tensorflow:1.8.0-gpu-py3
docker exec -ti me.test /bin/bash
apt-get update
pip install jupyterlab
pip install gputil
pip install keras==2.0.8
apt-get install git-core
apt-get install wget
cdls() { cd "$@" && ls -lrt; }
@aic25
aic25 / tf-keras.py
Created June 6, 2018 05:52
Setup to use GPU
# In case of python_tk error
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
# Limit the number of GPUs used
import tensorflow as tf
import numpy as np
import GPUtil
import os
@aic25
aic25 / init.sh
Last active August 27, 2018 12:41
Link to data folder and call the script from python
```ascript.sh
#!/bin/bash
some script
```
```python.py
import subprocess
print("start")
cur_pwd = os.getcwd()
os.chdir("path/to/ascript")
@aic25
aic25 / powershell.ps1
Created June 27, 2018 01:28
shell commands for server access
# serveraccess.bat
@echo off
powershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file "ServerAccess.ps1"
## ServerAccess.ps1
net use \\server /user:username password
@aic25
aic25 / Dockerfile
Created August 27, 2018 08:32 — forked from RinatMullayanov/Dockerfile
Ubuntu Node.js Dockerfile
#
# Ubuntu Node.js Dockerfile
#
# https://github.com/dockerfile/ubuntu/blob/master/Dockerfile
# https://docs.docker.com/examples/nodejs_web_app/
#
# Pull base image.
FROM ubuntu:14.04
@aic25
aic25 / countfiles.sh
Created August 30, 2018 03:30
file counter
#!/bin/bash
find . -type d -print0 | while read -d '' -r dir; do
files=("$dir"/*)
printf "%5d files in directory %s\n" "${#files[@]}" "$dir"
done
@aic25
aic25 / TF-dockerfile
Created September 3, 2018 06:01
Modified to use jupyter lab
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@aic25
aic25 / memo.txt
Last active February 26, 2019 02:18
shell adventure
~/.bashrc
```
export PATH="/notebooks/webcam/ffmpeg_sources/bin:$PATH"
export OPENCV_FFMPEG_CAPTURE_OPTIONS="video_codec;h264_cuvid"
export OPENCV_V4L_CAPTURE_OPTIONS="video_codec;h264_cuvid"
export OPENCV_V4L2_CAPTURE_OPTIONS="video_codec;h264_cuvid"
alias ls='ls -lsrht --color=auto'
alias docker='sudo docker'
alias nvidia-docker='sudo nvidia-docker'
alias cuda-info='cat /usr/local/cuda/version.txt && nvcc --version'
@aic25
aic25 / average-taker
Created January 7, 2019 22:39
Average taker
#!/bin/bash
sum=$(ls -l *.dat | wc -l)
paste -d" " *.dat | awk -v s="$sum" '{
for(i=0;i<=s-1;i++)
{
t1 = 2+(i*2)
temp1 = temp1 + $t1
}
print $1""temp1/s
temp1=0