Skip navigation

Category Archives: General Discussion

Everything that goes on here.

I haven’t written a scripting post in a while, but I’ve wanted to.  So in keeping with the spirit of my stick to the script posts lets look at something that is common among all scripting languages (even if the syntax isn’t).

Let’s talk about strings…….

 kitty-yarn

Awwww, but no.  These kind of strings.  In the case of scripting, I think the best way to think about it is, text, what you are reading or able to read.  They aren’t used mathematically (usually), but can and will be a huge component in your scripting.  Especially when automating things around a desktop or server environment.

Oh really?  Yes, really.  General uses for strings in a script are:

  • User messages
  • Reporting or logging
  • Comparisons
  • Explicit paths
  • Application execution
  • Conditionals

Ok, so maybe that list doesn’t look that impressive, but when you consider how much of that is done within a script, it becomes obvious the importance of string values to scripting.  It’s also important to recognize that in certain scripting environments, it’s important to define a string value as such so that it can be properly used. 

(Powershell for instance, requires you to properly define a value type to use the relevant functions… but I’m getting ahead of myself.)

So wait?  There are more than strings in a script?  Yes; Strings, Integers, and Booleans are your standard value types. Integers are numbers (math!) and Booleans are True or False.  So given those value types, perhaps it is a bit more obvious how frequently you will use string values?

So lets get into some sample code and evaluate strings some shall we?


VBScript:

strTest = "Hey, I'm a string value"

wscript.echo strTest
'Shows the string value
wscript.echo strTest&", and I've been concatenated to the value."
'& operator joins values
wscript.echo lcase(strTest)
'Lower case
wscript.echo ucase(strTest)
'Upper case
wscript.echo strReverse(strTest)
'Reverses the string
wscript.echo len(strTest)
'Gives the total length of a string
wscript.echo mid(strTest,10,8)
'Returns fix number of characters in string
wscript.echo left(strTest,11)
'11 chars from the left
wscript.echo right(strTest,13)
'13 chars from the right
'----------------------------------------------------------------
wscript.echo inStr(strTest,"a")
'Returns position of string from left to right
wscript.echo inStrRev(strTest,"a")
'Returns position of string from right to left
'----------------------------------------------------------------
a = split(strTest)
'Splits strTest by it's spaces
for each item in a
    wscript.echo item
   'echoes each dimension from the split array
next

wscript.echo a(3)&" "&a(4)

'echoes the split arrays dimensions 3 and 4
'---------------------------------------------------------------

strReturn=inputbox("Here, you try!")

if strReturn = "" then
   wscript.echo "Fine, don't play along"
else
    wscript.echo "So you said: "&trim(ucase(strReturn))&vbcrlf _
    &"Sheesh, no need to shout!"
end if
'---------------------------------------------------------------


Running the above script will give you a better understanding of what I’m about to explain.  I wanted to show some common functions in vbscript (syntax is different but these will be universal functions you will use).  The above are common string manipulation tools

 

Code explained… line by line

First we are defining our string to a variable strTest.  Now “in the wild” as it were, this string could be pulled from an object property, read from a file, registry, user input, output from another application, etc.  It’s best to define a string to a variable though, no matter the method for input.  This of course is the most direct way to do it for our example

Now we begin with the simplest string usage, output.

Now we raise the stakes a bit by joining an additional string value to our current strTest.  This action is known as concatenation.  This is a very common thing with string usage and manipulation.  Building complex values/messages/logs from various predefined and/or dynamically pulled string values.

Our next two examples have to do with manipulating case between upper and lower.  This is fairly self explanatory, and in the interest of string comparisons it’s usually a good practice (and often necessary) to force a case set, especially if the comparison function is case sensitive.

String reversal, this may not seem important initially, but makes a huge difference when you are forced to chop strings up.  The ability to reverse a string can go a long way for string chopping.  Especially if you are dealing with filenames.

The length function is another that may seem arbitrary to some, but allows for great flexibility as well in chopping up strings such as file names.  If you have a fixed number of characters to remove it’s sometimes simpler then splitting the string.  (so I wasn’t completely honest about the math stuff and strings)

Mid, Left, and Right.  These 3 can be used in conjunction with length to return a fixed number of characters from the left right, or middle (specified) of a string.  Here’s a quick easy example:

test="I am 18 chars long"
wscript.echo test
count=len(test)-4
wscript.echo right(test,count)

Very simply, we take the total length of Test and subtract it by 4, then return the sum of remaining characters from right to left of the original string.  In this example we, had a fixed value to subtract, be mindful you could use the length value of multiple strings to achieve the same type of results.

Now, InStr and InStrRev, or “In String” and “In String Reverse”.  These two functions make for great conditionals.  They, along with strComp, are excellent for determining like strings and taking action.  Especially when parsing through files and directories looking for specific returns. 

One of my favorites, especially in PowerShell, split.  Split takes a string, looks for a delimiter (space by default) and breaks the string up into an array.  Why do I like it so much?  Put simply, it allows you to quickly whittle down long path names into a single filename.  It also allows you to quickly and efficiently modify lists of data into manageable formats.  And last but not least, it can easily turn files like csv’s into an array for manipulation.

Finally, user input.  This is pretty self explanatory.  Prompt for input, receive and control input, use input.


In PowerShell, string functions are called like this:

$a=”This is a string value”

$a.ToString()

$a.ToUpper()

$a.ToLower()

$a.Replace(“a “,”my “)

$a.split(“ “)

$a.contains(“string”)

$a.StartsWith(“t”)

$a.EndsWith(“e”)

$a.Length

$a.CompareTo(“this is a string value”)

$a.Length.Equals(22)

$a.CharArray()

$a.PadLeft(“30”)

$a.PadRight(“30”)

$a.Trim()

$a.TrimEnd()

$a.TrimStart()

Given the previous examples in vbscript, you should be able to easily adapt your knowledge to using these in PowerShell.  The idea and purpose is still the same, again, the syntax is just different.


String manipulation inside Bash is, admitedly, a bit more convoluted so I won’t be touching on it in this post.  However I’d highly recommend an online source like: Mendel Cooper’s guide.  Again, the methodology will still be fairly the same, but the syntax will differ.  The largest issue with Bash is the myriad of ways of performing the string manipulation.

 

Anyway, I hope this has been informative for you.  Good luck, and happy scripting!

So over this holiday weekend I beat infamous 2 as hero, with full blast shards, and dead drops.  Outside of the hard difficulty setting and the infamous trophies I’m well on my way to earning the platinum one in this game.

I really enjoyed the first Infamous, so I’m kind of kicking myself that I waited as long as I did to grab this one, but I digress.  I wanted to take a minute or two to sum up my impressions of the story continuation, gameplay, and overall aesthetics.  So let’s dive in.

infamous2bx

 

The story does a pretty decent job of picking up right where the first one left off.  Cole is aware of the risk and is working a former NSA agent named Kuo to increase his powers through the help of Dr Wolfe in New Marias (think New Orleans).  As we are loading into the boat, who else should appear, but “The Beast”.

I was pleased that they would throw together a large set piece like this to open with and really kind of prepare you for the game.  It was also a good, narrative, piece to resetting your character a bit.  I mean Mario’s princess has to be in another castle, and no hero can STAY an end game powerhouse at the start of their sequel right?  So a minor tick back after a massive, yet futile, battle with the beast and a short boat ride later we are in New Marias searching for Dr Wolfe who is under siege by an anti-conduit militia.  Long story short, the lab explodes, blast shards you need to power up are spread everywhere and it’s time to start working on earning respect through love or fear begins anew. 

So instead of continuing to explain and spoil the entire story I’ll briefly touch on some things I really enjoyed about this that’s new, or part of what I enjoyed from the storytelling in the first game.

  • Dead drops are still present, I’m a storyline nerd, so these little insights into back story and character development leave me foaming at the mouth. (29 total)
  • The story twists and turns, although no startling revelations like that from the first infamous, still some interesting shifts in the story dynamic.  Game Informer accused the story of being convoluted and losing sight of the primary focus, I could see where they would get that impression, somewhere in the middle of the game the beast becomes less a concern, but still serves as the major tie in towards the end.
  • 2 new conduit partners to kick it with, good and evil as would be expected, but even that serves as a surprising plot twist for you towards the end of game.  I’ve learned not to expect a game developer, aptly titled, Sucker Punch to give me a straight shot. 🙂
  • Multiple factions, not that you can CHOOSE between the factions, but at the start of the game I was a bit afraid the militia would be my only enemy choice.  It didn’t take them long either to start introducing the additional baddies either.

Infamous-2-Review-Artwork

 

Now lets discuss the gameplay.  If Cole was a beast in Infamous, well in Infamous 2 he’s a titan.  The introduction of so many varied skills, ionic abilities, and mobility options; you’re never really left to one option.  The combat (especially later in the game) manages to stay fresh, and for me, something you look forward to.  I didn’t like riding trolley lines as much as the train, or the inability to drain while grinding, but these are minor concerns.  They did add vertical rails to grind, and that’s a change I’ll take gladly.  I’m also looking forward to seeing what and how they are going to branch the skill sets for the evil faction on my second play through (I saved evil for my second option since I was going to play on hard, AoE and reckless abandon make that far easier to do). 

The exploration vertical as well as horizontal is still in tact, and towards the end of the game especially becomes increasingly more fun to see how fast you can zip around New Marias.  I’ll never get tired of the insane speed from grinding and flying around the city.  Which was good, because you will be doing a lot of that.  It’s an open world game, so exploration is just as important to the full experience as completing the missions.

The User Generated Content is a nice addition for fun that they added, and as would be expected, ranges from really impressive to “how do I abort this mission?”  The creator is simple enough to use, and well, the rest depends on how creative you are feeling.

infamous2behemoth

Now, the aesthetics.  I’ll say this first, I did miss the vertical nature of empire city.  I even missed the junk yard type environment, initially.  However what I found offered by New Marias was more style, and character, with considerably greater environmental hazards.  These also work towards the gameplay challenge and in some cases combat creativity (flood town, water, lightning, bad guys).

They did a great job of taking a dreary environment and splashing it with color to keep it appealing, as well as to incorporate huge set pieces and a larger more destructible environment to create a greater sense of power. 

Yes, and the obvious, Cole looks different, and he sounds different.  5 minutes into the game and I had forgotten what the original Cole looked or sounded like. 

Speaking of sound, between the music, sound effects, and ambient sound in the game it’s as much a game to hear as to see and that also goes a long way with me. 


In the end, if you own a PS3, there is no excuse not to have this game in your library.  The added UGC, and enticement for secondary play through really helps add to the value of the investment.

image

Yup…

First I want to define a few things up front before I begin.

 


Grace: Mercy, forgiveness, freely extended to individuals who deserve only wrath.

Belief/Faith: Treasuring Christ above everything, and living in a manner that reflects outwardly the inward Joy of that profession.

Weight: Value or cost of something. Not necessarily a burden, although the cost or value to one might seem burdensome given it’s elevated cost to the one who assumes that weight. (it will make more sense as you read)


 

Recently (this past Sunday) I began a discussion with a friend of mine from church regarding God’s Love vs. His Justice.  I want to outline this briefly to provide a basis for further development.  We know that God’s Justice is perfect, and that our trespasses against an infinitely worthy/innocent/glorious God carries the penalty of death and eternal separation from God.  We also know that by Christ’s substitutionary sacrifice at Calvary we, upon accepting and having faith in him, have his righteousness imputed to us.  This is a legal action, nullifying our transgressions before God and allowing us to be in his presence in fellowship forever.  The question this raises is, why? 

Why would God in his perfect justice offers us, horrible sinners (yes all of us), a free pass?  This we define as Grace, and is fueled by one of God’s other characteristics, his Love.  Stick with me, this isn’t a Rob Bell moment.  We know that Hell is real and not all will receive this pardon or Justification.  So it’s safe to assume at this point, that there is a weight to Grace.  Freely extended, but not freely applied?  Yes, I believe that. 

It all sounds so simple, say a prayer, make a profession, and I’m safe.  True believers know this isn’t the case.  Like the man who finds the treasure in the field and gives away everything so that he can have that treasure.  Did he get more than he gave?  Did he make these sacrifices in sadness?  No, he assuredly received more than he gave, and did so gladly and without regret.  The faith runs deep, is transformational, and works in an equivalent manner.  No, our faith is not works based.  Yes, our works are faith based, and faith is the price of our salvation and reception of this imputed righteousness.

So lets evaluate Faith, and I will keep it very simple here.  Faith as I stated above with belief is placing Christ above everything, including yourself.  The truth is, this manner of living is not unlike living in servitude.  You seek to please your master, with love, through service in accordance to His Will.  You also, were bought and paid for, with his blood which he in turn paid lovingly for you.  Now to a non-believer this cost seems amazingly high.  Both the fact that Christ had to die, and the idea that servitude is the path to freedom.  The truth of the matter is, you are already in slavery before becoming a servant.  If you weren’t, no cost would have been paid for you.  We were all slaves to sin.  That sin drove us to place ourselves above that which deserves Glory (God) and heaps it upon ourselves.  I liken this to slavery, because in this scenario, we are not truly accounted for.  We are another slave, fighting for our own portion, which is maggoty bread compared to what rests on the masters table.  Yet as a servant, we are at the table with our master.  In servitude one is looked after, their best interests met in order for them to greater serve.  It’s a bond of love, and fellowship, sealed in service.  It is symbiotic in a sense, and provides what Sin so readily destroys, harmony or shalom/peace.  (do not read that God NEEDS us so much as he WANTS us)

So what is the weight of Grace?  That isn’t so easily defined, but one could surmise, the weight of Grace is:

The most heinous act in history; which merits the most glorious freedom for the believer.  That price was paid at Calvary, and the price for the believer is: Love, faith, and service for the one who died, and glory for the One who sent Him. 

As John Piper said in a sermon once, (an excellent sermon if you have an hour to listen) and it rings true here.

“We get the savior, He get’s the glory.  We get the great Joy, He get’s the honor.  Is that ok?  Good knight that’s ok!  It can’t be any other way if there is a God and a sinner like me.”

 


 

Parting thought on being a servant…

Lets take a moment to address something else for those who find the idea of being a servant repulsive or indignant. 

In our western culture the idea of “servitude” seems like something that devalues an individual.  We as believers are called into adoption, as heirs, to the throne.  We are not equal, but, part of the family.  How often do you cringe at the thought or service to your parents?  Siblings?  Cousins?  Children?  These are intimate relationships and fellowship, just as the relationship that is formed with the believer and Christ. 

You are cared for, provided for, and loved; but your worth does not exceed the worth of your master.  That does not diminish a thing.  I fully believe that every human is built with a desire to serve, it’s intrinsic to our nature and our happiness.  I do not think this is a coincidence. 

So with that; who or what are you serving?

So our little Maggie moo has had to get splints for her hands to wear while she sleeps.  The purpose?  To encourage her to keep her hands open more often.  The result?  She won’t sleep, at all.  She’s been making a lot of progress and has been very responsive to her physical and occupational therapy, but she has clearly drawn a little baby line in the sand on this one.

On the bright side, it does appear she’s keeping her hands open more, so they are working.  They are also helping us all suffer from sleep deprivation.  Will, having returned from a previous week with Grandma’s (the week before my lan party which was on the 3rd) has finally started to normalize from the spoiling that went down.  I love when he gets to spend time with his extended family, but I loathe trying to get him back into alignment afterwards.  It’s usually not accomplished without me being a iron wall, which no parent truly wants to be with their child.  Poor Amanda hasn’t been as lucky in terms of his best behavior in my absence.  It appears that we are at the point of: “Just wait till your daddy gets home”.  He is our little man though and we love him, he’s tons of fun, full of humor.  Right now with Maggie’s therapy, we are certain he is feeling a bit neglected.  It’s hard to explain to a 3 year old why their sibling is getting more attention than them.

Pray for them both and my wife as well.  These are trying, stressful times for all of us.  There are days where we feel absolutely broken.  We are still blessed, but the world has a way of blinding you from that.


In other news, I’m officially doing OSD testing and building as of the past two weeks.  So another SCCM feature/function/tech that I’ve had the chance to use in an applicable fashion.  So far I’m enjoying it, the initial building and testing though is very time consuming.

I’ve mostly been toying with MDT then applying what I see/learn from there to my SCCM builds.  It’s interesting, but I will assume it becomes less intense after I configure a baseline.

I’m also down to (started at 178) 164 lbs now and down 2 pants sizes from my workout regiment and dietary change. 

That’s all I have for now, for this disjointed blog post.

So as some of you may or may not know.  My wife is conducting a 365 picture project this year.  What’s a 365 picture project?  Essentially take a pic of you, or something in your life for each day of the year and compile it all together at the end of the year to sort of journal everything.  It’s, as you can imagine, a lot of pictures being taken a day.  I would say on average she has 5 to 10 pictures taken a day.  Realistically speaking, some days it’s about 2, others it’s near 30 or more. 

 

Ok, great, why are you telling me this? 

 

Well, I’m glad you asked.  She would spend a lot of time sorting, renaming, and organizing them.  I’ve been telling her a long time “just automate it” which is something I tell her about almost everything she does that’s repetitive.  Well finally after a long night or sorting through some 100+ photos she called me on it, and had me write her a script to rename all the files for her.  I also had a chance to get to show her a bit of that “computer stuff” I do everyday at work. Also, it’s been a while since I’ve done a scripting post, so I’m using this. 🙂

I figured I would go with powershell since I would have (easier) access to the .NET System.IO.DirectoryInfo class.  One of the things my wife loves is chronological accuracy, so pulling a timestamp from the image as part of its name seemed like a good idea.  She already had a routine where she copied them from her camera to an appropriate folder so specific file information was the only real concern here so this was going to be a very simple script.  Below is the code:

 


PARAM([string]$FOLDER)
$ErrorActionPreference = "silentlycontinue"
if($FOLDER -eq "")
    {$FOLDER = Read-Host "Path to picture folder?"}
    $LIST = Get-ChildItem "$FOLDER*" -Exclude *ps1 `
    -Include *jpg,*tiff,*jpeg,*gif,*bmp,*txt
            $X = 0
    ForEach($OBJECT in $LIST)
        {$EXTENSION = $OBJECT.ToString().Split("") | Select -Last 1
            $EXTENSION = $EXTENSION.Split(".") | Select-Object -Last 1
              $FILEINFO = New-Object System.IO.DirectoryInfo($OBJECT)
                $NAME = $FILEINFO.LastWriteTime.GetDateTimeFormats() `
                | Select-Object -Index 99
                    $NAME = "$($NAME) ($($X)).$($EXTENSION)"
                        Write-Output $NAME
            Rename-Item -Path "$OBJECT" $NAME
            $X = $X+1
            }       


So what’s happening?

First we run this script, either by launching it directly, or by launching it on a command line followed by the folder where our pictures reside. The folder path is our only variable here, if one isn’t entered at the start of execution, it will prompt the user for one.

Now the script will build an object list of everything inside the folder taking special care to exclude any potential powershell scripts in the directory to the $LIST variable.  I also built it to specifically include image file types (I didn’t want to rename some random non-picture files she might be storing in the directory (well, and txt for my testing purposes)). 

Now we define an integer value to $X so we can enumerate it for a counter during our ForEach loop, which we begin next.

For each file in $LIST we:

  1. Grab the extension for the file to variable $EXTENSION
  2. Retrieve the last write time of the file and store it as $NAME
  3. Set $NAME to $NAME + $X + $EXTENSION
  4. Write the final $NAME to console
  5. Rename the item to $NAME
  6. Enumerate $X by 1
  7. Loop

The outcome?

 

I showed her the way it renamed a series of text files I had placed in a test folder on my laptop.  At first, I received a rather dismissive “Oh, that’s good babe” however after I sat down at her desk and showed her the bad boy in action renaming another folder of 100 or so images in seconds, the sly grin found it’s way across her face.  The joy of automation.  The kind you can only get when you see something so small perform such a mind numbing laborious task for you.

She’s not quite ready to learn scripting, but at least now her eyes are open to other possibilities for automated solutions in her everyday computing.  And as a stay at home mother of 2, I’m more than willing to help her streamline all her recreational and productive time at the keyboard.  She is after all, my number 1 customer ;).

So this article was just posted.  I read it, and about cried.

http://tech.slashdot.org/story/11/06/06/2222226/How-To-Succeed-In-IT-Without-Really-Trying

What they are discussing here is something that truly geats at me in respect to my industry.  I’m certain its true in almost every area.  People can’t lead what they can’t understand.

So as I sit here, still stuck on an energy rush from this weekends excitement and the one to come, it hit me. 

How easily do things grab hold of us and jerk us into new directions.  I’m generally a very focused worker.  I’ve lately been a bit stand offish about my video game play, and been anti gadget.

Yet, here I am, tinkering endlessly with this modified nook, anticipating long hours of play with my friends this weekend, and unable to focus on my job.  Albeit I’m doing my job, its with great determination that I remain on task.

How much more or less is our faith a part of our being when we are so easily pulled this way and that? That our hearts and minds are so easily redirected.  I’m thankful to say that I’ve continued to read the word, remain in prayer, and give glory to God in what I’m doing and in what is being done for me… this time.  This isn’t always the case for me, or for others.  To witness that these idols come and go, serves as an amazing contrast to Gods steadfast nature.  Why would we need anything more? Why do we forget that?  That answer is both simplistic and complex, sin, or that our chief idol is ourselves and not our Creator. 

I realize that sounds sort of, dark.  Generally thinking of the “aftermath”conjures thoughts of destruction and loss.  However, the only thing lost is another year of my life, but the gains were enjoyable!

Lets start with the presents (so far).  I’m going to start with the immediately tangible present my wife got me….  A nook color.

May 26 (210)

 

Here’s the thing.  I’ve been itching to buy a tablet for a while.  I’ve also been itching for another e-reader besides my droid x.  I’ve also continually talked myself out of buying a nook and rooting it.

  1. It’s a great e-reader
  2. It’s android based
  3. It can be rooted into a full tablet
  4. It’s $250 dollars (half the price of standard tablets)

However:

  1. I own a droid-x
  2. I own multiple laptops 
  3. It’s $250 dollars

When I opened it though, the inner geek in me went into immediate conflict with the responsible adult in me.  So I spent all day deciding if I should open it, or return it.  In the end, the geek prevailed and the box was open and playtime ensued.  Will loved it immediately because of some preloaded children’s books with “read to me” functionality.  Especially the story of the elephant and the crocodile.  Which he had to read again this morning:

May 27 (216)

After the kids went to bed though, Amanda and I sat down to watch a movie, while I of course watched the movie and rooted my nook at the same time.  By about midnight I had settled on and installed my image of choice.  Cyanogen mod 7, I chose this primarily because of sd expansion install and low to no risk of usage.  I do after all still enjoy the stock nook interface and features, so I didn’t want to blow it away.

May 27 (214)

May 27 (215)

Sorry for poor quality shots, dark room, camera phone, bright screen….. No Buenos.  I’ve also greatly personalized the image since this shot, this was stock image.

Second gift

Apparently my wife has been a busy woman.  Sometime back in January she began coordinating with some of my old friends back home to throw me a 30th birthday LAN Party.  Yes, this is awesome to me.  Yes, I’m that nerdy.  Yes, she raised the bar on birthday surprises and I fear I shall forever fall woefully short for her. Sad smile

May 26 (211) internet safe

Third Gift

A completely decorated 30th birthday house before I got out of bed, and a banana pudding cake….

 

May 26 (12)

May 26 (17)

May 26 (20)

May 26 (24)

May 26 (66)


So, I threw my diet a bit off yesterday.  With my birthday lunch and my banana pudding cake.  It was worth it though, now time to publish this and go ride my bike for about an hour.  God bless and have a good one!

Thanks to everyone for your birthday wishes as well (cards, etc).


Oops, almost forgot:

Keen Keen is streamlined for summer time!!!

May 24 (209)

Zoe and all her black fur is jealous!

March 27 (170)

Daniel has now achieved level 30 with 0 deaths.