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
input = "20+4+2-1" | |
class String | |
def is_i? | |
!!(self =~ /\A[0-9]+\z/) | |
end | |
end | |
def operation(op) | |
case op |
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
# displacement calculation | |
# Instructions | |
# A car travels from one point to the next. It starts at point A, then moves to point B, then C and so on. Between each point it travels in a straight line. The car's travel is described in the input string in the following format: | |
# <<start_point>|<end_point>>[<heading>:<distance>],... | |
# Heading values can be 0 through 355 degrees (in increments of 5) | |
# For example, input might be: |
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
## MARS ROVER TEST ## | |
# A squad of robotic rovers are to be landed by NASA on a plateau on Mars. This plateau, which is curiously rectangular, must be navigated by the rovers so that their on-board cameras can get a complete view of the surrounding terrain to send back to Earth. | |
# A rover's position and location is represented by a combination of x and y co-ordinates and a letter representing one of the four cardinal compass points. The plateau is divided up into a grid to simplify navigation. An example position might be 0, 0, N, which means the rover is in the bottom left corner and facing North. | |
# In order to control a rover, NASA sends a simple string of letters. The possible letters are 'L', 'R' and 'M'. 'L' and 'R' makes the rover spin 90 degrees left or right respectively, without moving from its current spot. 'M' means move forward one grid point, and maintain the same heading. | |
# Assume that the square directly North from (x, y) is (x, y+1). |
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
g = TitanFactory.open('conf/titan-cassandra.properties') | |
bg = new BatchGraph(g, VertexIDType.NUMBER , 1300) | |
file = new File("/tmp/data.csv") | |
get_fields = {line-> | |
line_list = line.split(",") | |
size = line_list.size() | |
(ind_object_id, ind_temp_moneyhouse_id, ind_temp_moneyhouse_url, first_name, last_name, city_of_residence, ind_derived_state, relationship_type, org_object_id, org_temp_moneyhouse_id, org_temp_moneyhouse_url, name, city_of_registration, org_derived_state) = line_list[0..(size-1)] | |
return [ind_object_id, first_name, last_name, relationship_type, org_object_id] |
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 StartupMailer < ActionMailer::Base | |
default from: "[email protected]" | |
def respond_to_new_founder | |
send('mail', to: '[email protected]', subject: 'Welcome to My Awesome Site') | |
end | |
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
destroy: function(opt){ | |
if(!this.id){ | |
console.log('differing') | |
var fun = _.bind(Backbone.Model.prototype.destroy.call, this) | |
_.delay(fun,1000,[this,opt]); | |
} | |
else | |
Backbone.Model.prototype.destroy.call(this,opt); | |
}, | |
// console logs in browser |
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
/* | |
* Copyright (C) 2010 Google Inc. All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are | |
* met: | |
* | |
* * Redistributions of source code must retain the above copyright | |
* notice, this list of conditions and the following disclaimer. | |
* * Redistributions in binary form must reproduce the above |
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 Deliveryguy.Routers.PostsRouter extends Backbone.Router | |
initialize: (options) -> | |
@posts = new Deliveryguy.Collections.PostsCollection() | |
@posts.reset options.posts | |
routes: | |
"/new" : "newPost" | |
"/index" : "index" | |
"/:id/edit" : "edit" | |
"/:id" : "show" |
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
# in /app/models/tag_note.rb | |
class TagNote < ActiveRecord::Base | |
belongs_to :tag | |
end | |
# in /app/models/acts_as_taggable_on/tag.rb | |
class ActsAsTaggableOn::Tag | |
has_one :tag_note | |
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
#ruby -v # 1.9.2 | |
#gem list|grep em-ssh # em-ssh(0.1.0) | |
require 'em-ssh' | |
# runs the command on server and gives the callback call | |
def do_ssh(cmd) | |
do_ssh_var = 'ssh' | |
EM::Ssh.start('localhost','goutham') do |ssh| | |
puts 'ssh start' | |
ssh.exec!(cmd) do |channel, stream, data| |
NewerOlder