Skip to content

Instantly share code, notes, and snippets.

@mfenner
mfenner / homebrew.mxcl.nomad.plist
Last active May 15, 2023 11:20
Configure Nomad for MacOS
<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.nomad</string>
<key>LimitLoadToSessionType</key>
<array>
@mfenner
mfenner / gist:10675094
Created April 14, 2014 19:09
Rakefile for Jekyll/Travis (work in progress)
#############################################################################
#
# Modified version of jekyllrb Rakefile
# https://github.com/jekyll/jekyll/blob/master/Rakefile
#
#############################################################################
require 'rake'
require 'jekyll'
require 'date'
@mfenner
mfenner / search_for_tweets.R
Created December 9, 2013 09:30
Example of for almevents function of alm package. Retrieve all tweets about a vector of DOIs, do some basic formatting and return data frame.
library(alm)
dois <- c("10.1371/journal.pbio.1001535","10.1371/journal.pone.0046362","10.1371/journal.pmed.0020124","10.1371/journal.pntd.0001969","10.1371/journal.pone.0040259")
api_key <- "YOUR_KEY"
response <- almevents(doi=dois, source="twitter",key=api_key)
events <- data.frame()
for (i in 1:length(dois)) {
row <- response[[i]][["twitter"]]
@mfenner
mfenner / vennDiagramExample.R
Created September 22, 2013 18:06
Create VennDiagram using ALM data
#' Venn diagram F1000 vs. Wikipedia for PLOS ALM
#'
#' @author Martin Fenner <mfenner@plos.org>
# Read in required functions
library("plyr")
library(VennDiagram)
# Options
report_date <- "2013-09-11"
@mfenner
mfenner / wikipedia.rb
Created June 3, 2012 13:31
ALM configuration for Wikipedia search
class Wikipedia < Source
# List of Wikipedias to search, we are using 20 most popular wikis
# Taken from http://toolserver.org/~dartar/cite-o-meter/?doip=10.1371
LANGUAGES = %w(en de fr it pl es ru ja nl pt sv zh ca uk no fi vi cs hu ko commons)
validates_each :url do |record, attr, value|
record.errors.add(attr, "can't be blank") if value.blank?
end
def get_data(article, options={})
@mfenner
mfenner / anno-xml-download.php
Created June 25, 2011 12:48
Changes to Annotum Wordpress theme to support ePub Export Plugin
/**
* Get the ePub download link for a post
*
* @param int $id
* @return string
*/
function anno_epub_download_url($id = null) {
# Requires ePub Export Plugin, returns "" if ePub Export Plugin didn't create ePub file
$article_id = get_the_ID();
$uploads = wp_upload_dir();