Skip to content

Instantly share code, notes, and snippets.

@firebus
firebus / spl.spl
Last active October 7, 2021 16:56
Export private KOs and output a table of cURL URLs and parameters for recreating the KOs. Derived from https://github.com/paychex/Splunk.Conf19
| union maxtime=300 timeout=300
[| rest splunk_server="local" "/servicesNS/-/-/data/ui/views" search="eai:acl.sharing=user" | eval Type="view" | fields - type description label]
[| rest splunk_server="local" "/servicesNS/-/-/data/props/calcfields" search="eai:acl.sharing=user" | eval Type="calculated fields" | fields - type field.* | rex field=title " : [^\-]+-(?<title>[^\e]+)"]
[| rest splunk_server="local" "/servicesNS/-/-/data/props/fieldaliases" search="eai:acl.sharing=user" | eval Type="field aliases" | fields - type value | rex field=title " : [^\-]+-(?<title>[^\e]+)"]
[| rest splunk_server="local" "/servicesNS/-/-/data/transforms/extractions" search="eai:acl.sharing=user" | eval Type="field transformations" | fields - type]
[| rest splunk_server="local" "/servicesNS/-/-/data/props/extractions" search="eai:acl.sharing=user" | eval Type="extractions" | rex field=title " : (?<type>(EXTRACT|REPORT))-(?<title>[^\e]+)"]
[| rest splunk_server="local" "/servicesNS/-/-/data/props/sourcetype-rename" search="eai:
class MemoryMash {
public function mash() {
str_pad('', $this->getMaxMemory());
}
private function getMaxMemory() {
$memoryLimit = ini_get('memory_limit');
if ($memoryLimit != -1) {
$memoryLimit = $this->return_bytes($memoryLimit);
} else {
@firebus
firebus / getBootie.php
Created May 29, 2012 12:05
Bootie Top 10 Download Script
<?php
// usage: `php getBootie.php <url> <album-title>`
// for a url like: http://bootiemashup.com/blog/2012/05/triple-tribute-bootie-mashup-pays-tribute-to-mca-of-beastie-boys-robin-gibb-of-bee-gees-donna-summer.html
// @see http://www.getid3.org/
require_once(dirname(__FILE__) . '/getid3/getid3.php');
$url = $argv[1];
$album_title = $argv[2];
@firebus
firebus / grep
Created March 31, 2012 04:52
Grep with a built-in exclude list
#!/bin/bash
/bin/grep $@ | /bin/grep -v svn
@firebus
firebus / NoCaptcha.php
Created March 30, 2012 15:57
NoCaptcha library for PHP forms
<?php
/**
* Provide a set of fields to filter submissions from bots without requiring
* a captcha or otherwise inconveniencing human users
*
* TODO: Be more flexible about which fields are included - by default include
* all but allow caller to specify a subset
*
* TODO: Why you gotta be so static?
@firebus
firebus / mastermind.py
Created March 21, 2012 22:07 — forked from gvx/mastermind.py
An implementation of Knuth's five-guess algorithm to solve a mastermind code [CC0]
from itertools import product
possible = [''.join(secret) for secret in product('ABCDEF', repeat=4)]
results = [(right, wrong) for right in range(5) for wrong in range(5 - right) if not (right == 3 and wrong == 1)]
def score(secret, guess):
first = len([speg for speg, gpeg in zip(secret, guess) if speg == gpeg])
return first, sum([min(secret.count(j), guess.count(j)) for j in 'ABCDEF']) - first
def solve(secrets, attemptfun, first=False):