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
| public class OrdBok { | |
| public static void main (String args[]) { | |
| new OrdBok().run(); | |
| } | |
| public void run() { | |
| BinNode testnode = new BinNode("Ken"); | |
| System.out.println("Tree root node " + testnode.value); | |
| testnode.addChild(new BinNode("Kfen")); |
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 CaesarCipher | |
| attr_accessor :shift_value | |
| def initialize(shift_value) | |
| @shift_value = shift_value | |
| @shifted_alphabet_array = ("A".."Z").to_a.rotate(@shift_value) | |
| @alphabet_array = ("A".."Z").to_a | |
| end | |
| def cipher(text) | |
| text.upcase.split("").each_with_object("") do |chr, cipher_text| |
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
| 2.0.0p247 :001 > def method_missing m,*args; [m.to_s,args].flatten.join " "; end | |
| => nil | |
| 2.0.0p247 :002 > "j".happy "hh" | |
| 2.0.0p247 :001 > def method_missing *args; args.join " "; end | |
| => nil | |
| 2.0.0p247 :002 > "j".happy | |
| SystemStackError: stack level too deep | |
| from /Users/bjhaid/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/workspace.rb:86 | |
| Maybe IRB bug! |
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
| require 'helloworld' | |
| describe Helloworld do | |
| it "should say 'HelloWorld!'" do | |
| helloWorld = Helloworld.new() | |
| helloWorld.hello.should eql("HelloWorld!") | |
| 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
| Index: | |
| 1. should() #basic expectation | |
| 2. should_not() #basic negation of an expectation (RSpec does not support using !=) | |
| 3. include(item) #called on an enumerable object, this returns true or false if the object is found in the enumerable collection | |
| 4. respond_to(:message) #determines if a particular message (as a symbol) is defined for an object | |
| 5. raise_error(type, message) #checks if a particular error was raised, accepts zero, one or two parameters |
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 Die | |
| def roll | |
| rand(1..6) | |
| end | |
| end | |
| class Player | |
| attr_writer :die1, :die2 | |
| def initialize | |
| @dice_roll_from_first_turn = nil |
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
| $ rvm install 1.9.3 --debug | |
| 1.9.3 - install | |
| Searching for binary rubies, this might take some time. | |
| Remote file does not exist https://rvm.io/binaries/mint/15/x86_64/ruby-1.9.3-p448.tar.bz2 | |
| Remote file does not exist http://jruby.org.s3.amazonaws.com/downloads/ruby-1.9.3-p448.tar.bz2 | |
| Remote file does not exist http://binaries.rubini.us/mint/15/x86_64/ruby-1.9.3-p448.tar.bz2 | |
| rvm_remote_server_url3 not found | |
| No remote file name found | |
| No binary rubies available for: mint/15/x86_64/ruby-1.9.3-p448. | |
| Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. |
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 "I love Ruby so so much" | |
| sleep 5 | |
| puts("\n" * 3) | |
| puts "Welcome to Ruby" |
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
| #1. Write a script that would request for a person's name, age, home address, and print it to console in the format: | |
| My name is Ayodele Abejide, I am 29 years old, I live in Gbagada, Lagos, Nigeria. | |
| print "What is your name? " | |
| name = gets.chomp | |
| print "How old are you? " | |
| age = gets.chomp | |
| print "Where do you live? " | |
| home_address = gets.chomp |
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
| private RIMXMLResponseDetail processRIMResponse(String response) | |
| { | |
| RIMXMLResponseDetail rimXMLResponseDetail = new RIMXMLResponseDetail(); | |
| try | |
| { | |
| document = DocumentHelper.parseText(response); | |
| if ( document.selectSingleNode("//ProvisioningReply/Body/ProvisioningEntity/ProvisioningDataItem[@name='BillingId']") == null){ | |
| Node billingID = document.selectSingleNode("//ProvisioningReply/Body/ProvisioningEntity/ProvisioningDataItem[@name='IMSI']"); | |
| rimXMLResponseDetail.setImsi(billingID.getText()); |