Open Side Menu Go to the Top
Register
OFFICIAL Ruby on Rails Thread!!! OFFICIAL Ruby on Rails Thread!!!

04-26-2013 , 10:48 PM
So I'm having an issue where Rails thinks my "all_players" variable is an array instead of a hash. As a result, it doesn't let me call ".keys" on "all_players". Here's the code:

Code:
  def rankings
    @top_80 = Team.all
    # loop through all teams, add each player and their rating to the hash, sort by rating, limit to 200
    all_players = {}

    @top_80.each do |team|
      url = "http://modules.ussquash.com/ssm/pages/leagues/Team_Information.asp?id=#{team.team_id}"
      doc = Nokogiri::HTML(open(url))
      player_names = doc.css('.table.table-bordered.table-striped.table-condensed')[1].css('tr td a').map(&:content)
      player_ratings = doc.css('.table.table-bordered.table-striped.table-condensed')[1].css('tr td:nth-child(4)').map(&:content)
      team_players_hash = {}

      for i in (0..player_names.length-1)
        team_players_hash[player_names[i]] = player_ratings[i]
      end

      all_players.merge(team_players_hash)

    end
    all_players = all_players.sort_by{|key, value| value}.reverse.first(200)
    list = all_players.keys
    render :json => list
  end
Essentially it uses nokogiri to scrape each team's roster and each player's rating and then sorts them. It doesn't seem to take issue with me trying to sort a hash but, now that I think about it, that might be a problem...

Thoughts?
OFFICIAL Ruby on Rails Thread!!! Quote
04-26-2013 , 10:49 PM
Quote:
Originally Posted by muttiah
The Rails 3 Way. It is in depth and good reference. Goes into some Rails internals.

BTW, anyone play around with Rails 4 with Ruby 2.0? Crap this stuff changes so quickly. How long until Rails 3 becomes obsolete. If you're starting a new hobby app is there any benefit to sticking with Rails 3?
This this this. I picked it up a few weeks ago and it's LEAGUES ahead of any other book out there. I basically only consult this now haha.
OFFICIAL Ruby on Rails Thread!!! Quote
04-27-2013 , 12:22 AM
Quote:
Originally Posted by Mariogs37
So I'm having an issue where Rails thinks my "all_players" variable is an array instead of a hash. As a result, it doesn't let me call ".keys" on "all_players". Here's the code:

Code:
  def rankings
    @top_80 = Team.all
    # loop through all teams, add each player and their rating to the hash, sort by rating, limit to 200
    all_players = {}

    @top_80.each do |team|
      url = "http://modules.ussquash.com/ssm/pages/leagues/Team_Information.asp?id=#{team.team_id}"
      doc = Nokogiri::HTML(open(url))
      player_names = doc.css('.table.table-bordered.table-striped.table-condensed')[1].css('tr td a').map(&:content)
      player_ratings = doc.css('.table.table-bordered.table-striped.table-condensed')[1].css('tr td:nth-child(4)').map(&:content)
      team_players_hash = {}

      for i in (0..player_names.length-1)
        team_players_hash[player_names[i]] = player_ratings[i]
      end

      all_players.merge(team_players_hash)

    end
    all_players = all_players.sort_by{|key, value| value}.reverse.first(200)
    list = all_players.keys
    render :json => list
  end
Essentially it uses nokogiri to scrape each team's roster and each player's rating and then sorts them. It doesn't seem to take issue with me trying to sort a hash but, now that I think about it, that might be a problem...

Thoughts?
sort_by returns an array. Also you need "all_players.merge(team_players_hash)" to be all_players = all_players.merge(team_players_hash)

edit: The way to debug this is to just step through the code in a console.

irb(main):008:0> thash
=> {"foo"=>1, "the"=>2, "bar"=>3, "sexy"=>4, "hand"=>5}
irb(main):009:0> ap = {}
=> {}
irb(main):010:0> ap.merge thash
=> {"foo"=>1, "the"=>2, "bar"=>3, "sexy"=>4, "hand"=>5}
irb(main):011:0> ap
=> {}
irb(main):012:0> ap.sort_by{|key, value| value}
=> []
irb(main):013:0>
OFFICIAL Ruby on Rails Thread!!! Quote
04-27-2013 , 12:28 AM
Quote:
Originally Posted by muttiah
The Rails 3 Way. It is in depth and good reference. Goes into some Rails internals.

BTW, anyone play around with Rails 4 with Ruby 2.0? Crap this stuff changes so quickly. How long until Rails 3 becomes obsolete. If you're starting a new hobby app is there any benefit to sticking with Rails 3?
Rails 3.1 + won't be obsolete for a long time. But if I were starting a pet project, I'd play with rails 4 for sure. Turbolinks are sweet honestly... and most of the main gems have rails 4 support.

I'd be excited about switching our app from 3.2.13 to 4.0 at some point at work, but I'm more excited about making it an angularjs app.
OFFICIAL Ruby on Rails Thread!!! Quote
04-27-2013 , 02:34 AM
Is anybody very familiar with the expensive 2-3 month real-life boot camps? If their claims are to be believed they have just about a 100% job placement rate, and Ruby jobs supposedly start at $70K-$90K. $10K for one of the courses seems like a no-brainer for somebody in my position, still looking to get back into the "real world" after poker (I have a service industry job). One of the schools doesn't even take payment until you get a job, and then they take 15% of the first year's salary. Acceptance rate in general is very low, seems like 10% or less for the ones I've looked at.

What are the negatives here? One would be if they're straight up scammers, which seems unlikely. Another argument against is that you technically could do this learning on your own and save $9.6K, but much of the value is going to be in the networking both with fellow students and the companies the school is connected to.

Thoughts?

Edit: Oh okay, for some reason I was confused about whether or not OP was in one of those classes. Now I realize he was. Results?

Last edited by Baltimore Jones; 04-27-2013 at 02:46 AM.
OFFICIAL Ruby on Rails Thread!!! Quote
04-27-2013 , 04:00 AM
Yeah, I'd also like to find out how the boot camp experience went and if it was worthwhile.


From what little I've read (mostly puff-pieces), it seems that employers actually like the coding boot camp grads. This is the exact opposite of "boot camp" MCSEs and CCNAs, who face real issues actually finding a job that requires their credentials.
OFFICIAL Ruby on Rails Thread!!! Quote
04-27-2013 , 05:43 AM
I don't see why people wouldn't want coding bootcamp grads. Assuming it isn't 2 months from total newb to not such a newb... you'd learn a lot of strong fundamentals from presumably intelligent instructors.

I mean we can't find any coders right now that aren't super senior and asking a ton or super junior. That more advanced junior position would be a quick hire from us, since I don't have a few months to help someone in rails who is tripping over themselves constantly.
OFFICIAL Ruby on Rails Thread!!! Quote
04-27-2013 , 09:27 AM
Quote:
Originally Posted by Nchabazam
I don't see why people wouldn't want coding bootcamp grads. Assuming it isn't 2 months from total newb to not such a newb... you'd learn a lot of strong fundamentals from presumably intelligent instructors.

I mean we can't find any coders right now that aren't super senior and asking a ton or super junior. That more advanced junior position would be a quick hire from us, since I don't have a few months to help someone in rails who is tripping over themselves constantly.
Just out of curiosity, what qualifies as super senior and asking a ton?
OFFICIAL Ruby on Rails Thread!!! Quote
04-27-2013 , 02:43 PM
Quote:
Originally Posted by alex23
Just out of curiosity, what qualifies as super senior and asking a ton?
People who have been shipping apps for 10+ years asking like 2.5% equity and 180k... just stupid stuff in reality. Not what we need either.
OFFICIAL Ruby on Rails Thread!!! Quote
04-27-2013 , 04:35 PM
The reality is that a top notch senior dev is worth about 4-5 average developers. And the super junior 60k/yr dev is a horrible salary in general. Top programmers are incredibly underpaid, mostly because programmers as a group will allow it. The average/incompetent devs suck up the remaining money. It's like with salary caps in sports. Lebron James is worth way way more than the max salary.
OFFICIAL Ruby on Rails Thread!!! Quote
04-27-2013 , 10:11 PM
Soooo, I'm in the process of interviewing now. We have an apprenticeship program where you get hooked up with a 3m internship, 3.5k/month, potential full-time afterwards. Everyone from prior class placed but some are TA'ing which isn't a real dev position.

There's no doubt you learn a ton, but a lot of places are PHP or something other than RoR so those convo's don't seem to go anywhere.

Having said that, I'm interviewing at least twice next week so we'll see how it goes. Will post updates here if ppl are interested.
OFFICIAL Ruby on Rails Thread!!! Quote
04-28-2013 , 02:02 AM
Do you want to tell us which school?
OFFICIAL Ruby on Rails Thread!!! Quote
04-28-2013 , 10:03 PM
Would rather not out myself, sorry (too much identifying info on 2p2)

On a different note, I'm running into a tricky issue. So I'm scraping a bunch of players and their ratings. I create a hash where the keys are the player names and the values are the player's ratings.

Here's the issue: a few players have "ratings" that are "Not a member" and Ruby puts these players first when I sort by rating. I want to remove these players entirely:

Code:
for i in (0..player_names.length-1)
        if (player_ratings[i].type == "float")
          team_players_hash[player_names[i]] = player_ratings[i]
        end
end
The player ratings are always strings (even when they're numbers) so I'm having a hard time distinguishing between the two in my code.

Any guidance?

Thanks in advance,
Mariogs
OFFICIAL Ruby on Rails Thread!!! Quote
04-28-2013 , 11:30 PM
I don't understand the question. Are you saying that non float ratings are invalid and you want to skip them?
OFFICIAL Ruby on Rails Thread!!! Quote
04-29-2013 , 12:20 AM
Yeah, when I scrape them they're strings. So a few players have ratings of "Not a member" while most have "4.928" or w/e. I only want the floats.

So I guess I wanna convert the ratings to floats and then exclude the ones that are nil?
OFFICIAL Ruby on Rails Thread!!! Quote
04-29-2013 , 06:31 AM
Quote:
Originally Posted by Mariogs37
Would rather not out myself, sorry (too much identifying info on 2p2)

On a different note, I'm running into a tricky issue. So I'm scraping a bunch of players and their ratings. I create a hash where the keys are the player names and the values are the player's ratings.

Here's the issue: a few players have "ratings" that are "Not a member" and Ruby puts these players first when I sort by rating. I want to remove these players entirely:

Code:
for i in (0..player_names.length-1)
        if (player_ratings[i].type == "float")
          team_players_hash[player_names[i]] = player_ratings[i]
        end
end
The player ratings are always strings (even when they're numbers) so I'm having a hard time distinguishing between the two in my code.

Any guidance?

Thanks in advance,
Mariogs

Are ratings ever 0?

irb(main):012:0> a=%w[1.0 asdf 2.23 foo 2.22]
=> ["1.0", "asdf", "2.23", "foo", "2.22"]
irb(main):013:0> a.each do |num|
irb(main):014:1* puts num.to_f
irb(main):015:1> end

1.0
0.0
2.23
0.0
2.22

so it could be something like

Code:
team_players_hash = {}
player_ratings.map! { |name| name.to_f }
player_ratings.each_with_index do |rating, index|
  team_players_hash[player_names[index]] = rating
end
Then just display something different if the value is 0.0?

Sorry I'm tired and not totally sure what you're asking, but that should get you on your way.
OFFICIAL Ruby on Rails Thread!!! Quote
04-29-2013 , 07:05 AM
Ya to_f is simplest because it return 0.0 for non floats.

Also could see http://stackoverflow.com/questions/1...id-float-value
OFFICIAL Ruby on Rails Thread!!! Quote
04-29-2013 , 09:25 AM
@muttiah,

Perfect, that worked thanks!

As an aside: in jQuery, I should be able to do something like:

for (var m = 0; m < received_data.length; m++) {
$('#rankings ol').append('<li>' + received_data[m] + '</li>');
}

Right?
OFFICIAL Ruby on Rails Thread!!! Quote
05-01-2013 , 02:26 AM
I'm a noob but couldn't you use regexp to just ignore any rating containing letters?
OFFICIAL Ruby on Rails Thread!!! Quote
05-05-2013 , 10:41 PM
I went through Dev Bootcamp (the first of these programs) this past fall after graduating from college. I'd gotten a finance degree and knew I didn't want to go that route, so I took an additional year of entrepreneurship classes at my school and had a startup go nowhere in that time. I knew I wanted to eventually be a founder and that learning to code was the best route to being useful (and well-compensated) at a startup in the meantime, and would be a huge help in bootstrapping something down the line.

I'm now working as a software engineer at an EdTech startup in SF. Pretty tied up with a project right now so excuse delays in responding, but I'm happy to answer any questions (can do a full-blown AMA if people think it makes sense), as there seems to be a fair bit of interest and not a ton of us who have gone through one of these programs (yet).

Last edited by TomfooleryU; 05-05-2013 at 10:47 PM.
OFFICIAL Ruby on Rails Thread!!! Quote
05-06-2013 , 02:34 AM
Quote:
Originally Posted by TomfooleryU
I went through Dev Bootcamp (the first of these programs) this past fall after graduating from college. I'd gotten a finance degree and knew I didn't want to go that route, so I took an additional year of entrepreneurship classes at my school and had a startup go nowhere in that time. I knew I wanted to eventually be a founder and that learning to code was the best route to being useful (and well-compensated) at a startup in the meantime, and would be a huge help in bootstrapping something down the line.

I'm now working as a software engineer at an EdTech startup in SF. Pretty tied up with a project right now so excuse delays in responding, but I'm happy to answer any questions (can do a full-blown AMA if people think it makes sense), as there seems to be a fair bit of interest and not a ton of us who have gone through one of these programs (yet).
Very nice. Questions:

1. Most of these programs imply that starting Ruby jobs are $70K-$90K and that you're pretty close to guaranteed a job after completing the 2-3 month bootcamp. How realistic is that starting salary and how easy will the job market be for people who have gone through a bootcamp?

2. Advice on getting in?

3. Any ideas on Plan B, for people who cannot get into one of the schools?

Thanks!
OFFICIAL Ruby on Rails Thread!!! Quote
05-06-2013 , 02:10 PM
Quote:
Originally Posted by Baltimore Jones
Very nice. Questions:

1. Most of these programs imply that starting Ruby jobs are $70K-$90K and that you're pretty close to guaranteed a job after completing the 2-3 month bootcamp. How realistic is that starting salary and how easy will the job market be for people who have gone through a bootcamp?
That range is very realistic *for SF*. 80k seemed to be the standard coming out of the brand-name bootcamps, though some go higher and lower and lately it seems like that number is creeping a bit higher. It'll be interesting to see the numbers as some of these get established in other cities and build awareness. Dev Bootcamp just opened a Chicago branch, App Academy a NYC one, and plus all the other assorted clones. I work with a guy that went to a different bootcamp and without fail one of us has stumbled upon a website for a new one every week. From my experience, outside of SF it's a tougher slog, both in terms of number of opportunities and salary.

Tougher to answer re: job market -- I had a fairly easy go of it, but I'm one of many who are watching all these bootcamps popping up and feeling pretty happy that I got in when I did, as at some point we'll hit saturation. I'd consider Dev Bootcamp, App Academy, and Hack Reactor (JavaScript-based) the premier programs at this point. If you go to any of those 3 and do well, you won't have much trouble in the job market.

These things aren't cheap, but it's important you also give yourself some financial runway for afterwards to make sure you find a good fit. I'd budget for 2 months after so you aren't overly rushed. If you do well you likely won't need that much time -- the market moves insanely quick at a lot of companies here, I went from intro phone call to offer in exactly 1 week. But I also saw multiple people who were definitely good enough to get 80k+ offers take lower-paying internships or lowball offers because they didn't have the ability to wait for something better. I ended up with a great offer at a company in a field I'm very interested in, but there was some waiting involved and I was lucky to be able to afford to do so.

While the market is great for developers in general, there are only so many junior positions to go around, and I'm not sure how kind the market is going to be for those who don't excel at these bootcamps in the future. I think it's extremely important to show up prepared. While the whole "Anyone can learn to code" and "Perfect for absolute beginners" stuff makes for great copy, the reality is you should be doing as much as possible on your own before you show up so that you can be near the top of your class and have a nice portfolio to show off when you hit the market. Which leads into your next question..

Quote:
2. Advice on getting in?
Have worked through the free online resources on your own. You'll show that A) you've actually done some coding and aren't just applying on a whim, and B) you've been able to grok some of this on your own. Have a compelling or at least logical story for why this is the right next step for you and why you think you're ready for it. For me it was the fact that I'd had that startup my last year of school, couldn't work very effectively with my developers, and realized in the process that I wanted to do the actual "making." I had 2 interviews, and after the first I emailed one of the staff saying, "Hey, I interviewed with so-and-so and they mentioned the prep material -- I'd love to get started on it, would you mind sending a list of the resources you recommend?" Show that you're a self-starter, a quick learner, but humble and coachable.

I'd recommend digging into Codecademy, Eloquent Ruby/Pickaxe book, Ruby documentation, and possibly even Rails guides to try to build something basic/Hartl tutorial, before applying. Then if you get in, put as much time as your circumstances permit into prep work. I remember being told that regardless of how much we did beforehand, we'd be either 0.1% or 1% of where we'd be at the end. Not sure how true that statement was, but if it was accurate that was one big-ass 0.9% of separation. There just isn't enough time to catch up to those who come in far ahead of you, plus the people who come in most prepared are going to be hardworking enough that they'll never give you the opportunity to outwork them to make up that ground. I wish I had come in more prepared, and most everyone feels that way. I went in having done the bare minimum that was given to us as prep material, whereas one of the top guys in my class had been focusing on learning full-time for 6 months before walking through the door on Day 1..needless to say we were on different levels when we left. Go in prepared.

Quote:
3. Any ideas on Plan B, for people who cannot get into one of the schools? Thanks!
Tough one. I'm very new to this (no technical background at all before DBC) so this is my only-somewhat informed take:
A) Think hard about if this is *really* what you want to do, as it will be a tough path. If so, your end goal should probably be to put together as good of a portfolio as possible. To that end:
-go through the online resources (Codecademy, Code School, Railscasts, etc.)
-read (Well Grounded Rubyist, Eloquent Ruby, Practical Object Oriented Design in Ruby, Pickaxe book, RSpec book, The Rails 3 (4?) Way, etc for starters)
-Don't be afraid of the documentation -- dig into the Ruby documentation and Rails guides/documentation
-Try to find a mentor and/or pay someone to periodically pair-program and/or review your code. One of the CEO's that came and talked to us mentioned he was learning to code by paying some college student that was a total whiz-kid like $40/hr. to teach him, just basic stuff, but definitely an affordable way to supplement self-learning and bridge gaps. If you can swing being in SF while you learn on your own, there are multiple Ruby meetups every week that are pretty beginner-friendly from what I understand, and someone there would be happy to help you hack on a project you're working on.
-Start building stuff you're interested in and lean heavily on Google and Stackoverflow for debugging errors and getting your questions answered. Try out different technologies and try to demonstrate proficiency with different technologies/focus on different aspects with each one, as one of the main things I've heard is employers want to see more than just a bunch of standard CRUD apps.

A couple blog posts I read last night and completely agree with, from guys who just finished the most recent DBC cohort:
http://eyeofthesquid.tumblr.com/post/49755884503/day-99
http://t.co/lW6lYCzucZ Eno is a baller. I actually haven't met him yet, but the guy finished up his Ph.D at Princeton just after finishing DBC and is now going to work at Pivotal Labs (top consultancy), following in the footsteps of another guy that did DBC in the summer.

Last edited by TomfooleryU; 05-06-2013 at 02:18 PM.
OFFICIAL Ruby on Rails Thread!!! Quote
05-07-2013 , 03:20 AM
Wow. Thanks for all the info.


Does seem like you got in at the right time. With all the bootcamps coming online, seems like the market will get flooded fast.
OFFICIAL Ruby on Rails Thread!!! Quote
05-07-2013 , 07:51 AM
Ok since I'm still a relative nub at this. Anyone want to take a stab at this?

I have an activity feed I've written for my site. The site consists of 2 user types. Researchers and organizations, each with their own namespace, layout, etc. Organizations will often broadcast messages to 100+ researchers, and 1 researcher might broadcast a message to multiple organization users.

I've also written an authorization system similar to how cancan works. It blacklists all actions by default, and then I have basically a whitelisted set of actions. Some are passed in blocks, which if evaluated to true permit the user, otherwise false.

Think

Code:
allow_action 'org/foo', [ :show, :create, :edit ] do |bar|
  current_user.can_do_something_to_bar?(bar)
end
This will allow the org/foo controller :show, :create, :edit actions based on the resource bar being passed in. So basically, exactly how cancan works.

Activities are stored in a table as a polymorphic association. So there are ~10 different controllers (between namespaces) that might create an activity. This activity at some point in the future might be shown to 2000+ people. They have to be permitted to view the action using the permissions model I show above.

What's the best way to approach this? We're using postgres, but I'm not against looking into some different backend for this system perhaps.

I'm currently looping through say 1000 items, checking permissions, and returning the first 10 permitted activities. I'm thinking it might be less painful down the road to just create 2000 database entries and have much more finegrained control over the query, which would be way faster obviously, but slower upon creation of activities (which might create 2000 database entries for a given activity).

Do I need to look into redis or something?
OFFICIAL Ruby on Rails Thread!!! Quote
05-07-2013 , 03:18 PM
Quote:
Originally Posted by BigPoppa
Wow. Thanks for all the info.


Does seem like you got in at the right time. With all the bootcamps coming online, seems like the market will get flooded fast.
Yea, thank you Tomfoolery.

I applied for two yesterday. Not DBC yet because I need to make a video. Can you share with us what your video was like (if you had to do one)?

Seems like at this moment in time, these opportunities are sort of a job market inefficiency. Meaning, they're one of the quickest and cheapest ways of getting a high paying job with lots of upside. Of course, the prerequisite is that you're smart enough and lucky enough to get in and do well. And the party may be essentially closed to newcomers (figuratively) within a year.
OFFICIAL Ruby on Rails Thread!!! Quote

      
m