Skip to content

Instantly share code, notes, and snippets.

View hosiawak's full-sized avatar

Karol Hosiawa hosiawak

View GitHub Profile
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
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
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"
#
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'
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
%>
# * +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.
/**
* 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).
*
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|
# 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 -%>
# 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