Thursday, December 12, 2013

GS3: Prevent Recurring Downloads

If you're like me and updated to Android 4.3 recently, only to find out you get all of these annoying "phantom" downloads that keep popping up, then here's what you do (got this from Android Forums):


  • Go to the "Downloads" app.  Look for it, it's there.
  • Clear all the downloads in both tabs.

You should be good to go!

Tuesday, November 26, 2013

Beginnings With Entity Framework

I've used Entity Framework (EF) a bit, but haven't really given it a 'go' in my own code, so that's what I started doing today.

References

  1. http://msdn.microsoft.com/en-us/library/vstudio/cc716677(v=vs.100).aspx
  2. http://www.entityframeworktutorial.net
Background

I'm currently in the midst of putting together an API, using the "Class Library Project" template in Visual Studio, however I also wanted to store the data to a database using EF but EF is mostly geared towards Web Projects.  How do I integrate it?  My searches led me to Reference #1, above.

General Procedures

You can either follow the guide in Ref #1 above, or to get a general idea, you follow along here (I'll also give a simple example on retrieving data). Here I'm assuming you have already created a database in SQL Server.
  1. Create a new Solution, using the "Class Library Project" template option.
  2. Add a new project that will access EF in your class library, say, a Console Project (Solution Explorer --> Right-Click --> Add --> New Project)
  3. Add a reference to your class library inside your Console Project (Right-Click Console Project --> Add Reference --> Solution)
  4. Add a reference to System.Data.Entity inside your Console Project (Add Reference --> Assemblies)
  5. Add a Conceptual Model to the Class Library Project, i.e., Entity Framework. (Right-Click Project --> Add --> New Item --> Data --> ADO.NET Entity Data Model)
    1. A wizard will step you through the process of adding the tables from your existing database.  You basically make a connection to SQL Server, select the tables you would like to access, and click OK.
    2. This will create you a .edmx file and show you a diagram of you entities (this will initially resemble your db)
  6. Copy your app.config connection string to the Console Project
    1. Open app.config in your Class Library Project --> Copy the connection string ( name usually ends in -Entities, or however you name it in the wizard, above)
    2. Paste into the Console Project's app.config
    3. Save.
  7. Head over to your Console Project and edit the automatically created class (*.cs) and start accessing data.  Something basic like this:


Here, Team is an entity created by EF.  You can see all your entities by going looking through your edmx or looking at the EF graph. dbContext is your interface to the db via the context object, and you must add an entity to the context before you can save, as seen above.

To learn more ways you can interact with EF, I highly suggest visiting the link in Ref#2, as it describes a plethora of tasks, including updating, deleting, one-to-many and many-to-many relationships with EF.

Resharper & Visual Studio

I love Resharper from JetBrains.

However, I am a bit torn in using it because I realize the double-edged sword it presents, and I think any fan of Resharper may agree with me on this one:  while it may help you optimize your code on-the-fly as you are coding, over-reliance may weaken or even inhibit your learning of the code.  This is especially true when you are under a tight deadline and don't have a lot of time to scour your code again for more in-depth optimization, but on the other hand, Resharper is there to save the day when you didn't know you could refactor your project a certain way, or use a certain technique.

To alleviate this conundrum, I try to take the time every time Resharper suggests and optimization (hello yellow light bulb) to learn the technique, and prevent the suggestion from ever appearing.  As a junior developer I know this is especially important as I will not always be able to have Resharper available to me, and knowing these optimization techniques is key in everyday coding, however I am grateful that Resharper is there to suggest to me these techniques along the way, so that I may internalize them and use them in the future.

In sum, if using Resharper be wary not to rely on it too much as I believe it can inhibit and hinder actual code knowledge and optimization techniques if you don't take the time to realize what it is doing for you.  On the other hand, you may learn a few new tricks you'd never known before and add them to your coding 'arsenal'.  

Monday, November 25, 2013

Github and Visual Studio 2012

While I appreciate that MS has integrated support for Github into VS2012, setting it up is not so intuitive, even with a few resources around the web.  Here are a couple that helped me:

Resources
  1. http://mariusbancila.ro/blog/2013/01/31/visual-studio-2012-and-git/
  2. http://blogs.msdn.com/b/visualstudioalm/archive/2013/02/06/set-up-connect-and-publish-using-visual-studio-with-git.aspx
General Step from the guides above
  1. Install Git Tools from Microsoft
  2. Create your project in VS, and be sure to select the "Create Git Repo" option
  3. Right-click your project in the Solution Explorer, and "Add to Version Contol"
  4. Do an initial commit to your local git Repo
    1. In Team Explorer, click the drop-down and goto "Changes"
    2. Enter in a summary
    3. Click Commit
  5. Sync (in Team Explorer)
    1. From the drop-down click "Unsynced Commits"
    2. Drop in your Github (*.git) location - be sure to include the .git!
    3. Sync
Adding a branch to Github (from Visual Studio 2012)
  1. Create a local branch (Team Explorer --> Home --> Branches --> New Branch)
  2. Right-click the new branch under "Unpublished Branches" --> Publish Branch

Tip:  If you got the "Branch master does not exist error", you can check out the solution in Resource #2.  I have an *unconfirmed* suspicion that leaving out the (.git) extension in step #5 above will cause this error, as I recreated the project, adding the (.git) extension instead, and I can now commit to Master.

Tip:  "Commit" is local, and "Sync" is Github (or remote).  If you are working on multiple branches, don't forget to switch to the correct branch when making your edits.


Sunday, November 17, 2013

Starting as a Junior .NET Web Developer

In this post, which I will try to update as I learn new things as a junior ASP.NET web developer, will contain facts, tips, and ideas that I've gathered that I believe that may be helpful as a reference/guide/refresher.

 First Steps.

  1. Get a copy of Visual Studio (it's free!) 
    1. http://www.visualstudio.com/en-us
  2. Sign up for Microsoft Virtual Academy (MVA).  
    1. They have tons of free online courses that you can add to a development plan, covering topics such as MVC, .NET 4.5, and mobile development, just to name a few.
  3. Learn C#
    1. If you're completely new, or may have missed a few things:
      1.  http://meme.ms/nqgkbix
    2. If you're established with C#:
      1. http://meme.ms/nqjhnr1
  4. Learn .NET Web Apps (all-day Jump Start course)
    1. http://www.microsoftvirtualacademy.com/training-courses/create-web-apps-with-asp-net#
  5. Start to dabble in the topics covered.
    1. The Web Apps Jump Start video covers a lot of ground to introduce the major topics in ASP.NET 4.5 web development.  Pick a few and try to reproduce them on your own.  Try out JQuery, Knockout, Razor templates, or develop a Web API.  Knowing the ideas is great, but you need to actually practice them.  Start small, and scale up, maybe using Windows Azure.
  6. Sign up for Windows Azure (cloud hosting and development - free!)

Saturday, November 16, 2013

Mac Terminal Colors (Files & Folders)

So it appears you can colorize the files and folders in the Mac terminal.  I'd never bothered until now to figure it out, and with some Googling I found the answer.

In your ~/.bash_profile simply drop in this line:
export CLICOLOR=1
and now all of your folders and files will be colorized, similar to linux and Putty.