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,862 other subscribers

Archive for 2019

Structure and Interpretation of Test Cases : Kevlin Henney on Vimeo

Posted by jpluimers on 2019/08/28

Must watch when you do unit testing (no matter the environment): [WayBackStructure and Interpretation of Test Cases : Kevlin Henney on Vimeo which he presented at Javazone 2018 [Archive.is]

via [WayBack] Kevlin Henney – Google+

–jeroen

Posted in Agile, Conference Topics, Conferences, Development, Event, Software Development, Unit Testing | Leave a Comment »

Passing multiple parameters to a Python method: the * tag

Posted by jpluimers on 2019/08/28

I had to pass parameters to a method so they became a list:

    threadManager.append(
        UrlMonitorThread(monitor, "http://%s" % targetHost),
        SmtpMonitorThread(monitor, targetHost, 25),
        SmtpMonitorThread(monitor, targetHost, 587),
        SshMonitorThread(monitor, targetHost, 22))

This appeared much easier than I anticipated:

    def append(self, *threads):
        for thread in threads:
            self.threads.append(thread)

It uses the * tag which is explained here:

–jeroen

Posted in Development, Python, Scripting, Software Development | Leave a Comment »

Counting rows for all tables in Firebird

Posted by jpluimers on 2019/08/28

Sometimes you want to count data in all tables on a database to get a feel for the orders of magnitude, but you cannot use the approximated example in How to speed up Count(*) in Interbase/Firebird – Stack Overflow as those require primary keys.

Then the below script can help: it generates the right queries as a union all ordering by the count in the tables.

Example generated code on C:\Program Files (x86)\Firebird\Firebird_2_5\examples\empbuild\EMPLOYEE.FDB:

SQL
--------------------------------------------------------------------------------------------------
select 128 as id, 'COUNTRY' as name, count(*) from "COUNTRY" union all
select 129 as id, 'JOB' as name, count(*) from "JOB" union all
select 130 as id, 'DEPARTMENT' as name, count(*) from "DEPARTMENT" union all
select 131 as id, 'EMPLOYEE' as name, count(*) from "EMPLOYEE" union all
select 133 as id, 'PROJECT' as name, count(*) from "PROJECT" union all
select 134 as id, 'EMPLOYEE_PROJECT' as name, count(*) from "EMPLOYEE_PROJECT" union all
select 135 as id, 'PROJ_DEPT_BUDGET' as name, count(*) from "PROJ_DEPT_BUDGET" union all
select 136 as id, 'SALARY_HISTORY' as name, count(*) from "SALARY_HISTORY" union all
select 137 as id, 'CUSTOMER' as name, count(*) from "CUSTOMER" union all
select 138 as id, 'SALES' as name, count(*) from "SALES" order by 3

Example output on C:\Program Files (x86)\Firebird\Firebird_2_5\examples\empbuild\EMPLOYEE.FDB:

ID NAME COUNT
133 PROJECT 6
128 COUNTRY 14
137 CUSTOMER 15
130 DEPARTMENT 21
135 PROJ_DEPT_BUDGET 24
134 EMPLOYEE_PROJECT 28
129 JOB 31
138 SALES 33
131 EMPLOYEE 42
136 SALARY_HISTORY 49

The generation code below uses a few tricks:

The rank helps me distinguish the last row (for the order by 3 clause) and other rows (for the union all clauses).

Generation code:

with tables(id, name) as (
    -- http://www.firebirdfaq.org/faq376/
    select r.RDB$RELATION_ID as id, trim(r.RDB$RELATION_NAME) as name
    from RDB$RELATIONS r
    where 1=1
      and (r.RDB$SYSTEM_FLAG is null or r.RDB$SYSTEM_FLAG = 0)
      and r.RDB$VIEW_BLR is null
    order by 1
  ),
  ranked_tables(id, rank, name) as ( 
    -- http://www.firebirdfaq.org/faq343/
    select tables.ID, count(others.id)+1 as "rank", tables.NAME
    from tables
    left join tables others on others.ID < tables.ID
    group by "ID", "NAME"
    order by "rank"
  ),
  parts(id, rank, name, suffix) as (
    select ranked_tables.id, 
            ranked_tables.rank,
            ranked_tables.name,
      case
        when ranked_tables.rank = 1 then 'union all' -- first 
        when ranked_tables.rank = (select count(*) from tables) then 'order by 3' --last 
        else 'union all' -- middle
      end as suffix      
    from ranked_tables 
  ) 
select -- parts.id, parts.rank, parts.name, parts.suffix,
       'select '||parts.id||' as id, '''||parts.name||''' as name, count(*) from "'||parts.name||'" '||parts.suffix||'' as SQL
from parts
order by parts.id

–jeroen

Read the rest of this entry »

Posted in Database Development, Development, Firebird, Software Development, SQL | Leave a Comment »

git add remote with tracking

Posted by jpluimers on 2019/08/27

Since I keep forgetting this and the top search for “git remote add” “tracking” do not answer it (see for instance …):

git remote add gitlab https://user@gitlab.com/group/subgroup/repository.git -t master

This adds a new gitlab remote on the repository path https://user@gitlab.com/group/subgroup/repository.git tracking branch master.

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Source Code Management | Leave a Comment »

« In practice, the uptime of systems that favor availability have not proven …

Posted by jpluimers on 2019/08/27

via [WayBack] « In practice, the uptime of systems that favor availability have not proven greater than what can be achieved with consistent systems. » Aua, der hat gesessen. – Kristian Köhntopp – Google+:

–jeroen

Posted in Cloud Development, Database Development, Development, Software Development | Leave a Comment »

…short presentation at the Norway Delphi Club[1] meetup, covering some fun and interesting uses of the “new” language features introduce since Delphi7… – Asbjørn Heid – Google+

Posted by jpluimers on 2019/08/27

From [WayBack…short presentation at the Norway Delphi Club[1] meetup, covering some fun and interesting uses of the “new” language features introduce since Delphi7… – Asbjørn Heid – Google+

Yesterday I did a short presentation at the Norway Delphi Club[1] meetup, covering some fun and interesting uses of the “new” language features introduced after Delphi 7.

The main purpose of the talk was to try to be inspirational, and give a sense of what kind of stuff you can do with the language these days. So it’s not very in-depth, but rather tries to showcase several interesting features and tricks.

Anyway, in case it might be useful to others I thought I’d publish the slides and code here as well.

The examples are a nice introduction for when you want to dig deeper in the language itself, for instance when you are digging deeper into Spring4d.

Slides 35 and 36 – though hard for me to grasp initially – show a very nice concept called [WayBack] Partial Application (thanks Stefan Glienke for pointing me at this) by binding a parameter value plus parameter position to an existing function returning the bound function so it becomes easier to tall.

–jeroen

Read the rest of this entry »

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

How to Update All Your Ruby Gems At Once | Life, the Universe, and Everything

Posted by jpluimers on 2019/08/26

This looks smart

gem update `gem list | cut -d ' ' -f 1`

From: [WayBack] How to Update All Your Ruby Gems At Once | Life, the Universe, and Everything

Though on the bash prompt, it works fine on Mac OS X / OS X / macOS / …, it does not work nice as an alias.

You can get it to work with difficult escaping (or nesting).

But it is easier to escape this:

gem update $(gem list | cut -d ' ' -f 1)

Escaped, it comes down to:

alias "gem-update-all=gem update \$(gem list | cut -d ' ' -f 1)"

Based on:

–jeroen

Posted in Apple, bash, bash, Development, Mac OS X / OS X / MacOS, Power User, Scripting, Software Development | Leave a Comment »

There are still sites limiting password lengt to low values like 20 or 15. Don’t!

Posted by jpluimers on 2019/08/26

There are still sites limiting password lengt to low values like 20 or 15. Don’t!

The why at [WayBackImplement Proper Password Strength Controls: Password Length has been in place since October 2012, since when cracking passwords has become way faster, so risk at length 20 back then is now a risk at something like length 40.

Password Length

Longer passwords provide a greater combination of characters and consequently make it more difficult for an attacker to guess.

  • Minimum length of the passwords should be enforced by the application.
    • Passwords shorter than 10 characters are considered to be weak (NIST SP800-132).

While minimum length enforcement may cause problems with memorizing passwords among some users, applications should encourage them to set passphrases (sentences or combination of words) that can be much longer than typical passwords and yet much easier to remember.

  • Maximum password length should not be set too low, as it will prevent users from creating passphrases. Typical maximum length is 128 characters.
    • Passphrases shorter than 20 characters are usually considered weak if they only consist of lower case Latin characters.

–jeroen

via:

 

Posted in LifeHacker, Power User, Security | Leave a Comment »

Herbie Mann – Push Push 1971

Posted by jpluimers on 2019/08/26

I think I got the link to this song via Jan Wildeboer. It’s awesome: https://www.youtube.com/watch?v=iR64lF2agbM – Herbie Mann – Push Push 1971

–jeroen

Posted in Music, Power User | Leave a Comment »

Help:Links – MediaWiki

Posted by jpluimers on 2019/08/23

Since I needed to know how to formulate external hyperlinks on a Wiki page: [WayBack] Help:Links – MediaWiki.

Too many options, not even counting other sections on that page I did not quote, so I went for the first.

To create an external link, usually to a page at a different website, enclose the URL followed by space and the link text in single square brackets (see examples below). When you save or preview the page, you will see a link rendered slightly differently than an internal wikilink. It may be a different color and/or be followed by an arrow icon to show that it may lead to another site.

Description You type You get
External link with specified link text
[https://mediawiki.org MediaWiki]
MediaWiki
Numbered external link
[https://mediawiki.org]

This is what happens if you omit the link text. Multiple links of this type on the same page are numbered sequentially.

[1]
Bare external link
https://mediawiki.org

URLs beginning with “http://” and “https://” are automatically linked, even when no brackets are used.

https://mediawiki.org
Avoiding auto-linked URLs
<nowiki>https://mediawiki.org</nowiki>
https://mediawiki.org
Protocol-relativeexternal link
[//en.wikipedia.org Wikipedia]

[//en.wikipedia.org //en.wikipedia.org]

The link will be HTTP or HTTPS depending on the protocol of the page currently being viewed (which could be different for different users). This is only supported inside of square brackets [ ]. Using “//en.wikipedia.org” by itself does not result in a link.

Wikipedia

//en.wikipedia.org

External link to the current server
https://{{SERVERNAME}}/pagename
https://www.mediawiki.org/pagename
External link to other host passing the pagename
https://google.com/search?q={{PAGENAMEE}}

See also: URL encoded page namesPAGENAMEE encoding

https://google.com/search?q=Links
Mailto link
[mailto:info@example.org email me]
email me
Mailto named with subject line and body
[mailto:info@example.org?Subject=URL%20Encoded%20Subject&body=Body%20Text info]
info
Custom URI
[skype:echo123 call me]

Any URI you wish to add needs to be first declared through $wgUrlProtocols. (This example is not enabled on Mediawiki.org)

[skype:echo123 call me]
External links with file-type icons
[https://en.wikipedia.org/wiki/.avi video]

[https://en.wikipedia.org/wiki/.ogg sound]

[https://en.wikipedia.org/wiki/.pdf document]

See External link icons for currently supported icons and extensions. Note that this wiki is not set up to use such icons.

video

sound

document

–jeroen.

Posted in Development, Lightweight markup language, MediaWiki, Power User | Leave a Comment »