Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jcheng5
jcheng5 / create_forked_task.R
Last active August 3, 2022 17:11
Concurrent, forked, cancellable tasks in Shiny
library(shiny)
# Also uses parallel, shinyjs, tools
# Create a long-running task, executed in a forked process. (Doesn't work on Windows)
#
# The return value is a promise-like object with three
# methods:
# - completed(): FALSE initially, then TRUE if the task succeeds,
# fails, or is cancelled. Reactive, so when the state changes
# any reactive readers will invalidate.
@josephholsten
josephholsten / sizeup.lua
Last active June 4, 2022 11:41
SizeUp in Hammerspoon
-- === sizeup ===
--
-- SizeUp emulation for hammerspoon
--
-- To use, you can tweak the key bindings and the margins
local sizeup = { }
--------------
-- Bindings --
;; depends on [org.imgscalr/imgscalr-lib "4.2"]
(ns XXX.image
(:refer-clojure :exclude [read])
(:require [clojure.java.io :as io])
(:import [org.imgscalr Scalr Scalr$Method Scalr$Mode]
[java.awt Image]
[java.awt.image RenderedImage BufferedImageOp]
[javax.imageio ImageIO ImageWriter ImageWriteParam IIOImage]
@jcheng5
jcheng5 / README.md
Last active March 10, 2021 16:02
Installing R-devel on Solaris 10 VM

As far as CRAN is concerned, there are two flavors of R on Solaris: one that is built using the Solaris Studio compiler, and one that is built using the GNU/gcc toolchain. The latter is far more up-to-date, but if your package requires it, then your DESCRIPTION file must declare that with the line SystemRequirements: GNU make.

These instructions are for configuring, building, and installing R-devel using the GNU/gcc toolchain (only).

You'll need VMWare Fusion on Mac, or VMWare Workstation (?) on Windows/Linux.

Get Solaris VM

Download the Solaris VM provided by Jeroen Ooms: https://github.com/jeroen/solarisvm

@pandeiro
pandeiro / README.md
Last active June 2, 2020 08:02
Example of a simple webapp written as a single file

Instructions

  1. Get Boot
  2. Copy the above file to $HOME/app.boot
  3. $ chmod a+x $HOME/app.boot
  4. $ cd && ./app.boot
@jrk
jrk / llvmlisp.cpp
Created November 5, 2009 08:26
Toy LLVM Lisp, originally from http://paste.lisp.org/display/74068
/* A Trivial LLVM LISP
* Copyright (C) 2008-2009 David Robillard <dave@drobilla.net>
*
* Parts from the Kaleidoscope tutorial <http://llvm.org/docs/tutorial/>
* by Chris Lattner and Erick Tryzelaar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@wch
wch / remote_repl.R
Last active August 7, 2019 17:42
Remote R REPL app with httpuv
library(httpuv)
PORT <- 7000
app <- list(
call = function(req) {
page(req)
},
onWSOpen = function(ws) {
ws$onMessage(function(binary, message) {
@tylerlittlefield
tylerlittlefield / pkg_size.R
Last active February 12, 2019 21:56
Check the size of an R package or project
# Check Package Size
#
# Thanks to Alan Dipert for the help with this one.
#
# This function is used to calculate size of package and report size in
# README.md
pkg_size <- function(package) {
root <- find.package(package)
rel_paths <- list.files(root, all.files = TRUE, recursive = TRUE)
abs_paths <- file.path(root, rel_paths)
@wch
wch / proxy.R
Last active February 22, 2018 21:14
Quick and dirty HTTP proxy in R
library(curl)
library(httpuv)
req_rook_to_curl <- function(req, host) {
# browser()
# Rename headers. Example: HTTP_CACHE_CONTROL => Cache-Control
r <- as.list(req)
# Uncomment to print out request headers
cat("== Original ==\n")
@bcachet
bcachet / graph.fs
Last active August 11, 2017 21:00
Kahn sorting in F#
namespace Graph
// Implementation based on https://gist.github.com/alandipert/1263783
module Map =
let keys map =
map |> Map.toSeq |> Seq.map fst |> Set.ofSeq
let values map =
map |> Map.toSeq |> Seq.map snd |> Set.ofSeq