Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Bernhard Weichel
@bwl21
@Mogztter i came to know that asciidoctor is using Prawn. I tried to compile Prawn with Opal but failed. How do you handle Prawn in asciidoctor.js
Guillaume Grossetie
@Mogztter
@bwl21 Same here, I did try to compile Prawn with Opal but there's still some missing implementations: opal/opal#1697
With a lot of hacks Prawn was running in JavaScript but did not work as expected
Since we are now using web technologies to generate PDF, I stopped working on it
Bernhard Weichel
@bwl21
@Mogztter Thanks. As of now I am using jsPDF with good results for drawings and textannotations. But I would like to support more such as paragraphs, lists etc.
Guillaume Grossetie
@Mogztter
You should give Puppeteer a try to generate PDF using HTML and CSS
Might not work for you if you want a client-side (in the browser) solution
Mitch VanDuyn
@catmando
@bwl21 we are very heavy users of the old wkhtmltopdf but are now beta testing using puppeteer. It seems very stable and well supported. We do a lot with it. If u need any help let me know and I will put u in touch with one of developers
For example custom designs that are rendered using a combination of svg, html 5 and lots of opal and js like this one here https://hyperloop.catprint.com/drafts/new/doodle/1/1261/personalize?category=Holidays&per_page=12
Are then rendered to a print ready PDF Using puppeteer
Guillaume Grossetie
@Mogztter
That's really nice, when you say "print ready" you mean with crops marks and bleeds ? I was looking at a solution to generate them because I want to offer an Illustrator alternative :wink:
Guillaume Grossetie
@Mogztter
(I was checking your Instagram, how many cats do you have ?! 🙀😸😻)
Mitch VanDuyn
@catmando
The customer service department takes in cats that need to find homes. They stay a few weeks or a few months. I don’t know how many we have taken care of over the years maybe 30? They are not allowed in the factory cause they would get hurt, and they could damage the machinery.
Yes we also add all crop marks, bar codes, and other details by layering PDF images that are generated from html / svg. It all goes through wkhmtltopdf ( soon puppeteer)
It’s a Separate Sinatra app that runs on a cloud hosted scalable server farm
The main site is a Hyperstack app
Guillaume Grossetie
@Mogztter
so basically you generate a pdf file then you add layer on this pdf using ?
I really want to know more about this part. Currently I'm generating a A5 flyer (the pdf size is A5) but in order to add crop marks, bar codes, colors etc.. the pdf size should be bigger but I don't really know how to add layers on an existing pdf and if I want to add these details in the source HTML I will need to use a lot of absolute positioning :pensive:
Mitch VanDuyn
@catmando
@/all we are investigating a very strange problem. I am wondering if anybody has ever seen anything like this. I doubt at this point its even anything to do with Opal.
the problem is we have a method like this:
def foo(arg1, arg2, arg3, arg4 = SOME_CONST)
    ...
    puts "arg4 is true" if arg4
    puts "!arg4 is false" unless !arg4  # <---INTERMITTENTLY this line will not print when the line above and below prints!
    puts "!!arg4 is true" if !!arg4
    ...
end
yes its that bizarre
we see
Mitch VanDuyn
@catmando
arg4 is true
!!arg4 is true
however we can't reproduce it in a simple example, we are seeing this in a method used a lot in Hyperstack, and only on safari, and only when the app is minified
we have looked at the minified code, and minification seems to have done nothing incorrect
oh and the problem is intermittent
as in we can do the same sequence and sometimes the bad thing will happen, and other times it won't
oh and if we add more debugging puts and console.log statements the problem frequency goes down
we are thinking some bizarre safari bug???
Mitch VanDuyn
@catmando
oh yeah, and the problem can't be reproduced with debugger console open... so we redirected all console output to a buffer which is printed after the problem is seen.
meh.
@meh
sounds like a race condition in Safari
Elia Schito
@elia
image.png
@catmando have you tried with Safari Technology Preview? https://developer.apple.com/safari/technology-preview/
Mitch VanDuyn
@catmando
so its like the latest edge safari?
@meh @elia yeah we are pretty sure its something to do with JIT as well. if add and ensure block to the method in question (which adds a catch block, which turns off JIT) problem goes away.
the problem is that so far its pretty intermittent, so very hard to get it down to a smoking gun line of code.
Elia Schito
@elia
yep, just to see if it disappears there, could be interesting to whoever receives the bug report. An alternative to reporting via the menu is reaching out to the webkit devs on twitter, from what I remember they're super nice
Mitch VanDuyn
@catmando
okay thanks!
Jose Añasco
@merongivian
hey guys, I'm building this live code editor (for creating music) : http://negasonic.org. I need a way to get the code inside a block as pure text, is it possible?
I need a way to not run the code, unless it has changed (because of performance issues, audio performance in js is really bad he)
Bernhard Weichel
@bwl21
Megasonic.org ist parked ...
Do you plan to run the code with Eval then?
Could you show the code you have right now. It would help understanding your problem.
Jose Añasco
@merongivian
yes, will run it with eval
Elia Schito
@elia
@merongivian you need to require opal-parser then (be aware that the compiled size will grow!)
Mitch VanDuyn
@catmando
@merongivian can u explain a little more?
Mitch VanDuyn
@catmando
You can use eval (or compile) to change text into code. But why do you want to change code back into text?
Jose Añasco
@merongivian

So i'm building this code editor that plays music with code: http://negasonic.org, (similar to sonic pi, tidal cycles, etc) but it works with javascript (compiled with opal). I actually borrowed some of the code from http://opalrb.com/try/ for the text editor.

The idea is that every time i run the code it will reproduce sounds through the web audio api:

# code that generates music

# defining the the synth, effects
with_instrument(synth: :piano, volume: 3) do
   # the cycle is the one in charged of defining the notes
   # being played
   cycle do 
        # notes as numbers
        play 30, 40
   end
end

This is a custom DSL, so under the hood i use instance_eval to evaluate the block in with_instrument. Every time i execute the code for the instrument it will generate a bunch of web audio api objects called audio nodes that are really heavy for the browser, and can not be to destroyed completely after created, so i want to avoid creating them again if the code didn't changed.

Also, i think using instance_eval might be causing me performance issues (i'm using eval for the all compiling all the code, and then eval is used again in instance_eval).

My idea is to just store the code as text inside the instrument object used by with_instrument, and then somehow execute the code inside instance_evalonly if the code is different.

Was looking at BasicObject and seems that it retrieves the code inside the block as text as well, so i think i can create my own version of instance_eval.

Anyway if someone is interested in helping me, or has a better idea let me know :), this stuff is pretty difficult he