Skip to content

Instantly share code, notes, and snippets.

View hamelsmu's full-sized avatar
💻
Always learning.

Hamel Husain hamelsmu

💻
Always learning.
View GitHub Profile
@hamelsmu
hamelsmu / binder.yaml
Created May 20, 2020 21:37
Label your pull requests with mybinder.org links. This allows collaborators to view your files in a Jupyter Notebook environment with correct dependencies without cloning or building your repo.
name: Binder
on:
pull_request:
types: [opened, reopened]
jobs:
Create-Binder-Badge:
runs-on: ubuntu-latest
steps:
@hamelsmu
hamelsmu / fastpages.md
Last active February 24, 2020 21:35
Sharing Information With Jupyter Notebooks: A Data Scientist's Struggle
  1. Sally creates this notebook which contain interactive visualizations. She saves the notebook to GitHub.

  2. Sally wants to share this report with her colleagues on twitter, preferrably as a blog post. However, she cannot share her notebook via a GitHub link due of the following issues:

    • GitHub doesn't support rendering her interactive visualizations, even when all the code is client side, like the case with Vega-Lite or Altair. (That is why you don't see any visualizations in this notebook on GitHub!)
    • There is no place for colleague to comment on the notebook or provide feedback easily.
    • Sally wants to hide / show code to make the document easier to read, and remove extreanous information. It is impossible to do this without copying her notebook and creating an alternate version.
  • Sally needs the ability to hide/show code in collapsable cells in certain
@hamelsmu
hamelsmu / convert_nb2blog.py
Last active January 22, 2020 20:01
Monkey Patch nbdev for Jupyter Blog Posts
from nbdev import export2html
from nbdev.export2html import Config, Path, _re_digits
## Monkey Patch Nbdev For Jupyter Blog Posts ##
def _nb2htmlfname(nb_path, dest):
if dest is None: dest = Config().doc_path
return Path(dest)/_re_digits.sub('', nb_path.with_suffix('.md').name)
## apply monkey patch
export2html._nb2htmlfname = _nb2htmlfname
@hamelsmu
hamelsmu / vertical-line-altair.py
Created January 18, 2020 01:37
How to make vertical line in altair
from vega_datasets import data as vega_data
import pandas as pd
import altair as alt
data = pd.read_json(vega_data.gapminder.url)
data2000 = data.loc[data['year'] == 2000]
chart1 = alt.Chart(data2000).mark_line().encode(
alt.X('fertility:Q'),
@hamelsmu
hamelsmu / example
Last active January 16, 2020 21:29
Just paste this into your markdown
<link href="https://unpkg.com/@primer/css/dist/primer.css" rel="stylesheet" />
<div class="Toast">
<span class="Toast-icon">
{% octicon info %}
</span>
<span class="Toast-content">You can add these components, too!</span>
</div>
@hamelsmu
hamelsmu / markdown-details-collapsible.md
Created December 20, 2019 03:23 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
#!/usr/bin/env python
# coding: utf-8
# This notebook illustrates the use of a utility, `InferenceWrapper.df_to_emb` that can be used to perform inference in bulk.
# - **checkpointed model** (2.29 GB):
# `https://storage.googleapis.com/issue_label_bot/model/lang_model/models_22zkdqlr/best_22zkdqlr.pth`
@hamelsmu
hamelsmu / wandb_fastai_troubleshooting.py
Created May 14, 2019 21:09
For troubleshooting wandb
from fastai.text import TextLMDataBunch as lmdb
from fastai.text.transform import Tokenizer
import pandas as pd
from pathlib import Path
small_df = pd.read_csv('https://storage.googleapis.com/issue_label_bot/pre_processed_data/processed_part0000.csv').head(1000)
stokenizer = Tokenizer(pre_rules=[pass_through], n_cpus=30)
spath = Path('lang_model_test/')
import pandas as pd
from pathlib import Path
from fastai.text import TextLMDataBunch as lmdb, load_data
from fastai.text.transform import Tokenizer
def pass_through(x):
return x
valid_df = pd.read_csv('https://storage.googleapis.com/issue_label_bot/pre_processed_data/processed_part0000.csv')
train_df = valid_df
{
"action": "edited",
"issue": {
"html_url": "https://github.com/Codertocat/Hello-World/issues/2",
"id": 327883527,
"number": 2,
"title": "Spelling error in the README file",
"user": {
"login": "Codertocat",
"type": "User",