HNHacker News
TopNewBestAskShowJobs

fphilipe

1,088 karma · joined November 8, 2010

http://phili.pe

https://github.com/fphilipe

[ my public key: https://keybase.io/philipe; my proof: https://keybase.io/philipe/sigs/182uf1x4SUnMvtmLchInbgTL0X0b0qcRGe_g2T0KLDo ]

submissionscomments
fphilipe··on Chrome, Safari, and Edge to Prevent Disabling of Click Tracking Privacy Risk
Indeed, but I just learned about the DOM mutation API[1], that can be used here. This also makes sense when additional content is loaded later via AJAX (was achieving that with setInterval).

1: https://developer.mozilla.org/en-US/docs/Web/API/MutationObs...

fphilipe··on Chrome, Safari, and Edge to Prevent Disabling of Click Tracking Privacy Risk
I guess I’ll have to inject some JS to delete ping attributes while browsing in Safari.

This move is very counter to Apple’s privacy stance.

fphilipe··on Cog: Use pieces of Python code as generators in your source files
The Swift code base uses something similar that the core team wrote: GYB, Generate Your Boilerplate. It’s used to generate several variants of similar code that would be cumbersome to maintain otherwise.

https://github.com/apple/swift/blob/master/utils/gyb.py

fphilipe··on Timestamps and Time Zones in PostgreSQL (2016)
> > However, when you come across timestamp, you can’t possibly know in what time zone the timestamp is just by looking at it.

> yes I do, it's in UTC, because I assume the application is written to correctly handle datetimes.

> > It is merely a wall time. Maybe it’s UTC,

> no, it's UTC.

No, you don't know that if you're looking at the database without knowledge of the app's conventions.

I don't understand your argument about ambiguity and implicit conversions. Yes, if your session or DB is configured to something other than UTC, it will convert the timestamptz values in your output to that time zone's offset, but it'll still include the offset.

Thus, a value "2019-04-01 00:00:00+00" that is output when using timestamptz with UTC (compared to "2019-04-01 00:00:00" when using timestamp), is output as "2019-03-31 19:00:00-05" when using EST. Both values represent the same moment in time, obviously, and are equivalent. Assuming your app and ORM convert everything to UTC, that shouldn't matter at all.

fphilipe··on Timestamps and Time Zones in PostgreSQL (2016)
Thanks, much appreciated.

At least for me, writing an article like that takes time and lots of thought (plus forces you to grok the stuff deeply). I wish I could write more often (or at least, carve out the time and energy for it), haven’t written much since.

fphilipe··on UTC Is Enough for Everyone, Right?
Might sound "dumb" or confusing (which it is), but makes a lot of sense. I've written a post explaining the difference between "timestamp with/without time zone": http://phili.pe/posts/timestamps-and-time-zones-in-postgresq...
fphilipe··on Facebook Container for Firefox
Google Play Console only works with your primary account.
fphilipe··on Vim Anywhere
Have been using a US keyboard and never looked back to the Swiss one. Much better for programming and accents and umlauts are still easy to type. As I also occasionally type in Portuguese, German, Spanish, and French, I find the US keyboard to be the neutral middle ground.
fphilipe··on Sum Types Are Coming (2015)
If you're looking for a simple sum type without associated value, the standard library's enum works quite well: https://docs.python.org/3/library/enum.html
fphilipe··on Return type polymorphism in Haskell
Swift supports this. Having said that, I don't think I've encountered it in the standard library.

I recently started using the Decodable protocol and was surprised to find out that the `decode` methods all take an explicit type, e.g. `KeyedDecodingContainer.decode(Double.Type, forKey: KeyedDecodingContainer.Key)`. There's a method for each supported type. [1]

Not sure why they didn't just have one method to rule them all in the public interface, like this:

    extension KeyedDecodingContainer {
        public func decode<T: Decodable>(key: KeyedDecodingContainer.Key) throws -> T {
            return try decode(T.self, forKey: key)
        }
    }
The usage then becomes much simpler (assume `name` is a property of type `String`):

    // Before:
    name = try container.decode(String.self, forKey: .name)
    // After:
    name = try container.decode(key: .name)
[1]: https://developer.apple.com/documentation/swift/keyeddecodin...
fphilipe··on Feature comparison of ack, ag, git-grep, GNU grep and ripgrep
A nice feature of ag is the ability to limit the search to a certain file type. E.g. to only search ruby files: ag --ruby foo.

To see a list of supported types and the matching file extensions: ag --list-file-types.

Just checked and rg does have something similar, but you need to specify the type as an argument to a flag: rg --type ruby foo.

fphilipe··on Ten years of professional blogging – what I’ve learned
> Well written articles will generally place highly on Google's search results no matter the domain(unless you've got shady shit going on).

Absolutely. I've written two blog posts on PostgreSQL on topics that, in my opinion, weren't well covered and often misunderstood by its users. Both posts show up on the first page on a google search for "psql cli" and "postgres timezone".

I honestly never understood this whole fuss about SEO. In my opinion SEO is about good content. Good content over time will spread, which will result in a higher ranking.

fphilipe··on Does anyone remember websites?
> Oh,you mean like blogs?

Yes, but before they all looked the same and were hosted on the same platform.

I miss the days where you would encounter a blog filled with great content and with a unique look and feel. It's as if it almost burned in in my memory. I still remember how the website looked of some great articles that resonated with me.

That's one of the reasons I dislike Medium et al.

fphilipe··on Text-only CNN
Same for Switzerland: http://www.teletext.ch/
fphilipe··on Codemod – A library to assist with large-scale codebase refactoring
Or :cdo when using the quickfix window.
fphilipe··on Working with time in Postgres
Note that there's the ISO standard for weeks which uses slightly different abbreviations:

    SELECT to_char(now(), 'IYYY-"W"IW');
The difference is when the first week of the year starts. Compare yours to the ISO 8601 format for January 1 this year:

    $ SELECT to_char('2017-01-01'::date, 'IYYY-"W"IW');
    > 2016-W52

    $ SELECT to_char('2017-01-01'::date, 'YYYY-"W"WW');
    > 2017-W01
fphilipe··on Working with time in Postgres
One week is always 7 days. But one month (and year) is not always the same length. If you add or subtract n months from a timestamp or date at the beginning or the end of the month, it returns the beginning or end of the month n months away. Here's an example showcasing this using the fact that 2016 was a leap year:

    $ select '2016-03-31'::timestamp - '1 month'::interval;
    > 2016-02-29 00:00:00

    $ select '2016-03-31'::timestamp + '11 month'::interval;
    > 2017-02-28 00:00:00

    $ select '2016-02-29'::timestamp + '1 year'::interval;
    > 2017-02-28 00:00:00
fphilipe··on PostgreSQL 10 Beta 1 Released
Does MySQL do that on varchar by default?

Can't you just do this in PostgreSQL?

    SELECT id FROM users WHERE email = lower('Foo@example.com')
fphilipe··on Chicago's About to Get a Lot Less Orange
No. Once in a while you still see old cars with yellow lights though.
fphilipe··on Lessons learned as a React contractor
I'd say that's a Façade: https://en.wikipedia.org/wiki/Facade_pattern
fphilipe··on Pipfile for Python
That's what I meant by

generate a second requirements file after having done `pip install -r requirements.txt` to get the exact versions that were installed

So you'd need to have a `requirements.txt` with loose versions suitable for upgrading your apps deps, run `pip install -r requirements.txt` and then `pip freeze > requirements.locked.txt`. Then everyone should be using `pip install -r requirements.locked.txt` as well as during your build. But that's cumbersome and error prone and doesn't free you from having the wrong version of a dep in case you `pip install some-package` later on.

fphilipe··on Pipfile for Python
This is great news. Coming from Ruby and being used to Bundler, doing anything in Python or JS always was a huge pain. Countless times I deleted the current virtual environment or did an `rm -rf node_modules` to start fresh. So I'm excited to see Yarn for JS show up and now this.

The main problem with requirements.txt, as I see it, is that you don't get exact versions unless you specify it in your requirements.txt. So you'd have to have a loose requirements.txt and then generate a second requirements file after having done `pip install -r requirements.txt` to get the exact versions that were installed.

Further, if you happen to "accidentally" `pip install some-package` in your virtual environment, your app might now be using different packages locally without you noticing. With Pipfile the need for virtual environments is pretty much gone, assuming that at runtime it will automatically load the version of a package specified in the lockfile, which is not clear to me yet from the README.

fphilipe··on How to contribute to an open source project on GitHub
I can highly recommend hub [1], which does steps 3, 4, and 5 in one command:

    hub fork username/repo
1: https://github.com/github/hub
fphilipe··on Atom 1.11
Working for me.
fphilipe··on Upgrade your SSH keys
That you should be doing anyways, shouldn't you?
fphilipe··on Advancing in the Bash Shell
I used to do !$ a lot until I configured iTerm to allow me to cycle through the last args with alt-. which is way faster. But I did not know about the colon modifiers, so !$ might make its way back into my workflow. ZSH gives me a nice overview of what's possible:

    > !$:<tab>
    &  -- repeat substitution
    A  -- absolute path resolving symbolic links
    Q  -- strip quotes
    a  -- absolute path
    c  -- PATH search for command
    e  -- leave only extension
    g  -- globally apply s or &
    h  -- head - strip trailing path element
    l  -- lower case all words
    q  -- quote to escape further substitutions
    r  -- root - strip suffix
    s  -- substitute string
    t  -- tail - strip directories
    u  -- upper case all words
fphilipe··on Elevated error rates on applications and deployments
Agree, support is usually very fast. Also, an outage like today is quite rare, I'd say.
fphilipe··on Elevated error rates on applications and deployments
It took them 15 minutes to update their status from the time of our last received request.
fphilipe··on Setup Keybase.io, GPG and Git to sign commits on GitHub
GitHub is happy as long as you upload the public key to GitHub. Git though uses pgp key servers to verify the signature.
fphilipe··on Setup Keybase.io, GPG and Git to sign commits on GitHub
I'm not sure keybase does this by default, but make sure to upload your key to a keyserver such as MIT's (https://pgp.mit.edu). Otherwise, git will complain that the signature is invalid when doing `git log --show-signature`.
← PreviousPage 3 of 6Next →