Skip to content

Instantly share code, notes, and snippets.

View jplindgren's full-sized avatar
:octocat:

João Paulo Pozo Lindgren jplindgren

:octocat:
View GitHub Profile
@jplindgren
jplindgren / CreateMyProfile.ps1
Last active October 13, 2016 18:35
Automatically download and create powershell profile
######################################################
# Download custom PowerShell profile file
######################################################
Write-Host "Creating custom $profile for Powershell"
if (!(test-path $profile)) {
New-Item -path $profile -type file -force
}
Add-Content $profile ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/jplindgren/a3aefc76b1667e4fefa6a47f9974974e/raw/a6bceca451f08e765bd49e137656b1a25f4aa7b1/myprofile.ps1'))
Write-Host
@jplindgren
jplindgren / myprofile.ps1
Last active October 13, 2016 18:34
My Powershell Profile
# Check if Running as Admin
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if (-not $IsAdmin) {
if ($MyInvocation.ScriptName -ne "") {
try {
Write-Host "Relanuching Script as Admin"
$arg = "-file `"$($MyInvocation.ScriptName)`""
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop'
} catch {
@jplindgren
jplindgren / Microsoft.PowerShell_profile.ps1
Created June 2, 2016 05:56 — forked from wpsmith/Microsoft.PowerShell_profile.ps1
PowerShell: Profile to always launch PS as Administrator, set Aliases (ex. Notepad++), Import SharePoint Online, Azure AD, and Azure Services.
# Check if Running as Admin
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if (-not $IsAdmin)
{
if ($MyInvocation.ScriptName -ne "")
{
try
{
Write-Host "Relanuching Script as Admin"
@jplindgren
jplindgren / dev_setup.ps1
Created June 2, 2016 05:54 — forked from thitemple/dev_setup.ps1
A PowerShell script for installing a dev machine using Chocolatey.
function Add-Path() {
[Cmdletbinding()]
param([parameter(Mandatory=$True,ValueFromPipeline=$True,Position=0)][String[]]$AddedFolder)
# Get the current search path from the environment keys in the registry.
$OldPath=(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
# See if a new folder has been supplied.
if (!$AddedFolder) {
Return 'No Folder Supplied. $ENV:PATH Unchanged'
}
# See if the new folder exists on the file system.
@jplindgren
jplindgren / API.md
Created May 3, 2016 17:47 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@jplindgren
jplindgren / 01-Update-Windows.ps1
Created March 16, 2016 17:40 — forked from ChaseFlorell/01-Update-Windows.ps1
Boxstarter Installation Scripts
# http://boxstarter.org/package/url?
#####################
# BEGIN CONFIGURATION
#####################
#region Initial Windows Config
Install-WindowsUpdate -AcceptEula
Update-ExecutionPolicy Unrestricted
@jplindgren
jplindgren / gist:b7e963fb740f9c1122bc
Created February 10, 2016 20:38 — forked from petros/gist:110406
How to update the schema for an XPO object model
//How to update an XPO schema and create the XPObjectType table
using (Session session = new Session())
{
//Here we select one class from each assembly that contains XPO classes
//For example User is one of our XPO object model classes
Assembly[] array = { typeof(User).Assembly, typeof(XPObjectType).Assembly };
session.UpdateSchema(array);
}
namespace Sagas
{
using System;
using System.Collections.Generic;
class Program
{
static ActivityHost[] processes;
@jplindgren
jplindgren / gist:08bccc99ecfb08ee6b39
Last active October 6, 2017 12:17
provisioning jenkins
#variables
$url = 'http://localhost:8080/jnlpJars/jenkins-cli.jar';
$jenkinsTempCliDir = Join-Path $env:TEMP "jenkinsClient"
if (![System.IO.Directory]::Exists($jenkinsTempCliDir)) {[System.IO.Directory]::CreateDirectory($jenkinsTempCliDir)}
$file = Join-Path $jenkinsTempCliDir "jenkins-cli.jar"
#functions
function Download-File {
param ( [string]$url, [string]$file )
public static class TestHelpers
{
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue)
{
ShouldEqualWithDiff(actualValue, expectedValue, DiffStyle.Full, Console.Out);
}
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue, DiffStyle diffStyle)
{
ShouldEqualWithDiff(actualValue, expectedValue, diffStyle, Console.Out);