Skip to content

Instantly share code, notes, and snippets.

View haozhu233's full-sized avatar
🧙

Hao Zhu haozhu233

🧙
View GitHub Profile
@jthomasmock
jthomasmock / qbr-table.R
Last active September 14, 2022 23:20
Quick table for QBR
library(tidyverse)
library(glue)
library(gt)
library(kableExtra)
library(espnscrapeR)
# use espnscrapeR to get NFL standings + QBR ratings
nfl_qbr <- get_nfl_qbr(2020)
nfl_standings <- get_nfl_standings(2020)
@yanqd0
yanqd0 / dl_requests_tqdm.py
Last active September 18, 2024 22:39
Python requests download file with a tqdm progress bar
import requests
from tqdm import tqdm
def download(url: str, fname: str, chunk_size=1024):
resp = requests.get(url, stream=True)
total = int(resp.headers.get('content-length', 0))
with open(fname, 'wb') as file, tqdm(
desc=fname,
total=total,
@michaelchughes
michaelchughes / README.md
Last active May 30, 2024 01:16
Fixes for GLIBC errors when installing tensorflow or pytorch on older Red Hat or CentOS cluster environments

Goal

Install working tensorflow or pytorch via standard conda environment workflow.

Basic Setup : Install pytorch in a fresh conda environment

The recommended conda-based install process works smoothly:

$ # Create a fresh environment
@traversc
traversc / fastAUC.r
Last active April 12, 2021 09:31
Fast AUC and ROC calculations in R
fastROC <- function(probs, class) {
class_sorted <- class[order(probs, decreasing=T)]
TPR <- cumsum(class_sorted) / sum(class)
FPR <- cumsum(class_sorted == 0) / sum(class == 0)
return(list(tpr=TPR, fpr=FPR))
}
# Helpful function adapted from: https://stat.ethz.ch/pipermail/r-help/2005-September/079872.html
fastAUC <- function(probs, class) {
x <- probs
@omimo
omimo / index.html
Last active October 18, 2018 01:06
<html>
<head>
<title>
[Visualizing Movement Data with D3.js]
</title>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://omid.al/Mova-Viz/MovaViz-v0.1.2.js"></script>
<style>
* {
box-sizing: border-box
@jalapic
jalapic / serialinput.R
Created July 14, 2016 17:28
Arduino data to R
library(serial)
rm(list = ls()) # clear environment
graphics.off() # close all graphic windows
### establish a serial connection
con <- serialConnection(name = "get_temps",
@darcyliu
darcyliu / install_spark_centos7.sh
Created April 1, 2016 09:40
Install Spark on CentOS 7
#!/bin/bash
# Install Spark on CentOS 7
yum install java -y
java -version
yum install wget -y
wget http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz
tar xvf scala-2.11.7.tgz
sudo mv scala-2.11.7 /usr/lib
sudo ln -s /usr/lib/scala-2.11.7 /usr/lib/scala
@yihui
yihui / htmltools-deps.Rmd
Created March 31, 2015 02:33
A minimal example of HTML dependencies
---
title: HTML Dependencies
output: html_document
---
This example explains how HTML dependencies work in **htmltools**. Sometimes an HTML fragment may have additional dependencies to work correctly, such as JavaScript and/or CSS files. In R Markdown documents, you have to let **rmarkdown** know these dependencies, so they can be added to the HTML header when the document is rendered through Pandoc.
Another thing that you need to pay attention is you have to "protect" your HTML output so that Pandoc does not touch it, e.g. when you have four leading spaces, Pandoc may think this line is supposed to be a `<pre>` block whereas you only meant to indent the line for cosmetic purposes. In this case, the function `htmltools::htmlPreserve()` will be _automatically_ applied to your HTML content in R Markdown if the content is generated from `htmltools::tags` or wrapped in `htmltools::HTML()`.
Now we use a random CSS file in the **knitr** package to illustrate how dependencies work. The goal here is to generate a
@yihui
yihui / README.md
Last active March 15, 2017 18:35
A Shiny app based on annyang that responds to voice input
@stevejackson
stevejackson / gist:1429696
Created December 4, 2011 09:17
Chinese pinyin syllable list
'a'
'ba'
'pa'
'ma'
'fa'
'da'
'ta'
'na'
'la'
'ga'