Skip to content

Instantly share code, notes, and snippets.

View ericmjl's full-sized avatar
🎯
Focusing

Eric Ma ericmjl

🎯
Focusing
View GitHub Profile
@ericmjl
ericmjl / shell-command-cheatsheet.md
Last active January 26, 2017 15:07
Shortcuts for Bash Shell

Bash Shell Command Cheat Sheet

ssh: Access a remote computer.

Examples:

$ ssh my_username@my.server.address
$ ssh dcuser@ip-address-at-amazonaws.com
@ericmjl
ericmjl / tmux-cheatsheet.markdown
Created July 9, 2017 15:37 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ericmjl
ericmjl / .theanorc
Created August 7, 2017 17:33
Eric's .theanorc
[global]
device = cuda
floatX = float32
compute_test_value = off
[cuda]
root = /usr/local/cuda
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
@ericmjl
ericmjl / environment.yml
Created May 26, 2016 13:55
an example conda environment.yml file
name: envname
dependencies:
- python=3
- package1
- package2
- pip
- pip:
- pypi_package1
- pypi_package2
@ericmjl
ericmjl / gist:4234935dd5f06f34640ef9696f623550
Created May 9, 2018 20:38
CuPy arrays have shapes but cupy doesn't have shape()
In [1]: import cupy as cp
In [2]: a = cp.array([1, 2, 3])
In [3]: cp.shape(a)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-e2f1392629a9> in <module>()
----> 1 cp.shape(a)
@ericmjl
ericmjl / install_tmux.sh
Created June 1, 2018 12:33
A script to install Tmux on systems that you don't have root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=2.6
@ericmjl
ericmjl / jupyter_magic.md
Last active June 4, 2018 12:55
Jupyter magic imports
%load_ext autoreload
%autoreload 2
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
@ericmjl
ericmjl / random_scalar_graph.py
Created August 1, 2018 21:55
Generate lots of random graphs with scalar features on each node.
import networkx as nx
import numpy as np
def generate_graph():
num_nodes = np.random.randint(low=3, high=20)
G = nx.erdos_renyi_graph(n=num_nodes, p=0.3)
for n in G.nodes():
value = np.random.randint(low=1, high=20)
G.node[n]['value'] = value
return G
@ericmjl
ericmjl / create_dir.py
Last active August 13, 2018 13:26
Python: create directory if it doesn't exist, using pathlib!
from pathlib import Path
import os
# We will use the example of creating a .directory under home.
home = Path.home()
dirname = home / '.dir'
if not dirname.exists():
os.mkdir(dirname)