Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"sync"
)
func main() {
// Create our stream of ints up to the threshold
// This channel is closed by the generate goroutine
### Keybase proof
I hereby claim:
* I am geoffgarside on github.
* I am geoffgarside (https://keybase.io/geoffgarside) on keybase.
* I have a public key ASDcl8vtsaJfBRxCTO2u1zhKNs9M3cCs4e2CoV1fZg0r2go
To claim this, I am signing this object:
@geoffgarside
geoffgarside / AESDecrypt.ps1
Created September 14, 2017 18:04
Powershell Encryption, Compression, Base64 Encoding with C# Streams
#!/usr/bin/env powershell
param ( [String]$InputFile, [String]$OutputFile, [String]$Password="pa55w0rd" )
$InputStream = New-Object IO.FileStream($InputFile,
[IO.FileMode]::Open, [IO.FileAccess]::Read)
$OutputStream = New-Object IO.FileStream($OutputFile,
[IO.FileMode]::Create, [IO.FileAccess]::Write)
# Read the Salt
@geoffgarside
geoffgarside / [email protected]
Created December 1, 2016 13:25
Sphinx v2.0.6 legacy brew formula
class SphinxAT206 < Formula
homepage 'http://www.sphinxsearch.com'
url 'http://sphinxsearch.com/files/sphinx-2.0.6-release.tar.gz'
sha256 'de943c397efda706661b3a12e12e9f8cc8a03bf6c02c5a6ba967a06384feede2'
head 'http://sphinxsearch.googlecode.com/svn/trunk/'
option 'mysql', 'Force compiling against MySQL'
option 'pgsql', 'Force compiling against PostgreSQL'
option 'id64', 'Force compiling with 64-bit ID support'
---
hosts: server
tasks:
- name: create my.cnf file
copy: >
src=my.cnf dest=/var/db/mysql/my.cnf
owner=mysql group=mysql mode=0644
force=no
- name: configure my.cnf
#!/bin/sh
#
# PROVIDE: gitlab_ci_runner
# REQUIRE: networking syslog
# KEYWORD: shutdown
. /etc/rc.subr
name="gitlab_ci_runner"
rcvar="${name}_enable"
(function() {
/* First try to handle pages which are actually raw text of the email.
Extract the HTML part and replace page with it */
var orig_html = document.getElementsByTagName('html')[0].textContent;
var extracted_html = orig_html;
/* Try splitting it up if it's actually the multipart email. Otherwise, work
on the document itself, leaving the orig_html in place */
var boundary_pattern = '--===============';
while (extracted_html.indexOf(boundary_pattern) != -1) {
var next_boundary = extracted_html.indexOf(boundary_pattern);
---
thing_server: 192.168.0.88
client_thing::thing_server: "%{hiera('thing_server')}"
other_thing::thing_server: "%{hiera('thing_server')}"
@geoffgarside
geoffgarside / gist:d4936c241afacf08a9f2
Created March 24, 2015 09:32
Faster Redis mass key deletion
redis-cli --raw --scan --pattern "*" | awk '{ printf("*2\r\n$3\r\nDEL\r\n$%d\r\n%s\r\n", length($0), $0); }' > tmpfile.txt
cat tmpfile.txt | redis-cli --pipe
@geoffgarside
geoffgarside / exim-queue-auth
Created September 13, 2014 10:15
Ruby script to return Exim Queue IDs of messages with a given SMTP Auth value
#!/usr/bin/env ruby
INPUT_DIR = '/var/spool/exim/input/'
AUTH_ID = '-auth_id '
auth_id = ARGV[0]
if auth_id.nil? || auth_id == ""
puts "Usage: #{$0} auth_id"
exit