Skip to content

Instantly share code, notes, and snippets.

View spraints's full-sized avatar
🦦

Matt Burke spraints

🦦
View GitHub Profile
worker_pool 6
queue '*'
before_fork do
require File.expand_path('config/environment')
Rails.application.eager_load!
ActiveRecord::Base.connection.disconnect!
end
@spraints
spraints / application_controller.rb
Created August 14, 2013 17:45
Rails cache + dom manip testing, based on http://www.twmagic.com/misc/cache.html
# add this to app/controllers/application_controller.rb:
def cache
options = {
'no-store' => 'no-store',
'no-cache' => 'no-cache',
'zero-age' => 'max-age=0',
}
if cc = options[params[:id]]
headers['Cache-Control'] = cc
end
@spraints
spraints / 00.rb
Created June 17, 2013 23:30
Optimization doesn't always work.
require 'multi_json'
require 'stringio'
require 'zlib'
def gz(infile)
outfile = infile + '.gz'
File.open(outfile, 'w') do |f|
f << `gzip -9 -c #{infile}`
end
outfile
20:09:53 (0) [master] >>> cat
]
==
]]]]]
^[[B\\\\=]
\\\\=]
'[
'\\'\\\\
'\\;'[-0kkkkkkkkkk[i-k-=k;/. \\m[''''
@spraints
spraints / my-haunts.md
Created May 19, 2013 20:21
Places around town where you can find me. Come say hi, introduce yourself, and learn about GitHub or food.
Farmers Marketmarket at Normandy Farms, 79th and Marsh Rd, Fridays, 4-7 pm Carmel Farmers Market, Saturdays 8:00 a 11:30 am Code @ Coffee (Carmel or Fishers)
#!/bin/sh
# Make sure sudoing works first, because tcpdump is going in the background
sudo -p "Root privileges are required in order to run tcpdump. Password: " test
pcap=$TMPDIR/nethog.$$.pcap
# 10.0.1.1 is my LAN's AirPort Extreme, so it gets lots of backup traffic.
sudo tcpdump -i en0 -w $pcap not host 10.0.1.1 >&/dev/null &
tcpdump_pid=$!
@spraints
spraints / gist:5362874
Created April 11, 2013 12:09
fun with procs, blocks, and lambdas
def a
[1,2,3].each do |x|
return :a if x == 2
end
:not_a
end
def a2
block = lambda { |x| return :a if x == 2 }
[1,2,3].each(&block)
original:
T1 ----- T2 ----- T3 ----- T4
\
----- G1 ----- G2
after rcheckin, how it works now:
T1 ----- T2 ----- T3 ----- T4 ----- G1' ----- G2'
@spraints
spraints / 00-givens.cs
Last active December 14, 2015 15:59
This morning at code & coffee (http://www.meetup.com/Indianapolis-Code-and-Coffee/), we were talking about how to combine two Linq expressions together, while preserving the parse tree of both. I didn't look too hard to see if there's a built-in way to do this. If there is, I guess this was just a fun programming exercise.
// Given a class...
class Thing
{
public string Value { get; set; }
}
Error:
test: Search should find conversation with attached text. (SearchTest):
RSolr::Error::Http: RSolr::Error::Http - 500 Internal Server Error
Error: org.apache.solr.core.SolrResourceLoader.getClassLoader()Ljava/lang/ClassLoader;
java.lang.NoSuchMethodError: org.apache.solr.core.SolrResourceLoader.getClassLoader()Ljava/lang/ClassLoader;
at org.apache.solr.handler.extraction.ExtractingRequestHandler.inform(ExtractingRequestHandler.java:95)
at org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.getWrappedHandler(RequestHandlers.java:244)
at org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.handleRequest(RequestHandlers.java:231)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)