Skip to content

Instantly share code, notes, and snippets.

Avatar

Ramnath Vaidyanathan ramnathv

View GitHub Profile
@ramnathv
ramnathv / Makefile
Last active Jan 16, 2021
R Markdown to IPython Notebook
View Makefile
example.md: example.Rmd
./knit
example.ipynb: example.md
notedown example.md | sed 's/%%r/%%R/' > example.ipynb
@ramnathv
ramnathv / gh-pages.md
Created Mar 28, 2012
Creating a clean gh-pages branch
View gh-pages.md

Creating a clean gh-pages branch

This is the sequence of steps to follow to create a root gh-pages branch. It is based on a question at [SO]

cd /path/to/repo-name
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
echo "My GitHub Page" > index.html
@ramnathv
ramnathv / README.md
Last active Dec 17, 2020
Upload Directory of Files using Gist API
View README.md

This is a short set of functions that use the httr package to upload a directory of files as a gist. The post_gist function uploads an anonymous gist, which can only be deleted within a short time of being uploaded. So be cautious in what you upload using this function.

@ramnathv
ramnathv / bm25.py
Created Sep 8, 2020 — forked from koreyou/bm25.py
Implementation of OKapi BM25 with sklearn's TfidfVectorizer
View bm25.py
""" Implementation of OKapi BM25 with sklearn's TfidfVectorizer
Distributed as CC-0 (https://creativecommons.org/publicdomain/zero/1.0/)
"""
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from scipy import sparse
class BM25(object):
View datasaurus.R
library(ggplot2)
library(datasauRus)
library(gganimate)
p <- ggplot(datasaurus_dozen, aes(x = x, y = y, frame = dataset)) +
geom_point() +
theme(legend.position = "none")
gganimate(p, title_frame = FALSE)
@ramnathv
ramnathv / index.html
Created Nov 19, 2014
D3 Statebins with rMaps
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="data:application/x-javascript,%28function%28%29%20%7B%0A%20%20%2F%2F%20If%20window%2EHTMLWidgets%20is%20already%20defined%2C%20then%20use%20it%3B%20otherwise%20create%20a%0A%20%20%2F%2F%20new%20object%2E%20This%20allows%20preceding%20code%20to%20set%20options%20that%20affect%20the%0A%20%20%2F%2F%20initialization%20process%20%28though%20none%20currently%20exist%29%2E%0A%20%20window%2EHTMLWidgets%20%3D%20window%2EHTMLWidgets%20%7C%7C%20%7B%7D%3B%0A%20%20%0A%20%20%2F%2F%20See%20if%20we%27re%20running%20in%20a%20viewer%20pane%2E%20If%20not%2C%20we%27re%20in%20a%20web%20browser%2E%0A%20%20var%20viewerMode%20%3D%20window%2EHTMLWidgets%2EviewerMode%20%3D%0A%20%20%20%20%20%20%2F%5Cbviewer%5Fpane%3D1%5Cb%2F%2Etest%28window%2Elocation%29%3B%0A%0A%20%20%2F%2F%20See%20if%20we%27re%20running%20in%20Shiny%20mode%2E%20If%20not%2C%20it%27s%20a%20static%20document%2E%0A%20%20%2F%2F%20Note%20that%20static%20widgets%20can%20appear%20in%20both%20Shiny%20and%20st
View group_mean.R
#' Group Mean
#'
#' @examples
#' iris %>%
#' group_mean(Species, Petal.Length)
group_mean <- function(tbl, group_var, summary_var){
tbl %>%
group_by({{ group_var }}) %>%
summarize(
{{ summary_var }} := mean({{ summary_var }})
@ramnathv
ramnathv / index.Rmd
Last active Apr 24, 2019
Two Column Layout
View index.Rmd
---
title : Two Column Layout
author : Ramnath Vaidyanathan
framework : io2012 # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js # {highlight.js, prettify, highlight}
hitheme : solarized_light #
--- .RAW
## Two Column Layout
@ramnathv
ramnathv / Makefile
Last active Mar 25, 2019
Rmd to IPython Notebook and HTML
View Makefile
all: example.ipynb example.html
example.md: example.Rmd
./knit
example.ipynb: example.md
notedown example.md | sed '/%%r/d' > example.ipynb
example.html: example.Rmd
R -e "knitr::knit2html('example.Rmd')"
You can’t perform that action at this time.