Skip to content

Instantly share code, notes, and snippets.

View victor-iyi's full-sized avatar
🎯
Focusing

Victor I. Afolabi victor-iyi

🎯
Focusing
View GitHub Profile
@victor-iyi
victor-iyi / pbcopy.sh
Created March 10, 2020 17:03
Recreating Mac's version of pbcopy on Linux
#!/bin/sh
# Copyright (C) 2009-2017 Three Nine Consulting
# Always good practice to update packages. However ask user if they would like to do so
# For explanation on how this works and why check out https://garywoodfine.com/use-pbcopy-on-ubuntu/
read -p "Do you want to update your package repositories before proceeding ? " -n 1 -r
echo #adding new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo apt update
sudo apt upgrade -y
@victor-iyi
victor-iyi / threaded-knn.py
Created July 5, 2019 07:14
Multi threaded k-Nearest Neighbor
import threading
from queue import Queue
from collections import Counter
import numpy as np
from matplotlib import style, pyplot as plt
datasets = {
'red': [[1, 2], [3, 4], [3, 2], [1, 0]],
@victor-iyi
victor-iyi / gpt2-transformer.py
Last active November 13, 2020 04:11
How to Build the AI that's "Too Dangerous to Release"
"""
# GPT-2 Model
## Usage
Install the [PyTorch-Pretrained-BERT model](https://github.com/huggingface/pytorch-pretrained-BERT) and it's dependencies from [huggingface](https://github.com/huggingface/).
```sh
pip install pytorch-pretrained-bert
pip install spacy ftfy==4.4.3
@victor-iyi
victor-iyi / reinforcement-learning-part-1-01.py
Created April 11, 2019 19:26
Introduction to Reinforcement Learning (Article on Medium)
>>> import gym
>>> import numpy as np
>>> # Create a Taxi environment provided by OpenAI.
>>> env = gym.make('Taxi-v2')
>>> # Initialize the environment, by placing the agent in a random state.
>>> env.reset()
344
@victor-iyi
victor-iyi / sentence.py
Created March 27, 2019 17:12
A simple iterable sentence class.
class Sentence(str):
"""A simple iterable sentence class.
Methods:
def __init__(self, text): ...
def __repr__(self): ...
def __str__(self): ...
@victor-iyi
victor-iyi / tokenizer.py
Created January 21, 2019 22:20
Basic, End-to-end and Word-piece tokenization.
import collections
import re
import unicodedata
import six
import tensorflow as tf
def validate_case_matches_checkpoint(do_lower_case, init_checkpoint):
"""Checks whether the casing config is consistent with the checkpoint name."""
@victor-iyi
victor-iyi / license-badges.md
Created January 10, 2019 14:40 — forked from lukas-h/license-badges.md
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

@victor-iyi
victor-iyi / argparser.sh
Last active January 9, 2019 19:55
Keyword argument shell parser
#!/usr/bin/env bash
# Set Message Colors.
reset='\033[0m' # Text Reset
# Regular Colors.
red='\033[0;31m' # Red
green='\033[0;32m' # Green
purple='\033[0;35m' # Purple
@victor-iyi
victor-iyi / slice.py
Last active December 2, 2018 21:13
Multi-dimensional slicing in Python
class SliceAble:
def __init__(self):
pass
def __repr__(self):
return '{}()'.format(self.__class__.name)
def __getitem__(self, item):
if isinstance(item, slice):
@victor-iyi
victor-iyi / git-delete-history.sh
Last active December 1, 2018 21:15
Permanently delete files/folders from your git repository.
#!/bin/bash
set -o errexit
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
# Set Message Colors.
reset='\033[0m' # Text Reset
red='\033[0;31m' # Red