Better HN
topnewbestaskshowjobs
Log inSign up

chris12321

134 karma · joined Oct 16, 2022 (4y ago) · 61 submissions

Submissions

comment 1y ago · link · parent

A majority of people in North West England has Irish ancestry. Are those people not British?

comment 1y ago · link · parent

After German reunification the states of East Germany and West Germany ceased to be. Was that two genocides?

comment 1y ago · link · parent

No state has the right to exist, that thought terminating cliche makes no sense legally or philosophically. States are recognised by other states, with no legal rights involved. Also claiming that a call for the end of a state is a call for genocide is ludicrous, if that was the case then every revolution in world history would be a genocide.

comment 1y ago · link · parent

> It's almost like if bureaucrats who are writing regulations are experienced in writing regulations in such a way they can't be circumvented.

Americans often seem to have the view that lawmakers are bumbling buffoons who just make up laws on the spot with no thought given to loop holes or consequences. That might be how they do it over there, but it's not really how it works here.

comment 1y ago · link · parent

You can also set up DNS records pointing to your home server's VPN IP, which, with Tailscale, I've found to be pretty static and then a reverse proxy on your home server. So I have my home network apps running on app1.my-domiain.com app2.my-domain.com, app3.my-domain.com etc, which only work when I'm connected to the VPN.

The downsides are that I need to be connected to the VPN at home to use the domain and I currently don't have SSL set up on the domains, so browsers complain when I connect to them. The second problem I could fix, but I'm not sure if there's a solution for the first.

comment 1y ago · link · parent

That's certainly not a criticism that could be levelled at Giantbomb, considering it was started when its founder, Jeff Gerstman, was fired from his job at GameSpot for giving a game a low review score while the developer of the game was doing a big marketing campaign on the site.

comment 1y ago · link · parent

Thanks, I'll let my team know.

Sorry I meant to say "I've been thinking about building a Once style project" I've just got a couple of not very well fleshed out ideas at the moment.

In terms of licencing it's interesting, I suppose you could have the app phone home periodically, but since it's source available, someone could just remove that call. I guess the main idea is just that it's software for businesses and legitimate businesses generally aren't going to break licence agreements.

comment 1y ago · link · parent

It's simply not true that "regular AR calls are painfully slow." In the context of a web request, the time spent instantiating Active Record objects is negligible. For example, on my laptop:

Customer.limit(1000).to_a

completes in about 10ms, whereas:

Customer.last(1000).pluck(:id, :name, :tenant_id, :owner_id, :created_at, :updated_at)

runs in around 7ms.

Active Record methods are defined at application boot time as part of the class, they're not rebuilt each time an instance is created. So in a typical web app, there's virtually no performance penalty for working with Active Record objects.

And when you do need raw data without object overhead, .pluck and similar methods are available. It’s just a matter of understanding your use case and choosing the right tool for the job.

comment 1y ago · link · parent

It's been widely understood in the Ruby community for some time now that metaprogramming—like in the example above—should generally be limited to framework or library code, and avoided in regular application code.

Dynamically generated methods can provide amazing DX when used appropriately. A classic example from Rails is belongs_to, which dynamically defines methods based on the arguments provided:

class Post < ApplicationRecord belongs_to :user end

This generates methods like:

post.user - retrieves the associated user

post.user=(user) - sets the associated user

post.user_changed? - returns true if the user foreign key has changed.

comment 1y ago · link · parent

This is an interesting project! I'm going to recommend it to my team at work, since we've been moving to try to self-host more of our services.

I've been about building a Once-style project myself, how do you deal with tracking the licences, do you have the ability to revoke them if someone breaks the licence?

comment 1y ago · link · parent

I recently read The Ministry for the Future by Kim Stanley Robinson, and one of the ideas in it that I thought was very good was replacing our cargo ships with wind-powered ships, basically giant sailing ships. In the book, they were incredibly slow, with shipments taking months to complete, but if supply lines were set up correctly, that wouldn't matter for a lot of cargo. Cargo ships are a massive CO2 contributor, and it was interesting that a solution could be to return to sailing ships.

I know there are probably huge engineering problems preventing this from happening, so feel free to tell me why it's impossible.

comment 1y ago · link · parent

As a long time Ruby developer the only thing about Ruby that I wish would die is people declaring 'Is Ruby dead?/Ruby is dead/Ruby isn't dead'!

comment 1y ago · link · parent

Ruby will probably never again be the most popular language in the world, and it doesn't need to be for the people who enjoy it to be excited about the recent improvements in performance, documentation, tooling, ecosystem, and community.

comment 1y ago · link · parent

Between Rails At Scale and byroot's blogs, it's currently a fantastic time to be interested in in-depth discussions around Ruby internals and performance! And with all the recent improvements in Ruby and Rails, it's a great time to be a Rubyist in general!

comment 1y ago · link · parent

ChatGPT won't tell you how to do anything illegal, for example, it won't tell you how to make drugs.

comment 1y ago · link · parent

I know of a bunch of apps that deploy to multiple servers behind a load balancer using Kamal. Here's an article explaining the process https://guillaumebriday.fr/how-to-deploy-and-scale-your-rail...

comment 1y ago · link · parent

How does a modern goto differ from a traditional goto?

18.

Gem Shop: A Vulnerable Rails 8 App for Security Education(paraxial.io ↗)

1 points · by chris12321 · 1y ago · discuss

comment 1y ago · link · parent

This was written by the recently deceased Noah Gibbs. The site is now under the control of his widow. It's a great course and I'd encourage people to check it out.

comment 1y ago · link · parent

I think it's a combination of a lot of things over the last 2ish years:

1. Ruby 3.0 and YJIT have provided huge performance gains for the language with further improvements still left to be implemented.

2. Ruby releases new versions every year on Christmas day, so you're more likely to get new content around this time of year.

2. Large Rails shops like Github and Shopify have redoubled their commitment to Ruby/Rails and invested a lot of resources into improving the developer experience with ruby-lsp.

3. Prism, the new Ruby parser has been developed and merged into Ruby, from my understanding, it's a lot more user-friendly and fault-tolerant, allowing for the creation of more/better development tools.

4. Rails 7/8 released a ton of exciting new features such as Hotwire, Solid suite, auth generation and others. Promising a simpler way to make high-fidelity applications.

5. The Rails Foundation was created and has focused on improving documentation, organising Rails World and pushing the message of Rails being 'a one person framework' that can get you 'from hello world to IPO'.

6. A growing dissatisfaction with the needless complexity of the Javascript ecosystem and cloud providers, pushing people towards the simple but powerful solutions Rails provides.

All these individual contributions seem to have produced a snowball effect. As a long-time Rails developer, seeing there be a new Ruby and/or Rails post on the front page of HN nearly every day recently has been really exciting.

comment 1y ago · link · parent

I didn't mean to imply you didn't know that stuff, I just tend to write comments from the basics for anyone unfamiliar who may be reading. Yup I would expect it to have an (extremely small) boot time impact. Though I don't think it would have a runtime impact, since surely ruby has to check the frozen flag on mutation whether the flag has been set to true or not? Also by including the gem you preclude mutating the class objects anyway, since it raises an error.

comment 1y ago · link · parent

The gem isn't freezing instances of the objects, but rather the classes themselves. In Ruby (nearly) everything is an object, so for example Array is an object of type Class. Classes are also open by defualt, allowing them to be altered at run time. There's nothing stopping me doing the following in my app:

  irb(main):001* class Array
  irb(main):002*   def hello
  irb(main):003*     puts "hello"
  irb(main):004*   end
  irb(main):005> end
  => :hello
  irb(main):006> [].hello
  hello
This sort of monkey patching is used a lot in the ActiveSupport gem to give convenient methods such as:

  irb(main):001:0> 3.days.ago
  => Sat, 28 Dec 2024 13:10:24.562785251 GMT +00:00
Integer is extented with the `days` method making date maths very intuative.

This gem freezes the core classes, essentially closing them, so doing the above raises an error:

  irb(main):007> require 'refrigerator'
  => true
  irb(main):008> Refrigerator.freeze_core
  => nil
  irb(main):009* class Array
  irb(main):010*   def hello
  irb(main):011*     puts "hello"
  irb(main):012*   end
  irb(main):013> end
  (irb):10:in `<class:Array>': can't modify frozen class: Array (FrozenError)
Looking at the code in the gem, all it's doing is calling https://apidock.com/ruby/Object/freeze on all call modules. The frozen flag is an inbuilt part of the language and as far as I'm aware has a performance benefit. In fact the major verison of Ruby will have all string instances frozen by default.

comment 1y ago · link · parent

The new getting started guide is great. Chris Oliver is a great teacher. Afterwards, if you want a 102-style tutorial, I'm a big fan of https://www.hotrails.dev/. It goes step by step and explains how Hotwire works and how to use it.

comment 1y ago · link · parent

This rapid feedback seems like it will be especially useful when iterating on CSS designs

comment 1y ago · link · parent

Since Rails 7.1 we've had https://www.rubydoc.info/github/rails/rails/ActiveRecord%2FR... which actaully does run queries in parallel.

There's also Rails' russian doll caching, which can actaully results in pages with n+1 queries running quicker than ones with preloaded queries. https://rossta.net/blog/n-1-is-a-rails-feature.html

comment 2y ago · link · parent

I find that a 6-month-old JS project will often not even boot since its exhaustive dependency list will be out of date and now mutually incompatible. You have to feed a JS project with updates every couple of hours, or it will die like a Tamagotchi.

comment 2y ago · link · parent

In languages I'm most familiar with, you can't access variables defined outside of the function within the function unless the variable is a class or global variable. So for example in Python you can do:

  >>> x = "hello"
  >>> def test():
  ...     print(x)
  ...
  >>> test()
  hello
which seems very odd to me. In Ruby you get:

  irb(main):001> x = "hello"
  => "hello"
  irb(main):002\* def test
  irb(main):003\*   puts x
  irb(main):004> end
  => :test
  irb(main):005> test
  (irb):3:in `test': undefined local variable or method `x' for main:Object (NameError)
This makes much more sense to me, since x is defined outside of the scope of test, so why should test have access to it?

comment 2y ago · link · parent

This made me think of this recent tweet from Nate Berkopec, a developer well-known in the Rails community as a specialist in performance and scaling. https://x.com/nateberkopec/status/1846429195670552635

    If you're starting a new Rails app and live in the EU, the optimal strategy is pretty clear:
    
    Get a 64-thread box on Hetzner for 250 euro a month, allocate 20% of it to the DB, 40% to web, 40% to bg, then  just forget about scaling until you're making money hand over fist.
At a certain point, self-hosting is so much cheaper than PaaS that you can way overprovision your server and not worry about it until you're making serious money.

comment 2y ago · link · parent

Manim is incredibly cool, but my biggest takeaway from the video is how insane it is that Python apparently lets you reference a variable in a function that was defined outside the scope of the function.
123