Skip to content

Instantly share code, notes, and snippets.

@jrotello
jrotello / GodMode.ps1
Created July 12, 2012 02:51
Creates the GodMode (control panel on steriods) folder on the current user's desktop.
$godMode = "$env:userprofile\Desktop\GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}"
if (!(Test-Path -Path $godMode)) {
mkdir $godMode
}
@jrotello
jrotello / DownloadTRWallpapers.ps1
Created October 1, 2012 15:38
Script to download the Thomson Reuters ecaldenar background images.
param(
[string[]]$targetDirectories = $(throw "targetDirectories parameter is required"),
[string]$size = "1920x1280"
)
function getUrl ($imageNumber) {
$monthNumber =[System.DateTime]::Today.Month
$monthName = [System.Globalization.DateTimeFormatInfo]::InvariantInfo.GetAbbreviatedMonthName($monthNumber).ToLower()
$imageId = 4 * ($monthNumber - 1) + $imageNumber
$urlFormat = "http://ecalendar.thomsonreuters.com/download.asp?size={0}&mo={1}&id={2}"
@jrotello
jrotello / volunteer.ps1
Created October 9, 2012 13:59
Select "volunteers" from a list or file.
function Get-Volunteers {
[CmdletBinding()]
param(
[int]$count = 1,
[array]$values = @(),
[string]$file = ""
)
if ($file -ne "") {
Get-Content $file | % { $values += $_ }
@jrotello
jrotello / gitignore.io.ps1
Last active December 19, 2015 08:19
A couple of PowerShell helper functions to interact with http://gitignore.io. These functions will allow you to list the terms recognized by http://gitignore.io as well as generate .gitignore files.
# Description:
# A couple of PowerShell helper functions to interact with
# http://gitignore.io. These functions will allow you to
# list the terms recognized by http://gitignore.io as well
# as generate .gitignore files.
#
# Install:
# Save this file to your machine and dot source it in your PowerShell
# profile.
@jrotello
jrotello / EnumerateSqlServers.cs
Created July 7, 2013 14:27
Enumerate over all available SQL Server instances.
DataTable data = SqlDataSourceEnumerator.Instance.GetDataSources();
foreach(DataRow row in data.Rows) {
string server = row["ServerName"].ToString();
string instance = row["InstanceName"].ToString();
if (!string.IsNullOrWhiteSpace(instance)) {
server += "\\" + instance;
}
Console.WriteLine(server);
}
@jrotello
jrotello / blink1-cpumonitor.ps1
Created July 14, 2013 03:14
A PowerShell script that lights a blink(1) LED based upon the CPU utilization of the computer. The CPU load is polled and updated every 3 seconds. Requires a ThingM blink(1). Assumes that the blink1-tool.exe is the the system path.
$global:cpuMonitor = $null
function Enable-CpuMonitor() {
if ($global:cpuMonitor -eq $null) {
$global:cpuMonitor = New-Object Timers.Timer
$global:cpuMonitor.Interval = 3000
$global:cpuMonitor.Enabled = $true
Register-ObjectEvent -InputObject $global:cpuMonitor -SourceIdentifier CpuMonitor -EventName Elapsed -Action {
$processor = Get-WmiObject win32_processor
@jrotello
jrotello / blink1-batterymonitor.ps1
Created July 20, 2013 02:26
A PowerShell script that lights a blink(1) LED based upon the remaining battery level of the computer. The remaining battery level is polled and updated every 30 seconds. Requires a ThingM blink(1). Assumes that the blink1-tool.exe is the the system path.
$global:batteryMonitor = $null
function Enable-BatteryMonitor() {
if ((Get-WmiObject win32_battery) -eq $null) {
Write-Host "No battery found."
return
}
if ($global:batteryMonitor -eq $null) {
$global:batteryMonitor = New-Object Timers.Timer
@jrotello
jrotello / gist:6251742
Created August 16, 2013 17:18
Output encoding of current file in Sublime Text.
sublime.active_window().active_view().encoding()
@jrotello
jrotello / gist:8873462
Last active March 23, 2022 14:18
Powershell helper to ease Elasticsearch interaction without curl
function Invoke-Elasticsearch {
[CmdletBinding()]
Param(
[Uri]$Uri,
[Microsoft.PowerShell.Commands.WebRequestMethod]$Method = 'Get',
$Body = $null,
[PSCredential]$Credential
)
$headers = @{}
@jrotello
jrotello / ConvertToAutomaticPackageRestore.ps1
Last active August 29, 2015 13:57
Convert from MSBuild NuGet Package Restore to Automatic Package Restore. Updates nuget.exe, removes nuget.targets, and removes the nuget.targets references from all .csproj files under the solution directory provided.
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
$SolutionDir
)
$SolutionDir = Resolve-Path $SolutionDir
$nugetTargetsPath = Join-Path $SolutionDir ".nuget\nuget.targets"
$nugetExePath = Join-Path $SolutionDir ".nuget\nuget.exe"