<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" version="2.0"><channel><description /><title>Mike Chaliy's Personal Site</title><generator>Tumblr (3.0; @chaliy)</generator><link>http://blog.chaliy.name/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/chaliy" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="chaliy" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://tumblr.superfeedr.com/" /><geo:lat>50.525518</geo:lat><geo:long>30.494962</geo:long><creativeCommons:license>http://creativecommons.org/licenses/by/3.0/</creativeCommons:license><item><title>Where do we keep our application configuration settings?</title><description>&lt;p&gt;In code.&lt;/p&gt;

&lt;p&gt;Precisely this is not true. We have single configuration setting. This is environment name where code will work (e.g. Local, Staging, Live). Everything else is configured in code based on environment name, machine name and sometimes on phase of the moon.&lt;/p&gt;

&lt;p&gt;What we do when some reconfiguration needed? We redeploy application. 8 minutes and we are live (my bad btw, we need to optimize this, 8 minutes is huge time, especially in some sorts of fackups).&lt;/p&gt;

&lt;p&gt;One of the huge benefits (and why I write this post now) is that you can always take your app and execute in any other host. For example right now application works in console exe to fix some data with our domain model.&lt;/p&gt;

&lt;p&gt;Жартома ми називаємо цей стиль “гопники”. Я точно не знаю як це перекласти. Мені подобається.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/SlOraOBN_d4" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/16170896178</link><guid>http://blog.chaliy.name/post/16170896178</guid><pubDate>Fri, 20 Jan 2012 16:33:50 +0200</pubDate><category>configuration</category></item><item><title>Web-related development tools I used in 2011</title><description>&lt;p&gt;Client side web is quite new for me. Last year was interesting in this area. Let me list some tools:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://twitter.github.com/bootstrap/"&gt;&lt;strong&gt;Bootstrap, from Twitter&lt;/strong&gt;&lt;/a&gt; - this is killer. You add link to precompiled CSS file in your page and it starts look just well. For &lt;a href="http://psget.net/"&gt;utility sites&lt;/a&gt; where you do not want to spend time on design this is mast have. Another related project, &lt;a href="http://addyosmani.com/blog/jquery-ui-bootstrap/"&gt;jQuery UI Bootstrap&lt;/a&gt;, adds Bootstrap look and feel to jQuery UI.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://knockoutjs.com/"&gt;&lt;strong&gt;Knockout&lt;/strong&gt;&lt;/a&gt; - magic toolkit that brings MVVM for you. As for me too much magic. But overall is very nice. Thanks to &lt;a href="http://blog.kievalt.net/post/13154772832/javascript-report"&gt;Roman Gomolko&lt;/a&gt; for introduction. Also some people suggested that &lt;a href="http://documentcloud.github.com/backbone/"&gt;Backbone.js&lt;/a&gt; is similar but with less magic, so this is something I will try this year. Another library I need to try is &lt;a href="http://msdn.microsoft.com/en-us/data/gg577610#js"&gt;RxJS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://jashkenas.github.com/coffee-script/"&gt;&lt;strong&gt;CoffeScript&lt;/strong&gt;&lt;/a&gt; - nice syntax sugar for JavaScript, write less. However I wouldn’t try if integration to Visual Studio exists. &lt;a href="http://visualstudiogallery.msdn.microsoft.com/2b96d16a-c986-4501-8f97-8008f9db141a"&gt;Mindscape Web Workbench&lt;/a&gt; - extension that provides syntax highlighting and what is more useful, compilation to JavaScript when you press Ctrl+S (it uses code generator). So technically you add foo.coffee file and then reference foo.js, very frictionless.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.jetbrains.com/dotnet/tag/javascript/"&gt;&lt;strong&gt;ReSharper JavaScript&lt;/strong&gt;&lt;/a&gt;. Few years ago I decided to go with GWT, just because maintanance large JavaScript application was nightmare. Now I am slowly change my mind and JavaScript support in ReSharper is one of the best helpers on this journey :). Unfortunately, it does not support CoffeeScript :(. Anyway, this is example how tool can change your mind about another tool.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://wcf.codeplex.com/wikipage?title=WCF%20HTTP"&gt;&lt;strong&gt;WCF Web API&lt;/strong&gt;&lt;/a&gt; - next generation of WCF that will make HTTP stuff more user friendly. It quite unstable(it’s preview version), also Glen Block is &lt;a href="http://codebetter.com/glennblock/2011/12/24/i-moved-on-from-wcf-web-api-but-web-api-is-still-moving/"&gt;not on it anymore&lt;/a&gt;, so I cannot say that everything is light. However I really like it and use it in some of &lt;a href="https://github.com/chaliy/inline_scheduler"&gt;my&lt;/a&gt; &lt;a href="https://github.com/chaliy/zaz"&gt;pet&lt;/a&gt; projects with success.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://code.google.com/p/elmah/"&gt;&lt;strong&gt;ELMAH&lt;/strong&gt;&lt;/a&gt; - have to point this tool, but I do not really like it. First of all it look like alien in ASP.NET MVC world (&lt;a href="http://www.beletsky.net/2011/03/integrating-elmah-to-aspnet-mvc-in.html"&gt;fix&lt;/a&gt;). Second it is not useful. There is no daily digest, no filter on UI, no grouping or another stuff that could help to analyze errors. This is another time I am thinking about another pet project.&lt;/p&gt;

&lt;p&gt;And of course JQuery with &lt;a href="http://www.professorcloud.com/mainsite/cloud-zoom.htm"&gt;many&lt;/a&gt; &lt;a href="http://www.asual.com/jquery/address/"&gt;small&lt;/a&gt; &lt;a href="http://dev.chayachronicles.com/jquery/cascade/index.html"&gt;JQuery&lt;/a&gt; plugins.&lt;/p&gt;

&lt;p&gt;Something like this…&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/-FJ772Ssyc0" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/15181246914</link><guid>http://blog.chaliy.name/post/15181246914</guid><pubDate>Mon, 02 Jan 2012 15:26:00 +0200</pubDate><category>javascript</category><category>css</category><category>tools</category><category>html</category></item><item><title>PsGet News #1: features, new modules, challenges</title><description>&lt;h3&gt;Some new features:&lt;/h3&gt;

&lt;ol&gt;&lt;li&gt;Install-Module now has default alias inmo, &lt;code&gt;inmo posh-git&lt;/code&gt; will do the job&lt;/li&gt;
&lt;li&gt;Install-Module now supports tab completion, try &lt;code&gt;inmo posh&lt;Tab&gt;&lt;/code&gt; , watch slow motion &lt;a href="http://www.youtube.com/watch?v=qdUZ9RtHLqI"&gt;video&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Sidenote: to update PsGet itslef, execute &lt;code&gt;install-module psget -force&lt;/code&gt;. PsGet is also on PsGet :).&lt;/p&gt;

&lt;h3&gt;Some new modules:&lt;/h3&gt;

&lt;ol&gt;&lt;li&gt;&lt;a href="http://psget.net/directory/Find-String/"&gt;Find-String&lt;/a&gt; , more details &lt;a href="http://mohundro.com/blog/2009/06/12/find-stringps1---ack-for-powershell/"&gt;from author&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://psget.net/directory/Send-Growl/"&gt;Send-Growl&lt;/a&gt;, growl is notification system, if you have it installed you can now use this module to post notifications easy&lt;/li&gt;
&lt;li&gt;&lt;a href="http://psget.net/directory/pswatch/"&gt;pswatch&lt;/a&gt;, cmdlet continuously monitors a directory tree and write to the output the path of the file that has changed.&lt;/li&gt;
&lt;/ol&gt;&lt;h3&gt;New challenges:&lt;/h3&gt;

&lt;ol&gt;&lt;li&gt;Some interesting modules are hosted on CodePlex (e.g. &lt;a href="http://powertab.codeplex.com/"&gt;PowerTab&lt;/a&gt;, &lt;a href="http://pscx.codeplex.com/"&gt;PSCX&lt;/a&gt;). Unfortunately, CodePlex does not provide direct links to download this modules. There is no clear solution for this issue except to host compiled versions of this modules directly in PsGet repository. This is something we &lt;a href="http://powertab.codeplex.com/discussions/282939"&gt;discuss now&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;TabExpansion, Prompt this stuff could conflict in some modules. For example, try install posh-git and posh-hg, you will need to fix issues manually. I added &lt;a href="https://github.com/chaliy/psget/issues/6"&gt;ticket&lt;/a&gt; to resolve this stuff.&lt;/li&gt;
&lt;/ol&gt;&lt;h3&gt;In news:&lt;/h3&gt;

&lt;ol&gt;&lt;li&gt;Haacked - &lt;a href="http://haacked.com/archive/2011/12/13/better-git-with-powershell.aspx"&gt;Better Git with PowerShell&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Scott Muc - &lt;a href="http://scottmuc.com/blog/development/adopting-psget-for-powershell-module-management/"&gt;Adopting PsGet for Powershell Module Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;José F. Romaniello - &lt;a href="http://joseoncode.com/2011/12/09/continuous-testing-scripts-with-growl/"&gt;Continuous Testing scripts with Growl&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/kKuobQA-u20" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/14401601117</link><guid>http://blog.chaliy.name/post/14401601117</guid><pubDate>Sun, 18 Dec 2011 15:43:00 +0200</pubDate><category>psget</category><category>powershell</category></item><item><title>Script to commit with message taken from JIRA ticket</title><description>&lt;p&gt;Every day we commit. In some cases we commit resolutions to JIRA tickets. In most cases commit messge is title of the ticket and may be few additional words about what actually was done. Considering this, &lt;a href="https://gist.github.com/1360362"&gt;I wrote small script&lt;/a&gt;. It connects to JIRA, takes title of the tocket, optionally appends what you will say to it and eventually commit everything to Mercurial. Usage is simple:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Commit-Project ABB-499 "Foo bar"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will commit with message from issue ABB-499 and “Foo bar” at the end. Last message is optional.&lt;/p&gt;

&lt;script src="https://gist.github.com/1360362.js"&gt; &lt;/script&gt;&lt;p&gt;This script requires &lt;a href="http://psget.net/"&gt;PsGet&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/S5qOGDn3CYY" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/12682930993</link><guid>http://blog.chaliy.name/post/12682930993</guid><pubDate>Sat, 12 Nov 2011 12:43:08 +0200</pubDate><category>JIRA</category><category>Mercurial</category><category>Script</category><category>powershell</category><category>commit</category></item><item><title>Health monitoring for our production</title><description>&lt;p&gt;Few weeks ago we have small fail, when on staging environment one of our schedulers failed to start, so part of our background tasks just didn’t started. Few months ago we have had an issue, when wrong configuration on one of the web facing boxes have invalid serialization configuration and so public API calls to load balanced farm was failing on random basis. Why I am talking about this? Well, week ago we eventually decided that we need kind of health monitoring for our environment.&lt;/p&gt;

&lt;p&gt;To the time being we already have some integration tests (NUnit) that test our public endpoints and environment stuff. The only problem that they run only after deployment builds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The idea is simple. Schedule integration tests to run every XX minutes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I think most build servers can do this without problems. I do not know why we didn’t made this ages ago.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_lujlkdhu661qzjnbq.png" alt="TeamCity scheduled builds"/&gt;&lt;/p&gt;

&lt;p&gt;Now, I am about to write some tests that will use heuristics based on usage data of our services, so we probably be able to early identify if something goes wrong. Later we will expand this to check database health, disk usage and so on.&lt;/p&gt;

&lt;p&gt;If this stuff will work for us, we will open source our library with assertions for environment.&lt;/p&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/LwST0Ad6U4Q" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/12682506375</link><guid>http://blog.chaliy.name/post/12682506375</guid><pubDate>Sat, 12 Nov 2011 12:14:56 +0200</pubDate><category>integration testing</category><category>health monitoring</category><category>tests</category><category>teamcity</category><category>nunit</category></item><item><title>How do we automatically deploy with Mercurial and TeamCity</title><description>&lt;p&gt;Few weeks ago we moved from SVN to Mercurial. This transition triggered some changes to our deployment process and we decided to play with something interesting. We decided to implement fully automatic deployment. So the idea:&lt;/p&gt;

&lt;p&gt;First of all we have three permanent branches:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_lojpw9kgPC1qzjnbq.png" alt="Example"/&gt;&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;strong&gt;default&lt;/strong&gt;, this is a Mercurial name of trunk, main development occurs here. If you need something big you make branch, and after work is complete you merge back to default.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;staging&lt;/strong&gt;, this is common place where code is ready for staging lives. In most cases code first appear in default and then get merged to staging. Sometimes if we need fast fix on staging, we do it in staging branch and then merge back to default. We also experimenting with merging code from named feature branches, this scenario works, but requires some communication.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;live&lt;/strong&gt;, similar to staging, but dedicated to live. In most cases code comes from staging.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Second is we have TeamCity configured to pull changes from this branches and if something changed automatically build. In case of  staging and live branches build also includes deployment to servers. Deployment is implemented using simple Powershell scripts and robocopy.&lt;/p&gt;

&lt;p&gt;Easy and it works. Now deployment is just simple commit to the corresponding branch.&lt;/p&gt;

&lt;p&gt;Some less important notes:&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;If after deployment, we found issue and want rollback, two options here. First is reverting changes in corresponding branch (this is easy, because each build has its own commit). Second is using nice “Run custom build” feature of the TeamCity. You just need to select previous commit and run build again.&lt;/li&gt;
&lt;li&gt;Messages of the commits to staging and live should be descriptive, as they are gone be the only information you see on build server.&lt;/li&gt;
&lt;li&gt;This is easy to write script that will automate sequence of commands to commit to staging or live branch. This is &lt;a href="https://gist.github.com/1090570"&gt;one from me&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/JNJh-Nb5wOM" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/7772955245</link><guid>http://blog.chaliy.name/post/7772955245</guid><pubDate>Mon, 18 Jul 2011 23:30:00 +0300</pubDate><category>Mercurial</category><category>TeamCity</category><category>Deployment</category></item><item><title>Execute business logic in separate application domain</title><description>&lt;p&gt;From time to time, I am trying to simplify code that I write on daily basis. One of the ideas that keeps bugging me is using more static stuff. As you may know, general rule of thumbs is to reduce static state, singletons and other static code. This is true. So everything I will write later should be considered as experimental.&lt;/p&gt;

&lt;p&gt;One of the problems with static code is shared state. For example, you have class with static field, two threads access to it… and boom! you have permanently hidden problem. Traditional mitigation to this problem is just not to use static state. But what if we try to create static “instances”? If I am right we have two options, first is to just start new process and second is to create new AppDomain right in our current execution process. So I decided to give a try to second option. Test code is bellow:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
using System;
using System.Diagnostics;

public class Program
{
    public static class Runner
    {
        public static int Test1 = 0;
        public static void CodeInChildAppDomain()
        {
            Console.WriteLine("Test {0} + {1}", 
                  AppDomain.CurrentDomain.FriendlyName, ++Test1);
        }
    }

    static void Main()
    {        
        var s = new Stopwatch();
        s.Start();

        for (var i = 0; i 
            {
                Runner.CodeInChildAppDomain();
                Runner.CodeInChildAppDomain();
            });    
        }

        s.Stop();
        Console.WriteLine("Average: {0}ms", s.Elapsed.TotalMilliseconds / 1000);       
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/1076966"&gt;gist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Runner.CodeInChildAppDomain&lt;/code&gt; will run in child domain. Static field Test1 is for demonstration. Code will run 1000 cycles and average time is about 4ms. Adding Rx assembly to the Runner increased average up to 6ms.&lt;/p&gt;

&lt;p&gt;Conclusion is simple, if 6ms is ok for each your operation you can try. Enjoy.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/nFteh7BiQh0" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/7509151369</link><guid>http://blog.chaliy.name/post/7509151369</guid><pubDate>Tue, 12 Jul 2011 01:41:00 +0300</pubDate><category>AppDomain</category><category>.NET</category><category>BusnessLogic</category><category>Domain</category></item><item><title>IEnumerable could be considered harmful...</title><description>&lt;p&gt;… well, of course only under certain circumstances, but hey, I am quite experienced developer, and today I once again wrote code that killed app in unexpected way. So the point of this post, &lt;strong&gt;do not undervalue lazy nature of the IEnumerable&lt;/strong&gt;. Or &lt;strong&gt;do not use IEnumerable as arguments in your API&lt;/strong&gt;. Both is OK.&lt;/p&gt;

&lt;p&gt;Later is explanation for idiots like me. So take a look on this code:&lt;/p&gt;

&lt;script src="https://gist.github.com/1065756.js"&gt; &lt;/script&gt;&lt;p&gt;Simple LINQ query and simple usage of the results. Problem comes when you start using results. This is very easy to write code that will re-evaluate your nice LINQ stuff again and again. And this very easy to introduce unexpected side-effect. And this quite hard to find this side-effect.&lt;/p&gt;

&lt;p&gt;In my case I have had quite large LINQ query, that among other things called method that was responsible to find some entity and if not found, create it. And query was evaluating six! times for each item. As the result six new records in database, every time I hit this code. After I figure out what is wrong, fix was an easy job. However I still really ashamed with this code.&lt;/p&gt;

&lt;p&gt;From now I think to try arrays. This is does not seem to kill API usability, and even looks more compact. That’s it. Hope you do not write such stupid code.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/iMG1yWZavbw" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/7274777462</link><guid>http://blog.chaliy.name/post/7274777462</guid><pubDate>Tue, 05 Jul 2011 23:35:54 +0300</pubDate><category>.net</category><category>IEnumerable</category><category>LINQ</category><category>Stupid issue</category><category>Code smell</category></item><item><title>PsGet got its very own central directory</title><description>&lt;p&gt;There are two good news. First of all, full install of the &lt;a href="http://psget.net"&gt;PsGet&lt;/a&gt; can now look like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(new-object Net.WebClient).DownloadString("http://bit.ly/GetPsGet") | iex
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I also thinking to replace &lt;a href="http://bit.ly/GetPsGet"&gt;http://bit.ly/GetPsGet&lt;/a&gt; with something like &lt;a href="http://g.psget.net"&gt;http://g.psget.net&lt;/a&gt;. With its own name it should look more trusted to install.&lt;/p&gt;

&lt;p&gt;Second and much more notable is actually the fact that PsGet now supports simple central directory of the modules. Of course, for now it almost empty. But I will try to fill it with some intersting modules. So what we have…&lt;/p&gt;

&lt;p&gt;To install a PowerShell environment for Git from &lt;a href="https://github.com/dahlbyk/posh-git/"&gt;https://github.com/dahlbyk/posh-git/&lt;/a&gt; execute&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;install-module posh-git
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To install psake, a build automation tool… now with less XML…&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;install-module psake
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To install poshcode utilities from poshcode.org&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;install-module poshcode
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Does it look nice? I hope so :) You can also search for modules. Wildcards are supported:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; Get-PsGetModuleInfo ps* | format-list
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Btw, right now is good time to start suggesting modules you want to see in directory.&lt;/p&gt;

&lt;p&gt;P.S. Also I am thinking about short alias for install-module (e.g. install or psget or .. )&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/4cG7jIzdzB8" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/5108528643</link><guid>http://blog.chaliy.name/post/5108528643</guid><pubDate>Sun, 01 May 2011 22:25:00 +0300</pubDate><category>powershell</category><category>psget</category></item><item><title>Download files with PowerShell</title><description>&lt;p&gt;Few days ago I made introduction to &lt;a href="https://github.com/chaliy/psurl/"&gt;PsUrl&lt;/a&gt; - small PowerShell module to GET and POST stuff to Web. One of my intents was to resolve situation when there was no build it PowerShell way to download files. I was wrong. PowerShell has everything you need.&lt;/p&gt;

&lt;h2&gt;BitsTransfer&lt;/h2&gt;

&lt;p&gt;This is warper for BITS API available in Windows. And yes this module comes bundled with PowerShell 2.0&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Import-Module BitsTransfer
Start-BitsTransfer &lt;a href="http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe"&gt;http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe&lt;/a&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will download file and save it to dotNetFx40_Full_x86_x64.exe…&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;help about_bits_cmdlets
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Happy downloading!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/9tla8hIUgo4" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/4954856439</link><guid>http://blog.chaliy.name/post/4954856439</guid><pubDate>Tue, 26 Apr 2011 15:25:48 +0300</pubDate><category>powershell</category></item><item><title>Transfer files with PowerShell Remoting</title><description>&lt;p&gt;I am in progress to setup full server remotely from PowerShell command line. Now I have IIS installed, Tasks scheduled, .NET 4.0 installed and so on. What I need next is to get some files needed to setup application. I have them on my local computer. So few options here: a) updalod to Dropbox, and download them with &lt;a href="https://github.com/chaliy/psget/"&gt;PsGet&lt;/a&gt; b) Upload them with PowerShell Remoting. First option is too easy. So i decided to go with second.&lt;/p&gt;

&lt;p&gt;Ok, so SHH can easy &lt;a href="http://en.wikipedia.org/wiki/SSH_file_transfer_protocol"&gt;transfer files&lt;/a&gt;. What about PowerShell? Well, almost nothing. There is nothing built-in. In community I found two options: &lt;a href="http://www.nivot.org/post/2009/11/02/PowerShell20IntroducingThePModemFileTransferProtocol.aspx"&gt;PModem File Transfer Protocol&lt;/a&gt;, should work, but unfortunately file with implementation is not here any more. So second option. Blog post &lt;a href="http://stillpearling.blogspot.com/2009/02/more-powershell-remoting.html"&gt;More PowerShell Remoting&lt;/a&gt; is not strictly about transferring files, but it has nice idea. You can actually use Invoke-Command with script that will have file embedded as a string. Of course, this is not bad to have this idea packaged to PowerShell module. This is how &lt;a href="https://github.com/chaliy/psremotefiles"&gt;PsRemoteFiles&lt;/a&gt; micro project started.&lt;/p&gt;

&lt;h2&gt;PsRemoteFiles&lt;/h2&gt;

&lt;p&gt;In short words, it takes file on client, encode it as base64, then generate script with encoded data included and execute it on the remote server. Easy!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;copy-remoteItem Tests.ps1 -Credential "Comp1\User01" -ComputerName "Comp1"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For now, implementation is quite naїve, for example it loads file in memory twice. This is not really big problem if you have small files, but with big one… Anyway, next plans is to chunk file transfer. Also name does not seem to express what exactly this command do. So I have some work to do :).&lt;/p&gt;

&lt;p&gt;Project home page is &lt;a href="https://github.com/chaliy/psremotefiles"&gt;https://github.com/chaliy/psremotefiles&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/9lDznQXrusw" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/4743893772</link><guid>http://blog.chaliy.name/post/4743893772</guid><pubDate>Tue, 19 Apr 2011 13:20:00 +0300</pubDate><category>powershell</category><category>psremotefiles</category><category>shh</category><category>remote file transfer</category><category>PowerShell Remoting</category></item><item><title>Introducing PsUrl and PsGet</title><description>&lt;p&gt;For about three weeks I am sick with PowerShell. Of course, I used it for few years now, but now everything is different. I am automating stuff that I never though about. And this automation requires some helpers for comfortable work. This post is all about such utilities.&lt;/p&gt;

&lt;h2&gt;PsUrl&lt;/h2&gt;

&lt;p&gt;This story started from simple task, I needed download stuff and I have list of URLs. So the idea is &lt;code&gt;Get-Content Urls.txt | ...&lt;/code&gt;. The problem with &lt;code&gt;...&lt;/code&gt;, there is more or less nothing to download stuff from the web in PS. Of course we can use &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.webclient.downloadstring.aspx"&gt;WebClient&lt;/a&gt; from .NET.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(New-Object Net.WebClient).DownloadString($Url)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Well, this works, but not really super native, for example you cannot pipe URL directly from Get-Content. So I decided to implement simple wrapper and package it as a module. This is how &lt;a href="https://github.com/chaliy/psurl/"&gt;PsUrl&lt;/a&gt; micro project started. After installing PsUrl.psm1 module, you will get few commands. Most interesting is Get-Url.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Get-Url &lt;a href="http://example.com"&gt;http://example.com&lt;/a&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will basically download stuff from  example.com and return it as a string. Of course you can pipe in and pipe out.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Get-Content Urls.txt | Get-Url $_
Get-Url &lt;a href="http://example.com"&gt;http://example.com&lt;/a&gt; | Set-Content example.html
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Easy. The most visible problem here, is that you need install it. This is not super tricky, but rather annoying. This is how &lt;a href="https://github.com/chaliy/psget/"&gt;PsGet&lt;/a&gt; micro project started.&lt;/p&gt;

&lt;h2&gt;PsGet&lt;/h2&gt;

&lt;p&gt;Inspired by &lt;a href="http://nuget.org/"&gt;NuGet&lt;/a&gt;, I started to think how to simplify module installation in PS. I found &lt;a href="http://poshcode.org/1875"&gt;Install-Module&lt;/a&gt; script by Joel Bennett. It takes any single file module and install it to user modules or for global use. Do you see what I see? If you combine it with download stuff I already have, installation of the modules can became simple as&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Import-Module PsGet
Install-Module &lt;a href="https://github.com/chaliy/psurl/raw/master/PsUrl/PsUrl.psm1"&gt;https://github.com/chaliy/psurl/raw/master/PsUrl/PsUrl.psm1&lt;/a&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Nice? Last command actually installs previous PsUrl module. I have huge plans (and hopes) about this project. Right now it supports installing multi file modules, zipped packages from web or local file. Will support NuGet, possible registry of modules.&lt;/p&gt;

&lt;p&gt;And btw, it has single line installer.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(new-object System.Net.WebClient).DownloadString("https://github.com/chaliy/psget/raw/master/GetPsGet.ps1") | invoke-expression
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Downloads and installs PsGet  for your user account.&lt;/p&gt;

&lt;p&gt;That is all for now, in few days I will describe how remotely install and fully configure web server without RDP. Enjoy!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/chaliy/~4/GLOkXiffszI" height="1" width="1"/&gt;</description><link>http://blog.chaliy.name/post/4684130282</link><guid>http://blog.chaliy.name/post/4684130282</guid><pubDate>Sun, 17 Apr 2011 11:41:00 +0300</pubDate><category>powershell</category><category>psget</category><category>psurl</category></item></channel></rss>

