Skip to content

Instantly share code, notes, and snippets.

View greglu's full-sized avatar

Greg Lu greglu

  • Swoop.com
  • San Diego, CA
View GitHub Profile
public class Timestamp {
/**
* Convert the given date in hbase timestamp format.
* @param date to convert
* @return the timestamp
*/
public static long toHbaseTimestamp(Date date) {
return ((date.getTime() / 1000) << 32) + ((date.getTime() % 1000) * 1000);
}
hbase(main):051:0> get 'books', 'fe80a1eb-2b3c-4995-8630-4131ef4b4eb7'
COLUMN CELL
attribute:author timestamp=5410348784985219840, value=\001Richard Matheson
attribute:description timestamp=5410348784985219840, value=\001The most clever and riveting vampire nov
el since Dracula.
attribute:links timestamp=5410348784985219840, value=--- []\n\n
attribute:title timestamp=5410348784985219840, value=\001I Am Legend
log:change timestamp=5410348784985219840, value=--- []\n\n
5 row(s) in 0.0070 seconds
http://books.google.com/books?id=8lKyxS8_CNoC&lpg=PA196&ots=G-ZgzDfG_0&dq=pushdown%20automata%20complement%20of%20ww&pg=PA163#v=onepage&q=ww&f=false
max_function = ""
6.times do |i|
6.times do |j|
max_function << ((rand(2) == 1) ? " + " : " - ")
max_function << "#{rand(20)}*x#{i+1}#{j+1}"
end
end
puts ((max_function[0..2] == " + ") ? max_function[3..(max_function.size-1)] : max_function)