Open-source News

High-Speed Mold 1.5 Linker Released With PPC64LE, SPARC64 & RISC-V BE Targets

Phoronix - Tue, 09/27/2022 - 17:17
Mold 1.5 is out today as the newest version of this open-source, high-speed linker alternative to the likes of GNU Gold and LLVM LLD...

165+ JavaScript terms you need to know

opensource.com - Tue, 09/27/2022 - 15:00
165+ JavaScript terms you need to know Sachin Samal Tue, 09/27/2022 - 03:00

JavaScript is a rich language, with sometimes a seemingly overwhelming number of libraries and frameworks. With so many options available, it's sometimes useful to just look at the language itself and keep in mind its core components. This glossary covers the core JavaScript language, syntax, and functions.

JavaScript variables

var: The most used variable. Can be reassigned but only accessed within a function, meaning function scope. Variables defined with var move to the top when code is executed.

const: Cannot be reassigned and not accessible before they appear within the code, meaning block scope.

let: Similar to const with block scope, however, the let variable can be reassigned but not re-declared.

Data types

Numbers: var age = 33

Variables: var a

Text (strings): var a = "Sachin"

Operations: var b = 4 + 5 + 6

True or false statements: var a = true

Constant numbers: const PI = 3.14

Objects: var fullName = {firstName:"Sachin", lastName: "Samal"}

Objects

This is a simple example of objects in JavaScript. This object describe the variable car, and includes keys or properties such as make, model, and year are the object's property names. Each property has a value, such as Nissan, Altima, and 2022. A JavaScript object is a collection of properties with values, and it functions as a method.

var car = {
make:"Nissan",
model:"Altima",
year:2022,
};Comparison operators

==: Is equal to

===: Is equal value and equal type

!=: Is not equal

!==: Is not equal value or not equal type

>: Is greater than

<: Is less than

>=: Is greater than or equal to

<=: Is less than or equal to

?: Ternary operator

Logical operators

&&: Logical AND

||: Logical OR

!: Logical NOT

Output data

alert(): Output data in an alert box in the browser window

confirm(): Open up a yes/no dialog and return true/false depending on user click

console.log(): Write information to the browser console. Good for debugging.

document.write(): Write directly to the HTML document

prompt(): Create a dialog for user input

Array methods

Array: An object that can hold multiple values at once.

concat(): Join several arrays into one

indexOf(): Return the primitive value of the specified object

join(): Combine elements of an array into a single string and return the string

lastIndexOf(): Give the last position at which a given element appears in an array

pop(): Remove the last element of an array

push(): Add a new element at the end

reverse(): Sort elements in descending order

shift(): Remove the first element of an array

slice(): Pull a copy of a portion of an array into a new array

splice(): Add positions and elements in a specified way

toString(): Convert elements to strings

unshift(): Add a new element to the beginning

valueOf(): Return the first position at which a given element appears in an array

Programming and development Red Hat Developers Blog Programming cheat sheets Try for free: Red Hat Learning Subscription eBook: An introduction to programming with Bash Bash shell scripting cheat sheet eBook: Modernizing Enterprise Java JavaScript loops

Loops: Perform specific tasks repeatedly under applied conditions.

for (before loop; condition for loop; execute after loop) {
// what to do during the loop
}

for: Creates a conditional loop

while: Sets up conditions under which a loop executes at least once, as long as the specified condition is evaluated as true

do while: Similar to the while loop, it executes at least once and performs a check at the end to see if the condition is met. If it is, then it executes again

break: Stop and exit the cycle at certain conditions

continue: Skip parts of the cycle if certain conditions are met

if-else statements

An if statement executes the code within brackets as long as the condition in parentheses is true. Failing that, an optional else statement is executed instead.

if (condition) {
// do this if condition is met
} else {
// do this if condition is not met
}Strings String methods

charAt(): Return a character at a specified position inside a string

charCodeAt(): Give the Unicode of the character at that position

concat(): Concatenate (join) two or more strings into one

fromCharCode(): Return a string created from the specified sequence of UTF-16 code units

indexOf(): Provide the position of the first occurrence of a specified text within a string

lastIndexOf(): Same as indexOf() but with the last occurrence, searching backwards

match(): Retrieve the matches of a string against a search pattern

replace(): Find and replace specified text in a string

search(): Execute a search for a matching text and return its position

slice(): Extract a section of a string and return it as a new string

split(): Split a string object into an array of strings at a specified position

substr(): Extract a substring depended on a specified number of characters, similar to slice()

substring(): Can't accept negative indices, also similar to slice()

toLowerCase(): Convert strings to lower case

toUpperCase(): Convert strings to upper case

valueOf(): Return the primitive value (that has no properties or methods) of a string object

Number methods

toExponential(): Return a string with a rounded number written as exponential notation

toFixed(): Return the string of a number with a specified number of decimals

toPrecision(): String of a number written with a specified length

toString(): Return a number as a string

valueOf(): Return a number as a number

Math methods

abs(a): Return the absolute (positive) value of a

acos(x): Arccosine of x, in radians

asin(x): Arcsine of x, in radians

atan(x): Arctangent of x as a numeric value

atan2(y,x): Arctangent of the quotient of its arguments

ceil(a): Value of a rounded up to its nearest integer

cos(a): Cosine of a (x is in radians)

exp(a): Value of Ex

floor(a): Value of a rounded down to its nearest integer

log(a): Natural logarithm (base E) of a

max(a,b,c…,z): Return the number with the highest value

min(a,b,c…,z): Return the number with the lowest value

pow(a,b): a to the power of b

random(): Return a random number between 0 and 1

round(a): Value of a rounded to its nearest integer

sin(a): Sine of a (a is in radians)

sqrt(a): Square root of a

tan(a): Tangent of an angle

Dealing with dates in JavaScript Set dates

Date(): Create a new date object with the current date and time

Date(2022, 6, 22, 4, 22, 11, 0): Create a custom date object. The numbers represent year, month, day, hour, minutes, seconds, milliseconds. You can omit anything except for year and month.

Date("2022-07-29"): Date declaration as a string

Pull date and time values

getDate(): Day of the month as a number (1-31)

getDay(): Weekday as a number (0-6)

getFullYear(): Year as a four-digit number (yyyy)

getHours(): Hour (0-23)

getMilliseconds(): Millisecond (0-999)

getMinutes(): Minute (0-59)

getMonth(): Month as a number (0-11)

getSeconds(): Second (0-59)

getTime(): Milliseconds since January 1, 1970

getUTCDate(): Day (date) of the month in the specified date according to universal time (also available for day, month, full year, hours, minutes, etc.)

parse: Parse a string representation of a date and return the number of milliseconds since January 1, 1970

Set part of a date

setDate(): Set the day as a number (1-31)

setFullYear(): Set the year (optionally month and day)

setHours(): Set the hour (0-23)

setMilliseconds(): Set milliseconds (0-999)

setMinutes(): Set the minutes (0-59)

setMonth(): Set the month (0-11)

setSeconds(): Set the seconds (0-59)

setTime(): Set the time (milliseconds since January 1, 1970)

setUTCDate(): Set the day of the month for a specified date according to universal time (also available for day, month, full year, hours, minutes, etc.)

Dom mode Node methods

appendChild(): Add a new child node to an element as the last child node

cloneNode(): Clone an HTML element

compareDocumentPosition(): Compare the document position of two elements

getFeature(): Return an object which implements the APIs of a specified feature

hasAttributes(): Return true if an element has any attributes, otherwise false

hasChildNodes(): Return true if an element has any child nodes, otherwise false

insertBefore(): Insert a new child node before a specified, existing child node

isDefaultNamespace(): Return true if a specified namespaceURI is the default, otherwise false

isEqualNode(): Check if two elements are equal

isSameNode(): Check if two elements are the same node

isSupported(): Return true if a specified feature is supported on the element

lookupNamespaceURI(): Return the namespaceURI associated with a given node

normalize(): Join adjacent text nodes and removes empty text nodes in an element

removeChild(): Remove a child node from an element

replaceChild(): Replace a child node in an element

Element methods

getAttribute(): Return the specified attribute value of an element node

getAttributeNS(): Return string value of the attribute with the specified namespace and name

getAttributeNode(): Get the specified attribute node

getAttributeNodeNS(): Return the attribute node for the attribute with the given namespace and name

getElementsByTagName(): Provide a collection of all child elements with the specified tag name

getElementsByTagNameNS(): Return a live HTMLCollection of elements with a certain tag name belonging to the given namespace

hasAttribute(): Return true if an element has any attributes, otherwise false

hasAttributeNS(): Provide a true/false value indicating whether the current element in a given namespace has the specified attribute

removeAttribute(): Remove a specified attribute from an element

lookupPrefix(): Return a DOMString containing the prefix for a given namespaceURI, if present

removeAttributeNS(): Remove the specified attribute from an element within a certain namespace

removeAttributeNode(): Take away a specified attribute node and return the removed node

setAttribute(): Set or change the specified attribute to a specified value

setAttributeNS(): Add a new attribute or changes the value of an attribute with the given namespace and name

setAttributeNode(): Set or change the specified attribute node

setAttributeNodeNS(): Add a new namespaced attribute node to an element

JavaScript events Mouse

onclick: User clicks on an element

oncontextmenu: User right-clicks on an element to open a context menu

ondblclick: User double-clicks on an element

onmousedown: User presses a mouse button over an element

onmouseenter: Pointer moves onto an element

onmouseleave: Pointer moves out of an element

onmousemove: Pointer moves while it is over an element

onmouseover: Pointer moves onto an element or one of its children

setInterval(): Call a function or evaluates an expression at

oninput: User input on an element

onmouseup: User releases a mouse button while over an element

onmouseout: User moves the mouse pointer out of an element or one of its children

onerror: Happens when an error occurs while loading an external file

onloadeddata: Media data is loaded

onloadedmetadata: Metadata (like dimensions and duration) is loaded

onloadstart: Browser starts looking for specified media

onpause: Media is paused either by the user or automatically

onplay: Media is started or is no longer paused

onplaying: Media is playing after having been paused or stopped for buffering

onprogress: Browser is in the process of downloading the media

onratechange: Media play speed changes

onseeked: User finishes moving/skipping to a new position in the media

onseeking: User starts moving/skipping

onstalled: Browser tries to load the media, but it is not available

onsuspend — Browser is intentionally not loading media

ontimeupdate: Play position has changed (e.g., because of fast forward)

onvolumechange: Media volume has changed (including mute)

onwaiting: Media paused but expected to resume (for example, buffering)

Keep this JavaScript glossary bookmarked to reference variables, methods, strings, and more.

Image by:

Photo by Jen Wike Huger

JavaScript What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Get change alerts from any website with this open source tool

opensource.com - Tue, 09/27/2022 - 15:00
Get change alerts from any website with this open source tool Leigh Morresi Tue, 09/27/2022 - 03:00

The year was 2020, and news about COVID-19 came flooding in so quickly that everyone felt completely overwhelmed with similar news articles providing updates with varying degrees of accuracy.

But all I needed to know was when my official government guidelines changed. In the end, that's all that mattered to me.

Whether the concern is a pandemic or just the latest tech news, keeping ahead of changes in website content can be critical.

The changedetection.io project provides a simple yet highly capable, open source solution for website change detection and notification. It's easy to set up, and it can notify over 70 (and counting) different notification systems, such as Matrix, Mattermost, Nextcloud, Signal, Zulip, Home Assistant, email, and more. It also notifies proprietary applications like Discord, Office365, Reddit, Telegram, and many others.

But changedetection.io isn't just limited to watching web page content. You can also monitor XML and JSON feeds, and it will build an RSS feed of the websites that changed.

More great content Free online course: RHEL technical overview Learn advanced Linux commands Download cheat sheets Find an open source alternative Explore open source resources

Thanks to its built-in JSON simple storage system, there's no need to set up complicated databases to receive and store information. You can run it as a Docker image or install it with pip. The project has an extensive wiki help section, and most common questions are covered there.

For sites using complex JavaScript, you can connect your changedetection.io installation to a Chromium or Chrome browser with the built-in Playwright content fetcher.

Once running, access the application in your browser (http://localhost:5000, by default). You can set a password in the Settings section if your computer can be reached from an outside network.

Image by:

(Leigh Morresi, CC BY-SA 4.0)

Submit the URL of a page you want to monitor. There are several settings related to how the page is filtered. For example, you more than likely do not want to know when a company's stock price listed in their site footer has changed, but you may want to know when they post a news article to their blog.

Monitor a site

Imagine you want to add your favorite website, Opensource.com, to be monitored. You only want to know when the main call-out article contains the word "python" and you want to be notified over Matrix.

To do this, begin with the visual-selector tool. (This requires the playwright browser interface to be connected.)

Image by:

(Leigh Morresi, CC BY-SA 4.0)

The visual-selector tool automatically calculates the best Xpath or CSS filter to target the content. Otherwise, you would get a lot of noise from the daily page updates.

Next, visit the Filters & Triggers tab.

Image by:

(Leigh Morresi, CC BY-SA 4.0)

In CSS/JSON/XPATH Filter field (the blue circle), you can see the automatically generated CSS filter from the previous step.

There are several useful filters available, such as Remove elements (good for removing noisy elements), Ignore text, Trigger/wait for text, and Block change-detection if text matches (used for waiting for some text to disappear, like "sold out").

In Trigger/wait for text (the red circle), type in the keyword you want to monitor for. (That's "python" in this example.)

The final step is in the Notifications tab, where you configure where you want to receive your notification. Below I added a Matrix room as the notification target, using the Matrix API.

Image by:

(Leigh Morresi, CC BY-SA 4.0)

The notification URL is in the format of matrixs://username:password@matrix.org/#/room/#room-name:matrix.org

However, t2Bot format is also supported. Here are more Matrix notification options.

And that's it! Now you'll receive a message over Matrix whenever the content changes.

There's more

There's so much more to changedetection.io. If you prefer calling a custom JSON API, you don't have to use an API for notifications (use jsons://). You can also create a custom HTTP request (POST and GET), execute JavaScript before checking (perhaps to pre-fill a username and password login field), and many more interesting features, with more to come.

Stop browsing the web and start watching the web instead!

Use changedetection.io to get alerts when a website makes changes or updates.

Tools Web development What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Top 5 Open Source Plugins for ONLYOFFICE Docs

Tecmint - Tue, 09/27/2022 - 13:13
The post Top 5 Open Source Plugins for ONLYOFFICE Docs first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

If you think that office software is exclusively designed for writing texts, making calculations in spreadsheets, and creating informative presentations, you are wrong. Some office suites are capable of doing much more things than

The post Top 5 Open Source Plugins for ONLYOFFICE Docs first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Linux 6.0 Merges The AMD Performance Fix For The Old "Dummy Wait" Workaround

Phoronix - Tue, 09/27/2022 - 06:48
This morning I called attention to some pending work around a 20 year old chipset workaround in the Linux kernel had been hurting modern AMD systems by erroneously still applying the change to modern hardware. Fortunately, that patch has now been picked up by Linus Torvalds in time for the Linux 6.0 kernel expected for its stable debut next weekend...

Pages