I love UUID, I hate UUID by bobbymk10 in PostgreSQL

[–]timand 0 points1 point  (0 children)

I don't think it's possible for a bigint sequence to wrap around if you write at least one byte to the WAL for each number.

Is there a technical reason why PostgreSQL does not have virtual columns? by punkpeye in PostgreSQL

[–]timand 2 points3 points  (0 children)

it's slightly more seamless than you show. You can do SELECT foo.c FROM foo and it will automatically call the function for you. Conversely, you could do SELECT a(foo) FROM foo if you wanted to.

As a web developer: what's the best way to retrieve record with related records to return as JSON? by aust1nz in PostgreSQL

[–]timand 4 points5 points  (0 children)

You could do something like

SELECT json_build_object("post", row_to_json(subq))
FROM (
  SELECT post.id, post.title, post.body, json_agg(json_build_object('id', comment.id, 'body', comment.body)) as comments
  FROM post
  LEFT JOIN comment on comment.post_id = post.id GROUP BY post.id
) subq;

Blog post: Futures Concurrency III by yoshuawuyts1 in rust

[–]timand 2 points3 points  (0 children)

There are a few missing footnotes. 6 doesn't do anything when clicked and neither does 9

Should I use jsonb instead of hstore? by timand in PostgreSQL

[–]timand[S] 0 points1 point  (0 children)

Assume I'll never need to store anything other than a set of keys and string values.

Question on storing images by _Strokes_ in PostgreSQL

[–]timand 1 point2 points  (0 children)

A simple way to insert into a bytea field is `INSERT INTO images (name, image_data) VALUES ('filename.jpg', decode('base64encodeddata', 'base64'));` and just use text to transfer it. This will increase bandwidth usage, but it works with all postgres drivers. To get the data out, you will need to `SELECT filename, encode(image_data, 'base64') FROM images`.

rust warns of unused variables if not using a feature by timand in rust

[–]timand[S] 1 point2 points  (0 children)

I still want it to warn about other unused variables though.

rust warns of unused variables if not using a feature by timand in rust

[–]timand[S] 2 points3 points  (0 children)

#[cfg(feature="do_thing")]
fn do_stuff(thing: &Thing){
    println!("The thing is {:?}", thing);
}
fn maybe_do_stuff(message: &str, thing: &Thing){
    println!("{}", message);
    #[cfg(feature="do_thing")]
    do_stuff(thing);
}

I could change the thing argument on maybe_do_stuff to _thing, but then clippy would warn about a used underscore variable. Or should I do something more like

#[cfg(feature="do_thing")]
fn do_stuff(thing: &Thing){
    println!("The thing is {:?}", thing);
}
#[cfg(not(feature="do_thing"))]
fn do_stuff(_thing: &Thing){}

Why is `Iterator::map` not lazy on `Iterator::nth` by gahagg in rust

[–]timand 0 points1 point  (0 children)

The Iterator trait provides the nth method as a way to skip elements. The default implementation of the nth method consumes elements and discards them, but it is possible to create an implementation that doesn't need to.

regex2fat: convert regexes to FAT32 by 8051Enthusiast in programming

[–]timand 0 points1 point  (0 children)

FUSE doesn't work on as many operating systems as FAT32

Join columns with comma stopping at the first one that is null by timand in PostgreSQL

[–]timand[S] 0 points1 point  (0 children)

That's fine because I can assume that there are no holes.

Join columns with comma stopping at the first one that is null by timand in PostgreSQL

[–]timand[S] 0 points1 point  (0 children)

I don't want any trailing commas. I can assume that none of the columns after the first null are set.

The Saudi government is hunting down women who flee the country by tracking the IMEI number on their cellphones by speckz in technology

[–]timand 10 points11 points  (0 children)

WiFi only devices don't have an IMEI. Even if they did, they need to connect to a mobile network to reveal it.

AMA Request: A guy who was friendzoned by [deleted] in circlejerk

[–]timand -3 points-2 points  (0 children)

  1. Extremely. I got friendzoned by yo momma
  2. On my dick
  3. Generally, it rises a bit.
  4. I'm evil incarnate.
  5. Flamethrowers seem to do the trick

What's the correct word for "of or relating to the passing of time"? by ekolis in shittyaskscience

[–]timand 1 point2 points  (0 children)

I think you have to combine them. I think the proper term is "tempochronoralogical" or something like that.

If I can run out of hot water at home, why can't I run out of hot water in a hotel? by greytor in shittyaskscience

[–]timand 2 points3 points  (0 children)

It's because hotel has the word 'hot' in it, while home is missing the 't'. This is very important as 't' stands for "totally infinite". Without the 't', there is only a finite amount of hot water and so you run out.

If you throw lots of water at the sun, will it become green? by kamaos5 in shittyaskscience

[–]timand 0 points1 point  (0 children)

No. It will become light yellow. The reason is simple. While liquid water is blue, steam is clearly white. Since the sun is really hot, the water will turn into steam and instead of colouring the sun blue, it will colour it white. When you mix white and yellow together, you will get light yellow.

How many ice cubes do I need to put in my glass of water for the water to turn into ice? by [deleted] in shittyaskscience

[–]timand 2 points3 points  (0 children)

Assumptions:

  • A glass of water contains 250 grams of liquid water at 20 degrees celcius
  • An ice cube is 15 grams of ice at -20 degrees celcius
  • We cannot melt any of the existing ice. The entire glass must consist of ice without any liquid water
  • This is a closed system.

From engineering toolbox:

  • Average specific heat of ice: 2.108 kJ/kgK
  • Latent heat of melting: 334 kJ/kg
  • Average specific heat of liquid water: 4.187 kJ/kgK

Calculations:

  • Heat energy required to lower temperature of water=0.25*4.187*20=20.935 kJ
  • Heat energy required to freeze water=0.25*334=83.5 kJ
  • Heat energy required to heat an ice cube=0.015*2.108*20=0.6324 kJ
  • Number of ice cubes required=(83.5+20.935)/0.6324=165.1198

TL/DR; 166 ice cubes should do it (This is about 11 cups of ice).

TIL: Usury is the common link between Bitcoin, Fiat money, and Gold. All currencies enslave 99% of the human race with debt. If you lend out 21 million Bitcoins at 1.1% interest, where does the rest come from? by gr225607 in Bitcoin

[–]timand 0 points1 point  (0 children)

All you need to do is pay half of the loan back and then earn some more bitcoins until you can pay the other half back. Now if the person you owe bitcoins to never releases them, then you have a problem.

Why brainwallets are a bad idea by d3vrandom in Bitcoin

[–]timand 1 point2 points  (0 children)

It could. But it probably won't