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
scala> val src = "\n\t \t\nta\t\nsk: dupa\n\tdupa2" | |
src: java.lang.String = | |
ta | |
sk: dupa | |
dupa2 | |
scala> src.replaceAll("""[\n\t ]*(\w+)[\n\t]*(\w+): (\w+)([\n\t])+(\w+)""", """$1$2: $3$4$5""") | |
res1: java.lang.String = task: dupa dupa2 |
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
ActionView::TemplateError (undefined method `order_number' for []:Array) on line #5 of app/views/previous_orders/show.html.erb: | |
2: | |
3: <h3 class="din">Details</h3> | |
4: <p> | |
5: <strong>Order number</strong>: <%= @previous_order.order_number %><br /> | |
6: <strong>Account code</strong>: <%= @previous_order.account_number %><br /> | |
7: <strong>Your reference</strong>: <%= @previous_order.customer_order_reference %><br /> | |
8: <strong>Date</strong>: <%= @previous_order.date.to_formatted_s(:ddmmyyyy) %><br /> | |
app/views/previous_orders/show.html.erb:5 |
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
require 'geoip' | |
module Rack | |
# Rack::GeoIPCountry uses the geoip gem and the GeoIP database to lookup the country of a request by its IP address | |
# The database can be downloaded from: | |
# http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz | |
# | |
# Usage: | |
# use Rack::GeoIPCountry, :db => "path/to/GeoIP.dat" | |
# |
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 create | |
@notice = Notice.new(params[:notice]) | |
@user = ????????????????? # musisz to ustawic, poczytaj o acts_as_authentic | |
@notice.author = @user.name + ' ' + @user.surname | |
if @notice.save | |
flash[:notice] = 'Saved OK' | |
redirect_to "cokolwiek" | |
else | |
flash[:error] = "Problem etc." | |
render :action => 'new' |
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
in themes/default/assets/_attachment.html: | |
I replaced this: | |
<% available_files = Array.new | |
available_files << @asset.default_attachment.filename.gsub(/^[^.]+\./,'').upcase | |
@asset.other_attachments.each do |attachment| | |
available_files << attachment.filename.gsub(/^[^.]+\./,'').upcase | |
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
# * +convert_options+: When creating thumbnails, use this free-form options | |
# field to pass in various convert command options. Typical options are "-strip" to | |
# remove all Exif data from the image (save space for thumbnails and avatars) or | |
# "-depth 8" to specify the bit depth of the resulting conversion. See ImageMagick | |
# convert documentation for more options: (http://www.imagemagick.org/script/convert.php) | |
# Note that this option takes a hash of options, each of which correspond to the style | |
# of thumbnail being generated. You can also specify :all as a key, which will apply | |
# to all of the thumbnails being generated. If you specify options for the :original, | |
# it would be best if you did not specify destructive options, as the intent of keeping | |
# the original around is to regenerate all the thumbnails when requirements change. |
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
/** | |
* GC (Garbage Collection) Module | |
* | |
* Note: Since we rely on Java's memory model we can't provide the | |
* kind of control over garbage collection that MRI provides. Also note | |
* that since all Ruby libraries make GC assumptions based on MRI's GC | |
* that we decided to no-op explicit collection through these APIs. | |
* You can use Java Integration in your libraries to force a Java | |
* GC (assuming you really want to). | |
* |
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
Factory.define :site do |s| | |
s.name "Test site" | |
end | |
Factory.define :faq_category do |fc| | |
fc.association :site | |
fc.title "Test FAQ category" | |
end | |
Factory.define :faq do |f| |
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
# how to implement once ? | |
# it should evaluate the block only once per "once" call | |
# but it should evaluate again once if another "once" is in the view | |
# the following should render 1 1 | |
<% for i in (1..10) do -%> | |
<% once do -%> | |
<%= i -%> | |
<% 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
# the following kind of works but it cannot be used twice in once view | |
module ApplicationHelper | |
def once(&blk) | |
raise ArgumentError, "no block given" unless block_given? | |
yield unless @__once_called | |
@__once_called = true | |
end |