Skip to content

Instantly share code, notes, and snippets.

View paulegradie's full-sized avatar
🏠
Working from home

Paul Gradie, PhD paulegradie

🏠
Working from home
View GitHub Profile
@paulegradie
paulegradie / reset_branch.txt
Created April 3, 2018 01:11
Force pull - overwrite with content from origin
git fetch --all
git reset --hard origin/{branch_name}
@paulegradie
paulegradie / find_new_files.txt
Created October 24, 2018 21:09
How to find all new files you've added to a branch
git diff {old_branch}...{new_branch} --name-status --diff-filter=A
e.g. to find a enw file added since branching from master:
git diff master...gradie/sandbox --name-status --diff-filter=A
Options for `--diff-filter
Added (A)
Copied (C)
import numpy as np
def make_blob_part(mean, cov, num_points=500):
x, y = np.random.multivariate_normal(mean, cov, num_points).T
return np.hstack((x.reshape(-1, 1), y.reshape(-1, 1)))
mean1 = [-10, 10]
mean2 = [-15, 5]
mean3 = [-9, 3]
@paulegradie
paulegradie / sample_embeddings.txt
Last active August 8, 2019 00:52
A sample embedding matrix
idx | embed_matrix
0 [[ 0.21143426, 1.2885487 , 0.98160927, 0.17858341],
1 [-0.38735983, 0.06507064, 1.31839592, -0.91412724],
2 [ 1.13726889, 0.48327542, 0.65075236, 0.93818869],
3 [1.73606298, 1.70675348, 0.31396571, 2.03089933]]
# assigns the row from the embedding matrix to the named variable
king = embed_matrix[word_to_index['king']]
male = embed_matrix[word_to_index[‘male’]]
female = embed_matrix[word_to_index[‘female']]
queen = embed_matrix[word_to_index['queen']]
# the formula now uses the vectors from the embedding matrix
assert (king - man) + woman ≈ queen
@paulegradie
paulegradie / word2index.py
Last active August 20, 2019 02:39
A sample word2index generated in python.
"""
# The map
word | idx
----------------
king | 0
male | 1
queen | 2
female | 3
"""
@paulegradie
paulegradie / gist:ddce0bfb1f7bfb3754acc0b6f2a9affe
Created April 7, 2020 13:44
Bash function to help manage multiple github identities in your ssh config
#~/.ssh/config
_____________________________________________________________________________
# Instructions:
# ---------------------------------------------
# the way this works is that you have to use the Host value with the ssh call
# Host="github.com-paulegradie"
# git clone git@${Host}:paulegradie/SeqPyPlot.git
# The default here is github.com - this is what comes with the copy/paste from github when you click
# the clone or download button.
@paulegradie
paulegradie / AddPalavyrWidgetToWebsite
Created October 25, 2020 22:06
Add your widget to your website
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Awesome Website</title>
<style>
#mainFrame {
background-color: black;