Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 20,946
» Latest member: blackopsdlc
» Forum threads: 22,011
» Forum posts: 22,978

Full Statistics

Online Users
There are currently 1793 online users.
» 0 Member(s) | 1788 Guest(s)
Applebot, Baidu, Bing, Facebook, Google

Latest Threads
When does Godzilla releas...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 1
[WoW Retail News] Ula'tek...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 3
[DevBlog MS] Microsoft is...
Forum: C#, Visual Basic, & .Net Frameworks
Last Post: xSicKxBot

» Replies: 0
» Views: 13
[WoW Retail News] BlizzCo...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 14
What is Celestial Codex i...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 14
[Ubuntu News] Fine tune y...
Forum: Linux, FreeBSD, and Unix types
Last Post: xSicKxBot

» Replies: 0
» Views: 12
[WoW Retail News] Xal'ata...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 31
[Ubuntu News] Scaling And...
Forum: Linux, FreeBSD, and Unix types
Last Post: xSicKxBot

» Replies: 0
» Views: 22
[WoW Retail News] Comment...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 24
How to unlock Maya Aguina...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 31

 
  Open Liberty Java runtime now available to Red Hat Runtimes subscribers
Posted by: xSicKxBot - 03-24-2022, 12:37 PM - Forum: Java Language, JVM, and the JRE - No Replies

Open Liberty Java runtime now available to Red Hat Runtimes subscribers

Open Liberty is a lightweight, production-ready Java runtime for containerizing and deploying microservices to the cloud, and is now available as part of a Red Hat Runtimes subscription. If you are a Red Hat Runtimes subscriber, you can write your Eclipse MicroProfile and Jakarta EE apps on Open Liberty and then run them in containers on Red Hat OpenShift, with commercial support from Red Hat and IBM.

Develop cloud-native Java microservices


Open Liberty is designed to provide a smooth developer experience with a one-second startup time, a low memory footprint, and our new dev mode:

Tweet about Open Liberty Dev Mode.

Open Liberty provides a full implementation of MicroProfile 3 and Jakarta EE 8. MicroProfile is a collaborative project between multiple vendors (including Red Hat and IBM) and the Java community that aims to optimize enterprise Java for writing microservices. With a four-week release schedule, Liberty usually has the latest MicroProfile release available soon after the spec is published.

Also, Open Liberty is supported in common developer tools, including VS Code, Eclipse, Maven, and Gradle. Server configuration (e.g., adding or removing a capability, or “feature,” to your app) is through an XML file. Open Liberty’s zero migration policy means that you can focus on what’s important (writing your app!) and not have to worry about APIs changing under you.

Deploy in containers to any cloud


When you’re ready to deploy your app, you can just containerize it and deploy it to OpenShift. The zero migration principle means that new versions of Open Liberty features will not break your app, and you can control which version of the feature your app uses.

Monitoring live microservices is enabled by MicroProfile Metrics, Health, and OpenTracing, which add observability to your apps. The emitted metrics from your apps and from the Open Liberty runtime can be consolidated using Prometheus and presented in Grafana.

Learn with the Open Liberty developer guides


Our Open Liberty developer guides are available with runnable code and explanations to help you learn how to write microservices with MicroProfile and Jakarta EE, and then to deploy them to Red Hat OpenShift.

Get started


To get started with Open Liberty, try the Packaging and deploying applications guide and the Deploying microservices to OpenShift guide.

Share

The post Open Liberty Java runtime now available to Red Hat Runtimes subscribers appeared first on Red Hat Developer.



https://www.sickgaming.net/blog/2019/11/...bscribers/

Print this item

  [Tut] Python divmod() — A Simple Guide with Video
Posted by: xSicKxBot - 03-24-2022, 12:37 PM - Forum: Python - No Replies

Python divmod() — A Simple Guide with Video

Python’s built-in divmod(a, b) function takes two integer or float numbers a and b as input arguments and returns a tuple (a // b, a % b). The first tuple value is the result of the integer division a//b. The second tuple is the result of the remainder, also called modulo operation a % b. In case of float inputs, divmod() still returns the division without remainder by rounding down to the next round number.

Python divmod() visual explanation

Usage


Learn by example! Here are some examples of how to use the divmod() built-in function with integer arguments:

# divmod() with integers
>>> divmod(10, 2)
(5, 0)
>>> divmod(10, 3)
(3, 1)
>>> divmod(10, 4)
(2, 2)
>>> divmod(10, 5)
(2, 0)
>>> divmod(10, 10)
(1, 0)

You can also use float arguments as follows:

# divmod() with floats
>>> divmod(10.0, 2.0)
(5.0, 0.0)
>>> divmod(10.0, 3.0)
(3.0, 1.0)
>>> divmod(10.0, 4.0)
(2.0, 2.0)
>>> divmod(10.0, 5.0)
(2.0, 0.0)
>>> divmod(10.0, 10.0)
(1.0, 0.0)

Video divmod()




Syntax divmod()


Syntax: 
divmod(a, b) -> returns a tuple of two numbers. The first is the result of the division without remainder a/b. The second is the remainder (modulo) a%b.

Arguments integer The dividend of the division operation.
integer The divisor of the division operation.
Return Value tuple Returns a tuple of two numbers. The first is the result of the division without remainder. The second is the remainder (modulo).

Interactive Shell Exercise: Understanding divmod()


Consider the following interactive code:

Exercise: Guess the output before running the code.


But before we move on, I’m excited to present you my brand-new Python book Python One-Liners (Amazon Link).

If you like one-liners, you’ll LOVE the book. It’ll teach you everything there is to know about a single line of Python code. But it’s also an introduction to computer science, data science, machine learning, and algorithms. The universe in a single line of Python!


The book is released in 2020 with the world-class programming book publisher NoStarch Press (San Francisco).

Link: https://nostarch.com/pythononeliners


Exact Mathematical Definition divmod()


You can generally use the divmod(a, b) function with two integers, one integer and one float, or two floats.

Two integers. Say you call divmod(a, b) with two integers a and b. In this case, the exact mathematical definition of the return value is (a // b, a % b).

a = 5
b = 2
print((a // b, a % b))
print(divmod(a, b))
# OUTPUT:
# (2, 1)
# (2, 1)

One integer and one float. Say you call divmod(a, b) with an integer a and a float b. In this case, the exact mathematical definition of the return value is the return value of converting the integer to a float and calling divmod(a, float(b)).

a = 5.0
b = 2
print((a // b, a % b))
print(divmod(a, b))
# OUTPUT:
# (2.0, 1.0)
# (2.0, 1.0)

Two floats. Say you call divmod(a, b) with two floats a and b. In this case, the exact mathematical definition of the return value is (float(math.floor(a / b)), a % b).

import math a = 5.0
b = 2.0
print((float(math.floor(a / b)), a % b))
print(divmod(a, b))
# OUTPUT:
# (2.0, 1.0)
# (2.0, 1.0)

Note that because of the imprecision of floating point arithmetic, the result may have a small floating point error in one of the lower decimal positions. You can read more about the floating point trap on the Finxter blog.

Related Tutorial: Floating Point Error Explained

Python divmod() Negative Numbers


Can you use the divmod() method on negative numbers for the dividend or the divisor?

You can use divmod(a, b) for negative input arguments a, b, or both. In any case, if both arguments are integers, Python performs integer division a // b to obtain the first element and modulo division a % b to obtain the second element of the returned tuple. Both operations allow negative inputs a or b. The returned tuple (x, y) is calculated so that x * b + y = a.

Here’s an example of all three cases:

>>> divmod(-10, -3)
(3, -1)
>>> divmod(-10, 3)
(-4, 2)
>>> divmod(10, -3)
(-4, -2)

Python divmod() Performance — Is It Faster Than Integer Division // and Modulo % Operators?


There are two semantically identical ways to create a tuple where the first element is the result of the integer division and the second is the result of the modulo operation:

  • Use the divmod(a, b) function.
  • Use the (a // b, a % b) explicit operation with Python built-in operators.

Next, we measure the performance of calculating the elapsed runtime in milliseconds when performing 10 million computations for relatively small integers. Let’s start with divmod():

import time
import random # Small Operands
operands = zip([random.randint(1, 100) for i in range(10**7)], [random.randint(1, 100) for i in range(10**7)]) start = time.time() for i, j in operands: divmod(i, j) stop = time.time()
print('divmod() elapsed time: ', (stop-start), 'milliseconds')
# divmod() elapsed time: 1.7654337882995605 milliseconds

Compare this to integer division and modulo:

import time
import random # Small Operands
operands = zip([random.randint(1, 100) for i in range(10**7)], [random.randint(1, 100) for i in range(10**7)]) start = time.time() for i, j in operands: (i // j, i % j) stop = time.time()
print('(i // j, i % j) elapsed time: ', (stop-start), 'milliseconds')
# (i // j, i % j) elapsed time: 1.9048900604248047 milliseconds

The result of this performance benchmark is that divmod() requires 1.76 milliseconds and the explicit way of using integer division and modulo requires 1.90 milliseconds for 10,000,000 operations. Thus, divmod() is 8% faster. The reason is that the explicit way performs many duplicate operations to calculate the result of the integer division and the modulo operation which internally uses integer division again. This effect becomes even more pronounced if you use larger integers.

Performance difference divmod() vs Integer Division and Modulo

Python divmod() Implementation


For integer input arguments, here’s a semantically equivalent divmod() implementation:

>>> def divmod_own(x, y): return (x // y, x % y) >>> divmod_own(10, 3)
(3, 1)
>>> divmod(10, 3)
(3, 1)

But note that this implementation still performs redundant computations (e.g., integer division) and, therefore, is less efficient than divmod().

Summary


Python’s built-in divmod(a, b) function takes two integer or float numbers a and b as input arguments and returns a tuple (a // b, a % b).

In case of float inputs, divmod() still returns the division without remainder by rounding down to the next round number.


I hope you enjoyed the article! To improve your Python education, you may want to join the popular free Finxter Email Academy:

Do you want to boost your Python skills in a fun and easy-to-consume way? Consider the following resources and become a master coder!

Where to Go From Here?


Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Python divmod() — A Simple Guide with Video first appeared on Finxter.



https://www.sickgaming.net/blog/2021/01/...ith-video/

Print this item

  [Oracle Blog] 2018 starts strong for new Java Champions
Posted by: xSicKxBot - 03-24-2022, 12:37 PM - Forum: Java Language, JVM, and the JRE - No Replies

2018 starts strong for new Java Champions

It’s been a great start to the year for the Java Champion program having added new members from all over the world, New Zealand, Japan, Turkey, Europe, Canada and the USA. This group of talented individuals continue to push the language and platform forward, contributing to JSRs, working on open sou...

https://blogs.oracle.com/java/post/2018-...-champions

Print this item

  [Tut] Login with Twitter using OAuth1.0a Protocol via API in PHP
Posted by: xSicKxBot - 03-24-2022, 12:37 PM - Forum: PHP Development - No Replies

Login with Twitter using OAuth1.0a Protocol via API in PHP

Last modified on December 27th, 2020.

Almost all Internet giants (in good sense) like Google, Facebook, Twitter and LinkedIn support OAuth login. They provide API with detailed documentation to help developers integrate OAuth authentication.

There are many client libraries available to implement Twitter OAuth login. But we will do with just plain core PHP. Yes, actually it is sufficient, lightweight and better.

Application with the OAuth login feature has many advantages.

  • Simplifies the login process.
  • Reduces friction by minimising user’s effort with a single click.
  • Saves developers’ effort from building a custom login.
  • Assures secure authentication flow.

We have already seen how to integrate Facebook OAuth login into an application. Let us see how to Login with Twitter using OAuth authentication.

In its community API gallery, Twitter lists many PHP libraries. These libraries contain handlers to read-write API data in a secure manner. An authentication step ensures access security on each API request.

Twitter uses various authentication methods. Those are, OAuth 1.0a, OAuth 2.0 Bearer token, Basic authentication. I used OAuth 1.0a authentication to validate login with Twitter API requests.

During the login flow, Twitter prompts to enter user credentials to login. Then, it will ask to authorize the App for the first time.

“Login with Twitter” flow is very similar to the 3-legged OAuth flow used to get the access token. With the reference of this token, API will return user data as per the request URL. This example will read user name, photo and more details after successful authentication.

In this article, we will see how to integrate “Login with Twitter” by completing each of the below steps.

  • How to get and configure the API keys.
  • How to perform the 3-step authentication flow.
  • Create requests and handle responses during the authentication flow.
  • Store the authenticated user data into the Database.

What is inside?


  1. Twitter OAuth login flow
  2. How to integrate Twitter OAuth login?
  3. Generating Twitter app keys
  4. About this example
  5. Twitter OAuth PHP service
  6. PHP code to handle logged-in user data
  7. Database script
  8. Login with Twitter PHP example output

Twitter OAuth login flow


The Twitter login authentication flow includes three steps.

  1. Get a Request token and a secret-key.
  2. Redirect to Twitter to login and approve access rights to the Twitter app.
  3. Get an Access token and the secret-key to access the user account via API.

During the OAuth login process, each request has to be signed with an OAuth signature. In this example, it has a service class to prepare signed requests.

The following diagram shows the “Login with Twitter” flow. It indicates the steps, request parameters and API response data.

Twitter 3-Step OAuth Login Authentication Diagram

Click to see a larger image.

How to integrate Twitter OAuth login?


Twitter gives a Login with Twitter or Sign in with Twitter button control to put into an application. It makes users sign in to the application with a couple of clicks.

After obtaining the Twitter API keys and token secret, configure them with the PHP application. The next section will show the config file created for this example.

Then, create the request-response handlers to communicate with the Twitter API. It will proceed step by step process to obtain tokens to process the next request.

Instead of using custom handlers, we can use built-in Twitter client libraries.

With the access_token, API will allow access to hit the endpoints. But, it depends on the App permissions set in the developer console.

On getting the response data from the API, the application login flow comes to end. With this step, it will change the logged-in status of the application users in the UI.

Generating Twitter API keys


The process of generating Twitter API keys is straight-forward. Once we have seen the steps to get keys for Google OAuth login integration.

Login to the Twitter developer portal and follow the below steps.

  1. Login to Twitter and go to its developer console.
  2. Create a Twitter developer App. (project-specific app or standalone app).
  3. Go to app settings to edit permissions and authentication settings.
  4. Go to the “keys and tokens” tab to copy the consumer key and the secret key.
  5. Save the keys in a secured place and configure them into the application.

Twitter API Keys

Twitter allows creating two types of developer App. A project-specific app or a standalone app. The project-specific app can use v2 endpoints. The standalone apps can only access the v1 endpoints.

Twitter API keys will no longer keep the API keys and tokens permanently. This is for security purposes. But it allows regenerating the keys and tokens.

Configure the Twitter App consumer_key and secret_key in Config.php file. This application config defines the application constants. It includes the root path, database config and Twitter consumer and secrete key.

Common/config.php

<?php
namespace Phppot; class Config
{ const WEB_ROOT = "https://yourdomain/twitter-oauth"; // Database Configuration const DB_HOST = "localhost"; const DB_USERNAME = "root"; const DB_PASSWORD = ""; const DB_NAME = "twitter-oauth"; // Twitter API configuration const TW_CONSUMER_KEY = ''; const TW_CONSUMER_SECRET = ''; const TW_CALLBACK_URL = Config::WEB_ROOT . '/signin_with_twitter.php';
}

About this example


There are various ways to implement Twitter OAuth login in a PHP application. Generally, people use built-in client-side libraries to implement this. Twitter also recommends one or more PHP libraries in its community API gallery.

This example shows a simple code for “Login with Twitter” integration. It uses no external libraries to achieve this.

It has a custom class that prepares the API request and handle responses. It creates OAuth signatures to send valid signed requests to the API.

A landing page will show the “Sign in with Twitter” button to trigger the OAuth login process. On clicking, it invokes the PHP service to proceed with the three steps sign-in flow.

As a result, it gets the Twitter user data on successful authentication. The resultant page will change the logged-in state and display the user data.

If you refuse to approve the app access or login, Twitter will redirect back to the application. This redirect URL is set with the param list of the API request.

This example uses the Database to keep the user details read from the API response. Thus, it records the application’s users logged-in via Twitter OAuth login.

Twitter OAuth File Structure

Twitter OAuth PHP service


This PHP service class request Twitter API for the access key and token. It follows the three steps to obtain the access token.

We have seen such similar steps to get the access token in the LinkedIn OAuth login example code earlier.

The following three methods perform the three steps.

Step 1: getRequestToken() – sends the oauth_callback with the authentication header. It requests request_token and the secrete key from the Twitter API.

Step 2: getOAuthVerifier() – redirects the user to the Twitter authentication page. It let users sign in and approve the App to access the account. It passes the OAuth request token received in step1 with the URL. After authentication, Twitter will invoke the oauth_callback with the oauth_verifier in the querystring.

Step 3: getAccessToken() – requests the access_token and secrete key from the API. The params are the request_token, request_token_secret, oauth_verifier get from Step 1, 2.

Twitter requires each of the API requests has to be signed. This PHP service class has a function to generate the signature by the use of API request parameters.

lib/TwitterOAuthLogin.php

<?php
namespace Phppot; class TwitterOauthService
{ private $consumerKey; private $consumerSecret; private $signatureMethod = 'HMAC-SHA1'; private $oauthVersion = '1.0'; private $http_status = ""; public function __construct() { require_once __DIR__ . '/../Common/Config.php'; $this->consumerKey = Config::TW_CONSUMER_KEY; $this->consumerSecret = Config::TW_CONSUMER_SECRET; } public function getOauthVerifier() { $requestResponse = $this->getRequestToken(); $authUrl = "https://api.twitter.com/oauth/authenticate"; $redirectUrl = $authUrl . "?oauth_token=" . $requestResponse["request_token"]; return $redirectUrl; } public function getRequestToken() { $url = "https://api.twitter.com/oauth/request_token"; $params = array( 'oauth_callback' => Config::TW_CALLBACK_URL, "oauth_consumer_key" => $this->consumerKey, "oauth_nonce" => $this->getToken(42), "oauth_signature_method" => $this->signatureMethod, "oauth_timestamp" => time(), "oauth_version" => $this->oauthVersion ); $params['oauth_signature'] = $this->createSignature('POST', $url, $params); $oauthHeader = $this->generateOauthHeader($params); $response = $this->curlHttp('POST', $url, $oauthHeader); $responseVariables = array(); parse_str($response, $responseVariables); $tokenResponse = array(); $tokenResponse["request_token"] = $responseVariables["oauth_token"]; $tokenResponse["request_token_secret"] = $responseVariables["oauth_token_secret"]; session_start(); $_SESSION["oauth_token"] = $tokenResponse["request_token"]; $_SESSION["oauth_token_secret"] = $tokenResponse["request_token_secret"]; session_write_close(); return $tokenResponse; } public function getAccessToken($oauthVerifier, $oauthToken, $oauthTokenSecret) { $url = 'https://api.twitter.com/oauth/access_token'; $oauthPostData = array( 'oauth_verifier' => $oauthVerifier ); $params = array( "oauth_consumer_key" => $this->consumerKey, "oauth_nonce" => $this->getToken(42), "oauth_signature_method" => $this->signatureMethod, "oauth_timestamp" => time(), "oauth_token" => $oauthToken, "oauth_version" => $this->oauthVersion ); $params['oauth_signature'] = $this->createSignature('POST', $url, $params, $oauthTokenSecret); $oauthHeader = $this->generateOauthHeader($params); $response = $this->curlHttp('POST', $url, $oauthHeader, $oauthPostData); $fp = fopen("eg.log", "a"); fwrite($fp, "AccessToken: " . $response . "\n"); $responseVariables = array(); parse_str($response, $responseVariables); $tokenResponse = array(); $tokenResponse["access_token"] = $responseVariables["oauth_token"]; $tokenResponse["access_token_secret"] = $responseVariables["oauth_token_secret"]; return $tokenResponse; } public function getUserData($oauthVerifier, $oauthToken, $oauthTokenSecret) { $accessTokenResponse = $this->getAccessToken($oauthVerifier, $oauthToken, $oauthTokenSecret); $url = 'https://api.twitter.com/1.1/account/verify_credentials.json'; $params = array( "oauth_consumer_key" => $this->consumerKey, "oauth_nonce" => $this->getToken(42), "oauth_signature_method" => $this->signatureMethod, "oauth_timestamp" => time(), "oauth_token" => $accessTokenResponse["access_token"], "oauth_version" => $this->oauthVersion ); $params['oauth_signature'] = $this->createSignature('GET', $url, $params, $accessTokenResponse["access_token_secret"]); $oauthHeader = $this->generateOauthHeader($params); $response = $this->curlHttp('GET', $url, $oauthHeader); return $response; } public function curlHttp($httpRequestMethod, $url, $oauthHeader, $post_data = null) { $ch = curl_init(); $fp = fopen("eg.log", "a"); fwrite($fp, "Header: " . $oauthHeader . "\n"); $headers = array( "Authorization: OAuth " . $oauthHeader ); $options = [ CURLOPT_HTTPHEADER => $headers, CURLOPT_HEADER => false, CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, ]; if($httpRequestMethod == 'POST') { $options[CURLOPT_POST] = true; } if(!empty($post_data)) { $options[CURLOPT_POSTFIELDS] = $post_data; } curl_setopt_array($ch, $options); $response = curl_exec($ch); $this->http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $response; } public function generateOauthHeader($params) { foreach ($params as $k => $v) { $oauthParamArray[] = $k . '="' . rawurlencode($v) . '"'; } $oauthHeader = implode(', ', $oauthParamArray); return $oauthHeader; } public function createSignature($httpRequestMethod, $url, $params, $tokenSecret = '') { $strParams = rawurlencode(http_build_query($params)); $baseString = $httpRequestMethod . "&" . rawurlencode($url) . "&" . $strParams; $fp = fopen("eg.log", "a"); fwrite($fp, "Baaaase: " . $baseString . "\n"); $signKey = $this->generateSignatureKey($tokenSecret); $oauthSignature = base64_encode(hash_hmac('sha1', $baseString, $signKey, true)); return $oauthSignature; } public function generateSignatureKey($tokenSecret) { $signKey = rawurlencode($this->consumerSecret) . "&"; if (! empty($tokenSecret)) { $signKey = $signKey . rawurlencode($tokenSecret); } return $signKey; } public function getToken($length) { $token = ""; $codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $codeAlphabet .= "abcdefghijklmnopqrstuvwxyz"; $codeAlphabet .= "0123456789"; $max = strlen($codeAlphabet) - 1; for ($i = 0; $i < $length; $i ++) { $token .= $codeAlphabet[$this->cryptoRandSecure(0, $max)]; } return $token; } public function cryptoRandSecure($min, $max) { $range = $max - $min; if ($range < 1) { return $min; // not so random... } $log = ceil(log($range, 2)); $bytes = (int) ($log / 8) + 1; // length in bytes $bits = (int) $log + 1; // length in bits $filter = (int) (1 << $bits) - 1; // set all lower bits to 1 do { $rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes))); $rnd = $rnd & $filter; // discard irrelevant bits } while ($rnd >= $range); return $min + $rnd; }
}

Initiate login flow with “Sign in with Twitter” control


The landing page of this example will show a “Sign in with Twitter” button. On clicking this button, it invokes functions to proceed with the 3-step login flow.

The following code shows the index.php file script. It checks if any user logged-in already. If so, it displays the user dashboard. Otherwise, it shows the “Sign in with Twitter” button.

It invokes the TwitterOAuthService to initiate the login flow. This initiation will happen when the user tries to log in.

index.php

<?php
namespace Phppot; if (isset($_GET["action"]) && $_GET["action"] == "login") { require_once __DIR__ . '/lib/TwitterOauthService.php'; $twitterOauthService = new TwitterOauthService(); $redirectUrl = $twitterOauthService->getOauthVerifier(); header("Location: " . $redirectUrl); exit();
} session_start();
if ($_SESSION["id"]) { $memberId = $_SESSION["id"];
}
session_write_close(); ?>
<html>
<head>
<title>Home</title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body> <div class="phppot-container">
<?php
if (empty($memberId)) { ?> <a href="?action=login"> <img class="twitter-btn" src="sign-in-with-twitter.png"></a>
<?php
} else { require_once './lib/Member.php'; $member = new Member(); $userData = $member->getUserById($memberId); ?>
<div class="welcome-messge-container"> <img src="<?php echo $userData[0]["photo_url"]; ?>" class="profile-photo" /> <div>Welcome <?php echo $userData[0]["screen_name"]; ?></div> </div>
<?php
}
?>
</div>
</body>
</html>

PHP code to handle logged-in user data


After completing the 3-steps, the TwitterOauthService will return the user access token. Then it invokes GET oauth/verify_credentials endpoint to read the user daya.

It will return the logged-in user data as a JSON response. The application callback endpoint receives this data.

Then, the code will save the data into the database and put the logged-in user id into the session. Based on the existence of this user session the landing page will show the user dashboard.

sign-in-with-twitter.php

<?php
namespace Phppot; require_once './lib/TwitterOauthService.php';
$TwitterOauthService = new TwitterOauthService(); session_start();
$oauthTokenSecret = $_SESSION["oauth_token_secret"]; if (! empty($_GET["oauth_verifier"]) && ! empty($_GET["oauth_token"])) { $userData = $TwitterOauthService->getUserData($_GET["oauth_verifier"], $_GET["oauth_token"], $oauthTokenSecret); $userData = json_decode($userData, true); if (! empty($userData)) { $oauthId = $userData["id"]; $fullName = $userData["name"]; $screenName = $userData["screen_name"]; $photoUrl = $userData["profile_image_url"]; require_once './lib/Member.php'; $member = new Member(); $isMemberExists = $member->isExists($oauthId); if (empty($isMemberExists)) { $memberId = $member->insertMember($oauthId, $fullName, $screenName, $photoUrl); } else { $memberId = $isMemberExists[0]["id"]; } if (! empty($memberId)) { unset($_SESSION["oauth_token"]); unset($_SESSION["oauth_token_secret"]); $_SESSION["id"] = $memberId; header("Location: index.php"); } }
} else { ?>
<HTML>
<head>
<title>Signin with Twitter</title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body> <div class="phppot-container"> <div class="error"> Sorry. Something went wrong. <a href="index.php">Try again</a>. </div> </div>
</body>
</HTML>
<?php
}
session_write_close();
exit();

The following PHP class has functions to prepare database queries. It is to read data, to check user existency, to insert new records.

lib/Member.php

<?php
namespace Phppot; class Member
{ private $db; private $userTbl; function __construct() { require_once __DIR__ . '/DataSource.php'; $this->db = new DataSource(); } function isExists($twitterOauthId) { $query = "SELECT * FROM tbl_member WHERE oauth_id = ?"; $paramType = "s"; $paramArray = array( $twitterOauthId ); $result = $this->db->select($query, $paramType, $paramArray); return $result; } function insertMember($oauthId, $fullName, $screenName, $photoUrl) { $query = "INSERT INTO tbl_member (oauth_id, oauth_provider, full_name, screen_name, photo_url) values (?,?,?,?,?)"; $paramType = "sssss"; $paramArray = array( $oauthId, 'twitter', $fullName, $screenName, $photoUrl ); $this->db->insert($query, $paramType, $paramArray); } function getUserById($id) { $query = "SELECT * FROM tbl_member WHERE id = ?"; $paramType = "i"; $paramArray = array( $id ); $result = $this->db->select($query, $paramType, $paramArray); return $result; }
}

DataSource class and Database script


The database related functions are in the DataSource class. It is for creating the database connection and to perform read, write operations.

It uses MySQLi prepared statements to execute database queries. It will help to have a secured code that prevents SQL injection.

lib/DataSource.php

<?php
/** * Copyright © Phppot * * Distributed under 'The MIT License (MIT)' * In essense, you can do commercial use, modify, distribute and private use. * Though not mandatory, you are requested to attribute Phppot URL in your code or website. */
namespace Phppot; /** * Generic datasource class for handling DB operations. * Uses MySqli and PreparedStatements. * * @version 2.6 - recordCount function added */
class DataSource
{ const HOST = 'localhost'; const USERNAME = 'root'; const PASSWORD = 'test'; const DATABASENAME = 'oauth_login'; private $conn; /** * PHP implicitly takes care of cleanup for default connection types. * So no need to worry about closing the connection. * * Singletons not required in PHP as there is no * concept of shared memory. * Every object lives only for a request. * * Keeping things simple and that works! */ function __construct() { $this->conn = $this->getConnection(); } /** * If connection object is needed use this method and get access to it. * Otherwise, use the below methods for insert / update / etc. * * @return \mysqli */ public function getConnection() { $conn = new \mysqli(self::HOST, self::USERNAME, self::PASSWORD, self::DATABASENAME); if (mysqli_connect_errno()) { trigger_error("Problem with connecting to database."); } $conn->set_charset("utf8"); return $conn; } /** * To get database results * * @param string $query * @param string $paramType * @param array $paramArray * @return array */ public function select($query, $paramType = "", $paramArray = array()) { $stmt = $this->conn->prepare($query); if (! empty($paramType) && ! empty($paramArray)) { $this->bindQueryParams($stmt, $paramType, $paramArray); } $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $resultset[] = $row; } } if (! empty($resultset)) { return $resultset; } } /** * To insert * * @param string $query * @param string $paramType * @param array $paramArray * @return int */ public function insert($query, $paramType, $paramArray) { $stmt = $this->conn->prepare($query); $this->bindQueryParams($stmt, $paramType, $paramArray); $stmt->execute(); $insertId = $stmt->insert_id; return $insertId; } /** * To execute query * * @param string $query * @param string $paramType * @param array $paramArray */ public function execute($query, $paramType = "", $paramArray = array()) { $stmt = $this->conn->prepare($query); if (! empty($paramType) && ! empty($paramArray)) { $this->bindQueryParams($stmt, $paramType, $paramArray); } $stmt->execute(); } /** * 1. * Prepares parameter binding * 2. Bind prameters to the sql statement * * @param string $stmt * @param string $paramType * @param array $paramArray */ public function bindQueryParams($stmt, $paramType, $paramArray = array()) { $paramValueReference[] = &$paramType; for ($i = 0; $i < count($paramArray); $i ++) { $paramValueReference[] = &$paramArray[$i]; } call_user_func_array(array( $stmt, 'bind_param' ), $paramValueReference); } /** * To get database results * * @param string $query * @param string $paramType * @param array $paramArray * @return array */ public function getRecordCount($query, $paramType = "", $paramArray = array()) { $stmt = $this->conn->prepare($query); if (! empty($paramType) && ! empty($paramArray)) { $this->bindQueryParams($stmt, $paramType, $paramArray); } $stmt->execute(); $stmt->store_result(); $recordCount = $stmt->num_rows; return $recordCount; }
}

The below section shows the tbl_member database table script. Import this script before executing this example.

sql/structure.sql

--
-- Database: `oauth_login`
-- -- -------------------------------------------------------- --
-- Table structure for table `tbl_member`
-- CREATE TABLE `tbl_member` ( `id` int(11) NOT NULL, `oauth_id` varchar(255) NOT NULL, `oauth_provider` varchar(255) NOT NULL, `full_name` varchar(255) NOT NULL, `screen_name` varchar(255) NOT NULL, `photo_url` varchar(255) NOT NULL, `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1; --
-- Indexes for dumped tables
-- --
-- Indexes for table `tbl_member`
--
ALTER TABLE `tbl_member` ADD PRIMARY KEY (`id`); --
-- AUTO_INCREMENT for dumped tables
-- --
-- AUTO_INCREMENT for table `tbl_member`
--
ALTER TABLE `tbl_member` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

Login with Twitter example output


After completing the application config, the home page will display the “Sign in with Twitter” button as below.

Sign In with Twitter Gray

Before login, the home page will display the “Sign in with Twitter” button as below. I used the login button downloaded from the official Twitter documentation.

User Dashboard Twitter Login

Download

↑ Back to Top



https://www.sickgaming.net/blog/2020/12/...pi-in-php/

Print this item

  (Free Game Key) Cris Tales - Free Epic Game
Posted by: xSicKxBot - 03-24-2022, 12:37 PM - Forum: Deals or Specials - No Replies

Cris Tales - Free Epic Game

Visit the store page and add the game to your account:

Cris Tales[store.epicgames.com]

The game is free to keep until Mar 3rd 2022 - 16:00 UTC.

Next week's freebie:
Black Widow: Recharged
Centipede: Recharged

We are welcoming everyone to join our discord[discord.gg]. We are more active there on finding giveaways, small or large, and there are daily raffles you can participate.

?GrabFreeGames.com ?Twitter ?Steam Curator ?Facebook[fb.me]?Discord[discord.gg]
❤️Support us: ✔️HumbleBundle Partner[www.humblebundle.com] Epic Tag: GrabFreeGames


https://steamcommunity.com/groups/GrabFr...5211619834

Print this item

  (Indie Deal) Retro Classix Giveaways, Risk of Rain 2 & Slitherine Sales
Posted by: xSicKxBot - 03-24-2022, 12:37 PM - Forum: Deals or Specials - No Replies

Retro Classix Giveaways, Risk of Rain 2 & Slitherine Sales

Retro Classix Giveaways
[www.indiegala.com]

https://www.youtube.com/watch?v=ZRt93UcB5jE
Risk of Rain 2[www.indiegala.com] | 60%
Risk of Rain 2 - Survivors of the Void[www.indiegala.com] | 43%

TheGameCreators,Kalypso & Slitherine Sale
[www.indiegala.com]
[www.indiegala.com]
[www.indiegala.com]
Save up to 80% OFF, on the final cashback day! Any purchase made on IndieGala (be it store deals or bundles) will be rewarding you instantly and handsomely, directly into your IndieGala account, with 5% of your final purchase (in the form of GalaCredit).

https://www.youtube.com/watch?v=_d7tu_k8g2Q
Stay Inside, Stay Safe and Enjoy Good Games.
Check out IndieGala on Twitter, YouTube & Facebook[www.facebook.com]


https://steamcommunity.com/groups/indieg...3538893372

Print this item

  PC - ELEX II
Posted by: xSicKxBot - 03-24-2022, 12:37 PM - Forum: New Game Releases - No Replies

ELEX II



ELEX II is the sequel to ELEX, the vintage open-world role-playing experience from the award-winning creators of the Gothic and Risen series, Piranha Bytes. ELEX II returns to the post-apocalyptic Science Fantasy world of Magalan with massive environments that can be explored with unrivaled freedom via jetpack, you will be able to move through the epic story any way you want.

Several years after Jax defeated the Hybrid, a new threat arrives from the sky, unleashing the dangerous powers of dark Elex and endangering all life on the planet. In order to defend the peace on Magalan and the safety of his own family, Jax has to go on a mission to convince the factions to unite against the invaders.

Dive into a huge, hand-crafted, completely unique world with multiple factions and diverse environments set in a post-apocalyptic science fantasy universe.

Publisher: THQ Nordic

Release Date: Mar 01, 2022




https://www.metacritic.com/game/pc/elex-ii

Print this item

  How to install Node.js 16 on Ubuntu 20.04 LTS
Posted by: SickProdigy - 03-23-2022, 08:13 PM - Forum: Linux, FreeBSD, and Unix types - No Replies

Ubuntu tends to drop a new version of their April release shortly after a new version of Node.js drops. Every other year, this Ubuntu release is a long-term support release, which has a longer shelf life in terms of support and maintenance compared to their interim releases.

True to form of Debian and Debian-based distros striving for stability, Ubuntu doesn’t include the latest and greatest version of Node.js with their LTS releases. In fact, depending on the year, you get the current LTS version of Node.js or something even older.

With Ubuntu 20.04 LTS, your on Node.js 10.x-14.x, which at this point, is quite behind as Node.js 16.x is available and 10.x has left maintenance mode. Node.js 16.x won’t become the LTS release until later this year, but it’s still considered stable and will inevitably become the LTS release, so there’s no reason not to upgrade!

To get started, I always like to make sure my Ubuntu installation is fully up to date:

Code:
sudo apt update sudo apt upgrade

Don’t forget to reboot if you had any updates to the Linux Kernel.
With things all up to date, let’s make sure we have curl installed, as we’ll be using that to download the installation script from NodeSource (which provides binary packages for Ubuntu, Debian and a bunch of their derivatives):
Code:
sudo apt install -y curl


Obviously if you know you already have curl installed, you don’t need to run this. Once we have curl in the mix, we can download and run the setup script:
Code:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -

That script will run, gets thing added to your apt sources, and will even run another apt update to make sure you’re ready to go. Once that’s done running, you will need to install or upgrade the current version of Node.js you have installed:
Code:
sudo apt install -y nodejs


At this point, you should be all set. Just to be certain, you can run node to figure out what version you’re currently running:
Code:
$ node --version v16.1.0
A little note, because it never fails that somebody brings up that you could nvm to accomplish this. While you certainly COULD use nvm, and that may be your preferred method, it’s not mine, for a number of reasons.

First,
nvm needed to be sourced in your shell profile, which can slow your prompt down when creating new sessions. I’ve been able to speed things up by lazy loading it, but that wasn’t my biggest issue with using nvm.

My biggest concern with using nvm on a server is that it creates an additional way to install / update packages. By using this method, you add Node.js into your system’s existing package manager, apt and you can easily upgrade nodejs along with your other system packages.

This makes it the clear choice for me, as it’s one less thing for me to have to think about when maintaining a server.

Quick note:
NPM is installed with Node.js 16.x, so don't have to install separately like previous versions.

Print this item

  How To Zip Folder on Linux
Posted by: SickProdigy - 03-23-2022, 07:31 PM - Forum: Linux, FreeBSD, and Unix types - No Replies

From all the compression methods available, Zip is probably one of the most popular ones.

Released in 1989 by Philip Katz, Zip is widely used by system administrators in order to reduce the size of bulky files and directories on your system.

Nowadays, Zip is available on all operating systems on the market : whether it is Windows, Linux or MacOS.

With zip, you can easily transfer files between operating systems and save space on your disks.

In this tutorial, we are going to see how you can easily zip folders and directories on Linux using the zip command.


Zip Folder using zip

The easiest way to zip a folder on Linux is to use the “zip” command with the “-r” option and specify the file of your archive as well as the folders to be added to your zip file.

You can also specify multiple folders if you want to have multiple directories compressed in your zip file.

$ zip -r ...

For example, let’s say that you want to archive a folder named “Documents” in a zip file named “temp.zip”.

In order to achieve that, you would run the following command

$ zip -r temp.zip Documents

In order to check if your zip file was created, you can run the “ls” command and look for your archive file.

$ ls -l | grep .zip

Alternatively, if you are not sure where you stored your zip files before, you can search for files using the find command

$ find / -name *.zip 2> /dev/null

Zip Folder using find

Another great way of creating a zip file for your folders is to use the “find” command on Linux. You have to link it to the “exec” option in order to execute the “zip” command that creates an archive.

If you want to zip folders in the current working directory, you would run the following command

$ find . -maxdepth 1 -type d -exec zip archive.zip {} +


Using this technique is quite useful : you can choose to archive folders recursively or to have only a certain level of folders zipped in your archive.
Zip Folder using Desktop Interface

If you are using GNOME or KDE, there’s also an option for you to zip your folders easily.
Compress Folders using KDE Dolphin

If you are using the KDE Graphical Interface, you will be able to navigate your folders using the Dolphin File Manager.

In order to open Dolphin, click on your the “Application Launcher” button at the bottom left of your screen and type “Dolphin“.

Click on the “Dolphin – File Manager” option.

Now that Dolphin is open, select the folders to be zipped by holding the “Control” key and left-clicking on the folders to be compressed together.
select folders on dolphin linux

Now that folders are selected, right-click wherever you want and select the “Compress” option.

When hovering your mouse cursor over the “Compress” option and select the “Here (as ZIP)” option in the menu.

If you want to zip folders in another location, you will have to select the “Compress to” option, specify the location and the compression mode (as ZIP).
create zip for folders using dolphin on linux

After a quick time, depending on the size of your archive, your zip should be created with all the folders you have selected in it.
zip created for folders on linux

Congratulations, you successfully created a zip for your folders on Linux!
Compress Folders on GNOME

If you are using GNOME, on Debian 10 or on CentOS 8 for example, you will also be able to compress your files directly from the user interface.

Select the “Applications” menu at the top left corner of your Desktop, and search for “Files“
Files file manager on GNOME

Select the “Files” option : your file explorer should start automatically.

Now that you are in your file explorer, select multiple folders by holding the “Control” key and left-clicking on all the folders to be zipped.

When you are done, right-click and select the “Compress” option.
compressing folders using GNOME

Now that the “Compress” option is selected, a popup window should appear asking for the filename of your zip as well as the extension to be used.
naming your archive on GNOME

When you are done, simply click the “Create” option for your zip file to be created.
zip file created on GNOME File manager

That’s it!

Your folders should now be zipped in an archive file : you can start sending the archive or extracting the files that are contained in it.
Zipping Directories using Bash

In some cases, you may not have a graphical interface directly installed on your server.

As a consequence, you may want to zip folders directly from the command-line, using the Bash programming language.

If you are not sure about Bash, here’s a Bash beginners guide and another one for more advanced Bash scripting.

In order to zip folders using Bash, use the “for” loop and iterate over the directories of the current working directory

$ for file in $(ls -d */); do zip archive.zip $file; done

zip folder using bash

Using bash, you can actually get specific when it comes to the folders to be zipped.

For example, if you want to zip folders beginning with the letter D, you can write the following command

$ for file in $(ls -d */ | grep D); do zip archive.zip $file; done

Congratulations, you successfully created a zip for your folders in the current working directory!

Print this item

  New features in Red Hat CodeReady Studio 12.13.0.GA and JBoss Tools 4.13.0.Final for
Posted by: xSicKxBot - 03-23-2022, 11:50 AM - Forum: Java Language, JVM, and the JRE - No Replies

New features in Red Hat CodeReady Studio 12.13.0.GA and JBoss Tools 4.13.0.Final for

JBoss Tools 4.13.0 and Red Hat CodeReady Studio 12.13 for Eclipse 2019-09 are here and waiting for you. In this article, I’ll cover the highlights of the new releases and show how to get started.

Installation


Red Hat CodeReady Studio (previously known as Red Hat Developer Studio) comes with everything pre-bundled in its installer. Simply download it from our Red Hat CodeReady Studio product page and run it like this:

java -jar codereadystudio-<installername>.jar

JBoss Tools or Bring-Your-Own-Eclipse (BYOE) CodeReady Studio requires a bit more.

This release requires at least Eclipse 4.13 (2019-09), but we recommend using the latest Eclipse 4.13 2019-09 JEE Bundle because then you get most of the dependencies pre-installed.

Once you have installed Eclipse, you can either find us on the Eclipse Marketplace under “JBoss Tools” or “Red Hat CodeReady Studio.”

For JBoss Tools, you can also use our update site directly:

http://download.jboss.org/jbosstools/pho...e/updates/

What’s new?


Our main focus for this release was improvements for container-based development and bug fixing. Eclipse 2019-06 itself has a lot of new cool stuff, but I’ll highlight just a few updates in both Eclipse 2019-06 and JBoss Tools plugins that I think are worth mentioning.

Red Hat OpenShift


OpenShift Container Platform 4.2 support


With the new OpenShift Container Platform (OCP) 4.2 now available (see the announcement), even if this is a major shift compared to OCP 3, Red Hat CodeReady Studio and JBoss Tools are compatible with this major release in a transparent way. Just define your connection to your OCP 4.2 based cluster as you did before for an OCP 3 cluster, and use the tooling!

CodeReady Containers 1.0 Server Adapter


A new server adapter has been added to support the next generation of CodeReady Containers 1.0. Although the server adapter itself has limited functionality, it is able to start and stop the CodeReady Containers virtual machine via its crc binary. Simply hit Ctrl+3 (Cmd+3 on OSX) and type new server, which will bring up a command to set up a new server.

crc server adapter

Enter crc in the filter textbox.

You should see the Red Hat CodeReady Containers 1.0 server adapter.

Select Red Hat CodeReady Containers 1.0 and click Next.

All you have to do is set the location of the CodeReady Containers crc binary file and the pull secret file location, which can be downloaded from https://cloud.redhat.com/openshift/install/crc/installer-provisioned.

Once you’re finished, a new CodeReady Containers server adapter will then be created and visible in the Servers view.

Once the server is started, a new OpenShift connection should appear in the OpenShift Explorer view, allowing the user to quickly create a new Openshift application and begin developing their AwesomeApp in a highly replicatable environment.

Server tools


Wildfly 18 Server Adapter


A server adapter has been added to work with Wildfly 18. It adds support for Java EE 8 and Jakarta EE 8.

EAP 7.3 Beta Server Adapter


A server adapter has been added to work with EAP 7.3 Beta.

Hibernate Tools


Hibernate Runtime Provider Updates


A number of additions and updates have been performed on the available Hibernate runtime providers.

The Hibernate 5.4 runtime provider now incorporates Hibernate Core version 5.4.7.Final and Hibernate Tools version 5.4.7.Final.

The Hibernate 5.3 runtime provider now incorporates Hibernate Core version 5.3.13.Final and Hibernate Tools version 5.3.13.Final.

Platform


Views, Dialogs and Toolbar



The new Quick Search dialog provides a convenient, simple and fast way to run a textual search across your workspace and jump to matches in your code. The dialog provides a quick overview showing matching lines of text at a glance. It updates as quickly as you can type and allows for quick navigation using only the keyboard. A typical workflow starts by pressing the keyboard shortcut Ctrl+Alt+Shift+L (or Cmd+Alt+Shift+L on Mac). Typing a few letters updates the search result as you type. Use Up-Down arrow keys to select a match, then hit Enter to open it in an editor.

Save editor when Project Explorer has focus

You can now save the active editor even when the Project Explorer has focus. In cases where an extension contributes Saveables to the Project Explorer, the extension is honored and the save action on the Project Explorer will save the provided saveable item instead of the active editor.

“Show In” context menu available for normal resources

The Show In context menu is now available for an element inside a resource project on the Project Explorer.

Show colors for additions and deletions in Compare viewer

In simple cases such as a two-way comparison or a three-way comparison with no merges and conflicts, the Compare viewer now shows different colors, depending on whether text has been added, removed, or modified. The default colors are green, red, and black, respectively.

The colors can be customized through usual theme customization approaches, including using related entries in the Colors and Fonts preference page.

Editor status line shows more selection details

The status line for Text Editors now shows the cursor position, and when the editor has something selected, it shows the number of characters in the selection as well. This also works in the block selection mode.

These two new additions to the status line can be disabled via the General > Editors > Text Editors preference page.

Shorter dialog text

Several dialog texts have been shortened. This allows you to capture important information faster.

Previously:

Now:

Close project via middle-click

In the Project Explorer, you can now close a project using middle-click.

Debug


Improved usability of Environment tab in Launch Configurations

In the Environment tab of the Launch Configuration dialog, you can now double-click on an environment variable name or value and start editing it directly from the table.

Right-clicking on the environment variable table now opens a context menu, allowing for quick addition, removal, copying, and pasting of environment variables.

Show Command Line for external program launch

The External Tools Configuration dialog for launching an external program now supports the Show Command Line button.

Preferences


Close editors automatically when reaching 99 open editors

The preference to close editors automatically is now enabled by default. It will be triggered when you have opened 99 files. If you continue to open editors, old editors will be closed to protect you from performance problems. You can modify this setting in the Preferences dialog via the General > Editors > Close editors automatically preference.

In-table color previews for Text Editor appearance color options

You can now see all the colors currently being used in Text Editors from the Appearance color options table, located in the Preferences > General > Editors > Text Editor page.

Automatic detection of UI freezes in the Eclipse SDK

The Eclipse SDK has been configured to show stack traces for UI freezes in the Error Log view by default for new workspaces. You can use this information to identify and report slow parts of the Eclipse IDE.

You can disable the monitoring or tweak its settings via the options in the General > UI Responsiveness Monitoring preference page as shown below.

Themes and Styling


Start automatically in dark theme based on OS theme

On Linux and Mac, Eclipse can now start automatically in dark theme when the OS theme is dark. This works by default, that is on a new workspace or when the user has not explicitly set or changed the theme in Eclipse.

Display of Help content respects OS theme

More and more operating systems provide a system-wide dark theme. Eclipse now respects this system-wide theme setting when the Eclipse help content is displayed in an external browser. A prerequisite for this is a browser that supports the prefers-color-scheme CSS media query.

As of the time of writing, the following browser versions support it:

  • Firefox version 67
  • Chrome version 76
  • Safari version 12.1

Help content uses high-resolution icons.

The Help System, as well as the help content of the Eclipse Platform, the Java Development Tooling, and the Plug-in Development Environment, now uses high-resolution icons. They are now crisp on high-resolution displays and also look much better in the dark theme.

Improved dark theme on Windows

Labels, Sections, Checkboxes, Radio Buttons, FormTexts, and Sashes on forms now use the correct background color in the dark mode on windows.

General Updates


Interactive performance

Interactive performance has been further improved in this release and several UI freezes have been fixed.

Show key bindings when command is invoked

For presentations, screencasts, and learning purposes, it is very helpful to show the corresponding key binding when a command is invoked. When the command is invoked (via a key binding or menu interaction) the key binding, the command’s name and description are shown on the screen.

You can activate this in the Preferences dialog via the Show key binding when command is invoked checkbox on the General > Keys preference page. To toggle this setting quickly, you can use the Toggle Whether to Show Key Binding command (e.g., via the quick access).

Java Developement Tools (JDT)


Java 13 Support


Java 13 is out, and Eclipse JDT supports Java 13 for 4.13 via Marketplace.

The release notably includes the following Java 13 features:

  • JEP 354: Switch Expressions (Preview).
  • JEP 355: Text Blocks (Preview).

Please note that these are preview language features; hence, the enable preview option should be on. For an informal introduction of the support, please refer to Java 13 Examples wiki.

Java Views and Dialogs


Synchronize standard and error output in console

The Eclipse Console view currently can not ensure that mixed standard and error output is shown in the same order as it is produced by the running process. For Java applications, the launch configuration Common tab now provides an option to merge standard and error output. This ensures that standard and error output is shown in the same order it was produced but also disables the individual coloring of error output.

Java Editor


Convert to enhanced ‘for’ loop using Collections

The Java quickfix/cleanup Convert to enhanced ‘for’ loop is now offered on for loops that are iterating through Collections. The loop must reference the size method as part of the condition and if accessing elements in the body, must use the get method. All other Collection methods other than isEmpty invalidate the quickfix being offered.

Initialize ‘final’ fields

A Java quickfix is now offered to initialize an uninitialized final field in the class constructor. The fix will initialize a String to the empty string, a numeric base type to 0, and, for class fields, it initializes them using their default constructor if available or null if no default constructor exists.

Autoboxing and Unboxing

Use Autoboxing and Unboxing when possible. These features are enabled only for Java 5 and higher.

Improved redundant modifier removal

The Remove redundant modifier now also removes useless abstract modifier on the interfaces.

For the given code:

You get this:

Javadoc comment generation for module

Adding a Javadoc comment to a Java module (module-info.java) will result in automatic annotations being added per the new module comment preferences.

The $(tags) directive will add @uses and @provides tags for all uses and provides module statements.

Chain Completion Code Assist

Code assist for “Chain Template Proposals” will be available. These will traverse reachable local variables, fields, and methods, to produce a chain whose return type is compatible with the expected type in a particular context.

The preference to enable the feature can be found in the Advanced sub-menu of the Content Assist menu group (Preferences > Java > Editor > Content Assist > Advanced).

Java Formatter


Remove excess blank lines

All the settings in the Blank lines section can now be configured to remove excess blank lines, effectively taking precedence over the Number of empty lines to preserve setting. Each setting has its own button to turn the feature on, right next to its number control. The button is enabled only if the selected number of lines is smaller than the Number of empty lines to preserve; otherwise, any excess lines are removed anyway.

Changes in blank lines settings

There’s quite a lot of changes in the Blank lines section of the formatter profile.

Some of the existing subsections and settings are now phrased differently to better express their function:

  • The Blank lines within class declarations subsection is now Blank lines within type declaration.
  • Before first declaration is now Before first member declaration.
  • Before declarations of the same kind is now Between member declarations of different kind.
  • Before member class declarations is now Between member type declarations.
  • Before field declarations is now Between field declarations.
  • Before method declarations is now Between method/constructor declarations.

More importantly, a few new settings have been added to support more places where the number of empty lines can be controlled:

  • After last member declaration in a type (to complement previously existing Before first member declaration setting).
  • Between abstract method declarations in a type (these cases were previously handled by Between method/constructor declarations).
  • At end of method/constructor body (to complement previously existing At beginning of method/constructor body setting).
  • At beginning of code block and At end of code block.
  • Before statement with code block and After statement with code block.
  • Between statement groups in ‘switch.’

Most of the new settings have been put in a new subsection Blank lines within method/constructor declarations.

JUnit


JUnit 5.5.1

JUnit 5.5.1 is here and Eclipse JDT has been updated to use this version.

Debug


Enhanced support for –patch-module during launch

The Java Launch Configuration now supports patching of different modules by different sources during the launch. This can be verified in the Override Dependencies…​ dialog in the Dependencies tab in a Java Launch Configuration.

Java Build


Full build on JDT core preferences change

Manually changing the settings file .settings/org.eclipse.jdt.core.prefs of a project will result in a full project build, if the workspace auto-build is on. For example, pulling different settings from a git repository or generating the settings with a tool will now trigger a build. Note that this includes timestamp changes, even if actual settings file contents were not changed.

For the 4.13 release, it is possible to disable this new behavior with the VM property: -Dorg.eclipse.disableAutoBuildOnSettingsChange=true. It is planned to remove this VM property in a future release.

And more…​


You can find more noteworthy updates in on this page.

What is next?


Having JBoss Tools 4.13.0 and Red Hat CodeReady Studio 12.13 out we are already working on the next release for Eclipse 2019-12.

Share

The post New features in Red Hat CodeReady Studio 12.13.0.GA and JBoss Tools 4.13.0.Final for Eclipse 2019-09 appeared first on Red Hat Developer.



https://www.sickgaming.net/blog/2019/11/...e-2019-09/

Print this item