This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XVFB=/usr/bin/Xvfb | |
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset" | |
PIDFILE=/var/run/xvfb.pid | |
case "$1" in | |
start) | |
echo -n "Starting virtual X frame buffer: Xvfb" | |
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS | |
echo "." | |
;; | |
stop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: My Filter | |
*/ | |
// Exit if accessed directly | |
if ( !defined('ABSPATH')) exit; | |
# to exclude the category testing | |
function exclude_category($query) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# it is a tutorial to generate permuations/combinations using `partitions`, `gtools` and `multicool`. | |
# mainly for reference only, consider the package `iterpc` in practice. | |
library(partitions) | |
library(gtools) | |
library(multicool) | |
1) combinations: without replacement: distinct items | |
n = 5; r = 3 | |
combn(n, r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git-branch-name { | |
echo `git symbolic-ref HEAD --short 2> /dev/null || (git branch | sed -n 's/\* (*\([^)]*\))*/\1/p')` | |
} | |
function git-dirty { | |
[[ `wc -l <<< "$1" ` -eq 1 ]] || echo "*" | |
} | |
function git-unpushed { | |
if [[ "$1" =~ ("behind "([[:digit:]]*)) ]] | |
then | |
echo -n "-${BASH_REMATCH[2]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total <- 20 | |
# create progress bar | |
pb <- txtProgressBar(min = 0, max = total, style = 3) | |
for(i in 1:total){ | |
Sys.sleep(0.1) | |
# update progress bar | |
setTxtProgressBar(pb, i) | |
} | |
close(pb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
importCpp <- function(infile, output_dir="lib", rebuild=FALSE){ | |
output_dir = ifelse(is.null(output_dir), ".", output_dir) | |
dir.create(output_dir, recursive=T, showWarnings=FALSE) | |
outfile = file.path(output_dir, paste0(infile, ".R")) | |
if (!file.exists(outfile) || file.info(infile)$mtime > file.info(outfile)$mtime || rebuild){ | |
Rcpp::sourceCpp(infile, rebuild=rebuild) | |
context = .Call("sourceCppContext", PACKAGE = "Rcpp", | |
normalizePath(infile, winslash = "/"), code=NULL, 0L, .Platform) | |
scriptfile = file.path(context$buildDirectory, context$rSourceFilename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nbformat | |
import os | |
release_dir = "/home/randy3k/nbgrader/sts437/release" | |
assignment = "sts437-hw1" | |
assignment_dir = os.path.join(release_dir, assignment) | |
problems = [f for f in os.listdir(assignment_dir) if os.path.splitext(f)[1] == ".ipynb"] | |
users = [d for d in os.listdir("/home") if os.path.isdir("/home/{}".format(d))] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
topic_rd <- function(pkg_name, topic) { | |
rd_file <- as.character(help((topic), (pkg_name))) | |
utils:::.getHelpFile(rd_file) | |
} | |
topic_section <- function(rd, section) { | |
ret <- rd[sapply(rd, function(x) attr(x, "Rd_tag") == paste0("\\", section))] | |
if (length(ret) == 0) { | |
list() | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user www-data; | |
worker_processes auto; | |
pid /run/nginx.pid; | |
events { | |
worker_connections 768; | |
# multi_accept on; | |
} | |
http { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
trap 'kill -TERM $PID' INT TERM EXIT | |
cd /home/randy3k/nbviewer | |
python3 -m nbviewer --port=8080 --localfiles=/home/randy3k/ & | |
PID=$! | |
wait $PID |
OlderNewer