Skip to content

Instantly share code, notes, and snippets.

View kaz-yos's full-sized avatar
💭
I may be slow to respond.

Kazuki Yoshida kaz-yos

💭
I may be slow to respond.
View GitHub Profile
@halpo
halpo / Makefile
Created November 17, 2011 20:07
Makefile for R Packages
# Makefile for generating R packages.
# 2011 Andrew Redd
#
# Assumes Makefile is in a folder where package contents are in a subfolder pkg.
# Roxygen uses the roxygen2 package, and will run automatically on check and all.
PKG_VERSION=$(shell grep -i ^version pkg/DESCRIPTION | cut -d : -d \ -f 2)
PKG_NAME=$(shell grep -i ^package pkg/DESCRIPTION | cut -d : -d \ -f 2)
R_FILES := $(wildcard pkg/R/*.R)
@stephenLee
stephenLee / argmin_max.tex
Created December 15, 2012 08:44
latex argmax and argmin
\DeclareMathOperator*{\argmax}{arg\,max} % in your preamble
\DeclareMathOperator*{\argmin}{arg\,min} % in your preamble
\argmax_{...} % in your formula
\argmin_{...} % in your formula
@igjit
igjit / lispr.R
Last active November 22, 2016 03:36
Scheme Interpreter in R (more R-ish implementation of "lisp.R")
## Scheme Interpreter in R
## (more R-ish implementation of "lisp.R")
addGlobals <- function(env) {
procs <- list("+" = sum,
"*" = prod,
"-" = function(...) Reduce(`-`, list(...)),
"/" = function(...) Reduce(`/`, list(...)),
"=" = `==`,
"eq?" = `==`,
@even4void
even4void / .emacs
Last active August 21, 2021 08:47
Basic setup to use Gmail from Emacs using a combination of mu, mu4e and offlineimap
(require 'offlineimap)
(add-to-list 'load-path "~/.emacs.d/lib/mu4e")
(require 'mu4e)
(require 'mu4e-maildirs-extension)
(mu4e-maildirs-extension)
(setq mu4e-drafts-folder "/drafts"
mu4e-sent-folder "/sent"
mu4e-trash-folder "/trash")
(setq mu4e-maildir-shortcuts
@DASpringate
DASpringate / cond.R
Last active May 19, 2017 15:24
A simple R implementation of `cond` from Lisp. Allows for arbitrary numbers of conditionals without nested if statements
#' R implementation of `cond` from Lisp
#' allows for arbitrary numbers of conditionals without ugly nested if statements
#' conditionals are entered as pairs of expressions (clauses),
#' first the expression to be evaluated and second the return value if the expression is true
#' @param ... an even number of expressions as pairs (see example)
#' @param true the `else` expression (Taken from the Lisp (T resultN) see http://www.cis.upenn.edu/~matuszek/LispText/lisp-cond.html)
#' @return The paired value of the first true conditional expression or the value of true
#' @examples
#' x <- runif(1)
#' cond(x < 0.2, "lower tail",
@jwreagor
jwreagor / EmacsKeyBinding.dict
Created March 20, 2014 18:41
Global Emacs Key Bindings for OS X
{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
* BEWARE:
* This file uses the Option key as a meta key. This has the side-effect
* of overriding Mac OS keybindings for the option key, which generally
@magnusbae
magnusbae / git-stop-tracking-remote-branch.md
Created April 8, 2014 20:05
How to make Git stop track a remote branch without deleting the remote branch.

You don't have to delete your local branch.

Simply delete your remote tracking branch:

git branch -d -r origin/<remote branch name> (This will not delete the branch on the remote repo!)

See "Having a hard time understanding git-fetch"

there's no such concept of local tracking branches, only remote tracking branches.

@john2x
john2x / 00_destructuring.md
Last active June 6, 2024 13:40
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@eclarke
eclarke / lab-notebook.el
Created October 21, 2014 23:26
Minor mode and functions for a lab notebook in emacs
(defun ensure-in-vc-or-checkin ()
(interactive)
(if (file-exists-p (format "%s" (buffer-file-name)))
(progn (vc-next-action nil) (message "Committed"))
(ding) (message "File not checked in.")))
(defun export-bibtex ()
"Exports Papers library using a custom applescript."
(interactive)
(message "Exporting papers library...")
@ha2ne2
ha2ne2 / foldx.lisp
Last active August 29, 2015 14:19
(defun foldr (f lst)
(if (null (cdr lst)) (car lst)
(funcall f (car lst) (foldr f (cdr lst)))))
(defun foldl (f lst)
(if (null (cdr lst)) (car lst)
(funcall f (foldl f (butlast lst)) (car (last lst)))))
(defun foldr-tail (f a lst)
(if (null lst) a