Skip to content

Instantly share code, notes, and snippets.

View Jianghao's full-sized avatar

Jianghao Wang Jianghao

View GitHub Profile
@Jianghao
Jianghao / LanProxy.md
Last active November 29, 2021 14:07
Lanproxy
@Jianghao
Jianghao / linode_sentiment_env.sh
Last active December 29, 2019 00:54
linode sentiment envrionment.sh
# wang**
ssh root@45.79.186.179
# add a user
sudo adduser sentiment
cd ../home/
sudo chmod 700 sentiment/
# Add the new user to the sudo group
usermod -aG sudo sentiment
# test
@Jianghao
Jianghao / theme_sentiment.R
Last active June 21, 2021 14:43
Theme for sentiment temperature
# Ref: https://rpubs.com/Koundy/71792
library(ggplot2)
library(gridExtra)
library(ggsci)
library(extrafont)
library(grid)
library(ggthemes)
library(ggpmisc)
# method 1
Sys.setlocale("LC_TIME", "C")
options(encoding = "gbk")
shp <- maptools::readShapePoly("**.shp")
proj4string <- CRS("+proj=longlat +datum=WGS84")
proj4string(shp) <- proj4string
# method 2
library(rgdal)
shp <- readOGR("**.shp", layer = "**", use_iconv = TRUE, encoding = "UTF-8")
df <- mutate(df, !!paste0("days_", d) := number)
@Jianghao
Jianghao / maxiang.yaml
Created October 27, 2017 03:02
yaml of maxiang
---
title: "Title"
author: "Jianghao Wang"
date: "`r Sys.Date()`"
output:
html_document:
toc: true
toc_float: true
collapsed: false
smooth_scroll: false
@Jianghao
Jianghao / prettydoc.yaml
Last active October 27, 2017 03:01
yaml of prettydoc
---
title: "Title"
author: "Jianghao Wang"
date: "`r Sys.Date()`"
output:
prettydoc::html_pretty:
theme: architect # architect cayman leonids tactile hpstr
highlight: github # vignette github
toc: true
toc_depth: 2
library(foreach)
library(doSNOW)
cl <- makeCluster(20)
registerDoSNOW(cl)
start.time <- Sys.time()
pb <- txtProgressBar(max = length(users.sub), style = 3)
progress <- function(n) setTxtProgressBar(pb, n)
opts <- list(progress = progress)
fddf <- foreach(u = 1:length(users.sub), .options.snow = opts) %dopar% {
access_token <- access_tokens[u %% 10 + 1]
setCurl <- function(uid=1404376560, access_token="2.00X_6UXFwXYrFD089496f37cRKW2TB"){
prefix <- "curl \".....................&request_data="
suffix <- "&_t=0\" --compressed --connect-timeout 5 -m 10"
url <- paste0(prefix, "uid%3D", uid, "%26access_token%3D", access_token, suffix)
return(as.character(url))
}
@Jianghao
Jianghao / theme_Publication.R
Last active August 30, 2018 03:55
theme for Publication
# Ref: https://rpubs.com/Koundy/71792
library(ggplot2)
library(gridExtra)
library(ggsci)
library(extrafont)
library(grid)
library(ggthemes)
library(ggpmisc)