Skip to content

Instantly share code, notes, and snippets.

View Iristyle's full-sized avatar

Ethan J. Brown Iristyle

View GitHub Profile
@Iristyle
Iristyle / fix-rubygems.pp
Last active October 27, 2016 20:00
Fix RubyGems with Puppet
$ruby_dir = regsubst($::ruby['sitedir'],'^(.*/lib/ruby/).*$','\1')
$ruby_ver = regsubst($::ruby['sitedir'],'^.*/(.*)$','\1')
$cert_path = "${ruby_dir}${ruby_ver}/rubygems/ssl_certs/GlobalSign_Root_CA-2.11.4.0.0.0.0.1.21.75.90.195.148.pem"
file { $cert_path:
content => @(EOPEM)
# alias="GlobalSign Root CA"
# trust=CKA_TRUST_CODE_SIGNING CKA_TRUST_EMAIL_PROTECTION CKA_TRUST_SERVER_AUTH
# distrust=
# openssl-trust=codeSigning emailProtection serverAuth
@Iristyle
Iristyle / crash.txt
Created September 30, 2016 18:45
Ruby crash in popen3
C:/tools/ruby23/lib/ruby/2.3.0/open3.rb:201: [BUG] w32_reset_event: The handle is invalid.
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
-- Control frame information -----------------------------------------------
c:0043 p:---- s:0201 e:000200 CFUNC :close
c:0042 p:0009 s:0198 e:000197 BLOCK C:/tools/ruby23/lib/ruby/2.3.0/open3.rb:201 [FINISH]
c:0041 p:---- s:0195 e:000194 CFUNC :each
c:0040 p:0084 s:0192 e:000191 METHOD C:/tools/ruby23/lib/ruby/2.3.0/open3.rb:201
c:0039 p:0143 s:0181 e:000180 METHOD C:/tools/ruby23/lib/ruby/2.3.0/open3.rb:95
@Iristyle
Iristyle / uptime.ps1
Created September 8, 2016 21:08
Windows API GetTickCount64 used to retrieve system uptime on Windows with 64-bit resolution (5000+ years)
$signature = @'
[DllImport(@"kernel32.dll", SetLastError=true)]
public static extern UInt64 GetTickCount64 ();
'@
$type = Add-Type -MemberDefinition $signature -Name SystemTime -Namespace GetTickCount64 -PassThru
[System.TimeSpan]::FromMilliseconds($type::GetTickCount64())
@Iristyle
Iristyle / env-reset.ps1
Last active February 25, 2016 14:51
Reset environment variables
# initial stash of process vars that will overwrite Machine / User vars
if (! $processVars)
{
# capture all variables by name, using whats currently available in-proc for values (already expanded)
$processVars = [Environment]::GetEnvironmentVariables('Process').Keys |
% -Begin { $h = @{} } -Process { $h.$_ = (Get-Item Env:\$_).Value } -End { $h }
# Write-Host "Initially captured process vars:`n`n$($processVars | Out-String)"
# eliminate Machine / User vars so that we have only process vars
#!/bin/bash
# Mostly taken from http://forum.kodi.tv/showthread.php?tid=212971
###############################################################################
# Download and update latest Kodi build (nightly or stable) and install to a connected device.
# - tested using a Mac OSX and Fire TV Stick
###############################################################################
function progressbar()
{
bar="================================================================================​"
@Iristyle
Iristyle / ruby-native-gems.md
Last active September 6, 2017 08:37
Installing gems that require Ruby DevKit on a machine that has installed Puppet from MSI
  • Install Puppet from MSI
  • Note that the Ruby install path is something like c:\program files\puppet labs\puppet\sys\ruby
  • Install Chocolatey in PowerShell with iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
  • Close / re-open PowerShell
  • Install Ruby Devkit - choco install ruby2.devkit
  • Add Ruby to the beginning of the PATH using an 8.3 style path - $Env:PATH = "C:\Progra~1\Puppet~1\Puppet\sys\ruby\bin;" + $Env:PATH (NOTE: dir /x inside cmd.exe can be helpful to find 8.3 style paths)
    • If done correctly gem env should contain a line with RUBY EXECUTABLE: C:/PROGRA~1/PUPPET~1/Puppet/sys/ruby/bin/ruby.exe
    • This part is absolutely critical, so if gem env doesn't have a bunch of 8.3 style paths, you've done something wrong
  • Configure DevKit for use with our vendored Ruby
  • cd \DevKit-2.0-x64
@Iristyle
Iristyle / acls.txt
Last active August 29, 2015 14:24
MCO sync / service startup failure
Initial Permissions after installation
PS C:\Users\Administrator> get-acl C:\ProgramData\PuppetLabs\mcollective | select *
PSPath : Microsoft.PowerShell.Core\FileSystem::C:\ProgramData\PuppetLabs\mcollective
PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\ProgramData\PuppetLabs
PSChildName : mcollective
PSDrive : C
PSProvider : Microsoft.PowerShell.Core\FileSystem
@Iristyle
Iristyle / Directory Contents
Created June 23, 2015 00:24
Ruby MOF parsing text
[parser-tests] ls -l 17:18:43
total 1584
-rw-------+ 1 Iristyle staff 13004 May 12 15:52 DscCore.mof
-rw-------+ 1 Iristyle staff 5700 May 12 15:52 DscCoreConfProv.mof
-rw-r--r--+ 1 Iristyle staff 128 Jun 22 15:15 Gemfile
-rw-r--r--+ 1 Iristyle staff 610 Jun 22 15:16 Gemfile.lock
-rwx------+ 1 Iristyle staff 2000 May 12 15:52 MSFT_FileDirectoryConfiguration.Schema.mof
-rw-r-----@ 1 Iristyle staff 357 Jun 22 15:45 MSFT_Qualifiers.mof
-rw-r--r--+ 1 Iristyle staff 560 Jun 22 15:16 MSFT_xADDomain.schema.mof
-rw-r--r--+ 1 Iristyle staff 463 Jun 22 15:16 MSFT_xADDomainController.schema.mof
@Iristyle
Iristyle / cygwin.md
Last active August 29, 2015 14:21
Cygwin environment differences

Cygwin Missing

APPDATA=C:\Users\Administrator\AppData\Roaming
CLIENTNAME=Zachs-MacBook-P
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
FP_NO_HOST_CHECK=NO
LOCALAPPDATA=C:\Users\Administrator\AppData\Local
@Iristyle
Iristyle / setup-cmd-service.ps1
Created May 5, 2015 22:26
Run cmd.exe / powershell.exe in an interactive service
cinst rktools.2003
cd 'C:\Program Files (x86)\Windows Resource Kits\Tools'
$serviceName = 'Interactive SYSTEM cmd'
.\instsrv.exe $serviceName 'C:\Program Files (x86)\Windows Resource Kits\Tools\srvany.exe'
sc.exe config $serviceName depend= UI0Detect start= demand
$servicePath = "HKLM:\SYSTEM\CurrentControlSet\Services\$serviceName"
$serviceParams = New-Item $servicePath -Name Parameters