This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Party := Object clone | |
| Party getRowdy := ("Rabble rabble rabble" println) | |
| Party getRowdy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ActsAsCsv | |
| def self.included(base) | |
| base.extend ClassMethods | |
| end | |
| module ClassMethods | |
| def acts_as_csv | |
| include InstanceMethods | |
| end | |
| end | |
| module InstanceMethods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Tree | |
| attr_accessor :children, :node_name | |
| def initialize(node = {}) | |
| (node.length == 1) && (@node_name = node.first[0]) || @node_name = 'root' | |
| children = (@node_name == 'root') ? node : node[@node_name] | |
| @children = [] | |
| children.each do |k, v| | |
| @children.push(Tree.new({k => v})) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| puts "Guess a number between 1 and 10\n" | |
| goal = rand(10) + 1 | |
| until((answer = gets.chomp) == goal.to_s) | |
| puts "Too low\n" if answer.to_i < goal | |
| puts "Too high\n" if answer.to_i > goal | |
| end | |
| puts "Good job! You guessed #{goal} correctly!\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*global module:false*/ | |
| module.exports = function(grunt) { | |
| // Project configuration. | |
| grunt.initConfig({ | |
| concat: { | |
| dist: { | |
| src: [ | |
| 'vendor/bootstrap.js', | |
| 'vendor/underscore.js', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.brianscaturro | |
| import org.neo4j.graphdb.RelationshipType | |
| object RelTypes extends Enumeration { | |
| type RelTypes = Value | |
| val KNOWS = Value | |
| implicit def conversion(rt: RelTypes) = new RelationshipType() { def name = rt.toString } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| mkdir -p src/main/{resources,scala} | |
| mkdir -p "src/test/"{resources,scala} | |
| mkdir -p src/it/{resources,scala} | |
| mkdir project | |
| #create project files | |
| echo "sbt.version=0.11.3" > project/build.properties | |
| echo -e 'resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"\n' > project/plugins.sbt | |
| echo 'addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0-SNAPSHOT")' >> project/plugins.sbt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get(fbid: String):Option[FacebookObject] = { | |
| val response = graphFetch(fbid) | |
| response().map(jstr => { | |
| val js = jstr.asJson.asJsObject | |
| val obj = js.convertTo[FacebookObject] | |
| val comments = js.getFields("comments") | |
| if (comments.isEmpty) obj else build(obj, comments.head.asJsObject.convertTo[CommentsJson]) | |
| }) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (for(i <- 1 to 999 if(i % 3 == 0 || i % 5 == 0)) yield i) reduceLeft(_ + _) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isMobileDevice() | |
| { | |
| var agent = navigator.userAgent.toLowerCase(); | |
| var otherBrowser = (agent.indexOf("series60") != -1) || (agent.indexOf("symbian") != -1) || (agent.indexOf("windows ce") != -1) || (agent.indexOf("blackberry") != -1); | |
| var mobileOS = typeof orientation != 'undefined' ? true : false; | |
| var touchOS = ('ontouchstart' in document.documentElement) ? true : false; | |
| var iOS = (navigator.platform.indexOf("iPhone") != -1) || | |
| (navigator.platform.indexOf("iPad") != -1) ? true : false; | |
| var android = (agent.indexOf("android") != -1) || (!iOS && !otherBrowser && touchOS && mobileOS) ? true : false; |