Skip to content

Instantly share code, notes, and snippets.

Lukas Galke lgalke

View GitHub Profile
@lgalke
lgalke / anagrams.py
Last active Mar 12, 2020
Simple Anagram Generator in Python
View anagrams.py
import argparse, itertools
parser = argparse.ArgumentParser()
parser.add_argument('input', help="Initial text for generating anagrams")
parser.add_argument('-d', '--dict', default='/usr/share/dict/cracklib-small',
help="A word list such as '/usr/share/dict/words' or '/usr/dict/words'")
args = parser.parse_args()
with open(args.dict, 'r') as fh:
valid_words = set(line.strip().lower() for line in fh)
anagrams = set(''.join(a) for a in itertools.permutations(list(args.input.lower())) if all(w in valid_words for w in ''.join(a).split()))
for anagram in sorted(anagrams):
@lgalke
lgalke / locdb-journals.ipynb
Created Jan 14, 2018 — forked from zuphilip/locdb-journals.ipynb
LOC-DB Journals Analysis
View locdb-journals.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgalke
lgalke / text.py
Created Feb 28, 2017 — forked from psorianom/text.py
Text feature extractor with okapi bm25 and delta idf
View text.py
# -*- coding: utf-8 -*-
# Authors: Olivier Grisel <olivier.grisel@ensta.org>
# Mathieu Blondel <mathieu@mblondel.org>
# Lars Buitinck <L.J.Buitinck@uva.nl>
# Robert Layton <robertlayton@gmail.com>
# Jochen Wersdörfer <jochen@wersdoerfer.de>
# Roman Sinayev <roman.sinayev@gmail.com>
#
# License: BSD 3 clause
"""
@lgalke
lgalke / necromancy.vim
Last active Feb 25, 2017
Snippets in a single VimL line instead of plugin
View necromancy.vim
" Snippets (or reanimating skeletons) in plain vim which just uses ONE LINE OF CODE:
" The following is one single abbreviation for all:
" The graveyard.
" - Visual selection -> :w\g/<filename> will create a grave
" - Reanimating a skeleton by -> :r\g/<filename>
" Of course you can get a list of your skeletons by hitting <tab> instead of writing a filename (wildmenu).
" Or hit *.py<Tab> to get a list of only python snippets.
" - Editing a skeleton... -> :e\g/<filename>
cabbrev \g $HOME/.vim/graveyard
@lgalke
lgalke / all_but_the_top.py
Last active Nov 18, 2019
Word Embedding Postprocessing: All but the top
View all_but_the_top.py
"""
All-but-the-Top: Simple and Effective Postprocessing for Word Representations
Paper: https://arxiv.org/abs/1702.01417
Last Updated: Fri 15 Nov 2019 11:47:00 AM CET
**Prior version had serious issues, please excuse any inconveniences.**
"""
import numpy as np
from sklearn.decomposition import PCA
View cucumbertables.vim
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
View 01.cmake
-- The C compiler identification is Clang 5.0.0
-- The CXX compiler identification is Clang 5.0.0
-- Check for working C compiler: /usr/local/Library/ENV/4.3/clang
-- Check for working C compiler: /usr/local/Library/ENV/4.3/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/local/Library/ENV/4.3/clang++
-- Check for working CXX compiler: /usr/local/Library/ENV/4.3/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
You can’t perform that action at this time.