Skip to content

Instantly share code, notes, and snippets.

@alphapapa
alphapapa / org-insert-structure-template-or-enclose-region.el
Last active May 11, 2016 20:25
Enclose a region in an org-mode block (e.g. #+BEGIN_SRC), or insert a structure template with completion
(defun org-read-structure-template ()
"Read org-mode structure template with completion. Returns template string."
(let* ((templates (map 'list 'second org-structure-template-alist))
(prefixes (map 'list (lambda (tp)
;; Get template and pre-whitespace prefix for completion
(reverse (s-match (rx (group
(1+ (not (any "\n" space))))
(1+ anything))
tp)))
templates))
@simonmichael
simonmichael / invoicing.journal
Created January 28, 2016 18:23
invoicing entries
; accrual basis accounting
2016/2/1 * (201602ab) ab client invoice
revenues:business:consulting:ab $-1000
assets:business:accounts receivable:ab $1000
; or,
; cash basis accounting doesn't include invoices, but use an unbalanced posting to track it anyway
2016/2/1 * (201602ab) ab client invoice
(assets:business:accounts receivable:ab) $1000
@ibartomeus
ibartomeus / PowerSevilla.R
Created October 16, 2015 14:55
Talk about power analtsis for the Sevilla R users meeting
#SevillaR talk
#The problem:
time <- c(2000:2015)
abundance <- rnorm(16, 150, 50) #poison??
plot(abundance ~ time, t = "l")
#can I detect a trend?
@tonyfischetti
tonyfischetti / elastic-net-regression-evaluation.R
Last active April 27, 2021 13:24
Code for my blog post "Kickin' it with elastic net regression"
#!/usr/bin/Rscript --vanilla
###########################################################
## ##
## elastic.R ##
## ##
## Author: Tony Fischetti ##
## tony.fischetti@gmail.com ##
## ##
###########################################################
@hrbrmstr
hrbrmstr / ghelp.R
Last active August 29, 2015 14:23
github search in rstudio viewer pane - source it and try it with ghelp("vapply")
ghelp <- function(topic, in_cran=TRUE) {
require(htmltools) # for getting HTML to the viewer
require(rvest) # for scraping & munging HTML
# github search URL base
base_ext_url <- "https://github.com/search?utf8=%%E2%%9C%%93&q=%s+extension%%3AR"
ext_url <- sprintf(base_ext_url, topic)
# if searching with user:cran (the default) add that to the URL
@fperez
fperez / nbmerge.py
Created June 23, 2015 01:04
Merge/concatenate multiple IPython notebooks into one.
#!/usr/bin/env python
# Note, updated version of
# https://github.com/ipython/ipython-in-depth/blob/master/tools/nbmerge.py
"""
usage:
python nbmerge.py A.ipynb B.ipynb C.ipynb > merged.ipynb
"""
import io
@cletusw
cletusw / .eslintrc
Last active February 29, 2024 20:24
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@ramnathv
ramnathv / Makefile
Last active September 2, 2022 14:31
Rmd to IPython Notebook and HTML
all: example.ipynb example.html
example.md: example.Rmd
./knit
example.ipynb: example.md
notedown example.md | sed '/%%r/d' > example.ipynb
example.html: example.Rmd
R -e "knitr::knit2html('example.Rmd')"
@hugorodgerbrown
hugorodgerbrown / md_to_rst.sh
Last active March 26, 2023 16:57
Shell script for converting a batch of *.md files into *.rst using pandoc.
# This script was created to convert a directory full
# of markdown files into rst equivalents. It uses
# pandoc to do the conversion.
#
# 1. Install pandoc from http://johnmacfarlane.net/pandoc/
# 2. Copy this script into the directory containing the .md files
# 3. Ensure that the script has execute permissions
# 4. Run the script
#
# By default this will keep the original .md file
@tmiz
tmiz / CoreLocationTest.m
Created December 1, 2011 12:08
Using CoreLocation on Mac OS X with command-line
//
// Using CoreLocation on Mac OS X with command-line
// $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation
// $ ./a.out
// location service enabled
// 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 140.695538
// 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900
// tmiz moo@tmiz.net
//
#import <cocoa/cocoa.h>