Skip to content

Instantly share code, notes, and snippets.

@krlmlr
krlmlr / rowwise.Rmd
Last active August 4, 2016 18:50 — forked from wch/rowwise.Rmd
---
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 = "#>")
```
template <class Fun>
class ScopeGuard {
Fun f_;
bool active_;
public:
ScopeGuard(Fun f)
: f_(std::move(f))
, active_(true) {
}
~ScopeGuard() { if (active_) f_(); }
$ git branch -r --merged origin/master |
grep -v '>' |
grep -v master |
cut -d "/" -f 2- |
xargs git push origin --delete
#!/bin/sh
set -o errexit
set -o nounset
set -o noclobber
name=predis-sm
R --no-save --restore <<'EOF'
library(knitr)
@krlmlr
krlmlr / .gitignore
Last active December 27, 2015 00:09 — forked from jpritikin/predis-sm.Rnw
/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
@krlmlr
krlmlr / .screenrc-xpra
Last active December 7, 2016 16:50 — forked from anonymous/-
screen -t xpra 9 xpra start $DISPLAY --no-daemon
@krlmlr
krlmlr / xpra-attach-ssh
Last active December 20, 2015 16:59 — forked from anonymous/ivt-xpra
#!/bin/sh
ATTACH_TO=ssh:$1
echo -n "\033]0;xpra $1\007"
echo "Attaching to $ATTACH_TO..." >> /dev/stderr
xpra attach $ATTACH_TO
@krlmlr
krlmlr / xpra.conf
Last active December 20, 2015 16:59 — forked from anonymous/xpra.conf
#
# 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
@krlmlr
krlmlr / .autoscreen
Last active December 17, 2015 05:59 — forked from anonymous/.autoscreen
# 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
@krlmlr
krlmlr / cut2.R
Last active December 11, 2015 11:28 — forked from mrdwab/cut2.R
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))