Skip to content

Instantly share code, notes, and snippets.

View orestxherija's full-sized avatar

Orest Xherija orestxherija

View GitHub Profile
@dengemann
dengemann / run_profile_fast_dot.py
Last active September 8, 2020 14:04
Compare regular numpy dot with fast_dot directly handling BLAS
# Author: Denis A. Engemann <[email protected]>
#
# License: BSD (3-clause)
""" Profile fast_dot versus np.dot
Dependencies
------------
scikit-learn
https://github.com/fabianp/memory_profiler
@kidpixo
kidpixo / jupyter_shortcuts.md
Last active September 21, 2024 14:26
Keyboard shortcuts for ipython notebook 3.1.0 / jupyter

Warning This is SEVERELY outdated, the current jupyter version is > 6.X, please refer to your current jupyter notebook installation!

Disclaimer : I just copied those shortcuts from Jupyter Menú > Help > Keyboard Shortcuts, I didn't wrote them myself.

Check your current shortcuts in your Help, shortcuts coule have been modified by extensions or your past self.

Toc

Keyboard shortcuts

@abhin4v
abhin4v / Calc.hs
Last active November 29, 2022 08:02
Simple Applicative Parser and Expression Calculator in Haskell
module Calc
( Expr(..)
, parse
, calculate
) where
import Control.Applicative
import Parser
data Expr = Add Expr Expr
@suriyadeepan
suriyadeepan / wiki_recursive.py
Created August 26, 2016 07:33
Recursively grab Article titles from wiki using Beautiful Soup
from bs4 import BeautifulSoup
import requests
start_url = 'https://en.wikipedia.org/wiki/Transhumanism'
domain = 'https://en.wikipedia.org'
''' get soup '''
def get_soup(url):
# get contents from url
content = requests.get(url).content
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active February 20, 2025 02:47
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cezaraugusto
cezaraugusto / gpg_fix.txt
Last active November 7, 2024 16:39
fixing `gpg failed to sign data` error on macOS
For troubleshooting, two things to first try:
run `git config --global gpg.program gpg2`, to make sure git uses gpg2 and not gpg
run `echo "test" | gpg2 --clearsign`, to make sure gpg2 itself is working
If that all looks all right, one next thing to try:
run `brew install pinentry` to ensure you have a good tool installed for passphrase entry
If after that install and you re-try git commit and still get the "failed to sign the data" error:
run `gpgconf --kill gpg-agent` to kill any running agent that might be hung
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@egrefen
egrefen / maml_train.py
Last active May 12, 2021 08:15
Train maml model with torchmeta and higher v0.2.
# Based on the code in https://github.com/tristandeleu/pytorch-meta/tree/master/examples/maml
# Basically, we only use the dataset loaders/helpers from TorchMeta and replace usage of MetaModules
# with normal pytorch nn.Modules, letting higher deal with making the inner loop unrollable and the
# optimizers differentiable. This makes it easier to use another optimizer than SGD, or any arbitrary
# third-party model, when doing MAML using this codebase.
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
@thomwolf
thomwolf / loading_wikipedia.py
Last active January 12, 2025 13:34
Load full English Wikipedia dataset in HuggingFace nlp library
import os; import psutil; import timeit
from datasets import load_dataset
mem_before = psutil.Process(os.getpid()).memory_info().rss >> 20
wiki = load_dataset("wikipedia", "20200501.en", split='train')
mem_after = psutil.Process(os.getpid()).memory_info().rss >> 20
print(f"RAM memory used: {(mem_after - mem_before)} MB")
s = """batch_size = 1000
for i in range(0, len(wiki), batch_size):