Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

John http://www.red91.com

« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS 

nginx expires config

  location ~* ^.+\.(js|css|php|jpg|jpeg|gif|png|pdf|zip|rar)$ {
    root   /var/www/apps/myapp/public;
    access_log   off;
    expires      7d;
  }

nginx gzip config

  # output compression saves bandwidth 
  gzip              on;
  gzip_proxied      any;
  gzip_http_version 1.1;
  #gzip_min_length   1100;
  gzip_comp_level   5;
  #gzip_buffers      4 8k;
  gzip_types        text/plain text/html text/xml text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/atom+xml;
  #gzip_vary        on;
  #gzip_disable     "MSIE [1-6]\.";

rails sendmail settings

config.action_mailer.raise_delivery_errors = true
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.sendmail_settings = {
    :location       => '/usr/sbin/sendmail',
    :arguments      => '-i -t'
}

record grouping

@users = User.find(
  :all, 
  :select => "MONTH(created_at) as month, YEAR(created_at) as year, COUNT(*) AS records",
  :conditions => ["admin = 0'"], 
  :group => "year, month")

<% for @user in @users %>
  <%=@user.month%>
  <%=@user.year%>
  <%=@user.records%>
<% end %>

date_select conversion

function to convert a value from a date_select into a more sql-friendly value

<%=date_select(:date,'',:start_year => 1950,:include_blank => false, :default => { :year => '1970' })%>

def convert_date(obj) 
  return “#{obj[‘(1i)’]}-#{obj[‘(2i)’]}-#{obj[‘(3i)’]}” 
end
« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS