Language Selection

English French German Italian Portuguese Spanish

Python Programming Leftovers

Filed under
Development
  • Django 3 Tutorial & CRUD Example with MySQL and Bootstrap

    Django 3 is released with full async support! In this tutorial, we'll see by example how to create a CRUD application from scratch and step by step. We'll see how to configure a MySQL database, enable the admin interface, and create the django views.

    We'll be using Bootstrap 4 for styling.

  • Creating a transparently encrypted field in Django

    This is officially PythonDiary's first Python 3 article! Python 2 is now officially dead, so there's less reasons to make that a major focus going forward.

    In some rare situations you may wish to have data which may otherwise be visible on the Django site, or through the Django admin, but may wish to have this data transparently encrypted into the database. This could be very useful, if for example, you use an untrusted database where it is not managed by you, and some database administrator can indeed either dump the data, or otherwise view the stored schemas. This is common with managed databases, which are either maintained by a hosting provider, or is shared with other tenants. In this current day and age with many database breaches appearing in the news from large vendors, you can never be 100% sure that the data you save into your database will never be leaked.

    Django supports custom fields on your database models, and the various CRUD and model services Django provides will use these fields with ease, making the creation of a globally transparently encrypted field possible. First lets start with the creation of the custom Django field to explain how that works first.

  • Return the word with the longest length within a string using Python

    Simple challenge – eliminate all bugs from the supplied code so that the code runs and outputs the expected value. The output should be the length of the longest word, as a number. There will only be one ‘longest’ word.

    Above is a question from CodeWars, we will create the below python function to perform the above task.

  • Getting Jenkins Jobs by Build State with Python

    I have been working with Python and Jenkins a lot lately and recently needed to find a way to check the job’s status at the build level. I discovered the jenkinsapi package and played around with it to see if it would give me the ability to drill down to the build and resultset level within Jenkins.

    In the builds that I run, there are X number of sub-jobs. Each of these sub-jobs can pass or fail. If one of them fails, the entire build is marked with the color yellow and tagged as “UNSTABLE”, which is failed in my book. I want a way to track which of these sub-jobs is failing and how often over a time period. Some of these jobs can be unstable because they access network resources, which others may have been broken by a recent commit to the code base.

    I eventually came up with some code that helps me figure out some of this information. But before you can dive into the code, you will need to install a package.

  • Wing Python IDE 7.2 Release Candidate 1 - January 14, 2020

    Wing 7.2 adds auto-formatting with Black and YAPF, expands support for virtualenv, adds support for Anaconda environments, explicitly supports debugging modules launched with python -m, simplifies manually configured remote debugging, and fixes a number of usability issues.

  • Creating password input widget in PyQt

    One of the most common parts of writing any desktop tool and taking password input is about having a widget that can show/hide password text. In Qt, we can add a QAction to a QLineEdit to do the same. The only thing to remember, that the icons for the QAction, must be square in aspect ratio; otherwise, they look super bad.

    The following code creates such a password input, and you can see it working at the GIF at the end of the blog post. I wrote this for the SecureDrop client project.

More in Tux Machines

New in Linux 5.12

  • Linux 5.12 To Allow Voltage/Temperature Reporting On Some ASRock Motherboards - Phoronix

    Voltage, temperature, and fan speed reporting among desktop motherboards under Linux remains one of the unfortunate areas even in 2021... Many SIO ICs remain publicly undocumented and the Linux driver support is often left up to the community and usually through reverse-engineering. Thus the mainline Linux kernel support is left to suffer especially among newer desktop motherboards.

  • [Older] F2FS With Linux 5.12 To Allow Configuring Compression Level

    While the Flash-Friendly File-System (F2FS) allows selecting between your choice of optional compression algorithms like LZO, LZ4, and Zstd -- plus even specifying specific file extensions to optionally limit the transparent file-system compression to -- it doesn't allow easily specifying a compression level. That is fortunately set to change with the Linux 5.12 kernel this spring. Queued now into the F2FS "dev" tree ahead of the Linux 5.12 merge window is a patch that's been floating around for some weeks to allow easily configuring the compression level. The compress_algorithm mount option is expanded to allow also specifying a level, such that the format supported is [algorithm]:[level] should you want to override any level preference like with the LZ4 and Zstd compression algorithms.

Security and Proprietary Software

  • diffoscope 165 released

    The diffoscope maintainers are pleased to announce the release of diffoscope version 165. This version includes the following changes:

    [ Dimitrios Apostolou ]
    * Introduce the --no-acl and --no-xattr arguments [later collapsed to
      --extended-filesystem-attributes] to improve performance.
    * Avoid calling the external stat command.
    
    [ Chris Lamb ]
    * Collapse --acl and --xattr into --extended-filesystem-attributes to cover
      all of these extended attributes, defaulting the new option to false (ie.
      to not check these very expensive external calls).
    
    [ Mattia Rizzolo ]
    * Override several lintian warnings regarding prebuilt binaries in the
    * source.
    * Add a pytest.ini file to explicitly use Junit's xunit2 format.
    * Ignore the Python DeprecationWarning message regarding the `imp` module
      deprecation as it comes from a third-party library.
    * debian/rules: filter the content of the d/*.substvars files

  • SonicWall hardware VPNs hit by worst-case 0-zero-day-exploit attacks

    “…have information about hacking of a well-known firewall vendor and other security products by this they are silent and do not release press releases for their clients who are under attack due to several 0 days in particular very large companies are vulnerable technology companies,” BleepingComputer was told via email.

  • Cyber Firm SonicWall Says It Was Victim of ‘Sophisticated’ Hack

    The Silicon Valley-based company said in a statement that the two products compromised provide users with remote access to internal resources.

    The attackers exploited so-called “zero days” -- a newly discovered software flaw -- on certain SonicWall remote access products, the company said in a statement.

  • Former manager of Microsoft Taiwan investigated for fraud

    A former manager at the Taiwanese branch of software giant Microsoft was questioned Friday (Jan. 22) about an alleged fraud scam directed against the company.

    In 2016 and 2017, Chang Ming-fang (張銘芳) allegedly colluded with managers of other companies to forge orders to obtain discounts and products at lower prices, UDN reported.

  • School laptops sent by government arrive loaded with malware [iophk: Windows TCO]

    A number of the devices were found to be infected with a "self-propagating network worm", according to the forum, and they also appeared to be contacting Russian servers, one teacher wrote. The Windows-based laptops were specifically infected with Gamarue.1, a worm Microsoft identified in 2012.

  • Ransomware provides the perfect cover

    Look at any list of security challenges that CISOs are most concerned about and you’ll consistently find ransomware on them. It’s no wonder: ransomware attacks cripple organizations due to the costs of downtime, recovery, regulatory penalties, and lost revenue. Unfortunately, cybercriminals have added an extra sting to these attacks: they are using ransomware as a smokescreen to divert security teams from other clandestine activities behind the scenes.

    Attackers are using the noise of ransomware to their advantage as it provides the perfect cover to distract attention so they can take aim at their real target: exfiltrating IP [sic], research, and other valuable data from the corporate network.

  • Global ransom DDoS extortionists are retargeting companies

    According to Radware, companies that received this letter also received threats in August and September 2020. Security researchers’ analysis of this new wave of ransom letters suggested that the same threat actors from the middle of 2020 are behind these malicious communications.

    When the DDoS extortion campaign started in August of 2020, a single Bitcoin was worth approximately $10,000. It’s now worth roughly $30,000. The attackers cited this in the latest round of ransom letters, and it represents the impact the rising price of Bitcoin is having on the threat landscape.

    A few hours after receiving the message, organizations were hit by DDoS attacks that exceeded 200 Gbps and lasted over nine hours without slowdown or interruption. A maximum attack size of 237 Gbps was reached with a total duration of nearly 10 hours, the alert warned.

  • Boeing 737 MAX is a reminder of the REAL problem with software | Stop at Zona-M

    And that problem almost never is software.

7 Linux Distros to Look Forward in 2021

Here is a list of most anticipated Linux distributions you should keep an eye on in the year 2021. Read more

Games Leftovers

  • Gaming Like It's 1925: Last Week To Join The Public Domain Game Jam!

    Sign up for the Public Domain Game Jam on itch.io »

  • ujoy(4) added to -current

    With the following commit, Thomas Frohwein (thfr@) added a joystick/gamecontroller driver to -current: [...]

  • The First Online Conference Is Happening Today For The Godot Game Engine - Phoronix

    For those interested in Godot as the premiere open-source 2D/3D game engine or just looking for some interesting technical talks to enjoy this weekend, the first GodotCon Online is today. GodotCon 2021 is the open-source game engine's first entirely online conference for developers, users, and other contributors to this promising open-source project. The YouTube-based event has been running from 8:45 UTC today until 16:00 UTC, but fear not if you missed out as you can already go back and listen to the prior talks in the stream. The recordings will remain available for those wanting to enjoy it in the days ahead. All of the content is free of charge.