Random things shared on Twitter from the week: * Virtual Reality Contact Lenses Could Be Available by 2014 http://t.co/CnFwyGrc via @zite * Culture Eats Strategy For Lunch | Fast Company http://t.co/ruIe8jYf * Under the covers of eBay’s big data operation http://t.co/zrebNXcy * yEd diagram editor http://t.co/fTrn4uTJ via @zite * Forget the Super-PACs: The Parties’ Data Mining Operations Might Be More Influential in 2012 http://t.co/0URjFcoa via @slate * How NASA Solved a $100 Million Problem for Five Bucks http://t.co/0GsF12OW via @zite * What If The Apollo Program Never Happened? : Discovery News http://t.co/M3OcmsTv * Engineering Management: Why are software development task estimations regularly off by a factor of 2-3? http://t.co/Qgkt4AHA
From the article For Sale: Detailed Voter Profiles:
Catalist did the basic work of stitching together lists from local election officials, but some of the most valuable data came from its customers. The company described itself as a consortium, and every contract required a customer to contribute something of value back to Catalist. Rock the Vote used Catalist to identify adults it could target as part of its registration drives—in exchange, it put personal information gleaned during those drives back onto Catalist’s servers.
This is a great model for establishing a virtuous cycle. The more people that onboard and derive value from the service, the more value it is able to in turn deliver to the existing and future user base. Once this flywheel starts it just keeps going.
Random things shared on Twitter from the week:
- Engineering Management: Why are software development task estimations regularly off by a factor of 2-3? http://t.co/Qgkt4AHA
- That Was Fast: Betaworks Returns All Capital… And Then Some | PandoDaily http://t.co/if0x0CLf
- Why Big Data Won’t Make You Smart, Rich, Or Pretty | Fast Company http://t.co/fg2zj28k
- RT @rafer: Desalination via Graphene? Possibly world changing. http://t.co/edOTuGQx
- Pac-Man Proved NP-Hard By Computational Complexity Theory http://t.co/wnjjQJ4c
- Scaling GitHub http://t.co/86IQD4fA
- Love this analysis. Are Expensive Batteries Worth the Extra Cost? http://t.co/Ok095h5l
- One Div Zero: A Brief, Incomplete, and Mostly Wrong History of Programming Languages http://t.co/iz5WTTYD
- Mobile is here: You’ve probably underestimated just how big this is http://t.co/BE5VvZcn
- Legacy incentives - How Can A Free Conference Call Be Free? http://t.co/4mKDpjJM
- The Cognitive Consequences of Having Information at Our Fingertips at Farnam Street http://t.co/brU35S2h
I cleaned up a few Active Directory related PowerShell scripts this evening with a view to sharing them more broadly. More on that in another post. In honesty much of my recent PowerShell work has been rather hacky, just cobbling together script files until they run for a specific task at hand. Not exactly anything to be proud of or the readily reusable stuff I'd like to share so I figured it was time to brush up PowerShell modules which are well suited to exposing functionality.
In my case I'm not doing anything too fancy and my module will be very similar to the existing ps1 script. The major difference (and benefit) with a script module is the scope in which variables and functions are defined (i.e. not necessarily global) and the level of control the author retains over what is exposed (e.g. functions can be defined for use by other functions in the module but not exposed outside of it).
To convert a ps1 to psm1 PowerShell script module
- Make sure your functionality is neatly wrapped up in functions. A script which actually does work stuff in its script scope may need slight rework.
- Identify the functions to expose. Use the
Export-ModuleMember -function fun1, fun2to expose
To install the module (optional)
- Make sure you have a
Modulesfolder in place. If not, create it with
new-item -type directory -path $home\Documents\WindowsPowerShell\Modules
- Copy the module folder containing the psm1 file into the
copy-item -path c:\ps-test\MyModule -dest $home\Documents\WindowsPowerShell\Modules
To use the module
To use the module, simply use
import-module <modulename>. If you haven't installed the module into the well-known path defined above,
import-module can also take a full path to a psm1 file as a parameter. The exposed functions and variables will now be defined and ready for use.
Once you see how this model works it's very clean and organized.