Skip to content

Instantly share code, notes, and snippets.

@KensoDev
KensoDev / gist:2003199
Created March 8, 2012 20:25
get shit done pomodoro integration
tell application "Terminal"
activate
do script "sudo get-shit-done work"
end tell
before(:each) do
@user = Factory(:user)
@media = Factory(:media)
@place = Factory(:hotel)
controller.stub!(:current_user).and_return(@user)
end
it "saves the newly uploaded image" do
# Force the media width and height to be nil
@media.width = nil
@KensoDev
KensoDev / cache_control.rb
Created March 19, 2012 21:50
Cache control
module CacheControl
extends self
def expire_cache_for(model, options = {})
Rails.logger.debug "+++ CACHECONTROL - Expiring cache for #{model.class} #{model.id rescue nil} with options #{options.inspect}"
model_name = model.class.name
begin
invalidator_class = "CacheControl::#{model_name}".contantize
invalidator_class.invalidate_cache(model, option)
rescue Exception => e
# Hooks into ApplicationController's write_fragment method.
# write_fragment is used for action and fragment caching.
# Create an alias method chain to call our customer method
# which stores the associated key with the tag in a
# Redis Set. Then we can expire all those keys from anywhere
# in the code using Rails.cache.delete
#
# I use alias_method_chain instead of calling 'super'
# because there is a very rare case where someone
# may have redfined 'write_fragment' in their own
it "should write to cashier when I call Rails.cache.write with tags" do
cashier.should_receive(:store_fragment).with("foo", ["some_tag"])
subject.write("foo", "bar", :tag => ["some_tag"])
end
Resque::Server.use(Rack::Auth::Basic) do |user, password|
password == "some_password"
end
mount Resque::Server, :at => "/resque"
key('⌘+enter, ctrl+enter', function(e, h){
input = $(e.target);
form = input.parents("form");
form.submit();
});
function customKeyFilter(event) {
var tagName = (event.target || event.srcElement).tagName;
return (tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
}
key.filter = customKeyFilter;
@KensoDev
KensoDev / gist:2220225
Created March 27, 2012 21:04
Recruiter reply
Hi <recruiter name here>,
Thank you for your message.
At this point in time, I am not interested in any kind of full time position.
Sincerely, <your name here>
** I usually remove the contact details I usually have in the signature**