Skip to content

Instantly share code, notes, and snippets.

View blahah's full-sized avatar

Rik Smith-Unna blahah

  • upward spiral ∞⟨X∴↯⟩∞
  • Bristol / Berlin / Nairobi
  • X @blahah404
View GitHub Profile
@blahah
blahah / dat.sh
Last active November 5, 2016 17:02
install dat on a digitalocean droplet (fixing npm permissions issues)
# if you try to install dat on a digitalocean droplet you usually get an error like:
# sh: 1: prebuild: Permission denied
#
# this is caused by several intersecting facts:
# - digitalocean droplets, by default, only expose a root user for login
# - most node setup methods will create a node install that isn't owned by root
# - npm uses an 'undefined' user for installation
#
# and is solved in the following way:
# - taking root ownership of the node install and library install directory tree (with `chown`)

Let’s hypothesize that I have the magical ability to open a connection to any web server, and that every key press I make on my keyboard will be sent to the remote computer. I want to get the Google homepage, so I connect to one of their many web servers.

If the server spoke English, I might type:

Hello!  Please give me the content located at the path /
on the domain www.google.com.
I'm using the Chrome web browser, version 26.
I would like to receive the content as HTML,
zipped to save bandwidth,
@blahah
blahah / index.js
Created June 30, 2016 11:16
use the unified / rehype / retext ecosystem to extract enriched keywords from each article in a corpus of JATS XML articles
var fs = require('fs')
var unified = require('unified')
var parseHTML = require('rehype-parse')
var visit = require('unist-util-visit')
var findAfter = require('unist-util-find-after')
var file = '/Users/rds45/.sciencefair/data/elife_dws2/articles/01096/elife-01096-v1.xml'
var getBody = function () {
@blahah
blahah / email.md
Last active June 25, 2016 17:32
Letter to my MP (Alan Haselhurst) requesting block of EU withdrawal

Dear Sir Alan,

My partner Steph and I run a successful scientific software business from our house in Saffron Walden. We have a son who is approaching his first birthday. We are both Cambridge-educated scientists. We are appalled by the prospect of the UK withdrawing from the EU, and want to implore you to do anything in your power to help prevent it.

As I understand it, parliament must ultimately decide on whether to trigger Article 50 of the Lisbon Treaty in order to initiate withdrawal.

My first request is that you vote against withdrawal and against triggering of Article 50. Reasons for doing so are abundant. To highlight a few:

  • The world economy has clearly judged that Brexit would be a terrible idea. The pound has tanked, many British companies have lost unprecedented market capitalisation, and the Bank of England is having to resort to devaluing the pound in order to try to stabilise markets. Financial firms are already starting to move thousands of staff overseas.
  • Other EU leaders have ma
@blahah
blahah / response_to_wiley_fake_dois.md
Last active March 19, 2025 22:55
Reply to Wiley's claim that they "do not create fake DOIs"
@blahah
blahah / install_node.md
Created May 20, 2016 12:49
Node installation instructions

installing Node.js

Whatever operating system you use, you'll need to install Node.js. We recommend doing this using nvm - the node version manager. Your machine should come with at least one of curl or wget. You can use either to install nvm:

curl version:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
@blahah
blahah / getwileydoi.sh
Created May 19, 2016 04:48
download a wiley PDF by DOI
#!/bin/sh
wget \
--header "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36" \
--verbose \
--save-cookies cookies.txt \
--keep-session-cookies \
--content-disposition \
http://onlinelibrary.wiley.com/doi/$1/pdf \
-O `echo "$1" | tr '/' '☍'`.pdf
@blahah
blahah / eupmc_db_opts.json
Created April 22, 2016 12:18
Europe PMC lite open access metadata - 10,000 document sample for testing yunodb
{
"keyField": "$.identifier[?(@.type === 'pmcid')].id",
"indexMap": {
"title": true,
"author[*].surname": true,
"year": false
}
}
@blahah
blahah / optimise_eupmc.js
Last active April 18, 2016 17:37
europe pubmed central bibJSON -> search index optimised term array
#!/usr/bin/env node
// this script optimises the eupmc metadata for inclusion in a full-text
// search index.
var Transform = require("stream").Transform
var util = require("util")
var natural = require('natural')
var tokenize = (new natural.TreebankWordTokenizer()).tokenize
@blahah
blahah / README.md
Created April 17, 2016 07:34
Comparison of embedded NoSQL databases that can be emedded in a Node.js - Electron app

Making an Electron app and want to embed a database? Here's a table to help you choose the right database software.

Work in progress

Project Language NPM package? Flat file? In memory? Full-text search? Maturity Embedded size Dependencies
NeDB Javascript Yes Always No High Low Simple
Lunr Javascript No Yes Yes High Tiny None
Search-index Javascript
Sqlite3 C Yes No Yes (fts extens