Time formatting string in ruby [closed] - ruby

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Why is "Y" for "Year" capitalized while "m" for month is not? Moreover, "M" for minute is capitalized!
Time.now.strftime "%Y/%m/%d %H:%M:%S"
I always have difficulty to remember that as an english as second language programmer.
Methods of how to memorize the above formatting notation or explanation is much appreciated.

%Y is capitalized because it's long form year (2013). You can use %y and it will produce short form (13).
Also all parts in time section should be capitalized, because their lower-case variants are already taken by something else (in parentheses I provided current values).
`%h` - human short name for month (Jun)
`%H` - hour (14)
`%m` - month (06)
`%M` - minute (09)
`%s` - unixtime (1370599766)
`%S` - second
Simple, no?
If there's no rules, I will memorize it
Just memorize :)

Related

What takes less time to complete, comparing two variables, or assigning a new value to a variable? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Basically what I'm saying is, which operation takes less time to complete? I know the time it takes to complete 1 of these operations is too fast to measure, but I would assume that there would be some way to explain what happens that could explain which one is faster.
Also, I would assume that comparing two variables would be more taxing on the CPU and assigning a value would be more RAM taxing. Is that correct?
In American football, this would be like asking which is faster:
A running play?
A passing play?
It's too vague, too general to have any kind of sensible answer.

Given two strings of length, test if the two strings are identical [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a algorithmic based question. No code is required, just have to state how I would write this in words. Use n and m as variables if needed, in Java.
Enter the first string in the variable n.
Enter the second string in the variable m.
Compare the two string lengths :
*if they're different , return false.
Scan the two vector , character per character :
*if there's one difference, return false.
Return success.

Maintain realtime counter [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
The following is an interview question which shows up here and here:
Given a timer time() with nanosecond accuracy and given the interface
interface RealTimeCounter:
void increment()
int getCountInLastSecond()
int getCountInLastMinute()
int getCountInLastHour()
int getCountInLastDay()
The getCountInLastX functions should return the number of times increment was called in the last X
Here's one suggested solution (paraphrased from the above blog entry):
Maintain an ArrayList of timestamps. When asked for a given counter, let's say, the count for the last second, perform a binary search for (timer.time() - ONE_SECOND_IN_NANOSECONDS), and return the list.length() - list_index. Then, as a background process at regular intervals we trim our data. Since we only need to maintain data for the last day, we can delete all entries prior to the last day.
Please critique this solution or offer a better performing one.

What is the most general / common South American Spanish culture [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Our application has the language concept of Latin American Spanish and I need to select a Culture Info to use for that language file. Microsoft has a culture for 17 different Latin American countries and I need to choose one that best represents them all. Any input on which one that might be?
¡Viva México! !México es el mejor país del mundo¡
...or rather, I'd just go by population:
http://wiki.answers.com/Q/What_Latin_American_Country_is_the_world's_most_Populated_spanish-speaking_country
(Assuming no greater knowledge of your intended market.)
I wasn't aware localizations existed beyond the es master category...
http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(v=vs.71).aspx
If they haven't already established some sort of hierarchy then this seems like a fairly strange feature.

What is the optimal IDE/text editor print margin when programming? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
Considering today's monitors and programming fonts that look quite good at small point sizes, what is the optimal print margin to set in your IDE/text editor?
I have been using the age-old 80 characters for most of my career but Code Complete has made me consider a 90 character margin.
Is 100 going too far or is it really up to the developer/team involved?
Even if you have a very large screen, reading long lines is more difficult than reading short lines.
Besides, the extra space can be used to show other informations. I work in a team that uses very long lines (120 characters) which is fine when the text editor is in full-screen mode, but the text is often truncated when other panels are open.

Resources