Skip to content

Instantly share code, notes, and snippets.

@priyaaank
priyaaank / ICommand.java
Last active March 27, 2022 20:12
Rover implementation with Command pattern
public interface ICommand {
public void execute();
}
@priyaaank
priyaaank / Rover.java
Created July 28, 2014 11:27
Rover with a conditional command handling
public class Rover {
public void handleCommand(RoverCommand command) {
switch(command) {
case R:
//Do stuff to rotate right
break;
case L:
// Do stuff to rotate left
break;
@priyaaank
priyaaank / Coordinates.java
Last active November 2, 2021 08:51
Domain objects for Mars Rover
public class Coordinates {
// An object that represent a x and y coordinate.
// It is immutable, to reflect that a position cannot
// be modified, only a new one can be obtained using
// one as reference. Additionally it exposes behavior
// to check if another coordinate is outside or within
// bounds from 0,0 to current coordinate.
public Coordinates(final int xCoordinate,
@priyaaank
priyaaank / Vagrantfile
Created October 25, 2012 18:18
Vagrant configuration with jenkins cookbook
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ci"
# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
@priyaaank
priyaaank / Cheffile
Created October 25, 2012 18:05
Cheffile for Librarian-chef
#!/usr/bin/env ruby
#^syntax detection
site 'http://community.opscode.com/api/v1'
cookbook 'apt'
cookbook 'apache2'
cookbook 'jenkins'
@priyaaank
priyaaank / Vagrantfile
Created October 25, 2012 17:53
Vagrant configuration
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ci"
# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
@priyaaank
priyaaank / api.rb
Created October 21, 2012 09:32
Modular APIs with Grape and Rails
class API < Grape::API
format :json
error_format :json
version 'v1', :using => :header, :vendor => "App"
rescue_from Mongoid::Errors::DocumentNotFound do |error|
rack_response({"error" => {"message" => "We didn't find what we were looking for"}}.to_json, 404)
end
@priyaaank
priyaaank / contact_info.rb
Created October 21, 2012 08:39
Models for Modular API with Grape and Rails
class ContactInfo
include Mongoid::Document
field :address_line, :type => String
field :city, :type => String
field :country, :type => String
field :zipcode, :type => String
field :state, :type => String
embeds_many :phone_numbers