Show HN: Ray.so – Create images of your code
ray.so
ray.so
I initially used carbon.now.sh, but they don't have an API, and the community-provided API is pretty slow because it uses a headless browser to generate the image.
Source Code Shots uses VSCode's syntax-highlighting engine, so the highlighting is about as good as you can get and I can fully support a lot of languages that CodeMirror or Highlight.js haven't gotten to.
The docs, https://sourcecodeshots.com/docs, have plenty of examples of how to use it as an API. You can email me at daniel@onegraph.com if there's something you need that it doesn't support.
Since I suspect the cause here is copy-pasting off of an algorithms/code gallery, my guess is that there are examples across other languages. I checked everything I feel idiomatically comfortable enough and the others all seemed fine, but there are a lot of options here so who knows.
For the languages I don't know, I looked at the code people posted on rosettacode.org
It's a very imperative process and fairly slow on a cpu, but the nice thing is that I can run the same code in the browser to speed up development. The Rust project, https://github.com/Aloxaf/silicon, mentioned in another part of the comments is probably faster, but I didn't find it when I was searching for a solution.
Is there some way to get a CSS snippet out for publishing in a blog/article/presentation or is it only images?
edit: is this purely to add a rounded border/pad that you wouldn't get with WND+SHIFT+S / CMD+SHIFT+4 for sharing on sites where you don't control the style?
- Easy to view and understand the image of the code v/s the code block text when using a mobile device. Why? Easier to scroll images v/s text.
- Members will no longer have to rely on the issue reporters and commenters to format their code blocks correctly. Using the in built formatter, the code is always structured properly
- Maintainers can style the code blocks to suit their project's language and guidelines and not put the onus of this on the issue reporter / commenter
This uses carbon (https://github.com/carbon-app/carbon)
The Github Action in question: https://github.com/callmekatootie/carbonate
Maybe I'm missing the point. I get that it's easier to look at than pastebin, but I'm struggling to grasp what else. I've always agreed that LOC is a terrible measurement, and similarly I don't delude myself into thinking positioned or colored code is more functional.
The cleaner fake UI of this site, uncluttered by any warning or other editor glyphs, and the auto-resize make it slightly more convenient than an editor screenshot I suppose.
But still...why not print screen?
The #1 missing feature is the ability to select a different typeface. #2 would be the ability to serve up an image from a URL like a pastebin or a-la speedtest.net speed test (https://www.speedtest.net/result/10946633415.png)
When creating a service that allows people to “show off” bits of their code, why stifle them in making it feel like it’s theirs?
I know it should have been more obvious, but I didn't realize the text was editable. I was looking for an 'upload your code' button. Maybe put one of those "Try Me!" badges with an arrow pointing to the code like on toy boxes?
One of the shortcomings of HTML/CSS seems to be that you can not style the cursor a.k.a caret.
The goal for most people is to strike a balance between form and function. In my opinion, I personally think you should always err on more function than form, but the Apple-esque UI design philosophy tends to favor form over function - you know, getting rid of "ugly" UI elements that traditionally telegraphed functionality.
My only suggestion is these code snippets are fire on Twitter for a lot of people getting their RT/likes/following on.
Specifically, that means maybe adding an option for forcing some sizes that are ideal for share graphics (width/height, auto font-size, auto centering, etc..). Take the guess work out of it. Good luck!
Before: https://ibb.co/ZYxxFY5
After: https://ibb.co/PC98vDr
Beauty is subjective and I do not resonate with the cliche aesthetic (gradients, flat UI, soft pastel colors, rounded corners). It's a trend and it will come and go. I am inclined towards the timelessness of the International Style, Swiss Graphics, Brutalism, ultra modernist and offensively low-aesthetic-value aesthetics such as: https://git.sr.ht/~sircmpwn/core-go/tree/master/item/server/...
You can add emojis, custom images, place logos of your favourite programming language or service, add twitter/facbook instagram handles, custom background.
Apart from the screenshot module, codekeep allows you to store and share code snippets, most of the ui is inspired from google keep and i have added more features on top of that, we named it codekeep (google keep for code snippets).
do checkout and let us know your thought :-) https://codekeep.io/screenshot
I guess a similar process could work for other blogging platforms.
And, anyway, most people would rather clone the public repo or use GitHub for copy/paste purposes.
The dark/light definitely look good on most palettes regardless, so great defaults.
Also, there's no syntax option for plain C, but that's an understandable oversight since a good 99% of C's syntax is shared with C++ anyway.
Lastly, when writing C/C++ it auto-detects Objective-C. Just a few things I detected as a primarily C & C++ developer.
Other languages seem to come out great, and it's really a very nifty tool in the end.
Update: C# and Java seem to have a similar lack of coloring.
I could see something like automating a typesetting tool working however.
Edit: Side note, I'm kinda an idiot, so I could be wrong about web not being the right platform.
Anyway you can use some type of cloud IDE to run these examples. For JavaScript that should be pretty easy
- Easy to view and understand the image of the code v/s the code block text when using a mobile device. Why? Easier to scroll images v/s text.
- Members will no longer have to rely on the issue reporters and commenters to format their code blocks correctly. Using the in built formatter, the code is always structured properly
- Maintainers can style the code blocks to suit their project's language and guidelines and not put the onus of this on the issue reporter / commenter
Reference: https://github.com/callmekatootie/carbonate
I used Carbon to generate the images in this case - but you get the gist of what one can use images of code for
Do you want retyping-bugs? That’s how you get retyping-bugs.
I don't want to come across as all too negative, but it somehow feels really strange to have so many websites that basically just take a fancy screenshot of text. To me it kind of comes across like a developer version of those Instagram pictures of meals at restaurants.
Edit: Perhaps something can be done by somehow embedding the content into the image (EXIF?) Metadata?
https://help.twitter.com/en/using-twitter/picture-descriptio...
Twitter etc should really already have standardised on a way to store the ALT text in an image so it only ever needs to entered once.
Even GIF has support for text in a couple of different forms.
( Although I learned something new about PNG's support for GIF's text support here: http://www.libpng.org/pub/png/book/chapter11.html#png.ch11.d... )
( I've spent far too long reading the GIF spec in relation to my project that adds audio to GIFs: http://audiogif.rancidbacon.com :) )
What do you know, people love fancy and decorative things. Just human nature.
The other is documentation for code, something that visually impaired people are able to do if the documentation is accessible.
<svg role="img" aria-label="[title + description]"> <title>[title]</title> <desc>[long description]</desc> ... </svg >
I guess those pictures are popular because food is easy to relate to, and people build lots of social interactions around eating. Developers also relate to things about code, and like to share those relations among each other.
I feel some puzzlement about the format too, though. These days it's so easy to make text on the web look nice, and it's easily accessible, copyable and searchable.
Too bad Twitter isn't a tech company, otherwise they could implement something like a code view in tweets. Wait a minute…
And when you actually have control over the content you can use some nice CSS to get the same look with a fraction of the size and 100% accessible.
Facebook: https://www.facebook.com/help/214124458607871
Instagram: https://help.instagram.com/503708446705527
It's becoming a lot more common!
Here's one: people want to share formatted snippets on Twitter. They often post a link to the code below the pic, but being able to see it within the tweet is quite useful.
Though in my case I have a plugin for Notepad++ that lets me copy syntax highlighted code from NP++ and paste it into PowerPoint with all the highlighting and formatting maintained. Super cool plugin.
I can't just screenshot my editor (VSCode) because I use a theme that many people find violently irritating (DOS Edit).
Anyway, this looks like someone's fun little hacked together project to make something shiny. Making shiny things is fun. No one craps on shader toys for being inaccessible.
If someone tried to use the linked tool to make screenshots and used them in an actual MOOC or any other place for public consumption, yeah, wrong tool for the job. Don't do that. Use one of the dozens of existing tools that pretty print and embed code in an accessible way.
If this tool created an accessible SVG instead of a PNG then I think it would be getting a lot less criticism. There are accepted ways[0] to make SVGs accessible, and they are better for performance than the alternatives.
When you give people shiny tools that make it hard for visually impaired people to consume information, then more of that sort of content will be embedded in blogs, presentations, MOOCs or whatever else.
PowerPoint and Google Slides should really just get their act together with regards to rendering code blocks. It’s quite sad that in today’s world they still don’t have a built in way to show code on slides in a formatted and colorized way.
My Slack is similarly setup, to the limits that the themeing in Slack allows. :)
Sure let me watch your boring 25 minutes video just to MAYBE get a glance on that one line of code i am looking for...
The only missing feature I really need is Elixir syntax support (even though Ruby works for most examples)
Elixir's notably missing ;)
R.I.P. : (