Skip to content

Instantly share code, notes, and snippets.

View bcm's full-sized avatar

Brian Moseley bcm

  • Sixfold
  • New York,NY
  • 02:28 (UTC -04:00)
View GitHub Profile
@bcm
bcm / gist:663059
Created November 4, 2010 19:44
scala-typed query param provider
import com.sun.jersey.api.ParamException.QueryParamException
import com.sun.jersey.api.core.HttpContext
import com.sun.jersey.api.model.Parameter
import com.sun.jersey.core.spi.component.{ComponentContext, ComponentScope}
import com.sun.jersey.spi.inject.{Injectable, InjectableProvider}
import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable
import com.sun.jersey.server.impl.model.parameter.multivalued.MultivaluedParameterExtractor
import com.sun.jersey.server.impl.model.parameter.multivalued.ExtractorContainerException
import javax.ws.rs.QueryParam
@bcm
bcm / stories.rb.diff
Created February 11, 2011 21:34
apply this diff to stories.rb to make it work with ruby 1.9.2
diff --git a/ruby/stories.rb b/ruby/stories.rb
index acbfcb0..36b435a 100755
--- a/ruby/stories.rb
+++ b/ruby/stories.rb
@@ -2,7 +2,7 @@
require 'rubygems'
require 'json'
-require 'md5'
+require 'digest/md5'
@bcm
bcm / ServletPropertyResolver.scala
Created February 13, 2011 01:28
Circumflex property file resolver that uses the servlet context to find the properties file within the webapp
import java.io.File
import ru.circumflex._, core._, web._
class ServletPropertyFileResolver extends PropertyFileResolver {
override val propsRoot = new File(servletContext.getRealPath(cx.getOrElse("cx.messages.root", "/WEB-INF").toString))
}
@bcm
bcm / ScalatePackage.scala
Created February 13, 2011 19:29
default imports for scalate templates
import org.fusesource.scalate.{Binding, TemplateSource}
import org.fusesource.scalate.support.TemplatePackage
class ScalatePackage extends TemplatePackage {
def header(source: TemplateSource, bindings: List[Binding]) = """
import in.outside.slingshot._, controllers._, helpers._, models._
import ru.circumflex.web._
"""
}
@bcm
bcm / gist:3014649
Created June 28, 2012 23:17
rvm info for failing stamps test
ruby-1.9.3-p0@stamps:
system:
uname: "Darwin vrock.local 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr 9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"
rvm:
version: "rvm 1.10.2 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.beginrescueend.com/]"
updated: "4 months 21 days 19 hours 38 minutes 20 seconds ago"
@bcm
bcm / gist:3014652
Created June 28, 2012 23:17
Gemfile.lock for failing stamps test
PATH
remote: .
specs:
stamps (0.2.0.copious.0)
hashie (>= 1.0.0)
httpi (= 0.7.9)
json (>= 1.5.1)
multi_json (~> 1.0)
savon (>= 0.8.6)
@bcm
bcm / gist:3353209
Created August 14, 2012 21:30
Balanced pagination metadata
diff --git a/lib/balanced/pager.rb b/lib/balanced/pager.rb
index 2338d0e..9150592 100644
--- a/lib/balanced/pager.rb
+++ b/lib/balanced/pager.rb
@@ -34,17 +34,29 @@ module Balanced
load! unless @page
@page[:limit]
end
+ alias limit_value limit
$ rails-api new api-server
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
$ cd api-server/
@bcm
bcm / dacm-app-eng-coding-exercise.md
Last active April 15, 2019 21:20
Application Engineer Coding Exercise (Amex DACM)

Coding Exercise

For this exercise you will create a simple web application that does the following:

  1. Allow the user to enter the URL of a public webpage.
  2. From the browser, fetch the page and display the raw (not rendered) source to the user.
  3. When the user clicks on the name of an HTML element in the displayed source, highlight every element in the displayed source with that name (e.g. clicking on an a tag causes that and all other a tags to be highlighted).

The exercise should generally not take more than 2 or 3 hours, although you're free to take as much time as you'd like to work on it. If you don't finish within a few hours, that's okay; submit what you've got anyway.

@bcm
bcm / dapx-srv-eng-coding-exercise.md
Last active April 15, 2019 21:20
Amex Digital Acquisition Coding Exercise: Service Engineer, Platform Excellence

For this exercise you will build a simple Java web service that provides CRUD-style API access to data stored in a relational database system.  

  1. Create a database table that holds records representing people.
    • A person record should have a unique identifier and the following additional attributes:
      • name (string)
      • age (integer)
      • date of birth (date)
      • email address (string)
    • Email address has a unique constraint (case-insensitive).