Well, I missed my "blog post a month" by a week or so, but I finally got an idea for a blog post! A few weeks ago, I finally made it back to Arlington Ruby (as a part of me trying VERY hard to start going back to meetups and getting re-acquainted with the community I love so much) and learned about making chrome extension from Casey Watts. Nope, it has nothing to do with Ruby but it was really interesting to learn about. There were two components of this presentation that I enjoyed. The first was the actual technical content of learning how to do a chrome extension and the second was the presenter's teaching methodology.
Let's start with the technical content. Did you know that making chrome extensions is super easy?! In about 30 minutes, we already created like 3 chrome extensions. There are 2 things we learned... bookmarklets and actual chrome extensions. According to the presentation, a bookmarklet is "a bookmark that runs javascript on the current page instead of taking you to a new page" (like a regular bookmark would).The basic premise of both bookmarks and chrome extensions is altering the "location" field on the "add page" form in order to execute the javascript.
An extension is only slightly more complicated than a bookmarklet... at least the examples we did during the meetup, but i'm sure that this is where it can get really complex with more sophisticated ideas. An extension has a manifest.json file which outlines the name, version, description, javascript files (or html or css) you want to pull in, and where you want the extension to work.
Finally, we spent a little bit of time talking about examples of chrome extensions people might want to build, how to distribute and deploy a chrome extension, and some security things to keep in mind when either downloading or deploying an extension.
As I mentioned earlier, I still assume that making a more complex extension is more difficult. It seems like it could potentially involve a significant amount of code and because of how the code is pulled into a chrome extension, could be complicated to mentally keep it all straight and organized. All in all though, I had no idea that building an extension was so straightforward and I can't wait to think more critically about extensions I use or actions that might make sense to make an extension for.
The second part of this presentation that I liked was how it was taught! It is really difficult to teach something technical without really knowing the group of people you are teaching. It is even more difficult to do this when you know that there will be a pretty diverse level of skills in attendance as well. Casey did a great job! He started by framing what we were doing and what the end goal of the "lesson" was. He then had us pair up, which enabled everyone to work with someone on the parts of lesson that were self-guided. It was great to bounce ideas off of someone else and, we all know that often at technical meetups it can be difficult to meet other people. The guide that he walked us through was really clear and easy to understand. You could move through it faster if you were more experienced or slower if you were less so. It was a lesson but felt very laid back, informal, and fun. Finally, we worked independently in small chunks of time but then came together in between those times. When we came together as a group, Casey made sure we were all paying attention and as a result I think there was much more group participation than if he had just hoped that everyone was engaged instead of really enforcing that they do so. I feel like everyone left having met/spoken to someone AND actually having learned a bit more about chrome extensions.
Showing posts with label code tools. Show all posts
Showing posts with label code tools. Show all posts
Friday, December 25, 2015
Monday, June 16, 2014
One Giant Post about Ruby Nation
This year again, I attended Ruby Nation. This year was great because I actually understood what was going on!! Admittedly, I took better notes on the second day than on the first because I was speaking on the first day but most of the session I went to were really great. Also, I apologize in advance because this is just one giant post, as opposed to breaking it up by session which I usually do after conferences.
The first session was talking about ruby and government with Sarah Allen. She was recently a presidential innovation fellow and spoke a bit about the interesting things she was doing and the really interesting digital data issues that the Smithsonian system has. Sarah brought up some really interesting thoughts about rails in general. One of the most interesting (controversial?) things she talked about was making Rails more accessible. She talked about other platforms like Drupal or Wordpress and the ease of adding certain functionality or widgets there. These are things that Rails doesn’t have. It isn’t super accessible because you don't have the same sort of ability to add widgets or different features. Her point was that potentially being able to make it easier to add widgets would make us more effective programmers and that by doing this, we wouldn’t have to re-work things or add simple, commonly-requested functionality on a regular basis.
Her talk closed with three interesting points to think about. First, framework leads to language. Second, what if we could add UI features at runtime, and what would that look like? And third, non-developers are co-creators so how to we give them a more active role in rails.
The second talk was by Eileen Uchitelle and was about CRUD and ActiveRecord. I thought this talk was fantastic, although admittedly got a little lost in the middle. The premise of this talk was that when we assume activerecord is magic and does all these magical things, we end up not paying enough attention to our code and to the actual SQL queries and how they’re functioning. Eileen then went through an example using each of the CRUD methods (create, read, update, delete) and went through ways that the queries could be better, faster, and more effective. For example, in create, she spoke about batch insert and in read she talked about using pluck. Her slides are super clear and definitely worth a read.
The third session was Terence Lee speaking about working with Ruby. He spoke a lot about how to commit and encouraged everyone to get involved with fixing ruby, committing, and getting involved with the core team. I learned that .to_f is to float. Floating objects “represent inexact real numbers.” He talked about the future of ruby being focused on trust, transparency, and onboarding.
The fourth talk was given by Davy Stevenson on Ruby as science, art and craft. I thought this talk was really great and looked at code from different perspectives and points of view. She started with science, looking at algorithms and talking about what complexity looks like. Davy went through a variety of big O notation types like linear, quadratic, exponential, and factorial. She described an algorithm as a set of instructions that will solve a particular problem… a great definition for someone who isn’t a math person. She then looked at the convex hull problem and demonstrated different approaches through different algorithms that connect the points and show this convex hull in different ways. I won’t go into them here, but if you want to google them a bit further, she discussed brute force, gift wrapping, and monotone chain algorithms.
Then Davy talked about art. The art part was lots of imaged of different interpretations of art and thinking about them. The best part of that segment for me was a quote she mentioned from @sferik where he said that programming is about building powerful things in simple pieces.
Finally, Davy discussed craft taking the idea of apprenticeship and artisan abilities and connecting it to code. She said we write code to enrich our own lives and the lives of the people around us and then showed us examples of beautiful code. Definitely take a look at the slides to see what people consider as beautiful code.
After this was lightning talks!! There were a few talks… one on muscle driven development, which talked about health and treadmill desks. One on debugging, another on language and thinking about how the language we’re using shapes how we look at solutions. A fourth on Ruby For Good which is going to be awesome and everyone shold check out. The fifth was on the Angelo gem and the last talk was about how you shouldn’t do ops as a dev.
From here, we went into the tracks. Again, the talks today, I won’t do justice because I wasn’t focusing as much as I could/should have been but at hopefully I can provide some notes. The first session I went to was JohnPaul Ashenfelter’s Machine Learning talk. He did this at RailsConf as well (a longer version). It was really interesting. Basically, he spoke about different gems and things developers could use to learn more about the users. First, he talked about the sex machine gem which isn’t perfect but can help determine the gender assignment of your user base. Second, he discussed free geoip to show location awareness. After that, he got into clustering a bit and looking at clusters in order to help determine patterns. He walked through the ai4r gem which puts people into clusters and then calculates the centroid (centroid being the center of the random clusters) and finally, it loops through to see if users are closer to the center or their cluster or another cluster. This enables you to see what cluster people are in which is super helpful is your clusters show, for example, what tier users are paying for in your system. Alternatives to this can be hierarchical clusterers or divisive hierarchical clusterers. Finally, he talked about a gem called linalg and how you can use it for collaboration purposes (I think… my notes get a little sketchy here).
After that, I went to an ActiveRecord workshop with Dave Bock. This workshop is fantastic, but very hands on so not many notes. Basically, Dave has a handful of scenarios that each table has to discuss and talk about how they’d architect them. Really helpful for continuing to learn about ActiveRecord, associations, and modeling.
The next talks I went to was about tests and having a messy test suite. Presented by Chris Sexton and Aaron Kromer, this talk was great. They went through testing best practices and showed examples of clean, clear test structures. Some highlights were that you shouldn’t deeply nest state in your tests and you can fix this by creating contexts, this way the state is top level and you can test everything. Tests should help organize and expose state. Class declarations should tell what behaviors to test. Finally, the two most important pieces of advice were to prioritize what’s most important to test and then iterate towards that goal and make your tests better as you work towards your goal.
The last talk of the day was about sidekiq. I don’t have a ton of notes from this talk as well but presented by Mike Subelsky, it was a great walkthrough of sidekiq and what you can tell from the dashboard when running it.
Day 2
I was able to pay more attention on day 2.
Day 2 started with Jim Gay talking about east-oriented code. This is a pretty cool concept that operates under the principle of tell, don’t ask. The core of it is that queries travel west and commands travel east. The talked touched on the law of Demeter and talked about east oriented code being different than that. There are four things to keep in mind with east oriented code. First, always return self. In this way the method is prevented from querying, can only tell. It leads to polymorphism, duck typing, and encapsulation. Second, factories are exempt form this. Third, always follow rule 1. And finally, sometimes break rule 3. After rule four, he showed a really interesting rails erb template that described this and walked through it. I left this talk sortof understanding everything but definitely would love to take a look at the code examples and slides in order to comprehend it all a little further.
The second talk I went to was on two programmers in one. I loved this talk by Jano Gonzalez. He talked about how each of us as developers are a little hacker and a little thinker. The hacker wants to get things done, and quickly which can sometimes lead to a maintenance nightmare. The thinker thinks about maintainability, abstractions and all the different layers but sometimes can get away from the problem that they’re trying to solve and can have analysis paralysis. He then told his story about going from hacker to thinker and coming to a good balance with both sides when using ruby. Jano spoke about how the hacker is useful for exploring new territory but the thinker is good from defining components and acceptance criteria. Developers need to deliver value but also diminish technical debt and it’s all about the balance between the two. My favorite part of the talk was when he spoke about the 3 stages of learning from Martial Arts. There is Shu, Ha, and Ri. Shu is when you’re new and you follow all the rules. Ha is when you move on and start adding your own knowledge and breaking some of the rules, and Ri is when there are no rules to follow and no rules to break, you just do it.
After that was a talk on google glass by Lance. This was a fun talk and one I just sat back and enjoyed since I’m not really developing with google glass but was just curious. Lance talked about apps as service layers. He then went on to discuss some of the glass specs, things that are great about glass and things that still need to be fixed. He then talked about the Mirror API, which I still have to check out, and how you don’t need to know android in order to program for glass. There’s a concept of static cards which add functionality and a new(?) tool called WearScript which is a bit like phonegap for glass.
Interesting talk and really fun to just see some of the programming side of glass.
Sam spoke about the anatomy of a mocked call which basically involved doing a deep dive into what a mocked call means technically with rspec, using their internal mocking library. He started by talking about testing and why you test/TDD. His main points were that TDD’ing helps programmers create a mental model. It helps them think through what the code does and then because things change as you program, it helps keep that mental model intact and keeps you on track with the problem you’re trying to solve. In short, tests force behavior.
The first part of this deep dive was discussing stubbing. Stubbing is basically faking a response to a method. Moching enables you to verify the collaborations between objects by testing the methods that get called. It creates a mocked expectation. so in the example
it “does something” do
allow(foo).to receive(bar)
expect(foo.bar).to eq (nil)
end
The allow is actually allow= allowanceTarget.new
allowanceTarget is a subclass of the TargetBase and calls delegate_to on TargetBase and, with a setup_allowance, TargetBase defines TO as an allowancetarget enabling .to to exist as a matcher.
Then there is receive which is also often used as a matcher. Once receive is set up as a matcher, similar to how to is set up as a matcher above, then receive#setup_allowance creates a mock proxy. A mock proxy is an object that manages the metadata of mocks and stubs on the object in the lifecyce of a test. Calling add_stub on this proxy sets up a emthod double which saves the original implementation. Then calling foo.bar (the stubbed implementation) sends a message to the method double which sends a message to the proxy which invokes the stub which returns a value (gosh, I hope I got that right!).
When you run a test, rspec also runs setup and teardown before and after the test and at the end of the test, the teardown resets everything. This reminds me a little bit of how testing work in ember with quint.
Okay, now onto mocks. For explaining mocking, sam worked through the same example but using expect(foo) instead or allow(foo). In this case, expect = ExpectationTarget.new and goes through a similar process as the stub did, except this time with a mock. Here, once you have the proxy, the proxy callbacks checks to make sure the arguments are valid and the proxy raises if a mock wasn’t called.
Finally, I can’t remember at what point sam mentioned this, but during his talk (or when someone asked a question about using spies instead of mocks), he mentioned spies so now I know what spies are! Spies are whenever you do a a stub, it will record the information so you can set an expectation at the end of your test instead of at the beginning. Basically, you can set a spy to collect all sorts of information from you and when the object returns you can ask it questions about it’s experience. The way I envision this is similar to what the Dorothy’s were trying to do in Twister. In Twister, the tornado chasers weren’t able to learn more about tornadoes because they weren’t able to see or understand what was happening inside the tornado. They came up with a way to release thousands of little sensors into the tornado to collect all the information and have them transmit the information back so it could be recorded and studying. From my understanding so far, this is similar to what spies do.
Evan is great. He’s got so much experience and his talk was on remote pair programming. Now, I work remotely, so I’m familiar with a lot of the tools, but his talk was less focused on tools like madeye, nitrous, and screen hero and more focused on command line tools. He spoke a lot about vim and emacs (which made me really want to learn vim again… one day I’ll get around to that). He also spoke about tmux, ssh’ing into machines, and a lot of really interesting concepts. He spoke about how his remote pairing stack has changed over the years and different combinations of things he’s tried which allows people to pick any of these tools and configure it to their remote pairing liking. Overall, an interesting talk and some exposure to remote tools I hadn’t thought about in the past.
Mark spoke about wyriki which is a project that Jim Weirich was working on when he passed away. I’m gonna be honest and say that Mark lost me pretty early in his explanation but this is what I got. Wyriki is a different way to architect rails applications. It creates new structures of runners in between controllers and models which allow someone to isolate the business logic from everything else. The rest of my notes on this are sparse and it’s pretty obvious I got lost in there, but I think the core takeaway was thinking about different ways to structure apps, so not fat model, skinny controller and not everything in moderation but how to really separates different types of business logic in your apps.
Next up was Justin’s talk on breaking up with your test suite. I took frantic notes on this one and listened intently, but eve so I’m sure I missed stuff. Also, these slides were great and super understandable so check them out. So first was talking about why we should test. there were 8 or 9 ultimate reasons why code should be tested which fall into two essential categories. First, you can gain confidence from the test and you can gain understanding of the code through the tests. BUT he started by discussing that we should question before we test. When thinking about tests, we should think about the purpose, rules, and structure and we should expect that within our test suite these three items should be immediately clear to anyone looking at it. If we cram lots of different goals and motivations into each test, the test becomes unclear. The rules become debatable, the purpose becomes hazy, and the structure ends up being ad hoc instead of uniform. Every test suite should promote one type of confidence and 1 type of understanding. So, here are some different suites and for each suite Justin went through the user, what the understanding and confidence were, tips, and warning signs.
First up was the safety suite. The safety suite is for the browser It checks does the app work and is our product simple. If the tests do not fit inside 30 minute or if you can’t write a new test within 30 minutes then your product probably isn’t simple. These tests shouldn’t see the internal apis. They should bind to what is visible by the user and they should enforce a fixed time-budget. The warnings here are that failure from refactors are often false negatives here and that human intuition overvalues realistic tests. On this type of test suite, numerous releases and branches can get expensive and there is the idea of the superlinear slowdown meaning that the bigger the system, the slower the tests.
Next comes consumption tests You should verify behavior and demonstrate usage with these types of tests. The user is the repo’s customer and they are used to verify what you, as the programmer, is directly responsible for. It says, is this code usable? If it’s hard to test, it’s probably hard to use. For these the module boundaries should be meaningful beyond testing (ie- these things talk to each other so they should be tested together). It should fake all the dependencies. It should exercise the public, not private apis. And finally, it should be organized by the consumer’s goals and outcomes. Warnings-wise, these tests need to be fast and this is the only part of the suite that tells you “you just broke something”.
The next tests suite are contract tests. Contract tests are used by us. They represent our interests that live in someone else’s repo. It leads to faster feedback making sure that something in the system that someone else is working on, doesn’t break something you’re working on. For these, they should be written for first party dependencies and follow the same rules as consumption tests. These are NOT a replacement for actually going and talking to your fellow dev about what they’re working on.
Next is TDD. So, so far, in all these tests suites, none have talked at all about the design of the code. The main value in TDD-ing is to discover tiny, consistent bit that help with big projects. The user is someone concerned with implementation details and the inputs and outcomes. These tests are a sounding board and enable you to have confidence in building small things and learning about what roles our code is playing. Here, he showed a cool chart that had interesting structural points related to putting queries on the left, logic in the middle and commands on the right… reminded me a bit of east-oriented code structures. He also stated that commands and queries should have very little logic. The warning here is that discovery tests yield small disposable units so be okay with throwing stuff away.
Next are adapter tests (whoever knew there could be so many different kinds of tests suites!) These tests exercise the adapter API under just realistic enough circumstances. It warns us of outages or API changes. These tests also reduce the cost of swapping dependencies later. For these, don’t test them first and trust the framework. These are similar to contrat tests but contract tests improve communication between colleagues whereas these tests improve the feedback between your code and the 3rd party code. Last warnings are that these tests can be slow and outside of your control and that they can be tricky if you’re using some sort of CI.
Phew! that was that talk.
One note is that my confusion still lies a bit in integrating all of these different types of tests. Should an apps test suite have all of these things? What does it look like structurally? Are they in the same files or different files? But I think the idea of thinking about all of these different suites and the goals of tests and testing is pretty cool.
Production code analysis by Dan was a great talk. Dan talked about code cleanup and how to look at a monorail (single large application) and refactor/delete effectively. You want to look at what code is being run to allow for good code cleanup and that lots of these monorails have dead code. Some overarching tips are to celebrate clean up commits as a team and to start by finding large unused code sections by finding unused actions. There are a handful of tools he talked about to help find this dead code. First you can use new relic which can show you for any given endpoint, how often is it being hit and then you can do a route check to see what routes are completely unused. You can also use tools like graphte, statsD and redis to find unused actions. For example, statsD is pretty easy to implement, has lots of info from Etsy’s blog, and can be used to see both timing and emdpoint information. You can look at background jobs in redis to see which jobs aren’t being triggered at all and what events are related to those jobs.
For mailer, you can see which is the most popular and least popular mailers by hooking statsD into active mailer. Finally, if you find the actions not being triggered, you can often delete the related views that aren’t being rendered any more.
Another good place to look is at translations. Which translations are in memory but aren’t being used anymore? Use the gem humperdink to track these translations. Finally, you may have two methods that are doing the same thing in your code. For this, learn which is best by wrapping the methods in a split. Wrapping them in a split and tracking them with statsD will tell you which method is faster or more effective and allow you to make data-driven decisions.
Lastly, Dan talked about logs. Logs are great for cleaning up code. Logs should be searchable and in one place. You should try to standardize the log format and multiple apps that communicate should be in the same system. Once you’ve got good logs, you can do log queries or check out endpoints to see what’s arriving to them. For this, check out the gem imprint.
Russ Olsen spoke about going to the moon! Wait for this talk to come out on video. I had to leave about 15 minutes early which was a bummer but he’s such a good storyteller, I was on the edge of my seat the whole time.
Saturday, May 31, 2014
Interesting Reads 5/24 - 5/30
There's a whole boatload of good stuff this week! First, There are links to three more talks from RailsConf. Then another talk about leveling up. After that a few interesting blog posts. Finally, agood explanation of dotfiles.
Enjoy!
Sean Marcia is awesome and this is his great talk about Bees and saving the world: http://www.confreaks.com/videos/3318-railsconf-saving-the-world-literally-with-ruby-on-rails
Harking back to my management days a bit, this is a good talk about decision making and team working in tech: http://www.confreaks.com/videos/3487-railsconf-workshop-teamwork-ain-t-always-easy
Okay, I think I've only made it through 5 databases so far but interesting overviews: http://www.confreaks.com/videos/3374-railsconf-an-ode-to-17-databases-in-33-minutes
Another talk, but not from RailsConf, about taking your engineering role to the next level: https://www.youtube.com/watch?v=lgxEmiMJVq4
Information anxiety and how to parse through what you need/want to learn: http://blog.codinghorror.com/keeping-up-and-just-in-time-learning/
Great post on mentorship: https://medium.com/theli-st-medium/have-some-coffee-9e468d958e77
Interesting post on coding principles every engineer should know. Do you agree? Which would you add?: https://medium.com/on-coding/coding-principles-every-engineer-should-know-b946b48cc946
Lastly, this week I had to set up my first new computer for development. A friend passed this along to me. It's a great step-through of dot files which, I think, seem super intimidating, but aren't IRL: http://code.tutsplus.com/tutorials/setting-up-a-mac-dev-machine-from-zero-to-hero-with-dotfiles--net-35449
Enjoy!
Sean Marcia is awesome and this is his great talk about Bees and saving the world: http://www.confreaks.com/videos/3318-railsconf-saving-the-world-literally-with-ruby-on-rails
Harking back to my management days a bit, this is a good talk about decision making and team working in tech: http://www.confreaks.com/videos/3487-railsconf-workshop-teamwork-ain-t-always-easy
Okay, I think I've only made it through 5 databases so far but interesting overviews: http://www.confreaks.com/videos/3374-railsconf-an-ode-to-17-databases-in-33-minutes
Another talk, but not from RailsConf, about taking your engineering role to the next level: https://www.youtube.com/watch?v=lgxEmiMJVq4
Information anxiety and how to parse through what you need/want to learn: http://blog.codinghorror.com/keeping-up-and-just-in-time-learning/
Great post on mentorship: https://medium.com/theli-st-medium/have-some-coffee-9e468d958e77
Interesting post on coding principles every engineer should know. Do you agree? Which would you add?: https://medium.com/on-coding/coding-principles-every-engineer-should-know-b946b48cc946
Lastly, this week I had to set up my first new computer for development. A friend passed this along to me. It's a great step-through of dot files which, I think, seem super intimidating, but aren't IRL: http://code.tutsplus.com/tutorials/setting-up-a-mac-dev-machine-from-zero-to-hero-with-dotfiles--net-35449
Sunday, May 25, 2014
Interesting Reads 5/17 - 5/23
Lots of really great links this week. There are a few more RailsConf talks since I had a chance to watch a few more of those this week. Some great posts on terminal and keyboard shortcuts and tricks, and some fun team-related posts.
Enjoy!
Amazing tips and tricks in this post for keyboard shortcuts.
AND amazing tips for terminal in this one.
Leading a team is really hard. Jessie does a great job talking about some of the ways to actually be a GOOD manager.
Some great tools and thoughts for thinking from railsconf.
Love this! https://speakerdeck.com/aviflombaum/20-things-i-love-about-code
A really interesting talk about imposter syndrome
I've always looked at the stages of group development in the context of leadership groups and immersion experiences but this is an interesting post on the high performing team dynamic in programming
Does the size of a team affect the quality? This post talks about some of the data behind it.
Enjoy!
Amazing tips and tricks in this post for keyboard shortcuts.
AND amazing tips for terminal in this one.
Leading a team is really hard. Jessie does a great job talking about some of the ways to actually be a GOOD manager.
Some great tools and thoughts for thinking from railsconf.
Love this! https://speakerdeck.com/aviflombaum/20-things-i-love-about-code
A really interesting talk about imposter syndrome
I've always looked at the stages of group development in the context of leadership groups and immersion experiences but this is an interesting post on the high performing team dynamic in programming
Does the size of a team affect the quality? This post talks about some of the data behind it.
Monday, May 12, 2014
Setting up Aliases
For months and months I’ve heard people talk about setting up aliases and profiles and all these custom configs for their computers. I’ve done some basic googling but have stayed away from setting things up because I hadn’t found any simple, easy posts and I had this vision that this whole “set up” thing was super complicated. Guess what? It’s actually ridiculously simple. This is what I get for being too embarrassed to ask about something for an extended period of time.
What are aliases? Aliases are basically shortcuts for things you type all the time. The same way that hotkeys work to open up programs and execute certain actions you find yourself constantly using, aliases do that for your terminal.
The best place to start is to think about what you type all the time. For me, I type “git status” over a dozen times a day, so that was aliased to gs. Chris suggested that I set up an alias to open my bash_profile file so that I can quickly add more aliases as I discover what I type the most. As I mentioned, doing this is super easy.
1. Open up your bash_profile file
2. Set up your aliases by typing
alias gs=“git status”As you see, the left of the = is what you want the shortcut to be and the right of it is what the shortcut stands for. Once you’re got all your aliases in, quit terminal and reopen it to start using them.
Besides aliases, I also learned from JP about using homebrew more effectively. Homebrew is a package manager and with homebrew you can add different packages including git bash completion which allows you to tab to complete things like git branch names and more.
The final piece of this setup is naming your computer. Apparently this is a thing. I’ve got my Disney princess naming convention for my servers so now I need one for my computer(s). I’ve decided on 80’s cartoons starting with the very-applicable “penny”. I look forward to naming future computers Brain, Jem, and, I’m sure, a number of CareBears.
Here's a good article for additional reading on setting up git aliases: http://robots.thoughtbot.com/streamline-your-git-workflow-with-aliases
Friday, April 11, 2014
Interesting Reads 4/5 - 4/11
Some really good reads this week on a variety of different topics.
Enjoy!
Read on effective flows
Conference proposals and a good step-through process to create your proposal
Really in depth thoughts on crafting a talk
Improv and coding
Scientists and Code reviews
Write Code Everyday. I talk about this a lot in regards to learning to code. This post breaks things down really well.
Enjoy!
Read on effective flows
Conference proposals and a good step-through process to create your proposal
Really in depth thoughts on crafting a talk
Improv and coding
Scientists and Code reviews
Write Code Everyday. I talk about this a lot in regards to learning to code. This post breaks things down really well.
Monday, March 31, 2014
Snappy Means Happy
Matthew Beale gave us a lot to think about and showed me a bunch of tools I had no idea existed in this talk about performance. He started by giving us some good things to think about… mainly, what does fast mean to you? He showed different speeds and what that would mean in terms of actually viewing an app (ie- animations, etc.). You can use that “fastness” scale to then look at your code and see what piece is taking the longest. Is it the network? The javascript? Or the render? Thinking about each of these and looking at times for each part help you narrow down what tools to use and what part needs to be made snappier.
When you’re ready to dive into performance and have pinpointed what part needs working on, then you can move on to the recommended methodology. This is 1) gather the facts and isolate the problem. 2) analyze and theorize about what’s going on. 3) change a single thing… if you change a bunch of stuff and performance is better then you don’t actually know what made the difference. And 4) confirm the theory. The example Matthew used was loading the ember.js website on your phone.
So, first you need to reproduce the immobile latency reliability… in this case you can use slowyapp, Charles, or network line conditioner. You then create a clean browser (this was also a new concept to me) which means you have no extensions, a private window and therefore nothing interfering with the site you’re working on. Then you measure and analyze in the network inspector. In that inspector you can check out the timings tab which gives you a bunch of information.
Part of that information shows us that if you look at the timeline, you can see the load order of things and how long each element is taking. Here, you end up being able to move a script tag which makes the page’s load time much faster.
Next, we looked at “janky” animation. To solve this issue, you first need to understand browsers, then you measure with the timeline tool (another one of the inspector tabs). You can highlight a specific section to get more information about it. You can look at frames which show how long something takes to get to the screen. Green = paint, yellow = javascript, clear = upload to GPU, compositing. AND THEN, render console has a bunch of additional tools you can use to record and generate the data.
If you’re a little lost on where all these tools are and how to access them, the slides show it all pretty clearly.
Also, at this point in my notes I had written “OMG, so many tools!” which I thought was worth sharing here.
In this case, the solution to the issue is a webkit transform that keeps it on the GPU and then uploads the whole thing to the graphics card. By adding a Z translation to the animation, it forces the GPU to say this is 3D and should be put on the graphics card.
Finally, we talked about ember.js property change notifications. For this methodology, first you need to understand observers and then look at the profiler. Observers are synchronous and fire when a set thing occurs. There are two options
.setProperties or Ember.run.once. Then you look at the profiler. The profiler has processing and memory. You run a profile and get back information in form of a flame chart. A flame chart allows you to see the stack that is being run. In the list view you can use the profiler to pinpoint the issue. Here, you refactor to create a buffer instead of pushing items into an array which fires 1 change notification instead of many.The important thing to remember here is to have a methodology to solve issues, to remember that web performance does not equal ember performance and that there are a heck of a lot of awesome tools you can use to help you out.
Tuesday, March 18, 2014
So Many Random Learnings
I love learning and in the past few weeks, I've learned so much!! In lieu of a more organized post on this stuff, here’s a random smattering of what I’ve learned the last few weeks.
Debugging (with capybara): insert a
Alfred workflows are amazing. I’m trying to train myself to use my mouse less. My wonderful mentor suggested that instead of going cold turkey on the mouse, I should start by getting good at just a few things. So, I’m starting with Alfred workflows and trying to get better at not using my mouse within my text editor (sublime).
Alfred workflows that I have set up include spotify, dash, and being able to search for any file or folder on my computer. I’ve got the git workflow partially set up.
In Sublime text, one of the most useful things I’ve learned recently is
Option and highlight lets you highlight the first letter of each line
From the command line putting
When squashing commits (which means making multiple commits into one commit), you always ‘s’ (squash) the second one
Gem railroady produces a UML diagram of your code structure
Kill process… somehow I created a connection with a server and then I created a second connection with a server and then couldn’t get one of those connections to close!
Then
Ls –lM lists everything in list formGit rebase –i sha is what you use in order to squash commitsGit rebase master… I’m still learning the process and exactly how to troubleshoot this but it seems standard in worksflows that require pull requests and it’s pretty interesting to solve merge conflicts.Debugging (with capybara): insert a
save_and_open_page to see what page/path opensAlfred workflows are amazing. I’m trying to train myself to use my mouse less. My wonderful mentor suggested that instead of going cold turkey on the mouse, I should start by getting good at just a few things. So, I’m starting with Alfred workflows and trying to get better at not using my mouse within my text editor (sublime).
Alfred workflows that I have set up include spotify, dash, and being able to search for any file or folder on my computer. I’ve got the git workflow partially set up.
In Sublime text, one of the most useful things I’ve learned recently is
CMD + . will switch back and forth between the test file and file being tested. CMD T allows you to type to open a file. Just to name a few.Option and highlight lets you highlight the first letter of each line
Git commit (without –m, etc.) will open your text editor so you can do the commit message there, save it, close it and it’ll bring you back to the command line and finish the commitGit checkout – brings you back to the last branch you were onGit rebase –i HEAD ~1 rolls back 1 commit (~2 rolls back 2 commits)From the command line putting
touch and then the path with the filename at the end will create that fileWhen squashing commits (which means making multiple commits into one commit), you always ‘s’ (squash) the second one
Gem railroady produces a UML diagram of your code structure
Kill process… somehow I created a connection with a server and then I created a second connection with a server and then couldn’t get one of those connections to close!
ps aux | grep finds the process so you can see if it’s running (I’ve since used this ps aux | grep ruby and ps aux | grep puma)Then
kill -9 prodID (number all the way to the left) kills it. Alternatively, you can also kill it by doing killall -9 thin (or whatever you’re trying to kill)Sunday, February 2, 2014
Saturday, January 25, 2014
Interesting Reads 1/18 - 1/24
This week I started working with Purpose! Working with them this past week has been really interesting and really wonderful... BUT it means that I've currently got close to 80 tabs open covering things from "new stuff to learn" to "things to read" to "things to watch". So... I have definitely not had a chance to read everything on this list yet, but they all seem like excellent pieces for the week.
Enjoy!
Ruby Conferences! (not an article but a new awesome site)
Monday, December 30, 2013
Learning: More Tools To Keep You Moving Forward
So, you’ve been working really hard. You are able to check everything below off the list…
First off, if you were able to cross all those things off the list then seriously, great job!! You’re doing a lot, you’re working your booty off, and hopefully you’re feeling good about it. At this point, you should take a few minutes to take a look back at what you’ve accomplished. Think of everything you’ve learned and everything you didn’t know a few weeks ago. Smile about it, do a mini celebration, and get excited for the rest of your journey.
Here’s the next step… read Practical Object Oriented Programming in Ruby (POODR) by Sandi Metz. It’s amazing and you’ll want to reread it and keep it to refer to in the future. And start watching talks for past conferences. Confreaks is a great site that has talks from all sort of past Ruby conferences. It’s a great way to learn about new things that you might want to look into in the future (or now!). That’s all for now. Read that book carefully to really absorb everything, watch the talks to get inspired, and the next post on learning will be moving on to incorporating Rails!!!
- Involved in the community
- Setting goals
- Doing something every day
- Try ruby
- Ruby in 100 minutes
- Read Why’s poignant guide to Ruby
- Learn Ruby the Hard Way
- Ruby monk
- Ruby Rogues (listened to at least a few)
- Learn to program by Chris Pines
First off, if you were able to cross all those things off the list then seriously, great job!! You’re doing a lot, you’re working your booty off, and hopefully you’re feeling good about it. At this point, you should take a few minutes to take a look back at what you’ve accomplished. Think of everything you’ve learned and everything you didn’t know a few weeks ago. Smile about it, do a mini celebration, and get excited for the rest of your journey.
Here’s the next step… read Practical Object Oriented Programming in Ruby (POODR) by Sandi Metz. It’s amazing and you’ll want to reread it and keep it to refer to in the future. And start watching talks for past conferences. Confreaks is a great site that has talks from all sort of past Ruby conferences. It’s a great way to learn about new things that you might want to look into in the future (or now!). That’s all for now. Read that book carefully to really absorb everything, watch the talks to get inspired, and the next post on learning will be moving on to incorporating Rails!!!
Tuesday, November 26, 2013
Program on my iPad?! - Day 3, Session 3
TL;DR: have you ever programmed on your phone or iPad? I haven’t but now I totally want to.
I thought this session was plus/minus (sorry Charles Wood! I still love Ruby Rogues!). My main issue with the talk is that he showed this awesome demo of actually being able to pull up the command line on your phone or iPad in order to actually program but didn’t really go into how one would accomplish this.
Charles talked about the toolbox he uses to get his development machine in the cloud. Primarily, he uses SSH, Digital Ocean, tmux, emacs, Github, and Chef. First, the SSH is configured and public/private keys are created. You can create one key for each machine or a single key for all your machines. He discussed Digital Ocean as the server he uses.
Second, he prefers to use TMux. I’ve heard a lot about tmux for pairing and how it’s a great tool when you want to pair with someone (I’ve yet to use it). For this case, however, he also liked it because you can pick up where you left off instead of having to restart something or get back to where you left off. Additionally, you can do multiple or split screens which is useful.
I didn’t write down any notes about emacs, github or chef since I have a bit of a background on those (if you ever want a great presentation on chef, hit up Nathen Harvey… he did a 10 minute “what is devops and what is chef” talk for Rails Girls a few months ago that was so amazing).
I jotted down a few notes about security, since that seems like an important issue when you’re using a phone or ipad to log into your development environment. These security suggestions included turning off the root ssh, using public/private only, having a firewall, using something like proXPN (a tunneling service) and using sudo.
The main question I had after this session was “ok, but now how do I actually get this working?!” He did a good job explaining the tools, some of which I was familiar with, others not as much and while all the tools at the end sound great. I’m still not quite so sure how they all get pulled together to let me program on my iPad. After the session, I spoke with Conrad a little bit about this and he pulled things up on his phone (which again, was really cool) and I think I understand overall how I would go about doing this. It mainly has to do with setting up the SSH and a server and I think everything else stems mostly from that. The basic steps are to 1. set up or have access to a server. 2. Install with a package manager onto the server. 3. Ssh into the server. 4. Then you have an ssh client for iPhone, like prompt, which is a terminal emulator for ssh. (I’m a little unclear on that last part, so if you do want to get into this, I’d suggest taking the basic tools listed above and then doing some additional research on the actual setup).
I thought this session was plus/minus (sorry Charles Wood! I still love Ruby Rogues!). My main issue with the talk is that he showed this awesome demo of actually being able to pull up the command line on your phone or iPad in order to actually program but didn’t really go into how one would accomplish this.
Charles talked about the toolbox he uses to get his development machine in the cloud. Primarily, he uses SSH, Digital Ocean, tmux, emacs, Github, and Chef. First, the SSH is configured and public/private keys are created. You can create one key for each machine or a single key for all your machines. He discussed Digital Ocean as the server he uses.
Second, he prefers to use TMux. I’ve heard a lot about tmux for pairing and how it’s a great tool when you want to pair with someone (I’ve yet to use it). For this case, however, he also liked it because you can pick up where you left off instead of having to restart something or get back to where you left off. Additionally, you can do multiple or split screens which is useful.
I didn’t write down any notes about emacs, github or chef since I have a bit of a background on those (if you ever want a great presentation on chef, hit up Nathen Harvey… he did a 10 minute “what is devops and what is chef” talk for Rails Girls a few months ago that was so amazing).
I jotted down a few notes about security, since that seems like an important issue when you’re using a phone or ipad to log into your development environment. These security suggestions included turning off the root ssh, using public/private only, having a firewall, using something like proXPN (a tunneling service) and using sudo.
The main question I had after this session was “ok, but now how do I actually get this working?!” He did a good job explaining the tools, some of which I was familiar with, others not as much and while all the tools at the end sound great. I’m still not quite so sure how they all get pulled together to let me program on my iPad. After the session, I spoke with Conrad a little bit about this and he pulled things up on his phone (which again, was really cool) and I think I understand overall how I would go about doing this. It mainly has to do with setting up the SSH and a server and I think everything else stems mostly from that. The basic steps are to 1. set up or have access to a server. 2. Install with a package manager onto the server. 3. Ssh into the server. 4. Then you have an ssh client for iPhone, like prompt, which is a terminal emulator for ssh. (I’m a little unclear on that last part, so if you do want to get into this, I’d suggest taking the basic tools listed above and then doing some additional research on the actual setup).
Monday, November 11, 2013
RubyConf: First session
My initial intention was to write up a post on what I learned at Ruby Conf this year and put everything in 1 big post, however, I've just finished writing up the first session and I'm already over a page, so I think it makes more sense to post as I complete write ups. Here's my first one about basically the first two hours of Ruby Conf 2013!
This past weekend I had the opportunity to attend Ruby Conf in Miami! It was fantastic. I learned a ton. Met a bunch of new people and really dove into some Ruby amazingness. I was also really excited because, while I have been to a few ruby conferences before, this one was the first where I really understood what was going on and could sit through sessions without being completely overwhelmed and feeling like I didn’t understand a majority of the session.
I was also a recipient of a RubyConf Opportunity Scholarship. This program paid for the conference registration and also connected me with a guide for the weekend. My amazing guide was Conrad Irwin who was able to answer any lingering questions I had from sessions I attended. Conrad was very helpful and really advanced the amount of learning I was able to do and amount of information I was able to process.
So, let’s begin… the day started with a keynote from Matz (Yukihiro Matsumoto). For some reason, I didn’t think Matz would actually be there but he was and it was great. His talk was more to set the tone of the conference than go into technical details but a few points he made were great. First, appreciate your garbage collectors. Garbage collection was actually talked about a handful of times over the weekend but this was the first. Second, appreciate and respect are key. I think this is one of the reasons why I love the Ruby community so much… because these ideals are held paramount and discussed throughout the conference, but especially at the beginning to set the tone. Finally, an interesting note about open source was made, that OSS is like a shark, it needs to keep moving or it will die. All great points to set the tone for the rest of the weekend.
Onto the track sessions.
The first session I attended was on “A Peek inside the Ruby Toolbox” with Loren Segal (who, by the way, is interested in mentoring a new developer who's learning to code. If you’re interested, you should tweet at him @lsegal). Loren spoke about the really good tools the Ruby community has like deployment/ops, documentation, and testing, but mostly focused on where we could improve. The talk started with Visualization. There are lots of great visualization tools out there but none for ruby. Some example given were visual studio, which is a diagnostic hub which shows CPUs, load times, etc. It also has a built in debugger. XCode was noted as a good visualization system. VisualVM which is JVM code. All of these tools really help with discoverability which was interesting to think about. Discoverability is basically being able to have a visual representation of what’s going on. The other tool mentioned was firebug which is considered a really awesome visualization tool and it is the inspect element function in FireFox. Right now, Ruby Mine is available for Ruby but it’s not awesome and fairly expensive. He also spoke about profilers like perf tools which results in a graphic diagram that runs through code and new languages like JRuby which have a JVM.
Next, he spoke about Linting… which is not picking lint out of your belly button or using a lint brush to make your clothing un-fuzzy. Linting tools are basic “check up” tools that help determine if your code is good or bad. Linting tools detect code smells and should find common errors. In Javascript, there is JShint. Currently in Ruby, a few tools exist… Reek, Flog, and Flay. The issue, however, is that these tools test the prettiness of code, not if it is good code (more on good code versus bad code in a later talk). These are some of the tools Code Climate uses to rate code there. There’s a new tool called Ruby-Lint but again, it’s new, and so Loren wasn’t sure how good it is. I’m excited to look into it more!
Next, he talked about Static Analysis. Static Analysis is bug checking/ defect finding. Here, I learned about Fuzz Testing (almost as cool of a name as linting but not quite). Fuzz testing is when you throw a bunch of crap into you application to see what breaks it. (I later learned the SQL is well known for its fuzz testing). It seems like there are lots of interesting things to look into further about fuzz testing but what currently exists are heckle, which fiddles with if statements to see If the tests fail and mutant. Finally, he also spoke about symbolic execution which runs code with no immediate values. I wasn’t able to really wrap my head around this… it’s something that has to do with math, testing values, and automatic test case generation. Right now there’s nothing in Ruby for symbolic execution.
In the category of random knowledge learned, In this talk, I also learned about what an IDE is! I hear people say it all the time, but never fully comprehended what it was exactly. Anyway, an IDE (integrated development environment) is having all the tools you need in one window so XCode is an IDE and so having an IDE would mean that instead of having a text editor, console, etc. all open, you’d have it all in one place.
Great session and lots of new stuff to look up. It will also be interesting to see what new tools are built based on these weaknesses in our toolbox.
This past weekend I had the opportunity to attend Ruby Conf in Miami! It was fantastic. I learned a ton. Met a bunch of new people and really dove into some Ruby amazingness. I was also really excited because, while I have been to a few ruby conferences before, this one was the first where I really understood what was going on and could sit through sessions without being completely overwhelmed and feeling like I didn’t understand a majority of the session.
I was also a recipient of a RubyConf Opportunity Scholarship. This program paid for the conference registration and also connected me with a guide for the weekend. My amazing guide was Conrad Irwin who was able to answer any lingering questions I had from sessions I attended. Conrad was very helpful and really advanced the amount of learning I was able to do and amount of information I was able to process.
So, let’s begin… the day started with a keynote from Matz (Yukihiro Matsumoto). For some reason, I didn’t think Matz would actually be there but he was and it was great. His talk was more to set the tone of the conference than go into technical details but a few points he made were great. First, appreciate your garbage collectors. Garbage collection was actually talked about a handful of times over the weekend but this was the first. Second, appreciate and respect are key. I think this is one of the reasons why I love the Ruby community so much… because these ideals are held paramount and discussed throughout the conference, but especially at the beginning to set the tone. Finally, an interesting note about open source was made, that OSS is like a shark, it needs to keep moving or it will die. All great points to set the tone for the rest of the weekend.
Onto the track sessions.
The first session I attended was on “A Peek inside the Ruby Toolbox” with Loren Segal (who, by the way, is interested in mentoring a new developer who's learning to code. If you’re interested, you should tweet at him @lsegal). Loren spoke about the really good tools the Ruby community has like deployment/ops, documentation, and testing, but mostly focused on where we could improve. The talk started with Visualization. There are lots of great visualization tools out there but none for ruby. Some example given were visual studio, which is a diagnostic hub which shows CPUs, load times, etc. It also has a built in debugger. XCode was noted as a good visualization system. VisualVM which is JVM code. All of these tools really help with discoverability which was interesting to think about. Discoverability is basically being able to have a visual representation of what’s going on. The other tool mentioned was firebug which is considered a really awesome visualization tool and it is the inspect element function in FireFox. Right now, Ruby Mine is available for Ruby but it’s not awesome and fairly expensive. He also spoke about profilers like perf tools which results in a graphic diagram that runs through code and new languages like JRuby which have a JVM.
Next, he spoke about Linting… which is not picking lint out of your belly button or using a lint brush to make your clothing un-fuzzy. Linting tools are basic “check up” tools that help determine if your code is good or bad. Linting tools detect code smells and should find common errors. In Javascript, there is JShint. Currently in Ruby, a few tools exist… Reek, Flog, and Flay. The issue, however, is that these tools test the prettiness of code, not if it is good code (more on good code versus bad code in a later talk). These are some of the tools Code Climate uses to rate code there. There’s a new tool called Ruby-Lint but again, it’s new, and so Loren wasn’t sure how good it is. I’m excited to look into it more!
Next, he talked about Static Analysis. Static Analysis is bug checking/ defect finding. Here, I learned about Fuzz Testing (almost as cool of a name as linting but not quite). Fuzz testing is when you throw a bunch of crap into you application to see what breaks it. (I later learned the SQL is well known for its fuzz testing). It seems like there are lots of interesting things to look into further about fuzz testing but what currently exists are heckle, which fiddles with if statements to see If the tests fail and mutant. Finally, he also spoke about symbolic execution which runs code with no immediate values. I wasn’t able to really wrap my head around this… it’s something that has to do with math, testing values, and automatic test case generation. Right now there’s nothing in Ruby for symbolic execution.
In the category of random knowledge learned, In this talk, I also learned about what an IDE is! I hear people say it all the time, but never fully comprehended what it was exactly. Anyway, an IDE (integrated development environment) is having all the tools you need in one window so XCode is an IDE and so having an IDE would mean that instead of having a text editor, console, etc. all open, you’d have it all in one place.
Great session and lots of new stuff to look up. It will also be interesting to see what new tools are built based on these weaknesses in our toolbox.
Friday, November 1, 2013
A Day in the Life of LivingSocial
On Wednesday, I had the opportunity to shadow at LivingSocial with Tony Pitale. Tony is awesome. He was a coach at the first RailsGirls workshop and really enjoys teaching (which is good for me because I enjoy asking a gazillion questions). LivingSocial is, by far, the largest company I have shadowed at so far. A lot of the initial part of our day just focused on looking at different tools that LivingSocial uses and how the company is structured.
There are over 100 developers that work for LivingSocial, which to me is interesting to think about in terms of culture. I’ve met with some smaller teams so far, teams that almost all work from one office, teams that work entirely remotely, and the in between but none with the sheer mass of developers that LivingSocial has. It was really informative for me, especially as I look at different company cultures as a job applicant, to learn about how tasks are determined, how teams communicate with one another, how standups work, and what sorts of professional development and peer learning opportunities exist at their size.
LivingSocial has a lot of different engineering teams. Each team is responsible for one to a few apps. That team is responsible for knowing all the logic of that application’s purpose and also helps different teams work on different code without stepping on toes, interfering with others, etc. There are a ton of different applications. In order for the applications to communicate with one another, a lot of synchronous API calls are utilized. This means, basically, that when an event happens, the event needs information from a different application in order to continue and make the process happen. There are also asynchronous API calls for other types of events and application communication.
Finally, LivingSocial uses a ton of different tools to measure and provide information about what’s happening. To just name a few we looked at were graphite, rearview, new relic, hive, and kibana. Each has it’s own purpose and tracks something different. The really cool thing about looking at all of these different tools was figuring out how they are used to see what’s happening. For example, when an alert, error, or bug report comes up, you can go into these tracking tools to get more information on what is happening and also to make improvements like site or transaction speed.
Other smaller things I learned:
*If you drag the icon of your sublime text file into the terminal, it’ll put the file path and you can run the file!
*Serializers. What interesting pieces of applications. Serializers say when you take a record out of a database, these are the attributes that we want back in JSON. They’re good to use when you’re building an API. You use something like serializers so that you don’t have to make a class with a method as_json which defines what would get returned as JSON. (Serializers relate to an interesting conversation I had with Jim Gay about presenters and what presenters are used for. As I learn more about rails, it’s also been really interesting to see how you can continue to break out these pieces of information to make cleaner, more organized code.
*when TDDing something, you can also use it to think as a design helper. If your test for a specific item is getting to large or crazy, it’s probably time to break it into different pieces and look at the code design a bit.
*A good way to organize TDD tests are by thinking through the logical order. So the test order should be setup, execution (thing you want to run), assertion (event did happen), teardown.
Overall, a really interesting day at a really interesting company with a really interesting setup and a really interesting teacher!!
There are over 100 developers that work for LivingSocial, which to me is interesting to think about in terms of culture. I’ve met with some smaller teams so far, teams that almost all work from one office, teams that work entirely remotely, and the in between but none with the sheer mass of developers that LivingSocial has. It was really informative for me, especially as I look at different company cultures as a job applicant, to learn about how tasks are determined, how teams communicate with one another, how standups work, and what sorts of professional development and peer learning opportunities exist at their size.
LivingSocial has a lot of different engineering teams. Each team is responsible for one to a few apps. That team is responsible for knowing all the logic of that application’s purpose and also helps different teams work on different code without stepping on toes, interfering with others, etc. There are a ton of different applications. In order for the applications to communicate with one another, a lot of synchronous API calls are utilized. This means, basically, that when an event happens, the event needs information from a different application in order to continue and make the process happen. There are also asynchronous API calls for other types of events and application communication.
Finally, LivingSocial uses a ton of different tools to measure and provide information about what’s happening. To just name a few we looked at were graphite, rearview, new relic, hive, and kibana. Each has it’s own purpose and tracks something different. The really cool thing about looking at all of these different tools was figuring out how they are used to see what’s happening. For example, when an alert, error, or bug report comes up, you can go into these tracking tools to get more information on what is happening and also to make improvements like site or transaction speed.
Other smaller things I learned:
*If you drag the icon of your sublime text file into the terminal, it’ll put the file path and you can run the file!
*Serializers. What interesting pieces of applications. Serializers say when you take a record out of a database, these are the attributes that we want back in JSON. They’re good to use when you’re building an API. You use something like serializers so that you don’t have to make a class with a method as_json which defines what would get returned as JSON. (Serializers relate to an interesting conversation I had with Jim Gay about presenters and what presenters are used for. As I learn more about rails, it’s also been really interesting to see how you can continue to break out these pieces of information to make cleaner, more organized code.
*when TDDing something, you can also use it to think as a design helper. If your test for a specific item is getting to large or crazy, it’s probably time to break it into different pieces and look at the code design a bit.
*A good way to organize TDD tests are by thinking through the logical order. So the test order should be setup, execution (thing you want to run), assertion (event did happen), teardown.
Overall, a really interesting day at a really interesting company with a really interesting setup and a really interesting teacher!!
Friday, October 4, 2013
Project Euler all DAY
This week I took a break from building things to go back to the basics a bit. I've been having trouble getting a good handle on the different parts of Ruby (ie- blocks, hashes, etc.) and also struggled at the code retreat last weekend when I had to write code for tests in order to make them pass. Recognizing this as we significant weakness, I decided to spend the week tackling Project Euler problems.
Project Euler problems are math problems that you then solve using code. First, I found that they help me take an issue and think about different approaches. Second, they are great for practicing test-driven development. Third, they create additional challenges. For example, you can solve the problem and then go back and refactor to make your code even better OR I've had a few amazing friends/mentors this week look at my solutions and give me additional constraints or challenges to make my code even cleaner and better or explore a different method to solve the problem. There isn't one solution to these problems and if you google "euler ruby" you'll find dozens of responses.
I'll walk through the setup and first problem.
For me, the setup was actually pretty confusing, although really simply once I received some direction. It may seem basic, but I couldn't find these instructions anywhere so I'm writing them to hopefully help others get set up.
I wanted one euler folder with each problem in it's folder. I originally put both the problem1.rb and problem1_spec.rb files in the same folder but then rspec wouldn't run! It turns out that rspec looks for a lib folder in order to run it. The simplest way around this was to create a lib folder and a spec folder in my euler folder. The lib folder contains all the problem files and the spec folder contains all the spec files. To run the tests, I typed into the command line:
Euler Problem 1:
First, I'll start with the tests that I wrote. I use rspec:
This test format is pretty much what I have been using for all of the Euler problems and I have found it pretty useful. To start the test, you have to describe something and then describe it's characteristics. So, since we are given the answer, we are able to hard code (put in the actual numbers) the test. The test says that for the sum of the multiples of 3 and 5 under to, we should expect that problem1(module)'s multiples(method) of 10(parameters/argument) to equal 23 (because that's what the problem tells us. I did a similar format for the next test and plugged in the final number 233168 once I got the code working.
Now for the code:
So, first we defined what the module was. Then, we were trying to find the multiples of two numbers (3 and 5) up to a certain number. I put
(or modulo) which is the operation used to find the remainder of dividing one number by another, in this case either 3 or 5. Then the reduce method takes all the remaining numbers and using the :+ operator, adds those numbers together to get the sum.
Also, while going through this process, I paused in the middle to complete Ruby Monk. While initially I was like, "OMG, I CANNOT do another tutorial", Ruby Monk was really helpful and I wish it had been recommended to me two months ago. As opposed to the traditional ruby tutorial that builds a site of some sort, Ruby Monk really explains the terms and parts that make up Ruby and I feel much more confident in the definitions and grammar of it all now that I've completed it.
I'll be posting more problems in the next few days.
Project Euler problems are math problems that you then solve using code. First, I found that they help me take an issue and think about different approaches. Second, they are great for practicing test-driven development. Third, they create additional challenges. For example, you can solve the problem and then go back and refactor to make your code even better OR I've had a few amazing friends/mentors this week look at my solutions and give me additional constraints or challenges to make my code even cleaner and better or explore a different method to solve the problem. There isn't one solution to these problems and if you google "euler ruby" you'll find dozens of responses.
I'll walk through the setup and first problem.
For me, the setup was actually pretty confusing, although really simply once I received some direction. It may seem basic, but I couldn't find these instructions anywhere so I'm writing them to hopefully help others get set up.
I wanted one euler folder with each problem in it's folder. I originally put both the problem1.rb and problem1_spec.rb files in the same folder but then rspec wouldn't run! It turns out that rspec looks for a lib folder in order to run it. The simplest way around this was to create a lib folder and a spec folder in my euler folder. The lib folder contains all the problem files and the spec folder contains all the spec files. To run the tests, I typed into the command line:
$rspec spec/problem1_spec.rb and to run the actual file I had to type $ruby lib/problem1/problem1.rb. Finally, in order to test my code, I have been running the answer through IRB. To get to IRB, you simply type irb into the terminal and then you can write each line of code to see if you get the correct answer. Finally, at the top of the spec, we need to require the problem so that the tests finds the code file.Euler Problem 1:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.First, I'll start with the tests that I wrote. I use rspec:
require 'problem1/problem1'
describe 'solution' do
it "sums the multiples of 3 and 5 under 10" do
expect(Problem1.multiples(10)).to eq 23
end
it "sums the multiples of 3 and 5 under 1000" do
expect(Problem1.multiples(1000)).to eq 233168
end
end
This test format is pretty much what I have been using for all of the Euler problems and I have found it pretty useful. To start the test, you have to describe something and then describe it's characteristics. So, since we are given the answer, we are able to hard code (put in the actual numbers) the test. The test says that for the sum of the multiples of 3 and 5 under to, we should expect that problem1(module)'s multiples(method) of 10(parameters/argument) to equal 23 (because that's what the problem tells us. I did a similar format for the next test and plugged in the final number 233168 once I got the code working.
Now for the code:
module Problem1
def self.multiples(stop_counting)
(1...stop_counting).find_all { |i| i%3 == 0 || i%5 == 0 }.reduce(:+)
end
end
So, first we defined what the module was. Then, we were trying to find the multiples of two numbers (3 and 5) up to a certain number. I put
self on the method definition because we are calling the method on the module. I put stop_counting as the argument which helps the tests pass, because in the tests we put at what number I stop counting (10 in the first example and 1000 in the second example). By defining the argument as stop_counting, we have more flexibility on the tests to plug the numbers into the tests and not the code (I think of this like an excel document where you have you assumptions worksheet. When you have an assumptions worksheet, you can change the number there as your assumptions change and since the rest of the spreadsheet is built on those assumptions, the numbers used in the formulas on other worksheets will automatically change as opposed to having to go through each worksheet and redo all the math manually). So, the code says to look at all the numbers from 1 until stop_counting and then find all the numbers (I think you can also use .select here) that have a remainder of 0 when using the modulus (or modulo) which is the operation used to find the remainder of dividing one number by another, in this case either 3 or 5. Then the reduce method takes all the remaining numbers and using the :+ operator, adds those numbers together to get the sum.
Also, while going through this process, I paused in the middle to complete Ruby Monk. While initially I was like, "OMG, I CANNOT do another tutorial", Ruby Monk was really helpful and I wish it had been recommended to me two months ago. As opposed to the traditional ruby tutorial that builds a site of some sort, Ruby Monk really explains the terms and parts that make up Ruby and I feel much more confident in the definitions and grammar of it all now that I've completed it.
I'll be posting more problems in the next few days.
Subscribe to:
Posts (Atom)