It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Randomly output text from array to view - RAILS
It is not really well formated question ... You should be more precise about what you want, what you are using, etc.
Assuming you are using Rails 3, ERB for HTML generation:
# in your controller:
file_as_array = IO.readlines('filename.txt')
random_line = rand(file_as_array.size)
#my_random_string = file_as_array[random_line]
# in your view:
<%= #my_random_string %>
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to have this kind of lists:
asdasdas
aqweqwe
Instead of
asdasdasdas
jasdasdasda
Please help
Have a look at the Markdown syntax guide. In it's chapter about lists it says:
Unordered lists use asterisks, pluses, and hyphens — interchangably —
as list markers:
* Red
* Green
* Blue
is equivalent to:
+ Red
+ Green
+ Blue
and:
- Red
- Green
- Blue
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to be able to break the line inside the brackets without having the "inconsistant brackets" error.
Here's a example:
select.someclass.something{data: {max_amount: o.max_amount_clean, max_amount: o.min_amount_clean, fee: o.fee_clean}}
Thanks
I'm not sure if I understand, but if the argument is a hash and not a block, like it seems, you could do
select.someclass.something(
{data:
{max_amount: o.max_amount_clean,
max_amount: o.min_amount_clean,
fee: o.fee_clean}}
)
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Corona/Lua how to sort a table of strings from shortest to longest
Assuming your table is a indexed table and not a keyed one try
test = {'123','1234','1245','1','12'}
table.sort(test, function(a,b) return #a<#b end)
for i,v in ipairs(test) do
print (i,v)
end
The important line here is
table.sort(test, function(a,b) return #a<#b end)
Words will only sorted by length and order within matching lengths will be arbitrary. If you want to sort by additional criteria, extend the function for the sort
eg function(a,b) return #a<#b end
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am trying to read values from a .txt file and keep getting the above error. My code reads:
file <- readFile "films.txt"
let database = (read file :: [Film])
and Film is a data type I declared as:
type Film = (String, String, Int)
Still quite new to Haskell so have no idea how to parse a string back into the required type. Sort of assumed it would be nice and do it for me like it does with writeFile!
Any hints?
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How can I localize this one to French please :
PostDate id DateTime type.
#pr.PostDate.ToString("MMMM dd, yyyy")
You can use the ToString overload that takes a IFormatProvider and pass in a French culture:
#pr.PostDate.ToString("MMMM dd, yyyy", new CultureInfo("fr-FR"))
Though, if you need to do this in multiple locations, it may be easier to set the current culture to a French culture:
var frenchCulture = new CultureInfo("fr-FR");
Thread.CurrentThread.CurrentCulture = frenchCulture;
Thread.CurrentThread.CurrentUICulture = frenchCulture;