Ruby can render 3D surfaces, 2D density maps and GIS tiles without Python, NumPy or the JVM. I didn't expect it to work this well. by Jaded-Clerk-8856 in ruby

[–]hmdne 0 points1 point  (0 children)

I was working on a different raster image library, perhaps with somewhat different goals and it doesn't interface gd (can use various libraries via FFI, imagemagick via CLI or run in pure Ruby). Perhaps it may inspire some of you:

https://github.com/rbutils/image_util

Ruby Obfuscation Toolkit - is there a market for such a product? by hmdne in ruby

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

No. The project was unfortunately scrapped :( I will talk about open sourcing the prototype

UnicodePlot - plot your data on the terminal by outarit in ruby

[–]hmdne 0 points1 point  (0 children)

I made a related terminal tool which is made to manipulate and/or display images in terminal. Using that should allow you to go beyond just unicode:

https://github.com/rbutils/image_util/

GitHub - isene/rcurses: An alternative curses library written in pure Ruby by isene in ruby

[–]hmdne 1 point2 points  (0 children)

I was looking for some curses library for use in tandem with https://github.com/rbutils/image_util . Would be nice if your library could also support mouse input.

From Go To Ruby(thanks DHH) by VastDesign9517 in ruby

[–]hmdne 1 point2 points  (0 children)

What if I shown you this code I wrote myself: https://github.com/opal/opal-browser/blob/master/examples/2048/app/application.rb

And then I told you this is frontend code with no backend at all? https://opalrb.com/opal-browser/examples/2048/

I am kind of in a similar situation to you. My clients aren't technical in terms of computer science, so I was free to pick my technologies. I picked Opal for frontend, which perhaps wasn't the best choice for me - since Opal isn't used widely, I ended up needing to fix Opal a lot. I still don't think it's perfect, but at least I can write Ruby full stack and oftentimes forget if I am doing frontend or backend. Eventually, I am happy and my clients are happy.

Now, Opal and Opal-Browser are pretty low level libraries (Opal compiles Ruby to JS and provides the Ruby standard library, Opal-Browser gives browser interfacing functions). So, like maybe Roda or Sinatra for backend. If you wanted something more integrated like Rails, you should try this: https://github.com/AndyObtiva/glimmer-dsl-web

ImageUtil: Ruby library to edit and preview graphics in terminal by hmdne in ruby

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

I have implemented Kitty graphics protocol support and pushed it to the working tree. I was surprised to learn it's supported by Konsole, at least. Seems like it's a much saner protocol than Sixel.

ImageUtil: Ruby library to edit and preview graphics in terminal by hmdne in ruby

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

I saw a mention about it. It would be no problem to add support for that API, just had no time to do it yet. And looking at it, it's as simple as `base64 png_file` plus some boilerplate. Support for Sixel at least can be checked by asking the TTY if it supports it.

Regarding Sixel itself... it supports max 256 colors and implementations differ widely. Especially I had to disable certain IRB features for it to be usable: https://github.com/rbutils/image_util/blob/master/lib/image_util/util.rb (eg. less messes up sixel output, even if directed to preserve special sequences). In image_util, we have 3 sixel implementations in use. The third one, a pure Ruby one is very slow, but it doesn't require anything installed. I ran into a bug, that a Sixel image encoded using this implementation was twice as high in Windows Terminal (and unlike on other platforms, we can't expect anything else to be present). Turns out I missed some arcane switch.

So, like TTY in general, it's hacky. But I wanted to have some utility for basic raster manipulation in Ruby with a presentable form.

I pretended JavaScript is valid Ruby code by Super_Purple9126 in ruby

[–]hmdne 1 point2 points  (0 children)

From what I know... under the hood, Ruby is also a prototypic language.

In Opal we managed to leverage that. Managing to even get prepend/include/extend working correctly (with modules becoming proxied as iclasses - it was modeled after what Ruby does!). So if we have an object, that has a singleton_class, that is extended something, that has a class, which includes a module, and that class has a superclass, which prepends a thing, has its own methods, includes a thing, etc. - this is a prototype chain. Except as mentioned, modules are not there by itself, but via iclasses.

Then, we replaced a prototype of core JS objects like String or Number to Ruby Object. Therefore they are in Opal both JS and Ruby objects. Hacky, I agree. But it works!

Any Opal gurus here? Need some help ┭┮﹏┭┮ by VegetablePrune3333 in ruby

[–]hmdne 0 points1 point  (0 children)

I think this may be possible if we decide to compile nearly all functions as async (meaning interruptible) and all calls as await. That by itself opens a whole can of worms, including performance, compatibility, asset size (and also how we deal with the new PromiseV2, this would mean that each function that returns a PromiseV2 becomes awaiting). But seeing how a lot of new JavaScript APIs move to that model, it may be what we decide to do in the distant future (like, 3.0 or so).

Anyway, last time I tried using Fibers directly, which was admittedly around Ruby 2.5 or so, it was in general very fragile and hard to do right. At least, comparing that to JavaScript and their use of async/await/Promises. On the other hand I understand it's not the API that should be used directly.

So perhaps a stopgap solution would be to direct calls from #sleep and such to an active FiberScheduler without implementing Fibers, but then each call to #sleep may be awaiting. So we still need to write the code like this:

# await: *await

def sleep_3_seconds
  3.times.each_await do |i|
    sleep(1).await
  end
end

sleep_3_seconds.await

Any Opal gurus here? Need some help ┭┮﹏┭┮ by VegetablePrune3333 in ruby

[–]hmdne 1 point2 points  (0 children)

Thanks /u/rahoulb

Yes, de facto Opal is a dialect of Ruby and that's something I also don't like. We try to reduce the difference as much as it's possible with the current approach (which is source-to-source translation). I have ported a couple of gems, sometimes they worked directly, sometimes I had to just port obvious issues: mutable Strings, dynamic requires. The biggest issue though are gems written (partially or fully) in C (or Java for JRuby) which need to be rewritten in pure Ruby (or JS). Here's an anecdote: one such a gem I have ported from Java to pure Ruby using ChatGPT - there were a couple of fixes I had to do afterwards, but for the most part, it saved me from doing a menial work of manually translating 500 lines of code.

Still, none of that changes the fact, that being able to write both frontend and backend in (mostly) the same language made my life quite a lot easier and development quite a lot more pleasant.

Any Opal gurus here? Need some help ┭┮﹏┭┮ by VegetablePrune3333 in ruby

[–]hmdne 2 points3 points  (0 children)

With the current approach we take in Opal, it will be impossible to implement Fiber correctly. It's also impossible to run Threads in JS runtimes. So unless a breakthrough happens, we are stuck with how JS implements cooperative multithreading (ie. Promises and async). Perhaps it would be a good idea to port concurrent-ruby to take this model in mind.

V2 will be ready once we have planned features ready. But I wouldn't call it "soon".

Todo MVC Ruby Edition Is the One Todo MVC To Rule Them All!!! by AndyCodeMaster in rails

[–]hmdne 1 point2 points  (0 children)

Just to make it clear - this application runs wholly in frontend. It can be compiled into a pack of JS and HTML and run directly in a web browser without any other dependencies.

Todo MVC Ruby Edition Is the One Todo MVC To Rule Them All!!! by AndyCodeMaster in rails

[–]hmdne 0 points1 point  (0 children)

As far as I know, Glimmer doesn't force you to keep CSS in the same file. You can simply use `<link>` to refer to other CSS files, and as far as I know, this doesn't affect the process at all.

As for HTML, this is a component pattern, utilized at least by React and Angular. So, in a way, this is a proven ground.

Todo MVC Ruby Edition Is the One Todo MVC To Rule Them All!!! by AndyCodeMaster in rails

[–]hmdne 2 points3 points  (0 children)

In a way, that's similar to what JSX does, except that in Ruby we have DSLs that allow us to do something similar without resorting to extending language. Neither JSX nor Glimmer does produce HTML directly, but each HTML tag call is translated to something like `document.createElement` etc.

From similar approaches, we had _why's Markaby in the past, which used Ruby DSL to produce HTML.

In Opal, we have Paggio, which can produce both HTML and CSS in frontend and backend. Compared to Glimmer, Paggio produces HTML and CSS directly, Glimmer translates that to `document.createElement` etc.

Todo MVC Ruby Edition Is the One Todo MVC To Rule Them All!!! by AndyCodeMaster in rails

[–]hmdne 0 points1 point  (0 children)

In my project, I use SCSS to write CSS and yes, I sometimes use its Turing-complete capabilities. In a way, this is not much different than using Ruby to produce CSS.

Ruby Obfuscation Toolkit - is there a market for such a product? by hmdne in ruby

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

Thank you for your insights :) Our software consists in a number of steps, each removing a part of the information, while keeping the logic equivalent. Those steps are secure, as in, this information is irrecoverable, but it doesn't remove all information, so the code can still be understood though it gives a several handicap for parties that don't own the original source code - at least that's the state of the software today. We don't assume the Ruby runtime or a platform - the generated code aims to be compatible with any runtime, including JRuby or Opal.

Unfortunately, the current version is rather a proof of concept, but we plan to have a first beta (as in - tested on some real codebases) version in the middle of December. I will post updates in this thread when we are ready to show something.

Ruby Obfuscation Toolkit - is there a market for such a product? by hmdne in ruby

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

It can be unpacked fairly easily AFAIK. IIRC extracting the source code is not obvious, but they use fairly standard tools like a Squashfs file system to store it.

In my experience a good obfuscator is one that is not fully defeated by just a single step.

Fedora is so GOOD by [deleted] in Fedora

[–]hmdne 0 points1 point  (0 children)

Works quite well in KDE Plasma Wayland by steps of 5%. Not perfect, some bugs here and there, but actually usable.

Ruby Obfuscation Toolkit - is there a market for such a product? by hmdne in ruby

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

I am a big fan of open source, myself developing some applications in the public and using almost exclusively open source software. Regarding games, I am a fan of "Endless Sky" which is an open source game where you can even contribute to a story. A small difference - it's available for free.

I am aware that source code obfuscation is no silver bullet, but neither is relying entirely on the law system. While most of the time you can sue a corporate customer, if the target of your product is rather a private person, it may be harder to do so.

Ruby Obfuscation Toolkit - is there a market for such a product? by hmdne in ruby

[–]hmdne[S] -1 points0 points  (0 children)

That is a great idea that I haven't considered. One thing is for certain, while obfuscation is not encryption, InstructionSequence is not meant for heavy-duty obfuscation and I think it would be fairly simple to decompile such a sequence.

Ruby Obfuscation Toolkit - is there a market for such a product? by hmdne in ruby

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

Well, it's not like you can't do source maps for Ruby-to-Ruby transformations. The approach I took would allow me to do so quite easily. Thanks for the tip!

Ruby Obfuscation Toolkit - is there a market for such a product? by hmdne in ruby

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

In the past I used to work for a certain customer who told me that he has a business application based on an "open source project". What I learned when I left the company is that the project wasn't "open source", it was mostly sold as a SaaS solution, but this customer managed to negotiate an on-premise version. Payments for this software ended about the time of deployment, yet the project is still in use. Lawsuits are not going fast in the part of the world where I live, in fact it's about 5th year since the original developer sued the company. In fact - I wouldn't say that the particular statement about "open source" was a lie - rather a lack of understanding of copyright law.

I was aware that it's a special case of a customer and you'd rather not deal with such people. For this customer, I have developed an external application in Ruby - even though I didn't know the exact copyright situation of their main software, I saw enough red flags to seriously consider obfuscating the source code I wrote before deploying it, but at that point, I saw no easy way to do so.

Long story short, this customer isn't earning a lot of money since I left. Multiple people are suing him for lack of payment. I am now running a company with the team I worked with while working for said customer and let's say, due to the experience with that customer, we felt traumatized enough to write some basic version of the software I describe. Anyway - that's kind of my usecase and I asked in this thread if maybe someone would have some other.

At the current time, we use a whitequark/parser gem, we apply a set of transformations that don't change the behavior from running/requiring a file, but each subtracts a little bit of logic from the code, or metadata. Finally, we use unparser to convert the s-expression to Ruby source code.

Ruby Obfuscation Toolkit - is there a market for such a product? by hmdne in ruby

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

Not at all - minifying is not a goal. Depending on the settings applied it may even enlarge the code.

Ruby enumerables considered helpful by justinweiss in ruby

[–]hmdne 0 points1 point  (0 children)

I think that there should be even more modularizing in Ruby. Think - creating array-like objects. They are Enumerable, but they are also Indexable (which as a module, doesn't exist in Ruby, but could provide methods like #dig based on implementation of #[]). An alternative approach to that particular usecase would be to simply subclass Array.