Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Wright discoposse

View GitHub Profile
@discoposse
discoposse / SplitLogs.ps1
Created Sep 29, 2011
PowerShell - split large text/log file
View SplitLogs.ps1
#############################################
# Split a log/text file into smaller chunks #
#############################################
#
# WARNING: This will take a long while with extremely large files and uses lots of memory to stage the file
#
# Set the baseline counters
#
# Set the line counter to 0
@discoposse
discoposse / Folder structure
Created Jul 10, 2020
Terraform vSphere Folder reference challenged when using a Variable
View Folder structure
Datacenter = HawthorneSales
Default root folder (hidden) = HawthorneSales/vm
Folders = Users/eric.wright
@discoposse
discoposse / README.md
Created Apr 29, 2019 — forked from tristanm/README.md
Migrating a Rails project from MySQL to PostgreSQL
View README.md

Migrating a Rails project from MySQL to PostgreSQL

This brief guide is written from my own experience with migrating a large (~5GB) MySQL database to PostgreSQL for a Rails project.

No warranties, guarantees, support etc. Use at your own risk and, as always, ENSURE YOU MAKE BACKUPS FIRST!

I chose [pgloader][1] because it's extremely fast. YMMV.

  1. Replace mysql2 gem with pg in Gemfile.
  2. Update config/database.yml for PostgreSQL. I used [Rails' template][2] as a starting point.
View PowerShell - Get serial numbers for computers in Active Directory
# Requires ActiveRoles CmdLets from Quest Software (They're free and awesome) - http://www.quest.com/powershell/activeroles-server.aspx
Get-QADComputer -searchroot "OU=yourcomputerOUname,dc=yourdomain,dc=com" -SizeLimit 0 |
ForEach-Object {
$hostname = $_.name
$serialnumber = (Get-WMIObject Win32_BIOS -computer $hostname -ErrorAction SilentlyContinue).SerialNumber
if (-not $serialnumber) {
Add-Content d:\logfiles\offlinehosts.txt "$hostname is in offline"
}
else {
Write-Host "$hostname,$serialnumber" # output to screen
@discoposse
discoposse / docker-compose.yml
Created Nov 13, 2015
GlusterFS Docker Compose sample
View docker-compose.yml
glusterfs-server:
image: rancher/glusterfs:v0.1.3
devices:
- /dev/fuse:/dev/fuse:rwm
cap_add:
- SYS_ADMIN
volumes_from:
- glusterfs-data
labels:
io.rancher.container.hostname_override: container_name
View gist:64fc8f70e419a953182e270f32647dfd
#!/bin/bash
#
# Slack Webhook notification for Turbonomic Action Scripts
#
# Use cURL to post to the Slack API
curl -X POST --data-urlencode 'payload={"channel": "#turbonomic", "username": "discohook", "text": "Move action created for "$VMT_TARGET_NAME" from "$VMT_CURRENT_NAME" to "$VMT_NEW_NAME" with action name = "$VMT_ACTION_NAME"", "icon_emoji": ":bear:"}' https://hooks.slack.com/services/YOURDEDICATEDWEBHOOKURL
# Log locally in the same folder as the action script (optional)
echo "$VMT_TARGET_NAME is moving" >> mylog.txt
@discoposse
discoposse / gist:39045a714249ca7f771c
Created Jun 3, 2014
Delete and Rebuild Keystone database
View gist:39045a714249ca7f771c
# Log in to MySQL command line as root
drop database keystone;
create database keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'KEYSTONE_DBPASS';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'KEYSTONE_DBPASS';
exit
# now from the shell
sudo su -c "keystone-manage db_sync" keystone
View Bulk Green Circle User Follow using Jive API
#!/bin/bash
# USERID is the starting number for the users to follow
# LASTUSER is your upper bound user ID number
# JIVEUSER is your Jive username
# JIVEPASS is your plaintext password
USERID=38000
LASTUSER=38010
JIVEUSER=
View PowerShell - Finding users with password expiry in under 14 days and sending an email reminder
# Requires ActiveRoles CmdLets from Quest Software (They're free and awesome) - http://www.quest.com/powershell/activeroles-server.aspx
Get-QADUser -SizeLimit 0 | Select-Object samAccountName,mail,PasswordStatus |
Where-Object {$_.PasswordStatus -ne "Password never expires" -and $_.PasswordStatus -ne "Expired" -and $_.PasswordStatus -ne "User must change password at next logon." -and $_.mail -ne $null} |
ForEach-Object {
$today = Get-Date
$logdate = Get-Date -format yyyyMMdd
$samaccountname = $_.samAccountName
$mail = $_.mail
$passwordstatus = $_.PasswordStatus
$passwordexpiry = $passwordstatus.Replace("Expires at: ","")
@discoposse
discoposse / rancher-compose.yml
Created Nov 13, 2015
GlusterFS Rancher Compose sample
View rancher-compose.yml
.catalog:
name: "GlusterFS"
version: "3.7.5-rancher1"
description: "Gluster FS (3x) replicated volume"
uuid: glusterfs-0
questions:
- variable: "VOLUME_NAME"
description: "Name to give the Gluster volume"
label: "Volume Name"
required: true