Skip to content

Instantly share code, notes, and snippets.

View camilohe's full-sized avatar

Camilo E. Hidalgo Estevez camilohe

View GitHub Profile
@camilohe
camilohe / build.ps1
Created April 20, 2017 16:49 — forked from rkeithhill/build.ps1
PSake build script for publishing PowerShell modules
# This is a PSake script that supports the following tasks:
# clean, build, test and publish. The default task is build.
#
# The publish task uses the Publish-Module command to publish
# to either the PowerShell Gallery (the default) or you can change
# the $Repository property to the name of an alternate repository.
#
# The test task invokes Pester to run any Pester tests in your
# workspace folder. Name your test scripts <TestName>.Tests.ps1
# and Pester will find and run the tests contained in the files.
@camilohe
camilohe / powershell.json
Created April 20, 2017 16:48 — forked from rkeithhill/powershell.json
PowerShell snippets file for Visual Studio Code - place in your ~\AppData\Roaming\Code\User\Snippets directory
{
"Condition statement": {
"prefix": "cond",
"body": [
"${_} { ${0}; break }"
],
"description": "Switch condition statement"
},
"Condition single quoted string statement": {
@camilohe
camilohe / Optimize-PSReadlineHistory.ps1
Created April 20, 2017 16:46 — forked from rkeithhill/Optimize-PSReadlineHistory.ps1
Removes duplicate and optionally short commands from your PSReadline history file
<#
.SYNOPSIS
Optimizes your PSReadline history save file.
.DESCRIPTION
Optimizes your PSReadline history save file by removing duplicate
entries and optionally removing commands that are not longer than
a minimum length
.EXAMPLE
C:\PS> Optimize-PSReadlineHistory
Removes all the duplicate commands.
@camilohe
camilohe / ConfigureConsoleSettings.ps1
Created April 20, 2017 16:45 — forked from rkeithhill/ConfigureConsoleSettings.ps1
Configures the PowerShell console settings (colors, fonts, buffer size, etc).
<#
.SYNOPSIS
Sets the console settings to the specified values and color theme.
.DESCRIPTION
Sets the console settings to the specified values and color theme.
.EXAMPLE
C:\PS> Configure-ConsoleSettings -Theme ConEmu -WindowSize 120,50 `
-FontFace Consolas -FontSize 12
Sets the colors to those used in ConEmu and sets the font and window size.
@camilohe
camilohe / posh-git_config.ps1
Created April 20, 2017 16:44 — forked from rkeithhill/posh-git_config.ps1
Config file for posh-git.
# Import Posh-Git and configure Git prompt
function global:prompt {
$origLASTEXITCODE = $global:LASTEXITCODE
$id = 0
$histItem = Get-History -Count 1
if ($histItem) {
$id = $histItem.Id
}
# A UNC path has no drive so it's better to use the ProviderPath e.g. "\\server\share".
@camilohe
camilohe / PSReadline_config.ps1
Created April 20, 2017 16:42 — forked from rkeithhill/PSReadLine_config.ps1
PSReadline configuration updated for PSReadline v1.1
# Need to explicitly import PSReadLine in a number of cases: Windows versions < 10 and
# x86 consoles that aren't loading PSReadLine.
# Source: https://gist.github.com/rkeithhill/3103994447fd307b68be#file-psreadline_config-ps1
# Other hosts (ISE, ConEmu) don't always work as well with PSReadline.
if ($host.Name -ne 'ConsoleHost') { return }
# PSReadline hasn't been auto-imported, try to manually import it
if (!(Get-Module PSReadline -ErrorAction SilentlyContinue)) {
if (!$IsLinux -and !$IsOSX -and ([IntPtr]::Size -eq 4) -and !(Get-Module -ListAvailable PSReadline)) {
@camilohe
camilohe / gist:8bda691c077576133654
Last active September 7, 2015 16:20 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

$webclient = New-Object System.Net.WebClient
$url = "https://github.com/camilohe/Posh-SSH/archive/master.zip"
Write-Host "Downloading latest version of Posh-SSH from $url" -ForegroundColor Cyan
$file = "$($env:TEMP)\Posh-SSH.zip"
$webclient.DownloadFile($url,$file)
Write-Host "File saved to $file" -ForegroundColor Green
$targetondisk = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules"
New-Item -ItemType Directory -Force -Path $targetondisk | out-null
$shell_app=new-object -com shell.application
$zip_file = $shell_app.namespace($file)
@camilohe
camilohe / bs-install.ps1
Last active April 17, 2016 01:26
Boxstarter install.ps1 script, based in the install.ps1 script for Chocolatey
# Boxstarter bootstrap script, based on the install.ps1 script for Chocolatey
# functions
function Download-File {
param (
[string]$url,
[string]$file
)
Write-Host "Downloading $url to $file"
$downloader = new-object System.Net.WebClient