Skip to content

Instantly share code, notes, and snippets.

View chendo's full-sized avatar

chendo chendo

View GitHub Profile

CAXBasicSearchEngine

2012-12-24 11:19:26.378 CAXElement[24751:1e03] Timer for Enumeration: 0.056977s (0.000183s each for count 312, 5475.847230/s)
2012-12-24 11:19:26.675 CAXElement[24751:4703] Results: 25
2012-12-24 11:19:26.675 CAXElement[24751:4703] Results Count: 25
2012-12-24 11:19:26.675 CAXElement[24751:4703] Timer for Search: 0.297275s (0.000953s each for count 312, 1049.532079/s)
2012-12-24 11:19:26.676 CAXElement[24751:4703] Timer for Enumeration and Search: 0.355207s (0.001138s each for count 312, 878.360562/s)
@chendo
chendo / gist:4123532
Created November 21, 2012 07:10
WillPaginate::Collection and RSpec's =~ operator fix
# Seeing really confusing RSpec output like this?
# Failure/Error: obj.will_paginated_array.map(&:id).should =~ [foo.id, bar.id]
# expected: [1, 2]
# got: [1, 2] (using =~)
# (WillPaginate::Collection#map returns WillPaginate::Collection instance)
# This is due to how OperatorMatcher simply does a lookup of the class of the actual
# result rather and checking a hash rather than using #is_a?(klass)
#
# This snippet below will make it work again.
@chendo
chendo / 0-readme.md
Created November 13, 2012 03:33
Fast require patch for 1.9.3-p327
@chendo
chendo / elasticsearch.yml
Created October 8, 2012 05:12
Use mmapfs in ElasticSearch
index:
store:
type: mmapfs
fs:
mmapfs:
enabled: true
@chendo
chendo / gist:2411426
Created April 18, 2012 06:18
Super useful NewRelic custom view to look at view performance
You want to look at the top entries in the next two tables to reduce overall view rendering time. Cache or optimise.
{% line_chart regexp:'View/.*/Partial' title:'Total partial time' value:total_value %}
{% line_chart regexp:'View/.*/Rendering' title:'Total view render time' value:total_value %}
<hr />
{% line_chart regexp:'View/.*/Partial' title:'Slowest Partial' value:average_response_time %}
@chendo
chendo / gist:2411378
Created April 18, 2012 05:59
New Relic Custom View for super useful DB stats
{% compare_with_yesterday_and_last_week_chart metric:'ActiveRecord/find' title:'ActiveRecord Find Response time' value:average_response_time %}
{% compare_with_yesterday_and_last_week_chart metric:'ActiveRecord/create' title:'ActiveRecord Create Response time' value:average_response_time %}
{% compare_with_yesterday_and_last_week_chart metric:'ActiveRecord/save' title:'ActiveRecord Save Response time' value:average_response_time %}
{% compare_with_yesterday_and_last_week_chart metric:'ActiveRecord/destroy' title:'ActiveRecord Destroy Response time' value:average_response_time %}
{% line_chart value:call_count regexp:'Database/SQL/.*' title:'SQL Throughput' %}
@chendo
chendo / docstrings.rb
Created March 21, 2012 11:31
Python-like docstrings in Ruby!
class DocStrings
def docstrings!
"""
This is a docstring that's syntactically valid!
It'll do multiple lines!
"""
end
def single_line_docstring
"""Single line docstring!"""
def is_prime?(number)
return false if number == 2
return false if (number % 2).zero?
i = 3
while i * i < number
return false if (number % i).zero?
i += 2
end
true
end
require 'benchmark'
C = 100
Benchmark.bm do |x|
x.report do
C.times do
`pbpaste`
end
end
x.report do
@chendo
chendo / gist:1597354
Created January 11, 2012 23:05
Wireless network details for Niseko
As of Jan 2011
DownTownCafe: dcafe - shitty
Le Buffalo: cozy1 - alright
linksys (near Le Buffalo, same network): no pass - pretty good (17mbit synchronous)
nisekopizza: nisekopizza111 - meh
abucha: none - 7mbit synchronous
Nisade: nisadetama/2010