Monday, 20 March 2017

Learning Ruby

Hey guys! 

I've been meaning to learn Ruby for years now, and finally did it this month! I started the Codecademy Ruby course a couple of weeks ago and finished yesterday, on the 19th. It felt great, because it was a perfect level of challenge so I was really learning but having a fun time, and when I tried it two years ago I only got 40% in. It's also really addictive -- I've been procrastinating by working on it, and it's been a bit all-consuming to the exclusion of my other things over the last few days (I did the last 53% of the Codecademy course over Saturday and Sunday). 

I've discovered that I love Ruby. It's a beautiful language -- so high-level it reads almost like English and genuinely fun to write in (especially with the colour-coding Codecademy and lots of other things give you). It's not as fussy about syntax as other languages I've tried like Javascript and Python (very few semicolons required, whitespace irrelevant). 

It's really intuitive and pretty forgiving -- it can do implicit returns in blocks, so you don't even actually have to type return(function). 

It does require correct syntax, but the correct syntax is pretty simple and there are multiple ways to do things. Plus, I've finally started sort-of enjoying bugfixing -- I'm very impatient, but the payoff feels good. Shout-out to Leon for help with learning to notice them.

The syllabus featured basics like setting variables and doing calculations, looping (while, for, times), control flow (if/elsif/else, unless), booleans (true, false, AND, OR, NOT), arrays, hashes (sets of key-value pairs), blocks, sorting, symbols, improving code, procs, lambdas, classes and instantiation and more. 

There were two projects I was proud of: one for a movie catalogue, and a simple bank simulator. 

The movie catalogue allows you to add movies and their star-ratings, update their ratings, display the movies in the set and delete movies from the catalogue. I liked that because it was the first project I'd done that actually seemed like a real, potentially useful app. I learned some interesting things as well to customise it -- for example, variables can't have spaces in them, they have underscores instead, but users are going to input spaces as spaces so I added something in the code to replace spaces with underscores so the program could understand them. To make sure the program understood inputs no matter what case they were in, I downcased everything. A nice touch I added was displaying the movies remaining in the catalogue after a user deleted something. 

Here's what it looks like when you delete Harry Potter from the catalogue:



There are also lots of other nice things, like it checking if a movie is already there when you try to add one, update or delete one and directing you accordingly. 

Codecademy gave lots of hints and direction, but it was still really cool making and debugging it and coming up with ways to test it. 

Here's the code:

movies = {
    enders_game: 5,
    zoom: 3,
    harry_potter: 4
}

puts "What would you like to do?"
puts "--Type 'add' to add a movie" 
puts "--Type 'update' to update a movie rating"
puts "--Type 'display' to see the movie ratings"
puts "--Type 'delete' to delete a movie"
choice = gets.chomp.downcase

case choice
when 'add'
    puts "Type in the name of a movie"
    title = gets.chomp.downcase
    title.gsub!(/ /, "_")
    if movies[title.to_sym].nil?
        
    puts "Rate this movie with a number from 1-5"
    rating = gets.chomp
    movies[title.to_sym] = rating.to_i
else 
    puts "This movie is already here fuck off"
end

when 'update'
puts "Type in the title"
    title = gets.chomp.downcase
    title.gsub!(/ /, "_")
if movies[title.to_sym].nil?
    puts "This movie is not here"
else
   puts  "Give new rating from 1-5"
rating = gets.chomp
movies[title.to_sym] = rating.to_i 
end

when 'display'
    movies.each do |movie, rating|
       movie = movie.to_s
       movie.gsub!(/_/," ")
       movie =  movie.capitalize
        puts "#{movie}: #{rating}"
end
when 'delete' 
    puts "Type in the title you'd like to remove"
title = gets.chomp.downcase
title.gsub!(/ /, "_")
if movies[title.to_sym].nil?
    puts "Error! Movie not found"
else
    movies.delete(title.to_sym)
     movies.each do |movie, rating|
       movie = movie.to_s
       movie.gsub!(/_/," ")
       movie =  movie.capitalize
        puts "#{movie}: #{rating}"
end
end
else
    puts "Error!"

end

Terribly sorry about the formatting, but there would've been a lot of screenshots otherwise.

My other favourite project was the banking app. That one sets up a checking account and lets you withdraw and deposit money and check your balance, if you have the right PIN. Codecademy gave more freedom on this one and it was really cool. I used private and public classes (e.g. private for pin and public for balance), which was a cool way to learn them. It was really simple to do the methods -- this project convinced me that I've learned a lot. Even though I don't have a clue of lots of things and haven't even thought about things like efficiency yet, I'm still proud of it. 

Here's the code:

class Account
    attr_reader :name
    attr_reader :balance
    def initialize(name, balance=100)
        @name = name
        @balance = balance
    
    end

private
def pin
    @pin = 1234
    end
def pin_error
    return "Access denied: incorrect PIN."
    end
public
def display_balance(pin_number)
        if pin_number == pin
            puts "Balance: $#{@balance}."
        else
        puts pin_error
        end
    end
public
def withdraw(pin_number, amount)
        if pin_number == pin
            @balance -= amount
            puts "Withdrew #{amount}. New balance: $#{@balance}."
        else
        puts pin_error
        end
    end
public
def deposit(pin_number, amount)
    if pin_number == pin
        @balance += amount
        puts "Deposited #{amount}. New balance: $#{@balance}."
else
    puts pin_error
end
end


end

checking_account = Account.new("Elle Loughran", 1800)


checking_account.deposit(1234, 200)

That results in "Deposited 200. New balance: $2000.".


Obviously, I have lots left to learn (and, uh, college and many other projects to work on...). I'm writing notes on Ruby now to remember syntax etc, then planning to do the Ruby on Rails course, maybe some HackerRank stuff, and then figure out what I can do on my own. 

But this has been a lot of fun, and I'm really glad I'm doing it. 

Tuesday, 14 March 2017

Lablinn Survey

Hi all! As you may know, myself and some college pals are working on starting up a community lab in Ireland so everyday people can do real science. We're calling it Lablinn. 
Temporary logo from logomaker.com

A few months ago, we were advised by Trinity Launchpad to do a market research survey and we did, so here I am with those results. 

When designing the survey, we really wanted to find out whether there was interest in science among people outside research careers, and whether they'd like to channel that interest into participation in a community lab, and if so, what that community lab should look and function like.

We got 103 responses in total; here's a summary. 

First, we asked how people interacted with science, and if they didn't, why. 


Of the 17 people who said they rarely interacted with science, 82.4% said it was because it was "intimidating/inaccessible".

When we asked about previous involvement with science, 31 people said they'd been involved in BTYSTE, 23 in CoderDojo, 5 in the Walton Club, 26 in Scifest, 21 in a university STEM outreach program, and 36 in none of the above.

Would you use a community lab?

Then we asked if people would like to get practically involved in science, and 92.2% said yes. 84.5% of survey respondents said that if community labs and training in how to do experiments were available, they would use them. 



We asked what areas people were interested in (ecology, environment, physics, chemistry, biology, psychology), and found that psychology was most popular (58 people), followed by Biology (53) and Physics (49). We asked what facilities they'd like, to know what level we should pitch the lab at. We asked when they'd use a lab like this, and Saturday got 70% of the vote. A plurality (42.4%) said they'd use the lab once a week, and most people wanted an even mix of curriculum and guided research. People wanted a wide range of topics covered in a curriculum. They said they'd pay €8 per use, on average (with values ranging from 0 to €80 and €400, which may well be a typo). 

Finally, we got some demographics. 

Our audience skewed young, likely due to the survey's having been spread on our social media -- almost half of participants were between 18 and 24, and another 42% were 13-17. 62% were female. 33% were in college while 51% were in secondary school. Of those who had gone to college, 31% did not study STEM subjects. 

Thoughts


  • We were happy with the high "Yes" rates for getting involved in science and using community labs. However, we recognise that people likely self-selected into a survey described as being related to citizen science. 
  • Our audience is younger, on average, than the people I thought of this for originally (adults who never got the chance to do science). I'd love to have people from 12 up involved, so it remains to be seen how more adult involvement would change the results. 
  • We were surprised that there was such a low proportion of Dubliners in the sample - 33% were from somewhere in the Republic of Ireland that wasn't Dublin, Cork or Galway. We do intend to set up in Dublin because that's where we're based, but after that we hope to expand.
In other Lablinn news, we have a website under development now, which I will link when it's ready, and are working on a business plan to show college. 

Hope you enjoyed that, and if you responded to the survey, thank you! At the moment we're looking to get in touch with somewhere where we can set up, so if you can help us swing that, let me know at loughrae@tcd.ie. If you have any information or advice about insurance/curriculum/something else we should watch out for, or are interested in being an adviser in general, let us know too!


Friday, 3 March 2017

Review: February 2017

Hi all! 

February has been a pretty cool month. 

It kicked off with the Trinity Science Ball on 3rd February at the Ballsbridge Hotel. The gang scrubbed up pretty nicely, I think. 



On the 8th, I visited UCD to hold an antibiotic resistance education workshop with Dr. Bergin's science education Masters students. It was scary but mutually beneficial so that was cool and I'm glad I did it. If you're reading this, Shane, thanks for having me in (and Mags for helping set it up!). 




I had a really great Valentine's Day this year thanks to the wonderful Leon. We started dating on the 11th and saw The Space Between Us in Cineworld on Valentine's, then he made me dinner. I've had an amazing time with Leon in general this month, so have some selfies. 10/10. 



I spoke at Dublin Tech Summit on the 16th about youth in entrepreneurship. I was on a panel with Jordan Casey and Niamh Scanlon. The gang and Leon came out to support, which was cool. 




In other speaking news, Zeminar posted a video of some highlights from their 2016 event. You can spot me at 1:31. 




A LOT of time this month has been spent working on my book. I was approached by a publisher about writing a book through a sort of agency I'm in a few months ago, and March 1 was the deadline to send off the first three chapters so I had a lot to do. I had no idea writing a book was so hard but it's on something important to me, increasing citizen involvement with science, so it's quite rewarding. No deal has been agreed yet, so I can't say any more for now. Whatever happens, definitely a learning experience. 

College has continued to be intense, full of tough work but great fun with friends and the whole atmosphere. I just love being around college and hanging out with people and knowing there's always something on. It's so vibrant. I had loads of fun with the gang and lots of sleepovers this month as usual. I appreciate them so much. 

It's only a month to the European Youth Summit in Budapest I'm helping to organise as a council member of the Youth Platform of the European Talent Support Network, so we've been doing lots of work on that. I've also had meetings with the gang and college staff about the community labs idea. At the start of March, I thought of a name that I actually like and isn't taken: Lablinn. I like it because it's short, pretty easy to spell, not taken and relevant to the meaning ("lab" + "with us" in Irish). It's similar to GrĂ¡inne's idea of Saotharlinn (Irish word for lab but the last syllable replaced by "with us"), except pronounceable by non-Irish speakers. 

To end the month, the gang, Leon and I jetted off with DU Physoc to Edinburgh for a couple of days. We did a physics walking tour, visited an observatory and had good banter (and some sleep deprivation!). 



Honestly, there's probably stuff that I'm forgetting, but all in all it was a cool month. 

For March, I'll have a lot more time to do stuff I've been neglecting because of book deadlines, so I'm planning to do more for college, Lablinn, antibiotic resistance and perhaps reading and Ruby. 

Thanks for reading!