Quick Tip: Cool features of Chromium DevTools

Chromium Developer Tools is a powerful suite with many features you probably didn’t know about. Here are three of them I find very helpful, but not so popular.

DevTools console output with style

When you output to the console, you can also style text. This is done by putting %c sequence before the styled block. There can be more than one such block. Then you pass CSS styles in the following arguments:

console.log("%cHello developers!\n%cThis is a sample message.", "font: bold 14px/1.35 Arial;", "font: normal 12px/1.35 Arial;");

Styling text in Dev Tools

Copy JavaScript content to clipboard

Dev Tools allow you to copy to clipboard the value of a variable. You just have to invoke the copy function:

var test = "Lorem ipsum dolor sit amet enim";
copy(test);

And now you can paste string Lorem ipsum dolor sit amet enim anywhere.

Make the whole website editable

This is not so much a tip regarding console, you can paste the code there. You can allow editing any text on the web page simply setting

document.body.contentEditable = true

Now you will be able to put the cursor inside every text block and modify it as you want.

WordPress plugins: Creating widgets

I noticed my series on WordPress plugins misses widgets. It’s a good fortune because I needed to show some social icons in the sidebar.

This is how the widget looks like.

You will find the source code in my repo: https://github.com/kantoniak/kantoniak-about-me, along with the link to vector icons made by Allan McAvoy.

Update: Plugin is already available here: https://wordpress.org/plugins/kantoniak-about-me/. To install it from the dashboard, go to Plugins/Add New, change search criteria to Author and look for kantoniak. Continue reading

How to submit to WordPress Plugin Directory

It’s the time to start uploading to extension gallery. We have created two plugins so far:

I will describe the process on the example of the second one. You can find it here: https://wordpress.org/plugins/demo-shortcodes/. To install it from the dashboard, go to Plugins/Add New, change search criteria to Author and look for kantoniak.

Plugin preview

Continue reading

WordPress plugins: Using shortcodes and popups

I made a plugin to render HTML before page content (see “How do I make a WordPress plugin?“), but I needed another one. This extension adds “see demo” blocks inside content. I just give links to preview, set image and eye-pleasing blocks appear in place of shortcodes.

The extension is available from a GitHub repository; you can go there to see every line of code. I will try to send it to plugin repository shortly.

Update: Plugin is already available here: https://wordpress.org/plugins/demo-shortcodes/. To install it from the dashboard, go to Plugins/Add New, change search criteria to Author and look for kantoniak.

Demo plugin preview

OK, let’s go! Continue reading

How do I make a WordPress plugin?

I post progress summary for Konstruisto on Fridays, but not everybody knows what this project is. Every week I have to paste the same formula at the top. It shows in the RSS feed, it generates pingbacks to my articles and is unhandy in many other ways.

I thought I would make a WordPress plugin to solve these problems. It was a great opportunity to refresh my knowledge about the system – I hadn’t used WordPress for three years! Continue reading

How to draw in browser with Selenium

Selenium is a testing tool used in web development. It emulates user behavior inside a web browser, right in front of you. It can interact with links, move the mouse and so on. As an example, we will make a script that draws a simple shape in Sketchpad. Selenium has many integrations; I will use Python and Google Chrome driver. And everything under 60 lines of code!

Continue reading

Quick Tip: Google Charts for your website

Recently I found out about great charting library and I’m astonished to see how easy it was to integrate it into a project. Google Charts is a free, pure-JS library. You embed the script, write about ten lines of code and it works.

Hello charts!

Include link to library hosted by Google:

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

We just add the data and it works:

Continue reading