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,707 other followers

Archive for the ‘Scripting’ Category

GitHub – slikts/js-equality-game: The Worst Minesweeper 💣 Ever

Posted by jpluimers on 2019/09/10

[WayBack] GitHub – slikts/js-equality-game: The Worst Minesweeper 💣 Ever:

It’s in response to claims like this one by the well-known author getify:

However, implicit coercion is a mechanism that can be learned, and moreover should be learned by anyone wishing to take JavaScript programming seriously. Not only is it not confusing once you learn the rules, it can actually make your programs better! The effort is well worth it.

You can play it on [WayBack] JavaScript Equality Table Game: Find out how well you know (or don’t know) the JavaScript == operator rules

It reminds me of the hilarious video on Wat – Destroy All Software Lightning Talk : Gary Bernhardt : Free Download, Borrow, and Streaming : Internet Archive 

Based on:

Via:

–jeroen

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

What do the three arrow (“>>>”) signs mean in python?

Posted by jpluimers on 2019/09/10

When starting to work with Python, a lot of examples contain the >>> characters on the first line often followed by ... characters on continuing lines.

They are about two things:

  1. interactive Python sessions
  2. doctest

The answers in [WayBackWhat do the three arrow (“>>>”) signs mean in python? give insight in the various Python versions and how they prompt.

References from them:

–jeroen

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

Every time I try, I’m reminded of: You Don’ t Know JavaScript

Posted by jpluimers on 2019/09/05

I forgot how I originally bumped into the book series, but every time I try to program in JavaScript I’m reminded of them: You Don’ t Know JavaScript.

Originally a KickStarter project, they are now on GitHub and there is a Twitter account irregularly posting about them:

Titles

–jeroen

Read the rest of this entry »

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

Python “NameError: name ‘socket’ is not defined”

Posted by jpluimers on 2019/09/05

I bumped into this a while ago, but could not find back the code example showing it, so below is the SO question to solve it:

NameError: name 'socket' is not defined

[WayBackHow to refer to a standard library in a logging configuration file?

Related: [WayBack[Tutor] Socket error in class

–jeroen

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

python multithreading wait till all threads finished

Posted by jpluimers on 2019/09/04

A great tip from [WayBack] python multithreading wait till all threads finished:

ou need to use join method of Thread object in the end of the script.

t1 = Thread(target=call_script, args=(scriptA + argumentsA))
t2 = Thread(target=call_script, args=(scriptA + argumentsB))
t3 = Thread(target=call_script, args=(scriptA + argumentsC))

t1.start()
t2.start()
t3.start()

t1.join()
t2.join()
t3.join()

Thus the main thread will wait till t1t2 and t3 finish execution.

I’ve used a similar construct that’s used by the multi-threading code I posted a few ways ago (on Passing multiple parameters to a Python method: the * tag) in the ThreadManager class below.

But first some of the other links that helped me getting that code as it is now:

Example:

class ThreadManager:
    def __init__(self):
        self.threads = []

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

    def runAllToCompletion(self):
        ## The loops are the easiest way to run one methods on all entries in a list; see https://stackoverflow.com/questions/2682012/how-to-call-same-method-for-a-list-of-objects
        # First ensure everything runs in parallel:
        for thread in self.threads:
            thread.start()
        # Then wait until all monitoring work has finished:
        for thread in self.threads:
            thread.join()
        # here all threads have finished

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

    threadManager.runAllToCompletion()

–jeroen

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

 
%d bloggers like this: