Skip to content

Instantly share code, notes, and snippets.

View dzello's full-sized avatar
🛰️
Working from orbit

Josh Dzielak dzello

🛰️
Working from orbit
View GitHub Profile
@dzello
dzello / mod_count_check.sql
Created March 26, 2021 14:37
Proving the MOD function creates slices whose counts add up to the full count
View mod_count_check.sql
select count(*) from my_table where MOD(id, 10) = ANY('{0,1,2,3,4,5,6,7,8,9}'::int[]);
-- 3296168
select count(*) from my_table;
-- 3296168
@dzello
dzello / algolia-docsearch-snippet.html
Last active December 19, 2017 03:41
Algolia DocSearch snippet template
View algolia-docsearch-snippet.html
<!-- at the end of the HEAD -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
<!-- in the BODY -->
<input type="text" id="docsearch-input" />
<!-- at the end of the BODY -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script type="text/javascript"> docsearch({
apiKey: '### REPLACE ME ####',
View talksearch-record.json
{
"objectID": "ouyHp2nJl0I",
"id": "ouyHp2nJl0I",
"start": 828.94,
"duration": 1249,
"text": "talking about monads the only thing I'm",
"title": "Functional Go?",
"description": "Francesc discusses the feasibility and practicality of functional programming...",
"thumbnails": {
"url": "https://i.ytimg.com/vi/ouyHp2nJl0I/mqdefault.jpg",
@dzello
dzello / footer.html
Created May 18, 2016 14:25
Autocomplete blog search code for algoliasearch-jekyll plugin, see it in action on dzello.com
View footer.html
@dzello
dzello / indiana_doing_it_wrong.md
Last active August 29, 2015 14:17
On Indiana's Passing of a "Religious Freedom" Law
View indiana_doing_it_wrong.md

How sad it is, in the year 2015, to see a law passed in the United States that legalizes discrimination by religion, sexual orientation, or any other factor. This is a big step backwards for Indiana, a state already saddled with a tragic history of racism and klansmanship. While many of us are focused on brightening our shared future — a mission that calls us to highlight our similarities and embrace our differences – others remain to drive wedges between us, fearful of a future that doesn't recognize their privilege, afraid that progress may call past lives of prejudice into question.

I am a proponent of religious freedom. I am not, however, willing to accept as a religious "belief" anything that allows for discrimination and violence, physical or psychological, toward non-believers. For millennia such beliefs have only lead to hatred and war, and they still do today.

Indiana is 84% White and 80% Christian. The state legislature is 80% male. It is likely that the majority of these individuals have not expe

@dzello
dzello / query.json
Created December 28, 2014 19:57
Example post body for Keen IO query API containing a filter - https://keen.io/docs/data-analysis/post-queries/
View query.json
{
"filters" : [{
"property_name" : "price",
"operator" : "gte",
"property_value" : 1000
}]
}
@dzello
dzello / keen_client_noconflict.js
Last active December 29, 2015 21:09
Only add the Keen IO JS SDK to the page if it's not already there; otherwise configure a new client instance
View keen_client_noconflict.js
// useful if you are injecting code into 3rd party websites that may already have Keen
// this code will use the Keen SDK on the page if found, or initialize it's own otherwise.
// this approach will work in the average case, but could break if the 3rd party website
// is modifying or configuring the Keen library in an unexpected way
// a more durable approach would be to use an iFrame containing only the SDK and pass it messages
var context = this;
var myKeenClient = null;
@dzello
dzello / publish_async.rb
Created November 14, 2013 19:27
How to publish an event asynchronously from a simple ruby script using keen-gem
View publish_async.rb
require "keen"
require "em-http-request"
# make sure the environment is set up
ENV["KEEN_PROJECT_ID"] = "..."
ENV["KEEN_WRITE_KEY"] = "..."
Thread.new { EventMachine.run }
sleep 1
@dzello
dzello / PerformanceTestDrpcStream.java
Created August 19, 2013 21:41
Simple storm trident DRPC topology that spends too much time waiting for LMAX disruptor slots. Posted for the mailing list.
View PerformanceTestDrpcStream.java
package io.keen.storm.drpc.basic;
import backtype.storm.LocalDRPC;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import io.keen.base.BaseDrpcStream;
import io.keen.util.Env;
import io.keen.util.Timer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@dzello
dzello / shell-export.sh
Last active December 21, 2015 06:29
Shells and export - a quick cheat sheat / guide for beginners
View shell-export.sh
# variables
# assuming you're in a file / script...
# set a variable
$ foo=1
# prove it exists
$ echo foo