Skip to content

Instantly share code, notes, and snippets.

@Resisty
Resisty / common.yaml
Last active December 22, 2015 05:58
Brian is bad at hiera. Master can lookup data items, client can't.
mydataitem:
- username: "butts"
- pass: "lol"
# You have a proprietary file system type (myfs) with a custom set of command line tools.
# You need to clean up all files with a modification time older than 24 hours.
# Any directories left empty as a result of this cleanup should also be removed as well.
#
# The command to list a directory is 'myfs ls'
# The command to list a directory recursively is 'myfs lr'
# The command to delete a file or directory is 'myfs rm'
#
# The root uri of the filesystem is 'myfs://myserver/'
#
define sudoers::add_sudoer (
$theguy = $name,
$pass = '',
# variables here
) {
realize(Concat['/etc/sudoers'])
concat::fragment { $theguy:
target => '/etc/sudoers',
content => "${theguy} ALL=(ALL:ALL) NOPASSWD:ALL",
order => 90,
@Resisty
Resisty / gsearch.rb
Created March 12, 2015 04:55
Google Api Client test trying to get random result from next pages
require 'google/api_client'
def gsearch(searchstr, ftype: 'jpg', start: nil, depth: nil)
puts "Entering function with depth: \"#{depth}\""
client = Google::APIClient.new(:application_name => 'IRC Bot Search Helper',
:application_version => '0.0.1',
:client_id => cid,
:client_secret => cs,
:authorization => nil)
search = client.discovered_api('customsearch')
class BaseModel(Model):
class Meta:
database = psql_db
# There can be a lot of Alerts that come in.
# Each Alert can "have" many users
class Alert(BaseModel):
alertId = CharField(unique = True, primary_key = True)
alertLink = Charfield(unique = True)
startTime = TimeField()
def dice_roll(dicestr)
sets = dicestr.scan(/[0-9]+d[0-9]+/)
modifier = dicestr.scan(/for \w+ modifier ([+-])(\d+)/)
if !modifier.empty?
puts "Modifier is NOT empty\n\n"
if modifier[0][0] == '-'
mod = "#{modifier[0][0]}#{modifier[0][1]}".to_i
else
mod = "#{modifier[0][1]}".to_i
end
def getFromSite(self, search, contentonly = False, thingtype = 'contents'):
thingtypes = ['contents', 'places', 'people']
if thingtype not in thingtypes:
thingtype = 'contents'
query = 'https://example.com/api/core/v3/search/{0}?filter=search("{1}")'
setquery = query.format(thingtype, search)
returnedpage = requests.get(setquery,
auth = (self.settings['user'], self.settings['pass']),
headers = {'content-type': 'application/json'})
jsondata = ''.join(returnedpage.text.split('\n')[1:])
#!/usr/bin/env python
import ldap
import sys
import threading
import argparse
import signal
import time
import os
import Queue
@Resisty
Resisty / yamlint.py
Created February 11, 2016 00:48
Yam lint
#!/usr/bin/python
import sys
try:
import yaml
except:
print 'You must first install pyyaml: `pip install pyyaml`'
sys.exit(1)
from argparse import ArgumentParser
@Resisty
Resisty / __init__.py
Last active March 1, 2016 03:26
Hashtag Enterprise...ish
# modularize