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 / ggplot.R
Created June 8, 2017 15:04
ggplot2 data exploration
library(ggplot2)
install.packages('hexbin')
cars <- mtcars
cars$car <- rownames(mtcars)
cars <- cars[with(cars, order(hp)), ]
cars$car <- factor(cars$car, levels = cars$car)
cars$cyl[cars$cyl == 4] <- '4 cylinders'
cars$cyl[cars$cyl == 6] <- '6 cylinders'
cars$cyl[cars$cyl == 8] <- '8 cylinders'
@blahah
blahah / InkBackend.js
Last active May 24, 2017 11:01
InkBackend refactor to get Editoria component
const config = require('config')
const rp = require('request-promise-native')
const Busboy = require('busboy')
const temp = require('temp').track()
const fs = require('fs')
const path = require('path')
const promiseRetry = require('promise-retry')
let inkConfig = config.get('pubsweet-component-ink-backend')
let inkEndpoint = inkConfig.inkEndpoint
@blahah
blahah / install.sh
Last active May 19, 2017 13:08
Recreate EBADF error on windows when syncing files from a hyperdrive
npm init -y
npm install mkdirp blahah/hyperdrive dat-storage folder-walker through2 hyperdiscovery pumpify untildify
@blahah
blahah / 1_basic_browser.js
Last active February 8, 2023 09:04
loading geoJSON examples
// we have a geoJSON file (in this case for Guinea) on the web:
var guinea = 'https://raw.githubusercontent.com/johan/world.geo.json/master/countries/GIN.geo.json'
// and we have a function that does something with the geoJSON file:
var handleGeoJSON = function (data) {
// data is the JSON parsed into a JS object
console.log(data)
}
// using jquery (you must have loaded jQuery first) - http://api.jquery.com/jquery.getjson
hephaestus:hypercore rik$ npm run bench
> [email protected] bench /Users/rik/c/mafintosh/hypercore
> cd bench && ./all.sh
> git checkout a54dcf9
# clearing cache
> rm -rf cores
@blahah
blahah / crossref_retractions.sh
Last active April 19, 2017 06:50
split crossref openretractions into separate files for API
cat ../crossref_processed.json | while read entry
do
doi=$(echo $entry | jq -r '.doi')
echo creating "$doi"
mkdir -p "$doi"
echo $entry > "$doi/data.json"
done
@blahah
blahah / pubmed_retractions.sh
Last active March 19, 2025 22:55
easily find retracted papers in PubMed, using only bionode-ncbi and jq
# you'll need:
# - bionode-ncbi (https://github.com/bionode/bionode-ncbi)
# - jq (https://github.com/stedolan/jq)
# count the number of retracted papers
bionode-ncbi search pubmed "\"Retracted Publication\"" \
| jq -c 'select(.pubtype[] | inside("Retracted Publication"))'
| wc -l
# get DOIs for all the retracted papers
@blahah
blahah / unnest_dirs.sh
Created April 13, 2017 14:32
unnest nested dirs
for path in $(find ../articles_split/articles/ -type d -wholename '*\/*\/*\/*\/*' | grep '.\{36\}'); do
mergeddir=$(echo $path | sed 's/\([0-9]\)\/\([0-9]\)\/\([0-9]\)\/\([0-9]\)\/\([0-9]\)/\1\2\3\4\5/')
mkdir -p $mergeddir
cp -R $path/* $mergeddir/
done
@blahah
blahah / problem.js
Last active April 11, 2017 14:33
stream never reads more than 20 results...
const resultbatcher = ds => {
let count = 0
const write = (list, cb) => {
count += list.length
bus.emit('results:receive', {
hits: list.map(r => {
r.source = ds.key
return r
@blahah
blahah / search.js
Created April 10, 2017 03:15
choo5 search field wip
const html = require('choo/html')
const css = require('csjs-inject')
const C = require('../lib/constants')
const style = css`
.search {
height: 30px;
width: 80%;
bottom: 0;