Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / run_noop.pp
Created September 17, 2015 20:16
Schedule a module to run in noop mode via cron
class run_noop (
$git_dir = '/opt/my_puppet_module',
) {
# Install git puppet repo into git directory
vcsrepo { $git_dir:
ensure => latest,
provider => git,
source => 'https://github.com/user/my_puppet_module.git',
revision => 'master',
@marshyski
marshyski / git_checkout.pp
Last active October 15, 2015 06:08
Puppet VCS example
class yum_nginx_api (
$git_ver = 'latest',
$git_dir = '/opt/yum-nginx-api',
) {
# Install git client
package { 'git':
ensure => $git_ver,
}
@marshyski
marshyski / puppet-classifier-get.sh
Created October 23, 2015 05:22
Get All Puppet Enterprise Node Classifications
#!/bin/bash
PATH="/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin:/opt/puppet/bin:$PATH"
declare -x PE_CERT=$(puppet agent --configprint hostcert)
declare -x PE_KEY=$(puppet agent --configprint hostprivkey)
declare -x PE_CA=$(puppet agent --configprint localcacert)
declare -x NC_CURL_OPT="-s --cacert $PE_CA --cert $PE_CERT --key $PE_KEY --insecure"