Skip to content

Instantly share code, notes, and snippets.

@DanCoughlin
DanCoughlin / gist:e2e9b43e5834a986c4b2
Created April 30, 2015 00:11
Fixing style over ride for striped tables
.table-striped {
tbody {
tr:nth-child(odd) {
td {
background-color: rgba(255,255,255,0.1);
color: gray;
a {
color: white;
}
@DanCoughlin
DanCoughlin / seeds.rb
Last active February 12, 2021 11:27
Example of a database seed file for rails
# loop over this 5 times
5.times do |i|
# create a topic with the name provided name and description
t = Topic.create(title: "Topic ##{i}", description: "This topic is cool because everyone loves the topic number ##{i}.")
# create a random number between 1 and 100 and loop that many times create a vote for this topic
rand(1..100).times do |j|
t.votes.create
end
end
# create a user with this email address and password

ARCHITECTing ScholarSphere

ScholarSphere is a web application that allows the Penn State research community to deposit, share, and manage its scholarly works. It is also, as some of our users and our peers have observed, a repository app that feels much more like Google Docs or GitHub than earlier-generation repository applications. ScholarSphere is built upon the Hydra framework (Fedora Commons, Solr, Blacklight, Ruby on Rails), MySQL, Redis, Resque, FITS, ImageMagick, jQuery, Bootstrap, and FontAwesome. We'll talk about techniques we used to:

  • eliminate Fedora-isms in the application
    1. no objects
    2. no datastreams
    3. no namespaces in URLs
  • model and expose RDF metadata in ways that users find unobtrusive
  1. tradeoffs for using RDF instead of XML to serialize metadata
@DanCoughlin
DanCoughlin / gf-rspec
Created November 19, 2012 21:20
GF controller output
{"checksum_audit_log"=>{"actual_result"=>nil, "created_at"=>"2012-11-19T21:20:24Z", "dsid"=>"DC", "expected_result"=>nil, "id"=>35, "pass"=>1, "pid"=>"scholarsphere:bc386j20b", "updated_at"=>"2012-11-19T21:20:24Z", "version"=>"DC1.0"}}
{"checksum_audit_log"=>{"actual_result"=>nil, "created_at"=>"2012-11-19T21:20:24Z", "dsid"=>"RELS-EXT", "expected_result"=>nil, "id"=>36, "pass"=>1, "pid"=>"scholarsphere:bc386j20b", "updated_at"=>"2012-11-19T21:20:24Z", "version"=>"RELS-EXT.1"}}
{"checksum_audit_log"=>{"actual_result"=>nil, "created_at"=>"2012-11-19T21:20:24Z", "dsid"=>"RELS-EXT", "expected_result"=>nil, "id"=>36, "pass"=>1, "pid"=>"scholarsphere:bc386j20b", "updated_at"=>"2012-11-19T21:20:24Z", "version"=>"RELS-EXT.1"}}
{"checksum_audit_log"=>{"actual_result"=>nil, "created_at"=>"2012-11-19T21:20:24Z", "dsid"=>"rightsMetadata", "expected_result"=>nil, "id"=>37, "pass"=>1, "pid"=>"scholarsphere:bc386j20b", "updated_at"=>"2012-11-19T21:20:24Z", "version"=>"rightsMetadata.0"}}
{"checksum_audit_log"=>{"actual_res
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
@DanCoughlin
DanCoughlin / .profile
Created October 9, 2012 14:27
Profile
PATH=:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/X11R6/bin:/Applications/Utilities:$HOME/bin:/usr/local/fits-0.6.0:$PATH
# Tomcat, Java, Fedora settings
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home;
export JAVA_HOME;
# default shell settings
set -o vi
export LC_ALL=en_US.UTF-8
@DanCoughlin
DanCoughlin / bashrc
Created September 19, 2012 18:37
gemset rvm release
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
@DanCoughlin
DanCoughlin / hl-rspec.rb
Created July 27, 2012 18:32
rspec tests for hydra-ldap
require 'spec_helper'require 'ladle'
describe 'Ldap service' do
before(:all) do
@ldap_server = Ladle::Server.new( :port => 3897,
:domain => "dc=example,dc=org", :allow_anonymous => true,
:verbose => true,
:ldif => 'default.ldif'
).start
end
@DanCoughlin
DanCoughlin / directory_controller.rb
Created July 24, 2012 18:07
Here is the main ldap library and then the directory controller where these are used and the user model that exposes the ldap functionality
# returns true if the user exists and false otherwise
def user
render :json => User.attributes(params[:uid])
end
def user_attribute
if params[:attribute] == "groups"
res = User.groups(params[:uid])
else
res = User.attributes(params[:uid], params[:attribute])
@DanCoughlin
DanCoughlin / dc_spec
Created July 14, 2012 20:22
trying to get spec tests for directory controller
require 'spec_helper'
describe DirectoryController do
describe "#user" do
it "should return an empty array for non-existing user" do
get :user, uid:"noone"
response.should == [] #be_empty
end