Updating all sub modules in a git project

This command will find all the submodules in your current git projects and pull down changes from master for each submodule.

git submodule -q foreach git pull -q origin master

Once you pull down changes make sure you push the changes back to your project to see the changes.

What is this actually doing?

git submodule basically gets all the submodules in your project

-q means quiet which means it doesn’t output the name of the submodule as it loops through them. This parameter is not required.

foreach um, it loops through each submodule

git pull -q origin master this pulls down the changes from master on the submodule and doesn’t output the changes. Again, the -q is not required, but will reduce the conole output.

read more

Bash loop through folders recursively and lower case files

This script will loop through all files and folders recursively and make them lower case. Please do not just blindly run this against your intended directory. The echo is there for testing and once you know that works then use the mv command

You can perform any command you’d like after the tr. In my case it’s replace all upper case letters with lower case ones.

If you don’t include the if statement, you’ll get a warning message if it tries to rename to the same case, so that keeps the console clean.

find /home/buschm3/bananas -depth -name '*' -print0 |
while IFS= read -r -d '' src; do
    dst=`dirname "${src}"`/`basename "${src}" | tr '[A-Z]' '[a-z]'`
    echo "$src"
    echo "$dst"
    if [ "${src}" != "${dst}" ]
    then
        #mv "$src" "$dst"
    fi
done

read more

Current request is not of type HttpServletRequest

Ran into this error this week

There was an unexpected error (type=Internal Server Error, status=500). Current request is not of type [org.apache.catalina.servlet4preview.http.HttpServletRequest]: ServletWebRequest: uri=/my/url/

Make sure you imported the correct HttpServletRequest import. I wanted import javax.servlet.http.HttpServletRequest;

read more

Filtering FiveThirtyEight's NFL Forecasting Leaderboard

A group of friends and I have a contest going on FiveThirtyEight’s NFL Forecasting Game Leaderboard and they don’t allow group functionality, so at the end of each week I Ctrl + F on the page to find each of our name’s and update a spreadsheet. Instead of spending 3 minutes once a week I decided to spend 15 minutes and write something that will do it for me.

Just replace the names array with a list of the names in your group

var table = document.getElementById('leaderboard-table-wrap').getElementsByTagName('tr');
Array.from(table).forEach(function(item) {
  var names = ['Matt Busche', 'Random Dude'];
  if (names.indexOf(item.getElementsByClassName('name')[0].textContent) === -1) {
    item.closest('tr').remove();
  }
});

As always you can use a Bookmarklet Creator to add this as a “bookmark” on your address bar to make filtering super easy.

Note: If you can’t find a person, each person needs to acknowledge that they want to publically post their score by visiting the leaderboard page and clicking a link.

read more

Finding md5 hash of file

Fun tip I learned today. If you need to find the md5 hash of a file you can simply user the following command.

certutil -hashfile {path+filename} md5 

certutil is included in windows by default, so you aren’t required to have anything additional installed.

read more