Skip to content

Instantly share code, notes, and snippets.

View kardeiz's full-sized avatar

Jacob Brown kardeiz

View GitHub Profile
@kardeiz
kardeiz / desc.md
Last active December 24, 2015 16:59
  1. User visits web application.

    • User can view resource availability as unauthenticated user (availability recorded in web app database).
  2. User logs in to web application.

    • User information is authenticated against library SIP2 server:
      • On failure: user is prompted to re-enter information
      • On success:
        • User's supplementary information (e.g., name) is added to web app database (unless exists). Password (PIN) is not saved to web app database.
        • User account is created in ActiveDirectory (unless already exists). AD password is created from user's PIN (all information passed over SSL). Group and logon hours set to none.
@kardeiz
kardeiz / dcpromo_unattend.txt.erb
Last active December 27, 2015 05:29
Chef Windows Server 2008 recipe
[DCINSTALL]
SafeModeAdminPassword=<%= @admin_password %>
RebootOnCompletion=Yes
ReplicaOrNewDomain=domain
NewDomain=forest
NewDomainDNSName=<%= @domain_name %>
ForestLevel=3
DomainLevel=3
InstallDNS=yes
@kardeiz
kardeiz / ad_utils.rb
Created November 2, 2013 00:29
Active Directory utility class
require 'net/ldap'
module AdHelper
class Connector
NO_LOGON_HOURS = '0' * 168
def initialize
config_file = Dir.glob("#{Rails.root}/config/**/ad.yml").first
@kardeiz
kardeiz / gist:7812863
Created December 5, 2013 20:02
Rails controller boilerplate - since I can never find it online
class TestsController < ApplicationController
# GET /tests
# GET /tests.json
def index
@tests = Test.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tests }
end
class Description < ActiveRecord::Base
belongs_to :user
belongs_to :product
belongs_to :document
# attr_accessible :title, :body
validate :check_limit
def check_limit
if self.class.where(:user_id => self.user_id).count >= 1
Import-Module PSTerminalServices
Function OctetToHours ($Octet)
{
# Function to convert Octet value (byte array) into binary string
# representing logonHours attribute. The 168 bits represent 24 hours
# per day for 7 days, Sunday through Saturday. The values are converted
# into local time. If the bit is "1", the user is allowed to logon
# during that hour. If the bit is "0", the user is not allowed to logon.
$Bias = (Get-ItemProperty -Path HKLM:\System\CurrentControlSet\Control\TimeZoneInformation).Bias
@kardeiz
kardeiz / saxon-for-dspace.md
Last active June 28, 2016 18:46
Using Saxon with Cocoon XSLT for DSpace

Using Saxon with Cocoon XSLT for DSpace

Create an xconf file at [dspace-src]/dspace/modules/xmlui/src/main/resources/META-INF/cocoon/avalon/cocoon-core-saxon-xslt.xconf and add the following lines:

<?xml version="1.0" encoding="UTF-8"?>
<components>
  <component role="org.apache.excalibur.xml.xslt.XSLTProcessor/saxon"
 class="org.apache.cocoon.components.xslt.TraxProcessor"&gt;
@kardeiz
kardeiz / gist:c8ab990614dbbcb31213
Created November 11, 2014 16:33
script to output DSpace resource policy info
#!/bin/env jruby
require 'csv'
DSPACE_CFG = 'path to your dspace.cfg'
DSPACE_DIR = File.expand_path('../..', DSPACE_CFG)
DSPACE_JARS = Dir[File.join(DSPACE_DIR, 'lib/*.jar')]
ADMIN_EMAIL = 'your admin email'
OUTPUT = '/tmp/rp.csv'
@kardeiz
kardeiz / gist:d80bc301e67cc87d1eb4
Last active August 29, 2015 14:19
Difference bw `rails new myapp -O` and `rails new myapp` for Rails 4.2.1
diff -r tmp1/myapp/config/application.rb tmp2/myapp/config/application.rb
3,12c3
< require "rails"
< # Pick the frameworks you want:
< require "active_model/railtie"
< require "active_job/railtie"
< # require "active_record/railtie"
< require "action_controller/railtie"
< require "action_mailer/railtie"
< require "action_view/railtie"
@kardeiz
kardeiz / gist:682714d2a1fa02872a96
Created April 14, 2015 15:05
Difference bw `rails new myapp --skip-sprockets` and `rails new myapp` for Rails 4.2.1
diff -r tmp3/myapp/config/application.rb tmp2/myapp/config/application.rb
3,12c3
< require "rails"
< # Pick the frameworks you want:
< require "active_model/railtie"
< require "active_job/railtie"
< require "active_record/railtie"
< require "action_controller/railtie"
< require "action_mailer/railtie"
< require "action_view/railtie"