Skip to content

Instantly share code, notes, and snippets.

@nathania
nathania / RCF2.Rakefile.rb
Created August 4, 2012 21:09 — forked from CameronCarroll/RCF2.Rakefile.rb
Rakefile to compile Ruby/C/Fortran extensions
# Ruby/C/Fortran Bridge Rakefile
# Cameron Carroll, July 2012
# Purpose: Rake build script to facilitate calling Fortran code from Ruby in order to outsource
# heavy lifting computation. This script will compile Fortran and C code in present directory
# but leaves implementation and linking up to the user.
#
# Notes: This script may require a little bit of configuration depending on the system.
# 1: The Ruby include flags are specifically for MY system. I haven't found a way to generate them,
# so you have to either tailor them by hand or generate a extconf.rb makefile, enable verbose mode,
# and copy the include flags from the compile command. Yeah, I know, I know...
@nathania
nathania / gist:4162919
Created November 28, 2012 18:04 — forked from gglanzani/gist:3224737
Export your collection of papers in Papers to BibTeX
-- the following variable allows to choose what we want to export
-- it can be "Selected Papers Only", "Selected Collection" or "Entire Library"
set myDesiredSaveRange to "Selected Collection"
-- the following variable allows is the path where we save the bib file
set myPath to "~/Desktop/from_papers.bib"
-- do we also have a prettifier?
set runPrettifier to true
-- path to it
#!/usr/bin/env ruby -wKU
# Adapted from Brett Terpstra’s original “Markdown to Evernote” service (http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/)
# Martin Kopischke 2011 – License: Creative Commons Attribution Share-Alike (CC BY-SA) 3.0 Unported (http://creativecommons.org/licenses/by-sa/3.0/)
# Changes: – create only one Evernote note per (Multi)Markdown input passed (instead of one per line)
# – do not choke on shell escape characters (use Tempfile instead of shell pipe for osascript)
# – default to MultiMarkdown 3 executable (instead of MMD 2 Perl script)
# – make smart typography processing optional (set SMARTY to 'false' to bypass processing;
# note smart typography cannot be disabled in MMD 3.0 and 3.0.1
# – handle both smart typography processing scripts (ie. SmartyPants.pl)
@nathania
nathania / pub_med.py
Created March 16, 2017 19:41 — forked from ehazlett/pub_med.py
Search PubMed with BioPython
#!/usr/bin/env python
# numpy and biopython are required -- pip install numpy biopython
from Bio import Entrez
from Bio import Medline
MAX_COUNT = 10
TERM = 'Tuberculosis'
print('Getting {0} publications containing {1}...'.format(MAX_COUNT, TERM))
@nathania
nathania / rotate-axis-labels-ggplot2.R
Created December 9, 2018 01:01 — forked from benmarwick/rotate-axis-labels-ggplot2.R
I can never remember how to rotate the x-axis labels with ggplot2: theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))
# Adapted from https://stackoverflow.com/a/7267364/1036500 by Andrie de Vries
library(ggplot2)
td <- expand.grid(
hjust=c(0, 0.5, 1),
vjust=c(0, 0.5, 1),
angle=c(0, 45, 90),
text="text"
)
@nathania
nathania / ruler.R
Created March 12, 2019 20:31 — forked from hadley/ruler.R
ruler <- function(width = getOption("width")) {
x <- seq_len(width)
y <- dplyr::case_when(
x %% 10 == 0 ~ as.character((x %/% 10) %% 10),
x %% 5 == 0 ~ "+",
TRUE ~ "-"
)
cat(y, "\n", sep = "")
cat(x %% 10, "\n", sep = "")
}
@nathania
nathania / move_slides_to_web.R
Created March 31, 2019 13:14 — forked from malcolmbarrett/move_slides_to_web.R
Move R Markdown HTML slides to Blogdown and Push to Web
# install.packages(c("here", "fs", "stringr", "purrr", "git2r"))
# to add invisibly in your R profile, open with usethis::edit_r_profile()
# then define it in an environment, e.g.
# .env <- new.env()
# .env$move_slides_to_web <- {function definition}
move_slides_to_web <- function(folder = NULL, index = NULL) {
if (is.null(folder)) {
@nathania
nathania / installation.md
Created February 14, 2023 18:32 — forked from juliasilge/installation.md
Installing R + Tensorflow on M1