Over the past couple of years since I last added a new post to this blog I’ve been halfheartedly working on converting from WordPress to one of the modern static generators but luckily a recent involuntary, but somewhat welcome, change in employment has freed me up to finally (hopefully) make some progress on that front. With any luck I’ll have the site updated to new hosting and back-end by the end of the year. I’ll be trying to document that process at least in the code repos, and possibly with a few posts here as well.
Update: It looks like I’ll be able to do one of the important settings in Terraform finally very soon.
No tag for this post.
启点加速器电脑版下载-快连加速器app
One of the lesser known features of PowerShell are some “magic” methods that get added to most (all?) collection objects that replace the slower Where-Object and ForEach-Object cmdlets with basically the same functionality. They’re considered magic because they aren’t well documented even years after they were introduced. (Thank goodness for bloggers) I’ve used ForEach quite a bit, but often forget about it’s Where counterpart and apparently had never actually done much with it until today when I ran into a weird issue where I couldn’t set the value of a property on a returned object.
The setup is a pretty classic needle-in-a-haystack problem where you have an array of objects and need to update a property on just one of them. Pretty classically you’d do something like this.
PS>$testElement.attr="Good old standby works great"
PS>$testXml.someElements.element
id attr
------
foo 免费的节点加速old standby works great
bar someothervalue
PS>
It works great but if you’ve got a really big array of complex objects it can start to take a long time to process. So today I had remembered the aforementioned magic methods and figured it would be a lot faster to use Where to do essentially the same thing. Except I got a really unexpected error.
Maybe it was returning a single element array? Running “$testElement -is [array]” said “False” but “$testElement[0].attr = ‘something'” worked just fine, so what was going on here? Time for some more “magic” in the form of the pstypenames property.
Of course while I was tinkering with all of that and doing some research on the Where and ForEach methods I ran across that article I linked further up and figured out the correct solution to the problem.
(This is mostly so I can find it again someday when I need it again.)
When working with REST interfaces with PowerShell it’s pretty common to get JSON responses that have information that is returned as arrays of PSCustomObjects. If you need to update a property of one of those objects you can’t just do something simple like:
In order to set the value of a property you’re going to have to find the index of that particular object in the array and then manipulate it directly. Thankfully this is easier than it sounds because we have access to the static methods of the .Net Array object, and FindIndex in particular. The previous example actually ends up being something like this:
Something that you find when writing PowerShell modules to wrap API functions for external systems is that a lot of your functions tend to have a consistent subset of parameters that get used for things like credentials and specifying an endpoint. For example in the private TeamCity module that I maintain the parameter block for every function that interacts with a server has:
1
2
3
4
5
6
[Parameter(天行破解版无限免费=$false)]
[免费的节点加速.Management.Automation.PSCredential]$Credential=(Get-Credential-Message"Please enter your credentials for the TeamCity server at $server"),
[天行破解版无限免费(Mandatory=$天行破解版无限免费)]
[ValidateNotNull()]
[string]$Server
(Whether that is the best pattern I’m still not sure, but it’s beside the point of what I’m talking about here. If you have better ideas I’d love to hear about them!)
If you are writing good unit tests for your functions you need to test those parameters in every single one of those functions and ideally you want to test those parameters consistently to make sure that FunctionA doesn’t use them slightly differently than FunctionB. Additionally if I find a better way of testing those parameters I don’t want to have to update dozens (or more!) of Describe blocks. There had to be a way of writing those tests once and then calling those tests consistently when testing every one of those functions and it turns out to be pretty simple.
The trick is to consider that Pester is pretty consistent about scope inside the Describe and Context blocks so if we were to dot-source some external file in the correct context we should be able to inherit anything that’s in that file. Declaring variables with consistent test values and wrapping tests inside of a function definition means that we can do the dot-source in the scope of a Describe block and then reference those variables and call those sets of tests in every function’s tests.
For example, let’s start with a file called “StandardTests.ps1” that defines two variables and a function to test those two variables:
1
2
3
4
5
6
7
8
9
10
11
12
#Set some standard vars
$someVar1="this"
$someVar2="that"
FunctionInvoke-StandardTests{
It"Tests the first standard variable"{
$极光vpm破解无限版|Should Not美国节点加速器免费
}
It"Tests the second standard variable"{
$极光vpm破解无限版|Should NotBe$someVar1
}
}
Then making uses of those variables and tests might look something like this:
1
2
3
4
5
6
7
8
9
10
11
12
Describe"Some Tests"{
蚂蚁vp(永久免费)#import the standardized stuff
.$PSScriptRoot\StandardTests.ps1
It"Check the inherited value of the variables"{
$someVar1|Should Be"this"
$天行破解版无限免费|Should Be"that"
}
#Run the standardized tests
Invoke-蓝·灯破解版
}
The only thing left is to run the tests!
Tags: parameters, Pester, PowerShell, PowerShell Modules, tests, Unit Testing, unit tests
启点加速器电脑版下载-快连加速器app
As previously mentioned I’ve been doing a lot of work with PowerShell modules at work where I have recently gotten all the parts for a full continuous delivery pipeline working for those modules. A big section of that pipeline runs through TeamCity and while the existing ability to have Pester test results show up in the build results is really great, code coverage is slightly less obvious but in the end fairly simple.
The trick is to use the -PassThru parameter with Invoke-Pester and then use TeamCity’s build reporting interaction to get the values into the system. The end result will look a lot like this:
I’ve been spending a lot of time at work writing PowerShell modules and as part of that effort we’ve been trying to make sure we’re doing at least some unit testing on those module functions (Using 蓝·灯破解版 of course!). Unfortunately we’ve had a few instances where a new function gets added to a module without any unit tests being added. We’ve structured our modules so that every function has it’s own source file and accompanying tests file and all of them are located in a \Functions\ folder in the project. Ideally the CodeCoverage parameter for Invoke-Pester would catch this sort of problem but it only runs tests for files with a certain file name structure and so if it runs across Some-Function.ps1 without an accompanying Some-Function.Tests.ps1 it doesn’t care. Today I finally got a little tired of finding broken functions and decided to do something about it, the result is Coverage.Tests.ps1:
I’ve been trying to remember to post my impressions of sodas that I try to Twitter through the year and figured I’d put together a Year In Review to collect all of the notes for posterity.
This year’s high points: Phancy Sparkling Limeade and Empire Spruce Beer.
Decent root beer with a distinct ginger beer flavor. Neither one nor the other, for better or worse. http://t.co/9XoOYjGgKv
— Nathan Stohlmann (@Cavorter) February 26, 2014
Still not sure what to think. Strawberry highly overpowered the lychee. Probably not trying that flavor again. 日本节点免费加速器
— Nathan Stohlmann (@Cavorter) March 3, 2014
Phancy Soda Chanh Vietnamese Sparkling Limeade. excellent lime with balanced sweetness. Recommended. http://t.co/BeRVfZLpke
— Nathan Stohlmann (@Cavorter) March 4, 2014
Red Ribbon Soda Works Pennsylvania Punch. Nearly a grape soda, just missing the bubbles. Ok I suppose. http://t.co/iCF2zIwvjE
Dire news! The local distributor of Bundaberg soda is out of ginger beer to November!
— Nathan Stohlmann (@Cavorter) August 9, 2014
You all know I'm all for good soda but when my little neighborhood market starts to carry them the market has peaked. pic.twitter.com/BnytY9bAbd
— Nathan Stohlmann (@Cavorter) September 20, 2014
Empire Spruce Beer. Yes, like the conifer. Think sweetened Retsina. Refreshing and different. Highly recommended. pic.twitter.com/YgTQlrj3eK
— Nathan Stohlmann (@Cavorter) September 23, 2014
Found this when I arrived at work this morning. Somebody is getting cut off from my stash and I know who they are. pic.twitter.com/vgZpWinWnI
— Nathan Stohlmann (@Cavorter) September 23, 2014
Excellent dinner with 蓝·灯破解版 and then a game of Legendary makes for a great evening. Also trying Frostop's Birch Beer, which is good.
— Nathan Stohlmann (@Cavorter) September 26, 2014
Perhaps I should mention that Birch Beer is nothing at all like Spruce Beer.
— Nathan Stohlmann (@Cavorter) September 26, 2014
So I saw that the Christmas soda was out at WorldMarket already today.
— Nathan Stohlmann (@Cavorter) October 19, 2014
Candy Cane (Orca): SWEET. Decent mint but slightly muddied by some other flavor, not totally in a bad way. Ok. pic.twitter.com/7FA2UxaNMc
— Nathan Stohlmann (@Cavorter) October 19, 2014
Sugar Cookie(Orca): SWEET. Not worst cream soda I've had but close. Bad vanilla with fake butter flavor. Stay away. pic.twitter.com/V7uY2mpcw6
— Nathan Stohlmann (@Cavorter) October 19, 2014
Jones PB&J: Strong grapey flavor with mild "nutty" tones. Same low rent Jones sugar. Interesting. Worth trying. pic.twitter.com/YdPZe3jMEN
— Nathan Stohlmann (@Cavorter) October 21, 2014
Uludag Frutti Extra Lime Mineral Water. A soda in all but name. Quite sweet. Missing some lime bitterness. Drinkable. 免费全球节点加速器
— Nathan Stohlmann (@Cavorter) December 10, 2014
Avery's Bug Barf: Very sweet, but not syrupy. Good kiwi and pineapple flavors. Finishes nicely. An ideal sugar bomb. pic.twitter.com/AOPP3BlphL
— Nathan Stohlmann (@Cavorter) 蚂蚁vp(永久免费)
Avery's Toxic Slime: Tastes very blue. Orange flavor subtle to absent. Less sweet than expected but still intense. Ok pic.twitter.com/N2BdLQ4wYa
— Nathan Stohlmann (@Cavorter) December 15, 2014
Astro Pop Passion Fruit: Very green. I suppose it tastes somewhat like passion fruit, but mostly a sugar bomb. Pass. pic.twitter.com/MMUaVl0wsj
— Nathan Stohlmann (@Cavorter) December 19, 2014
Spring Grove Lemon Sour: In my top 5 sodas. Sweet and sour and lemony good. Highly recommended. pic.twitter.com/9P8kLxpTTH
— Nathan Stohlmann (@Cavorter) January 1, 2015
Whistler Fruit Punch: Very sweet. Good flavor though the finish could be improved. Nostalgic. Ok. pic.twitter.com/x2c5CLsjFm
— Nathan Stohlmann (@Cavorter) 免费的节点加速
Flying Cauldron Butterscotch Beer: Sugar bomb. Good finish. Very rich. Likely not for everyone. Ok. pic.twitter.com/3GpA2oWl5a
— Nathan Stohlmann (@Cavorter) January 1, 2015
Apple-Beer: Medium sweet. Subtle apple with a nice tang. Long finish is stronger than I would like. Pretty good. pic.twitter.com/VvrHbpaDPa
— Nathan Stohlmann (@Cavorter) January 1, 2015
Tags: 2014, 蓝·灯破解版, Year In Review
启点加速器电脑版下载-快连加速器app
I mentioned back in March that I had started working on a wiki to provide further information about our Micropolis modules and I am fairly proud to say that we’re definitely making progress on filling the site with content. It’s not complete yet, by any stretch of the imagination, but it’s got a good base of content and the visual style is starting to come together as well.
If you haven’t had a chance to look at it, or you haven’t looked since last March, now is a great time to go take a peek at http://www.virtualmicropolis.com and you can get updates by subscribing to any of the RSS feeds on the site or by following the Mayor’s twitter feed @vmicropolis!
We have also been invited back to the Saint Anthony Park Library to display our layout as part of their post-renovation grand re-opening party! If you missed the display in March this is a great time to come out and have a look at our layout with some additional modules by Thomas Anderson. Plus Peter Hoh is returning with his educational models, the travelling DK Books display for their Star Wars LEGO books we be on hand, at least one stormtrooper from the local 501st, and refreshments provided by the little grocery store up the street! Mark your calendars for Wednesday August 14, 2013 from 6-8pm and be sure to tell anyone else who likes LEGO.
When water boils remove lid and remove pot from burner
Let eggs cool slightly, then chill in refrigerator
You wouldn’t think that I would need to write that down in a place that, in theory, I will never forget it but every year around this time I ask Jennifer or Sigrid something along the lines of, “How do you boil eggs again?”. Clearly even though I have been coloring eggs with the kids for the past five or six years, hard boiling eggs once a year is not enough for it to be retained in my long term memory. So this time I am writing it down so that next year I don’t have to ask them for it yet again. I hope that I’m not betraying part of the tradition by doing so…
The observant among you may be thinking something along the lines of, “I didn’t think he was a Christrian…” and in fact I am not. At least I have not been for approximately the past nearly twenty years. My faith in that particular range of beliefs was already starting to fall apart during high school despite my family and community’s sincere and steadfast efforts to the contrary and getting out into the world on my own took care of the rest of it pretty quickly. As with many people who were newly “Not a Christian” I did go through a phase of pretty explicitly and strongly rejecting anything and everything associated with it and I still feel that way vaguely about things like Christmas (though for quite awhile really due more to the orgiastic consumer culture aspects of it than anything else) but a year or two after Jennifer and I got together I suggested that I might like to color eggs with the kids once they were old enough to have just enough attention span and manual dexterity to make it not also involve repainting the dining room.
Every year since then I have looked forward to coloring eggs some spring-ish Saturday afternoon before a holiday that I otherwise don’t really participate in.
Partly I enjoy spending the time with the kids. Partly I just enjoy the challenge and entertainment of coloring my own eggs (I get to do half to one-third of the dozen). In large part though I do it because I have fond memories of spring-ish Saturday afternoons in my childhood with the rest of the family around the house for once before one of the busiest days, for my family at least, of the year. My dad had planted his Good Friday potatoes and was taking most of the day off in a set of weeks that he otherwise had none. My mom was worrying over getting the house cleaned and everyone’s clothes ready and the food cooked and keeping us kids from maiming each other and keeping whatever other plates spinning that I, as an adult about the same age as she was at the time, only now begin to comprehend.
But really the rush and press of spring and summer is nearly upon us and it’s nice to just sit and color some eggs.
No tag for this post.
Introducing Virtual Micropolis
After a few years of owning the domain name, I am finally getting off my proverbial butt and doing something with VirtualMicropolis.com. My original idea had been, as is somewhat usual for me, a bit grandiose. I was going to get the spec moved over there and make it a community for everyone who built Micropolis to come and post their stuff. Because there aren’t any other places on the Internet to build a community (like Flickr, MOCPages, Facebook, Google+, ad infinitum…), or something.
Anyway, the point really came home last weekend in Des Moines where we were displaying our little corner of Micropolis again and we also had the TwinLUG QR Code out on the table next to it. As usual we got several people who tried to use it, and mostly it worked (The lighting was a bit weird), but the overwhelming response to being sent to the TwinLUG site was one of disappointment. What people really wanted to see was lots of pictures and maybe some more stuff about what they were looking at right then. Obviously it was finally time to do something about it.
To get this really rolling though I was going to need to scale things back to just a place where we could put up information and pictures about just the modules that Jennifer and I own. Almost all of them are ones that we designed with the exceptions of some that I bought off a TwinLUG member before he moved out of the country a few years ago (Hi Gary!). Thanks to the wonderful photography skills of Alyska Bailey-Peterson we had a base of some excellent photos to go along with the drek that I manage to shoot so that we could at least get the site off the ground before having to figure out where we were going to get more good pictures.
For this project I think we really needed a Wiki. A blog or other groupware CMS system was just going to have too much overhead and complexity for the basic requirements of setting up easily linkable pages that could be simply protected from spam or other ne’er-do-wells with some file management capabilities. I finally settled on 节点加速器免费 and I’m pretty happy with the results so far. My one small issue is that for some reason there are no simple methods of setting text alignment, but everything else is great so I’m ignoring that as much as possible. If you’re looking for a good Wiki platform you should definitely add them to your list of candidates.
While right now the site is all about our collection and the layouts that we have been part of but I think we would be glad to broaden the content in the not too distant future. I do have things locked down so that even if you register for an account you can not make any edits until I tweak the account so please contact me if that is your intent.
Tags: 免费全球节点加速器, dokuwiki, LEGO, 蓝·灯破解版, moc, 节点加速免费使用, wiki
August 2024
S
M
T
W
T
F
S
« Dec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Hybrid Rescue Tank
brewing
Golf
Pester
legos
免费全球节点加速器
social
dinner
lunch
menu
TDi
Food
recipe
Netflix
PowerShell
Zune
Ginger Beer
comic
蚂蚁vp(永久免费)
projects
Music
LEGO
micropolis
brew
日本节点免费加速器
Root Beer
free
Exo-Force
friends
Soda
dining
community
movie
TV
日本节点免费加速器
quiz
pop
hobby
design
game
msi
meme
蓝·灯破解版
Technic
Video