Skip to content

Instantly share code, notes, and snippets.

Avatar
Go Phillies!

Tim Ski marshyski

Go Phillies!
View GitHub Profile
@marshyski
marshyski / consume.py
Created Apr 14, 2016
pynsq JSON example
View consume.py
## curl -d '{"test":"data","friend":"tim"}' 'http://127.0.0.1:4151/put?topic=test'
import nsq
import json
buf = []
def process_message(message):
global buf
message.enable_async()
msg = json.loads(message.body)
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
echo "vm.swappiness=0" >> /etc/sysctl.conf
echo "kernel.randomize_va_space=1" >> /etc/sysctl.conf
echo "vm.dirty_ratio=3" >> /etc/sysctl.conf
echo "vm.dirty_background_ratio=2" >> /etc/sysctl.conf
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
echo "vm.mmap_min_addr=4096" >> /etc/sysctl.conf
@marshyski
marshyski / mssql.pp
Created Nov 20, 2015
Basic SQL Install with Puppet
View mssql.pp
# Class to install SQL Server, set its configuration, create an
# instance, as well as a sample DB.
class app_sqlserver (
$source = 'F:/',
$admin_user = 'Administrator',
$db_instance = 'MYINSTANCE',
$sa_pass = 'MySecretPASSWORD',
$db_name = 'sampledb',
) {
@marshyski
marshyski / puppet-classifier-get.sh
Created Oct 23, 2015
Get All Puppet Enterprise Node Classifications
View puppet-classifier-get.sh
#!/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"
@marshyski
marshyski / puppet-classifier-post.sh
Created Oct 23, 2015
POST JSON to Puppet Enterprise Node Classifier Example
View puppet-classifier-post.sh
#!/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 PE_CERTNAME=$(puppet agent --configprint certname)
declare -x NC_CURL_OPT="-s --cacert $PE_CA --cert $PE_CERT --key $PE_KEY --insecure"
@marshyski
marshyski / git_checkout.pp
Last active Oct 15, 2015
Puppet VCS example
View git_checkout.pp
class yum_nginx_api (
$git_ver = 'latest',
$git_dir = '/opt/yum-nginx-api',
) {
# Install git client
package { 'git':
ensure => $git_ver,
}
@marshyski
marshyski / run_noop.pp
Created Sep 17, 2015
Schedule a module to run in noop mode via cron
View run_noop.pp
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 / test1.rb
Created Sep 4, 2015
Windows fact to parse file by pattern and show field by space delimiter
View test1.rb
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 Sep 4, 2015
Setup a demo env with a public Linux terminal
View public-terminal.sh
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 Aug 31, 2015
Just playing around with NFL Game Python lib
View nflgame-stuff.py
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'