Skip to content

Instantly share code, notes, and snippets.

View sflender's full-sized avatar

Samuel Flender sflender

View GitHub Profile
import torch
import torch.nn as nn
import torch.nn.functional as F
class SimpleSelfAttention(nn.Module):
def __init__(self, embed_size):
super(SimpleSelfAttention, self).__init__()
self.embed_size = embed_size
self.values = nn.Linear(embed_size, embed_size, bias=False)
self.keys = nn.Linear(embed_size, embed_size, bias=False)
@sflender
sflender / site.md
Created October 20, 2022 23:24
How to launch a website with Github Pages and Jekyll
import pandas as pd
import numpy as np
def get_values_for_key(key, entries):
return [(str(e).split(key)[1].split(';')[0].split('>')[1].split('<')[0] if key in str(e) else 'missing') for e in entries ]
df = pd.DataFrame()
df['id'] = np.arange(0,len(entries),1)
for key in ['Flag','Abandoned','Notified','Port of abandonment']:
df[key] = get_values_for_key(key, entries)
import requests
import urllib.request
from bs4 import BeautifulSoup
response = requests.get("https://www.ilo.org/dyn/seafarers/seafarersBrowse.list?p_lang=en")
soup = BeautifulSoup(response.text, 'html.parser')
entries = soup.findAll('p')
@sflender
sflender / gist:48feb65fb9f7331df389bac3c1f5f861
Created March 13, 2018 18:33
How to use Sublime Text 3 on remote server
How to use Sublime text 3 on remote server:
- option 1: use sshfs. This has the disadvantage that you need to log in twice if you want to edit and compile code on remote.
- option 2: use rsub.
wget -O ~/bin/rsub \https://raw.github.com/aurora/rmate/master/rmate
chmod a+x ~/bin/rsub
add this to .bashrc:
export PATH="~/bin:$PATH"
@sflender
sflender / gist:b7f2f740803924cb8672f7018a4c85eb
Last active September 16, 2021 04:42
How to use tensorboard on remote server
There are two ways for using tensorboard on a remote server:
--1. Use sshfs.
However, I found that this method is pretty slow, in particular if you want to compare several different long runs in tensorboard.
--2. ssh with a port forwarding:
ssh -L 16006:127.0.0.1:6006 user@remote
Then, on your local machine simply open
http://127.0.0.1:16006/
@sflender
sflender / instructions.md
Last active January 5, 2018 20:06
Install xgboost on MacOS

Here's how I installed xgboost on my Mac. First, install gcc:


brew install gcc

Then clone the repo:


git clone --recursive https://github.com/dmlc/xgboost 
cd xgboost
cp make/config.mk .