Home Blog Page 275

Basics of Object-Oriented Programming

In programming, an object is simply a ‘thing’. I know, I know…how can you define something as a ‘thing’. Well, let’s think about it – What do ‘things’ have? Attributes, right?  – A dog has four legs, a color, a name, an owner, and a breed. Though there are millions Dogs with countless names, owners, etc, the one thing that ties them all together are the very fact that every single one can be described as a Dog.

Although this may seem like a not-very informative explanation, these types of examples are what ultimately made me understand Object-oriented programing. The set of activities that an object can perform is an Object’s behavior. 

Let’s look at a common element in programming, a simple string. As you can see, after the string is defined, I’m able to call different ‘methods’ or functions on the string I created. Ruby has several built in methods on common objects(ie strings, integers, arrays, and hashes.

Read more at Dev.to

The URLephant in the Room

Check out this presentation by Emily Stark from the Usenix Enigma 2019 conference.

In a security professional’s ideal world, every web user would carefully inspect their browser’s URL bar on every page they visit, verifying that they are accessing the site they intend to be accessing. In reality, many users rarely notice the URL bar and don’t know how to interpret the URL to verify a website’s identity. An evil URL may even be carefully designed to be indistinguishable from a legitimate one, such that even an expert couldn’t tell the difference!

In this talk, I’ll discuss the URLephant in the room: the fact that the web security model rests on users noticing and understanding URLs as indicators of website identities, but they don’t actually work very well for that purpose. I’ll discuss how the Chrome usable security team measures whether an indicator of website identity is working, and when the security community should consider breaking some rules of usable security in search of better solutions. 

Watch the presentation at Usenix.

ST Spins Up Linux-Powered Cortex-A SoC

STMicroelectronics has announced a new Cortex-A SoC and Linux- and Android-driven processor. The STM32MP1 SoC intends to ease the transition for developers moving from its STM32 microprocessor unit (MCU) family to more complex embedded systems. Development boards based on the SoC will be available in April.

Aimed at industrial, consumer, smart home, health, and wellness applications, the STM32MP1 features dual, 650MHz Cortex-A7 cores running a new “mainlined, open-sourced” OpenSTLinux distro with Yocto Project and OpenEmbedded underpinnings. There’s also a 209MHz Cortex-M4 chip with an FPU, MPU, and DSP instructions. The Cortex-M4 is supported by an enhanced version of ST’s STM32Cube development tools that support the Cortex-A7 cores in addition to the M4 (see below).

Like most of NXP’s recent embedded SoCs, including the single- or -dual Cortex-A7 i.MX7 and its newer, Cortex-A53 i.MX8M and i.MX8M Mini, the STM32MP1 is a hybrid Cortex-A/M design intended in ST’s words to “perform fast processing and real-time tasks on a single chip.” Hybrid Cortex-A7/M4 SoCs are also available from Renesas, Marvell, and MediaTek, which has developed a custom-built MT3620 SoC as the hardware foundation for Microsoft’s Azure Sphere IoT framework.

As the market leader in Cortex-A MCUs, ST has made a larger leap from its comfort zone than these other semiconductor vendors. NXP is also a leading MCU vendor, but it’s been crafting Linux-powered Cortex-A SoCs since long before it changed it named from Freescale. The SM32MP1 launch continues a trend of MCU technology companies reaching out to the Linux community, such as Arm’s new Mbed Linux distro and Pelion IoT Platform, which orchestrates Cortex-M and Cortex-A devices under a single IoT platform.

Inside the STM32MP1

The STM32MP1 is equipped with 32KB instruction and data caches, as well as a 256KB L2 cache. ST also supplies an optional Vivante 3D GPU with support for OpenGL ES 2.0 and 24-bit parallel RGB displays at up to WXGA (1280×800) at 60fps.

The SoC supports a 2-lane MIPI-DSI interface running at 1Gbps and offers native support for Linux and application frameworks such as Android Qt and Crank Software’s Storyboard GUI. While the GPU is pretty run-of-the-mill for Cortex-A7 SoCs it’s a giant leap from the perspective of MCU developers trying to bring up modern HMI displays.

Three SoC models are available: one with 3D GPU, MIPI-DSI, and 2x CAN FD interfaces, as well as one with 2x CAN FD only and one without the GPU and CAN I/O.

The STM32MP1 is touted for its rolling 10-year longevity support and heterogeneous architecture, which lets developers halt the Cortex-A7 and run only on the Cortex-M4 to reduce power consumption by 25 percent. From this mode, “going to Standby further cuts power by 2.5k times — while still supporting the resumption of Linux execution in 1 to 3 seconds, depending on the application,” says ST. The SoC includes a PMIC and other power circuitry such as buck and boost converters.

For security, the SoC provides Arm TrustZone, cryptography, hash, secure boot, anti-tamper pins, and a real-time clock. RAM support includes 32/16-bit, 533MHz DDR3, DDR3L, LPDDR2, LPDDR3. Flash support includes SD, eMMC, NAND, and NOR.

Peripherals include Cortex-A7 linked GbE, 3x USB 2.0, I2C, and multiple UART and SPI links. Analog I/O connected to the Cortex-M4 include 2x 16-bit ADCs, 2x 12-bit DACs, 29x timers, 3x watchdogs, LDOs, and up to 176 GPIOs.

OpenSTLinux, STM32Cube, and starter kits

The new OpenSTLinux distribution “has already been reviewed and accepted by the “Linux community: Linux Foundation, Yocto project, and Linaro,” says ST. The Linux BSP includes mainline kernel, drivers, boot chain, and Linaro’s OP-TEE (Trusted Execution Environment) security stack. It also includes Wayland/Weston, Gstreamer, and ALSA libraries.

Three Linux software development packages are available: a quick Starter package with STM32CubeMP1 samples; a Dev package with a Yocto Project SDK that lets you add your own Linux code; and an OpenEmbedded based Distrib package that also lets you create your own OpenSTLinux-based Linux distro. ST has collaborated with Timesys on the Linux BSPs and with Witekio to port Android to STM32MP1. 

STM32 developers can “easily find their marks” by using the familiar STM32Cube toolset to control both the Cortex-M4 and Cortex-A7 chips. The toolset includes GCC-based STM32CubeProgrammer and STM32CubeMX IDEs, which “include the DRAM interface tuning tool for easy configuration of the DRAM sub-system,” says ST.

Finally, ST is supporting its chip with a four development boards: the entry level STM32MP157A-DK1 and STM32MP157C-DK2 and the higher end STM32MP157A-EV1 and STM32MP157C-EV1. All the boards offer GPIO connectors for the Raspberry Pi and Arduino Uno V3.

The DK1/DK2 boards are equipped with 4GB DDR3L, as well as USB Type-C, USB Type-A OTG, HDMI, and MIPI-DSI. You also get GbE and WiFi/Bluetooth, and a 4-inch, VGA capacitive touch panel, among other features.

The more advanced A-EV1 and C-EV1 boards support up to 8GB DDR3L, 32GB eMMCv5.0. a microSD slot, and SPI and NAND flash. They provide most of the features of the DK boards, as well as CAN, camera support, SAI, SPDIF, digital mics, analog audio, and much more. They also supply 4x USB host ports and a micro-USB port. A 5.5-inch 720×1280 touchscreen is available.

DevOps Training for Network Engineers

Linux Foundation training has announced a new course designed to provide network engineers with the skills necessary to start applying DevOps practices and leverage their expertise in a DevOps environment.

In the new DevOps for Network Engineers course, you’ll learn how to navigate your role in the CI/CD cycle, find common ground, and use key tools to contribute effectively in areas like connectivity, network performance tuning, security, and other aspects of network management within a DevOps environment.

Network automation is becoming the standard in data centers, with major implications for network engineers. This online, self-paced course will help you become familiar with the tools needed to integrate your skills into the DevOps/Agile process.

Course highlights include:

  • How to integrate into a DevOps/Agile environment

  • Commonly used DevOps tools

  • How DevOps teams collaborate on projects

  • How to confidently work with software and configuration files in version control

  • How to confidently apply Agile principles in an organization

Learn more about the DevOps for Network Engineers course now.

 

Microsoft Releases Windows 10 Preview with Support for Linux Files

Microsoft yesterday released a new Windows 10 preview with support for Linux files, gaming improvements, and a Chrome extension for Timeline. The update bumps Windows 10 from build 18334 (made available to testers on February 9) to build 18342. These builds are from the 19H1 branch, which represents the Windows 10 update that will arrive in the first half of this year.

Windows 10 is being developed as a service, meaning it receives new features on a regular basis. … The seventh update will bring the ability for users to access Linux files in a WSL distro from Windows. These files can be accessed through the command line by navigating to \wsl$ (see a list of running distributions by navigating to \wsl$). Windows apps like File Explorer and Visual Studio Code can also interact with these files.

Read more at VentureBeat

A Linux Noob Reviews: The openSUSE Leap 15.0 Installer

Forbes covers your very first experience with a desktop Linux operating system: the installer. Read more at Forbes.

The Calico Cloud

You know what’s one of the real pains of cloud and container based computing? Networking. Workloads on a cloud come and go faster than you can read this story. Connecting those workloads, especially when they become even more ephemeral containers, is not easy. That’s where the open-source Software Defined Network (SDN) Calico comes in.

SDN enables you to centrally manage and monitor your network across not just routers and switches from a single vendor, but across any hardware that implements standardized SDN protocols. This enables network administrators to create efficient virtual networks independent of the infrastructure.

Calico takes these concepts to the cloud and simplifies them so they can work without a netadmin snapping a whip over the network. Calico does this with a simplified Layer 3 networking model designed for cloud-native applications. It also uses good old Internet Protocol, which makes it simpler than SDN overlay approaches. With it, you can set network policies for your virtual machines (VM)s and containers.

Read more at DXC Technology

Do Linux Distributions Still Matter with Containers?

There are two major trends in container builds: using a base image and building from scratch. Each has engineering tradeoffs.

Some people say Linux distributions no longer matter with containers. Alternative approaches, like distroless and scratch containers, seem to be all the rage. It appears we are considering and making technology decisions based more on fashion sense and immediate emotional gratification than thinking through the secondary effects of our choices. We should be asking questions like: How will these choices affect maintenance six months down the road? What are the engineering tradeoffs? How does this paradigm shift affect our build systems at scale?

It’s frustrating to watch. If we forget that engineering is a zero-sum game with measurable tradeoffs—advantages and disadvantages, with costs and benefits of different approaches— we do ourselves a disservice, we do our employers a disservice, and we do our colleagues who will eventually maintain our code a disservice. Finally, we do all of the maintainers (hail the maintainers!) a disservice by not appreciating the work they do.

Understanding the problem

To understand the problem, we have to investigate why we started using Linux distributions in the first place. I would group the reasons into two major buckets: kernels and other packages. 

Read more at OpenSource.com

GhostBSD: A Solid Linux-Like Open Source Alternative

The subject of this week’s Linux Picks and Pans is a representative of a less well-known computing platform that coexists with Linux as an open source operating system. If you thought that the Linux kernel was the only open source engine for a free OS, think again. BSD (Berkeley Software Distribution) shares many of the same features that make Linux OSes viable alternatives to proprietary computing platforms.

GhostBSD is a user-friendly Linux-like desktop operating system based onTrueOS. TrueOS is, in turn, based on FreeBSD’s development branch. TrueOS’ goal is to combine the stability and security of FreeBSD with a preinstalled GNOME, MATE, Xfce, LXDE or Openbox graphical user interface.

Read more at Linux Insider

Today is a Good Day to Learn Python

Get started learning Python with this tutorial from our archives.

The cool thing about Linux and FOSS is also an aggravating thing, which is that sometimes there’s too much of a good thing. There is such an abundance of goodies that it can be overwhelming. So I am here to help you decide which programming language you should learn next, and that is Python. Oh, yes, it is.

Why Python? I like it because it is clean and straightforward. It’s a great introduction to object-oriented languages. The Python world is beginner-friendly and, as a general-purpose language, Python can be used for all sorts of things: quick simple scripts, games, Web development, Raspberry Pi — anything you want. It is also in demand by employers if you’re thinking of a career.

There are numerous excellent Python books and tons of online documentation. I want to show off Python’s coolness for beginners so you will get excited and go “Yes! I too must love Python!”

But what about all the other languages? Don’t worry, they won’t get lonesome, and everything you learn in Python is applicable to many other languages as well.

What Stuff Means

I think most of us learn terminology better with hands-on exercises, but there are four things to know from the start.

The first is Python is strongly typed. As you study Python, you will see this repeated a gazillion times. What does this even mean? Who uses a typewriter? Fortunately, it has nothing to do with typewriters, but rather with how Python handles data types. All computer programs are made of two things: data, and operating on that data. Data comes in different types, and the types determine how your programming language will handle them. Data types include characters or strings, which are literal numbers and letters, like names and addresses; integers and floating point numbers that are used in calculations; Boolean values (true/false); and arrays, which are lists of data of all the same data types.

Python enforces data types and relies on you to define them. Weakly typed languages decide for themselves what your data types are, so the data type can change depending on context.

For example, most any programming language will add the integers 1 + 2 + 3. A weakly typed language may also let you add integers and text strings, for example 5 + helloworld. If you try to do this in Python, your code will fail and you will get an error message. Weakly typed languages don’t do this randomly; this is a feature intended to add speed and flexibility by not requiring you to define your data types.

However, weak typing can lead to strange errors. One of the most common errors involves converting strings of numbers to integers when you really want them to be a literal string, like 221B Baker Street, 10,000 Maniacs, or 23andMe. In my modest opinion, it is better to learn the discipline and structure of a strongly typed language, and then try out weakly typed languages after you have experience and good grounding in the basics.

The second thing to know is what the heck is object oriented programming (OOP)? An object is a clump of data and procedures grouped into a single reusable entity. If you were coding a car racing game you might have a car object, an obstacle object, and a driver object. So, you say, objects are just like functions, right? Yes. If you already understand how to organize code into properly grouped functions and variables, then you already understand OOP. There are finer points to OOP such as classes, inheritance, and polymorphism; again, if you think in terms of sensible organization these things are easier to understand.

Third, white space has meaning in Python. You have to get your white spaces right or your code won’t work.

Fourth, Python is an interpreted language. You don’t have to compile and link your Python programs. If you’re experienced with the Bash shell, then you already know about interpreted languages, how fast they are to code in, and how you can test out your programs interactively before writing them into a script.

The downside to interpreted languages is the overhead of the interpreter. Usually, programs written in compiled languages run faster. However, you can link your Python programs to functions written in many other languages, including C/C++, Lisp, Fortran, Java, and Perl, and many more so you can mix and match to get the results you want.

Try It

Python is included in most Linux distributions, and usually the python package installs the base components and Python command interpreter. The text in bold is what you type.

$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> topics

Here is a list of available topics.  Enter any topic name to get more help.

ASSERTION  DEBUGGING LITERALS SEQUENCEMETHODS2
ASSIGNMENT DELETION  LOOPING  SEQUENCES
[...]
help> quit

Of course we must do the traditional Hello World! Strings must be enclosed in single or double quotes.

>>> 'Hello, world!'
'Hello, world!'
>>> hell = "Hello, world!"
>>> hell
'Hello, world!'

Now create the simplest possible Python script, save it as hello.py, and run it from your normal Linux shell:

#!/usr/bin/python

print "Hello World!";

carla@studio:~$ python hello.py
Hello World!

Let’s go back to the Python interpreter and play with data types.

>>> 2 + 2
4
>>> 2 + foo
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'foo' is not defined
>>> foo = 5
>>> 2 + foo
7

Now try a short interactive script. It asks you to input your age, responds according to the age you type, and checks if your response is in the correct data type. This is a great little script to tweak in different ways. For example, you could limit the acceptable age range, limit the number of incorrect tries, and get creative with your responses. Note that raw_input is for Python 2.x, and 3.x uses input.

Watch your indentation; the indented lines must be four spaces. If you are using a proper code editor, it should take care of this for you.

#!/usr/bin/python

while True:
    try:
        age = int(raw_input("Please enter your age: "))
    except ValueError:
        print("I'm so very sorry, that does not compute. Please try again.")
        continue
    else:
        break
if age >= 18: 
    print("Very good, you are old enough to know better, but not too old to do it anyway.")
else:
    print("Sorry, come back when you're 18 and try again.")

Modules and Learning

There are a great number of Python modules, and you can learn to write your own. The key to writing good Python programs and making them do what you want is learning where to find modules. Start at Python.org because of the abundant documentation and good organization. Plan to spend a lot of time here, because it contains the best and authoritative information. It even has an interactive shell you can practice with.

Learn more about Linux through the free “Introduction to Linux” course from The Linux Foundation and edX.