Hacker Newsnew | past | comments | ask | show | jobs | submit | localhostdotdev's commentslogin

to be fair, i went there, saw rip and didn't read further :)


oh nice, i didn't know where the coin flipping quote came from: https://en.wikiquote.org/wiki/Piet_Hein


you were programming in text, a very popular programming language that i'm using right now :)

here is a peg grammar:

    text = $.*
you can try it at https://pegjs.org/online :)

edit: sry to disappoint but this matches binary files too :(


already better than s3 :) makes me think of https://www.reddit.com/r/DataHoarder/


wow that's quite amazing! could be worth it even at 10k+

here is a direct link so people don't have to copy/paste https://innerscene.com/products


this is my definition of a boring programmer:

- makes code that works

- solves people's problems

- doesn't care what other programmers think

edit: the truth is a boring programmer won't even read this, just doesn't care, doesn't read hn, just does stuff


If the code only works but isn't maintainable (simple and extendable), then you've got a very interesting programmer, just havn't realized it yet.



pretty cool how the urls stayed the same:

http://stackoverflow.com/questions/13204/why-doesnt-my-cron-... (still works)

http://stackoverflow.com/questions/21064/massive-reputation-... ("this question was removed from stack overflow for reasons of moderation", still available: https://i.imgur.com/Csy94IL.png)


thanks for linking there, tried to make some ruby notebooks and works quite well https://nbviewer.jupyter.org/github/localhostdotdev/notebook... (very similar to the github interface though)


    rails g model Post published_at:datetime title content:text
    rails g model Comment post:references author published_at:datetime content:text
    rails g model Tag name
    rails g model PostTag post:references tag:references

    class Post < ApplicationRecord
      has_many :comments
      has_many :post_tags
      has_many :tags, through: :post_tags
    end

    class Tag < ApplicationRecord
      has_many :post_tags
      has_many :posts, through: :post_tags
    end
from there it's just regular rails:

    Tag.find_by(name: "something").posts
    Post.joins(:tags).where(tags: { name: "something" })
    Tag.create(name: "something")
    Post.create(...)
    Tag.first.posts << Post.all.sample(2)
made a little repo if people want to play with it: https://github.com/localhostdotdev/bug/tree/orm-or-not-orm


You forgot to add an index on tags.name and null constraints on the rest of the columns.

> from there it's just regular rails

That's the problem. Examples like this focus on the first few minutes of development. Not the subsequent years of maintenance.


> Not the subsequent years of maintenance.

You're gonna have to pry the Rails from my cold dead fingers if you want me to maintain a web app's database abstraction layer long-term. No other tool works half as well as ActiveRecord. You could maybe convince me to try out https://rom-rb.org/ but only on a brand new project and only if Rails isn't appropriate.

If it's a project that wasn't built with Rails, I'm going to want https://github.com/jeremyevans/sequel if ActiveRecord is too much trouble to introduce.


I have been lucky to be able to pick what I want to use, so I pick non-rails stack (Sinatra/Padrino and now Roda + Sequel). No other tool works as half as Sequel. You're gonna have to pry Sequel from my cold dead fingers.


Don't get me wrong, I love Sequel. But ActiveRecord is far more polished. And that starts to matter once you start needing to go 'off-script'.


Adding an index on tags.name is likely not very useful on its own but adding an index with an uniqueness constraint to prevent duplicates is probably a good idea. Assuming there are just a few different tags records (<1000) then a sequential scan is generally either insignificantly slower or even faster than an index scan.

>Not the subsequent years of maintenance.

I'd much rather maintain this example than a code base replicating the same behavior without an ORM.


I stayed close to what the author did.

adding an index:

    add_index :tags, :name
adding a null constraint:

    change_column :tags, :name, :string, null: false
    validates :name, presence: true # for proper validations
https://github.com/localhostdotdev/bug/commit/3765237008c36c...


> I stayed close to what the author did.

Fair enough. I’ll concede that wasn’t a fair comparison to the OP. My point remains that examples focusing on the initial setup are uninteresting (to me) because that’s not where the bulk of the work is.


Rails is also fine to maintain down the road. Certainly easier than any data layer most engineers would make by hand.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: