Share the Love! Free Programming eBooks

Leave a comment Standard

GoalKicker.com is giving away these free programming books and I thought I would share the love for anyone who hasn’t seen them yet. There are more available from their website but these are the ones I was most interested in. Enjoy!

Screen Shot 2018-01-31 at 4.26.46 PM

Screen Shot 2018-01-31 at 4.26.54 PM

Screen Shot 2018-01-31 at 4.27.01 PM

Screen Shot 2018-01-31 at 4.27.11 PM

Screen Shot 2018-01-31 at 4.27.18 PM

Screen Shot 2018-01-31 at 4.27.24 PM

Screen Shot 2018-01-31 at 4.27.37 PM

Screen Shot 2018-01-31 at 4.27.44 PM

15 Things Schools Won’t Teach You About Programming

Comments 4 Standard

Don’t get me wrong, going to school to learn how to program is great but there are some things that schools seem to miss the mark on and these drive me nuts.

  1. Copying – well yes, cheating is bad and you should do your own work in school but it’s also not reasonable to expect someone to go it alone on a project in a job setting. Your manager won’t ask you to live in a bubble of seclusion when they want you to complete a difficult task in a short amount of time. In fact they’ll encourage you to use outside resources and other programmers to get the job done. This is one of my worst pet-peeves about schools. Sure you need to know how to program but in the real world you aren’t required to go it alone without any kind of external resources at your disposal or the collaborative programming with other co-workers.
  2. Scope Creep – so in school your projects have a nicely defined list of features and requirements your professor wants you to implement. However the real world isn’t so nice and cut and paste — even if you have well developed requirements. The fact of the matter is you often won’t know what requirements you need to fulfill until you stub out some kind of prototype and show it to your clients and get their feedback. In addition you’ll typically find things that you didn’t think about which make you scratch your head and go back to the drawing board a time or two.
  3. Text Book Solutions – if you’ve ever done an assignment from a textbook with an answer key in the back you know exactly what I’m talking about. There’s always that one solution that’s deemed the “correct” answer. In reality there often isn’t a single solution to a problem and what may work as a solution in one environment is a complete and utter failure in another as the scale or complexity or speed of the results actually hinder the user experience.
  4. Making The Grade – everyone knows you’re supposed to get straight A’s in order to get a good job after school. Wrong! I’ve never known an employer to ask for a GPA or how many times I failed a class. The truth is your grades don’t matter, it’s your knowledge and experience that count. So what if you have straight A’s in every class you ever took if you’ve never had any practical experience building your own program or working on a large, complex project. No one cares what your grades are, they want to know you can get the work done well and in a timely fashion with minimal bugs.
  5. Re-Inventing The Wheel – yes it’s important that you understand how and why something works but schools are notorious for having their students re-invent the wheel. Let’s write five different types of searches that most languages have built in functionality for, or let’s write a function that swaps two values so you can use it in later projects. Please, don’t re-invent the wheel. If it’s already done for you then why are you wasting your time? Understand how it works and then take that knowledge and build something useful, don’t just regurgitate what’s already been done over and over again.
  6. Debugging – this is one of the most useful skills you can have and yet schools are sadly lacking in teaching students how to intelligently debug errors and use helpful debugging tools. In addition most schools stress actual programming when even the software life-cycle emphasizes maintenance and  bug fixing as a majority of the time spent on piece of software. Why are schools leaving this out of their curriculum when most new programmers are tasked with bug fixes in order to learn how a large piece of software works?
  7. Documentation – there is a sad lack of acknowledgement for documentation in programming. Some schools will skim over it briefly but for the most part it’s a passing reference in a class. I’m amazed at how many new programmers I interact with who have thousands and thousands of lines of code without a single comment. Now some of you may argue that documentation isn’t needed however if you’ve ever returned to work on a project you set down years ago you know those hours you spent trying to figure out why you did something that you didn’t document could have been better spent with the 5 minutes documenting it in the first place.
  8. Deadlines – in school you’re given long deadlines to get something done. Deadlines aren’t as set and fixed in a job setting. One day your boss may walk up to you and say “I need this in an hour.” If you’re always used to long, drawn out deadlines then you get that deer in the headlights look in your eyes. Of course this works both ways, and I’ve worked on projects that have no deadlines either. The point to take away from this is deadlines are flexible and rigid, achievable and impossible to meet and not a fixed point in time and space.
  9. Multitasking – in school you only work on a single project at a time until that project is done. A job setting is far from that. You may start a project one day, have it scrapped the next day and then returned to you six months later. In addition it’s common to be working on multiple projects at a time as you wait for other requirements or client feedback to trickle in. Asking students to work on one project at a time is detrimental to them learning how to multitask and adjust as the situation warrants.
  10. Pass or Fail – schools have a pretty black and white approach to how a program is supposed to work in order for you to get a passing grade. What they forget is often times a project just needs to be “good enough” due to deadlines or budgets or resource constraints. Something that is good enough to meet the requirements doesn’t mean you failed, it means you have room for improvement and re-factoring.
  11. Refactoring – I would love to see a school tell a student to take the first project they completed at the beginning of the year and re-write it with what they know now. Re-factoring is a major aspect of a programmer’s job and yet few students are asked to look at their past work, reflect on how it could be improved, and then set to the task of improving it. This is something most programmers are faced with on a yearly basis as they complete new iterations and features of their software.
  12. Coding Together – since schools are so intent on grading you as an individual the students miss out on the ability to code collaboratively. There is rarely a time when a complete piece of large software will have been written by a single person. Being able to read and understand other people’s programming and to match your style to theirs is a huge asset and ability that shouldn’t be overlooked.
  13. Best Coding Practices – so you learn the programming fundamentals but you’re hardly taught when you should use one rather than the other and where, how or why you make that decision.
  14. Code Style Guidelines – one of the biggest indications of a good programmer is their coding style. Code that is easy to read, indented properly, and consistently written is essential for improving maintainability of a piece of software. Most new programmers run their lines of code in big long strings with inconsistent spacing and style guidelines. Would you rather read 1,200 lines of code condensed onto 5 lines that makes you scroll infinitely in your editor to read them or properly indented and spaced code in a logical and easy to read manner? I know which one I’d choose.
  15. Experience – there is no substitute for real experience. No school can give you anything more than an introduction to programming no matter if you spend a year or four years learning and expanding your knowledge. There’s a wonderful article by Peter Norivg that I like to give anyone whose interested in making programming a profession. You can’t take ten years of experience and condense it into a quick fix or four year series of courses. Experience will always be your best teacher.

Got a few minutes? Check out the best tools to test your websites responsiveness.

Node JS Tutorial: How To Create A Simple Server

Leave a comment Standard

This will allow you to quickly setup a working node server in just a few easy steps.

1. Install Node.js

For Windows/Linux
Go to http://nodejs.org and download the
latest version of node for the operating system you want to install it on.

Open node and test if it’s working by typing 2+2 and hitting enter.

For Mac OS X
Visit Homebrew and then open your
command line and run (If you’re prompted to install command line tools go ahead and do that). :

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

When that’s done run you can make sure your install was successful by running:

brew doctor

Then it’s a good idea run this to make sure you have the most up to date copy:

brew update

Then install node by running:

brew install node

Test your install by opening a command line and typing this to see the node version:

node -v

2. Install NPM

This package will help you install lots of node related libraries. You can find out more
about it by visiting https://npmjs.org.
Open a command line and type:

npn install express body-parser

If you get an error on Windows that says something along the lines of

Error: ENOENT, stat...

This means the NPM directory is missing from your filesystem. Navigate to where NPM should be as displayed by the error message and create an empty folder called npm.

3. Create These Simple Server Files

First let’s make our index.html. This should go in the directory you want to serve this index file from. So on a server it would be something along the lines of htdocs/public_html/directory/ or var/www/html and on your local computer it should be whatever directory you did your npm install.

Create the index.html file:

<html ng-app="app">
  <head>
    <title>My First Node Server File</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/stylesheet.css">
  </head>
  <body ng-controller="appCtrl">
    <div class="page-header">
      <h1>
        <i class="glyphicon glyphicon-certificate"></i>
        Congratulations!
      </h1>
    </div>
    <section>You have successfully created your first HTML5 node server.</section>
  </body>
  <footer>
    <a href="http://design1online.com" target="_blank">Tutorials by Design1Online.com, LLC</a>
  </footer>
</html>

Now let’s create the server.js file:

'use strict';

// Importing express and body parser libraries
var express = require('express');
var bodyParser = require('body-parser');

//this is a built in node library that handles the file system
var fs = require('fs');


/**
* Server configs
*/

/**
* The port to run your node server on
* 
* If you're running this on a web server this should be 80
* If you're running this locally try 8080 or 9080
*/
var BASE_PORT = 8080;

/** 
* The root directory of your files
*
* By default it uses the current folder this file is in
*/
var ROOT_DIR = __dirname + '/';
ROOT_DIR = fs.realpathSync(ROOT_DIR);
if (!fs.existsSync(ROOT_DIR)) {
	console.log('Error: cannot find working directory: ' + ROOT_DIR);
	exit();
}

/**
* Create an instance of express
*/
var app = express();

/**
 * Adds a simple logging, "mounted" on the root path.
 * Using Express middleware
 **/
app.use(function(req, res, next) {
	console.log('%s %s', req.method, req.url);
	next();
});

/**
 * Allows us to parse http body parameters as json
 **/
app.use(bodyParser.json());

app.use(express.static(ROOT_DIR));

app.listen(BASE_PORT, function() {
	console.log('Node server started @ http://localhost:' + BASE_PORT);
	console.log('Serving static files from ' + ROOT_DIR);
	console.log('Press Ctrl + c for server termination');
});

4. Start the Server

Go to the directory you installed npm in and that your index.html and server.js file reside. This is where you want to start the node server. In the console type:

node server.js

Now open your browser. If you installed node on a server then navigate to your index page on your website. You should see your new node js index file. If you’re running the node server on your local machine then type in http://localhost:BASE_PORT and replace BASE_PORT with the port number you configured in the server.js file. You’ll see your index file in your browser.

Congrats! You’ve successfully create your first node server.

Error FIX: Ubuntu LAMP server won’t display flash applets

Comment 1 Standard

If you’re using a Ubuntu LAMP server and you find that your flash applets aren’t being served by your server even if you go directly to the file location then you’ve run into the same problem I did. This happens when apache doesn’t recognize the mime type of the file.

The Solution

Edit your mime.conf file. If you’re using apache2 it will be:

vi /etc/apache2/mods-enabled/mime.conf

Add the following line under the other uncommented out mime types and save your changes:

AddType application/x-shockwave-flash .swf

Make sure you restart apache when you’re done:

service apache2 restart

Linux Tutorial: Fix Heartbleed on Ubutntu 14.04

Leave a comment Standard

I’ll keep this short and sweet!

sudo apt-get update && sudo apt-get install --only-upgrade bash

Cywgin .bashrc file

Leave a comment Standard

I’ve been working on my .bashrc file so I thought I would share.

# To the extent possible under law, the author(s) have dedicated all 
# copyright and related and neighboring rights to this software to the 
# public domain worldwide. This software is distributed without any warranty. 
# You should have received a copy of the CC0 Public Domain Dedication along 
# with this software. 
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. 

# base-files version 4.2-3

# ~/.bashrc: executed by bash(1) for interactive shells.

# The latest version as installed by the Cygwin Setup program can
# always be found at /etc/defaults/etc/skel/.bashrc

# Modifying /etc/skel/.bashrc directly will prevent
# setup from updating it.

# The copy in your home directory (~/.bashrc) is yours, please
# feel free to customise it to create a shell
# environment to your liking.  If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the cygwin mailing list.

# User dependent .bashrc file

# If not running interactively, don't do anything
[[ "$-" != *i* ]] && return

# Shell Options
#
# See man bash for more options...
#
# Don't wait for job termination notification
# set -o notify
#
# Don't use ^D to exit
# set -o ignoreeof
#
# Use case-insensitive filename globbing
# shopt -s nocaseglob
#
# Make bash append rather than overwrite the history on disk
# shopt -s histappend
#
# When changing directory small typos can be ignored by bash
# for example, cd /vr/lgo/apaache would find /var/log/apache
shopt -s cdspell

# Completion options
#
# These completion tuning parameters change the default behavior of bash_completion:
#
# Define to access remotely checked-out files over passwordless ssh for CVS
# COMP_CVS_REMOTE=1
#
# Define to avoid stripping description in --option=description of './configure --help'
# COMP_CONFIGURE_HINTS=1
#
# Define to avoid flattening internal contents of tar files
# COMP_TAR_INTERNAL_PATHS=1
#
# Uncomment to turn on programmable completion enhancements.
# Any completions you add in ~/.bash_completion are sourced last.
# [[ -f /etc/bash_completion ]] && . /etc/bash_completion

# History Options
#
# Don't put duplicate lines in the history.
# export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
#
# Ignore some controlling instructions
# HISTIGNORE is a colon-delimited list of patterns which should be excluded.
# The '&' is a special pattern which suppresses duplicate entries.
# export HISTIGNORE=$'[ \t]*:&:[fb]g:exit'
# export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:ls' # Ignore the ls command as well
#
# Whenever displaying the prompt, write the previous line to disk
# export PROMPT_COMMAND="history -a"

# Aliases
#
# Some people use a different file for aliases
# if [ -f "${HOME}/.bash_aliases" ]; then
#   source "${HOME}/.bash_aliases"
# fi
#
# Some example alias instructions
# If these are enabled they will be used instead of any instructions
# they may mask.  For example, alias rm='rm -i' will mask the rm
# application.  To override the alias instruction use a \ before, ie
# \rm will call the real rm not the alias.
#
# Interactive operation...
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'
#
# Default to human readable figures
# alias df='df -h'
# alias du='du -h'
#
# Misc :)
# alias less='less -r'                          # raw control characters
# alias whence='type -a'                        # where, of a sort
 alias grep='grep --color'                     # show differences in colour
 alias egrep='egrep --color=auto'              # show differences in colour
 alias fgrep='fgrep --color=auto'              # show differences in colour
#
# Some shortcuts for different directory listings
alias ls='ls -hF --color=tty'                 # classify files in colour
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
alias ll='ls -l'                              # long list
alias la='ls -A'                              # all but . and ..
# alias l='ls -CF'                              #

# Umask
#
# /etc/profile sets 022, removing write perms to group + others.
# Set a more restrictive umask: i.e. no exec perms for others:
# umask 027
# Paranoid: neither group nor others have any perms:
# umask 077

# Functions
#
# Some people use a different file for functions
# if [ -f "${HOME}/.bash_functions" ]; then
#   source "${HOME}/.bash_functions"
# fi
#
# Some example functions:
#
# a) function settitle
# settitle () 
# { 
#   echo -ne "\e]2;$@\a\e]1;$@\a"; 
# }
# 
# b) function cd_func
# This function defines a 'cd' replacement function capable of keeping, 
# displaying and accessing history of visited directories, up to 10 entries.
# To use it, uncomment it, source this file and try 'cd --'.
# acd_func 1.0.5, 10-nov-2004
# Petar Marinov, http:/geocities.com/h2428, this is public domain
# cd_func ()
# {
#   local x2 the_new_dir adir index
#   local -i cnt
# 
#   if [[ $1 ==  "--" ]]; then
#     dirs -v
#     return 0
#   fi
# 
#   the_new_dir=$1
#   [[ -z $1 ]] && the_new_dir=$HOME
# 
#   if [[ ${the_new_dir:0:1} == '-' ]]; then
#     #
#     # Extract dir N from dirs
#     index=${the_new_dir:1}
#     [[ -z $index ]] && index=1
#     adir=$(dirs +$index)
#     [[ -z $adir ]] && return 1
#     the_new_dir=$adir
#   fi
# 
#   #
#   # '~' has to be substituted by ${HOME}
#   [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
# 
#   #
#   # Now change to the new dir and add to the top of the stack
#   pushd "${the_new_dir}" > /dev/null
#   [[ $? -ne 0 ]] && return 1
#   the_new_dir=$(pwd)
# 
#   #
#   # Trim down everything beyond 11th entry
#   popd -n +11 2>/dev/null 1>/dev/null
# 
#   #
#   # Remove any other occurence of this dir, skipping the top of the stack
#   for ((cnt=1; cnt <= 10; cnt++)); do
#     x2=$(dirs +${cnt} 2>/dev/null)
#     [[ $? -ne 0 ]] && return 0
#     [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
#     if [[ "${x2}" == "${the_new_dir}" ]]; then
#       popd -n +$cnt 2>/dev/null 1>/dev/null
#       cnt=cnt-1
#     fi
#   done
# 
#   return 0
# }
# 
# alias cd=cd_func

#make a directory and cd into it
mkcd() {
    if [ $# != 1 ]; then
        echo "Usage: mkcd <dir>"
    else
        mkdir -p $1 && cd $1
    fi
}

#create a symlink (aka shortcut)
symlink() {
    if [ $# != 1 ]; then
        echo "Usage: symlink <target_path> [link_path]"
    else
        ln -s $1 $2
    fi
}

#how many directories to cd .. through (ie up 4 moves up 4 directories)
up(){
  local d=""
  limit=$1
  for ((i=1 ; i <= limit ; i++))
    do
      d=$d/..
    done
  d=$(echo $d | sed 's/^\///')
  if [ -z "$d" ]; then
    d=..
  fi
  cd $d
}

#extract an archive
extract () {
   if [ -f $1 ] ; then
       case $1 in
           *.tar.bz2)   tar xvjf $1    ;;
           *.tar.gz)    tar xvzf $1    ;;
           *.bz2)       bunzip2 $1     ;;
           *.rar)       unrar x $1       ;;
           *.gz)        gunzip $1      ;;
           *.tar)       tar xvf $1     ;;
           *.tbz2)      tar xvjf $1    ;;
           *.tgz)       tar xvzf $1    ;;
           *.zip)       unzip $1       ;;
           *.Z)         uncompress $1  ;;
           *.7z)        7z x $1        ;;
           *)           echo "don't know how to extract '$1'..." ;;
       esac
   else
       echo "'$1' is not a valid file!"
   fi
 }

#move up directories with periods
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."

#set command line to colored format user@host:~working/directory $
RESET="\[17\]"
NORMAL="\[33[0m\]"
RED="\[33[31;1m\]"
GREEN="\[33[32;1m\]"
YELLOW="\[33[33;1m\]"
BLUE="\[33[34;1m\]"
MAGENTA="\[33[35;1m\]"
CYAN="\[33[36;1m\]"
WHITE="\[33[37;1m\]"
PS1="${RESET}${RED}\u@${YELLOW}\h${WHITE}:${GREEN}\w ${CYAN}\$${NORMAL} "

#figure out which git branch we're currently on
branch_name=$(git symbolic-ref -q HEAD)
branch_name=${branch_name##refs/heads/}
branch_name=${branch_name:-HEAD}
#shorten git commands
alias gs='git status'
alias gc='git commit'
alias ga='git add'
alias gd='git diff'
alias gb='git branch'
alias gl='git log'
alias gsb='git show-branch'
alias gco='git checkout'
alias gg='git grep'
alias gk='gitk --all'
alias gr='git rebase'
alias gri='git rebase --interactive'
alias gcp='git cherry-pick'
alias grm='git rm'
alias gp='git push'
alias gf='git fetch'
alias gm='git merge'

#switch to the master branch
alias gcom='gco master'

#checkout master branch, pull in changes and then checkout your current branch and merge in those changes
alias gmm='gcom && gp && gco ${branch_name} && gm origin master'
#shows "git diff" across any project in any subdirectory
alias git-differ='for g in $(find . -name ".git"); do g=${g%%.git};printf "$g\t\t\t";pu $g >/dev/null && git diff |wc -l; p >/dev/null; done'

#does git house keeping across any project in any subdirectory
alias git-housekeep='for g in $(find . -name ".git"); do g=${g%%.git};echo $g;pu $g && git repack && git gc --auto && p;done'

# clear the cygwin console
alias clear='printf "33c"'