Skip to content

Instantly share code, notes, and snippets.

View johntbush's full-sized avatar

john bush johntbush

View GitHub Profile
function make_printing_guide_blurb() {
return '<div class="alert alert-info">
<img src="'.get_stylesheet_directory_uri().'/img/SIP4_Cover_RGB1.jpg" class="thumbnail pull-right" style="width:125px; height: auto;" />
<h4 style="text-align:center;">MAKE Ultimate Guide To 3D Printing</h4>
<ul>
<li>3D Printers Buyer\'s Guide</li>
-- H2 0.5/B --
-- H2 0.5/B --
-- H2 0.5/B --

@johntbush
johntbush / gist:10226188
Created April 9, 2014 04:30
implicit method def
def isModerator()(implicit user: User, request: RequestHeader): Boolean = {
..
}
@johntbush
johntbush / gist:10226365
Created April 9, 2014 04:34
call implicit method with parameters
var user : User = new User
var request : RequestHeader = new RequestHeader
isModerator(user, request)
@johntbush
johntbush / gist:10226463
Created April 9, 2014 04:36
implicitl call
implicit val user = currentUser
implicit val request = currentRequest
isModerator()
@johntbush
johntbush / gist:10227229
Created April 9, 2014 04:54
implicit methods
class JoinUrlMethod(meeting:Meeting) {
def joinUrl()(implicit user:User) : String = {
MeetingManager.joinMeeting(meeting, user)
}
}
object Conversions {
implicit def meetingWithJoinUrl(meeting:Meeting) = new JoinUrlMethod(meeting)
}
@johntbush
johntbush / gist:10227532
Created April 9, 2014 05:00
implicit method example
@import model.Conversions._
...
@for(meeting <- meetings) {
...
@if(meeting.isJoinable) {
<a class="btn btn-primary" href='@meeting.joinUrl'> @Messages("tool.view.join")</a>
}
}
@johntbush
johntbush / gist:ed81dc6d2dec7f957c74
Created May 2, 2014 19:52
export ANI source code
svn export https://source.sakaiproject.org/svn/msub/rsmart.com/sakai/tags/2.9.4.0
@johntbush
johntbush / gist:5114592b7aec85d37fdf
Created August 15, 2014 06:00
After learning about Function.chain...
def transform[T: TypeTag: ClassTag](json: JsValue, bean: T, overridableFieldsMap : HashMap[String, String]): JsValue = {
val functionCalls: Seq[(JsValue) => JsValue] = typeOf[T].members.filter(!_.isPrivate)
.filter(_.isMethod)
.filter(_.asMethod.isAccessor)
.filter(_.asMethod.fullName.startsWith("services."))
.map(
methodScope => {
var term = methodScope.asTerm
var mirror = runtimeMirror(bean.getClass.getClassLoader)
(x:JsValue) => {transformField(x, fieldName, displayName)}