Skip to content

Instantly share code, notes, and snippets.

@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'
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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',