Better HN
topnewbestaskshowjobs
Log inSign up

Seb-C

1,107 karma · joined Mar 22, 2019 (7y ago) · 450 submissions

Submissions

comment 6y ago · link · parent

If you disable the option allowing Google to track and collect your location data everywhere and everytime, you cannot use this option.

comment 6y ago · link · parent

This is nice and I really appreciate the work of DuckDuckgo for privacy, but unfortunately it is not enough for me to switch from Google Maps. First, you cannot select a custom location as a target, it automatically selects a shop from a search result. I could not select my house or the closest station.

Secondly, there are no public transports, so it is unusable in Tokyo.

comment 6y ago · link · parent

Sorry, I just re-read my initial comment and I think the way I wrote it was misleading.

My case was about the allow-scripts directive of the sandboxed iframe, which I thought was linked to the csp mechanism, but now that I checked the documentation, it seems that I was wrong.

I basically display a random HTML document in an sandboxed iframe with disabled scripts. When you do so on Chrome and Firefox, the event listeners injected inside the iframe from a script in the parent frame still works, but on Safari it does not because all the scripts (or events) inside the iframe are disabled.

So rather that relying on this mechanism, I used DOMPurify to filter all the scripts.

comment 6y ago · link · parent

I had a situation lately where the CSP was not enough because of Safari, so I had to fallback to dom-purify. It is not always possible to just rely on it unfortunately.

comment 6y ago · link · parent

When I read about this, I expected a lot of unnecessary but positive PRs, or some grammar-nazi-ness, but actually it is really pure spam:

   https://github.com/phpmyadmin/website/pulls?q=is%3Apr+is%3Aclosed+label%3Aspam
The changes are not even positive contributions, it literally breaks the documentations and adds some useless or unwanted meaningless SPAM.

comment 6y ago · link · parent

I had a positive view on Cloudflare until recently. I started using it for my project about 3 months ago. I was impressed by the available features and even started planning to spend more in the future (I have only been on the free plan).

You can set-up a lot of things and even have a load-balancer. I was also impressed by the smooth and easy onboarding process.

Unfortunately, after starting to use it I realized that my site was extremely slow for everything that is not cached. Cloudflare was adding 250ms of latency to every request to my server. I certainly did not expect that much. When you try to send a support ticket, they aggressively try to make you not do it. My support ticket did not receive an answer for 2 months.

I stopped using it last week and will certainly not look back.

comment 6y ago · link · parent

I see what you mean. Indeed, more helpers would be ... helpful I guess, but for now I only implement what I really need and feel like is necessary.

For your specific example, what is wrong with `SELECT *`?

comment 6y ago · link · parent

With experience I have learned to stop relying on how the interview feels, but look more at the facts instead.

Some companies who did feel strict during the interviews actually were really good companies.

The opposite is true, I interviewed a company that seemed open minded and fun.

The interview in appearance was quite enjoyable, but with huge red flags. The CTO was always talking (super fast) and just wouldn't let me speak. I could ask only one question (during 1h) and was rudely interrupted in the end because he had no more time.

The CTO also said something like "If you join this company you will work with very competent engineers, smarter than you". To which I humorously answered while defending my pride, but probably ended up looking like someone full of himself.

Clearly this is not someone I would enjoy working with on a daily basis.

comment 6y ago · link · parent

This multi-api indeed seems similar to the sequence function.

If you can try-catch the failure in the external service, you can rollback the transaction with kiss-orm. Actually kiss-orm does not abstract the transaction itself, so you can do whatever you want.

I just realized a flaw in my current implementation, which is that directly using the repository CRUD methods from inside the sequence (rather than a query) function would execute those operations outside the scope of the sequence.

comment 6y ago · link · parent

Wow, thank you for the kind message!

I did not know about Ecto. It is interesting, but I think more abstract than what I would like kiss-orm to become.

About the ChangeSet stuff, from what I understood it is actually already possible in kiss-orm. The main difference being that I decided to not do the validation at runtime, but rely on typescript.

At worst you could have a runtime SQL error (inserting the wrong type of data in the wrong column for example), but the queries would be safe from injection.

You can definitely keep using kiss-orm with the default `any` type for the insert and update operation, but you can also specify it: https://github.com/Seb-C/kiss-orm#advanced-typings This way, your typings have to be right to use those methods. Runtime validation of inputs should not be done in the repository/database/orm layer anyway :) .

comment 6y ago · link · parent

Implementing eager-loading with the current philosophy of kiss-orm would be tricky and difficult to use/read. It did not seem a high-priority, so I chose to not implement it for now.

Depending on the ORMs, the definition of eager-loading also varies.

I have seem ORMs doing everything in a single query, returning everything in a single result-set and then de-duplicating everything client-side. This is very messy (and impossible to hack/fix most of the time).

Currently, the way to go would be something like this:

    const articles = await articlesRepository.search(sql`
        "authorId" IN (${sqlJoin(
             users.map(user => user.id),
             sql`, `,
        )})
    `);
    // Dispatch and assign the articles in the collection of users
I could consider having a helper method to make this easier, but I am afraid this would be quite difficult to use.

comment 6y ago · link · parent

I did not expect to see a site (legitimately) using an HTML 3.2 DOCTYPE in 2020.

comment 6y ago · link · parent

> expanding lists of column names

I am not sure about what do you mean here?

> dealing with casing (snake_case to camelCase)

This is one of the opinionated parts of kiss-orm I guess, because I specifically do not want to implement this.

I think having consistency in the naming of the properties/columns is more important. I would rather break the naming convention by having snake_case properties than automagically rename properties.

comment 6y ago · link · parent

Thanks. I do not have experience with Room, but I usually prefer to control and know what is happening in my schema.

For example, if your schema is automatically handled, how do you both rename and change the type of a column without losing data? Would it perform a delete and a create?

comment 6y ago · link · parent

I am glad that it is appreciated! Thank you.

comment 6y ago · link · parent

Well, this project is my alternative, and so far I did not see any case where it fails, but I'd be happy to learn.

This migration pattern is quite common in many frameworks, I just removed the query-building abstraction layer.

comment 6y ago · link · parent

Thanks for your comment!

As you say, one of the main arguments for query-builders is allowing the support of different RDBMS. But in my experience it not only never happens, but the abstraction is never perfect and makes any unsupported edge case impossible to solve without hacking around.

There is so much that can be done with SQL that would result in a mess of inefficient spaghetti code...

comment 6y ago · link · parent

Thanks! It was a copy/paste mistake. I just fixed the README file.

comment 6y ago · link · parent

That is something I seriously considered, but I just did not want to bother with multiple packages and repositories, especially for a repository class that is about 150 lines of code.

The repository class that I provide is a very basic and handy abstraction for the 4 basic CRUD operations, but ultimately the goal is to write your own queries and repositories.

comment 6y ago · link · parent

Thanks! It was a bit tricky to solve the transactions problem, because I did not want to abstract the BEGIN / COMMIT / ROLLBACK instructions, but at the same time I needed to provide something to ensure the integrity of a transaction made of multiple commands.

As for the audit fields, I decided not to include it because it very simple to implement, and would be clearer to do it specifically. Most of those fields could be implemented by just adding a default value in the right function.

comment 6y ago · link · parent

> reliable migrations (writing them by hand? no thanks. Outsourcing to another library like knex? no thanks)

IMHO, "real production features" means also caring about the long term maintenance, performance and reliability of the data.

My experience with ORMs (especially ActiveRecord patterns) is that it always becomes a mess once you reach a certain level of complexity. It is very fast to get started, but gets slower over time once you start having a lot of bugs and hard-to-solve behaviours.

comment 6y ago · link · parent

For a long time, I have been frustrated with the state-of-the-art about the existing ORMs. I like things to be simple, but somehow all ORMs seems to be bloated and overcomplicate a lot of things.

When designing a new project, I have been trying to find a more satisfying design while avoiding the existing ORMs. I especially wanted to use proper SQL rather than reducing it's syntax to fit it in another language.

This is the result of my experiments. This is a completely new balance between productivity, simplicity and readability, while providing useful features.

I use the template-string tagging syntax to allow writing and concatenating raw SQL queries, while keeping it safe from injections, which allowed me to build kiss-orm. There is no query-building involved, you can freely use the full-power of SQL.

I would appreciate feedback on this (and contributions if you love it :D ).

383.

Show HN: ORM for TypeScript with no query-builder, supporting full SQL queries(github.com ↗)

220 points · by Seb-C · 6y ago · 119 comments

comment 6y ago · link · parent

I have been using mega.nz to synchronize and backup my files for years, and so far I am very happy with it.

Everything works as expected, there is a lot of storage space and end-to-end encryption. There are clients for all platforms and it just works.

I can easily create secure share links whenever I want.

The only downsides are that the browser-based app is very slow to start once you have lots of files, and the android client does not have the same synchronization capabilities.

comment 6y ago · link · parent

It happened to me a long time ago. He was not only spamming and using SQL injections to destroy my community, but also advertising his own concurrent website.

When I also started to build scripts and destroyed his own website, he basically realized the harm he was doing, apologized and stopped.

Reminds me of the old good times when you could trap script-kiddies on msn.

"I think you are lying and not capable of hacking my computer. I'm waiting for you, my IP is 127.42.196.8"

comment 6y ago · link · parent

I know it is a voluntary exaggeration but well, if I saw a report seriously stating a 500% safety for a vaccine, I probably wouldn't take it.

comment 6y ago · link · parent

In modern development you should actually use micro-services. It is so useful that you can use it for everything. For example, if you find out that you have too many different functions to validate an integer, write a micro-service that validates integers!

And because the new service crashes when you input a non-integer string, please catch and ignore the exception client side (we'll fix it later).

comment 6y ago · link · parent

> Use exceptions for control flow. With different exceptions leading to entirely different flows. On C you can use setjmp/longjmp + globals for a similar effect. This will help the maintenance programmer develop thinking in multiple dimensions.

I recommend writing a CustomException class instead. So everytime you see a third-party error, catch it and throw a new CustomException() (Without arguments, otherwise you may carry some bad third-party classes/exceptions in your codebase). And don't forget to catch CustomException at strategic places too, so you can actually throw a new CustomException().

comment 6y ago · link · parent

Did that in Japan (I'm talking about the sole proprietorship and already have a working visa here, so it's not exactly the same situation).

Well, actually I didn't do anything because you literally have nothing to do. You just have the right to do some business on your own (but of course there are official companies of you want to get bigger).

Just when you start getting money, you have to inform the tax office, so they can give you the form next year.

comment 6y ago · link · parent

The title should be edited by a moderator to at least add the unit, this feels like a clickbait otherwise.
1
1112131415