- Twitter: @alinajaf
- Website or Blog: http://happybearsoftware.com/archive.html
- Company: Happy Bear Software Ltd. http://happybearsoftware.com
This file contains 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
#! /usr/bin/env ruby | |
require 'socket' | |
server = TCPServer.new ARGV.first.to_i | |
loop do | |
client = server.accept | |
client.puts "Hello, world" | |
client.close |
This file contains 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
#! /usr/bin/env ruby | |
require 'socket' | |
Socket.tcp_server_loop(ARGV[0].to_i) do |connection| | |
connection.write("Hello, world\n") | |
connection.close | |
end |
- Twitter: @alinajaf
- Website or Blog: http://happybearsoftware.com/archive.html
- Company: Happy Bear Software Ltd. http://happybearsoftware.com
- Twitter: @alinajaf
- Website or Blog: http://happybearsoftware.com/archive.html
- Company: Happy Bear Software Ltd. http://happybearsoftware.com
This file contains 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
# We prefer composition over inheritance because inheritance couples type to | |
# implementation. | |
# | |
# Take a look at this example using inheritance: | |
class Duck | |
def initialize | |
@wings = Wings.new | |
end |
This file contains 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 this_method_takes_three_arguments(a, b, c) | |
# do stuff with three arguments | |
end | |
# Now imagine you had an array that contained the three arguments that | |
# you wanted to pass into the above method: | |
arguments = ['foo', 'bar', 'baz'] | |
# You could pass them in like this: |
This file contains 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
#! /usr/bin/env ruby | |
require 'csv' | |
#Initialised the hash to store the valence values | |
valence_index = {} | |
CSV.foreach("./ratings.csv") do |row| | |
valence_index[row[1]] = row[2] | |
end |
This file contains 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
#! /usr/bin/env ruby | |
require 'csv' | |
tweet = "Chocolate makes me happy, it makes my life wonderful" | |
tweetsplit = tweet.downcase.split(/\W+/) | |
valences = [] | |
tweetsplit.each do |i| |
This file contains 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
#! /usr/bin/env ruby | |
require 'csv' | |
tweet = "Chocolate makes me happy, it makes my life wonderful" | |
tweetsplit = tweet.downcase.split(/\W+/) | |
valences = [] | |
tweetsplit.each do |i| |