Wednesday, August 24, 2016

Become a Programmer in 3 Easy Steps (with links to helpful resources)

My friends keep asking me how I taught myself to write code. This is how:

Requirements before you get started:

- Be literate

- You'll need a computer, even your old Dell laptop collecting dust in the back of your closet will work

- You will also want an IDE (integrated development environment) installed on your machine to make writing and debugging a lot easier. IDEs provide a user friendly interface and a lot of powerful features for developing and debugging applications as opposed to just using a text editor. 

Example: If you're planning on starting with Java as your first language, you'd install a popular IDE such as NetBeans. Most beginner tutorials out there will suggest an IDE for you to start with or a quick google search should point you in the right direction.

  • Step 1: Learn the basics and break stuff
    • Pick any language and find a website, book, or youtube channel that has a bunch of tutorials- they are all roughly the same when it comes to the bare fundamentals of modern computer programming (variables, functions/methods, classes, etc) aside from syntax. Do these tutorials until you start wondering where the more advanced tutorials are and why programming is boring as hell at this point in your journey. You should be able to make simple programs that utilize everything you've learned up to this point and know how to do some basic debugging.
  • Step 2: Break more stuff and learn how to Google
    • Now that you are familiar with the syntax of a language and the fundamentals of programming, you probably wanna build some cool stuff. The good news: you're only limited by your imagination and there's an enormous amount of resources out there like Stack Overflow to help you with literally any problem you run into. Take some time to brainstorm what you want to create with the skills you've learned and what other languages or skills you'll need to learn to make your idea a reality. When in doubt, find someone else's project, look through it and start building a similar one from scratch.
    • If you see a block of code on a tutorial or SO post and want to know how it works, copy it line by line and read up on any keywords or syntax that may be confusing (GOOGLE EVERYTHING), then start modifying it until the program breaks repeatedly. Through trial and error you will learn what works, what doesn't, and eventually be able to write that same functionality without breaking a sweat. If you get stuck, you're not stuck, just lazy. If you feel stuck just google the fuck out of the problem you're trying to figure out.
    • You will break a lot of things, don't stress fam. There will be times in which your IDE doesn't cooperate or you can't figure out why your code is not compiling correctly, but keep in mind that programming does get easier the more you read up on topics you're unfamiliar with
    • Keep building projects and set aside some time daily to write code
  • Step 3: Keep breaking things and learn other skillz
    • By now you're probably balls deep in a project you're interested in and can solve most of your problems with a quick Stack Overflow or Google search. While you're learning new languages and skills I recommend you become familiar with how to use source control, set up a simple web server, and general computer hardware knowledge (GOOGLE EVERYTHING). If you want to develop applications for different platforms that you're unfamiliar with (example: you want to make apps for mobile devices), go back to step one after you've figured out what languages and tools you'll need to begin work.
    • If you see some code that is over your head, don't shy away from it- try to find things you understand and figure out how it works. Then GOOGLE EVERYTHING. 

Monday, May 23, 2016

High vs Low isolation levels in database systems

High Isolation
  • More system resources used
  • More chances of table locking causing other transactions to be blocked. This can harm performance dramatically
  • Reduces types of other concurrency effects that users may encounter

Low Isolation
  • Less system resources used
  • More chances of reading inaccurate data, "dirty reads" and lost data, phantom reads
  • Can potentially improve performance if used correctly
  • Increases types of other concurrency effects that users may encounter

Potential problems to be aware of when using NOLOCK liberally

The sql table hint NOLOCK can be dangerous when abused, especially if there are other stored procedures that depend on and write to the same tables around the same time or concurrently. Reading uncommitted data can impact the integrity of the results returned. These are the same dangers present when using "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED"

Bad things that could potentially happen:

  • Reading uncommitted, inaccurate data ("dirty reads")
  • Missing data from other transactions that occurred during read
  • Reading multiple versions of the same rows
  • Read errors occurring if data is moved during read

Saturday, May 21, 2016

What to avoid when writing stored procedures

A list of bad practices to avoid when writing sql stored procedures

  • Using Subqueries when you could use a temp table
  • Not uppercasing keywords and built in functions
  • No consistent formatting
  • Using nested views
  • Not using a consistent naming scheme for sprocs in the same db
  • Not using "BEGIN" and "END" keywords
  • Not using "SET NOCOUNT ON" when needed
  • Selecting all columns when you only need a few
  • Not using comments
  • Not making comments legible
  • Using cursors
  • Counting rows to verify if data exists
  • Misuse of Object-Relational Mappers (ORMs)
  • Negative searches
  • Not doing large comparisons against temp tables or table variables
  • Double dipping instead of writing one query with good conditions
  • Not using local variables
  • Comparing a lot of strings 
  • Clustering with GUIDs
  • Using "UPDATE" too liberally when "CASE" could be used
  • Doing updates and deletes in large batches
  • Using NOLOCK too much
  • Not using paramerterized queries
  • Importing bulk data with "INSERT"
  • Using "SELECT MAX(ID)" when importing

Friday, October 30, 2015

Running a program as a different user over vpn in Windows

If you ever need to run an application as a different user but that user does not have an account on your local pc:

runas /netonly /user:DOMAINGOESHERE\USERNAMEGOESHERE "path to executable"

Use this batch script template. It's pretty self explanatory, it will ensure that any network communication done by that app will use the credentials specified and not your local account.
In my case I was attempting to run SQL Management Studio from my local pc while using a VPN service.

Sunday, August 9, 2015

Windows 10 - Upgrading from Windows 7 or 8 Tips

  • Check out the FAQ for Windows 10 here: Link to FAQ
  • Upgrading from Windows 7/8/8.1
    • You don't have to wait for the update windows icon. Just download the standalone installer here.
    • If you upgraded from windows 7 or 8, I recommend backing up your important files and doing a clean install of Windows 10 after the upgrade. You can do this by creating a bootable installation medium using the installer provided by Microsoft and booting from it. For me, this helped isolate any driver issues that needed to be taken care of and the whole experience was just smoother after a clean install. Download the standalone installer here. 
    • If you have already upgraded once, you do not need a key for the clean install. Microsoft registers your hardware to verify your legitimacy, so you don't have to worry about finding a Windows 10 key for future installations. Just click "skip" during the installation when it gets to that part.
    • Link to list of common errors

  • Drivers
    • Make sure you update your drivers after your clean install. Open up settings > Connected devices and scroll down to the link that says Device manager. From there, go through your devices and check for updates (Right Click > Update Driver Software).
    • If you are experiencing display or sound related issues, this is the first thing you should try.

Click Here to Buy This Shirt