This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When you want to tail a rails log, but without the extraneous stuff, you can simply do: | |
tail -f log/production.log | grep "[/#]" | |
It will show the first and last lines of each request, plus any error stack trace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* this mapreduce pair returns all the keys of the attribute hash from all records in the system */ | |
/* the map function to return all the values of keys */ | |
function(doc) { | |
keys = {} | |
for(key in doc) { | |
if (key != "_id" && key != "_rev") { | |
keys[key] = 1 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias arc="pushd /Library/Arc3/;mzscheme -m -f as.scm; popd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeMailer < ActionMailer::Base | |
# assumes that there's a file named pretty_template.html.erb in app/views/some_mailer | |
def html_email_with_attachment(email_address, msg) | |
recipients [email_address] | |
from "hello@world.com" | |
subject "This is an html email with an attachment" | |
# have to set content_type explicitly | |
content_type "multipart/alternative" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<% if @messages.empty? %> | |
There are no messages | |
<% else %> | |
<% @messages.each do |m| %> | |
<li><%= m.body %></li> | |
<% end %> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<% if @messages.each do |m| %> | |
<li><%= m.body %></li> | |
<% end.empty? %> | |
<li>There are no messages</li> | |
<% end %> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index | |
render :update do |page| | |
page.inner_html(params["target"], "Hello world!") | |
page.effect(:highlight, params["target"]) | |
# and other page effects | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1><%= @article.title %></h1> | |
<p> | |
<%= @article.body %> | |
</p> | |
<p id="comments_list" style="display: none"> | |
</p> | |
<span id="comments_indicator" style="display: none"> | |
<%= image_tag "indicator.gif" %> | |
</span> | |
<%= link_to_remote "show all comments", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1><%= @article.title %></h1> | |
<p> | |
<%= @article.body %> | |
</p> | |
<p id="comments_list" style="display: none"> | |
</p> | |
<span id="comments_indicator" style="display: none"> | |
<%= image_tag "indicator.gif" %> | |
</span> | |
<a href="#" class="get" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$("a.get").click( | |
function() { | |
url = $(this).attr("data-href"); | |
target = $(this).attr("data-target"); | |
$(target).html("Loading..."); | |
$.get(url, function(data) { | |
$(target).html(data); | |
}); | |
}); |
OlderNewer