Skip to content

Instantly share code, notes, and snippets.

@jeremyhaile
jeremyhaile / gist:e7b6258480c9b82d1ed2
Created December 11, 2015 15:21
Varnish purge all from cache
varnishadm "ban.url ."
@jeremyhaile
jeremyhaile / gist:f595165dfb641f26a5f1
Created June 24, 2015 14:05
Build mongo condition hash recursively given a set of ranges and values
def build_agg_hash(condition_hash)
return '' unless condition_hash && condition_hash.length > 0
range, value = condition_hash.shift
{'$cond' => {
'$if' => {'$gte' => range.first, '$lt' => range.last},
'$then' => value,
'$else' => build_agg_hash(condition_hash)
}}
end
@jeremyhaile
jeremyhaile / gist:927f26dcdecbb56fb43c
Created April 28, 2015 15:06
Sublime Text 3 Settings
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Made of Code.tmTheme",
"detect_indentation": false,
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
PING yahoo.com (206.190.36.45): 56 data bytes
64 bytes from 206.190.36.45: icmp_seq=0 ttl=49 time=87.727 ms
64 bytes from 206.190.36.45: icmp_seq=1 ttl=49 time=82.465 ms
64 bytes from 206.190.36.45: icmp_seq=2 ttl=49 time=82.931 ms
64 bytes from 206.190.36.45: icmp_seq=3 ttl=49 time=134.212 ms
64 bytes from 206.190.36.45: icmp_seq=4 ttl=49 time=81.815 ms
64 bytes from 206.190.36.45: icmp_seq=5 ttl=49 time=83.399 ms
64 bytes from 206.190.36.45: icmp_seq=6 ttl=49 time=84.119 ms
64 bytes from 206.190.36.45: icmp_seq=7 ttl=49 time=84.665 ms
64 bytes from 206.190.36.45: icmp_seq=8 ttl=49 time=80.456 ms
PING yahoo.com (206.190.36.45): 56 data bytes
64 bytes from 206.190.36.45: icmp_seq=0 ttl=49 time=717.221 ms
64 bytes from 206.190.36.45: icmp_seq=1 ttl=49 time=134.367 ms
64 bytes from 206.190.36.45: icmp_seq=2 ttl=49 time=87.870 ms
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
64 bytes from 206.190.36.45: icmp_seq=3 ttl=49 time=3834.620 ms
64 bytes from 206.190.36.45: icmp_seq=4 ttl=49 time=2845.990 ms
64 bytes from 206.190.36.45: icmp_seq=5 ttl=49 time=1846.129 ms
Error Page Exception
SRVE0260E: The server cannot use the error page specified for your application to handle the Original Exception printed below.
Original Exception:
Error Message: JSPG0227E: Exception caught while translating /WEB-INF/jsp/common/layouts/landingLayout.jsp: java.lang.reflect.InvocationTargetException
Error Code: 500
Target Servlet: /WEB-INF/jsp/common/layouts/landingLayout.jsp
@jeremyhaile
jeremyhaile / gist:1718726
Created February 1, 2012 19:16
Kill Postgres connections prior to rake db:drop
task :kill_postgres_connections => :environment do
db_name = ActiveRecord::Base.configurations[Rails.env.to_s]['database']
raise "No database name found in #{Rails.env} configuration." if db_name.nil?
sh = <<EOF
ps xa \
| grep postgres: \
| grep #{db_name} \
| grep -v grep \
| awk '{print $1}' \
| xargs kill
@jeremyhaile
jeremyhaile / gist:1633467
Created January 18, 2012 15:16
Quiet Rails 3.1 asset logger
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets
@jeremyhaile
jeremyhaile / Android Haml
Created April 7, 2011 15:08
Example of an android XML file in HAML
!!! XML
- xmlns = {"xmlns:android" => "http://schemas.android.com/apk/res/android"}
- id = "android:id"; width = "android:layout_width"; height = "android_layout_height"; text = "android:text"; orientation = "android:orientation"
%LinearLayout{ xmlns, width => "fill_parent", height => "fill_parent", orientation => "vertical" }
%TextView{ id => "@+id/text", width => "wrap_content", height => "wrap_content", text => "Hello, I am a TextView" }
%Button{ id => "@+id/button", width => "wrap_content", height => "wrap_content", text => "Hello, I am a Button" }