Skip to content

Instantly share code, notes, and snippets.

@rexarski
rexarski / data
Created September 1, 2020 06:31
boomsday-packopening.R
| common | rare | epic | legendary | g.common | g.rare | g.epic | g.legendary |
| ---- | ---- | ---- | ---- | -------- | -------- | -------- | -------- |
| 4 | 1 | | | | | | |
| 4 | 1 | | | | | | |
| 3 | 2 | | | | | | |
| 4 | 1 | | | | | | |
| 4 | 1 | | | | | | |
| 3 | | 1 | 1 | | | | |
| 4 | 1 | | | | | | |
| 4 | 1 | | | | | | |
@rexarski
rexarski / dejong.R
Created August 29, 2020 12:02
draw trajectory of peter de jong attractors with ggplot2
library(Rcpp)
library(ggplot2)
library(dplyr)
opt = theme(legend.position = "none",
panel.background = element_rect(fill="white"),
axis.ticks = element_blank(),
panel.grid = element_blank(),
axis.title = element_blank(),
axis.text = element_blank())
@rexarski
rexarski / hugo-build.sh
Created August 13, 2020 00:42
Custom hugo site building (testing) script.
# first need to `chmod a+rx hugo-build.sh`
# inside a root directory:
rm -rf public
hugo --verbose
hugo server --gc -D --verbose --watch
# inside a theme, aim to serve an exampleSite:
# cd exampleSite
# hugo server --gc -D -t ../..
@rexarski
rexarski / animated-line-chart.R
Created June 13, 2020 08:37
A piece of R Script used to produce an animated line chart.
library(tidyverse)
library(gganimate)
library(ggthemes)
df <- read_csv("pd.csv") %>%
select(-c("Day")) %>%
rename("Email" = `Email Inbox`,
"RIL" = `Reeder Read it Later`,
"Podcasts" = `Podcasts Episodes`,
"YouTube" = `YouTube Watch Later`) %>%
@rexarski
rexarski / my_weather_data.json
Last active June 12, 2020 05:35
my_weather_data.json
[{"time": 1514782800, "summary": "Clear throughout the day.", "icon": "clear-day", "sunriseTime": 1514809280, "sunsetTime": 1514842810, "moonPhase": 0.48, "precipIntensity": 0, "precipIntensityMax": 0, "precipProbability": 0, "temperatureHigh": 18.39, "temperatureHighTime": 1514836800, "temperatureLow": 12.23, "temperatureLowTime": 1514894400, "apparentTemperatureHigh": 17.29, "apparentTemperatureHighTime": 1514844000, "apparentTemperatureLow": 4.51, "apparentTemperatureLowTime": 1514887200, "dewPoint": -1.67, "humidity": 0.54, "pressure": 1028.26, "windSpeed": 4.16, "windGust": 13.98, "windGustTime": 1514829600, "windBearing": 309, "cloudCover": 0.02, "uvIndex": 2, "uvIndexTime": 1514822400, "visibility": 10, "temperatureMin": 6.17, "temperatureMinTime": 1514808000, "temperatureMax": 18.39, "temperatureMaxTime": 1514836800, "apparentTemperatureMin": -2.19, "apparentTemperatureMinTime": 1514808000, "apparentTemperatureMax": 17.29, "apparentTemperatureMaxTime": 1514844000, "date": "2018-01-01"}, {"time": 15148
@rexarski
rexarski / racing-bar.R
Created June 7, 2020 12:28
Use ggplot2 and gganimate to implement a simple racing barplot.
library(tidyverse)
library(gganimate)
library(janitor)
library(gapminder)
df <- gapminder %>%
janitor::clean_names() %>%
group_by(year) %>%
mutate(rank = rank(-life_exp),
Value_rel = life_exp/life_exp[rank==1],
@rexarski
rexarski / non-ascii.R
Created December 6, 2019 09:52 — forked from nassimhaddad/non-ascii.R
remove non-ascii characters
# remove non-ascii characters
df$text <- gsub("[^\x20-\x7E]", "", df$text)
@rexarski
rexarski / cloudSettings
Last active November 19, 2020 03:01
my-visual-studio-code-settings
{"lastUpload":"2020-11-19T03:01:40.792Z","extensionVersion":"v3.4.3"}
@rexarski
rexarski / redpocket.py
Created July 5, 2019 03:35
Emulate WeChat redpocket 模拟微信红包
import random
legit = 0
while legit != 1:
x = eval(input("How much money do you like to put in the red pocket? "))
y = eval(input("How many red pockets would you like to send? "))
if x < y * 0.01:
print('Not enough money to send, sorry!')
@rexarski
rexarski / bayes-premier-league.R
Created April 20, 2019 13:28
A Bayesian hierrchical model for the prediction of Premier League results.
library(rjags)
library(coda)
library(mcmcplots)
# 2015-2016 Premier League result table
# data source: https://github.com/vijinho/epl_mysql_db/blob/master/csv/E0-2015.csv
dat <- read.csv("E0-2015.csv")
head(dat)
dat <- dat[,3:6]