codebyjeff, to programming 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 avatar
SergKoren, to programming avatar

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

stevensanderson, to programming 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), ].

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

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

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



feudjais, to programming 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 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:

blog, to python avatar

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 );}

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:



<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]);


$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.


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.


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


#!/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 = = me["id"]year_joined = me["created_at"].year


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


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


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

fell, to python 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 avatar

Building Large Scale Web Apps A React field guide by Addy Osmani and Hassan Djirdeh is the featured book on the Leanpub homepage! @addyosmani

liztai, to python 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 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 avatar

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

wervice, to programming 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.

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

glassbottommeg, to gamedev 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"

nebyoolae, to Podcast 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:
Show Feed:
Show Home:

gregorni, to emacs 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 avatar

whats the vscode theme that lets u compile faster

davep, to python avatar

About to do a bit more work on the Wayback checker for Tinboard on stream:

alienmelon, to gamedev avatar

new post!
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 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.




codebyjeff, to programming 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


EngineerDaryl, to programming 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.


veronica, to discworld 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