Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@marshyski
marshyski / test1.rb
Created September 4, 2015 07:11
Windows fact to parse file by pattern and show field by space delimiter
Facter.Add(:test1) do
confine :kernel => 'Windows'
setcode do
powershell = 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe'
test1 = 'Get-Content C:\test.txt | Select-String -Pattern "test1" - SimpleMatch | foreach { $_.ToString().split(" ")[1]}'
Facter::Util::Resolution.exec(%Q{#{powershell} -command "#{test1}"})
end
end
# Below is example of file
@marshyski
marshyski / public-terminal.sh
Last active September 4, 2015 07:05
Setup a demo env with a public Linux terminal
cd /root
yum install -y screen
wget https://dl.ngrok.com/ngrok_2.0.19_linux_amd64.zip
unzip ngrok_2.0.19_linux_amd64.zip
wget https://github.com/yudai/gotty/releases/download/v0.0.10/linux_amd64.tar.gz
tar -zxvf linux_amd64.tar.gz
nohup /root/gotty -c marshyski:SuperPowers123 -p 9000 screen -S demo &
#/root/gotty -p 9000 -w screen -S demo #If you want users to interact with your session
#/root/ngrok update
/root/ngrok http 9000
@marshyski
marshyski / nflgame-stuff.py
Created August 31, 2015 01:25
Just playing around with NFL Game Python lib
import nflgame
games = nflgame.games(2014, week=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])
#games = nflgame.games(2015, kind='PRE')
players = nflgame.combine_game_stats(games)
print "\n Top 10 Rushing TDS \n"
for p in players.rushing().sort('rushing_tds').limit(10):
msg = '%s %d carries for %d yards and %d TDs'
@marshyski
marshyski / init.pp
Last active November 20, 2015 18:00
class windows_baseline {
# Create directories
file {
[
'c:\temp',
'c:\test',
]:
ensure => directory,
owner => 'Administrator',
@marshyski
marshyski / webstarterkit.sh
Created June 7, 2015 04:32
Get started with Google's Web Starter Kit on Mac OS X & Homebrew
#!/bin/bash
# ./webstarterkit.sh project_name
# Need Homebrew installed
# ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
if [[ $1 == "" ]]; then
echo "Specify project name: $0 project_name" && echo
exit 1
fi
@marshyski
marshyski / puppet-jenkins-job.sh
Created June 2, 2015 18:59
Puppet Lint, Parser Validate, Noop and Add Header
PUPPET=/usr/local/bin/puppet
LINT=/usr/local/bin/puppet-lint
for x in `find . -iname *.pp`; do echo $x ; ${LINT} --no-2sp_soft_tabs-check --no-80chars-check --no-autoloader_layout-check -f $x \
--log-format "%{path}:%{line}:%{check}:%{KIND}:%{message}" ;\
echo "";\
done
for x in `find . | grep '.svn\|.git'`; do rm -rf $x ; done
@marshyski
marshyski / build-plural.sh
Created May 1, 2015 00:33
Jenkins Build for Plural
rm -rf $WORKSPACE/*
export GOPATH=$WORKSPACE/
export PATH=$PATH:/usr/local/bin
go get github.com/spf13/viper
go get github.com/shirou/gopsutil
go get github.com/dustin/go-humanize
go get github.com/fsouza/go-dockerclient
go get github.com/drael/GOnetstat
@marshyski
marshyski / build-gofile.sh
Last active August 29, 2015 14:20
Build a Gofile for go-getter
# If you have an existing go project
# cd into src and run below command
cd $GOPATH/src && for x in `find github.com | grep '.git/refs/heads/master'`; do echo "`echo $x | awk -F'/.git' '{print $1}'` `cat $x`"; done
@marshyski
marshyski / getinfo.sh
Last active August 29, 2015 14:19
System Info RHEL/CentOS 7
#!/bin/bash
env && echo
runlevel && echo
hostname -f && echo
cat /etc/hosts && echo
@marshyski
marshyski / wait_https.py
Created April 20, 2015 17:56
Wait for website listening on port 443 to become available
import configuration as config
from subprocess import call
import requests
import time, socket
''' Turn off SSL errors '''
requests.packages.urllib3.disable_warnings()
''' Wait for port 443 is listening '''
while True: