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 / chrome_catch.js
Created August 26, 2011 06:09
Interesting Chrome behavior in catch block
(function(){ with(this) {
function pow() {
var foo = "cow", bar;
try {
foo = bar;
throw "meh";
} catch (e2) {
foo = bar; //breaks in chrome with ender + jaaulde (line 2518)
//foo = eval("bar"); //amazingly this works though, and debugger ok too
@joshed-io
joshed-io / com.darkice.plist
Created November 21, 2012 18:11
launchd plists for Icecast, Darkice, Jack Audio, and Github's Play
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.darkice</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
@joshed-io
joshed-io / README.html
Created September 27, 2011 23:15
Edit and preview your Github README.md locally
<!-- single file version -->
<!DOCTYPE html>
<html>
<head>
<link href="http://a248.e.akamai.net/assets.github.com/stylesheets/bundle_github.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="site">
<div id="slider">
<div class="frames">
@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 / 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 / apple_store_ufo_snowflake_upside_down.rb
Last active August 11, 2019 15:03
Run this on a handful of macs at the Apple Store and then shout "We've been hacked!"
while true do print "[ **** ] #{" "*rand(50)} "; sleep (rand(50.0).to_f/1000.0) end
@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 / test_party.rb
Created August 23, 2011 18:19
Use httparty with rspec and capybara
# Simple demonstration of using httparty in an rspec test suite
# capybara's not required, but if you're otherwise using a capybara
# acceptance test suite this method complements the other drivers
# in your suite such as rack test, selenium or mechanize.
# Specifically - selenium is slow, rack test doesn't work remotely,
# and mechanize doesn't work well with pages that have AJAX/JS DOM manipulation
# Sometimes an old school get or post is what you need
# fwiw my use case for this is an rspec-driven performance test
@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;