Skip to content

Instantly share code, notes, and snippets.

View mikesparr's full-sized avatar

Mike Sparr mikesparr

  • Montana, USA
View GitHub Profile
@mikesparr
mikesparr / librets.rb
Last active August 29, 2015 14:09
Homebrew librets 1.6.1 formula (mine using Py and Java bindings)
require 'formula'
class Librets < Formula
homepage 'http://code.crt.realtors.org/projects/librets'
url 'https://github.com/NationalAssociationOfRealtors/libRETS/archive/1.6.1.tar.gz'
sha1 '0078524e12ced0ac98c472c8a9e69c8d12d24546'
depends_on 'swig'
depends_on 'boost'
depends_on 'autoconf'
@mikesparr
mikesparr / test_api_rate_limit
Created June 4, 2015 22:23
Goomzee API rate limiting tests
Mikebook-Pro-SSD:local mike$ curl -i -X GET --url http://localhost:8000/hello
HTTP/1.1 200 OK
Date: Thu, 04 Jun 2015 22:17:29 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 23
Connection: keep-alive
X-RateLimit-Limit: 5
X-RateLimit-Remaining: 1
X-Powered-By: Turbo Hamsters
@mikesparr
mikesparr / Constants.swift
Last active March 18, 2018 00:20
Swift IOS Architecture Quick Start
//
// Constants.swift
// Goomzee
//
// Created by Michael Sparr on 11/11/15.
//
import Foundation
// MARK: - Environment
@mikesparr
mikesparr / librdkafka.rb
Created May 26, 2016 20:37
Updated Homebrew formula for librdkafka so you can install confluent-kafka Python client via PIP (requires > 0.9.01)
class Librdkafka < Formula
desc "The Apache Kafka C/C++ library"
homepage "https://github.com/edenhill/librdkafka"
url "https://github.com/edenhill/librdkafka/archive/0.9.1.tar.gz"
sha256 "5ad57e0c9a4ec8121e19f13f05bacc41556489dfe8f46ff509af567fdee98d82"
#bottle do
# cellar :any
# sha256 "63b97ce272e07632f10e33a7963f291bf1a0457f0823d4ab4bdce01eb3e65bbe" => :el_capitan
# sha256 "ffa2e218bbd43230c3a999b3adb7f4e08f132a15fa43ae552dd7692874834f91" => :yosemite
@mikesparr
mikesparr / stream_producer.py
Last active December 17, 2021 18:09
Producer helper class using Confluent Kafka Python
#!/usr/bin/env python
# encoding: utf-8
"""
stream_producer.py
Created by Michael Sparr on 2016-01-11.
Copyright (c) 2016 Goomzee Corporation. All rights reserved.
"""
import sys
@mikesparr
mikesparr / stream_consumer.py
Created July 5, 2016 20:04
Consumer helper class using Confluent Kafka Python library
#!/usr/bin/env python
# encoding: utf-8
"""
stream_consumer.py
Created by Michael Sparr on 2016-01-17.
Copyright (c) 2016 Goomzee Corporation. All rights reserved.
"""
import sys
@mikesparr
mikesparr / local_storage_fallback.js
Last active February 5, 2018 21:59
Local storage with Cookie fallback
/**
* Simple localStorage with Cookie Fallback
*
* USAGE:
* ----------------------------------------
* Set New / Modify:
* store('my_key', 'some_value');
*
* Retrieve:
* store('my_key');
@mikesparr
mikesparr / cleanup_docker.sh
Created March 5, 2018 23:01
Docker batch delete local images and containers
#!/usr/bin/env bash
# optionally add --force flag
# stop all containers
echo "Stopping all containers"
docker ps -a | awk -F ' ' '{print $1}' | xargs docker stop
# remove all containers
echo "Removing all containers"
@mikesparr
mikesparr / pure_javascript_hash.js
Created May 18, 2018 20:23
Function to create unsigned int hash of a string in pure JS
const hash = (str) => {
let val = 0;
const strlen = str.length;
if (strlen === 0) { return val; }
for (let i = 0; i < strlen; ++i) {
const code = str.charCodeAt(i);
val = ((val << 5) - val) + code;
val &= val; // Int32
@mikesparr
mikesparr / test-app.yaml
Last active April 29, 2020 22:49
Article content for InitContainers
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: test-app
name: test-app
spec:
replicas: 1
selector:
matchLabels: