Skip to content

Instantly share code, notes, and snippets.

View alienzj's full-sized avatar
🦀
MAGs lives matter

alienzj

🦀
MAGs lives matter
View GitHub Profile
@trinker
trinker / dumbellplot
Created April 16, 2017 17:27
Dumbell plot
dat <- data.frame(
freq = c(37, 88, 47, 89, 28, 68, 65, 98, 68, 86, 50, 87, 59, 82, 45, 65, 52, 32, 59, 47, 68, 78, 39, 31, 64, 68)
)
dat[["sector"]] <- rep(c("U.S. adults", "AAAS scientist"), nrow(dat)/2)
field <- c("Biomedical sciences", "Climate, energy, space sciences")
dat[["field"]] <- factor(rep(field, c(10, 16)), levels=field)
items <- c(
@hkmix
hkmix / pi_approx.cc
Last active April 29, 2017 01:19
Pi Day Challenge entry
#include <iostream>
#include <iomanip>
#include <random>
#include <string>
#include <thread>
#include <vector>
using std::size_t;
class Point {
snippet gg
ggplot(${1:data}, aes(${2:aes})) +
geom_${3:geom}()
snippet shiny
library(shiny)
ui <- fluidPage(
${1:ui}
)
@microcai
microcai / smart_timer.hpp
Last active April 16, 2017 08:01
新的 smart_timer 来啦!
#pragma once
#include <tuple>
#include <mutex>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
@trinker
trinker / ggplot2_labels_on_top.txt
Created January 13, 2017 14:55
ggplot2 labels on top
library(reshape2)
library(ggplot2)
data(mtcars)
dat <- with(mtcars, data.frame(mpg, cyl, disp, hp, wt, gear))
cor.matrix <- round(cor(dat, use = "pairwise.complete.obs", method = "spearman"), digits = 2)
diag(cor.matrix)<-NA
cor.dat <- melt(cor.matrix)
cor.dat <- data.frame(cor.dat)
@whophil
whophil / jupyter.service
Last active October 8, 2024 00:42 — forked from doowon/jupyter_systemd
A systemd script for running a Jupyter notebook server.
# After Ubuntu 16.04, Systemd becomes the default.
# It is simpler than https://gist.github.com/Doowon/38910829898a6624ce4ed554f082c4dd
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config=/home/phil/.jupyter/jupyter_notebook_config.py
@scchan
scchan / saxpy.cpp
Last active October 12, 2018 16:11
hcc saxpy example
#include <random>
#include <algorithm>
#include <iostream>
#include <cmath>
// header file for the hc API
#include <hc.hpp>
#define N (1024 * 500)
@conormm
conormm / r-to-python-data-wrangling-basics.md
Last active May 3, 2025 19:21
R to Python: Data wrangling with dplyr and pandas

R to python data wrangling snippets

The dplyr package in R makes data wrangling significantly easier. The beauty of dplyr is that, by design, the options available are limited. Specifically, a set of key verbs form the core of the package. Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package).

dplyr is organised around six key verbs:

@52cik
52cik / npm.taobao.sh
Last active May 6, 2025 07:01
npm 淘宝镜像配置
npm set registry https://r.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
npm set ELECTRON_MIRROR https://cdn.npm.taobao.org/dist/electron/ # electron 二进制包镜像
npm set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer 二进制包镜像
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver 二进制包镜像