Skip to content

Instantly share code, notes, and snippets.

View joshed-io's full-sized avatar

Josh Dzielak joshed-io

View GitHub Profile
@joshed-io
joshed-io / mod_count_check.sql
Created March 26, 2021 14:37
Proving the MOD function creates slices whose counts add up to the full count
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
@joshed-io
joshed-io / algolia-docsearch-snippet.html
Last active December 19, 2017 03:41
Algolia DocSearch snippet template
<!-- 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 ####',
{
"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",
@joshed-io
joshed-io / footer.html
Created May 18, 2016 14:25
Autocomplete blog search code for algoliasearch-jekyll plugin, see it in action on dzello.com
@joshed-io
joshed-io / indiana_doing_it_wrong.md
Last active August 29, 2015 14:17
On Indiana's Passing of a "Religious Freedom" Law

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

@joshed-io
joshed-io / 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/
{
"filters" : [{
"property_name" : "price",
"operator" : "gte",
"property_value" : 1000
}]
}
@joshed-io
joshed-io / 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
// 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;
@joshed-io
joshed-io / publish_async.rb
Created November 14, 2013 19:27
How to publish an event asynchronously from a simple ruby script using keen-gem
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
@joshed-io
joshed-io / 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.
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;
@joshed-io
joshed-io / shell-export.sh
Last active December 21, 2015 06:29
Shells and export - a quick cheat sheat / guide for beginners
# variables
# assuming you're in a file / script...
# set a variable
$ foo=1
# prove it exists
$ echo foo