codebyjeff, to programming
@codebyjeff@hachyderm.io avatar

If you're one of those programmers who leaves out any vertical whitespace between functions or blocks of code

wtf is it that motivates you?

membook, to Meme Polish
@membook@rigcz.club avatar
SergKoren, to programming
@SergKoren@writing.exchange avatar

I think I want to get back into BeOS/Haiku. Why? Why not? Maybe I’m feeling nostalgic.

https://www.haiku-os.org

stevensanderson, to programming
@stevensanderson@mstdn.social avatar

🔍 How to Extract Last Row in Data Frame in R

Base R
Use nrow(my_df) to get the total rows.
Extract the last row with indexing: my_df[nrow(my_df), ].

dplyr
Use tail(my_df, 1) to get the last row.

data.table
Convert to data.table: my_dt <- as.data.table(my_df).
Get last row using .N: my_dt[.N].

Now you know three ways to extract the last row. Try it yourself! 📊

#R

Post: https://www.spsanderson.com/steveondata/posts/2024-04-18/

feudjais, to programming
@feudjais@eldritch.cafe avatar

Hey fellow Pythoners !

If you used Kivy, how good is it to make GUI ? Does it really work to make an app which runs both on Linux and Android ? What issues have you encoutered ?

Thanks a lot, please retoot.

Edent, to HowTo
@Edent@mastodon.social avatar

🆕 blog! “Server-Side Rendering of Embedded Markdown Code Snippets in WordPress”

Because I'm a grumpy old man, I don't use Gutenberg or Block themes on my WordPress. Instead, I write everything in Markdown. When I write code snippets in Markdown, they look like this: ```php $a = 1; echo $a; if ($a < 5) { // Do Something return thing( $a, true …

👀 Read more: https://shkspr.mobi/blog/2024/04/server-side-rendering-of-embedded-markdown-code-snippets/

blog, to python
@blog@shkspr.mobi avatar

Server-Side Rendering of Embedded Markdown Code Snippets in WordPress
https://shkspr.mobi/blog/2024/04/server-side-rendering-of-embedded-markdown-code-snippets/

Because I'm a grumpy old man, I don't use Gutenberg or Block themes on my WordPress. Instead, I write everything in Markdown.

When I write code snippets in Markdown, they look like this:

php$a = 1;echo $a;if ($a < 5) { // Do Something return thing( $a, true );}

But I want to render that with code highlighting. I was using the Prismatic Plugin. It is excellent and very customisable. But it uses JavaScript to do the code highlighting. I want to respect my readers' time and battery life; so I'm trying to reduce my dependency on Client-Side rendering.

I've switched to a modified version of WP-GeSHi-Highlight. That turns the above Markdown into:

$a = 1;echo $a;if ($a < 5) {   // Do Something   return thing( $a, true );}

Necessary Changes

When the JetPack Markdown pre-processor encounters a code block, it changes:

```php

into

<code class="language-php">

This means the WP-GeSHi-Highlight detection needs to be changed.

Old version:

return preg_replace_callback(    "/s*".    "(.*)</pre>s*/siU",   "wp_geshi_store_and_substitute",   $s);

New version:

return preg_replace_callback(    "/s*".    "(.*)</code>s*/siU",   "wp_geshi_store_and_substitute",   $s);

One of those matches looks for escaped= which can be true or false. I always want this to be true so, later in the code, I change a variable from:

$escaped = trim($match[3]);

To:

$escaped = true;

Style Changes

By default, everything looks pretty good - but there are a few changes I found necessary to make.

Firstly, there was something weird going on with the line-heights of my style, so I added this to my site's CSS:

/* GeSHI Highlighter Fixes */pre:has(> .wp-geshi-highlight-wrap5) {    line-height: 0;    padding: 0;    background: none;    filter: invert(1);}

The invert gives it a dark mode.

Secondly, in order to make any changes to the default styles of the highlighter, you need to add the bundled wp-geshi-highlight.css file into your style directory. The plugin will use that if it exists - so you can change font size and padding to be the same as your main theme.

Limitations

There are a few limitations with this approach.

No line-numbers. The plugin looks for something like line="13", but there's no way to add that in Markdown.

GeSHi hasn't received style updates on some languages for quite some time. It hasn't received any significant update since 2019. Which means bugs and security issues are likely.

Language definitions are quite strict. You can use javascript but not json.

The plugin doesn't have any options - nor an easy way to override its settings. So I've monkeypatched everything above. If the plugin updates, I'll need to change my code.

Demos

A few demos - just so you can see what it looks like.

Python

#!/usr/bin/env pythonfrom datetime import datetime, timedeltafrom mastodon import Mastodonfrom bs4 import BeautifulSoupimport config#  Set up accessmastodon = Mastodon( api_base_url=config.instance, access_token=config.access_token )#  Get user's infome = mastodon.me()my_id = me["id"]year_joined = me["created_at"].year

Bash

if [ "$(basename $2)" = "Image.gz" ] || [ "$(basename $2)" = "vmlinuz.efi" ]then# Compressed install  echo "Installing compressed kernel"  base=vmlinuzelse# Normal install  echo "Installing normal kernel"  base=vmlinuxfiif [ -f $4/$base-$1 ]; then  mv $4/$base-$1 $4/$base-$1.oldfi

Rust

// This is the main function.fn main() {    // Print text to the console.    println!("Hello World!");}

JavaScript

if (hour < 18) {  greeting = "Good day";  alert( greeting );} 

https://shkspr.mobi/blog/2024/04/server-side-rendering-of-embedded-markdown-code-snippets/

fell, to python
@fell@ma.fellr.net avatar

Even though I despise Python for wasting CPU cycles, I have rarely seen a CPU-limted system that was actually busy doing CPU things.

Most of the time things are only slow because GPU things like rendering and video decoding have to be done on the CPU.

leanpub, to react
@leanpub@mastodon.social avatar

Building Large Scale Web Apps https://leanpub.com/large-scale A React field guide by Addy Osmani and Hassan Djirdeh is the featured book on the Leanpub homepage! https://leanpub.com @addyosmani

liztai, to python
@liztai@hachyderm.io avatar

The one reason why I want to learn is so that I could program my computer to copy my social media posts and just stuff them into my Daily Note automatically. Ambitious or impossible? lol

itamarst, to python
@itamarst@hachyderm.io avatar

Anyone have suggestions for a tech conference in the US that is:

  1. Suitable for both frontend and backend web developers, and
  2. In a state anyone from the US can feel comfortable and safe traveling to?

smashtie, to world
@smashtie@mas.to avatar

Anyone know if I can cherry pick this reality branch back into the one I tagged in 2012?

wervice, to programming
@wervice@fosstodon.org avatar

I am continuing work on Zentrox. Today I almost finished user.c completly. The only problem is, that empty strings get replaced with -1in the databases.

I am working on fixing this as well.

https://github.com/Wervice/zentrox

(Also, thx for 5 stars in just about a day 😃

glassbottommeg, to gamedev
@glassbottommeg@peoplemaking.games avatar

I've been trying to work this whole morning, but my brain keeps spinning back around to "even SockDreams itself, the central website, calls them programmer socks now" https://sockdreams.com/products/xl-foot-extraordinarily-longer-programming-socks

nebyoolae, to Podcast
@nebyoolae@masto.neb.host avatar

New Hacking the Grepson podcast episode is out!

Hacking the Grepson 065: Job Changes

Matt (@messerman) and Mike (@nebyoolae) discuss the ups and downs of making an employment switch.

Episode Link: https://www.podbean.com/eas/pb-jv66r-15ea098
Show Feed: https://feed.podbean.com/hackingthegrepson/feed.xml
Show Home: https://hackingthegrepson.com

gregorni, to emacs
@gregorni@fosstodon.org avatar

My supervisor at CERN uses Emacs with a plugin to emulate Vim bindings! 🤯

He is the true winner of the Vim vs. Emacs wars.

Adorable_Sergal, to vscode
@Adorable_Sergal@hachyderm.io avatar

whats the vscode theme that lets u compile faster

davep, to python
@davep@fosstodon.org avatar

About to do a bit more work on the Wayback checker for Tinboard on stream: https://www.youtube.com/watch?v=wcuRXUtV1ok

alienmelon, to gamedev
@alienmelon@mastodon.social avatar

new post!
Solo-Devs and Risk-Takers (An Artistic Exploration of Experimental Tools)
https://www.nathalielawhead.com/candybox/solo-devs-and-risk-takers-an-artistic-exploration-of-experimental-tools
"Exploring experimental digital work will always be very new by principle that this is an ever growing possibility space where anyone’s wildest dreams can be made true…”

#GameDev #IndieDev #Curation #Art #Programming #FOSS #Software

stevensanderson, to programming
@stevensanderson@mstdn.social avatar

I had previously discussed how to drop those pesky NA records from your data.frame but now, what if you actually want to inspect them? That is what I cover in today's post.

Post: https://www.spsanderson.com/steveondata/posts/2024-04-17/

#R

image/png

codebyjeff, to programming
@codebyjeff@hachyderm.io avatar

I want to be CEO of Atlassian for a day,

so I can put the #$%& description and the #$& comments on different tabs in JIRA

#programming

EngineerDaryl, to programming
@EngineerDaryl@fosstodon.org avatar

People often don't understand that I code for fun in my spare time and code for work on company time. They don't understand that coding on my personal projects is actually giving me energy and is relaxing for me. They say things like "are you honestly programming now? Are you working?" and when I explain them that I'm working on a personal project they suggest that I should "do something relaxing" so I don't get overworked.

#Programming

veronica, to discworld
@veronica@mastodon.online avatar

It's nice to see that the users of my app are noticing that the window title of my fatal error dialog is quoting error messages from Hex, the computer at Unseen University in Ankh-Morpork. 😁

Thankfully, the error is in a pre-release at least. Crashes are not nice.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag4
  • kavyap
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • InstantRegret
  • everett
  • thenastyranch
  • Youngstown
  • slotface
  • GTA5RPClips
  • khanakhh
  • osvaldo12
  • rosin
  • lostlight
  • cisconetworking
  • Durango
  • Leos
  • ethstaker
  • cubers
  • modclub
  • tacticalgear
  • provamag3
  • tester
  • anitta
  • normalnudes
  • JUstTest
  • relationshipadvice
  • All magazines