get milliseconds since 1970 from string
DateTime.parse("2016-08-12 06:13:24 UTC").strftime('%Q')
Get first 3 integer
in rails console
How do i print the date and time of specific lines that contain a certain key word using Ruby?
One way to do it would be like so (within a block that's iterating over the lines in the file, obviously):
Since the date information (which is what you want output) appears in the same position and is the same length in every line, we don't bother doing any parsing of the text for the output - just spit out the first 15 characters.
I'm tempted to try to compress all of this into a single regular expression, but this ought to work. Obviously, you could do something other than print out the date within the conditional, and if you wanted to work with it as a date, you could pass it to
DateTime.parse() (just remember to
require 'date' first).
jsTime = 1252268867928
# Sun Sep 06 20:27:47 +0000 2009
Ensuring a unique number to identify something
If you need unique identifier, you should make such. For example,
p SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
(I assume that PayPal accepts arbitrary strings and doesn't require actual integers)
In Rails - Is There a Rails Method to Convert Newlines to <Br>
Rails 3 - No Such File to Load -- Openssl
Best Way to Highlight Current Page in Rails 3? - Apply a CSS Class to Links Conditionally
Gem.Source_Index Is Deprecated, Use Specification. Should I Re-Install Gem or Rails
What's the Difference Between Gets.Chomp() VS. Stdin.Gets.Chomp()
Finding Out Current Index in Each Loop (Ruby)
Get the Value of an Instance Variable Given Its Name
Rails: Postgres Permission Denied to Create Database on Rake Db:Create:All
How to Make Instance Variables Private in Ruby
In Ruby, Why Does Inspect() Print Out Some Kind of Object Id Which Is Different from What Object_Id() Gives
How to Compare Strings Ignoring the Case
How to Print Out the Contents of an Object in Rails for Easy Debugging
What's the Difference Between Gem_Home and Gem_Path
Given an Array of Arguments, How to Send Those Arguments to a Particular Function in Ruby
Using Instance Variables in Class Methods - Ruby