Skip to content

Instantly share code, notes, and snippets.

@marshyski
marshyski / puppet-classifier-post.sh
Created October 23, 2015 05:21
POST JSON to Puppet Enterprise Node Classifier Example
#!/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 / 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"
@marshyski
marshyski / mssql.pp
Created November 20, 2015 16:01
Basic SQL Install with Puppet
# 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 / Vagrantfile
Last active April 14, 2016 17:25
My Stack
# -*- 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 / consume.py
Created April 14, 2016 17:18
pynsq JSON example
## 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)
@marshyski
marshyski / sqs-reader.py
Created April 21, 2016 15:01
Just a simple SQS reader
import boto.sqs
import time
conn = boto.sqs.connect_to_region("us-east-1")
q = conn.create_queue("myqueue")
while(True):
for m in q.get_messages():
print m.get_body()
q.delete_message(m)
@marshyski
marshyski / luajit-luarocks-osx.sh
Last active March 20, 2019 21:31
LuaJIT and luarocks on Mac OS X El Capitan
# This is to install both on OS X if you don't want to use homebrew
# xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
xcode-select --install
curl -O http://luajit.org/download/LuaJIT-2.0.4.zip
unzip LuaJIT-2.0.4.zip
cd LuaJIT-2.0.4
make && make install
curl -O http://keplerproject.github.io/luarocks/releases/luarocks-2.3.0.tar.gz
@marshyski
marshyski / lua-randoms.sh
Created May 12, 2016 03:49
Random Lua installs
luarocks install lua-requests CRYPTO_INCDIR='/usr/local/Cellar/openssl/1.0.2g/include' OPENSSL_INCDIR='/usr/local/Cellar/openssl/1.0.2g/include'
#!/bin/bash
NAME=project
WORKERS=`lscpu | grep ^'CPU(s)' | awk '{ print $2 }'`
DEPLOY_DIR=./
if [[ `grep ^nginx /etc/passwd` = "" ]]; then
if [[ `grep ^www-data /etc/passwd` = "" ]]; then
GUN_USER=$USER
fi
server {
listen 80;
server_name 54.213.202.21;
location ~ /(.git|.svn|README.md) {
deny all;
log_not_found off;
access_log off;
return 404;
}