Skip to content

Instantly share code, notes, and snippets.

Avatar

Jon Stroop jpstroop

  • Princeton University Library
  • Princeton, NJ
View GitHub Profile
@althonos
althonos / setup.cfg
Last active Apr 8, 2021
A `setup.cfg` template for my Python projects
View setup.cfg
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c
[metadata]
name = {name}
version = file: {name}/_version.txt
author = Martin Larralde
author-email = martin.larralde@embl.de
home-page = https://github.com/althonos/{name}
description = {description}
long-description = file: README.md
View plum.json
{
"states": ["pending", "metadata_review", "final_review", "complete", "flagged", "takedown"],
"state_groups":[
{"name":"suppressed", "states":["pending", "metadata_review", "final_review", "takedown"]}
],
"events":[
{ "from":"pending", "to":"metadata_review", "name":"finalize_digitization" },
{ "from":"metadata_review", "to":"final_review", "name":"finalize_metadata" },
{ "from":"final_review", "to":"complete", "name":"complete" },
{ "from":"complete", "to":"takedown", "name":"takedown" },
@no-reply
no-reply / vocabs.rb
Last active Jan 4, 2016
Using Vocabulary Loader
View vocabs.rb
# The ruby-rdf vocabulary loader is used to maintain the vocabularies in the core library.
# There's a rake task that is the main way it is used and serves as a good reference.
# https://github.com/ruby-rdf/rdf/blob/develop/Rakefile
rake gen_vocabs
# Generate lib/rdf/vocab/cc.rb
# Generate lib/rdf/vocab/cert.rb
# Generate lib/rdf/vocab/dc.rb
# Generate lib/rdf/vocab/dc11.rb
@no-reply
no-reply / oregon_rdf_demo.rb
Last active Jul 12, 2017
RDF Resources in OregonDigital
View oregon_rdf_demo.rb
# RdfResource is a subclass of RDF::Graph with property configuration, accessors, and some other methods
# for managing "resources" as discrete subgraphs which can be managed by a Hydra datastream model.
#
# The relevant modules and class are:
#
# https://github.com/OregonDigital/oregondigital/tree/master/lib/oregon_digital/rdf/rdf_configurable.rb
# https://github.com/OregonDigital/oregondigital/tree/master/lib/oregon_digital/rdf/rdf_properties.rb
# https://github.com/OregonDigital/oregondigital/tree/master/lib/oregon_digital/rdf/rdf_resource.rb
bnode = OregonDigital::RDF::RdfResource.new
@peterjmit
peterjmit / benchmark.sh
Created Oct 10, 2012
Bash Benchmark Script (using time)
View benchmark.sh
#!/bin/bash
# REQUIRES SUDO
# Benchmark runner
repeats=20
output_file='benchmark_results.csv'
command_to_run='echo 1'
run_tests() {
# --------------------------------------------------------------------------
@cosimo
cosimo / parse-options.sh
Created Sep 21, 2012
Example of how to parse options with bash/getopt
View parse-options.sh
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@bradmontgomery
bradmontgomery / rvm_apache_passenger.txt
Created Jan 10, 2012
RVM + Apache + passenger setup for Ubuntu
View rvm_apache_passenger.txt
# Install rvm system-wide
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
# Update the packages
apt-get update
apt-get upgrade
apt-get install build-essential
# get the packages required by ruby
rvm pkg install zlib
@edsu
edsu / bots.py
Created Jun 23, 2011
see what your bot traffic is like
View bots.py
#!/usr/bin/env python
"""
Hack to look for user agent strings in typical Apache style log and
count up the number of requests by bots vs non-bots. The list of bot
user agents comes from http://www.user-agents.org/ but has had some
agents added to it, since the user-agents.org list is pretty out of date, e.g.
no Bing?!
"""
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@mnot
mnot / link_header.py
Created Oct 15, 2009
link_header.py: HTTP Link header parsing
View link_header.py