Sunday, June 29, 2014

Youtube Video Review: Lean Startup: Why it Rocks Far More than Agile Development - Joshua Kerievsky

Video Url

http://www.youtube.com/watch?v=V5p8m1IjJoA

Synopsis

"Lean Startup is a disciplined, scientific and capital effecient method for discovering and building products and services that people love." (From the video's Description Section on Youtube)

Notes

* Came from Eric Ries' failures (With his book `The Lean Startup`)
    * `The Startup Owner's Manual` - Great book on learning how to start startups
        * What does customer need/want
        * Customer Development is a core part for the lean startup
    * `Implementing Lean Software Development`
    * `Extreme Programming Explained`
    * `Kanban`
        * "How to visualize and limit work-in-progress in software development and information technology work"
        * Catalyzes cultural change and delivers better business agility - Amazon Book Description
* Even Large companies like Intuit can handle using the Lean Startup approach
* Needfeed example
    * Combination of buying and social networks
    * They invalidate their idea
        * Went on rentacoder.com
            * Changed facebook to show fake things that your friends bought
            * 40-50% people hated new stuff, but the company spent close to nothing getting feedback from users to show that
    * Went back to investors and told them the results of invalidating their idea
    * Kept pivoting 'till they found what works
        * Found what gets traction, and went with it
    * Invalidate extremely efficiently
(9:10) "In a startup no facts exist inside the building, only opinions." - Steve Blank
    * Fundamental idea that there's no facts only guesses until you have something to show
(9:35) "Get outside of the building" - Steve Blank
    * Try to see waste and eliminate it
    * "Learning to see waste and then systematically eliminate it has allowed lean companies such as Toyota to dominate entire indeustries." - Eric Ries
(9:55) Feature Fake
    * Thought: We have a guess that people are going to want todo online chat
        * Just an idea until you get users using it
    * Do a feature fake of this by hacking it in
        * 100 people saw it
            * 6/100 said they were likely to use it
        * 1000 people should have probably done it
        * You would think a lot of people would be annoyed by it, but you use it very sparingly
        * Is very fast
    * Eliminates waste
(12:30) Agile: Accepted
    * Agile development style - You want to get "Accepted"
    * Accepted means nothing, it's just accepting a guess that no one knows
    * Lean Startup Style: Validated
        * Want to validate whether something was used by people and it makes things better
    * (13:45) Use "Measure Usage" to see if something was validated
        * Logins with Resume
        * Resumes
        * Non-Resumes
(14:50) Validated Learning
    * Learning validated via data, surveys, interviews.
    * Demonstrated by positive improvements in startup's core metrics
    * Need to be doing experiments in order to validate the stuff you're adding is useful
(15:25) "Agile methods remove waste... yet those [Agile] methods had led me down a road in which the majority of my team's efforts were wasted." - Eric Ries
    * Well-crafted software that nobody wanted to use
    * Should have done minimalistic and tried it out
    * Agile doesn't say anywhere to do minimalistic
    * (16:45) Gave incredible customer service, but weren't watching usage
        * 80% of stuff was untouched
        * Don't have "shelfware" and things that aren't touched
(18:05) "A startup is a human institution designed to create a new product or service under conditions of extreme uncertainty." - Eric Ries
(18:28) Ecosystem Happiness
(19:35) Continuous Deployment
    * Best part about Agile Development
(20:25) Started to deal with low-usage rates
    * Categorize Users
        * Non-Starters
        * Skimmers
        * Dabblers
        * Connectors
        * Finishers
    * Observe data to see how can make the max amount of people Finishers
(21:08) Average Response Time
    * See where bottlenecks for certain customer service questions are
(21:54) Analyze Page Views
    * What happens when you change your site slightly
(22:15) Usage Improvements
    * Completion Rates vs. Starting Rates
(22:45) "In an early stage startup, success is not in a 'to do' list, it's in a 'to learn' list." - Sean Ellis
    * Applies to most things we do
    * What do we need to learn, and how do we do it as rapidly as possible?
(23:15) Tools for planning Agile projects
    * Lean Launch Lab
        * Everything you enter in is all about hypotheses and tracking them
        * Everything is a guess, not really a hypothesis
        * Helps deal with the "Lean Canvas"
        1) Enter Hypothesis
        2) Enter Experiments to Prove/Disprove Hypothesis
        3) Enter key metrics to be measured
        4) Enter tasks to complete
(25:00) Product/Market Fit (diagram)
    * If you have to ask "Have we achieved Product/Market Fit?", then you haven't yet
        * You'll know it when you achieve it
    * The search for a business
(26:00) A Pivot is "a special kind of change designed to test a new fundamental hypothesis about the product, business model or engine of growth." - Eric Ries
    * Focused on these questions:
        * What is the product you're building
        * What are the metrics around it
        * What's your Engine of growth
        * How can I test/optimize it
(26:25) New Yorker Cartoon - "I'm not leaving you. I'm pivoting to another man."
(26:40) Eric's Catalog of Pivots
    * Zoom-In Pivot
        * Build on what users actually use
    * Zoom-Out Pivot
        * Build more stuff so more users use product
    * Customer Segment Pivot
        * Go to different segment/audience
        * Going from building for users to building for businesses
    * Customer Need Pivot
        * Change product to your customers
        * (Roast Beef story)
    * Platform Pivot
        * Change platforms completely
        * Move from one technology to another
(28:25) Votizen
    * Went through a lot of pivoting to find product
        * 1st MVP: Initial Product
        * 2nd MVP: Zoom-In Pivot
        * 3rd MVP: Customer Segment Pivot
        * 4th MVP: Platform Pivot
(29:45) Can't do well with MVP if you don't do innovation accounting
    * Innovation Accounting is when you account for: "Is my MVP any good?"
        * What metrics are telling me that my MVP is any good?
        * Track your numbers
            * Engine of growth
            * Registration rate
            * Activation
            * Retention
            * Referral
            * Revenue
            * Lifetime Value
(30:15) AARRR: Metrics for Pirates
    * Acquisition: users come to the product/site
    * Activation: users "use" the product/site
    * Retention: users use the site/product
    * Referral: users like product enough to refer others (Net promoter score)
    * Revenue: users conduct some monetization behavior
(31:05) Love Metrics (Intuit's metrics)
    * Delivered customer benefit?
    * Customers actively using it?
    * Customers telling others about it?
(31:45) Goto the Monkeys for Lean Insights
    * SurveyMonkey
    * MailChimp
    * Angry Monkeys
(32:05) Split (A/B) Testing
    * Different versions of a product offered to customers at the same time
         * Champion and Contender
    * Refine understanding of what customers want
    * Measure productivity via validated learning, not production of features
         * Stops arguing, just do experiments and make changes based on real data
(33:00) Mailchimp Email A/B testing
    * Paragraph difference (VIP vs. Not VIP)
(35:00) Collect as much data about your customers as possible
    * Don't make assumptions
(35:35) Usability data
    * Constant testing of UI
    * Where users click
(39:20) Concurrent Set Based Design
    * Combine many people's designs
    * 99 designs
(41:15) Heat/Click/Scroll Mapping
    * Create fake page and can Pre-Order for half price
    * Can see new/returning users
    * Can see if scroll down
(42:30) All tools shown are to see if we should build something
(42:45) Agile vs. Lean Startup
    * Most things are built upon Lean Startup idea
    * Lean Startup Ideas
        * Business Model Canvas
        * Product Market Fit
        * Minimum Viable Product
        * Learn/Measure/Build
        * "Get out of The Building"
            * No facts in the building, go find the facts
            * Always learning about the customer
        * Hypothesis
        * To Learn List
        * Customer Validation
        * Split (A/B) Test
        * Continuous Deployment
        * AARRR
        * Five Whys
        * Innovation Accounting
        * Led by Successful Entrepreneurs

Rating: 5/5

Review
I think this is a fantastic overview of the ideas of a Lean Startup and the differences between a Lean Startup and Agile Development. Joshua goes through in a high level what each idea means and follows them up with real-life examples of when companies, like his own, practiced these ideas. It's a great video to watch if you're interested in this topic and how to practice it.

Youtube Video Review: UrbanCode Video Blog 2 - Continuous Delivery and DevOps

Video Link: http://www.youtube.com/watch?v=IVnaRI2jOp8

Description
Goes through the difference between what Continuous Delivery does and what DevOps does

Synopsis
Continuous Delivery handles all the steps before pushing to the production servers, while DevOps handles pushing from one server to the production server.

Rating: 3/5

Review:

  • It doesn't seem to go through the subject in enough detail, and their definition seems to be slightly off from the programming community's definition.
  • It gives a really dumbed down definition of both
  • If you're new to the subject, it'd be good to watch, but don't trust all the information contained in this video.
  • It's great how short the video

Youtube Video Synopsis and Review - Introduction to Continuous Delivery by Rolf Russell

Video Link: http://www.youtube.com/watch?v=t6XUVaPQkKE

Synopsis:
Test everything fast and only change things on servers through automation. Continuous Delivery is awesome, and the benefits you get from implementing it outweigh the costs.

Notes (Taken halfway through 'till the end)

  • You want to check-in code once a day to develop, and develop to master frequently
  • Trunk Based Development rather than Branch Based Development
    • Do this because it's tough to refactor with Branch Based Development
    • Merges take time, no one wants todo them
  • How to write features this way 
    • Feature Toggles (Flag in .ini file)
      • Most common mistake: People don't delete their old toggle (The previous code), but you need todo this
  • Consistency from Development to Production
    • Be consistent in the deployment process (Automating)
    • Environment Configuration (Keep the OS and Packages the same)
    • Testing Tools (Developers should use the same testing tools. QA should be using same tools)
  • IT/Ops/QA/DEVs should be sitting together
    • Work together
    • Share KPIs (Key Performance Indicators)
      • Stability and Change
    • The nature of itops is changing
      • The needs not consistent, so need generalists that can do a little of everything
  • Concerns for moving to Continuous Delivery
    • Reliability & Stability: Move to smaller chunks
    • Compliance & Traceability: Automation provides great compliance and traceability
    • Releasing 10 times/day: Not necessary, but you want to always have production releasable code
    • Complexity of my systems: It's about continuous improvement. Start with low hanging fruit. Low cycle times.
    • It will take investment: Yes, but it will also start paying dividends fairly quickly
  • Question to ask about your Organization:
    • How long would it take to get a one line code change into production using the normal process?
Rating: 5/5

Review
I thought this was a fantastic, first introduction into what continuous delivery was. It didn't give any details on the software to use or how exactly to implement, but it did provide an overview of what to think about and how your organization could benefit from continuous delivery

Monday, June 23, 2014

/usr/bin/env: Bad Interpreter

If you've corrupted or deleted your /usr/bin/env file, you'll most certainly brake a lot of your installed packages. You'll probably see errors like:

/usr/bin/env: bad interpreter: No such file or directory

The way to fix this issue is to reinstall coreutils:

        sudo aptitude reinstall coreutils


Don't have aptitude? Just install it:

       sudo apt-get install aptitude

Sunday, June 8, 2014

Learning Rails - Practice Makes Perfect

Overview
Learning how to program is like learning how to play a sport or learning an instrument. It's a dynamic process that has a lot of different patterns that are used consistently. These patterns include:

  • Opening/Editing/Closing files
  • Adding files in certain locations
  • Setting up and editing database configuration and such
  • Using the debugger to fix runtime errors
  • etc.
When learning to play a sport or an instrument, you practice the fundamentals of the patterns you use that you can then use in a game/performance.

Take Baseball as an example. To get better in Baseball, you practice. During practice you go over things like:
  • Sprints to get faster at running the bases or running after the baseball
  • Catching Fly-Balls to improve at focusing on the ball and catching it
  • Taking Ground-Balls to improve at catching grounders
  • Throwing to improve at accuracy and strength or throwing the baseball
  • Batting to improve on hitting the ball with the bat
These things are repetitive things you practice to get better so that when you're thrown into a game situation, you are ready for whatever comes your way.

What most programmers do
Programmers don't tend to like to practice. They tend to just dive in and handle whatever comes their way. This is completely fine, because even though they never "practice", they get all the practice they need during game-time. They aren't being quizzed and no one is judging them for making a poor decision on the fly. 

However, I still think there's a lot of value in practicing correctly with programming. Without the proper repetition, you don't learn as effectively. Even after years of programming, I'm not as fast as I could be when developing a new application or debugging an application. What practicing allows you todo is develop reactive memory that will allow you to, with little to no thinking, sprint out many lines of code without doing much thinking. This allows you to build more over time and be more productive with your time.

What you should do
What should generally happen is you should set out for incremental learning over a long period of time. I'd say try to focus 30 minutes a day on practicing programming something that starts out very small. An example would be build a website from scratch that displays "Hello World" on the home page. This example may only take 5 minutes on the first day, and that's completely fine. You want to build up, adding something small each day. On the 2nd Day you could add css to that Hello World, making it blue instead of black. On the third day you could add a header. The important to note that every single day you start from scratch. You create a whole new rails application every single day that you will know how to build, so that process of building is reactive, and you can use that for building other applications very fast.

I like to think of this type of learning like a video game that you replay over and over again. Over time you get really fast at doing the commands, and so you're able to beat each level extremely quickly, and it builds your overall gameplay. With this style of learning, it's best to time yourself everyday to see how fast you can complete the application up to that point in. You should be getting faster, or remaining at a similar time if it's your computer that is the bottleneck, with each sequential day.

Overview
Do it, it will help

Friday, May 16, 2014

How Many Tests Should You Have in Your Python Program?

Overview:
Tests are one of the most crucial things in programming, but very few programmers write enough tests. One of the beginning obstacles to writing tests is how to write proper, fast tests.

Idea behind tests:
Tests should be extremely fast and should cover as much of your program as possible (100% is always preferred). Rule of thumb is if you have an if statement, you should have at least 2 tests.

Reason for Having 100% test coverge:
The more code you write, the higher chance of things to go wrong. If you write 10 lines of code, that's at least 10 spots where you can have an unexpected error in your code.

I think it would be a little excessive to have a test for each line of code in your program, but it's reasonable to have at least 2 tests for each if statement in your program. Why this number? Because the complexity of your program comes mainly from conditional logic (Or if statements). Take these lines of code:

if input == 'cat':
  a = 'meow'
else:
  a = 'woof'

Here, our program has 2 things that could happen: `a` can either be 'meow' or 'woof'. So we'd have 2 tests here: a test with input == 'cat', and a test where input != 'cat'. By having these 2 tests, we have 100% code coverage. By having this, it saves us from 2 potential fatal flaws in our program.

Lets look at a slightly more difficult example:

if input == 'cat':
  a = 'meow'
elif input == 'dog':
  a = 'woof'
else:
  a = "Hello kind sir"

Here, our program has 3 things that could happen: `a` can either be 'meow', 'woof', or 'Hello kind sir'. So, instead of 2 tests, we'd have 3 tests: a test with input == 'cat', a test with input == 'dog' and a test that doesn't equal 'cat' or 'dog'.

So lets go into a slightly harder example with if statements inside if statements:

if input == 'cat':
  if input2 == 'siemese':
    a = 'mawww'
  else:
    a = 'meow'
elif input == 'cat2':
  if input2 == 'siemese':
    a = 'mawww'
  else:
    a = 'meow'
else:
  a = "Hello kind sir"

Now the calculation of complexity is slightly harder. We need to take into account the if statement inside the first if statement, so the calculation will be about 7, because we have 5 possible different things that could be set, but also have to be sure the outer if statements (`if input == 'cat'` and `if input == 'cat2'`) are true ever. The important thing to note is that we have written the inner if statement logic twice, so we can simplify this to this:

def output_on_cat_type(cat_type):
  if input2 == 'siemese':
    return 'mawww'
  return 'meow'

if input == 'cat':
  a = output_on_cat_type(input2)
elif input == 'cat2':
  a = output_on_cat_type(input2)
else:
  a = "Hello kind sir"

Our new calculation is now 5 because we need to test the 3 if statements in the regular code, and test the 2 conditions in the `output_on_cat_type` function. This is one of the reasons why it's so important to refactor out if statements within if statements: It gets increasingly more difficult to have 100% test coverage with every if statement.

Friday, April 11, 2014

Writing Comments in Python

Overview
I think writing comments in python is grossly under-utilized and under appreciated. Many programmers say that your code should always be readable, thus they do not need comments. Others say that you don't need comments because you should have tests that show what the function is doing. While I think both are valid, comments are still necessary.

Why Comments are Needed
    Comments allow you to explain everything at a higher, deeper level. It gives other programmers who need to work on your code context to what the function they're working on is supposed to do. It also allows these programmers to refactor any poorly written code you wrote because they'll know for sure what the function is supposed to do. It prevents the "hacky" fixes and allows people to develop for what the function needs to do.
    They also allow you to have a deeper knowledge of what you need to do to write your function. If you write the comment before you write your function, then you don't get held up by uncertainty when writing it in python code.
    It allows you to develop an api for other programmers to use. An api without comments is like buying a do-it-yourself kit without instructions. Yes, other programmers can probably figure out what to do eventually, but they won't be happy doing it if they have to stumble over everything.

Why we don't put comments

  • We are lazy
  • Our current code isn't commented, so don't have the will to start
  • We don't feel like we have time
    I've certainly experienced all of these reasons. The first step is to realize you have a problem. The second step is to start writing comments.

How to write comments
Docstrings
    The best way to write comments in python is to use docstrings. Docstrings allow programmers to see the comments of a function while running python by doing `help(<function_name>)`. They are also conveniently always right under the function declaration, which is very helpful for programmers looking for function comments. This is how to write a docstring:
    def function_name(param1, param2):
        """your_comments
        ...
        """
        <rest_of_your_function>

    As you can see, it's a pretty standard python comment, except that it is always placed right underneath the python declaration. If it's not placed there, then it's not a docstring.

Comment Design Patterns
    We want to provide other programmers with the most understandable, standardized comments possible, so lets take a look at what these comments should have and where they should have them.

    def function_name(param1, param2):
        """<What_Your_Function_Returns>
        
        <More_In_Depth_Of_What_Your_Function_Does_and_Returns>
        
        <Your_Function_API>
        
        <Examples_Of_How_To_Call_Your_Function_And_What_It_Returns>
        
        <And_Special_Case_Examples_Like_Errors>
        
        <Anything_Extra_You_Want_To_Add>
        """

Monday, March 10, 2014

Vim: How to Turn On/Off Numbered Display In Vim

Overview
The Numbered Display in Vim (or Ruler) is extremely helpful when programming. However, sometimes, such as when you need to copy text from vim and paste to another program, you need to turn off the numbered display.

Solution
To do this, type this in vim
     
        :set nonumber

The numbers should disappear. If you want them to reappear, type this in vim

        :set number




NOTE: Please note that this guide is currently in rough draft form. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Python Style: Why is it So Important to Follow Conventions?

Overview
Conventions are in there for a reason. They make things easy to scale over time by providing easy-to remember guidelines for people to follow. In python, you don't have to follow most of the guidelines. However, you should try to follow all of the guidelines when possible. It makes it easier for people to read your code as well as helps yourself search through your code faster and remember where things are.

Readability
Ever read something that had horrendous grammar? Maybe a post on my site? Then you know how hard it is to read something that doesn't follow grammer. When you don't follow conventions, you are basically writing code without following python's grammar. Sure, you can write something without grammar, but you and other people won't be able to read it/maintain it later. Writing code that is maintainable is one of the most important things in programming, because even if your program's functionality should never change, the system its running on certainly will (Like the change from python2.7 to python 3.2).

Searching Your Code
Ever have to grep in your terminal in order to find a method or variable in your program? By following conventions, you can find things faster and easier. Say you're trying to find an instance variable. If you did it right, you'll search "_var_name". This will help you weed out all of the things that have "var_name" in them, like method names. Say you want to find a method that starts with "foo". All you have to search is "def foo" and you'll be taking to all the methods that start with "foo".

Remembering Where Things Are
By Following conventions, you can remember where things are put in your program. Say you have a class file with a bunch of methods, helper methods, variables and other things. If you scatter all of these across the file, it will be harder for you and others to find methods or variables of interest to you/them. If you instead put all of the variables together, then helper methods together, then regular methods together, you'll be able to find things a lot quicker later.

Conclusion
Study and Follow conventions. You'll be able to read your code and other code faster with more comprehension.


NOTE: Please note that I am not an expert at this topic and this info can certainly be improved. If you have questions, comments or suggestions for this blog post, please comment! Also, this guide is currently in rough draft form. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Python Style: Refrain from Setting/Getting Instance Variables Outside your Class

Overview
Instance Variables can cause some really bad stuff to happen in your program, but they're basically necessary to have in any class to keep track of the state of an object. Even worse is that there are no private variables in python. Because of this, it's especially important to make sure your programs have setters and getters, as well as naming your variables in a way that prevents other classes/programs from accessing them directly.

What Are Getters?
Getters are just methods in your class that return the variable, or variation of the variable, that the user wants. They allow you to send the variable to whoever asks for the variable on your terms. For example, lets say a person asks for data of a user. In your database, you've stored the user object with a password that you don't want others to see. So, when someone calls your method, you return them all of the info except the password.

Getters also allow you to keep track of anyone who asks for the variable. Lets say you want to find all of the referred methods that call your getter. You can set a console.log to print out the stack trace every time the method is called. This would allow you to go through your log files later and see where your getter was called from.

What Are Setters?
Setters are very similar to Getters, but instead are used to set the variables in your class. They are very useful for making sure variables are set correctly, providing extra info into your variables, and seeing who's set your variables.

Setters make sure variables are set correctly because you're able to add extra checking to make sure the variables don't become corrupt. For example, lets say you have a bank app that stores dict objects. These dict objects look like this: {'deposit': 500}. Lets say a user decided to just add a dict object like this: {'deposit': 'foo'}. 'foo' is not a number, so the program is likely to crash. If you have a setter, you can check the key and value of the dict and make sure each are valid when being set, and, if they aren't, send a nicely-worded error message back to the user.

Setters can also provide extra, very useful data into your variables. Lets say you want to add a deposit, and you want to also record when that deposit was made. Well, you don't really want to trust the user to pass in the proper timestamp, because he can send a made up timestamp. So, in your method you record the time the method was called in the variable, so the variable would look like this: {'deposit': 500, 'time_created': 523423423}

Setters allow you to see who has set your variables. Like in the getters example, you can set a console.log to log a stacktrace to see everywhere your method was called.

Debugging Reasons
One of my favorite reasons is for Debugging. If someone sets the variable directly, its very hard to track down where it happened. You can grep all your files, but if it came from some other source, then you are not going to have much luck. If you have setters and getters, you can set a pdb.set_trace() in those methods and see every time you get the value and you set the value.

Creating your Instance Variables Correctly
Anyone can change any variable in your class, but most people don't. If you follow the PEP8 Guide, you can be sure that the fewest number of programmers try to change your instance variables. To do this, add an underscore before your variable name, like this: _var_name. This is the syntax to say that variable is "private". If you want to make it really hard on programmers trying to screw things up, put 2 underscores before your variable name, like this: __var_name. This obfuscates the variable, making it harder for people to change it.

Conclusion
Setters and Getters are always a good idea. Use them.

References:

  • http://stackoverflow.com/questions/1641219/does-python-have-private-variables-in-classes

NOTE: Please note that I am not an expert at this topic and this info can certainly be improved. If you have questions, comments or suggestions for this blog post, please comment! Also, this guide is currently in rough draft form. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Ubuntu: How to Turn Off Your Trackpad

Overview
Trackpads can be very annoying when programming on laptops. Your palm can accidentally brush against it when pressing keys and click into another program.

Solution
In Ubuntu, you can easily disable the touch pad from the command line. Todo so, follow these steps:


  1. Open up your terminal
  2. Execute this command: xinput
    • This command will show you information about the inputs that are connected to the laptop.
  3. Search for "TouchPad" and find the "id" that is on that line (example: id=10)
  4. Disable the touch pad by executing this command (Replace <id> with whatever id you got from step 3): xinput set-prop <id> "Device Enabled" 0
    • Example if your id is 10: xinput set-prop 10 "Device Enabled" 0

Your touch pad should now be disabled. To re-enable, just change the ending 0 in step 4 to a 1 like this: xinput set-prop <id> "Device Enabled" 1

Conclusion
Turning off your touch pad will be very useful in situations where you only want to use your keyboard, like if you're programming. However, some things, like using a website, will still require you to use the touch pad. This is why I suggest creating a bash script to enable and disable the touch pad so you don't have to remember these commands every time.



NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Sunday, March 9, 2014

Ubuntu: How to Force-Quit an Application in Ubuntu

Overview:
Something can go wrong on all computers. Ubuntu is no exception. One of the most common things to go wrong is a program has stalled and you can't seem to stop it.

How you Solve this on Mac/Windows:
Mac and Windows computers seem to make it easy on you, having nice, command-line free ways of quitting a program. On Mac you can just look at running programs and do "force-quit" on the application that has stopped running. On windows you can do "Cntrl-Alt-Delete" and quit the program that has stopped running.

How Ubuntu is Different:
Ubuntu doesn't seem to make it as easy on you, but this is how you do it:
1) Open the terminal
2) execute the command "xkill" (Without the quotations)
3) With your cursor (Also called mouse), click on the window you want to quit

Why Ubuntu is still better:
I use all 3 operating systems on a daily basis and while I regularly have to force quit programs on my mac/windows machines, I only have to do this once or twice a year with my ubuntu machines.

Conclusion:
It might be slightly more difficult in ubuntu mainly because the easiest way you need to open your terminal. If you're a programmer, this should be simple to do.



NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Sunday, March 2, 2014

Losing Weight: Why you Should get Good Sleep to Lose Weight

Overview
Losing weight is mostly about avoiding craving food and making sure you're eating less than you are burning.

Why you should avoid Craving
Craving, or wanting to eat something, leads to frustration and binge eating. This is why we want to avoid craving as much as possible to lose weight.

Why you should Eat Less than you Burn to lose weight
This is the only way to lose weight. If you don't want to lose weight, don't follow this rule.

Why you should get good sleep
When you don't get good sleep, you get tired more often. When you get tired, you start to crave food more often.



NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and references. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Losing Weight: Why you should eat a large breakfast

Overview
When I was younger, I never ate breakfast. I never had time for it as I would wake up 10 minutes before school started and would have to sprint to get to school that was 15 minutes away. However, this would leave me craving for food until lunch.

Problem
Craving food often leads to overeating. You tend to over-compensate when you are too low to make sure your cravings go away. However, because your body typically takes 20 minutes to realize when you've actually satisfied your hunger, it's not great to just eat until you feel "Full."

How to stop craving food
You want to avoid craving food as much as possible. In my experience, I never feel hungry in the morning, so my body feels I can skip it. However, to keep from craving food, you should put something in your stomach about every 2 hours. This makes sure your body knows you are feeding it and doesn't have to remind you.

Why you should eat more earlier
You want to give your body the longest amount of time to burn the stuff you eat. If you eat more at night, then you only have a few hours to burn off those extra calories. It allows you to not feel as tired later because your body knows it has energy to burn. It also reduces cravings later because your body isn't just burning the fat at first.

You may be saying "But I want to lose weight, so I should eat a lot less, and be skipping breakfast, I eat less." You are right in saying you lose more weight if you eat less, but that's only if you keep up your exercise routine. If you get frustrated at any point and decide to just quite, you aren't going to lose any weight. The key to losing weight is persistence in your routine. By eating more in the morning, you'll have that wood and kindling to start that fire in your belly everyday to keep going.

Conclusion
Eat more early. You'll be happier this way.



NOTE: This guide is currently in rough draft form and could be improved deeper explanation and more references. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Beginning to learn Electrical Engineering: Important Formulas (Part 1)

Overview
I'm someone who loves learning anything engineering, and something I've been lacking is an understanding of electrical engineering and how electronics actually work. So I think I'll start a blog entry series that will cover learning electrical engineering, from absolute beginner to at least competent.

Why learn electrical engineering concepts?
There is a bunch you can do with programming alone, but to make really cool physical projects, like running a toy car or building something that checks temperature, you'll need to program for things like Arduino or raspberry pi. These will require at least introductory knowledge on how circuits work and what resistors are in order to not destroy your electronics.

Basic Formulas
Key of Symbols:
E = energy in Joules
I = current in Amperes
t = time in seconds
V = voltage in volts
Q = Charge in Coulombs
R = resistance in Ohms
P = Power in Watts (Amount of energy transferred)

Energy (E)
E = ItV

Current (I)
I = P/V
I = dQ/dt

Voltage (Also called Potential Difference) (V)
V = IR
V = W/Q

Resistance (R)
R = V/I

Power (P)
P = IV
P = I^2R
P = V^2/R


Conclusion
This is just a basic overview of the beginning formulas for what will be talked about in later blog posts. You should study these equations and try to memorize them first in order to be proficient doing equations later.


Resources
These notes were derived mainly from: http://www.bmatcrashcourse.com/electricity-notes.pdf. I highly recommend looking over this document as it has the same information, but includes nice diagrams/pictures for reference.




NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about). This post deals with equations, and is very susceptible to errors. If you see an error, please leave a comment and I will fix it asap!

Friday, February 28, 2014

NERDTree Bookmarks in Vim

Overview
Vim is an extremely awesome tool for editing code, but with so many files in web applications, it can quickly become confusing to use. When you're trying to follow 4 or more files at a time, you may decide to leave files open even though you aren't really paying attention to them.

What we Want
What would be great to have is a way to bookmark files/folders, so that we can quickly go to them right when we need them without searching through hundreds of files/folders to find them.

Solution
NERDTree has a bunch of fantastic features, one of them being bookmarks. This is just their way of tagging files and allow you to quickly goto them when needed.

How to show the bookmarks section
To so the bookmarks section, just goto your NERDTree window and press Shift-B. This will toggle the bookmarks section, making it appear. If you want the bookmarks section to not be show, just hit Shift-B again.

How to create a Bookmark
To create a bookmark, just put your cursor over the file/folder you want to bookmark, then type and enter :Bookmark. This will create a bookmark in the bookmarks section. You can treat this as any other file/folder in NERDTree, and open it with "i" or "o".

How to Delete a Bookmark
To delete a bookmark, put your cursor over the file/folder you want to delete, then press Shift-D, then confirm by typing "y".

Conclusion
Bookmarks can make your programming experience much more enjoyable and is highly recommended over having a bunch of windows open at once

Resources
  • http://dailyvim.tumblr.com/post/51238147680/nerdtree-bookmarks


NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Thursday, February 27, 2014

How to goto the beginning or end of a line in Vim

Overview
Much of the time in vim you'll want to goto the beginning or end of a line. My solution thus far has been to just press "l" until I get to the end, but that takes a long time on some long lines. Another bad solution is to just hit "w" or "e" to go by every word. But that can be annoying because if your reflexes aren't good, the cursor will just end up on the next line

Solution

  • To goto the end of a line
    • hit "$". If your familiar with regular expressions, this signifies the end of a line. If you would like to goto the end of a line and enter edit mode, hit "A".
  • To goto the beginning of a line
    • hit "0" or "^". I personally find it easiest to hit "0", but if you're familiar with regular expressions, "^" signifies the beginning of a line. If you would like to goto the beginning of a line and enter edit mode, hit "I".
Conclusions
These commands will allow you to be a lot faster when editing your code.

Resources:
  • http://stackoverflow.com/questions/10243551/go-to-beginning-of-line-without-opening-new-line-in-vi
  • http://stackoverflow.com/questions/105721/how-to-move-to-end-of-line-in-vim


NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Wednesday, February 26, 2014

How to Reset your Branch to Remote Code on Github

Overview
Sometimes Github may be giving you issues and not allowing you to reset your local branch with your remote branch. If you don't have any code that you need saved on your local branch, here's a good way of fixing this situation

Solution
Issue these commands:

    git checkout master
    git branch -D <your_branch_name>
    git fetch
    git checkout <your_branch_name>

Explanation of Commands
1) git checkout master - What this does is checkout your master branch so you are no longer on the branch you want to reset
2) git branch -D <your_branch_name> - This deletes your local branch, even if files are not merged from your local machine to your remote github account. This will not delete anything that you have already pushed to github.
3) git fetch - This downloads all of the branches onto your local machine so that you can easily checkout any of them onto your local machine
4) git checkout <your_branch_name> - This checks out the branch you want to be on that was just downloaded from github.

Conclusion
This will reset all your local changes, so you have to be careful that your local changes are saved. You should be able to issue the command "git stash" before, then "git stash pop" after in order to maintain local changes, but I need to test this first to make sure it works before saying for sure.



NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Monday, February 24, 2014

How to Execute a Terminal Command From Vim

Overview
Vim is my editor of choice, mostly because I like how it looks, I like being able to solely use the keyboard and, after some practice, the commands are pretty intuitive and easy to learn. However, one major thing I need to do often in order to be effective at my job is to grep for variables and functions to follow the code's flow. But vim makes it difficult because it's run in the terminal that you opened it from, so unless you close out of your file you'll have to find other ways of executing the command.

Bad Solution
The bad solution to this is to have multiple terminals, one for code, and one for doing random commands, like grep. The problem with this is this can quickly get very clunky and hard to organize.

Good Solution
The proper solution to this is to issue the command in vim. You can issue any command in the terminal from vim by typing :! then then command. So to execute a grep command from the terminal, type this in your vim file:

        :! grep -r "<thing_you_are_searching_for>"

Replacing <thing_you_are_searching_for> with whatever word or phrase you want to replace. You will be taken back to the terminal and shown the results from your search. You can then go back to your vim session by hitting the "Enter" button on your keyboard.



NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Friday, February 21, 2014

Security: Make Sure None Of Your Passwords Are Stored On Your Computer

Overview
------------
We've all done stupid things in our lives. As programmers, we tend to do stupid stuff on our computers. One of those stupid things may be storing passwords in files on your computer.

We all have reasons why we may have done this. Whether we "needed" to add those passwords in to make a program work, or we wanted to save ourselves time by making a program that automatically logs into certain websites to scrape information.

Don't Store Passwords On Your Personal Computer
------------------------------------------------------------------
A good rule of thumb is to not store your password anywhere on your local computer. Because personal computers are very vulnerable from random stuff we download, going to sketchy sites and a large number of other things, it makes it easier for hackerz to gain control of your computer/log in as you. Because of this, anything you can view on your computer, whoever gains access to your computer can view the exact same thing. So any passwords you have on your computer will be compromised without even knowing it.

How to Fix This
---------------------
What you should do is search your computer and find all of the passwords that you use to log into websites/bank sites and any other important things, like social security numbers, and remove them. In order to do this without your computer recording the command, type this command (MAKE SURE THERE'S A SPACE IN FRONT OF IT) in your terminal:

 grep -r "<your_password_you_want_to_find>" /

Make sure you replace <your_password_you_want_to_find> with the password you are trying to find on your system. Here's an explanation of what this command does:

space at the beginning - The space at the beginning tells the terminal not to record this command in your bash history (in the ~/.bash_history file). You'll want to be sure this will work first by issuing the command "echo $HISTCONTROL" in your terminal. The output you want to see is either "ignoreboth" or "ignorespace". If neither of those is the output in the terminal, then you'll want to set that variable like this: "export HISTCONTROL=ignorespace"

grep - This command is the standard search in unix. It searches for the word/phrase given to it

-r - recursively look in all directories that you specify. This allows you to look inside the directories in the folder you specify, allowing you to search the entire system

"<your_password_you_want_to_find>" - This is the word/phrase that is being searched for. If you wanted to find variations of a password, you can make this into a regex expression.

/ - This makes the command run under the root directory (The lowest directory there is) so that you can search the entire computer.

Removing the Passwords
--------------------------------
Once the grep command find all of the occurrences of your password, you need to go into each file and remove the password.

Conclusion
--------------
Removing passwords from your computer is important to ensure your security from hacking attacks. Some passwords for things like websites or databases you create may need to be stored on your computer, but you should never have to store things like your email password or social security numbers on your personal computers.

Resources
-------------
- http://stackoverflow.com/questions/8473121/execute-command-without-keeping-it-in-history
- http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/

NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Thursday, February 20, 2014

Adding Desktop Workspaces in Ubuntu

Overview
Having 4 Workspaces in Ubuntu is fantastic. You're able to have whatever windows you want cleanly open, while still keeping your screen clean and organized. However, 4 Workspaces is not always enough. For me, having 2 more workspaces would allow me to be a much more productive

CompizConfig Settings Manager
In order to add more screens to your setup, you'll have to download CompizConfig Settings Manager. goto your application "Ubuntu Software Center" and search for "CompizConfig Settings Manager". Download the application, then open it.

Once the application is open, Search for and click on "General Options". In the new menu, click on the "Desktop Size" tab in the top right. In this new tab you'll see 3 options:
  • "Horizontal Virtual Size"
    • If you want to add a column of new Workspaces, then add 1 to this
  • "Vertical Virtual Size"
    • If you want to add a row of new Workspaces, then add 1 to this
  • "Number of Desktops"
    • I'm not sure what this option does

When You're Finished
When you're finished making edits, just close the application and you'll now have more workspaces!


NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Wednesday, February 19, 2014

Learning Programming Effectively

Overview
If you ask most programmers how to become great at programming, you'll usually get the same response, "Program." While experience in writing code is extremely important in learning how to be a great programmer it doesn't quite capture the full picture of how to learn programming effectively.

First Things First: Please Take All This Advice With A Grain of Salt
I've found the worst thing you can do is nothing at all. Do whatever you enjoy doing to learn. If you are doing nothing because you want to do something "right," then that will just hinder you and your talent. So whatever advice you don't like here, just ignore.

The best way to learn anything is to start a passion/obsession for it. Just do whatever you need to do to love coding. If you become proficient, you start applying some of these techniques.

Taking the Athlete Approach
Becoming the top in your field is very similar no matter what you're doing. Because athletics has refined their training strategy over many years, I like to take that as an example.

Practicing
If you look at College Athletes, they typically train for around 4-5 hours (or longer) every weekday (I used to be one of them), taking a couple days off to rest. During these practices they typically run drills, learn how to refine their skills, learn new skills, watch film of themselves and others, and scrimmage/play the game.

Practicing Learned Skillz
If you're like me, you don't like doing repetitive stuff. If you do it once, then you want to say it's done and you'll never have to do it ever again. However, this is not great learning-wise. Athletes will do the same stuff over and over again because that's what allows them to get faster and/or stronger at that activity, as well as commit it to memory. If you want to get better at programming, you'll have to practice doing things over and over again. If you do this, you won't forget if you run into the issue ever again (which is extremely likely), you'll be able to use that knowledge on other issues, and you'll be a lot faster at writing code like that.

Practicing for Speed
The faster you are at performing certain tasks like debugging, writing code or finding the correct files to edit, the more time you will have to be a better programmer. Doing speed excercises, like writing a certain python program over and over quickly, or getting to different folders/files in unix as fast as you can, or debugging a bug faster and faster, will allow you to be a faster programmer and be able to retain information in your brain for fast retrieval.

Learning from Mistakes
Most athletes don't have train alone: They have coaches to help them get better and teach them how to get over personal hurdles. Programming has something actually better: A community of coaches/teachers.

I'm pretty sure most programmers know this one, but I'll repeat it here: You can Google Anything! Google is a fantastic resource for debugging errors in your code. The programmer community is one of the largest communities on the internet. Older programmers know how tough learning how to program can be, and it seems almost all want to give back to the younger generation. Because of this generosity, we have communities like Stack Overflow to help you learn how to fix bugs you've encountered. All you need to do is type in your error in Google and you should get at least a couple results. If you can't find anything from Google, goto Stack Overflow yourself and ask the question!

Learning new information
Athletes like to look up information to see how they could improve their techniques or how to train better. Programmers need to learn more information about specific technologies, or research to see if there are any new programs or technologies. Again, we have Google to the rescue. Google anything, find something you want to learn about, and take notes! Study it like something you'd study in school (Unless you don't want to).

Taking and Reviewing Notes
You need a way of remembering things you've done. If you don't remember, then you'll be bound to repeat looking up stuff on Google, which is inefficient as well as annoying to do. By taking notes, you'll be able to easily review important details and commands you've learned.

Along with taking notes on things you've done, you should also write comments in your code! If you ever go back to the code you've written, you want to be able to easily find out what you were thinking. Also, you want others to be able to read your code and find out what the heck you were thinking.

Taking notes is hitting a save button in a video game. If you were fixing a bug and you need to go back to it another day, then sometimes you'll have to go all the way back to the beginning, retrying things you've already done to try to fix it. If you write notes, you can be caught up to speed extremely quickly and won't have to redo things you've already done.

Reviewing Video
I don't think a lot of people will take this one seriously, but reviewing video of yourself programming/learning can significantly help you become a better programmer. It allows you to examine your actions, allowing you to take note and fix things later. It allows you to take notes on things like code and commands later so you don't have to bother yourself while you're in the zone. It allows you to review things at a later date and share with others so that they may learn how to do things they didn't know how to do before.

If you want help setting up your environment to be able to automagically take video from the terminal, and reduce the size of the file, please comment/message me and I will show you how. It's a bit too complicated to explain here, but it's really cool once you've gotten it going.

How to Apply This Strategy of Learning
Here's a decent way of applying these learning techniques
*This should be done at least once a day for about 30 minutes*
Take Film
- Look over yesterdays stuff
  - quickly go over commands in the terminal
  - Try to write any programs and code learned yesterday again quickly
- Repeat until feel comfortable
Stop Film
Review Film at 8 times speed & Write Down notes you feel would help

*This should be done for every new thing you do, trying to limit yourself to programming thing per hour*
Take Film
-  Review What have learned previously
-  Run the new commands/code you've learned
-  Write Code
  - Write Comments as you go
  - Keep text file of what you've done
  - If you don't know something:
    - Look it up
    - Write down the thing w/ comments & fix code
Stop Film
Review Film at 8 times speed (or faster) & Write Down notes you feel would help

Conclusion
If you are just getting started learning how to program, please don't pay too much attention to this post. The most important thing you can do is develop a passion for programming and to start writing programs or, if you are more of a beginner, taking classes at sites like Code Academy or TeamTreehouse. However, if you're an intermediate programmer trying to become a great programmer, maybe try some of these techniques if you feel like it.



NOTE: Please note that I am not an expert at this topic and this info can certainly be improved. If you have questions, comments or suggestions for this blog post, please comment! Also, this guide is currently in rough draft form. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).

Tuesday, February 18, 2014

Programmer's Guide to Note Taking

Overview
I've always been an avid note taker, but it always seemed that I would go from one note taking app to another. I thought all my problems were solved when I found out about Google Docs. It seemed like the perfect solution for me to view notes across my 4 computers. Google Docs allows you to sync instantly over the internet, write down and organize notes on any computer with an internet connection and share painlessly with others over the internet. It was fantastic for a long time, but always had an issue: you needed an internet connection.

Reason For Issue
I would sporadically go without internet connection in dire situations: When I was bored, in a meeting or at my Girlfriend's mum's house. In these situations I would be left without my notes and not know what to do.

Possible Solutions
There are apps for google docs that you could download in order for your notes to be downloaded locally and synced up when you have internet connection. However, I found most of these apps were either hard to use, or required you to buy it.

There was also a way to download your google docs using "googlecl". This seemed like a perfect solution at first, but apparently the code is broken in several key areas, like uploading a document to a specific folder, so it isn't a great solution if you have multiple folders.

Programmer's Solution
I've learned to love Github. All of the pushing of code up and pulling it down locally, collaborating, etc. It's just a fantastic tool for programmers to write code and be able to manage the code effectively. But the awesomeness doesn't have to stop with coding.

By creating a new repository just for note taking, you're able to easily pull down your repository to each computer you want to write notes on. Because you're a programmer, you'll be able to then take notes on your favorite text editor. To save time on formatting, you can take notes in markdown format, which is easy to learn and take notes on. You can collaborate easily with others if you want to create a repository of notes on a class.

One thing to note is these notes won't be private unless you make the repository private. Github has a fantastic deal for college students. They give free micro subscriptions to college students for four years, which give you 5 free private repos. If you aren't a college student, then you'll have to pay $7 a month to have private repos.

Other People Who've Tried This
Here's another person who's tried this note taking strategy: Cory's Blog

NOTE: Please note that I am not yet an expert at this topic and this info can certainly be improved. If you have questions, comments or suggestions for this blog post, please comment! Also, this guide is currently in rough draft form. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).