Digital Ocean – Remote Desktop – What $5 a month buys you.
Posted: October 18, 2015 Filed under: Uncategorized Leave a commentGo sign up at Digital Ocean and create a 512MB RAM, 1 CPU droplet in your region using the Ubuntu image.
Wait a whole dammed minute for your 20 GB SSD based VM to be provisioned and go get your root credentials from the welcome email.
If you manage your own DNS, which you must or we can’t hangout, go add an A record for the VM IP like with coolname.yourdomain.huh.
SSH into the box and change your password and maybe apt-get update, apt-get -y upgrade, reboot. No sudo required. Whoami, I am root beaches, this is free balling.
Then apt-get install -y lxde xrdp midori. Remote in with mstsc or rdesktop to your hearts content and use it like a shoe, like for if your work blocks eBay and that is basically your second income.
Add swap as needed, you will need it.
I only do all this so I can run byobu, mwahahahaha.
SQL SMO PowerShell
Posted: May 12, 2013 Filed under: Uncategorized Leave a commentSome simple PS that has potential.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Just some shortcuts on top of SMO to add powershell flavor. | |
| Basically you pick from a collection, and choose an item, rinse and repeat. | |
| Easier done than said. | |
| Note: Be careful with this, you are on top of SMO and that can kill things. | |
| Note: Piping any SMO object at all to Export-Clixml looks interesting. | |
| TODO: Needs more documentation. | |
| TODO: Add script options. | |
| TODO: Add depends function with the dependency walker stuff. | |
| TODO: Consolidate pick and choose function, make it smarter. | |
| e.g. | |
| (express).Databases | pick Northwind | choose Tables | list | |
| (express).Databases | pick Northwind | choose Tables | pick Suppliers | script | |
| (express).Databases | pick Northwind | choose Tables | pick Suppliers | Select-Object -Property Columns | |
| (express).Databases | pick Northwind | choose Views | owner dbo | list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null; | |
| function express() { | |
| server ".\sqlexpress" | |
| } | |
| function server($name) { | |
| New-Object Microsoft.SqlServer.Management.Smo.Server $name | |
| } | |
| function list() { | |
| $input | Select-Object -Property Name | |
| } | |
| function pick($name) { | |
| $input | Where-Object {$_.Name -eq $name} | |
| } | |
| function choose($name) { | |
| $input | Select-Object -ExpandProperty $name | |
| } | |
| function owner($owner) { | |
| $input | Where-Object {$_.Owner -eq $owner} | |
| } | |
| function script() { | |
| $input | ForEach-Object {$_.Script()} | |
| } |
Sample dependency injection for suburbanites
Posted: May 11, 2013 Filed under: Uncategorized Leave a commentProgrammers write a whole lot of code to use to “spin up” other objects in order to use that objects services and all of the required dependencies to use the object services are otherwise of absolutely no concern to the consumer of the service. It is pernicious. See Separation of concerns for more info.
The factory may seem like a lot of work and a lot of code but most times you don’t code it and it is generated, either at compile time, perhaps using attributes for some aspect oriented programming, or at runtime using reflection. In the end whatever work you put into configuring it is supposed to be recouped by all the supposedly many consumers who no longer have to open their garage door and rummage about for two stroke oil.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // All I want is my lawn mowed. | |
| // Yet I have to gather up the tools which are of no direct use to me in this case. | |
| var myLawn = {}, myWalk = {}; | |
| var myTools = MyGarage.Tools(["mower", "gas", "oil", "broom"]); | |
| var gardener = new Gardener(myTools); | |
| gardener.mow(myLawn); | |
| //Given the factory code below now all I have to do is this. | |
| var worker = workerFactory().getWorker("gardener") | |
| worker.mow(myLawn); | |
| worker.sweep(myWalk); | |
| var workerFactory = function() { | |
| map = { | |
| gardener : { | |
| tools : ["mower", "gas", "oil", "broom"], | |
| skills : {mow: function(lawn) {return "yes boss";}, sweep: function(walk) {return "yes boss";}} | |
| } | |
| } | |
| function getWorker(type) { | |
| var worker = {type: type}; | |
| // Give the worker tools | |
| var tools = map[type].tools; | |
| worker.tools = []; | |
| for (var item in tools) { | |
| worker.tools[item] = tools[item]; | |
| } | |
| // Give the worker skills | |
| var skills = map[type].skills; | |
| for (var item in skills) { | |
| worker[item] = skills[item]; | |
| } | |
| return worker; | |
| } | |
| return { | |
| getWorker: getWorker | |
| } | |
| } |