Skip to content

Instantly share code, notes, and snippets.

View trevmex's full-sized avatar
👨‍👩‍👧‍👦

Trevor Menagh trevmex

👨‍👩‍👧‍👦
View GitHub Profile
@trevmex
trevmex / 10.9.1.txt
Last active August 29, 2015 13:57
Mac OS X build failure for gs-rest-service
$ uname -a
Darwin 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
$ mvn -version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 11:22:22-0400)
Maven home: /usr/local/Cellar/maven/3.1.1/libexec
Java version: 1.6.0_65, vendor: Apple Inc.
@trevmex
trevmex / hal+metadata.json
Created May 1, 2014 01:16
An example of HAL JSON with Schema.org Metadata
{
"_type": "http://schema.org/QuantitativeValue/ProcessableOrders",
"_links": {
"self": { "href": "/orders" },
"curies": [{ "name": "ea", "href": "http://example.com/docs/rels/{rel}", "templated": true }],
"next": { "href": "/orders?page=2" },
"ea:find": {
"href": "/orders{?id}",
"templated": true
},
### Keybase proof
I hereby claim:
* I am trevmex on github.
* I am trevmex (https://keybase.io/trevmex) on keybase.
* I have a public key whose fingerprint is 9E7E 1FCC 1894 727B E845 ADC9 F105 E554 39A1 A7D9
To claim this, I am signing this object:
# In all comments :stage represents the stage you want to use (i.e. production, staging, etc.)
# Follow these steps AFTER modifying your /etc/apache2/httpd.conf file to add a new rails instance and running `sudo apachectl restart`
# Steps to setup capistrano for the first time:
# - cap :stage deploy:setup # this creates the correct directory tree
# - cap :stage deploy:check # this checks to make sure setup ran
# - cap :stage deploy:update # this updates the server with the app code
# - ssh :user@:main_server # fill in the correct user and server here
# - cd :deploy_to/current # again fill in the correct deploy to dir
# - RAILS_ENV=:stage sudo rake gems:install # this installs gems that need native compiling
class ActiveDirectoryUser
require 'restclient'
@authentication_site = 'https://your_server'
@find_site = 'http://your_server'
@authentication_prefix = '/your_auth_page'
@find_prefix = '/cgi-bin/dscl_search.sh?'
# Returns true if the user has the correct password, false otherwise.
def self.authenticate(login, password)
Factory.define :user , :class => User do |u|
u.sequence(:login) {|l| "user#{l}"}
u.sequence(:persistence_token) {|l| "#{Authlogic::Random.hex_token}"}
end
Factory.define :user , :class => User do |u|
u.add_attribute 'id', 1 # u.id calls the id method of the class instead of assigning an attribute 'id'
u.login "trevor"
end
OK, I figured it out. Dumb mistake: to create an optional format like
you see in `rake routes` as:
classify_user_asset GET /users/:user_id/assets/:id/edit/
class(.:format) {:action=>"classify", :controller=>"assets"}
you would write:
map.with_options :controller => 'assets', :conditions => {:method
=> :get} do |assets|
assets.classify_user_asset '/users/:user_id/assets/:id/edit/
class.:format', :action => 'classify'
module ActiveResource
class Base
# Returns the raw data to display the thumbnail of an Alfresco document
def thumbnail
if self.doclib
begin
Net::HTTP.start(self.class.site.host, self.class.site.port) do |http|
req = Net::HTTP::Get.new(self.doclib, {'Content-Type' => 'image/png'})
req.basic_auth self.class.user, self.class.password
http.request(req).body
@trevmex
trevmex / install_homebrew.rb
Created May 24, 2010 13:02 — forked from mxcl/install_homebrew.markdown
Install in any directory via command line arguments. The default behavior is still intact.
#!/usr/bin/ruby
#
# Download and execute this script in one-line with no temporary files:
#
# ruby -e "$(curl http://gist.github.com/raw/411826/install_homebrew.rb)"
#
#
# 24th May 2010 (trevmex):
# Adapted mxcl's fork: http://gist.github.com/323731
# Changed mxcl's code to include a prefix command line variable to allow