Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/Rscript --vanilla
# from https://github.com/muuankarski/blog
# run ./knitpages.R to update all Rmd files that need to be updated.
KnitPost <- function(input, outfile) {
require(knitr);
opts_knit$set(base.dir = "content")
opts_knit$set(base.url = "/")
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.duckdns.randyimac</string>
<key>ProgramArguments</key>
<array>
<string>curl</string>
<string>-w</string>
macro compileinfo(file_name, command)
quote
open($(esc(file_name)), "w") do io
ccall(:jl_dump_compiles, Void, (Ptr{Void},), io.handle)
try
$command
finally
close(io)
ccall(:jl_dump_compiles, Void, (Ptr{Void},), C_NULL)
end
@randy3k
randy3k / open-pantheon.py
Last active June 20, 2021 08:30
open pantheon-terminal in Ubuntu nautilus
# -*- coding: UTF-8 -*-
# From https://github.com/gnunn1/tilix/blob/3f0a3d37f10f6ecfce30deca41636bb13020c2b3/data/nautilus/open-tilix.py
# Example modified for Pantheon Terminal
# Shortcuts Provider was inspired by captain nemo extension
from gettext import gettext, textdomain
from subprocess import PIPE, call
from urllib import unquote
from urlparse import urlparse
@randy3k
randy3k / cie94.py
Created August 13, 2017 19:21
color metric
# https://gist.github.com/fikr4n/368f2f2070e0f9a15fb4
from math import sqrt
def _square(x):
return x * x
def rgb(x):
@randy3k
randy3k / homebrew.mxcl.syncthing.plist
Created September 19, 2017 22:07
syncthing plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.syncthing</string>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>/Users/Randy</string>
@randy3k
randy3k / cubature.cpp
Created November 19, 2017 03:49
Rcpp: multidimensional integration via sourceCpp and cubature
// [[Rcpp::depends(cubature)]]
// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
#include <exp_cubature.h>
using namespace Rcpp;
const double log2pi = std::log(2.0 * M_PI);
arma::vec mu;
@randy3k
randy3k / nb_available.c
Created January 28, 2018 05:36
use PeekNamedPipe to check bytes available
#include <windows.h>
#include <stdio.h>
#include <stdbool.h>
#define BUFSIZE 1024
int main(int ac, char** av) {
HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
DWORD rd;
@randy3k
randy3k / plugin.py
Last active April 26, 2018 03:44
LanguageHandler with custom Notification class
from LSP.plugin.core.handlers import LanguageHandler
from LSP.plugin.core.settings import ClientConfig
from LSP.plugin.core.rpc import Notification
import os
class LspClangRcppPlugin(LanguageHandler):
name = "clangd-rcpp"
@randy3k
randy3k / wc.py
Created May 18, 2018 05:37
python ctypes wctomb and mbtowc
import rapi
rapi.start()
# let R to set the locale
import ctypes
from ctypes import wintypes
MultiByteToWideChar = ctypes.windll.kernel32.MultiByteToWideChar
MultiByteToWideChar.argtypes = [wintypes.UINT, wintypes.DWORD,
wintypes.LPCSTR, ctypes.c_int,