ScriptCS or PowerShell? part 1

§ May 15, 2013 13:02 by beefarino |

TL;DR: Use both: https://github.com/beefarino/ScriptCS-PowerShell-Module

A few days ago I posted a teaser of a project I hammered together that allowed you to run ScriptCS inside of your PowerShell session.  This morning I pushed the cleaned-up version to to GitHub: https://github.com/beefarino/ScriptCS-PowerShell-Module.

I’ve been watching ScriptCS with much interest – I’m a huge fan of scripting and REPL interaction and having another environment to leverage makes me happy.  What makes me sad is when I read crap like this on twitter:

ScriptCS is awesome!  <expletive deleted> PowerShell!

Or this:

PowerShell is amazing and ScriptCS is teh suck!

Why anyone would shun one or the other is beyond me.  They each have a wealth of possibility to offer.  My first instinct with new technology is to figure out how to make it work with other things I already know.  This helps me understand the guts of the new thing and gives me a frame of reference to move forward.  So that’s what I’m doing, and the potential is tantalizing.

Phase One

Phase one was pushed to GitHub this morning.  You can now run ScriptCS code inside of a PowerShell session:

PS > ipmo scriptcs
PS > invoke-scriptcs '"Hello PowerShell!"'
Hello PowerShell!

You can even pipe data to ScriptCS and consume it:

PS > 0..9 | invoke-scriptcs '(int)pscmdlet.Input[0] + 100'
100
101
102
103
104
105
106
107
108
109

And put data from ScriptCS onto the pipe:

PS > 0..9 | `
    invoke-scriptcs '(int)pscmdlet.Input[0] + 100' | `
   %{ "Output: $_" }
Output: 100
Output: 101
Output: 102
Output: 103
Output: 104
Output: 105
Output: 106
Output: 107
Output: 108
Output: 109

There’s still lots to do, but the possibilities are pretty amazing.  Ever wished you could use LINQ from PowerShell?  Now you can:

PS > invoke-scriptcs -input (0..9) -script 'from i in pscmdlet.Input where (int)i > 5 select i'
6
7
8
9

Phase 2

Phase 2 is pretty much the opposite of what I’ve done so far.  Phase two is a Script Pack for ScriptCS that allows you to run arbitrary PowerShell script in ScriptCS.  This is working now – the plan is to clean it up over the next week and make it public.  Stay tuned…



Yo Dawg I Heard You Like Scripts So I Put Scripts in your Scripts

§ May 13, 2013 12:56 by beefarino |

 

image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Because reasons, that’s why.



CodeOwls Skunkworks at the AZ PoSh User Group

§ April 30, 2013 09:17 by beefarino |

white-compass-rose-hiTomorrow evening I’ll be giving an online presentation to the Arizona PowerShell User Group.  I’ve heard great things about this group and am really looking forward to the talk – if you want to join the fun check out the details here: http://www.azposh.com/2013/04/maymeeting/.

The topic is “Strange Things with PowerShell”.  Well, that’s the title – the topic is really a set of skunkwork projects I’ve been hammering out since the beginning of the year.  I’ll introduce them briefly in this post, but if you want to learn more you’ll have to tune in tomorrow evening or wait for the release.

The first project I’ll be covering is the Entity Shell (ES).  ES is a PowerShell module that “knows” all about Microsoft’s ORM named Entity Framework.  Basically, once you have an Entity Framework data context defined, you can use PowerShell to manage your entities without doing any extra work.  Here’s a working code snippet to whet your appetite:

# pull in the entity shell
import-module entityshell;

# pull in my entity data context
new-psdrive -name ent -root '' -psp entityprovider `
    -context [SuperAwesomeWebsite.Models.Context]

# create a set of 100 new user accounts for testing
0..99 | new-item -path ent:/users -username { "User$_" } -password { "Password$_" }

# commit the new entities to persistent storage
complete-unitOfWork

# server-side filter for users without a password
$u = dir ent:/users -filter "it.Password IS NULL" 

# generate a report of these users
$u | convertto-csv | out-file "badusers.csv"

# remove the offending users
$u | remove-item

# commit these removals to persistent storage
complete-unitOfWork

The other project I’ll be demoing is Polaris; this project came about as a way to see how simple I could make the process of extending Windows Explorer.  Shell namespace extensions are hard; Polaris makes it dirt simple, and all you need is a little PowerShell to turn Windows Explorer into a rich dashboard of the stuff you want to see.

More on these projects in the coming weeks; in the meantime, if you want to see the goods, you’ll have to tune in (http://www.azposh.com/2013/04/maymeeting/).



Proposed CodeStock Talks for 2013

§ April 23, 2013 12:33 by beefarino |

CodeStock 2013It’s that time of year again!  One of my favorite conferences has opened early registration, and once you register you get to vote on the sessions you want to see.  I’ve changed the theme of my submissions this year – instead of focusing on PowerShell stuff I’ve submitted several more general talks about developer and independent life.  I’m expounding on them here in case you need a little persuasion to send some votes my way.

An Honest Look at Being Independent

This talk is about the changes that comes with being independent of an employer.  The goal is give you a very clear picture of what changed for me – financially, psychologically, and legally.  Part of the talk will include a near-pornographic look at my cashflow and expenses – where the money comes from and where the money goes, and how this folds into the choices I make around my time and my family.

If you’re considering the move to independence, please vote for this session.

http://www.codestock.org/sessions/an-honest-look-at-being-independent/

Programmer Body Issues

We don’t usually think of the programmer’s career ending because of injury, but it happens more often than you know.  The human body wasn’t designed to sit and type for long periods, and the effects of doing that can have career-ending implications.  This talk is about what your job is doing to your body, how to recognize the warning signs before stress turns into pain and then injury, and how to keep yourself healthy and happy and productive with very little effort.

This isn’t about diet & exercise, nor ergonomics.  It’s about undoing the damage you’ve already done.

http://www.codestock.org/sessions/programmer-body-issues/

Giving it Away: How Publishing OSS Helps the Independent Developer

It may not make sense at face-value, but spending your time on open-source projects can be a huge boon for your business.  This talk is about treating OSS as a business opportunity, and how I’ve managed these give-it-away efforts to generate more income than the “regular” consulting and software sales facets of my business.

http://www.codestock.org/sessions/giving-it-away-how-publishing-oss-helps-the-independent-developer/

Creating Mayhem!

This one is just for fun – Mayhem is an open-source project that allows you to “wire up” events to reactions.  Use your phone to turn on your lights, or your XBox controller to run a PowerPoint presentation.  I’ll show you how easy it is to get started with this framework, and how quickly you can fold in your own creations.

For our summer project this year, my oldest daughter and I will be creating devices for our dog’s kennel that will allow us to dispense treats, sense his movement and barking, etc.  Part of this talk will feature how we’re using Mayhem to read from and drive these arduino-based devices.

http://www.codestock.org/sessions/creating-mayhem/