File Download Script for Visual Studio

download-progress-dialog.png

If you have some binary files you need for your Visual Studio project but you don’t want to add them to your version control system, here’s a PowerShell script that does the downloading for you:

download.ps1

Basically this mimics a very simple dependency management.

Source Repository: https://bitbucket.org/mayastudios/powershell-downloader/

Configuration

At the very top of the script, you define which files to download where.

For example, this downloads the x86 and the x64 version of a SQLite .dll file:

$base_url = 'https://mydomain.com/sqlite'
$files = @{
  '..\sqlite.dll' = "$base_url/x86/sqlite.dll"
  '..\sqlite_x64.dll' = "$base_url/x64/sqlite_x64.dll"
}

Entries must be separated by line breaks or semicolon (;).

Paths are relative to the location of the script file.

Usage

To include the script in your project, call it from your project’s Pre-build event.

For example, if you’ve placed download.ps1 in a folder called libs in your project, use this line to execute it:

powershell -ExecutionPolicy ByPass -File "$(ProjectDir)\libs\download.ps1"

That’s it.

When Does It Download

The script will download the files if:

  • they don’t exist
  • the script file is newer as the files (idea behind this: you’ve changed the file version to download)
  • a file named force-download.txt exists in the scripts folder and this file contains anything else but “false”

These rules are defined in the Needs-Downloading function.

PowerShell functions for the uninitiated (C# programmer)

Being a C# programmer, I recently found some use for Microsoft’s PowerShell (the cmd replacement). What’s nice about PowerShell is that it has full access to the .NET framework.

However, there are also some very pit falls when coming from C# (or any related programming language).

There’s one very mean pit fall when it comes to functions and their return values that – if you don’t exactly know how PowerShell works – makes you pull out your hair.

Read more →

How To Fix Multiple Items In The ‘Open With’ Menu in OS X

Did you ever get that annoying problem that in your “Open With” menu the same app shows multiple times?

Multiple items for the same app showing in OS X's "Open With" menu.

Fortunately, this is easy to fix. Just open up Terminal and paste in the following lines (all at once) to fix the problem!

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user && pkill Finder

Cause of the problem: When you delete an application, its entry in the “Open With” menu is not deleted. This also applies to app updates, where the old version of the app is deleted and replaced by a new one (which gets its own menu entry). The problem probably only occurs for non-Mac App Store apps.

Sort posts by modification date in WordPress

By default, WordPress sorts blog posts by creation date. However, if you update your blog posts from time to time, you may want to sort them by modification date rather than creation date.

To achieve this, use this snippet:

function order_posts_by_mod_date($orderby) {
  if  (is_home() || is_archive() || is_feed()) {
    $orderby = "post_modified_gmt DESC";
  }

  return $orderby;
}

add_filter('posts_orderby', 'order_posts_by_mod_date', 999);

In your theme, just dump this snippet into functions.php. (You may need to create this file in your theme’s directory.)

Android Source Code in Eclipse

Google made developing an Android app fairly simple. Everything you need can be downloaded for free from Android’s development site. This includes the Android API, an Android emulator (for running Android apps directly on your computer), and an Eclipse plugin called ADT (Android Developer Tools). However, there is was one thing missing: the Java source code.

Read more →