<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Kevin Pelgrims</title>
    <description>Experiments with Android, Git, Gradle, the web, .NET and PowerShell.</description>
    <link>https://kevinpelgrims.com/blog/</link>
    <atom:link href="https://kevinpelgrims.com/blog/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>2026-03-08T20:01:46Z</pubDate>
    <lastBuildDate>2026-03-08T20:01:46Z</lastBuildDate>
    <author>
      <name>Kevin Pelgrims</name>
    </author>
    <generator>Eleventy</generator>
    <item>
      <title>Using multicursor in Android Studio</title>
      <description>&lt;p&gt;One of the most useful methods for editing multiple lines of code or XML in Android Studio (or IntelliJ) is multicursor. This is a feature that makes it possible to edit multiple lines at the same time. There are a few shortcuts you need to remember before you can really take advantage of multicursor, and this is basically a cheat sheet with the most useful multicursor-related shortcuts.&lt;/p&gt;
&lt;h2&gt;Multiple carets&lt;/h2&gt;
&lt;p&gt;There are a few different ways to add and remove carets, depending on the situation.&lt;/p&gt;
&lt;p&gt;With the &lt;strong&gt;mouse&lt;/strong&gt;, use &lt;code&gt;Shift+Alt+Click&lt;/code&gt; to add a caret and &lt;code&gt;Shift+Alt+Click&lt;/code&gt; on a caret to remove it. If you need a faster way to add a bunch of carests, you can press &lt;code&gt;Alt&lt;/code&gt; while clicking and dragging vertically to select a block or a line.&lt;/p&gt;
&lt;p&gt;With the &lt;strong&gt;keyboard&lt;/strong&gt;, press &lt;code&gt;Ctrl&lt;/code&gt;(Windows &amp;amp; Linux) / &lt;code&gt;Alt&lt;/code&gt;(macOS) twice, and then without releasing it, press up or down arrow keys. To delete all the existing carets, except the primary one, press &lt;code&gt;Esc&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Multiple selections&lt;/h2&gt;
&lt;p&gt;There are also several ways to select multiple occurrences of the same text.&lt;/p&gt;
&lt;p&gt;You can manually create new selections by pressing &lt;code&gt;Shift+Alt&lt;/code&gt; and double-clicking the left mouse button. If you want to select matching pieces of text, press &lt;code&gt;Alt+J&lt;/code&gt; (Windows &amp;amp; Linux) / &lt;code&gt;Ctrl+G&lt;/code&gt; (macOS) to automatically find and select the next occurrence of the currently selected text.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2017/12/multicursor_ctrl_g.gif&quot; alt=&quot;Select next occurrence demo&quot;&gt;&lt;/p&gt;
&lt;p&gt;If you need to select all the occurrences, you can speed it up by using &lt;code&gt;Shift+Ctrl+Alt+J&lt;/code&gt; (Windows &amp;amp; Linux) / &lt;code&gt;Ctrl+Cmd+G&lt;/code&gt; (macOS).&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2017/12/multicursor_ctrl_cmd_g.gif&quot; alt=&quot;Select all occurrences demo&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Editing&lt;/h2&gt;
&lt;p&gt;When you make multiple selection, you can edit all the pieces of text at the same time, and use &lt;code&gt;Esc	&lt;/code&gt; to deselect all, except the primary one.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2017/12/multicursor_edit_escape.gif&quot; alt=&quot;Edit and escape demo&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2017/12/multicursor_deselect.gif&quot; alt=&quot;Deselect demo&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.jetbrains.com/help/idea/multicursor.html&quot;&gt;https://www.jetbrains.com/help/idea/multicursor.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://blog.jetbrains.com/idea/2014/03/intellij-idea-13-1-rc-introduces-sublime-text-style-multiple-selections/&quot;&gt;https://blog.jetbrains.com/idea/2014/03/intellij-idea-13-1-rc-introduces-sublime-text-style-multiple-selections/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.jetbrains.com/help/idea/selecting-text-in-the-editor.html#column_selection&quot;&gt;https://www.jetbrains.com/help/idea/selecting-text-in-the-editor.html#column_selection&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>2017-12-29T15:30:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2017/12/29/using-multicursor-in-android-studio/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2017/12/29/using-multicursor-in-android-studio/</guid>
      <category>android</category>
      <category>tools</category>
    </item>
    <item>
      <title>Git commits: You&#39;re doing it wrong</title>
      <description>&lt;p&gt;Git is an amazing tool that makes development in a team a lot easier for everyone. But easy comes with a downside: people think less about what they are doing. I quite often come across commits that hurt my eyes. I will address two common issues that annoy me, and I hope to convince you that they are wrong &lt;em&gt;and&lt;/em&gt; that there is a better way.&lt;/p&gt;
&lt;h2&gt;The &amp;quot;fix previous commit&amp;quot; commit&lt;/h2&gt;
&lt;p&gt;A common pattern in a lot of repositories on Github is the double commit that is actually the same commit, but the first one had a mistake and the second is a fix:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;664e6ac  &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;HEAD, master&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; Fix one line &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; verification method  &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt; minutes ago&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
3945ef1  Add verification method  &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt; minutes ago&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now what is actually one commit, is split into two commits. This is bad for several reasons. The obvious reason is that it becomes harder to read through the commit history, which is now cluttered with useless entries. Another reason is that it becomes harder to use &lt;code&gt;git blame&lt;/code&gt; to figure out when code was written and why. The fixed line is now part of a separate commit, and that commit&#39;s message just says &amp;quot;fixed issue&amp;quot;. The person that stumbles upon that commit has no context.&lt;/p&gt;
&lt;h3&gt;Disclaimer&lt;/h3&gt;
&lt;p&gt;All suggestions will rewrite the history of the repository. If you have already pushed the code, and someone else has already pulled the latest commits, be extremely careful. Any kind of history rewriting could make it very complicated for your teammates to merge later. So keep that in mind as you apply these tricks.&lt;/p&gt;
&lt;h3&gt;The simple solution&lt;/h3&gt;
&lt;p&gt;It is easy to fix these commits. If you discover that you made a mistake in the last commit, you can just make new changes and amend the last commit:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit &lt;span class=&quot;token parameter variable&quot;&gt;--amend&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In practice, this removes the last commit, and creates a new one with the changes from the last commit and the new changes combined.&lt;/p&gt;
&lt;p&gt;Amending a commit only works if there is a problem with the last commit. What if you find issues with the last 2 commits, or decide that it would make sense to combine them?&lt;/p&gt;
&lt;h3&gt;Fixing multiple commits&lt;/h3&gt;
&lt;p&gt;If you want to make changes to the 2 (or more) last commits, you can do a soft reset. This reset will cause the commits to disappear, while keeping all changes made. You can then make a new commit, combining all changes from the last couple of commits:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; reset HEAD~2
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; commit&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to reset more than 2 commits, simply change the number after &lt;code&gt;HEAD~&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you want to reset multiple commits and split the changes up into more than one commit, check out the paragraph on &lt;code&gt;git add -i&lt;/code&gt; below.&lt;/p&gt;
&lt;h3&gt;More complicated situations&lt;/h3&gt;
&lt;p&gt;For more complicated situations, you can always use interactive rebase:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; rebase &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I will not write an entire rebase manual here, as that has &lt;a href=&quot;https://git-scm.com/docs/git-rebase&quot;&gt;already&lt;/a&gt; &lt;a href=&quot;https://www.atlassian.com/git/tutorials/merging-vs-rebasing/&quot;&gt;been&lt;/a&gt; &lt;a href=&quot;http://nathanleclaire.com/blog/2014/09/14/dont-be-scared-of-git-rebase/&quot;&gt;done&lt;/a&gt;. It is a powerful tool, though, and if you want to look like a Git wizard in front of your geeky friends, be sure to read up on rebasing.&lt;/p&gt;
&lt;h2&gt;The &amp;quot;875 lines changed&amp;quot; commit&lt;/h2&gt;
&lt;p&gt;We have all seen people make huge commits:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token number&quot;&gt;511&lt;/span&gt; lines added, &lt;span class=&quot;token number&quot;&gt;364&lt;/span&gt; lines deleted&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is horrible because it is completely impossible to figure out what this commit does. You need to delve into the code and figure out yourself which changes belong together. Also, consider the following scenario: Someone finds a bug in the application you are working on, and the decision is made to temporarily exclude the feature that causes the bug. You can either comment everything out (aka the bad way), or find the commit that introduced the feature and &lt;a href=&quot;https://git-scm.com/docs/git-revert&quot;&gt;revert&lt;/a&gt; it (aka the good way). If the entire feature is added in one huge commit that also added 4 other features, it becomes extremely hard to remove it. You would need to comment out chunks of code, or in the worst case even manually rewrite methods, or even entire classes, to a previous state.&lt;/p&gt;
&lt;h3&gt;The solution&lt;/h3&gt;
&lt;p&gt;So, you ended up making completely unrelated changes without committing. Worry not, we can fix this! Interactive staging to the rescue:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There is a &lt;a href=&quot;https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging&quot;&gt;complete tutorial on interactive staging&lt;/a&gt; on the official Git website, so you can read up on it. But simply put, it makes it easy for you to partially commit changes you have made within the same file. For example, if you have added 2 methods in one class that are used for two different features, you can use interactive staging to do a commit with only the first method, and then a second commit with the other method.&lt;/p&gt;
&lt;h2&gt;Why bother?&lt;/h2&gt;
&lt;p&gt;Some people think I&#39;m wasting my time when I&#39;m carefully splitting up commits, or merging several commits into one. I think they are wrong. Every time I go through my own repositories&#39; history to find something specific, I am either really glad that my commits are well-structured, or annoyed with myself for not always doing it. I see a commit as a piece of the code, and I want every piece of code to have one responsibility.&lt;/p&gt;
</description>
      <pubDate>2016-02-23T13:00:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2016/02/23/git-commits-youre-doing-it-wrong/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2016/02/23/git-commits-youre-doing-it-wrong/</guid>
      <category>general</category>
      <category>git</category>
    </item>
    <item>
      <title>Introducing Forward</title>
      <description>&lt;img src=&quot;/img/2016/02/forward_donations.png&quot; alt=&quot;Forward donations&quot; style=&quot;float: right; margin: 5px 0 5px 10px; width: 200px;&quot;/&gt;
&lt;p&gt;The past couple of months, I have been working on a project called &lt;a href=&quot;https://forwardapphq.com/?utm_source=kevinpelgrims.com&quot; title=&quot;Forward&quot;&gt;Forward&lt;/a&gt;. Forward is an online community where you gather donations for your favorite charity by giving stuff away. If you have something that you want to throw out that is actually still in good shape, you can put it on Forward instead. The person who wants to get the item, pays for it by donating to a charity you specify.&lt;/p&gt;
&lt;p&gt;People can get rid of things they no longer need, others can get stuff for an amount between $1 and $15, money goes to charity, and we encourage recycling. It&#39;s &lt;code&gt;#winning&lt;/code&gt; all over the place.&lt;/p&gt;
&lt;p&gt;We have an Android version of the app on &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.commanigy.forward&amp;amp;utm_source=kevinpelgrims.com&quot; title=&quot;Forward on Google Play&quot;&gt;Google Play&lt;/a&gt;, and an iOS version on &lt;a href=&quot;https://itunes.apple.com/app/id955565754&quot; title=&quot;Forward on iTunes&quot;&gt;iTunes&lt;/a&gt;. You can also use &lt;a href=&quot;https://forwardapphq.com/?utm_source=kevinpelgrims.com&quot; title=&quot;Forward website&quot;&gt;the website&lt;/a&gt; to view items and post comments. (We hope to expand the functionality on the website soon.)&lt;/p&gt;
&lt;img src=&quot;/img/2016/02/forward_donation_new.png&quot; alt=&quot;Forward new donation&quot; style=&quot;float: left; margin: 5px 10px 5px 0; width: 200px;&quot;/&gt;
&lt;p&gt;Because these items are real-life objects, everything on Forward is geographically restricted. People can only see and request items within a certain radius. Currently we are trying to build a community of users in Copenhagen (Denmark), which takes quite some time and effort. Hopefully we can expand to the rest of the country soon. After that, we will take the entire world! :-)&lt;/p&gt;
&lt;p&gt;Growth is quite slow at the moment, but we have just announced a partnership with a charity organization in Denmark called &lt;a href=&quot;https://moedrehjaelpen.dk&quot;&gt;Mødrehjælpen&lt;/a&gt;, which we hope will kick start user acquisition. We are also actively looking for more partnerships.
Forward is a way for charity organizations to passively get some extra donations. All we ask in return, is that they make sure to let the world know they are a part of the Forward network.&lt;/p&gt;
&lt;p&gt;If you happen to work for a charity organization, or know someone who does, or just have some questions about the project, get in touch: &lt;a href=&quot;mailto:kevin@forwardapphq.com&quot;&gt;kevin@forwardapphq.com&lt;/a&gt;. I really hope we can make a difference, and help charity organizations that need money for all kinds of good causes.&lt;/p&gt;
</description>
      <pubDate>2016-02-20T13:00:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2016/02/20/introducing-forward/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2016/02/20/introducing-forward/</guid>
      <category>forward</category>
    </item>
    <item>
      <title>Getting involved - 2015 in review</title>
      <description>&lt;p&gt;At the beginning of 2015, I decided I should get more involved in the Android community. I&#39;ve been working on Android apps since 2011, but I hadn&#39;t gone to conferences, written a lot of blog posts, or made a lot of useful contributions on StackOverflow. Sure, I did a few small talks at DroidDevsDK in 2014, but that was it. So in 2015, I wanted to do better.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I wrote a book!&lt;/strong&gt; Which, I think, is a pretty cool thing to have done. It was a lot of hard work, but I was very proud when &lt;a href=&quot;https://www.packtpub.com/application-development/gradle-android&quot; title=&quot;Gradle for Android - Packt Publishing&quot;&gt;Gradle for Android&lt;/a&gt; (also available &lt;a href=&quot;http://www.amazon.com/gp/product/1783986824/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=1783986824&amp;amp;linkCode=as2&amp;amp;tag=kevpelblo-20&amp;amp;linkId=4SC63BNQEBHIDPVH&quot; title=&quot;Gradle for Android - Amazon&quot;&gt;on Amazon&lt;/a&gt;) hit the shelves, so to speak. I thought I would be able to use some parts of the book for my blog, but when I was writing, I did not really seem to find the time to rewrite some excerpts. So that did not happen, and I ended up neglecting my blog, once again. I did manage to contribute more on &lt;a href=&quot;http://stackoverflow.com/users/421524/kevinpelgrims&quot; title=&quot;kevinpelgrims on StackOverflow&quot;&gt;StackOverflow&lt;/a&gt; for the &lt;code&gt;android&lt;/code&gt; and &lt;code&gt;gradle&lt;/code&gt; tags, unsurprisingly. In fact, my score on SO more than quadrupled in 2015. I&#39;ve had an account since 2011 but was not being very useful there. I&#39;m happy I was finally able to get more involved there, and help some people out.&lt;/p&gt;
&lt;p&gt;Besides doing a few more talks at &lt;a href=&quot;http://lanyrd.com/series/droiddevsdk/&quot; title=&quot;DroidDevsDK&quot;&gt;DroidDevsDK&lt;/a&gt;, I was also asked to become part of the organizing team there. So I am actively looking for speakers in the Copenhagen area or people who can present via live stream!&lt;/p&gt;
&lt;p&gt;The past year was also the year I did my very first talk at a real conference! I talked about Gradle for Android at &lt;a href=&quot;http://www.babbq.nl/&quot; title=&quot;Big Android BBQ&quot;&gt;Big Android BBQ in Amsterdam&lt;/a&gt;. It was a great experience to talk in front of a bunch of people, and it was nice hanging out with a few really good Android developers as well. I got inspired from listening to their talks and speaking to them in person afterwards, and realized I have a lot more to learn.&lt;/p&gt;
&lt;p&gt;I also worked on a little side project together with a colleague, and managed to release &lt;a href=&quot;https://forwardapphq.com/?utm_source=kevinpelgrims.com&quot; title=&quot;Forward&quot;&gt;Forward&lt;/a&gt;! As described in the &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.commanigy.forward&amp;amp;utm_source=kevinpelgrims.com&quot; title=&quot;Forward on Google Play&quot;&gt;Play store&lt;/a&gt;: Forward is an online community where you gather donations for your favorite charity by giving stuff away. So if you have something that you want to throw out, but is still in good shape, instead of throwing it out you put it on Forward. The person who wants to get the item, pays for it by donating to a charity you specify for a certain amount. I absolutely love the idea, and everyone I talk to seems to think it is amazing as well. So I really hope it will take off in 2016. We are working very hard on building a community in Copenhagen (Denmark) at the moment. It would be great if we can add more cities soon. We went into a partnership with &lt;a href=&quot;https://moedrehjaelpen.dk/&quot; title=&quot;Mødrehjælpen&quot;&gt;Mødrehjælpen&lt;/a&gt;, which is an organization that supports families or pregnant women that ended up in a vulnerable situation. . Hopefully, we can make a big contribution, and I would love to add more charity organizations to our list of partners. (If you happen to work for a charity organization, or know someone who does, get in touch!)&lt;/p&gt;
&lt;p&gt;On a personal level, I visited East Africa for the first time and got married. At the same time!&lt;/p&gt;
&lt;h2&gt;Plans for 2016&lt;/h2&gt;
&lt;p&gt;The next few months, I want to do some more experimenting with data binding on Android (and write about it here). I feel like I still need to spread the word about Gradle, because a lot of people are still clueless as to how much time it can save them. Hopefully, I will get another chance to speak at a conference (given I get myself together and submit some talk proposals). And of course, I want Forward to succeed.
In short: I want to get even more involved.&lt;/p&gt;
</description>
      <pubDate>2016-01-07T22:00:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2016/01/07/getting-involved-2015-in-review/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2016/01/07/getting-involved-2015-in-review/</guid>
      <category>life</category>
      <category>android</category>
      <category>forward</category>
    </item>
    <item>
      <title>Speeding up Gradle builds</title>
      <description>&lt;p&gt;A common complaint among Android developers that switch to Gradle is that the build time for their projects increases significantly. Gradle provides a lot of flexibility, but this power comes at the cost of a slower build process. Luckily there are several ways to speed things up.&lt;/p&gt;
&lt;h2&gt;Maven Central vs. JCenter&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Quick fix: change every occurrence of &lt;code&gt;mavenCentral()&lt;/code&gt; to &lt;code&gt;jcenter()&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For a long time, Android Studio would download the indices for Maven Central specifically when running the first build. These indices could use up several gigabytes and downloading this amount of data obviously takes a long time. This download process was hidden from developers, so it seemed like Android Studio was just stuck during the build.&lt;/p&gt;
&lt;p&gt;This issue has since been solved, and the latest versions of Android Studio should not have this behavior anymore. But you might as well play it safe and just use &lt;code&gt;jcenter()&lt;/code&gt;, as there are no disadvantages at all. You can read up on this bug (or was it a feature?) on &lt;a href=&quot;https://code.google.com/p/android/issues/detail?id=72061&quot;&gt;Google&#39;s issue tracker&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Get the latest version of Gradle&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Quick fix: update the version of Gradle used in your projects&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The guys at Gradleware (the company that is driving the development of Gradle) are spending a lot of time on improving the experience for developers, and making Gradle faster is a high priority. The latest versions have seen some improvement in speed and upgrading can shave a few seconds off your build times.&lt;/p&gt;
&lt;p&gt;Since Android Studio 1.3, Gradle version 2.4 is the default. But you might not have upgraded your projects yet. There are two ways to get started with Gradle version 2.4: Manually editing the Gradle wrapper properties file or using an Android Studio dialog.&lt;/p&gt;
&lt;p&gt;The properties file for the &lt;a href=&quot;/blog/2015/05/25/use-the-gradle-wrapper-for-your-android-projects/&quot; title=&quot;Using the Gradle Wrapper for Android projects&quot;&gt;Gradle wrapper&lt;/a&gt; can be found in your project folder under &lt;code&gt;gradle/wrapper/&lt;/code&gt; and is called &lt;code&gt;gradle-wrapper.properties&lt;/code&gt;. The content of that file might look like this:&lt;/p&gt;
&lt;pre class=&quot;language-properties&quot;&gt;&lt;code class=&quot;language-properties&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;#Wed Apr 10 15:27:10 PDT 2013&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;distributionBase&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;GRADLE_USER_HOME&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;distributionPath&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;wrapper/dists&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;zipStoreBase&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;GRADLE_USER_HOME&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;zipStorePath&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;wrapper/dists&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;distributionUrl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;https&#92;://services.gradle.org/distributions/gradle-2.2.1-all.zip&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can manually change the version number &lt;code&gt;2.2.1&lt;/code&gt; to &lt;code&gt;2.4&lt;/code&gt; and the next time you run the wrapper, the new version is downloaded automatically.&lt;/p&gt;
&lt;p&gt;Using Android Studio is even easier! Open the &lt;code&gt;Project Structure&lt;/code&gt; dialog and click on &lt;code&gt;Project&lt;/code&gt; to see the Gradle settings for your project. Here you can change the version number, again, to &lt;code&gt;2.4&lt;/code&gt;, and Android Studio will take care of the rest.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2015/06/gradle_androidstudio.png&quot; alt=&quot;Android Studio Gradle setting&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Gradle properties&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Quick fix: Change your Gradle properties&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There are a few Gradle properties that can speed up your builds a bit.&lt;/p&gt;
&lt;pre class=&quot;language-properties&quot;&gt;&lt;code class=&quot;language-properties&quot;&gt;&lt;span class=&quot;token key attr-name&quot;&gt;org.gradle.parallel&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;org.gradle.daemon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;token key attr-name&quot;&gt;org.gradle.jvmargs&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token value attr-value&quot;&gt;-Xms256m -Xmx1024m&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Enabling parallel builds with &lt;code&gt;org.gradle.parallel&lt;/code&gt; is only useful if your project has multiple modules. You might, for example, have an Android app, a Java library, an Android project library, and an Android Wear module in the same project. When you enable parallel builds, some of the modules can be built at the same time, making use of all the cores in your machine.&lt;/p&gt;
&lt;p&gt;The Gradle daemon is a background process that is started the first time you run the build. Subsequent builds will reuse that background process.  This means that the startup cost for any build is a lot lower and Gradle will start a lot faster. You can find more information on &lt;a href=&quot;https://docs.gradle.org/current/userguide/gradle_daemon.html&quot; title=&quot;Gradle Daemon documentation&quot;&gt;the daemon in the Gradle documentation&lt;/a&gt;.
Android Studio enables the daemon by default, so this setting only affects builds triggered from the command line interface.&lt;/p&gt;
&lt;p&gt;Finally, you can tweak the parameters of the Java Virtual Machine. This will speed up the build itself. You can find a nice explanation on these settings in &lt;a href=&quot;http://stackoverflow.com/a/14763095&quot; title=&quot;StackOverflow - JVM arguments&quot;&gt;this StackOverflow answer&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;How to use Gradle properties&lt;/h3&gt;
&lt;p&gt;You can set these properties locally in your project by creating a file called &lt;code&gt;gradle.properties&lt;/code&gt; in the project root, or you can set them globally for all your projects by creating the same file in your home directory (&lt;code&gt;%UserProfile%&#92;.gradle&lt;/code&gt; on Windows, &lt;code&gt;~/.gradle&lt;/code&gt; on Linux and Mac OS X). It is a good practice to set the properties in your home directory, rather than on a project level. On a build server, you usually want to keep memory consumption low, and the duration of the build is not that important. Setting these settings on a project level would change the build server behavior as well. (You are using a build server, right?)&lt;/p&gt;
&lt;h2&gt;Speeding up multi-module builds&lt;/h2&gt;
&lt;h3&gt;Building modules separately&lt;/h3&gt;
&lt;p&gt;If you have several modules in your project and you make changes to the app, but not the rest, you can manually make sure that Gradle only builds the app. You can run &lt;code&gt;gradlew :app:build&lt;/code&gt; (dependening on the names of your modules) to build the app and not have Gradle touch the other modules.&lt;/p&gt;
&lt;p&gt;In case you want to build several modules, but not all, you can just combine the build tasks: &lt;code&gt;gradlew :app:build :moduledirectoryname:build&lt;/code&gt;. That way you can avoid going through Gradle&#39;s configuration phase twice.&lt;/p&gt;
&lt;h3&gt;Excluding modules from the build&lt;/h3&gt;
&lt;p&gt;To extend on the previous tip, you can also exclude certain tasks by using the command-line option &lt;code&gt;-x&lt;/code&gt; or &lt;code&gt;--exclude-task&lt;/code&gt;. For example, if you want to build all your modules, except for one, you can run a command like this: &lt;code&gt;gradlew assemble -x :libraryproject:assemble&lt;/code&gt;. If the task you exclude has any dependencies, then those dependencies are also exluded from the build.&lt;/p&gt;
&lt;h2&gt;Profiling&lt;/h2&gt;
&lt;p&gt;If your builds are extremely slow and you want to figure out the cause for this, you can try profiling your build process. You can add the &lt;code&gt;--profile&lt;/code&gt; flag to any Gradle task. Adding this flag will create a report under &lt;code&gt;build/reports/profile&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2015/06/gradle_profiling.png&quot; alt=&quot;Gradle Profiling&quot;&gt;&lt;/p&gt;
&lt;p&gt;This report shows an overview of where time is spent when running a certain task.&lt;/p&gt;
&lt;h2&gt;By the way...&lt;/h2&gt;
&lt;p&gt;I wrote a book! It is titled &amp;quot;Gradle for Android&amp;quot; and will be available in June. (You can already order it on &lt;a href=&quot;https://www.packtpub.com/application-development/gradle-android&quot; title=&quot;Gradle for Android - Packt Publishing&quot;&gt;Packt&#39;s website&lt;/a&gt;.) I got a lot of inspiration and ideas while I was writing, and there are a few things that I had to leave out of the book, but would still like to get out there. This means that I will be doing some more Gradle posts the coming weeks. So stay tuned for more Gradle goodness!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.packtpub.com/application-development/gradle-android&quot; title=&quot;Gradle for Android - Packt Publishing&quot;&gt;&lt;img src=&quot;/img/2015/05/gradle_for_android_cover.jpg&quot; alt=&quot;Gradle for Android cover&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</description>
      <pubDate>2015-06-11T17:00:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2015/06/11/speeding-up-your-gradle-builds/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2015/06/11/speeding-up-your-gradle-builds/</guid>
      <category>android</category>
      <category>gradle</category>
    </item>
    <item>
      <title>Use the Gradle Wrapper for your Android projects</title>
      <description>&lt;img src=&quot;/img/2015/05/gradle_icon.png&quot; style=&quot;float: right; width: 250px; margin: 10px;&quot;/&gt;
I sometimes meet Android developers that are using Android Studio and Gradle for their projects, but have no idea what is happening when I start executing `gradlew` in the command line interface. They usually installed Gradle manually, because they figured it was necessary to get their builds to work now that Google is pushing Gradle. Using the Gradle wrapper, however, has huge advantages.
&lt;h2&gt;What is the Gradle wrapper?&lt;/h2&gt;
&lt;p&gt;Gradle is under constant development, and new versions could potentially break functionality. The Gradle wrapper is a batch file on Windows called &lt;code&gt;gradlew.bat&lt;/code&gt; or a shell script on Mac OS X and Linux called &lt;code&gt;gradlew&lt;/code&gt;. When you run this script and the selected version of Gradle is not present, it will be downloaded automatically. If the selected version of Gradle is already downloaded, it functions as a proxy to the local Gradle binary.&lt;/p&gt;
&lt;p&gt;The idea behind this is that developers and automated systems that need to build the app can do so just by downloading the repository and running the wrapper, which will take care of the rest. Manually installing Gradle is not necessary, and you don&#39;t need to manage several version of Gradle yourself.&lt;/p&gt;
&lt;p&gt;Another advantage of using the wrapper is that it enables you to use different versions of Gradle for different projects. If you start a project using Gradle 2.2.1 and start another project using Gradle 2.4, those projects can both be built with the Gradle version they require, even on the same machine.&lt;/p&gt;
&lt;h2&gt;It&#39;s there by default&lt;/h2&gt;
&lt;p&gt;When you create a project with Android Studio, the Gradle wrapper is included by default. The necessary files will be copied into the project directory, and you should include them in your repository. (You are using a source control system, right?) So whenever you start a new Android project, you can immediately run the wrapper from the command line interface without extra setup. Instead of running the &lt;code&gt;gradle&lt;/code&gt; command, just run the &lt;code&gt;gradlew&lt;/code&gt; command. All the rest is the same.&lt;/p&gt;
&lt;h2&gt;Get the wrapper yourself&lt;/h2&gt;
&lt;p&gt;If you are not creating your Android projects using Android Studio, you can get the wrapper by executing a Gradle task. Of course, in that case, you will need to have Gradle installed. You can download Gradle from the &lt;a href=&quot;http://gradle.org/downloads&quot; title=&quot;Gradle download page&quot;&gt;official website&lt;/a&gt;, or use a package manager like Homebrew if you&#39;re on Mac OS X. Once you have Gradle and it is added to your PATH, run following command in your project folder:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;$ gradle wrapper --gradle-version &lt;span class=&quot;token number&quot;&gt;2.4&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This task will download the wrapper and set the preferred version to 2.4 (the latest at the time of writing this post). If you do not add the version, it will just download the latest version by default.&lt;/p&gt;
&lt;h2&gt;Android Studio&lt;/h2&gt;
&lt;p&gt;Internally, Android Studio uses the version of Gradle that is defined in the wrapper configuration. That configuration can be found in &lt;code&gt;gradle/wrapper/gradle-wrapper.properties&lt;/code&gt;.
When Google decides that it is time to use a new version of Gradle, Android Studio will display a message nudging you to upgrade. All you need to do then is click the message and Android Studio will edit the properties file and synchronize the Gradle installation for you.&lt;/p&gt;
&lt;h2&gt;Read more&lt;/h2&gt;
&lt;p&gt;You can find more information on the Gradle wrapper in the &lt;a href=&quot;https://docs.gradle.org/current/userguide/gradle_wrapper.html&quot; title=&quot;Gradle Wrapper documentation&quot;&gt;Gradle documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;TL;DR&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;gradlew&lt;/code&gt; instead if &lt;code&gt;gradle&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It&#39;s there by default&lt;/li&gt;
&lt;li&gt;It&#39;s everywhere&lt;/li&gt;
&lt;li&gt;It&#39;s always the right version&lt;/li&gt;
&lt;li&gt;You can use different versions of Gradle for different projects&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;By the way...&lt;/h2&gt;
&lt;p&gt;I wrote a book! It is titled &amp;quot;Gradle for Android&amp;quot; and will be available in June. (You can already order it on &lt;a href=&quot;https://www.packtpub.com/application-development/gradle-android&quot; title=&quot;Gradle for Android - Packt Publishing&quot;&gt;Packt&#39;s website&lt;/a&gt;.) I got a lot of inspiration and ideas while I was writing, and there are a few things that I had to leave out of the book, but would still like to get out there. This means that I will be doing some more Gradle posts the coming weeks. So stay tuned for more Gradle goodness!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.packtpub.com/application-development/gradle-android&quot; title=&quot;Gradle for Android - Packt Publishing&quot;&gt;&lt;img src=&quot;/img/2015/05/gradle_for_android_cover.jpg&quot; alt=&quot;Gradle for Android cover&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</description>
      <pubDate>2015-05-25T19:00:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2015/05/25/use-the-gradle-wrapper-for-your-android-projects/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2015/05/25/use-the-gradle-wrapper-for-your-android-projects/</guid>
      <category>android</category>
      <category>gradle</category>
    </item>
    <item>
      <title>Adding a badge to an ActionBar tab</title>
      <description>&lt;p&gt;An app I worked on a while ago has a notifications screen where the notifications are divided into tabs. So in order to make it very clear how many notifications are on each tab, we decided to have a &amp;quot;badge&amp;quot; on every tab. Here&#39;s an example of what I mean:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2014/06/android_actionbar_tab_badge.png&quot; alt=&quot;ActionBar tab badge example&quot;&gt;&lt;/p&gt;
&lt;p&gt;It&#39;s not possible to just add views to the tab view, so to do this you need to completely override it instead. I&#39;ve seen a bunch of questions on StackOverflow regarding custom tab views and even adding a badge, but none of them seem to have a good answer. So I decided to write things up here when I was done with my solution.&lt;/p&gt;
&lt;h2&gt;Re-create the standard tab view&lt;/h2&gt;
&lt;p&gt;The first thing you need to do is re-create the standard tab view. It&#39;s possible to do this in code, creating a &lt;code&gt;TextView&lt;/code&gt; and setting its properties. To make sure you get the text to look exactly like the standard tab view text, you can use the &lt;code&gt;TabText&lt;/code&gt; &lt;code&gt;TextAppearance&lt;/code&gt; from the support library. The code snippet below also sets a custom background, because one of the requirements was to have different colors for the tab indicators. You could possibly use a background from the support library there as well.&lt;/p&gt;
&lt;pre class=&quot;language-java&quot;&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;renderTabView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Context&lt;/span&gt; context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; titleResource&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; backgroundResource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;TextView&lt;/span&gt; view &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;context&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setLayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ViewGroup&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ViewGroup&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;MATCH_PARENT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;  &lt;span class=&quot;token class-name&quot;&gt;ViewGroup&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;MATCH_PARENT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setGravity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Gravity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;CENTER&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;titleResource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setTextAppearance&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;support&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;v7&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;/span&gt;R&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Widget_AppCompat_Light_ActionBar_TabText&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setBackgroundResource&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;backgroundResource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; view&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This works, but I prefer using XML for views. If you want to add a badge to the tab view later, creating the layout in XML is a lot easier anyway.&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;TextView&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;xmlns:&lt;/span&gt;android&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://schemas.android.com/apk/res/android&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_width&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;match_parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_height&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;match_parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;gravity&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;center&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;textAppearance&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@style/Widget.AppCompat.Light.ActionBar.TabText&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The layout file sets most of the visual elements of the view, but you still need to set the &lt;code&gt;LayoutParams&lt;/code&gt; in code, because of how the views get drawn by Android. The background resource here is still set in code, but if you have a fixed background, you can handle that in XML as well.&lt;/p&gt;
&lt;pre class=&quot;language-java&quot;&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;renderTabView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Context&lt;/span&gt; context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; titleResource&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; backgroundResource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;TextView&lt;/span&gt; view &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;LayoutInflater&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;context&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tab_default&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// We need to manually set the LayoutParams here because we don&#39;t have a view root&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setLayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ViewGroup&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ViewGroup&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;MATCH_PARENT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ViewGroup&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;MATCH_PARENT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;titleResource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setBackgroundResource&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;backgroundResource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; view&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Add the tab to the ActionBar&lt;/h2&gt;
&lt;p&gt;Now you need to set the custom view when you add the tab to the &lt;code&gt;ActionBar&lt;/code&gt;. The &lt;code&gt;renderTabView()&lt;/code&gt; method from before will create the view you need.&lt;/p&gt;
&lt;pre class=&quot;language-java&quot;&gt;&lt;code class=&quot;language-java&quot;&gt;actionBar&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addTab&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;actionBar&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;newTab&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setCustomView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;renderTabView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;NotificationsActivity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tab_invitations&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;drawable&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tab_orange&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setTabListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tabListener&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;R.drawable.tab_orange&lt;/code&gt; drawable is a selector that has a transparent background in most states, but has the tab indicator when selected.&lt;/p&gt;
&lt;h2&gt;Add the badge&lt;/h2&gt;
&lt;p&gt;Now you can add the actual badge to the tab view. You should wrap the &lt;code&gt;TextView&lt;/code&gt; from before in a &lt;code&gt;FrameLayout&lt;/code&gt; and add a new &lt;code&gt;TextView&lt;/code&gt; that will act as the badge.&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;FrameLayout&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;xmlns:&lt;/span&gt;android&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://schemas.android.com/apk/res/android&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_width&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;match_parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_height&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;match_parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;TextView&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@+id/tab_text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_width&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;match_parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_height&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;match_parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;gravity&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;center&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;textAppearance&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@style/Widget.AppCompat.Light.ActionBar.TabText&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;

    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;TextView&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@+id/tab_badge&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_width&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@dimen/badgeSizeHome&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_height&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@dimen/badgeSizeHome&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;background&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@drawable/badge_background&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_marginRight&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;4dp&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_marginTop&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;4dp&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_gravity&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;top|right&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;gravity&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;center&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;textColor&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@color/white&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;textSize&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;8dp&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;FrameLayout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;@drawable/badge_background&lt;/code&gt; drawable is just an oval shape with a background color.&lt;/p&gt;
&lt;p&gt;You then also need to update &lt;code&gt;renderTabView&lt;/code&gt; to take in a number to display in the badge. If you want to update the number in the badge after creating the tab view, you can use &lt;code&gt;updateTabBadge&lt;/code&gt;. That method will also hide the badge if the number is not bigger than 0.&lt;/p&gt;
&lt;pre class=&quot;language-java&quot;&gt;&lt;code class=&quot;language-java&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;renderTabView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Context&lt;/span&gt; context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; titleResource&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; backgroundResource&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; badgeNumber&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;FrameLayout&lt;/span&gt; view &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;FrameLayout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;LayoutInflater&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;context&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tab_badge&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// We need to manually set the LayoutParams here because we don&#39;t have a view root&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setLayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ViewGroup&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ViewGroup&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;MATCH_PARENT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ViewGroup&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;LayoutParams&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;MATCH_PARENT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tab_text&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;titleResource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tab_text&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setBackgroundResource&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;backgroundResource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;updateTabBadge&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tab_badge&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; badgeNumber&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; view&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateTabBadge&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ActionBar&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Tab&lt;/span&gt; tab&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; badgeNumber&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;updateTabBadge&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; tab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getCustomView&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tab_badge&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; badgeNumber&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateTabBadge&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;TextView&lt;/span&gt; view&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; badgeNumber&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;badgeNumber &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setVisibility&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;View&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;VISIBLE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;badgeNumber&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        view&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setVisibility&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;View&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;GONE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And that&#39;s it. You now have a way to easily set a different background to every tab and add and update a badge on the tab view.&lt;/p&gt;
&lt;p&gt;If you want to see all the used code and layouts, check out &lt;a href=&quot;https://gist.github.com/kevinpelgrims/8685c8e1a68e3cd9cff9&quot;&gt;this gist&lt;/a&gt;.&lt;/p&gt;
&lt;script src=&quot;https://gist.github.com/kevinpelgrims/8685c8e1a68e3cd9cff9.js&quot;&gt;&lt;/script&gt;
</description>
      <pubDate>2014-06-24T20:12:02Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2014/06/24/adding-a-badge-to-an-actionbar-tab/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2014/06/24/adding-a-badge-to-an-actionbar-tab/</guid>
      <category>android</category>
      <category>ui</category>
    </item>
    <item>
      <title>Reference a local .aar in your Android project</title>
      <description>&lt;p&gt;If you create an Android library project and you don&#39;t want to upload it to Maven central or run a local repository, it&#39;s a little tricky to add your .aar to an Android project.&lt;/p&gt;
&lt;p&gt;According to the &lt;a href=&quot;http://tools.android.com/recent/androidstudio044released&quot;&gt;release notes for Android Studio 0.4.4&lt;/a&gt; support for .aar files was added there. To quote the note:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Newly created projects are initialized with the right build.gradle setup such that you can simply put .jar and .aar files into the libs/ directory and they will automatically be used (similar to how the libs/ folder worked in Eclipse ADT.)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now, I might be doing something completely wrong, but for me this simply does not work. I have tried to add a library project using things like &lt;code&gt;compile files(&#39;libs/library.aar&#39;)&lt;/code&gt; and &lt;code&gt;compile fileTree(dir: &#39;libs&#39;, include: &#39;*.aar&#39;)&lt;/code&gt;, but all of them failed.&lt;/p&gt;
&lt;p&gt;So I gave up on that and instead started to use a different way. With Gradle it is possible to create a repository from a basic directory using &lt;code&gt;flatDir&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;language-groovy&quot;&gt;&lt;code class=&quot;language-groovy&quot;&gt;repositories &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;mavenCentral&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    flatDir &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        dirs &lt;span class=&quot;token string&quot;&gt;&#39;libs&#39;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example, we&#39;ll put the .aar file in the &lt;code&gt;libs&lt;/code&gt; folder, but you could use any folder you like. If you prefer to store your library projects in a separate folder like &lt;code&gt;aars&lt;/code&gt; instead of &lt;code&gt;libs&lt;/code&gt;, that is a possibility.&lt;/p&gt;
&lt;p&gt;The next step is of course to reference the actual library. There are two ways of doing this.&lt;/p&gt;
&lt;pre class=&quot;language-groovy&quot;&gt;&lt;code class=&quot;language-groovy&quot;&gt;dependencies &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   compile &lt;span class=&quot;token string&quot;&gt;&#39;com.kevinpelgrims.library:library:1.0.0@aar&#39;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;@aar&lt;/code&gt; is necessary to specify the type of the dependency. The namespace though seems to be completely useless. This is definitely a lot easier then setting up your own Maven repository. The annoying thing about this is that you still need to update the version on every update. In recent versions of Android Studio it is also possible to add the dependency in a different way.&lt;/p&gt;
&lt;pre class=&quot;language-groovy&quot;&gt;&lt;code class=&quot;language-groovy&quot;&gt;dependencies &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;libraryfilename&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ext&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aar&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This makes it a lot easier to maintain the dependency itself. Now when you update the file, you don&#39;t need to update the version number in the Gradle build file.&lt;/p&gt;
&lt;p&gt;Although this is a good workaround, it seems like there is no official solution yet. I hope Google will address this problem in the near future. You can star/follow &lt;a href=&quot;https://code.google.com/p/android/issues/detail?id=55863&quot;&gt;an issue on this on the Android issue tracker&lt;/a&gt; that was reported a year ago and is still open.&lt;/p&gt;
</description>
      <pubDate>2014-05-18T21:05:01Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/</guid>
      <category>android</category>
      <category>gradle</category>
    </item>
    <item>
      <title>Git is easy. Seriously.</title>
      <description>&lt;p&gt;A lot of developers often say things like &amp;quot;Git is easy, once you know it&amp;quot;. I&#39;m sick of reading those comments. Git is easy. Period. You can definitely make it as easy as you want. You don&#39;t need to know what cherry picking is to use Git, you don&#39;t need to rebase everything all the time; all of that is extra. What you need to be able to do is pull, commit and push. Those three commands can get everyone going. Sure, there&#39;s a lot more to it, but you can learn that as you go (if you want to). The point is, you don&#39;t need to know the rest.&lt;/p&gt;
&lt;p&gt;To go even further, I actually think more people should learn how to use Git (or any other &lt;a href=&quot;http://blogs.atlassian.com/2012/02/version-control-centralized-dvcs/&quot;&gt;distributed version control system&lt;/a&gt;). Not only programmers, but also designers, scientists, architects, journalists, etc.&lt;br&gt;
Seriously, there are only benefits. You just need to get into the mindset of not only saving your work, but also making backups continuously. Because that&#39;s what a version control system basically is if you use it on your own.&lt;br&gt;
It shouldn&#39;t take a designer too long to learn how to make a repository and do commits. Next thing to learn is how to go back in history. And that&#39;s it really.&lt;/p&gt;
&lt;h2&gt;Book review: &amp;quot;Git: Version Control for Everyone&amp;quot;&lt;/h2&gt;
&lt;img src=&quot;https://www.packtpub.com/media/catalog/product/cache/e4d64343b1bc593f1c5348fe05efa4a6/7/5/7522os_0.jpg&quot; style=&quot;float: left; width: 250px; margin-top: 5px; margin-right: 10px;&quot; /&gt;
I suggest taking a look at [Git: Version Control for Everyone](http://www.packtpub.com/git-version-control-for-everyone/book). This book is perfect for the less technical when it comes to Git. When I read the description I was interested in seeing how the writer would go about this topic. I was pleasantly surprised. I think the author found a way to explain the basics in a very simple way and to make it all look even easier than it already is.
&lt;p&gt;The further you go in the book, the more advanced it gets. But you don&#39;t need to read all of it if you&#39;re not ready or don&#39;t need it. The first couple of chapters can already get you started and you&#39;ll be creating backups of your work in no time. I honestly think this can greatly improve your professional life, no matter what you do, as long as you&#39;re creating content on a computer.&lt;/p&gt;
&lt;p&gt;The book is full of good information. From absolute basics like why you need version control, how to set up Git and the basic commands, to branching and even a deep explanation of how Git works under the hood.&lt;br&gt;
The writing is very informal, which I personally like in a tech book, and I think it&#39;s a good fit for a tech book targeted to less technical people.&lt;/p&gt;
&lt;p&gt;So in case you&#39;re interested, check out the book. It&#39;s a great way to get going.&lt;/p&gt;
</description>
      <pubDate>2013-04-22T18:59:46Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2013/04/22/git-is-easy-seriously/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2013/04/22/git-is-easy-seriously/</guid>
      <category>general</category>
      <category>git</category>
    </item>
    <item>
      <title>Version control best practices - Git edition</title>
      <description>&lt;img style=&quot;float: right; margin: 0 0 5px 10px;&quot; alt=&quot;git logo&quot; src=&quot;/img/2012/07/git_logo.png&quot; /&gt;
&lt;p&gt;I already made a list of general &lt;a href=&quot;/blog/2012/07/05/version-control-best-practices/&quot;&gt;version control best practices&lt;/a&gt;, but since my day to day work is with git, I felt the list was not complete. So I decided to make an extension on the previous post, this time with some git specific best practices. Of course, there is a lot more to it. But this is a good basic list to make sure working (together) with git becomes easier.&lt;/p&gt;
&lt;h2&gt;Git best practices&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use .gitignore&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Don&#39;t commit generated content like jars or bin folders. Use a &lt;a href=&quot;https://help.github.com/articles/ignoring-files&quot;&gt;.gitignore&lt;/a&gt; file to filter out the files that don&#39;t belong in the repository.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Commit often&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Do a lot of small commits, push it when you&#39;re ready. You can always do a bunch of changes or rewrite history locally before you push your code to a shared repository.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Be careful with &lt;code&gt;git reset&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;git reset (--hard)&lt;/code&gt; will reset the current HEAD to a specific commit. This means that if you have any unsaved changes (= not committed or stashed), they will be lost.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Rewriting history&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Git makes it easy to rewrite history, but that doesn&#39;t mean you should. The rule here is that it&#39;s okay to rewrite history locally, working with commits that are not yet pushed to a shared repository. Once something is shared, don&#39;t change it or all your team members could run into problems with their repositories once they pull. Even a simple &lt;code&gt;git commit --amend&lt;/code&gt; to change a commit message is no longer allowed after a push!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Branching&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Choose a workflow for branching&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some people like working with &lt;a href=&quot;http://nvie.com/posts/a-successful-git-branching-model/&quot;&gt;feature branches&lt;/a&gt;, some people even do &lt;em&gt;all&lt;/em&gt; their work in a &lt;a href=&quot;http://lostechies.com/jimmybogard/2010/06/03/translating-my-git-workflow-with-local-branches-to-mercurial/&quot;&gt;separate branch&lt;/a&gt;. As long as you don&#39;t have any long running branches that are completely separate for weeks, you&#39;re good. But be sure to have a defined workflow for the entire team, so everybody is doing the same.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Merge often and stay up to date&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you work on a feature branch, be sure to merge the develop branch into your feature branch often. This way you stay up to date with development and fixes and as an extra bonus it will be easier to merge the feature branch into development!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Post-merge delete&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you are done merging a feature branch back into develop, be sure to delete the feature branch. This way your repository doesn&#39;t get cluttered.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tag releases&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you do a release, tag the commit the release is based on. This way you can find out when you released what and it will make it easy to go back to that certain state by checking out the tag.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Stashing&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Name your stashes. If you don&#39;t provide a name, git generates one based on the previous commit. This gives you at least some information, but you still don&#39;t know what&#39;s in the stash. So unless you&#39;re making a quick, temporary stash, consider giving it a name by using &lt;code&gt;git stash save name&lt;/code&gt; instead of just using &lt;code&gt;git stash&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Experiment!&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you think a certain git command can be useful, but you&#39;re not completely sure what it does, just try it out. If you&#39;re really unsure, try it in a copy/clone of your repository. But usually (if you committed everything) you will never lose data (unless you try &lt;em&gt;really&lt;/em&gt; hard).&lt;/p&gt;
</description>
      <pubDate>2012-07-27T06:51:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/07/27/version-control-best-practices-git-edition/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/07/27/version-control-best-practices-git-edition/</guid>
      <category>general</category>
      <category>version control</category>
      <category>git</category>
    </item>
    <item>
      <title>Setting up multiple GitHub accounts on Windows</title>
      <description>&lt;img style=&quot;float: right; width: 200px&quot; alt=&quot;github windows&quot; src=&quot;/img/2012/07/github_windows.png&quot; /&gt;
&lt;p&gt;So you have Windows, you&#39;re using &lt;a href=&quot;https://code.google.com/p/msysgit/&quot;&gt;msysgit&lt;/a&gt; and you already have &lt;a href=&quot;https://github.com/&quot;&gt;GitHub&lt;/a&gt; &lt;a href=&quot;https://help.github.com/articles/set-up-git&quot;&gt;set up&lt;/a&gt;. But now you have a second GitHub account and you need that to work on your current installation as well. It took me some time to get this right, so I want to share my experience here. This is a bit tricky, but I will try to explain in 3 short steps.&lt;/p&gt;
&lt;h2&gt;Create a new SSH key&lt;/h2&gt;
&lt;p&gt;First you need to create a new SSH key. This is how you will identify yourself to GitHub.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;ssh-keygen &lt;span class=&quot;token parameter variable&quot;&gt;-t&lt;/span&gt; rsa &lt;span class=&quot;token parameter variable&quot;&gt;-C&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;your_email@youremail.com&quot;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# Creates a new ssh key using the provided email&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Generating public/private rsa key pair.&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa):&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should be careful at that last step. You already have a key, so be sure to enter a new name for this file, to avoid overriding the old one. For example, at the prompt type &lt;code&gt;/c/Users/you/.ssh/id_rsa_two&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Configure the SSH key&lt;/h2&gt;
&lt;p&gt;To find the key you just created, go to the .ssh folder and open the new file &lt;code&gt;id_rsa_two.pub&lt;/code&gt;. Copy the entire content of that file and paste it to GitHub in in &lt;a href=&quot;https://github.com/settings/ssh&quot;&gt;Account Settings &amp;gt; SSH Keys&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You&#39;ll also need to add the key to your local ssh database. This part gets annoying on Windows, because the ssh-add command doesn&#39;t work out of the box in Git Bash. But there&#39;s a trick! In Git Bash first run &lt;code&gt;exec ssh-agent bash&lt;/code&gt;, this will make sure your SSH agent is running (it will also change the prompt, but let&#39;s not care about that). Now you can go ahead and &lt;code&gt;ssh-add /c/Users/you/.ssh/id_rsa_two&lt;/code&gt; without any problems.&lt;/p&gt;
&lt;h2&gt;Create a config file&lt;/h2&gt;
&lt;p&gt;But the fun is not over yet! You need to set up the two profiles in a config file. Create &lt;code&gt;/c/Users/you/.ssh/config&lt;/code&gt; and make it look like this:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;#Account one&lt;/span&gt;
Host one.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile /c/Projects/.ssh/id_rsa

&lt;span class=&quot;token comment&quot;&gt;#Account two&lt;/span&gt;
Host two.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile /c/Projects/.ssh/id_rsa_two&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will make sure git knows about the two identities and can pick the right one when you talk to GitHub.&lt;/p&gt;
&lt;h2&gt;Test it!&lt;/h2&gt;
&lt;p&gt;You can now make sure your setup works by running &lt;code&gt;ssh -T git@github.com&lt;/code&gt; and &lt;code&gt;ssh -T git@github.com -i /c/Users/you/.ssh/id_rsa_two&lt;/code&gt;. This will test both identities and should return something like &lt;code&gt;Hi kevinpelgrims! You&#39;ve successfully authenticated, but GitHub does not provide shell access.&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now everything is set up and you&#39;re ready to go! Next time you clone a repository from second account, you should use &lt;code&gt;git@two.github.com&lt;/code&gt; in the URL, instead of the default &lt;code&gt;git@github.com&lt;/code&gt;. Otherwise it will default to the first account.&lt;/p&gt;
</description>
      <pubDate>2012-07-20T06:51:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/07/20/setting-up-multiple-github-accounts-on-windows/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/07/20/setting-up-multiple-github-accounts-on-windows/</guid>
      <category>version control</category>
      <category>git</category>
    </item>
    <item>
      <title>Track your BitBucket repository with Google Analytics</title>
      <description>&lt;p&gt;Recently I released &lt;a href=&quot;/blog/2012/05/21/introducing-nugetfight/&quot;&gt;my first open source code out in the wild&lt;/a&gt;, but I had no idea if people were actually looking at the code at all. We use Google Analytics on &lt;a href=&quot;http://nugetfight.com&quot;&gt;NuGet Fight&lt;/a&gt;, so I figured it would be nice to have the statistics for the repository in there as well. As it turns out this is possible with BitBucket!&lt;/p&gt;
&lt;h2&gt;Setting it up&lt;/h2&gt;
&lt;p&gt;First, in Google Analytics go to account administration and click the &amp;quot;New Account&amp;quot; button. Set this up with &lt;a href=&quot;http://bitbucket.org&quot;&gt;http://bitbucket.org&lt;/a&gt; as the URL. Fill in the other information and click &amp;quot;Create Account&amp;quot;.&lt;/p&gt;
&lt;p&gt;Google Analytics now creates your account and a website profile automatically and brings you to a page that displays your Google Analytics key. Copy that key and go to the admin page of your BitBucket repository. The repository details screen actually has a field called &amp;quot;Google Analytics key&amp;quot;, paste your key there and save the settings.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2012/07/GoogleAnalyticsBitBucket_Key.png&quot; alt=&quot;Google Analytics for BitBucket&quot;&gt;&lt;/p&gt;
&lt;p&gt;Now go back to the Google Analytics page from before and open the &amp;quot;profiles&amp;quot; tab. As mentioned before Analytics already created a profile for you, but you&#39;ll need to change some settings. It&#39;s probably a good idea to change the name of the profile, which has the same name as the account by default. More importantly, change the website URL to the full URL to the repository.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2012/07/GoogleAnalyticsBitBucket.png&quot; alt=&quot;Google Analytics for BitBucket&quot;&gt;&lt;/p&gt;
&lt;p&gt;Now when you save this and check the status on the &amp;quot;Tracking Code&amp;quot; tab, it should say &amp;quot;Receiving Data&amp;quot; instead of &amp;quot;Tracking Not Installed&amp;quot;. Keep in mind this might take a few minutes.&lt;/p&gt;
&lt;h2&gt;Start tracking!&lt;/h2&gt;
&lt;p&gt;If you have multiple repositories on BitBucket and want to add all of them, it gets easier after the first time. You can use the same account and just add more website profiles. You just have to insert the full URL and save the Google Analytics key on BitBucket.&lt;/p&gt;
&lt;p&gt;Tracking visitors on your repository can give you some insight into how interested people actually are in seeing your code and where those people come from. I sure thought it was interesting to see visitor stats for &lt;a href=&quot;https://bitbucket.org/kevinpelgrims/nugetfight&quot;&gt;the NuGet Fight repository&lt;/a&gt;!&lt;/p&gt;
</description>
      <pubDate>2012-07-11T06:52:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/07/11/track-your-bitbucket-repository-with-google-analytics/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/07/11/track-your-bitbucket-repository-with-google-analytics/</guid>
      <category>version control</category>
      <category>analytics</category>
    </item>
    <item>
      <title>Version control best practices</title>
      <description>&lt;p&gt;I&#39;m one of the poor guys who had to deal with Visual SourceSafe, I used to work with TFS on a daily basis, I&#39;m using Git every day at work with a few other people, I&#39;ve been using Hg for some pet projects with a friend and everybody has used Subversion.&lt;/p&gt;
&lt;img style=&quot;float: right; margin: 5px 0 5px 10px;&quot; alt=&quot;version control logos&quot; src=&quot;/img/2012/07/vc_logos.png&quot; /&gt;
&lt;p&gt;Version control is everywhere and is much needed when programming. But everybody who has worked with a version control system with a number of people before knows that it is inevitable that at some point someone will commit something that doesn&#39;t build, or something that compiles but doesn&#39;t run. I have made mistakes like this, so have my colleagues and so have you!&lt;/p&gt;
&lt;h2&gt;Best practices&lt;/h2&gt;
&lt;p&gt;So to prevent this from happening again, I made a small list of best practices that I will try and follow myself. This list is applicable to every system out there!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Diff before you commit&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I use a GUI to check my changes in an easy way before I commit changes. That makes it easier to see if I forgot anything or if a commit needs to be split up in several commits.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Keep commits small and logical&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A commit should be a logical grouping of changes in your code. If you change some code in one class and add two completely unrelated classes, consider doing three commits. This will make it easier to find changes in the history later. Also, keep your commits small. Even if you&#39;re working on different classes that are logically grouped together, it might be a good idea to split up some changes. This way it&#39;ll be easier to revert changes if necessary.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;There is room for comments, use it!&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I always try to have a &amp;quot;header&amp;quot; and a full explanation in my commit messages. That way I can easily see what it&#39;s about on the first line and I can read the complete commit message if I need to dig deeper. Titles like &amp;quot;fixed bug&amp;quot; are useless, try to use descriptive titles.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Build and test code before a commit&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We managed to make two related mistakes at work in one week recently. First a colleague committed code that didn&#39;t compile after a heavy merge, a few days later I committed code that could build but did not work. Double check this before you commit, even when you think nothing could&#39;ve gone wrong! In a distributed version control system like git, this rule might read &amp;quot;build and test before you &lt;strong&gt;push&lt;/strong&gt;&amp;quot;, although I believe you should be able to at least build every commit.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Don&#39;t leave commented-out code in there&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you want to remove some code that you might need again later, don&#39;t comment it out, remove it. You can always retrieve it, it&#39;s in source control! Commented-out code pollutes the code base and makes no sense when you can easily check the history of a file.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Check other people&#39;s commits&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Read the commit message and take a look at the code. This will improve your understanding of your colleagues&#39; code, it can serve as a very simple code review and you might learn a thing or two.&lt;/p&gt;
&lt;h2&gt;Live by the rules, man&lt;/h2&gt;
&lt;p&gt;I&#39;m trying to follow these rules every day to make work nicer for me and my colleagues. We don&#39;t have a pink sombrero around, so there&#39;s no fun in broken builds at the office ;-)&lt;/p&gt;
</description>
      <pubDate>2012-07-05T07:51:19Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/07/05/version-control-best-practices/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/07/05/version-control-best-practices/</guid>
      <category>general</category>
    </item>
    <item>
      <title>Android development tips - Style inheritance</title>
      <description>&lt;img style=&quot;float: right; margin: 5px 0 5px 10px; width: 200px;&quot; alt=&quot;android logo&quot; src=&quot;/img/2012/05/android.png&quot; /&gt;
It&#39;s a good habit to use styles in your Android application to do layouts or style fonts that occur in multiple places. It also makes it a lot easier to change the layout of your app later. And styles in Android get even cooler once you figure out how to reuse them!
&lt;h2&gt;Styles&lt;/h2&gt;
&lt;p&gt;In a project at work, we have a style called &amp;quot;NormalText&amp;quot; which takes care of a lot of the text in the app. So instead of this:&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;TextView&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_width&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;wrap_content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;layout_height&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;wrap_content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;textSize&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;14sp&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;textColor&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#000000&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;text&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@string/hello&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can just do this:&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;TextView&lt;/span&gt;
    &lt;span class=&quot;token special-attr&quot;&gt;&lt;span class=&quot;token attr-name&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token value css language-css&quot;&gt;@style/NormalText&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;android:&lt;/span&gt;text&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@string/hello&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thanks to this styles.xml file:&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token prolog&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;resources&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;NormalText&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;
        &amp;lt;item name=&lt;span class=&quot;token string&quot;&gt;&quot;android:layout_width&quot;&lt;/span&gt;&gt;wrap_content&amp;lt;/item&gt;
        &amp;lt;item name=&lt;span class=&quot;token string&quot;&gt;&quot;android:layout_height&quot;&lt;/span&gt;&gt;wrap_content&amp;lt;/item&gt;
        &amp;lt;item name=&lt;span class=&quot;token string&quot;&gt;&quot;android:textSize&quot;&lt;/span&gt;&gt;14sp&amp;lt;/item&gt;
        &amp;lt;item name=&lt;span class=&quot;token string&quot;&gt;&quot;android:textColor&quot;&lt;/span&gt;&gt;#000000&amp;lt;/item&gt;
    &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;resources&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Inheritance&lt;/h2&gt;
&lt;p&gt;Now if you need to layout some text with the same properties as another style, this is actually pretty straight forward in Android. All you need to do is prefix your new style name with the name of the parent style.&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;NormalText.Green&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;
    &amp;lt;item name=&lt;span class=&quot;token string&quot;&gt;&quot;android:textColor&quot;&lt;/span&gt;&gt;#00ff00&amp;lt;/item&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Not only will this make it easier to create styles, it will also make it easier to change styles. If you need the font to be bigger, you only need to change it in one place. This makes maintaining styles a lot easier!&lt;/p&gt;
&lt;h2&gt;Inherit from built-in Android styles&lt;/h2&gt;
&lt;p&gt;There are also a bunch of built-in Android styles available when you&#39;re developing an app. It is possible to inherit from these styles as well, but you need to take a different approach. Instead of prefixing the name, you set the parent attribute of the style you&#39;re creating.&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;RedText&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;@android:style/TextAppearance&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;
    &amp;lt;item name=&lt;span class=&quot;token string&quot;&gt;&quot;android:textColor&quot;&lt;/span&gt;&gt;#ff0000&amp;lt;/item&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The sad thing is that the built-in Android styles are not really documented by Google. All you get is &lt;a href=&quot;http://developer.android.com/reference/android/R.style.html&quot;&gt;a list of the constants in the R.style class&lt;/a&gt;. So to actually figure out what these styles look like, you will have to experiment with them. I tried to find an overview online, but it seems that doesn&#39;t exist. If you know of such an overview, please let me know, so I can link it here - and use it myself :-)&lt;/p&gt;
&lt;p&gt;This simple technique can speed up styling in your app and makes it a lot easier to reuse styling you already did. And don&#39;t forget to take advantage of the built-in Android styles!&lt;/p&gt;
</description>
      <pubDate>2012-06-25T07:45:04Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/06/25/android-development-tips-style-inheritance/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/06/25/android-development-tips-style-inheritance/</guid>
      <category>android</category>
    </item>
    <item>
      <title>.NET project workflow with Hg, BitBucket and AppHarbor</title>
      <description>&lt;p&gt;The past few weeks I&#39;ve been working on a project with a friend who lives in Belgium. You can read more about that in a previous post, &lt;a href=&quot;/blog/2012/05/21/introducing-nugetfight/&quot;&gt;Introducing NuGetFight&lt;/a&gt;. Since we&#39;re living 1000km apart, we need the right tools to deal with all this. The project is a ASP.NET MVC3 website in C#, we&#39;re using Visual Studio to develop it. But as we&#39;re not able to sit in the same room and code, we need some extra tools to enhance the workflow.&lt;/p&gt;
&lt;h2&gt;Mercurial on BitBucket&lt;/h2&gt;
&lt;p&gt;For source control we&#39;re using &lt;a href=&quot;http://mercurial.selenic.com&quot;&gt;Mercurial&lt;/a&gt; on &lt;a href=&quot;https://bitbucket.org&quot;&gt;BitBucket&lt;/a&gt;. We both worked a bit with git before, but Mercurial (Hg) felt more natural for us beginners to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Distributed_revision_control&quot;&gt;DVCS&lt;/a&gt; scene. I started out using the command line for Hg, but now I&#39;m using &lt;a href=&quot;http://tortoisehg.bitbucket.org&quot;&gt;TortoiseHg&lt;/a&gt; for commits and pushes and pulls. It gives me a way to visualize the changes in an easier way than with the command line. BitBucket also has a nice way of keeping track of issues. This gives us a way of putting some stuff on the to-do list, with some information attached and to flag it as important when necessary. For me this is very important, because I tend to forget things ;-)&lt;/p&gt;
&lt;p&gt;To set up Hg and BitBucket you simply need to follow &lt;a href=&quot;http://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Mercurial&quot;&gt;the instructions&lt;/a&gt; in the documentation. It seems a bit complicated, but it&#39;s all pretty straight forward. You also need to have &amp;quot;pageant.exe&amp;quot; (the PuTTY authentication agent) running with your SSH key anytime you wish to connect to BitBucket.&lt;/p&gt;
&lt;h2&gt;AppHarbor for easy deployment&lt;/h2&gt;
&lt;p&gt;After a couple of days we were getting sick of always telling each other &amp;quot;hey, I changed something, pull and run to see how cool it is&amp;quot;. So we decided to deploy the website on &lt;a href=&quot;https://appharbor.com&quot;&gt;AppHarbor&lt;/a&gt;. The cool thing about this is that you can connect AppHarbor and BitBucket to automatically do everything for you. Setting this up is fairly easy, just follow &lt;a href=&quot;http://support.appharbor.com/kb/3rd-party-integrations/integrating-with-bitbucket&quot;&gt;this guide&lt;/a&gt; and five minutes later you can benefit!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2012/05/ngf_apphb.png&quot; alt=&quot;NuGetFight on AppHarbor&quot;&gt;&lt;/p&gt;
&lt;p&gt;This makes testing the website so much easier. Now I just do some commits locally, when I decide to push to BitBucket it also deploys the website to AppHarbor and my friend can check out the website without having to build it himself.&lt;/p&gt;
&lt;h2&gt;Saving data on MongoLab&lt;/h2&gt;
&lt;p&gt;After some developing we decided to save some data. We didn&#39;t want to set up a SQL Server for something this simple. In fact, we didn&#39;t even want to host the database ourselves. So we decided to try something and went for &lt;a href=&quot;https://mongolab.com/home&quot;&gt;MongoLab&lt;/a&gt;, which is basically Mongo hosting in the cloud. They have a free plan, so we could just check it out to see how it works.&lt;/p&gt;
&lt;p&gt;To be honest, there is a lot of work yet to be done for MongoLab. It seriously annoys me that there can be only one administrator on a project, for example. But it does its job and it didn&#39;t take a lot of time to set up. You simply create an account, create a database, create a user for the database and copy the connection string. For more information on how to use MongoLab, I recommend &lt;a href=&quot;http://koenmetsu.com/2012/03/26/starting-up-fast-with-nosql-first-steps&quot;&gt;Koen Metsu&#39;s blog&lt;/a&gt;, he has some interesting posts about this topic and he also explains how to use MongoLab with .NET.&lt;/p&gt;
&lt;h2&gt;NuGetFight&lt;/h2&gt;
&lt;p&gt;The result of all this work is &lt;a href=&quot;http://nugetfight.com&quot;&gt;NuGetFight&lt;/a&gt;, a website that makes it easier to decide on which &lt;a href=&quot;http://nuget.org&quot;&gt;NuGet&lt;/a&gt; package to choose.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2012/05/ngf.png&quot; alt=&quot;NuGetFight&quot;&gt;&lt;/p&gt;
&lt;p&gt;Check it out and feel free to contribute, it&#39;s &lt;a href=&quot;https://bitbucket.org/kevinpelgrims/nugetfight/&quot;&gt;open source&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>2012-05-28T07:48:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/05/28/net-project-workflow-with-hg-bitbucket-and-appharbor/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/05/28/net-project-workflow-with-hg-bitbucket-and-appharbor/</guid>
      <category>.net</category>
      <category>tools</category>
      <category>web</category>
    </item>
    <item>
      <title>Android development tips - Eclipse crash on deploy</title>
      <description>&lt;img style=&quot;float: right; margin: 0 0 5px 10px&quot; alt=&quot;eclipse logo&quot; src=&quot;/img/2012/05/eclipse.png&quot; /&gt;
Last week I added a new external library to an Android project and all of a sudden Eclipse started crashing half of the times I wanted to deploy my app to a phone. The error I got looked like this: &quot;Conversion to Dalvik format failed: Unable to execute dex: Java heap space&quot;. But sometimes I would get &quot;Internal error – An out of memory error has occurred&quot; or &quot;GC overhead limit exceeded&quot;. I restarted Eclipse, I even rebooted my laptop, nothing seemed to work.
&lt;h2&gt;Heap space&lt;/h2&gt;
&lt;p&gt;So I found some questions of other people with the same problems on the Net. It seems that the best way to fix this is by changing some values in the &lt;code&gt;eclipse.ini&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;At the bottom of that file there are two values that, by default, say &lt;code&gt;-Xms40m&lt;/code&gt; and &lt;code&gt;-Xmx384m&lt;/code&gt;. If you change those to make them bigger, for example &lt;code&gt;-Xms512m&lt;/code&gt; and &lt;code&gt;-Xmx512m&lt;/code&gt; the error stops occurring (or at least it did for me).&lt;/p&gt;
&lt;h2&gt;Not only an error fix&lt;/h2&gt;
&lt;p&gt;What we&#39;re actually doing here is setting the heap space to 512MB, instead of the default 40MB with a maximum of 384MB. The nice thing is that this does not only fix the problem, it also makes your builds faster and deployment to Android ... a little less slow. So definitely try this, even if you don&#39;t get an error!&lt;/p&gt;
</description>
      <pubDate>2012-05-23T07:43:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/05/23/android-development-tips-eclipse-crash-on-deploy/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/05/23/android-development-tips-eclipse-crash-on-deploy/</guid>
      <category>android</category>
      <category>eclipse</category>
    </item>
    <item>
      <title>Introducing NuGetFight</title>
      <description>&lt;p&gt;I&#39;ve recently been teaming up with &lt;a href=&quot;http://koenmetsu.com&quot;&gt;Koen Metsu&lt;/a&gt; to create &lt;a href=&quot;http://nugetfight.com&quot;&gt;NuGetFight&lt;/a&gt;, a website that makes it easier to decide on which &lt;a href=&quot;http://nuget.org&quot;&gt;NuGet&lt;/a&gt; package to choose. We sometimes find it hard to decide which packages to use when we start working on a project. Which one is best supported? Which one has good documentation? We thougth that this should be easier to compare and figured that queries with more packages and downloads also have better support and documentation. Sure, this is not a scientific way, but it can help and also, we&#39;re not really taking all of this &lt;em&gt;too&lt;/em&gt; serious (in case you haven&#39;t noticed).&lt;/p&gt;
&lt;h2&gt;Technologies&lt;/h2&gt;
&lt;p&gt;So we decided to make NuGetFight! We went for a ASP.NET MVC 3 project, with C#. We chose this mainly because we&#39;re both familiar with C# and MVC and it seemed like a right fit. We also wanted to have some &amp;quot;fancy&amp;quot; animated charts to show the data in a more visible manner. For those we decided to use JavaScript, as it is &amp;quot;pretty easy&amp;quot; to do with the canvas and some scripting.&lt;/p&gt;
&lt;h2&gt;JavaScript charts&lt;/h2&gt;
&lt;p&gt;For the charts we decided to go for JavaScript. Using the canvas element it&#39;s pretty fast to get some drawing and some animation going. The first draft of the chart was pretty easy to make.&lt;/p&gt;
&lt;p&gt;First draft of the chart:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2012/05/ngf_barchart.png&quot; alt=&quot;first chart version&quot;&gt;&lt;/p&gt;
&lt;p&gt;But after that we improved on it a lot and later also added some animation. We also used the script to learn a bit more about some features of JavaScript we hadn&#39;t used before. We&#39;re not JavaScript wizards, so it would be cool if somebody with some more knowledge on that part could help us make the charts a bit cooler!&lt;/p&gt;
&lt;h2&gt;And the winner is ...&lt;/h2&gt;
&lt;p&gt;It took us a while to find the right formula. In the beginning we used the number of packages, but then when we added the downloads that seemed kind of silly. So Koen came up with the idea to make a spreadsheet and try some formulas in there.&lt;/p&gt;
&lt;p&gt;Formula spreadsheet:
&lt;img src=&quot;/img/2012/05/ngf_algorithm.png&quot; alt=&quot;formula spreadhseet&quot;&gt;&lt;/p&gt;
&lt;p&gt;We ended up going for the last one, (packages / download) + downloads. This greatly benefits popular queries. The point of using NuGetFight is finding out which query to use, and finding the most popular one seems like a good reason to use a certain package. Because usually the most popular packages also have good documentation and the biggest community. Of course, this isn&#39;t the best way to find out which package to use, but it&#39;s the best way to do it programmatically.&lt;/p&gt;
&lt;h2&gt;Open source&lt;/h2&gt;
&lt;p&gt;We decided to &lt;a href=&quot;https://bitbucket.org/kevinpelgrims/nugetfight&quot;&gt;open up the code&lt;/a&gt;, for several reasons. People might be able to use some of it, whether they are trying to figure out how to work with the NuGet API, or how to do simple JavaScript graphics in a canvas. Another important reason is that we would like you to get involved! If you have any cool ideas, make an issue on BitBucket, fork the project and start coding. We&#39;d be really happy with some pull requests. And we chose to use the beer-ware license, so you&#39;re also free to use the code for your own projects.&lt;/p&gt;
&lt;h2&gt;Future features&lt;/h2&gt;
&lt;p&gt;Of course, there is a lot of improvement to be made. We definitely need someone to help us with the design. We are both very much programmers with a bad design sense, as you may have noticed... It would also be nice if we could spice up the charts a bit. We also want to add some popular suggestions and make a few nice error pages. The mobile version of the website needs some work as well. Those are the things on our list, feel free to check it out and suggest other possible improvements. It would be really cool to get some contributions!&lt;/p&gt;
</description>
      <pubDate>2012-05-21T11:01:14Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/05/21/introducing-nugetfight/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/05/21/introducing-nugetfight/</guid>
      <category>.net</category>
      <category>web</category>
    </item>
    <item>
      <title>A week without Google search</title>
      <description>&lt;p&gt;With all the commotion about &lt;a href=&quot;http://www.zdnet.com/blog/btl/googles-new-privacy-policy-the-good-bad-scary/67893&quot;&gt;Google&#39;s new privacy policy&lt;/a&gt; and realizing how much the Internet giant controls my online life, I wanted to do an experiment. A week without using Google for search.&lt;/p&gt;
&lt;p&gt;If you take a moment to think about it, Google knows everything about you. If you have and use a Gmail account, Google+, Google Docs, Google Maps, Google Translate, Google Reader, ... they know who you are, who you communicate with, even in which languages, what your interests are, what you like to read, etc. It starts to get scary, right? On top of all that they also know what you look for on the internet.&lt;/p&gt;
&lt;p&gt;Now, I can live with all that, because their products are simply the best. At least, that&#39;s what I&#39;ve been thinking all this time. Maybe it was time to see if Google really is the best search engine out there.&lt;/p&gt;
&lt;p&gt;One other reason for my experiment is my disappointment about Google using &lt;a href=&quot;http://www.amritray.com/2012/01/google-integrates-google-plus-into-google-search-results/&quot;&gt;Google+ results in search&lt;/a&gt; and upcoming plans to do more in that area. I&#39;ve been using Google search in a different browser or in incognito mode a lot, because I don&#39;t need all this &amp;quot;personalization&amp;quot; crap. I just want good results, based on my query. Not based on my friends, on my interests or on my location.&lt;/p&gt;
&lt;h2&gt;DuckDuckGo&lt;/h2&gt;
&lt;p&gt;One search engine that seems to be getting some traction is &lt;a href=&quot;http://duckduckgo.com/&quot;&gt;DuckDuckGo&lt;/a&gt;. After exploring &lt;a href=&quot;http://duckduckgo.com/settings.html&quot;&gt;the settings&lt;/a&gt; a bit, I could immediately see why. You can tweak the thing as much as you like and make sure you get the most neutral result possible. And it makes a big deal out of not saving anything you do and having a &lt;a href=&quot;http://duckduckgo.com/privacy.html&quot;&gt;user friendly privacy policy&lt;/a&gt;. So I decided to use DuckDuckGo for my experiment.&lt;/p&gt;
&lt;h2&gt;Wolfram Alpha&lt;/h2&gt;
&lt;p&gt;I&#39;ve been using &lt;a href=&quot;http://www.wolframalpha.com/&quot;&gt;Wolfram Alpha&lt;/a&gt; for a while now, for  things other than real search. It&#39;s really good as a Wikipedia replacement if you just want basic information in an efficient way. For example, if I want some info on Copenhagen (where exactly is the city located, how many people live there, which timezone is it and how close is the nearest airport) I just &lt;a href=&quot;http://www.wolframalpha.com/input/?i=copenhagen&quot;&gt;look for &amp;quot;copenhagen&amp;quot; in Wolfram Alpha&lt;/a&gt; and everything is there. It also seems to be well integrated in DuckDuckGo, for example when you want to perform &lt;a href=&quot;http://www.wolframalpha.com/input/?i=50+dkk+in+eur&quot;&gt;currency conversion&lt;/a&gt;. This is nice and I think I&#39;ll be using it more than usual this week, because I sometimes do some &lt;a href=&quot;http://www.google.com/insidesearch/features.html#unit&quot;&gt;calculations and conversions&lt;/a&gt; in Google.&lt;/p&gt;
&lt;h2&gt;The experiment&lt;/h2&gt;
&lt;p&gt;So I started my week by replacing the standard search engine in my browsers by DuckDuckGo. Now, I recently switched from .NET to Android development for my full-time job, so I need to look up a lot of things. A lot of times I want to look for things in the Android developer documentation. DuckDuckGo has this really cool thing called bang syntax that makes it super simple to search all kinds of sites, including the Android documentation, but also Wikipedia, YouTube, WordPress, a whole bunch of developer resources for a wide range of languages, maps, blogs, shopping, ... The list is huge! There are shortcuts available for some of the bang syntax and you can even do a Google search with DuckDuckGo using &amp;quot;!g&amp;quot;. Crazy shit. If you want to know more about this awesomeness, check out &lt;a href=&quot;https://duckduckgo.com/bang.html&quot;&gt;the entire list&lt;/a&gt;. This is a lot more convenient than adding search engines and shortcuts to my browser.&lt;/p&gt;
&lt;p&gt;Another cool thing is that for queries that have a lot of video results you get a &lt;a href=&quot;https://duckduckgo.com/?q=how+to+open+coconut&quot;&gt;top result embedded in the page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2012/03/duckduckgo_videoembed.png&quot; alt=&quot;DuckDuckGo with embedded video&quot;&gt;&lt;/p&gt;
&lt;p&gt;Also pretty cool is you can read &lt;a href=&quot;https://duckduckgo.com/?q=xkcd&quot;&gt;xkcd straight in DuckDuckGo&lt;/a&gt;. Besides that there&#39;s also the calculations and the integration with Wolfram Alpha helps to find facts like &lt;a href=&quot;https://duckduckgo.com/?q=birth+date+of+james+hetfield&quot;&gt;James Hetfield&#39;s birthday&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;OpenStreetMap is present too. When looking for a city, a little map appears on the right and when looking for exact coordinates, the first result you get is a &lt;a href=&quot;https://duckduckgo.com/?q=55.68%2C+12.57&quot;&gt;map of the area&lt;/a&gt;. And more integration! You can search for a Twitter handle and you will get some &lt;a href=&quot;https://duckduckgo.com/?q=%40kevinpelgrims&quot;&gt;info straight from Twitter&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There&#39;s a &lt;a href=&quot;https://duckduckgo.com/tech.html&quot;&gt;page dedicated to techies&lt;/a&gt; (read: nerds) with some information on how to find math formulas, get your own IP address, look for things on StackExchange, github, ... If you want to find out &lt;a href=&quot;https://duckduckgo.com/?q=git+push&quot;&gt;what a specific git command does&lt;/a&gt;, DuckDuckGo can tell it for you without even clicking through to a website.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I&#39;m making this all sound really good, because it is. But to be honest, I did have to use Google ( or at least &amp;quot;!g&amp;quot; ;-) ) a couple of times to find something for work, so I don&#39;t think I&#39;m ready for a Google search free world. But the week of the experiment has passed for a while now and I haven&#39;t switched the default search engine for my browsers back to Google. I&#39;m liking DuckDuckGo a lot and it will remain my default search engine for a while.&lt;/p&gt;
</description>
      <pubDate>2012-03-13T09:44:26Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/03/13/a-week-without-google-search/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/03/13/a-week-without-google-search/</guid>
      <category>tools</category>
      <category>web</category>
      <category>general</category>
    </item>
    <item>
      <title>Project progress tracking with Google Docs and Trello</title>
      <description>&lt;p&gt;I recently discovered some really powerful features in Google Docs. When you&#39;re in a Google Docs spreadsheet, you can do a whole lot of interesting things. For example it&#39;s possible to consume XML, including XPath functionality, and easily parse JSON. For more advanced stuff, you can use &lt;a href=&quot;https://en.wikipedia.org/wiki/Google_Apps_Script&quot;&gt;Google Apps Script&lt;/a&gt; and you can even access other Google applications from there. You could send an email or add an item to your calendar from there. It&#39;s possible to trigger those scripts on certain events or with a timer. You can see that there is A LOT of potential here and I actually wonder why we&#39;re not all using this some more. I decided to play with it, to see what the possibilities are. For the purpose of this blog post, I made a progress tracker that uses data from a &lt;a href=&quot;https://trello.com/&quot;&gt;Trello&lt;/a&gt; board.&lt;/p&gt;
&lt;h2&gt;Code52&lt;/h2&gt;
&lt;p&gt;I wanted to track a project with enough tasks to make sure there&#39;s enough data, but also with quick advances. So one of the &lt;a href=&quot;http://code52.org/&quot;&gt;Code52&lt;/a&gt; seemed like a great idea. They&#39;re doing a new project each week of the year and they&#39;re doing it open source from the ground up. Everybody is welcome to make suggestions and even participate in the programming! If you haven&#39;t heard of them, check out the website. Also an advantage is their use of Trello.&lt;/p&gt;
&lt;h2&gt;Trello&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://trello.com/&quot;&gt;Trello&lt;/a&gt; is one of the most popular free/simple project management tools out there. Basically you have a board with some lists to order your tasks. I&#39;m using Trello for personal projects, projects at work and projects with friends. It&#39;s simple, gives you a good overview and has no explosion of functionality or settings that are impossible to find. Another cool thing about Trello is that they have a public API. A personal key is necessary to use the API though. All the information needed is in the &lt;a href=&quot;https://trello.com/docs/&quot;&gt;API documentation&lt;/a&gt;, which is really good and has examples on everything.&lt;/p&gt;
&lt;h2&gt;Using the Trello API in Google Docs&lt;/h2&gt;
&lt;p&gt;As I said before, Google Docs can easily parse JSON, which is very convenient when you want to use the &lt;a href=&quot;https://trello.com/docs/&quot;&gt;Trello API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The first thing we need to work with the Trello API is a personal key, which is described in the docs. Once you have that you can start messing around with the API to figure out how things work. By looking at the examples and trying a few things straight in the browser it&#39;s easy to get a grasp of how everything fits together. When you&#39;re done reading the basics and getting a key, it&#39;s time to fire up Google Docs and create a new spreadsheet.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2012/03/googledocs_script_editor.png&quot; alt=&quot;Google Docs script editor&quot;&gt;&lt;/p&gt;
&lt;p&gt;To start using scripts in Google Docs, just create a new spreadsheet, Tools &amp;gt; Script editor... and you can get started. To fetch data there&#39;s a little function available called UrlFetchApp.fetch(url). To parse the resulting JSON data, you can just use Utilities.jsonParse(data). The URL needed to fetch JSON from a Trello board is &amp;quot;https://api.trello.com/1/url?key=apikey&amp;quot;. In this case we need to get all the lists from a board, so &amp;quot;url&amp;quot; here will be &amp;quot;boards/4f49efbbd105c95e0c12332e/lists&amp;quot;. This all works nicely together and should give you a list of the lists on the Trello board for the Code52 project. You can debug through the script to check the results of what you&#39;re doing without having to write it to the spreadsheet every time.&lt;/p&gt;
&lt;h2&gt;Getting data from Trello&lt;/h2&gt;
&lt;p&gt;Based on the snippets above, we can now make a function to fetch data from Trello in a generic way. This is how I did that:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;trelloFetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; key &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;insertyourkeyhere&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; completeUrl &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://api.trello.com/1/&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; url &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;?key=&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; key&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; jsondata &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; UrlFetchApp&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;completeUrl&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; object &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Utilities&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;jsonParse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;jsondata&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getContentText&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; object&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This way it&#39;s easy to get anything needed from Trello, using the one function. If something needs to change, there&#39;s only one place. DRY FTW!&lt;/p&gt;
&lt;h2&gt;Automatically fetch data&lt;/h2&gt;
&lt;p&gt;To make sure the script runs at a certain interval, it&#39;s possible to set a timer. In the script editor click Triggers &amp;gt; Current script&#39;s triggers... and create a new one. Set it to Time-driven and adjust to the interval at which you want it to run. To get project progress data from a Trello board, 8 hours should be fine. Also, be sure to set up an execution failure notification, so you get informed when the script fails to run.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2012/03/googledocs_script_trigger.png&quot; alt=&quot;Google Docs script trigger&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Counter&lt;/h2&gt;
&lt;p&gt;So the whole point is to run this with a timer, every 8 hours. To make sure every increment appears on a new row in the spreadsheet, you will need some kind of counter. This counter needs to be incremented every time the script gets executed. To make sure that happens, you can just put an integer in the spreadsheet and then the script gets the value when it runs. When the script is done, it increments the integer.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; counter &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; sheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getRange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; baserow &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; counter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;

counter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;counter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So you have to add a counter to the field on 1,9 (or row 1, column I) in the spreadsheet. The baserow var is the integer that&#39;s used to determine on which row the data should be saved. The first time the script runs, there&#39;s an extra row because the titles need to be added. You can just check if the script has run before using the value of the counter.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;counter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  data &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getC52I18NMVC4BoardListCount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  sheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getRange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;baserow &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; basecolumn&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setValues&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  data &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getC52I18NMVC4BoardListCount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  sheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getRange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;baserow&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; basecolumn&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setValues&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first run of the script gets the titles and the values, after that only the values are needed. In this script there is a specified number of columns, this could also be dynamic, that would make the script a bit more dynamic. I should do that later. For now I just want the thing to run.&lt;/p&gt;
&lt;h2&gt;The result&lt;/h2&gt;
&lt;p&gt;After a week my spreadsheet is filled with data and it&#39;s easy to use the Google Docs capabilities to make some nice charts. Below is a trend chart (it requires Flash to work, if you can&#39;t see anything, I blame Google!) Feel free to play around with it, you can hover over data and change the time range.&lt;/p&gt;
&lt;iframe width=&quot;600&quot; height=&quot;371&quot; seamless frameborder=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;https://docs.google.com/spreadsheets/d/1zC3_g_2hzp_NcSNm7pgRk_MOZDr_EXgEeepogbdb2hY/pubchart?oid=2&amp;amp;format=interactive&quot;&gt;&lt;/iframe&gt;
&lt;p&gt;Also a very interesting chart, is the area chart. This one shows us the accumulated number of tasks and the growth of the project.&lt;/p&gt;
&lt;iframe width=&quot;600&quot; height=&quot;371&quot; seamless frameborder=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;https://docs.google.com/spreadsheets/d/1zC3_g_2hzp_NcSNm7pgRk_MOZDr_EXgEeepogbdb2hY/pubchart?oid=3&amp;amp;format=interactive&quot;&gt;&lt;/iframe&gt;
&lt;p&gt;These charts are based on the data in the table below (all times are in the Central European timezone, just so you know).&lt;/p&gt;
&lt;iframe width=&quot;600&quot; height=&quot;371&quot; seamless frameborder=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;https://docs.google.com/spreadsheets/d/1zC3_g_2hzp_NcSNm7pgRk_MOZDr_EXgEeepogbdb2hY/pubchart?oid=1&amp;amp;format=interactive&quot;&gt;&lt;/iframe&gt;
&lt;h3&gt;Charts update&lt;/h3&gt;
&lt;p&gt;The charts have stopped working properly and it seems to be impossible to fix them. If you&#39;d like to see them, just open &lt;a href=&quot;https://docs.google.com/spreadsheets/d/1zC3_g_2hzp_NcSNm7pgRk_MOZDr_EXgEeepogbdb2hY/pubhtml?gid=0&amp;amp;single=true&quot;&gt;this page&lt;/a&gt; which has all the data and the three charts.&lt;/p&gt;
&lt;h2&gt;The script&lt;/h2&gt;
&lt;p&gt;So here&#39;s the entire script to fetch data from a Trello of choice, it&#39;s actually pretty simple. To use it, a counter is also needed. To make it even cooler it&#39;s possible to set it all up so that an email is sent when errors occur. Google Docs can be a nice tool to keep track of progress on a project and this script can be easily extended with some extra functionality. This is just an exploration of the possibilities and apparently Google Docs is really powerful!&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;trelloFetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; key &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;insertkeyhere&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; completeUrl &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://api.trello.com/1/&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; url &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;?key=&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; key&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; jsondata &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; UrlFetchApp&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;completeUrl&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; object &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Utilities&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;jsonParse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;jsondata&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getContentText&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; object&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getC52I18NMVC4BoardListCount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; boardid &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;4f49efbbd105c95e0c12332e&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; url_lists &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;boards/&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; boardid &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/lists&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; trello_lists &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;trelloFetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;url_lists&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; lists &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; listnames &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; listcounts &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; trello_lists&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; listid &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; trello_lists&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; url_cards &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;lists/&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; listid &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/cards&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; trello_cards &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;trelloFetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;url_cards&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; count &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; j &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; j &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; trello_cards&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; j&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      count&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    
    listnames&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; trello_lists&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    listcounts&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; count&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;first&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    lists&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; listnames&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    lists&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; listcounts&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    lists&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; listcounts&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; lists&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getC52I18NMVC4Values&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; data&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; sheet &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; SpreadsheetApp&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getActiveSheet&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; counter &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; sheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getRange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; baserow &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; counter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; basecolumn &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  sheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getRange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;baserow&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; basecolumn &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;counter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    data &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getC52I18NMVC4BoardListCount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    sheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getRange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;baserow &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; basecolumn&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setValues&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    data &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getC52I18NMVC4BoardListCount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    sheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getRange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;baserow&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; basecolumn&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setValues&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  
  counter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;counter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</description>
      <pubDate>2012-03-05T08:24:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/03/05/project-progress-tracking-with-google-docs-and-trello/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/03/05/project-progress-tracking-with-google-docs-and-trello/</guid>
      <category>tools</category>
      <category>analytics</category>
    </item>
    <item>
      <title>Upgrading my blog from WordPress to FunnelWeb</title>
      <description>&lt;blockquote&gt;
&lt;p&gt;UPDATE: The blog now runs with static pages generated by 11ty, so this is no longer relevant for this blog.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;Moving my blog away from WordPress&lt;/h2&gt;
&lt;p&gt;One of my resolutions for the year was to move my blog from WordPress to my own personal hosting. I have a few reasons for this.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;First of all, the editor in WordPress is really, really, really bad. I want to have control over the generated output and WordPress always wants to change everything I do.&lt;/li&gt;
&lt;li&gt;Second reason is control. I want a blogengine that I can adjust or extend more easily. I do realize that I could install WordPress on my own hosting account and use plugins, but I&#39;d like to dig in the code as well.&lt;/li&gt;
&lt;li&gt;Third reason is statistics. I like looking at my blogstatistics, even though they&#39;re not that spectacular. The stats in WordPress are very limited and very slow. Though I guess you could have third party stats in a WordPress installation..&lt;/li&gt;
&lt;li&gt;It&#39;s very tightly coupled. It should be easy to change blogengine, WordPress makes this really complicated.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;The quest for the right blogengine&lt;/h2&gt;
&lt;p&gt;So based on my &amp;quot;complaints&amp;quot; about WordPress, I made the following requirements for my choice of blogengine:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Markdown support. This is absolutely the nicest way to write blogposts. Heck, I want to write all my documents in markdown! No hassle with closing tags (as in HTML) and no selecting and clicking toolbars (as in Word).&lt;/li&gt;
&lt;li&gt;Open source. A blogengine that has its source publicly available is not only more easy to adjust to my needs, but might also have a lot of other users sending in their own adjustments. Which I believe will lead to better quality in the end. I don&#39;t care that much about the language it is written in. I know .NET, some PHP and Java and have played with Ruby. Besides, once you know one language, you know them all!&lt;/li&gt;
&lt;li&gt;Google analytics. I haven&#39;t seen a better way to get some nice stats without paying for it.&lt;/li&gt;
&lt;li&gt;Disqus for comments. It&#39;s being used on a lot of blogs now and has proven it&#39;s value.&lt;/li&gt;
&lt;li&gt;FeedBurner to keep people informed. I can easily change the address of the feed later without anyone noticing it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;FunnelWeb VS Octopress&lt;/h2&gt;
&lt;p&gt;After some research there were two blogengines left. One written in C# and ASP.NET MVC, the other one in Ruby. The bigger difference however, is the way they generate output. &lt;a href=&quot;http://www.funnelweblog.com/&quot;&gt;FunnelWeb&lt;/a&gt; takes the traditional database approach. &lt;a href=&quot;http://octopress.org/&quot;&gt;Octopress&lt;/a&gt; is more of a static page generator. In the end I went for FunnelWeb because I prefer to have a database online, that makes it easier to make quick changes to the layout for example.&lt;/p&gt;
&lt;h2&gt;The plan&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.funnelweblog.com/&quot;&gt;FunnelWeb&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://disqus.com&quot;&gt;Disqus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://feedburner.google.com/&quot;&gt;FeedBurner&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.google.com/analytics/&quot;&gt;Google Analytics&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Getting everything out of WordPress&lt;/h2&gt;
&lt;p&gt;Getting my blogposts out of WordPress is pretty straightforward. WordPress has an export function, which creates a XML file. You can choose to export only your posts, only your pages, or everything (pages, posts, comments and some other stuff). It&#39;s nice that they provide a simple way to do this. The format was not all that user friendly though...&lt;/p&gt;
&lt;h2&gt;Getting everything in FunnelWeb&lt;/h2&gt;
&lt;p&gt;It took some Googling and puzzling to get the posts in FunnelWeb. The format of the XML provided by the WordPress export is not really standard, so you have to do some conversion first. FunnelWeb has the option to import stuff from BlogML, so I needed a tool to convert the WordPress file to regular BlogML. I used an application called &lt;a href=&quot;http://www.visualsoftware.net/Blog/post/2009/10/27/WordPress-eXtended-RSS-to-BlogMl-converter-WXR-2-BlogML.aspx&quot;&gt;WXR 2 BlogML&lt;/a&gt;. That did its job fine. One thing to note though, it&#39;s best to remove the lines that contain references to &amp;quot;atom&amp;quot; from the original XML, because it tends to throw some exceptions when those are still in there.&lt;/p&gt;
&lt;h2&gt;Getting comments in Disqus&lt;/h2&gt;
&lt;p&gt;This was definitely the hardest part! I spent a LOT of time figuring out what was going wrong here. I used the export from WordPress to get the comments in Disqus, with the nice import functionality on the Disqus website. I could see the comments in Disqus, but they never showed up on my blog. I could add comments on my blog, they would show up in Disqus and then they would be there on my blog too. But what about the old comments? Something weird was going on there. I thought the problem was with FunnelWeb and spent some time digging in the code and abusing developer tools in every browser to figure things out. But I couldn&#39;t find a thing. When I was close to giving up &lt;a href=&quot;http://koenmetsu.com/&quot;&gt;Koen Metsu&lt;/a&gt; came up with the (strange) solution. Apparently all I needed to do was remove the trailing slashes in links to posts from the comments in the XML file from WordPress.&lt;/p&gt;
&lt;p&gt;For example, this:&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;wp:&lt;/span&gt;comment_author_url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;http://kevinpelgrims.wordpress.com/2010/04/27/powershell-2-0-background-jobs/&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;wp:&lt;/span&gt;comment_author_url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Becomes:&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;wp:&lt;/span&gt;comment_author_url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;http://kevinpelgrims.wordpress.com/2010/04/27/powershell-2-0-background-jobs&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;wp:&lt;/span&gt;comment_author_url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Yes, the only difference is the frikkin slash... Then when I imported to Disqus everything just magically worked! That was a nice moment, because I was getting seriously annoyed and almost considered just dropping all the old comments. Thanks Koen for figuring that out!&lt;/p&gt;
&lt;h2&gt;Google Analytics&lt;/h2&gt;
&lt;p&gt;Setting up Google Analytics is pretty much just following the steps, everything is very straightforward. A nice tip though is &lt;a href=&quot;http://aijazansari.com/2011/12/20/excluding-yourself-from-google-analytics/&quot;&gt;this explanation&lt;/a&gt; on how to exclude yourself from the results using a cookie. You basically need to set up an exclusion rule in Analytics, create a HTML file with some JavaScript from Google and visit that page. Again, follow the steps described on the website.&lt;/p&gt;
&lt;h2&gt;FeedBurner&lt;/h2&gt;
&lt;p&gt;I also decided to get my feed on &lt;a href=&quot;http://feedburner.google.com/&quot;&gt;FeedBurner&lt;/a&gt;. It&#39;s one more building block to the whole flexible construction my blog has become. If I decide to change blogengine again, I don&#39;t have to tell people to change their subscription, I just change the feed in FeedBurner and it&#39;s taken care of.&lt;/p&gt;
&lt;h2&gt;MarkPad&lt;/h2&gt;
&lt;p&gt;To write this blogpost I&#39;m using &lt;a href=&quot;http://code52.org/DownmarkerWPF/&quot;&gt;MarkPad&lt;/a&gt;. While not completely perfect yet, it is the most beautiful markdown editor out there (at least, that&#39;s what I think). It&#39;s also an open source effort, started by the &lt;a href=&quot;http://code52.org/&quot;&gt;Code52&lt;/a&gt; initiative. Be sure to check them out, as they have a lot of cool projects going on.&lt;/p&gt;
&lt;p&gt;Also useful is &lt;a href=&quot;http://daringfireball.net/projects/markdown/syntax&quot;&gt;this good markdown reference&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Result&lt;/h2&gt;
&lt;p&gt;My blog has become a very loosely coupled project. Everything can be taken apart and if I ever decide to change blog engine again, I can easily just use the comments from Disqus, change my feed in FeedBurner and export my comments in BlogML. The markdown layout makes it look pretty in the backend. I like!&lt;/p&gt;
&lt;p&gt;I still have some styling to do, but I can do that while the blog is online. A bit more pressure to get things done will only be more motivating ;-) So far I&#39;m using a standard theme with some adjustments. FunnelWeb has really nice theming and extension features that make it pretty easy to create your own stuff on top of what is already there, without changing all of the FunnelWeb code itself. Check out the &lt;a href=&quot;http://www.funnelweblog.com/&quot;&gt;FunnelWeb website&lt;/a&gt; if you&#39;re interested!&lt;/p&gt;
&lt;p&gt;It didn&#39;t go as smooth as I&#39;d hoped, but I guess I never really expected it to be a walk in the park. Damn computers! Overall I&#39;m very pleased about the whole process and all the tools I&#39;m using do their job very well!&lt;/p&gt;
</description>
      <pubDate>2012-02-27T21:02:45Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2012/02/27/upgrading-my-blog-from-wordpress-to-funnelweb/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2012/02/27/upgrading-my-blog-from-wordpress-to-funnelweb/</guid>
      <category>general</category>
      <category>.net</category>
      <category>tools</category>
      <category>web</category>
    </item>
    <item>
      <title>Building CoffeeScript with Sublime on Windows</title>
      <description>&lt;p&gt;As I’m looking at &lt;a href=&quot;http://coffeescript.org/&quot;&gt;CoffeeScript&lt;/a&gt; in my spare time, I wanted a fast way to build the scripts. Since I work with &lt;a href=&quot;http://www.sublimetext.com/&quot;&gt;Sublime Text 2&lt;/a&gt; for all my scripting, it seemed like the right tool for the job.&lt;/p&gt;
&lt;p&gt;Sublime is a text editor that has a lot in common with &lt;a href=&quot;http://macromates.com/&quot;&gt;TextMate&lt;/a&gt; for OS X, but it has the huge advantage of working cross-platform. Sublime can also be extended using plug-ins, like TextMate, and a lot of TextMate bundles are compatible with it.&lt;/p&gt;
&lt;h2&gt;Node.js&lt;/h2&gt;
&lt;p&gt;Now, there are several ways to compile CoffeeScript locally (e.g. &lt;a href=&quot;http://stackoverflow.com/questions/2879401/how-can-i-compile-coffeescript-from-net&quot;&gt;from .NET&lt;/a&gt; or using &lt;a href=&quot;http://jashkenas.github.com/coffee-script/#usage&quot;&gt;the built-in watch option&lt;/a&gt;). We are going to use &lt;a href=&quot;http://nodejs.org/&quot;&gt;Node.js&lt;/a&gt; and &lt;a href=&quot;http://npmjs.org/&quot;&gt;npm&lt;/a&gt; (the Node Package Manager). Node.js works on Windows these days and the .msi installer also makes sure npm is on your system. You will need to add the folder that contains (default is &lt;code&gt;C:&#92;Program Files (x86)&#92;nodejs&lt;/code&gt;) node.exe and npm.cmd to your environment variables to make sure you can easily run them from anywhere. Here’s a nice guide to &lt;a href=&quot;http://www.itechtalk.com/thread3595.html&quot;&gt;adding, removing and editing environment variables in Windows 7&lt;/a&gt;. The normal thing to do here, is to add it to the &lt;code&gt;path&lt;/code&gt; variable, if it’s not there already, feel free to create it.&lt;/p&gt;
&lt;h2&gt;CoffeeScript compiler&lt;/h2&gt;
&lt;p&gt;Installing the CoffeeScript compiler and Node.js tools is pretty straight forward when we open up a command window and use npm:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; coffee-script&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;font-size:smaller;&quot;&gt;
    **Warning**: be sure to open the command window on the same folder as your Node.js installation, that means where node.exe lives (default is `C:&#92;Program Files (x86)&#92;nodejs`).
    You will need to open the command windows as administrator to do this.
    Because npm will not use an absolute path to create new folders, but will use `./node_modules`.
    So it will create a new folder in a location you don&#39;t want it to be if you don&#39;t pay attention.
&lt;/span&gt;
&lt;p&gt;This installs CoffeeScript stuff for Node.js and on Windows it has a .cmd to run coffee-related stuff through Node.js automatically. The default folder for these .cmd files is &lt;code&gt;C:&#92;Program Files (x86)&#92;nodejs&#92;node_modules&#92;.bin&lt;/code&gt; and you should add this to your environment variables too (preferably the existing &lt;code&gt;path&lt;/code&gt; variable). After doing all that, you should be able to run &lt;code&gt;coffee&lt;/code&gt; in your command window.&lt;/p&gt;
&lt;h2&gt;CoffeeScript in Sublime&lt;/h2&gt;
&lt;p&gt;To get CoffeeScript support in Sublime, we’re going to download the CoffeeScript package. First off, it’ll be useful to install Sublime Package Control, to make it easier to install packages. Detailed instructions can be found here: &lt;a href=&quot;http://wbond.net/sublime_packages/package_control/installation&quot;&gt;http://wbond.net/sublime_packages/package_control/installation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now, when we restart Sublime, we can access package control through the Command Palette using &lt;code&gt;Ctrl+Shift+P&lt;/code&gt;. As you start typing commands, you get an overview of the available options. If you execute &lt;code&gt;discover packages&lt;/code&gt;, a browser pops up giving you a nice overview of all available packages and a search bar. To install a package, we need the command &lt;code&gt;install package&lt;/code&gt;. After pressing enter we get a list of all available packages. We will install &amp;quot;CoffeeScript&amp;quot;.&lt;/p&gt;
&lt;h2&gt;Building it&lt;/h2&gt;
&lt;p&gt;After doing all that we already have some support for the language, i.e. syntax highlighting. But building the scripts will not yet work on Windows. To fix this, click &lt;code&gt;Preferences –&amp;gt; Browse Packages...&lt;/code&gt; in Sublime. This will open an explorer window where you can see all the packages. Navigate to &lt;code&gt;CoffeeScript&#92;Commands&lt;/code&gt; and open the file &lt;code&gt;CoffeeScript.sublime-build&lt;/code&gt;. Remove the line that has the path variable and change the cmd line to have &lt;code&gt;coffee.cmd&lt;/code&gt; instead of &lt;code&gt;coffee&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Original version:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;token property&quot;&gt;&quot;path&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;$HOME/bin:/usr/local/bin:$PATH&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token property&quot;&gt;&quot;cmd&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;coffee&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;-c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;$file&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token property&quot;&gt;&quot;file_regex&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;^(...*?):([0-9]*):?([0-9]*)&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token property&quot;&gt;&quot;selector&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;source.coffee&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Edited version:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;token property&quot;&gt;&quot;cmd&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;coffee.cmd&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;-c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;$file&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token property&quot;&gt;&quot;file_regex&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;^(...*?):([0-9]*):?([0-9]*)&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token property&quot;&gt;&quot;selector&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;source.coffee&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now create a file, save it as &lt;code&gt;test.coffee&lt;/code&gt;, add some CoffeeScript, press &lt;code&gt;Ctrl+B&lt;/code&gt; and Sublime creates a file called &lt;code&gt;test.js&lt;/code&gt; in the same folder.&lt;/p&gt;
&lt;p&gt;CoffeeScript file:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;log &lt;span class=&quot;token string&quot;&gt;&quot;Hello world!&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;JavaScript file:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Hello world!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can adjust the build settings to your own needs, e.g. change the output directory or include &lt;a href=&quot;http://www.jslint.com/&quot;&gt;JSLint&lt;/a&gt;. But for getting to know CoffeeScript and playing with it locally, this will work. And it makes it a lot easier! We can also for example integrate building LESS files to CSS in the same way. That would provide a uniform way of building different scripts and styles in a project and prevents us from having to use the command line to do everything manually, which would slow us down.&lt;/p&gt;
</description>
      <pubDate>2011-12-28T15:15:28Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/12/28/building-coffeescript-with-sublime-on-windows/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/12/28/building-coffeescript-with-sublime-on-windows/</guid>
      <category>tools</category>
      <category>web</category>
    </item>
    <item>
      <title>Parallel programming in .NET - PLINQ</title>
      <description>&lt;p&gt;Now that we&#39;ve covered the &lt;a href=&quot;/blog/2011/12/17/parallel-programming-in-net-task-parallel-library/&quot;&gt;Task Parallel Library&lt;/a&gt;, it&#39;s time to move on.&lt;/p&gt;
&lt;h2&gt;What is PLINQ?&lt;/h2&gt;
&lt;p&gt;PLINQ stands for Parallel LINQ and is simply the parallel version of LINQ to Objects. Just like LINQ you can use it on any IEnumerable and there’s also deferred execution. Using PLINQ is even easier than using the Task Parallel Library!&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/12/parallel_net_plinq.png&quot; alt=&quot;Regular for loop and LINQ compared to PLINQ (with time in seconds)&quot; width=&quot;300&quot;&gt;
              &lt;figcaption&gt;Regular for loop and LINQ compared to PLINQ (with time in seconds)&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;h2&gt;How do we use PLINQ?&lt;/h2&gt;
&lt;p&gt;You can even make existing LINQ queries parallel simply by adding the &lt;code&gt;AsParallel()&lt;/code&gt; method. That’s how easy it is! This makes it easy to use the power of parallelization, while enjoying the readability of LINQ. Isn’t that great?&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt;&lt;/span&gt; employees &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;GetEmployees&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Regular LINQ&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt;&lt;/span&gt; query &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; employees&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Skills&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Contains&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;C#&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Extension method style PLINQ&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt;&lt;/span&gt; queryParallel1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; employees&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;AsParallel&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                              &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Skills&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Contains&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;C#&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Query expression style PLINQ&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt;&lt;/span&gt; queryParallel2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; e &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; employees&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;AsParallel&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                     &lt;span class=&quot;token keyword&quot;&gt;where&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Skills&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Contains&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;C#&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                     &lt;span class=&quot;token keyword&quot;&gt;select&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Important fact: PLINQ uses all the processors of your system by default, with a maximum of 64. In some cases you might want to limit this, to give a machine some more power to take care of other tasks. Everybody deserves some CPU time! So don’t be greedy and use &lt;code&gt;WithDegreeOfParallelism()&lt;/code&gt; on heavy queries. Following example uses a maximum of 3 processors, even if there are 16 available.&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt;&lt;/span&gt; queryDegree &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; employees&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;AsParallel&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                           &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;WithDegreeOfParallelism&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                           &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Skills&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Contains&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;C#&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default PLINQ doesn’t care about the order of your output, compared to the input. This is because order preservation costs more time. You can enable order preservation though, again in a very simple way, by using the &lt;code&gt;AsOrdered()&lt;/code&gt; method. It’s good to know that &lt;code&gt;OrderBy()&lt;/code&gt; will also take care of order preservation.&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt;&lt;/span&gt; employees &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;GetEmployeesOrderedByName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt;&lt;/span&gt; queryOrdered &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; employees&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;AsParallel&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Skills&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Contains&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;C#&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;AsOrdered&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;We want more!&lt;/h2&gt;
&lt;p&gt;PLINQ has a lot more to offer than what we talked about here, so be sure to use Google and MSDN if you want to know more. Check out this &amp;quot;old&amp;quot; (2007) yet interesting &lt;a href=&quot;http://msdn.microsoft.com/en-us/magazine/cc163329.aspx&quot;&gt;article on PLINQ&lt;/a&gt; from MSDN magazine. An important read is &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd997399.aspx&quot;&gt;Understanding Speedup in PLINQ on MSDN&lt;/a&gt;, which explains a bit more of how PLINQ works and why it sometimes defaults to sequential mode anyway.&lt;/p&gt;
</description>
      <pubDate>2011-12-23T06:02:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/12/23/parallel-programming-in-net-plinq/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/12/23/parallel-programming-in-net-plinq/</guid>
      <category>parallel</category>
      <category>.net</category>
    </item>
    <item>
      <title>Parallel programming in .NET - Task Parallel Library</title>
      <description>&lt;p&gt;I have talked about parallel programming in .NET before, very briefly: &lt;a href=&quot;/blog/2010/08/30/parallel-programming-in-net-introduction/&quot;&gt;Parallel programming in .NET - Introduction&lt;/a&gt;. This follow-up post is long overdue :)&lt;/p&gt;
&lt;h2&gt;What is the TPL?&lt;/h2&gt;
&lt;p&gt;The Task Parallel Library is a set of APIs present in the &lt;code&gt;System.Threading&lt;/code&gt; and &lt;code&gt;System.Threading.Tasks&lt;/code&gt; namespaces. The point of these APIs is to make parallel programming easier to read and code. The library exposes the &lt;code&gt;Parallel.For&lt;/code&gt; and &lt;code&gt;Parallel.ForEach&lt;/code&gt; methods to enable parallel execution of loops and takes care of spawning and terminating threads, as well as scaling to multiple processors.&lt;/p&gt;
&lt;h2&gt;How do we use the TPL?&lt;/h2&gt;
&lt;p&gt;Following code uses the sequential and the parallel approach to go over a for-loop with some heavy calculations. I use the &lt;code&gt;StopWatch&lt;/code&gt; class to compare the results in a command window.&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;//Sequential&lt;/span&gt;
watch &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;Stopwatch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
watch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Start&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;SomeHeavyCalculations&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
watch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Stop&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
Console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Sequential Time: &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; watch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Elapsed&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Seconds&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ToString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//Parallel&lt;/span&gt;
watch &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;Stopwatch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
watch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Start&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Threading&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Tasks&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Parallel&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;For&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;SomeHeavyCalculations&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
watch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Stop&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
Console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Parallel Time: &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; watch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Elapsed&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Seconds&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ToString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The result of running this on my laptop (with multiple cores) looks like this:&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/12/parallel_net_comparison.png&quot; alt=&quot;Result of comparison sequential - parallel&quot; width=&quot;300&quot;&gt;
              &lt;figcaption&gt;Result of comparison sequential - parallel&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;As you can see, the parallel for-loop runs A LOT faster than the sequential version. By using all the available processing power, we can speed up loops significantly!&lt;/p&gt;
&lt;p&gt;Below is a screenshot of the task manager keeping track of what&#39;s happening  while executing the sequential and the parallel. What we can see here is that at first (where the red arrow is pointing at) we only use 1 core heavily. When the parallel code kicks in, all cores peak.&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/12/parallel_net_taskman.png&quot; alt=&quot;Task manager during comparison sequential - parallel&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Task manager during comparison sequential - parallel&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;So, looking at the above code, implementing all this parallelism doesn’t seem to be that hard. The TPL makes it pretty easy to make use of all the processors in a machine.&lt;/p&gt;
&lt;h2&gt;Creating and running tasks&lt;/h2&gt;
&lt;p&gt;It’s possible to run a task implicitly by using the &lt;code&gt;Parallel.Invoke&lt;/code&gt; method.&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;Parallel&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Invoke&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;DoSomething&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
Parallel&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Invoke&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;DoSomething&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;DoSomethingElse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All you need to do is pass in a delegate, using lambda expressions makes this easy. You can call a named method or have some inline code. If you want to start more tasks concurrently, you can just insert more delegates to the same &lt;code&gt;Parallel.Invoke&lt;/code&gt; method.&lt;/p&gt;
&lt;p&gt;If you want more control over what’s happening, you’ll need to use a Task object, though. The task object has some interesting methods and properties that we can use to control the flow of our parallel code.&lt;/p&gt;
&lt;p&gt;It is possible to use &lt;code&gt;new Task()&lt;/code&gt; to create a new task object, but it’s a best practice to use the task factory. (Note that you can’t use the task factory if you want to separate the creation and the scheduling of the task.)&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create a task and start it&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt;&lt;/span&gt; task1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; Console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Task1 says hi!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
task1&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Start&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Create a task using the task factory&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt;&lt;/span&gt; task1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Task&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Factory&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;StartNew&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; Console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Task1 says hi!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also get results from a task, by accessing the &lt;code&gt;Result&lt;/code&gt; property. If you access it before the task is completed, the thread will be blocked until the result is available.&lt;/p&gt;
&lt;pre class=&quot;language-cs&#92;&quot;&gt;&lt;code class=&quot;language-cs&#92;&quot;&gt;taskreturn = Task.Factory.StartNew(() =&gt;
  {
    int calc = 3 + 3;
    return calc;
  });
int result = taskreturn.Result;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;To be continued..&lt;/h2&gt;
&lt;p&gt;You can chain tasks by using the &lt;code&gt;Task.ContinueWith&lt;/code&gt; method. It’s also possible to access the result of the preceding task in the next one, using the &lt;code&gt;Result&lt;/code&gt; property.&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Regular continuation&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;Task&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; task1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Task&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Factory&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;StartNew&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;Task&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; task2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; task1&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ContinueWith&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;x &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;PrintInt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;x&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Chained continuation&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;Task&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; task1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Task&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Factory&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;StartNew&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                     &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ContinueWith&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;x &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;PrintInt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;x&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The methods &lt;code&gt;ContinueWhenAll()&lt;/code&gt; and &lt;code&gt;ContinueWhenAny()&lt;/code&gt; make it possible to continue from multiple tasks by taking in an array of tasks to wait on and the action to be undertaken when those have finished. More about those functions can be found &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd321479.aspx&quot;&gt;on MSDN&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;The force is strong with this one&lt;/h2&gt;
&lt;p&gt;We only looked at a few functions of the TPL and I think it’s clear this is a very powerful library. When working on applications that need a lot of processing power, parallel programming in .NET can make it easier to improve performance, a lot.&lt;/p&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;Of course there is a lot more to TPL than covered in this small introduction, so go ahead and explore!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd460717.aspx&quot;&gt;MSDN chapter on Task Parallel Library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blogs.msdn.com/b/pfxteam/&quot;&gt;Blog of the Parallel Extensions team&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>2011-12-17T06:04:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/12/17/parallel-programming-in-net-task-parallel-library/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/12/17/parallel-programming-in-net-task-parallel-library/</guid>
      <category>parallel</category>
      <category>.net</category>
    </item>
    <item>
      <title>Unit Testing Best Practices and Test Reviews with Roy Osherove</title>
      <description>&lt;p&gt;Yesterday I attended a session on unit testing by &lt;a href=&quot;http://osherove.com/&quot;&gt;Roy Osherove&lt;/a&gt; in Copenhagen. As I am trying to learn more about unit testing and TDD by applying it in a pet project, it was very interesting to see what a veteran like Roy had to say about the subject of unit testing. Also very interesting was his approach in this session, as he tried to teach us about good habits by showing us bad (real world) examples.&lt;/p&gt;
&lt;p&gt;He also pointed out that anyone interested in writing unit tests and working test driven should do test reviews. It can be used as a learning tool, for example test review some open source projects. But it can also be used internally almost as a replacement of code reviews, because reviewing tests takes a lot less time and should give you a good idea of what the code is supposed to do (when working test driven).&lt;/p&gt;
&lt;p&gt;I took some notes during the session that I would like to share - and keep here for my own reference ;-) I wrote down most of his tips, so to the unit testing experts out there some of it might seem really basic. But I thought it was interesting to have it all written down.&lt;/p&gt;
&lt;h2&gt;Three important words&lt;/h2&gt;
&lt;p&gt;The basic, yet very important requirements for tests:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Readable&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maintainable&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Trustworthy&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Unit test VS integration test&lt;/h2&gt;
&lt;p&gt;Unit tests are used for testing stuff in memory. The tests don’t change and they’re static. They don’t depend on other things.&lt;/p&gt;
&lt;p&gt;Integration tests would be used when there is a dependency on the filesystem, a database, a Sharepoint server, etc.&lt;/p&gt;
&lt;p&gt;Unit tests and integration tests have their own test project!&lt;/p&gt;
&lt;h2&gt;Basics&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Avoid test logic: too complicated
&lt;ul&gt;
&lt;li&gt;Ifs, switches, for loops, ..&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;No multiple asserts
&lt;ul&gt;
&lt;li&gt;This can be okay when you’re asserting using the same object&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Avoid “magic numbers”
&lt;ul&gt;
&lt;li&gt;Using the number 42 somewhere raises the question whether it is important that the number is equal to 42; a good idea would be to use a variable with a descriptive name&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Don’t assert on calculations or concatenations
&lt;ul&gt;
&lt;li&gt;Assert(“user,password”, Bleh()) is better than Assert(user + “,” + password, Bleh())&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Don’t change or remove tests!&lt;/li&gt;
&lt;li&gt;DateTime.Now (or friends like Random) –&amp;gt; NOT okay! These values change every time&lt;/li&gt;
&lt;li&gt;Test only publics&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Reuse&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Factory methods (usually in the same class as the tests using them)
&lt;ul&gt;
&lt;li&gt;make_xx&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Configure initial state
&lt;ul&gt;
&lt;li&gt;init_xx&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Common tests in common methods
&lt;ul&gt;
&lt;li&gt;verify_xx&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Tests are isolated&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Don’t call other tests in a test&lt;/li&gt;
&lt;li&gt;No shared state, have cleanup code for shared objects&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Mock != Stub (in short)&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Mock = used for asserts&lt;/li&gt;
&lt;li&gt;Stub = used to help the test&lt;/li&gt;
&lt;li&gt;Fake = can be both&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Tip&lt;/h2&gt;
&lt;p&gt;If you need to test things related to a database, that would be an integration test and it’s a good idea to use the TransactionScope class in .NET so you can rollback everything when the test is done.&lt;/p&gt;
</description>
      <pubDate>2011-10-28T10:58:02Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/10/28/unit-testing-best-practices-and-test-reviews-with-roy-osherove/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/10/28/unit-testing-best-practices-and-test-reviews-with-roy-osherove/</guid>
      <category>.net</category>
      <category>testing</category>
    </item>
    <item>
      <title>Bing Maps - Geocoding in PowerShell</title>
      <description>&lt;p&gt;Since I had fun using the Bing Maps API in C# (see &lt;a href=&quot;/blog/2011/08/17/bing-maps-geocoding-and-imagery/&quot;&gt;Bing Maps - Geocoding and Imagery&lt;/a&gt;), I decided to try and do the same in PowerShell. This didn&#39;t seem to be very hard either, as it&#39;s possible to use the same objects as you would in a regular .NET application. Go PowerShell! The only difference is the web service trick on the second line.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$key&lt;/span&gt; = &lt;span class=&quot;token string&quot;&gt;&quot;apikey&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;$ws&lt;/span&gt; = &lt;span class=&quot;token function&quot;&gt;New-WebServiceProxy&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;uri http:&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;dev&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;virtualearth&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;net/webservices/v1/geocodeservice/geocodeservice&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;svc?wsdl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;$wsgr&lt;/span&gt; = &lt;span class=&quot;token function&quot;&gt;New-Object&lt;/span&gt; Microsoft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PowerShell&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Commands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;NewWebserviceProxy&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;AutogeneratedTypes&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;WebServiceProxy1ervice_geocodeservice_svc_wsdl&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;GeocodeRequest&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token variable&quot;&gt;$wsc&lt;/span&gt; = &lt;span class=&quot;token function&quot;&gt;New-Object&lt;/span&gt; Microsoft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PowerShell&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Commands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;NewWebserviceProxy&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;AutogeneratedTypes&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;WebServiceProxy1ervice_geocodeservice_svc_wsdl&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;$wsc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ApplicationId = &lt;span class=&quot;token variable&quot;&gt;$key&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;$wsgr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials = &lt;span class=&quot;token variable&quot;&gt;$wsc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token variable&quot;&gt;$wsgr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Query = &lt;span class=&quot;token string&quot;&gt;&#39;Brussels, Belgium&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token variable&quot;&gt;$wsr&lt;/span&gt; = &lt;span class=&quot;token variable&quot;&gt;$ws&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Geocode&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$wsgr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token variable&quot;&gt;$wsr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Results&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;select&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Address&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;FormattedAddress&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Locations&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Longitude&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Locations&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Latitude&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you execute this in PowerShell, it looks like this:&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/08/bingapi_powershell.png&quot; alt=&quot;Geocoding in PowerShell&quot; &gt;
              &lt;figcaption&gt;Geocoding in PowerShell&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;Things like this make you think about the power of PowerShell. If you can do it in .NET, you can do it in PS!&lt;/p&gt;
</description>
      <pubDate>2011-08-19T05:05:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/08/19/bing-maps-geocoding-in-powershell/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/08/19/bing-maps-geocoding-in-powershell/</guid>
      <category>gis</category>
      <category>powershell</category>
    </item>
    <item>
      <title>Bing Maps - Geocoding and Imagery</title>
      <description>&lt;p&gt;Since I did a lot of GIS related stuff recently for work, I decided I&#39;d have some fun with the Bing Maps API. I&#39;ve been using Bing to display maps as a base for multiple layers of data in combination with MapGuide OS and needed to convert addresses to coordinates. Afterwards I decided to play with it some more and I created a little app in C# that makes more use of Bing Maps.&lt;/p&gt;
&lt;p&gt;If you want to &lt;strong&gt;get started with the Bing API&lt;/strong&gt;, you&#39;ll first need to &lt;strong&gt;get a key&lt;/strong&gt;. More info on that can be found &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ff428642.aspx&quot;&gt;on MSDN&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Alright, now you got your key, let&#39;s get started!&lt;/p&gt;
&lt;h2&gt;Setting up&lt;/h2&gt;
&lt;p&gt;First thing you need to do to use the Bing Maps service, is &lt;strong&gt;adding a service reference&lt;/strong&gt;. We&#39;ll start out with some geocoding, so we need the geocode service. The addresses of the available services can be found &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc966738.aspx&quot; title=&quot;Bing Maps Services&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/08/bingapi_servicereference.png&quot; alt=&quot;Click &#39;Add Service Reference...&#39; to open the service reference dialog&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Click &#39;Add Service Reference...&#39; to open the service reference dialog&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;h1&gt;Geocoding&lt;/h1&gt;
&lt;p&gt;We can use the following code to &amp;quot;geocode&amp;quot; an address (get the coordinates):&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Geocode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; address&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;GeocodeRequest&lt;/span&gt; geocodeRequest &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;GeocodeRequest&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Set credentials using a Bing Maps key&lt;/span&gt;
    geocodeRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;GeocodeService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    geocodeRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ApplicationId &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; key&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Set the address&lt;/span&gt;
    geocodeRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Query &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; address&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Make the geocode request&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;GeocodeServiceClient&lt;/span&gt; geocodeService &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;GeocodeServiceClient&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;BasicHttpBinding_IGeocodeService&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;GeocodeResponse&lt;/span&gt; geocodeResponse &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; geocodeService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Geocode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;geocodeRequest&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;GetGeocodeResults&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;geocodeResponse&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;GetGeocodeResults is just a function that I made to print out the response on the screen. As seen here:&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/08/bingapi_geocode.png&quot; alt=&quot;Get the coordinates for an address&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Get the coordinates for an address&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;(There are some extra options available. You could, for example, tell the service to only return &amp;quot;high confidence&amp;quot; results. But I&#39;m not going to talk about that here.)&lt;/p&gt;
&lt;h2&gt;Reverse geocoding&lt;/h2&gt;
&lt;p&gt;Because getting the coordinates was so easy, I decided to also implement reverse geocoding. Which is (as you would expect) converting coordinates to an address.&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ReverseGeocode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;double&lt;/span&gt;&lt;/span&gt; latitude&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;double&lt;/span&gt;&lt;/span&gt; longitude&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;ReverseGeocodeRequest&lt;/span&gt; reverseGeocodeRequest &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;ReverseGeocodeRequest&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Set credentials using a Bing Maps key&lt;/span&gt;
    reverseGeocodeRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;GeocodeService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    reverseGeocodeRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ApplicationId &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; key&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Set the coordinates&lt;/span&gt;
    reverseGeocodeRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Location &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;BingMapsSoap&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;GeocodeService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;GeocodeLocation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Latitude &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; latitude&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Longitude &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; longitude &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Make the reverse geocode request&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;GeocodeServiceClient&lt;/span&gt; geocodeService &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;GeocodeServiceClient&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;BasicHttpBinding_IGeocodeService&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;GeocodeResponse&lt;/span&gt; geocodeResponse &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; geocodeService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ReverseGeocode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;reverseGeocodeRequest&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;GetGeocodeResults&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;geocodeResponse&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/08/bingapi_reversegeocode.png&quot; alt=&quot;Converting coordinates to addresses is easy!&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Converting coordinates to addresses is easy!&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;h2&gt;Imagery&lt;/h2&gt;
&lt;p&gt;After getting this far in about 15 minutes of figuring it out and coding, I couldn&#39;t stop there! I decided to add some basic imagery for the address/coordinates that are converted. For imagery you need to add a reference to the imagery service first. Writing code for this is also pretty easy, as there are plenty of examples on MSDN that can be useful. It seems Microsoft really put some effort into  documenting this right :-)&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;GetImagery&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;double&lt;/span&gt;&lt;/span&gt; latitude&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;double&lt;/span&gt;&lt;/span&gt; longitude&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;MapUriRequest&lt;/span&gt; mapUriRequest &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;MapUriRequest&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Set credentials using Bing Maps key&lt;/span&gt;
    mapUriRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;ImageryService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    mapUriRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ApplicationId &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; key&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Set the location of the image&lt;/span&gt;
    mapUriRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Center &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;ImageryService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Location&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    mapUriRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Center&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Latitude &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; latitude&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    mapUriRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Center&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Longitude &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; longitude&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Set map style and zoom level&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;MapUriOptions&lt;/span&gt; mapUriOptions &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;MapUriOptions&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    mapUriOptions&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Style &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MapStyle&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;AerialWithLabels&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    mapUriOptions&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ZoomLevel &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// Set size of the image to match the size of the image control&lt;/span&gt;
    mapUriOptions&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ImageSize &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;ImageryService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;SizeOfint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    mapUriOptions&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ImageSize&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Height &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;160&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    mapUriOptions&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ImageSize&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Width &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;160&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    mapUriRequest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Options &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; mapUriOptions&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token class-name&quot;&gt;ImageryServiceClient&lt;/span&gt; imageryService &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;ImageryServiceClient&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;BasicHttpBinding_IImageryService&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;MapUriResponse&lt;/span&gt; mapUriResponse &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; imageryService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;GetMapUri&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;mapUriRequest&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token class-name&quot;&gt;BitmapImage&lt;/span&gt; bmpImg &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;BitmapImage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;Uri&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;mapUriResponse&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Uri&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    bingImage&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Source &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; bmpImg&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That code gives us this result:&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/08/bingapi_imagery.png&quot; alt=&quot;Bing Maps Imagery&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Bing Maps Imagery&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;Looks pretty good for a small app that took almost no time to make. The Bing Maps API is pretty straight-forward to work with and MSDN has some good samples to get started. So if you&#39;re interested in working with Bing Maps, be sure to check out &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd877180.aspx&quot; title=&quot;Bing Maps on MSDN&quot;&gt;the documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now go and have fun with this!&lt;/p&gt;
</description>
      <pubDate>2011-08-17T05:06:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/08/17/bing-maps-geocoding-and-imagery/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/08/17/bing-maps-geocoding-and-imagery/</guid>
      <category>gis</category>
    </item>
    <item>
      <title>PowerShell Script Commander</title>
      <description>&lt;blockquote&gt;
&lt;p&gt;I wrote this entry last year September, but for several reasons the post and the code never made it to the interwebs.
After running into it again I decided to post it anyway and upload the code to &lt;a href=&quot;http://pscommander.codeplex.com/&quot;&gt;Codeplex&lt;/a&gt;.
So, here goes!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A while back I created this PowerShell script to remotely manage services (see &lt;a href=&quot;/blog/2010/02/24/powershell-remote-service-manager/&quot;&gt;Remote Service Manager&lt;/a&gt;), a bit later I made the available help a bit more professional (see &lt;a href=&quot;/blog/2010/05/10/add-help-to-your-own-powershell-scripts/&quot;&gt;Add help to your own PowerShell scripts&lt;/a&gt;). Now I was thinking it would be cool to create an interface in .NET for this script. So I started developing a WinForm application around the script. Initially, it looked like this:&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/08/remoteservicemanager.png&quot; alt=&quot;Remote Service Manager&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Remote Service Manager&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;This was the first (working) prototype of the RSM-GUI. But then I started thinking it would be much cooler to create an application that can run all scripts, even those with parameters. I started thinking about how to do this and actually it didn&#39;t seem so hard. I started by creating a form that can execute simple PowerShell commands and show the output, then added support for running scripts stored on the hard drive. For the parameters I just made sure they are all displayed in a grid, where you can give them a value by simply typing something in. And that was it! I now have a Windows application that can run scripts on a more visual way. Now you can simply load the script with an OpenFileDialog and see what parameters are available. If you still don&#39;t fully understand how the script works, you can press the Get-Help button to display the help information in the outputbox.&lt;/p&gt;
&lt;p&gt;And now, it looks like this:&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/08/scriptcommander-help.png&quot; alt=&quot;PowerShell Script Commander help function&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;PowerShell Script Commander help function&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2011/08/scriptcommander-rsm.png&quot; alt=&quot;PowerShell Script Commander running the RSM script, with parameters&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;PowerShell Script Commander running the RSM script, with parameters&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;A lot of work needs to be done to make this more reliable and to make it work with all scripts on the planet ;-) But I think it&#39;s already pretty cool.&lt;/p&gt;
&lt;p&gt;The source code can be found here: &lt;a href=&quot;http://pscommander.codeplex.com/&quot;&gt;http://pscommander.codeplex.com/&lt;/a&gt;&lt;/p&gt;
</description>
      <pubDate>2011-08-13T05:07:00Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/08/13/powershell-script-commander/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/08/13/powershell-script-commander/</guid>
      <category>powershell</category>
    </item>
    <item>
      <title>MapGuide OS - Failed while processing WebVirtualDirs</title>
      <description>&lt;img style=&quot;float:left;margin-right:5px;&quot; title=&quot;Error!&quot; src=&quot;/img/2011/08/error.png&quot; alt=&quot;&quot; width=&quot;120&quot; /&gt;
When you are installing MapGuide OS and you encounter following error:
&lt;p&gt;&lt;code&gt;Failed while processing WebVirtualDirs&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Fear not, because here is the solution!&lt;/p&gt;
&lt;p&gt;The problem is with how MapGuide OS is trying to install its websites. This is not configurable during the installation and will by default be installed in a website called &amp;quot;Default Web Site&amp;quot; on port 80. This is the website that is created for you when IIS is installed. If you change the name of the website or the port number, the MapGuide OS installation freaks out!&lt;/p&gt;
&lt;p&gt;So the simplest solution is to create a website called &amp;quot;Default Web Site&amp;quot; and have it run at port 80. You can then edit those settings after the installation is done without any problems, so you can still run the MapGuide OS websites on a different port.&lt;/p&gt;
&lt;p&gt;If you need some more explanation, there is an &lt;a href=&quot;http://osgeo-org.1803224.n2.nabble.com/Installation-error-td3858392.html&quot;&gt;interesting thread&lt;/a&gt; with a &lt;a href=&quot;http://www.jasonbirch.com/nodes/&quot;&gt;good answer by Jason Birch&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>2011-08-11T14:01:12Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/08/11/mapguide-os-failed-while-processing-webvirtualdirs/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/08/11/mapguide-os-failed-while-processing-webvirtualdirs/</guid>
      <category>gis</category>
    </item>
    <item>
      <title>MapGuide – LayerDefinitionFactory in .NET</title>
      <description>&lt;img style=&quot;float:left;margin-left:5px;margin-right:5px;&quot; title=&quot;Autodesk Infrastructure Map Server&quot; src=&quot;/img/2011/08/autodeskinfrastructuremapserver.png&quot; alt=&quot;Autodesk Infrastructure Map Server logo&quot; width=&quot;119&quot; height=&quot;150&quot; /&gt;
I encountered a problem today while working on a website that uses Autodesk Infrastructure Map Server 2012 (aka MapGuide) and its API. To programmatically create a new layer on a map it seems to be recommended to use the LayerDefinitionFactory that is provided with the installation of the server. Now the problem is that this factory is only provided in PHP and I am working in C#. I could install PHP on the server and try to get all freaky with .NET-PHP communication. But it seemed easier to just port the factory to C# (it&#39;s not that big anyway).
&lt;p&gt;I wrote some basic functions and then only converted the stuff I need for this particular project, but it should be very easy to convert the other functions when you need them. I did not rewrite the &lt;code&gt;sprintf()&lt;/code&gt; function that can be found in PHP, because it is a lot easier to use &lt;code&gt;String.Format()&lt;/code&gt; if you adjust the template files. So, this is what one of the templates now look like after changing all the occurrences of &lt;code&gt;%s&lt;/code&gt; to the C# version with &lt;code&gt;{0}&lt;/code&gt;, &lt;code&gt;{1}&lt;/code&gt;, etc.:&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token prolog&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;LayerDefinition&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;xmlns:&lt;/span&gt;xsi&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://www.w3.org/2001/XMLSchema-instance&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
                 &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;xsi:&lt;/span&gt;noNamespaceSchemaLocation&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;LayerDefinition-2.3.0.xsd&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
                 &lt;span class=&quot;token attr-name&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2.3.0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;VectorLayerDefinition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ResourceId&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;{0}&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ResourceId&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;FeatureName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;{1}&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;FeatureName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;FeatureNameType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;FeatureClass&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;FeatureNameType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Geometry&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;{2}&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;Geometry&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    {3}
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;VectorLayerDefinition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;LayerDefinition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here is the code:&lt;/p&gt;
&lt;pre class=&quot;language-cs&quot;&gt;&lt;code class=&quot;language-cs&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Text&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;IO&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;summary&gt;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;/// Factory for MapGuide layer definitions.&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;/summary&gt;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;LayerDefinitionFactory&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; templatePath&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;LayerDefinitionFactory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		templatePath &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; String&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Concat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;{0}.templ&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// Read the template required for the layer definition.&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;/summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;returns&gt;Returns (a part of) the layer definition in XML.&amp;lt;/returns&gt;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ReadTemplate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; filename&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token class-name&quot;&gt;StreamReader&lt;/span&gt; reader &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;StreamReader&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;String&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;templatePath&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; filename&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; templateDefinition &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; reader&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ReadToEnd&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		reader&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Close&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; templateDefinition&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// Create a new layerdefinition.&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;/summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;CreateLayerDefinition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; resourceId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; featureClass&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; geometry&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; featureClassRange&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt; values &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; resourceId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; featureClass&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; geometry&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; featureClassRange &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; String&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ReadTemplate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;layerdefinition&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; values&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// Create a new line rule for the layer definition.&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;/summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;CreateLineRule&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; lineStyle&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; thickness&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; color&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt; values &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; lineStyle&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; thickness&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; color &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; String&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ReadTemplate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;linerule&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; values&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// Create the line type style with line rules for the layer definition.&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;/summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;CreateLineTypeStyle&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; lineRules&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt; values &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; lineRules &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; String&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ReadTemplate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;linetypestyle&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; values&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// Create the scale range for the layer definition.&lt;/span&gt;
	&lt;span class=&quot;token comment&quot;&gt;/// &amp;lt;/summary&gt;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token return-type class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;CreateScaleRange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; minScale&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; maxScale&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;/span&gt; typeStyle&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt; values &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token constructor-invocation class-name&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; minScale&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; maxScale&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; typeStyle &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; String&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ReadTemplate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;scalerange&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; values&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</description>
      <pubDate>2011-08-09T14:29:22Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/08/09/mapguide-layerdefinitionfactory-in-net/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/08/09/mapguide-layerdefinitionfactory-in-net/</guid>
      <category>gis</category>
    </item>
    <item>
      <title>Cool tool - Neptune (SMTP Testing Server)</title>
      <description>&lt;h2&gt;Testing e-mails sent from .NET code&lt;/h2&gt;
&lt;p&gt;It&#39;s always a big hassle to test sending e-mails from websites or applications written in .NET (or any other platform/language). Your inbox gets flooded or even worse, customers&#39; inboxes get flooded. Or you&#39;ve set up a dummy account to test if e-mails get sent. But sometimes e-mail addresses need to be picked up dynamically depending on certain parameters, from a database, for example. Testing gets annoying here. You can debug and check if the address you want is the right one, you can bother people to check their inbox every time you&#39;re testing, ...&lt;/p&gt;
&lt;p&gt;There has to be a better solution, right? Yes there is!&lt;/p&gt;
&lt;h2&gt;Developers, let&#39;s start testing!&lt;/h2&gt;
&lt;p&gt;Thanks to this little tool I found last week, this has become a lot easier. It&#39;s actually been around for about 2,5 years already. Too bad I never found out about it earlier :-)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: Just found out about this thing, which is on CodePlex, so we can play with the code! It&#39;s called smtp4dev and can be found here: &lt;a href=&quot;http://smtp4dev.codeplex.com/&quot;&gt;http://smtp4dev.codeplex.com/&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Here are URLs to the 3 blogposts by Donovan Brown about the little server app:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://donovanbrown.com/post/Neptune.aspx%22%3Ehttp://donovanbrown.com/post/Neptune.aspx&quot;&gt;Neptune&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://donovanbrown.com/post/Neptune-(future-features).aspx%22%3Ehttp://donovanbrown.com/post/Neptune-(future-features).aspx&quot;&gt;Neptune (future features)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://donovanbrown.com/post/Neptune-with-POP3.aspx%22%3Ehttp://donovanbrown.com/post/Neptune-with-POP3.aspx&quot;&gt;Neptune with POP3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Note: Don&#39;t download the application from the first blogpost! The post about POP3 has the latest version.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Be sure to read the documentation, it has everything you need to know about using this tool.&lt;/p&gt;
&lt;p&gt;Too bad Donovan has never put this on Codeplex (or any other open source repository), because I think we can all imagine some nice features to add to this little useful thing..&lt;/p&gt;
</description>
      <pubDate>2011-05-12T23:28:09Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2011/05/12/cool-tool-neptune-smtp-testing-server/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2011/05/12/cool-tool-neptune-smtp-testing-server/</guid>
      <category>general</category>
      <category>tools</category>
    </item>
    <item>
      <title>Parallel programming in .NET - Introduction</title>
      <description>&lt;h2&gt;What is parallel programming?&lt;/h2&gt;
&lt;p&gt;Sequential programming assumes a set of instructions that are executed sequentially by a single processor. The point of parallel programming is to program systems that consist of multiple processors and therefore have multiple simultaneous instruction streams.&lt;/p&gt;
&lt;h2&gt;Why do we need it?&lt;/h2&gt;
&lt;p&gt;The clock speeds of chips are no longer increasing. All future improvements in computer speed will come from parallelism. In other words, more and more processors are being added to new computers. These chips enable software to do &lt;strong&gt;multiple tasks at the same time&lt;/strong&gt;. Each processor its own task. So one way to make applications run faster, is to use parallel programming. This is &lt;strong&gt;not the same as multithreading&lt;/strong&gt;, though. Multithreading can be done on a single core CPU. In that case, two threads can never execute at the same time on the CPU. The operating system (which takes care of multi-threading) divides the time of the processor between all open threads. When you have too many executing threads at once, your system slows down as there is not enough time for all the threads to run at full speed.&lt;/p&gt;
&lt;h2&gt;Concurrent vs Parallel&lt;/h2&gt;
&lt;p&gt;To be clear, parallel programming is not the same as concurrent programming. As they say, a picture says more than a thousand words:&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/08/concurrentvsparallel.png&quot; alt=&quot;Comparison between concurrent and parallel&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Comparison between concurrent and parallel&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;Well, maybe it could use some explanation.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Concurrent applications&lt;/strong&gt; tend to create a thread that handles a whole series of tasks. Most of the time these concurrent applications create threads because they need an isolated process for a concurrent event.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parallel applications&lt;/strong&gt; divide a process into small tasks that are executed on seperate threads. Because the tasks are small, the threads can be divided evenly over the processors, resulting in very efficient use of a multi-core CPU.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Parallel programming in .NET 4.0&lt;/h2&gt;
&lt;p&gt;In the .NET 4.0 framework parallel is included in the form of &lt;strong&gt;Task Parallel Library&lt;/strong&gt; (TPL) and &lt;strong&gt;Parallel LINQ&lt;/strong&gt; (PLINQ). These functions are actually built on top of the existing thread pool in previous versions of the .NET framework. Parallel is pretty easy to implement, but also very easy to misuse or overuse. Caution is required!&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/08/paralleloverview-msdn.png&quot; alt=&quot;Overview of parallelism in .NET (from MSDN)&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Overview of parallelism in .NET (from MSDN)&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;The following resources provide an introduction to parallel programming in C# 4.0 and provide some guidelines and best practices:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd460693(v=VS.100).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/dd460693%28v=VS.100%29.aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Parallel_Extensions&quot;&gt;http://en.wikipedia.org/wiki/Parallel_Extensions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>2010-08-30T17:27:18Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/08/30/parallel-programming-in-net-introduction/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/08/30/parallel-programming-in-net-introduction/</guid>
      <category>parallel</category>
    </item>
    <item>
      <title>Add help to your own PowerShell scripts</title>
      <description>&lt;p&gt;A while ago I created a script to manage services on a remote server (see &lt;a href=&quot;/blog/2010/02/24/powershell-remote-service-manager/&quot;&gt;Remote Service Manager&lt;/a&gt;). Included in that script was a way to display some information with the use of a switch (&lt;code&gt;-help&lt;/code&gt;). A few days later I was wondering if there wasn&#39;t a better way to include help in own PowerShell scripts. And of course there is! It&#39;s even in the help files.&lt;/p&gt;
&lt;p&gt;So, here&#39;s what to do. First, check the information in PowerShell help by running following command:&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;Get-Help&lt;/span&gt; about_Comment_Based_Help&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There we can see this help thing will be pretty straightforward to implement. Here&#39;s what it says:&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;The syntax &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; comment-based Help is as follows:

    &lt;span class=&quot;token comment&quot;&gt;# .help keyword&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;# help content&lt;/span&gt;

&lt;span class=&quot;token operator&quot;&gt;-or&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;#
        .help keyword
        help content
    #&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This means we just have to make a comment block, with some specific keywords. Cool. So, what are the right keywords? They&#39;re also in the help. Here&#39;s a small list of the most important stuff:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.SYNOPSIS&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.DESCRIPTION&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.PARAMETER &amp;amp;lt;Parameter-Name&amp;amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.EXAMPLE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.NOTES&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.LINK&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more details and a complete list of keywords, I suggest you look at the help in PowerShell. Here is a little example of how we&#39;re going to put this to work:&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;#

.SYNOPSIS
This is a simple Powershell script to explain how to create help

.DESCRIPTION
The script itself will only print &#39;Hello World&#39;. But that&#39;s cool.
Its main objective is to show off the cool help thingy anyway.

.EXAMPLE
./HelloWorld.ps1

.NOTES
Put some notes here.

.LINK
https://kevinpelgrims.com

#&gt;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;Write-Host&lt;/span&gt; ‘Hello World!’&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There, that&#39;s all there is to it. I wish I looked at that before I made the RSM script :) It adds some kind of professionalism to a script, don&#39;t you think? And also, it&#39;s intuitive for users to use the Get-Help command. Everyone is happy!&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/05/get-help.png&quot; alt=&quot;Our very own help&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Our very own help&lt;/figcaption&gt;
            &lt;/figure&gt;
</description>
      <pubDate>2010-05-10T08:21:56Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/05/10/add-help-to-your-own-powershell-scripts/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/05/10/add-help-to-your-own-powershell-scripts/</guid>
      <category>powershell</category>
    </item>
    <item>
      <title>PowerShell 2.0 - Remoting</title>
      <description>&lt;p&gt;This is the last part (of four) in a series of articles on the new features in PowerShell 2.0. Last time we discussed &lt;a href=&quot;/blog/2010/05/03/powershell-2-0-modules/&quot;&gt;modules&lt;/a&gt;, now it&#39;s time for &lt;strong&gt;remoting&lt;/strong&gt;!&lt;/p&gt;
&lt;h2&gt;Remoting&lt;/h2&gt;
&lt;p&gt;One of the coolest new features is remoting. It is kind of like running remote desktop in command line. Although it&#39;s an important piece of PowerShell 2.0, there&#39;s not a lot to explain about this. It&#39;s all pretty easy to use.&lt;/p&gt;
&lt;p&gt;What&#39;s fun is that we have the option of executing one command on different remote computers at the same time. This will save system administrators a lot of time. To demonstrate this consider following command:&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;Invoke-Command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;ComputerName Server1 &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;scriptblock &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Get-Service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This gets all services from Server1. To run this on multiple servers we just adjust the command:&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;Invoke-Command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;ComputerName Server1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Server2&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Server3 &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;scriptblock &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Get-Service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we get all services from Server1, Server2 and Server3 in a really easy way.&lt;/p&gt;
&lt;p&gt;Another way to use remoting is by connecting to a remote session with &lt;code&gt;Enter-PSSession&lt;/code&gt;. You type commands in your local console, but everything is executed on the remote machine. Until you leave the remote session, by using &lt;code&gt;Exit-PSSession&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;PS&lt;/span&gt; D:&#92;ProjectsPS&gt; &lt;span class=&quot;token function&quot;&gt;Enter-PSSession&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;ComputerName Server1

&lt;span class=&quot;token function&quot;&gt;PS&lt;/span&gt; Server1&gt; &lt;span class=&quot;token function&quot;&gt;Get-Process&lt;/span&gt; powershell

Handles  NPM&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;K&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;    PM&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;K&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;      WS&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;K&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; VM&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;M&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;   CPU&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;     Id ProcessName
&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;  &lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;    &lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;      &lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;   &lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;     &lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;
    547       8    95660       8852   199     6&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;84   5136 powershell

&lt;span class=&quot;token function&quot;&gt;PS&lt;/span&gt; Server1&gt; &lt;span class=&quot;token function&quot;&gt;Exit-PSSession&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;PS&lt;/span&gt; D:&#92;ProjectsPS&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Of course, there are a lot of other commands available, so once more, I will tell you to use the PowerShell 2.0 help: &lt;code&gt;Get-Help about_PSSessions&lt;/code&gt;. Much can be learned from the official documentation (yes, it&#39;s really good!).&lt;/p&gt;
&lt;p&gt;And another good resource is of course Technet, where all the available cmdlets are explained in a more readable manner (see resources).&lt;/p&gt;
&lt;p&gt;So that&#39;s all for today folks! I hope you learned some things that will be useful in future projects.&lt;/p&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/dd347701.aspx&quot;&gt;All available cmdlets on Technet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>2010-05-06T10:18:10Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/05/06/powershell-2-0-remoting/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/05/06/powershell-2-0-remoting/</guid>
      <category>powershell</category>
    </item>
    <item>
      <title>PowerShell 2.0 - Modules</title>
      <description>&lt;p&gt;This is part three of four in a series of articles on the new features in PowerShell 2.0.
Last time we discussed &lt;a href=&quot;/blog/2010/04/29/powershell-2-0-transactions/&quot;&gt;transactions&lt;/a&gt;, now it&#39;s time for &lt;strong&gt;modules&lt;/strong&gt;!&lt;/p&gt;
&lt;h2&gt;Modules&lt;/h2&gt;
&lt;p&gt;A module is a package that contains a bunch of PowerShell commands, like cmdlets, functions, variables, ..&lt;/p&gt;
&lt;p&gt;This can be very useful when sharing your code with others, or deploying it to different servers. Think of a module as kind of an assembly for PowerShell.&lt;/p&gt;
&lt;p&gt;Consider the next piece of code:&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; Add &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Test-Path&lt;/span&gt; variable:script:count&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$script&lt;/span&gt;:count = 0 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$script&lt;/span&gt;:count+&lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&quot;We add one and the total becomes {0}!&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;f &lt;span class=&quot;token variable&quot;&gt;$script&lt;/span&gt;:count
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; Substract &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Test-Path&lt;/span&gt; variable:script:count&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$script&lt;/span&gt;:count = 0 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token variable&quot;&gt;$script&lt;/span&gt;:count-&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&quot;We substract one and the total becomes {0}!&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;f &lt;span class=&quot;token variable&quot;&gt;$script&lt;/span&gt;:count
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; SetCount&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;token variable&quot;&gt;$script&lt;/span&gt;:count = &lt;span class=&quot;token variable&quot;&gt;$value&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Export only the Add and Substract functions, not SetCount.&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;Export-ModuleMember&lt;/span&gt; Add&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Substract
&lt;span class=&quot;token comment&quot;&gt;# End of Script&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is our module. Now what do we do with it? To deploy this module we just need to create a new folder in &lt;code&gt;C:&#92;Users&#92;username&#92;Documents&#92;WindowsPowerShell&#92;Modules&#92;&lt;/code&gt; and put our files in there. I&#39;ll call this file &lt;code&gt;Calculatron.psm1&lt;/code&gt; and create the folder Calculatron at the Modules root.&lt;/p&gt;
&lt;p&gt;All we need to do now is import the module by calling &lt;code&gt;Import-Module&lt;/code&gt; and then we can use the new functions we created! They even become available in the tab command completion (you know what I mean, type &amp;quot;subs&amp;quot; and press the tab button).&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/05/modules.png&quot; alt=&quot;&quot; width=&quot;519&quot;&gt;
              &lt;figcaption&gt;&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;Now you can use this awesome power to do some fun stuff and make your scripts easily reusable.&lt;/p&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/dd347701.aspx&quot;&gt;All available cmdlets on Technet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tfl09.blogspot.com/2009/01/modules-in-powershell-v2.html&quot;&gt;About modules&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd878324%28v=VS.85%29.aspx&quot;&gt;MSDN on modules&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>2010-05-03T07:37:20Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/05/03/powershell-2-0-modules/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/05/03/powershell-2-0-modules/</guid>
      <category>powershell</category>
    </item>
    <item>
      <title>PowerShell 2.0 - Transactions</title>
      <description>&lt;p&gt;This is part two of four in a series of articles on the new features in PowerShell 2.0. Last time we discussed &lt;a href=&quot;/blog/2010/04/27/powershell-2-0-background-jobs/&quot;&gt;background jobs&lt;/a&gt;, now it&#39;s time for &lt;strong&gt;transactions&lt;/strong&gt;!&lt;/p&gt;
&lt;h2&gt;Transactions&lt;/h2&gt;
&lt;p&gt;When you run scripts, generally, three things can happen:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The script runs, my favorite&lt;/li&gt;
&lt;li&gt;The script fails, this is not cool, but you can probably fix it&lt;/li&gt;
&lt;li&gt;The script runs only partially and dies unexpectedly in the middle of executing stuff. This is very bad and this is probably not what you want.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;PowerShell 2.0 has the solution: transactions. They can help you to solve these issues and make sure the script just succeeds, or fails, but nothing in between.&lt;/p&gt;
&lt;p&gt;Starting a transaction is pretty easy with the &lt;code&gt;Start-Transaction&lt;/code&gt; command, but it doesn&#39;t magically fix everything. You still have to use the &lt;code&gt;-UseTransaction&lt;/code&gt; switch on your regular commands. Commands that use this switch will run inside the scope of the transaction, those who don&#39;t will run on the outside. To commit the results of the transaction, use &lt;code&gt;Complete-Transaction&lt;/code&gt;. If there is something wrong and you need to undo the changes, call &lt;code&gt;Undo-Transaction&lt;/code&gt;. A little transactions demo in the new Microsoft PowerShell ISE:&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/04/transactions.png&quot; alt=&quot;&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;This small script creates a transaction scope and creates a string object. Then we append some text to it twice. Once out of the transaction scope, the second time inside of the transaction scope. When we do a &lt;code&gt;ToString()&lt;/code&gt;, we see that the text that is appended inside of the transaction is not visible at this point. This is kind of normal, because the transaction is not yet completed. Then we complete the transaction and do a &lt;code&gt;ToString()&lt;/code&gt; again, and we can see the second text too.&lt;/p&gt;
&lt;p&gt;Again, use the power of the shell for more info: &lt;code&gt;Get-Help about_Transaction&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/dd347701.aspx&quot;&gt;All available cmdlets on Technet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blogs.msdn.com/powershell/archive/2008/05/09/powershell-transactions-quickstart.aspx&quot;&gt;Transactions quickstart on the official PowerShell Blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>2010-04-29T19:37:10Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/04/29/powershell-2-0-transactions/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/04/29/powershell-2-0-transactions/</guid>
      <category>powershell</category>
    </item>
    <item>
      <title>PowerShell 2.0 - Background Jobs</title>
      <description>&lt;p&gt;I already told you about a few &lt;a href=&quot;/blog/2010/02/17/powershell-2-what-is-it-and-whats-new/&quot;&gt;cool new features&lt;/a&gt; in PowerShell 2.0, now it&#39;s time to play with them. I&#39;ve divided one large article into four small ones, to make it a bit more readable. We&#39;ll start with &lt;strong&gt;background jobs&lt;/strong&gt;, &lt;strong&gt;transactions&lt;/strong&gt; and &lt;strong&gt;modules&lt;/strong&gt; and end with &lt;strong&gt;remoting&lt;/strong&gt;. These will become very useful for the PowerShell master.&lt;/p&gt;
&lt;h2&gt;Background jobs&lt;/h2&gt;
&lt;p&gt;What do these things do again? Background jobs are commands that run asynchronously. When you run a background job, the command prompt returns immediately, even if the command is still running.&lt;/p&gt;
&lt;p&gt;Background jobs can be really useful to run complex commands on the background, while continuing some other work. Let&#39;s see how this works and start off with the commands, it&#39;s actually pretty easy.&lt;/p&gt;
&lt;p&gt;The basic (and most important) commands are &lt;code&gt;Start-Job&lt;/code&gt;, &lt;code&gt;Get-Job&lt;/code&gt; and &lt;code&gt;Stop-Job&lt;/code&gt;. A small demonstration:&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/04/backgroundjobs1.png&quot; alt=&quot;&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;As you can see, Start-Job starts a background job (surprise, surprise!) and shows us some info of the newly created job.&lt;/p&gt;
&lt;p&gt;In the small script above I created a command that would normally pause the execution of it for 30 seconds. Now, because of the use of a background process we can immediately continue our work, while the first piece of script keeps running in the background.&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/04/backgroundjobs1.png&quot; alt=&quot;&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;Get-Job gets a list of running or completed jobs in the current session, as you probably expected. Using this command we also get a lot of useful information, like state and command of the job.&lt;/p&gt;
&lt;p&gt;Using the Id we can find with the Get-Job command, we can also stop the execution a running job with &lt;code&gt;Stop-Job&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;PS&lt;/span&gt; D:&#92;ProjectsPS&gt; &lt;span class=&quot;token function&quot;&gt;Stop-Job&lt;/span&gt; 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we want to get rid of the job completely, we simply remove it:&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token function&quot;&gt;PS&lt;/span&gt; D:&#92;ProjectsPS&gt; &lt;span class=&quot;token function&quot;&gt;Remove-Job&lt;/span&gt; 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What if you want to run a command that returns data? Use &lt;code&gt;Receive-Job&lt;/code&gt;!&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$job&lt;/span&gt; = &lt;span class=&quot;token function&quot;&gt;Start-Job&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;scriptblock &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Get-Process&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;Receive-Job&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;job &lt;span class=&quot;token variable&quot;&gt;$job&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The Receive-Job command will output the data from the scriptblock used in Start-Job (in this case, a list of processes on the computer).&lt;/p&gt;
&lt;p&gt;These are pretty basic uses of background jobs, but it demonstrates how powerful this can be when creating large scripts that have to execute fast. For more information on this topic, use the PowerShell help, it&#39;s all there! Tip: Get-Help about_Jobs&lt;/p&gt;
&lt;p&gt;Do try this at home!&lt;/p&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/dd347701.aspx&quot;&gt;All available cmdlets on Technet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://bartdesmet.net/blogs/bart/archive/2008/03/25/windows-powershell-2-0-feature-focus-background-jobs.aspx&quot;&gt;Some info on background jobs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>2010-04-27T19:19:07Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/04/27/powershell-2-0-background-jobs/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/04/27/powershell-2-0-background-jobs/</guid>
      <category>powershell</category>
    </item>
    <item>
      <title>Format source code on WordPress</title>
      <description>&lt;p&gt;I had a few people asking me how I managed to format the source code for my PowerShell posts, so here&#39;s a short explanation. Just type (or paste) your post and when it&#39;s time to insert the source code, switch to HTML view.&lt;/p&gt;
&lt;p&gt;There you can insert these tags:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;sourcecode language&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;csharp&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
somecode
&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;sourcecode&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it will come out like this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;formatting&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;quot&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;Yay&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;quot&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Yes, that&#39;s all there is to it.&lt;/p&gt;
&lt;p&gt;There are actually quite a few languages that are supported. You can see the full list and an explanation on some extra parameters on this official WordPress page: &lt;a href=&quot;http://en.support.wordpress.com/code/posting-source-code/&quot;&gt;http://en.support.wordpress.com/code/posting-source-code/&lt;/a&gt;&lt;/p&gt;
</description>
      <pubDate>2010-03-04T12:23:27Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/03/04/format-source-code-on-wordpress/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/03/04/format-source-code-on-wordpress/</guid>
      <category>general</category>
    </item>
    <item>
      <title>PowerShell - Remote Service Manager</title>
      <description>&lt;p&gt;On my last project I had a few problems with a Sharepoint service on a server, we couldn&#39;t find the problem straightaway, but restarting the service always seemed to help for a while. Connecting to the server with Remote Desktop and restarting the service, however, is pretty timeconsuming for such a simple task, so I made a little PowerShell script to restart the service remotely.&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/02/powershell_rsm.png&quot; alt=&quot;A screenshot with the script in action&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;A screenshot with the script in action&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;h2&gt;Show me the script!&lt;/h2&gt;
&lt;p&gt;So, how do I start to write this script? As a PowerShell beginner I Google a bit, and stumble upon this nice &lt;a href=&quot;http://thepowershellguy.com/blogs/posh/archive/2007/01/03/powershell-using-net-to-manage-remote-services.aspx%5D&quot;&gt;post on The PowerShell Guy blog&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;[System.ServiceProcess.ServiceController]&lt;/span&gt;::GetServices&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;server&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-Object&lt;/span&gt; System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceProcess&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceController&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Service&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;server&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Start&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-Object&lt;/span&gt; System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceProcess&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceController&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Service&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;server&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;WaitForStatus&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Running&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-timespan&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;seconds 5&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alright, that&#39;s pretty easy! This gives me a good way to deal with the services, now all I have to do is write a script around it that is easy to use for everyone working on the project.&lt;/p&gt;
&lt;p&gt;Time to start thinking about the actions I&#39;m going to implement.&lt;/p&gt;
&lt;p&gt;Getting a list of all services, or a filtered list (based on the displayname of a service) is a pretty important function. I can pretty much copy the line from the blogpost mentioned above, but I will also provide the possibility to filter the list.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;[System.ServiceProcess.ServiceController]&lt;/span&gt;::GetServices&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;|&lt;/span&gt; where &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;DisplayName &lt;span class=&quot;token operator&quot;&gt;-match&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To manage the services I&#39;m going to implement start, stop and restart. Let&#39;s do this the clean way and create two functions, &lt;code&gt;startService&lt;/code&gt; and &lt;code&gt;stopService&lt;/code&gt;, I think this is pretty straightforward.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; startService&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt; = &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-Object&lt;/span&gt; System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceProcess&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceController&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Status &lt;span class=&quot;token operator&quot;&gt;-notlike&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Running&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Start&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;WaitForStatus&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;StartPending&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-timespan&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;seconds 10&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; is starting..&quot;&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;WaitForStatus&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Running&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-timespan&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;seconds 20&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; is &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Status
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Write-Host&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; is already Running.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, the server to target and the service to manage can always be different and should be provided by the user of the script. I also need a way to determine which action a user want to perform. When listing the services a filter could be useful. Including some help in the script is probably a good idea. I will use named parameters to implement all this. This should be on the first line in the script.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;param&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;[string]&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;[string]&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;[string]&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;[string]&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;[switch]&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$help&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are my parameters, this makes the script a bit universal in it&#39;s use. But this also means a user can provide a service that doesn&#39;t exist. Let&#39;s write a function to check for that.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; checkServiceExists&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;Write-Host&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Please provide service name.&#39;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;exit&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token variable&quot;&gt;$svcexists&lt;/span&gt; = 0
  &lt;span class=&quot;token variable&quot;&gt;$svcs&lt;/span&gt; = &lt;span class=&quot;token namespace&quot;&gt;[System.ServiceProcess.ServiceController]&lt;/span&gt;::GetServices&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;foreach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$svc&lt;/span&gt; in &lt;span class=&quot;token variable&quot;&gt;$svcs&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$svc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Name &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$svcexists&lt;/span&gt; = 1&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$svcexists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;Write-Host&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Service does not exist on remote machine.&#39;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;exit&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So, I&#39;m checking if the service name contains a value and, if it does, that it exists on the remote machine. Otherwise the script tells the user to edit the parameter. Great!&lt;/p&gt;
&lt;p&gt;Now I need to check which action a user wants to perform. This can simply be done using &lt;code&gt;If&lt;/code&gt; and &lt;code&gt;ElseIf&lt;/code&gt;, it could also be done with the &lt;code&gt;Switch&lt;/code&gt; statement. When a user types a command that doesn&#39;t exist, a message will clarify this.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;elseif&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;get&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token namespace&quot;&gt;[System.ServiceProcess.ServiceController]&lt;/span&gt;::GetServices&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;|&lt;/span&gt; where &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;DisplayName &lt;span class=&quot;token operator&quot;&gt;-match&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;elseif&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;start&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  startService
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;elseif&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;stop&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  stopService
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;elseif&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;restart&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  stopService
  startService
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;Write-Host&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&#39;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt;&#39; is an invalid command.&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This PowerShell stuff is actually pretty easy! Now all I need to implement is the help.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$help&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;Write-Host&lt;/span&gt; @&lt;span class=&quot;token string&quot;&gt;&quot;

RemoteServiceManager.ps1

Manage services on a remote computer.

Parameters explanation.

&quot;&lt;/span&gt;@
  &lt;span class=&quot;token keyword&quot;&gt;exit&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;The complete &#39;manage services remotely&#39; script&lt;/h2&gt;
&lt;p&gt;Alright, I now have a working script to remotely manage services, that provides some feedback when users provide wrong information. This will definately be useful in future projects too.&lt;/p&gt;
&lt;p&gt;There is still a lot of room for improvements, so feel free to play around with my script and let me know if you add something cool to it. You can download the complete script here.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: I updated the code for the file, because it&#39;s changed since first posting this, by adding the help in a standard way and some adjustments here and there.&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;###################################&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;##  RemoteServiceManager.ps1     ##&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;##   by Kevin Pelgrims           ##&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;##  kevinpelgrims.com            ##&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;##   February 23, 2010           ##&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;###################################&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Get parameters&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;param&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;[string]&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;[string]&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;[string]&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;[string]&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Load ServiceController assembly, if it is not already loaded&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;-not&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;[appdomain]&lt;/span&gt;::CurrentDomain&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;getassemblies&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;|&lt;/span&gt;? &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ManifestModule &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &amp;amp;quot&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;system&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;serviceprocess&amp;amp;quot&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;[void]&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;[System.Reflection.Assembly]&lt;/span&gt;::LoadWithPartialName&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;system.serviceprocess&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Check if a servicename is given and if the service exists&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; checkServiceExists&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token string&quot;&gt;&quot;Please provide service name.&quot;&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;exit&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token variable&quot;&gt;$svcexists&lt;/span&gt; = 0
    &lt;span class=&quot;token variable&quot;&gt;$svcs&lt;/span&gt; = &lt;span class=&quot;token namespace&quot;&gt;[System.ServiceProcess.ServiceController]&lt;/span&gt;::GetServices&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;foreach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$svc&lt;/span&gt; in &lt;span class=&quot;token variable&quot;&gt;$svcs&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$svc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Name &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$svcexists&lt;/span&gt; = 1&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$svcexists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token string&quot;&gt;&quot;Service does not exist on remote machine.&quot;&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;exit&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Start the service, if it is not already running&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; startService&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    checkServiceExists
    &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt; = &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-Object&lt;/span&gt; System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceProcess&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceController&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Status &lt;span class=&quot;token operator&quot;&gt;-notlike&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Running&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Start&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;WaitForStatus&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;StartPending&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-timespan&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;seconds 10&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; is starting..&quot;&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;WaitForStatus&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Running&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-timespan&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;seconds 20&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; is &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Status
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; is already Running.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Stop the service, if it is not already stopped&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; stopService&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    checkServiceExists
    &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt; = &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-Object&lt;/span&gt; System&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceProcess&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ServiceController&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Status &lt;span class=&quot;token operator&quot;&gt;-notlike&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Stopped&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Stop&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;WaitForStatus&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;StopPending&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-timespan&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;seconds 10&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; is stopping..&quot;&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;WaitForStatus&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Stopped&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new-timespan&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;seconds 20&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; is &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$serviceController&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Status
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$service&lt;/span&gt; is already Stopped.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Check the command parameter to determine the action to be undertaken&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;elseif&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;get&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token namespace&quot;&gt;[System.ServiceProcess.ServiceController]&lt;/span&gt;::GetServices&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;|&lt;/span&gt; where &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;DisplayName &lt;span class=&quot;token operator&quot;&gt;-match&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;elseif&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;start&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    startService
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;elseif&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;stop&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    stopService
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;elseif&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-like&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;restart&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    stopService
    startService
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;&#39;&lt;span class=&quot;token variable&quot;&gt;$command&lt;/span&gt;&#39; is an invalid command.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;#

.SYNOPSIS
RemoteServiceManager.ps1

Manage services on a remote computer.

Input:
  None.

Output:
  None.

Parameters:
  server             - Name of the remote machine on which commands should be executed
  command            - The command that should be executed
                       Available commands: get, start, stop, restart
  filter             - Filter on DisplayName for &amp;amp;quot;get&amp;amp;quot; command
  service            - Name of the service

.DESCRIPTION
Manage services on a remote computer.

.LINK

https://kevinpelgrims.com

#&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</description>
      <pubDate>2010-02-24T10:58:13Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/02/24/powershell-remote-service-manager/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/02/24/powershell-remote-service-manager/</guid>
      <category>powershell</category>
    </item>
    <item>
      <title>PowerShell 2 - What is it and what&#39;s new</title>
      <description>&lt;h2&gt;What is PowerShell?&lt;/h2&gt;
&lt;p&gt;PowerShell is an object-oriented programming language and interactive command line shell for Microsoft Windows that is built on top of the .NET framework.&lt;/p&gt;
&lt;p&gt;It was designed to automate system tasks and create systems management tools for commonly implemented processes.&lt;/p&gt;
&lt;p&gt;PowerShell offers a variety of ways to automate tasks, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cmdlets, which are very small .NET classes that appear as system commands.&lt;/li&gt;
&lt;li&gt;Scripts, which are combinations of cmdlets and associated logic.&lt;/li&gt;
&lt;li&gt;Executables, which are standalone tools.&lt;/li&gt;
&lt;li&gt;Instantiation of standard .NET classes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;PowerShell integrates with the .NET environment and can also be embedded within other applications. Over a hundred cmdlets are included that can be used separately or combined with others to automate more complex tasks. Users can also create and share cmdlets.&lt;/p&gt;
&lt;p&gt;PowerShell 2.0 is installed by default with Windows 7 and Windows Server 2008 R2. It has also been released for older platforms, i.e.Windows XP SP3, Windows Server 2003 SP2, Windows Vista SP1 and Windows Server 2008.&lt;/p&gt;
&lt;p&gt;Some good info on PowerShell in general can be found on Wikipedia: &lt;a href=&quot;http://en.wikipedia.org/wiki/Windows_PowerShell&quot;&gt;http://en.wikipedia.org/wiki/Windows_PowerShell&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;What are the cool new features of version 2.0?&lt;/h2&gt;
&lt;p&gt;PowerShell 2.0 has a lot of great improvements over version 1.0, listed here are some of the more important new features.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Remoting&lt;/strong&gt;
&lt;br /&gt;
PowerShell 2.0 lets you run commands on one or many remote computers with a single Windows PowerShell command. You can run individual commands, or you can create a persistent connection (a session) to run a series of related commands. You can also start a session with a remote computer so that the commands you type run directly on the remote computer.&lt;/p&gt;
&lt;p&gt;The remoting features of Windows PowerShell are built on Windows Remote Management (WinRM).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Windows PowerShell ISE and debugger&lt;/strong&gt;
&lt;br /&gt;
PowerShell 2.0 includes Windows PowerShell Integrate Scripting Environment (ISE), an application that lets you run commands, and design, write, test, and debug scripts in a graphical,  color-coded environment. It does not contain code completion, as opposed to &lt;a id=&quot;qfja&quot; title=&quot;PowerGUI&quot; href=&quot;http://www.powergui.org/&quot;&gt;PowerGUI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;PowerShell 2.0 also includes a debugger for scripts and functions. You can add breakpoints and display the call stack.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Background jobs&lt;/strong&gt;
&lt;br /&gt;
Background jobs are commands that run asynchronously. When you run a background job, the command prompt returns immediately, even if the command is still running. You can use the background job feature to run a complex command in the background so that you can use your session for other work while the command runs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lots and lots of new Cmdlets!&lt;/strong&gt;
&lt;br /&gt;
There are 107 new Cmdlets in PowerShell 2.0 for you to play with. Ranging from Cmdlets to take advantage of the new Remoting capabilities to Computer Management and WS-Management Cmdlets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Event notification&lt;/strong&gt;
&lt;br /&gt;
Users can register and subscribe to events, such as Windows PowerShell events, WMI events, or .NET Framework events. And users can listen, forward, and act on management and system events both synchronously and asynchronously.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Modules&lt;/strong&gt;
&lt;br /&gt;
Modules let you divide and organize your PowerShell scripts into independent, self-contained, reusable units. Code from a module executes in its own context, so it does not conflict withthe variables, functions and other resources in the session.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Transactions&lt;/strong&gt;
&lt;br /&gt;
Transactions let you undo an entire series of operations. They are available only for operations that support transactions. Transactions are designed for applications that require atomicity, consistency, isolation and recoverability, like databases and message queuing.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;And a lot more..&lt;/strong&gt;
&lt;br /&gt;
There are a whole lot more new features in version 2.0, you can find more information at the resources below.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Installing PowerShell&lt;/h2&gt;
&lt;p&gt;Installing PowerShell 2.0 is pretty straightforward, just run the installer. If you want to use the remoting feature, be sure to install PowerShell 2.0 on all machines.
&lt;br /&gt;
Here is the link: &lt;a href=&quot;http://support.microsoft.com/kb/968929&quot;&gt;http://support.microsoft.com/kb/968929&lt;/a&gt; (it&#39;s all there at the bottom of the page).&lt;/p&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;A list of resources on PowerShell 2.0:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Scripting with Windows PowerShell - &lt;a href=&quot;http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx&quot;&gt;http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Windows PowerShell Blog - &lt;a href=&quot;http://blogs.msdn.com/powershell/default.aspx&quot;&gt;http://blogs.msdn.com/powershell/default.aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Windows PowerShell Getting Started Guide - &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa973757(VS.85).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/aa973757(VS.85).aspx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;And, of course, PowerShell help commands are very useful (example: &lt;code&gt;help about_Remote&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>2010-02-17T11:17:16Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/02/17/powershell-2-what-is-it-and-whats-new/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/02/17/powershell-2-what-is-it-and-whats-new/</guid>
      <category>powershell</category>
    </item>
    <item>
      <title>Hide fields in Nintex Workflow task form</title>
      <description>&lt;p&gt;On the Sharepoint project I am currently working on I use Nintex Workflow for approval workflows. There is this one list with lots of columns, some of which are irrelevant for certain approvers. So I needed to find a way to hide certain fields from the approver in the approval form (= task form). I googled this a bit, and the solution is actually pretty simple. All you need to do is create a view on the list, called &amp;quot;Workflow Task View&amp;quot;, select the columns you want to be visible and you&#39;re done!&lt;/p&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/01/nintextaskformhidecolumn1.png&quot; alt=&quot;Create a view, hiding the columns you don&#39;t want on the approval form&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;Create a view, hiding the columns you don&#39;t want on the approval form&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;figure&gt;
              &lt;img src=&quot;/img/2010/01/nintextaskformhidecolumn2.png&quot; alt=&quot;The field is not displayed to the approval form&quot; width=&quot;510&quot;&gt;
              &lt;figcaption&gt;The field is not displayed to the approval form&lt;/figcaption&gt;
            &lt;/figure&gt;
&lt;p&gt;Yes, it&#39;s that simple :)&lt;/p&gt;
</description>
      <pubDate>2010-01-21T15:24:42Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/01/21/hide-fields-in-nintex-workflow-task-form/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/01/21/hide-fields-in-nintex-workflow-task-form/</guid>
      <category>sharepoint</category>
    </item>
    <item>
      <title>Sharepoint tips and tricks</title>
      <description>&lt;p&gt;Recently I added a webpart to a page in Sharepoint with some bad code in it. As a result I wasn&#39;t able to load the page anymore. The only thing I had to do was remove the webpart, so I found this little trick. If you add &lt;strong&gt;?Contents=1&lt;/strong&gt; to the end of the URL of the page containing the webpart it displays the Webpart Page Maintenance page. Here you can remove the bad webpart.&lt;/p&gt;
&lt;p&gt;An example of a URL: &lt;strong&gt;http://moss/default.aspx?contents=1&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;After that I decided to collect some tricks and add them here, so here is a small list of links to useful Sharepoint resources.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.heathersolomon.com/blog/articles/sp07urls.aspx&quot;&gt;http://www.heathersolomon.com/blog/articles/sp07urls.aspx&lt;/a&gt;
&lt;br /&gt;
Sharepoint 2007 &lt;strong&gt;URL Quick List&lt;/strong&gt;, containing a list of commonly used Sharepoint URLs (like the one above).&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://sharepointjavascript.wordpress.com/2009/09/20/showing-or-hiding-list-fields-based-on-membership-in-a-sharepoint-group/&quot;&gt;http://sharepointjavascript.wordpress.com/2009/09/20/showing-or-hiding-list-fields-based-on-membership-in-a-sharepoint-group/&lt;/a&gt;
&lt;br /&gt;
This one was very useful for &lt;strong&gt;hiding fields&lt;/strong&gt; in a form based on the group a user was (not) in. Uses jQuery and some other JavaScript files. Very cool.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://officetoolbox.codeplex.com/&quot;&gt;http://officetoolbox.codeplex.com/&lt;/a&gt;
&lt;br /&gt;
Form settings is a nice feature to completely &lt;strong&gt;hide certain fields&lt;/strong&gt; in forms, without writing code. Integrates with Sharepoint nicely.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://geekswithblogs.net/naijacoder/archive/2007/09/23/115552.aspx&quot;&gt;http://geekswithblogs.net/naijacoder/archive/2007/09/23/115552.aspx&lt;/a&gt;
&lt;br /&gt;
When you create &lt;strong&gt;webpartpages the navigation on the left side is gone&lt;/strong&gt;. Using Sharepoint Designer this can easily be fixed.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sharepointology.com/development/customize-the-people-search-results-part-1/&quot;&gt;http://www.sharepointology.com/development/customize-the-people-search-results-part-1/&lt;/a&gt;
&lt;br /&gt;
Very good post on &lt;strong&gt;customizing&lt;/strong&gt; the results of &lt;strong&gt;people search&lt;/strong&gt; in MOSS.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://sqlsrvintegrationsrv.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=17652&quot;&gt;http://sqlsrvintegrationsrv.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=17652&lt;/a&gt;
&lt;br /&gt;
If you have to migrate data from SQL Server to Sharepoint lists or vice versa and you can use &lt;strong&gt;Integration Services&lt;/strong&gt;, this will be very useful. It adds a Sharepoint list source and destination to the toolbox of Business Intelligence Development Studio.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://sharepointmagazine.net/technical/administration/everything-you-need-to-know-about-bdc-part-1-of-8&quot;&gt;http://sharepointmagazine.net/technical/administration/everything-you-need-to-know-about-bdc-part-1-of-8&lt;/a&gt;
&lt;br /&gt;
Everything you need to know about &lt;strong&gt;Business Data Catalog&lt;/strong&gt;. Great starting guide.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blah.winsmarts.com/2007-12-SharePoint_and_SQL_Server_Reporting_Services.aspx&quot;&gt;http://blah.winsmarts.com/2007-12-SharePoint_and_SQL_Server_Reporting_Services.aspx&lt;/a&gt;
&lt;br /&gt;
Very good starting guide on using &lt;strong&gt;Reporting Services&lt;/strong&gt; in Sharepoint.&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>2010-01-15T22:27:28Z</pubDate>
      <link>https://kevinpelgrims.com/blog/2010/01/15/sharepoint-tips-and-tricks/</link>
      <guid isPermaLink="true">https://kevinpelgrims.com/blog/2010/01/15/sharepoint-tips-and-tricks/</guid>
      <category>sharepoint</category>
    </item>
  </channel>
</rss>
