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
--- | |
title: "Applying a function over rows of a data frame" | |
author: "Winston Chang" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(collapse = TRUE, comment = "#>") | |
``` |
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
template <class Fun> | |
class ScopeGuard { | |
Fun f_; | |
bool active_; | |
public: | |
ScopeGuard(Fun f) | |
: f_(std::move(f)) | |
, active_(true) { | |
} | |
~ScopeGuard() { if (active_) f_(); } |
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
$ git branch -r --merged origin/master | | |
grep -v '>' | | |
grep -v master | | |
cut -d "/" -f 2- | | |
xargs git push origin --delete |
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
#!/bin/sh | |
set -o errexit | |
set -o nounset | |
set -o noclobber | |
name=predis-sm | |
R --no-save --restore <<'EOF' | |
library(knitr) |
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
/cache/ | |
/figure/ | |
/predis-sm.aux | |
/predis-sm.bcf | |
/predis-sm.blg | |
/predis-sm.log | |
/predis-sm.out | |
/predis-sm.pdf | |
/predis-sm.pyg | |
/predis-sm.run.xml |
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
screen -t xpra 9 xpra start $DISPLAY --no-daemon |
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
#!/bin/sh | |
ATTACH_TO=ssh:$1 | |
echo -n "\033]0;xpra $1\007" | |
echo "Attaching to $ATTACH_TO..." >> /dev/stderr | |
xpra attach $ATTACH_TO |
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
# | |
# This is the default configuration file for Xpra | |
# | |
# You can provide default values for most command line | |
# options here. | |
# All options can be overriden on the xpra command line. | |
# See the man page for details. | |
# Options which can be turned on or off will accept | |
# the following values: 1, 0, true, false, yes, no |
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
# Auto-screen invocation. see: http://taint.org/wk/RemoteLoginAutoScreen | |
# if we're coming from a remote SSH connection, in an interactive session | |
# then automatically put us into a screen(1) session. Only try once | |
# -- if $STARTED_SCREEN is set, don't try it again, to avoid looping | |
# if screen fails for some reason. | |
if [ "$TERM" != screen -a "$PS1" != "" -a "${STARTED_SCREEN:-x}" = x -a "${SSH_TTY:-x}" != x -a "$DISPLAY" == "" ] | |
then | |
echo "Auto-starting screen." | |
# Set the window title to HOSTNAME |
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
cut2 <- function (x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, | |
dig.lab = 3, ordered_result = FALSE, ...) | |
{ | |
if (!is.numeric(x)) | |
stop("'x' must be numeric") | |
if (length(breaks) == 1L) { | |
if (is.na(breaks) || breaks < 2L) | |
stop("invalid number of intervals") | |
nb <- as.integer(breaks + 1) | |
dx <- diff(rx <- range(x, na.rm = TRUE)) |
NewerOlder