Skip to content

Instantly share code, notes, and snippets.

View andreasgrv's full-sized avatar

Andreas Grivas andreasgrv

View GitHub Profile
@JohnGiorgi
JohnGiorgi / biaffine_classifier.py
Last active November 2, 2023 04:58
PyTorch implementation of the biaffine attention operator from "End-to-end neural relation extraction using deep biaffine attention" (https://arxiv.org/abs/1812.11275) which can be used as a classifier for binary relation classification. If you spot an error or have an improvement, let me know!
import torch
class BiaffineAttention(torch.nn.Module):
"""Implements a biaffine attention operator for binary relation classification.
PyTorch implementation of the biaffine attention operator from "End-to-end neural relation
extraction using deep biaffine attention" (https://arxiv.org/abs/1812.11275) which can be used
as a classifier for binary relation classification.
@koreyou
koreyou / shuf
Created January 6, 2018 09:31
Linux shuf command with seed option
#!/bin/bash
# seeding adopted from https://stackoverflow.com/a/41962458/7820599
get_seeded_random()
{
seed="$1";
openssl enc -aes-256-ctr -pass pass:"$seed" -nosalt \
</dev/zero 2>/dev/null;
}
@florianbeer
florianbeer / set-tmux-title
Created April 21, 2015 10:47
Set tmux pane title to short hostname on ssh connections
ssh() {
if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=)" = "tmux" ]; then
tmux rename-window "$(echo $* | cut -d . -f 1)"
command ssh "$@"
tmux set-window-option automatic-rename "on" 1>/dev/null
else
command ssh "$@"
fi
}
@dwyerk
dwyerk / concave_hulls.ipynb
Created April 12, 2014 23:20
concave hulls using shapely and scipy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@killercup
killercup / pandoc.css
Created July 3, 2013 11:31
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
@codemonkey85
codemonkey85 / objSerialization.cpp
Last active November 26, 2022 04:26
An example of how to serialize / deserialize a C++ struct to and from a disk file.
struct OBJECT{ // The object to be serialized / deserialized
public:
// Members are serialized / deserialized in the order they are declared. Can use bitpacking as well.
DATATYPE member1;
DATATYPE member2;
DATATYPE member3;
DATATYPE member4;
};
void write(const std::string& file_name, OBJECT& data) // Writes the given OBJECT data to the given file name.
@ttezel
ttezel / gist:4138642
Last active March 24, 2024 03:24
Natural Language Processing Notes

#A Collection of NLP notes

##N-grams

###Calculating unigram probabilities:

P( wi ) = count ( wi ) ) / count ( total number of words )

In english..

@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 2, 2024 15:59
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: