The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,825 other followers

Archive for December 3rd, 2019

Thomas Mueller’s Open Source Projects

Posted by jpluimers on 2019/12/03

Since Thomas has been moving projects to OSDN, he now keeps a list of which one is where at [WayBack] My Open Source Projects – twm’s blog

via:

–jeroen

Posted in Delphi, Development, Open Source, Software Development | Leave a Comment »

Automated clicking on HTML elements – Chee Wee’s blog

Posted by jpluimers on 2019/12/03

Magic from the JavaScript console: [WayBackAutomated clicking on HTML elements – Chee Wee’s blog: IT solutions for Singapore and companies worldwide.

This is the code he uses because [WayBackgetElementsByClassName returns an array ([WayBack] getElementById returns one reference or null, but many sites still develop without assigning an ID to their elements):

function clickRefresh() {
  ImStillHere = document.getElementsByClassName("Button Success");
  if (ImStillHere.length > 0)
    ImStillHere[0].click();
  document.getElementsByClassName("refresh-widget")[0].click();
}
setInterval(clickRefresh, 1000);

via: [WayBack] function clickRefresh(){ … – CHUA Chee Wee – Google+

I like the approach. Now I need to find a way to automate this in some kind of plug-in.

–jeroen

Posted in Development, JavaScript/ECMAScript, Scripting, Software Development | Leave a Comment »

bash: converting numbers to human readable SI or IEC units

Posted by jpluimers on 2019/12/03

Many unix tools that report sizes in bytes can convert them to either IEC or SI readable formats.

For github.com/jpluimers/btrfs-du/blob/master/btrfs-du I wrote about last week, I also wanted that kind of behaviour. So I did some research and came up with the code and test cases below.

Note that depending on the bitness of your system, bash integer numeric values are limited in size; see [WayBack] What is the maximum value of a numeric bash shell variable? – Super User.

So I wrote a small bash script for that too, which needed also gave me the opportunity to show how a  perpetual while loop as explained by [WayBack] bash – “while :” vs. “while true” – Stack Overflow.

Two things that always bite me with these short scripts are expressions (done through [WayBack]Arithmetic Expansion) and comparisons (through[WayBack] Other Comparison Operators).

The IEC suffixes contain one extra i to indicate binary and – next to the ISO notation that were already ISO defined – made it into the ISO 80000 standard since 2008. Here is a comparison list from [WayBackBinary prefix – Wikipedia:

Prefixes for multiples of
bits (bit) or bytes (B)
Decimal
Value SI
1000 k kilo
10002 M mega
10003 G giga
10004 T tera
10005 P peta
10006 E exa
10007 Z zetta
10008 Y yotta
Binary
Value IEC JEDEC
1024 Ki kibi K kilo
10242 Mi mebi M mega
10243 Gi gibi G giga
10244 Ti tebi
10245 Pi pebi
10246 Ei exbi
10247 Zi zebi
10248 Yi yobi

Most tools nowadays default to binary IEC suffixes for byte sizes, though disk manufacturers still use SI suffixes because, well then they appear bigger but aren’t. Just for comparison, look at the numbers from [WayBack] File size – Wikipedia and [WayBack] IEC and SI Size Notations – AN!Wiki where I got the test cases from:

Read the rest of this entry »

Posted in *nix, *nix-tools, bash, bash, Development, Power User, Scripting, Software Development | Leave a Comment »

 
%d bloggers like this: