Skip to content

Instantly share code, notes, and snippets.

View jackwasey's full-sized avatar

Jack Wasey jackwasey

View GitHub Profile
@jackwasey
jackwasey / testCoverage.R
Last active August 29, 2015 14:02
test coverage for an R package
#' @title list all functions in a package
#' @param pkg character string containing package name
#' @return character vector of functions in given package
#' @export
lsf <- function(pkg) {
envirName <- paste("package", pkg, sep = ":")
everything <- ls(pos = envirName, all.names = TRUE)
funcs <- c()
@jackwasey
jackwasey / gist:7beb8fdc5449cf760aac
Created January 6, 2015 13:21
lintr allowing camel case
lintr::lint_package(linters = lintr::default_linters[names(lintr::default_linters) != "object_camel_case_linter"])
//' @title Sort using STL
//' @description if compiler flags and standard library support is available
//' (only tested on glibc), OpenMP, then this will use a parallel sort
//' algorithm which is significantly faster. It doesn't however deal with NA
//' values. TODO: handle NA values.
//' @param x vector of strings. In the current implementation, NA is completely
//' ignored, so is probably converted to "NA"
//' @examples
//' \dontrun{
@jackwasey
jackwasey / fastmatch-demo.r
Last active May 25, 2018 20:28
benchmark fastmatch for string comparison in R
library(fastmatch)
library(microbenchmark)
WORDS <- read.table("https://dotnetperls-controls.googlecode.com/files/enable1.txt",
stringsAsFactors = FALSE)[[1]]
words_factor <- as.factor(WORDS)
# generate 100 sentences of between 5 and 15 words:
SENTENCES <- lapply(c(1:100), sample, x = WORDS, size = sample(c(5:15), size = 1))

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@jackwasey
jackwasey / ubuntu-vnc-activate-remote.sh
Created June 19, 2020 21:36 — forked from samba/ubuntu-vnc-activate-remote.sh
Activate VNC support in Ubuntu, from command-line (for active sessions)
#!/bin/sh
# This assumes you have access to the system via SSH already, and need
# remote VNC access as the same user, and you want only the primary display.
export DISPLAY=:0
# Encoded password with http://www.motobit.com/util/base64-decoder-encoder.asp
export VNC_PASSWORD="dm5jX3Bhc3N3b3JkNzE=" # vnc_password71
export VNC_PASSWORD="dm5jX3Bhc3M=" # vnc_password (a character limit is enforced?)
# Sadly many common VNC clients don't support encryption.
@jackwasey
jackwasey / macos-tmux-256color.md
Created September 16, 2020 19:08 — forked from bbqtd/macos-tmux-256color.md
Installing tmux-256color for macOS

Installing tmux-256color for macOS

  • macOS 10.15.5
  • tmux 3.1b

macOS has ncurses version 5.7 which does not ship the terminfo description for tmux. There're two ways that can help you to solve this problem.

The Fast Blazing Solution

Instead of tmux-256color, use screen-256color which comes with system. Place this command into ~/.tmux.conf or ~/.config/tmux/tmux.conf(for version 3.1 and later):

@jackwasey
jackwasey / 256 colors.md
Created September 16, 2020 23:41 — forked from limingjie/256 colors.md
256 colors in putty, tmux/screen and vim

#256 colors in putty, tmux/screen and vim There is a detailed answer on stackoverflow. If you are looking for a short one, here it is.

  • putty

    Set Connection -> Data -> Terminal-type string to xterm-256color

  • tmux

Add this line to ~/.tmux.conf

@jackwasey
jackwasey / Installation.md
Created September 27, 2020 18:35 — forked from albertbori/Installation.md
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges
@jackwasey
jackwasey / latency.txt
Created October 4, 2020 19:36 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD