Skip to content

Instantly share code, notes, and snippets.

View btelles's full-sized avatar

Bernie Telles btelles

  • Wing Aviation LLC
  • California, US
  • X @btelles
View GitHub Profile
# This Gist helps you analyze mysql slow query logs.
# This Ruby code should not be used as an example of tested,
# production ready, or idiomatic Ruby. You've been warned.
# 1. Download and extract slow logs.
# 2. Specify a directory to analyze, using Dir[] syntax:
DIRECTORY_TO_ANALYZE = "./mysql_slow_logs/2012/*/*/mysqld_slow.log"
# 3. Run the script with "ruby ./mysql_slow_log_parser.rb"
@btelles
btelles / monty_hall_simulation.rb
Last active December 17, 2015 06:29
Monty Hall Statistics simulation script.
def random_between_1_and_3
(rand * 3).ceil
end
file = File.open('results.csv', 'w')
file.puts 'car, first_choice, expose, second_choice, win, switch, switch_and_win, stay_and_win'
1_000_000.times do
@btelles
btelles / api-test-needs-custom-event.html
Created November 30, 2015 23:50
When writing a test that needs to speak to an appengine endpoint, it's difficult to make the test wait for a response from a server. I've tried a bunch of permutations on waiting for "ready" on various elements, and triggering stuff. but I keep having to go back to writing a custom event and triggering it as below. Is there an easier way to wait…
<test-fixture id="basic">
<template>
<r-api path="api.widget.list"></r-api>
</template>
</test-fixture>
<dom-module id="fake-google-api">
<template>
<iron-ajax id="widgetList"
auto
[16:44:51] Using gulpfile ~/polymer/gulpfile.js
[16:44:51] Starting 'wct:local'...
Starting Selenium server for local browsers
Selenium server running on port 40499
Web server running on port 2000 and serving from ~/polymer
chrome 46 Beginning tests via http://localhost:2000/components/polymer/generated-index.html?cli_browser_id=0
chrome 46 ✖ Test Suite Initialization
Failed to execute 'registerElement' on 'Document': Registration failed for type 'dom-module'. A type with that name is already registered.
<unknown> at <unknown> at /components/polymer/app/bower_components/polymer/polymer-micro.html:308:0