Skip to content

Instantly share code, notes, and snippets.

View tcotav's full-sized avatar

James Francis tcotav

View GitHub Profile
@tcotav
tcotav / gist:5374588
Created April 12, 2013 19:46
gitconfig aliases
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
tree = log --graph --decorate --pretty=oneline --abbrev-commit
lol = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%cr)%C(reset) %C(white)%s%C(reset) %C(bold white)— %cn%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
unstage = reset HEAD --
remote_file distzipexe do
  source node['drupal']['windows']['sqlserv-driver']['source']
  checksum node['drupal']['windows']['sqlserv-driver']['checksum']
  notifies :run, 'windows_batch[open-sqlserv-driver]', :immediately
  notifies :run, 'windows_batch[move-sqlserv-plugin]', :immediately
end

# unroll and dump in same dir
@tcotav
tcotav / unzip.ps1
Created July 22, 2013 22:48
powershell only unzip (silent)
$shell_app=new-object -com shell.application
$filename = "vmwaretools.zip"
$zip_file = $shell_app.namespace((Get-Location).Path + "\$filename")
$destination = $shell_app.namespace((Get-Location).Path)
$destination.Copyhere($zip_file.items(), 20)
$shell = new-object -com shell.application
$zip = $shell.NameSpace(“C:\howtogeeksite.zip”)
foreach($item in $zip.items())
{
$shell.Namespace(“C:\temp\howtogeek”).copyhere($item)
}
@tcotav
tcotav / eping.py
Created August 25, 2013 22:06
python ping -- put into cron, every minute
#!/usr/bin/env python
import subprocess
import datetime
import time
from os.path import expanduser
home = expanduser("~")
today=datetime.date.today()
@tcotav
tcotav / chef powershell snippet.ps1
Created August 26, 2013 19:06
disable netbios over tcpip
powershell "disable netbios over tcpip" do
code <<-EOH
wmic /interactive:off nicconfig where TcpipNetbiosOptions=0 call SetTcpipNetbios 2
wmic /interactive:off nicconfig where TcpipNetbiosOptions=1 call SetTcpipNetbios 2
EOH
end
@tcotav
tcotav / gist:7489860
Created November 15, 2013 19:08
Recipe snippet to join a host to AD via Powershell using Chef (Chef::Mixin::PowershellOut)
#
# set this up for reboot should we join domain successfully
#
windows_reboot 5 do
reason 'Reboot after joining AD'
action :nothing
end
#
# import mixin powershellout here
@tcotav
tcotav / ohai_disable_windows
Last active December 28, 2015 21:39
Ohai Plugin config to disable irrelevant or poorly performing plugins on windows
Ohai::Config::disabled_plugins= [
#
# add to client.rb file -- c:\chef\client.rb
#
# ref: http://www.slideshare.net/opscode/chef-conf-windowsdougireton # slide 30
# ohai plugins that have poor perf or are irrelevant to windows
#
"c", "cloud", "ec2", "rackspace", "eucalyptus", "command", "dmi", "dmi_common",
"erlang", "groovy", "ip_scopes", "java", "keys", "lua", "mono", "network_listeners",
"passwd", "perl", "php", "python", "ssh_host_key", "uptime", "virtualization",
@tcotav
tcotav / gist:7948702
Created December 13, 2013 18:18
dynamically adding a variable to an object (for tagging source, for example)

adding a variable into the object

Here's now we dynamically add that variable/accessor on an already created object:

def tagList(item_list)
item_list.each do |item|
  item.class.module_eval { attr_accessor :source_type}
  item.source_type = some_source_type_A
done
itemlist
@tcotav
tcotav / Vagrantfile
Created March 6, 2014 02:15
Vagrantfile for test local salt + minion
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos6.4"
# Every Vagrant virtual environment requires a box to build off of.
config.vm.define "master", primary: true do |box|
box.vm.hostname = "salt"
box.vm.network "public_network"
box.vm.network "private_network", ip: "192.168.56.160"