Create an account


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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 20,108
» Latest member: jax9090mm
» Forum threads: 21,756
» Forum posts: 22,621

Full Statistics

Online Users
There are currently 775 online users.
» 2 Member(s) | 768 Guest(s)
Applebot, Baidu, Bing, Google, Yandex, jax9090mm, Silky121

 
  PC - Atomic Heart
Posted by: xSicKxBot - 02-28-2023, 06:54 AM - Forum: New Game Releases - No Replies

Atomic Heart



In the Soviet Union of the future, in 1955, science reigns supreme. The world is on the verge of the greatest event. You are Agent Major P-3 and you will have to find out what is really lying behind the utopian dream.

Publisher: Mundfish

Release Date: Feb 21, 2023




https://www.metacritic.com/game/pc/atomic-heart

Print this item

  [Oracle Blog] Java Card 3.1: Enhanced deployment model and core features
Posted by: xSicKxBot - 02-27-2023, 11:06 AM - Forum: Java Language, JVM, and the JRE - No Replies

Java Card 3.1: Enhanced deployment model and core features

Java Card 3.1 introduces an extended file format, the management of static resources, binary compatibility improvements, and the support of array views. Those features evolve the deployment and upgrade of applications, and they permit better design modularity and security as well.


https://blogs.oracle.com/java/post/java-...e-features

Print this item

  [Tut] BrainWaves P2P Social Network – How I Created a Basic Server
Posted by: xSicKxBot - 02-27-2023, 11:06 AM - Forum: Python - No Replies

BrainWaves P2P Social Network – How I Created a Basic Server

5/5 – (1 vote)

Welcome back to the Brainwaves P2P project, or at least my take on it :-).

The previous article was a theoretical explanation of how I envision this project. It is now time to start laying the groundwork!

I learn as I go…


As some of you might have guessed already, I’m a completely self-taught coder. Because of that, I’m sure many professionals might not agree with how I code.

I accept that and will welcome any constructive criticism. I have been learning non-stop since I started this project. I assume this will not slow down anytime soon. YouTube is my main source of knowledge as I learn best when seeing something done. I am, in other words, a visual learner. I found an article that explains it well here.

Articles on various sites are the other half of how I learn new concepts in coding. That is how I found Finxter :-).

So to sum it up, my code is far from perfect, and I will never claim it is. This is my take on trying to solve this puzzle. I actually look forward to alternative approaches!

You can open issues on my GitHub if you want to address something.

Now that we all know where we stand let us dive right in! How to build a server for our peer-to-peer social network app?

Flask vs FastAPI


In the previous article, I mentioned that I want to use FastAPI to build the relay server, as opposed to Flask. As I have done before and will do again, I asked ChatGPT about the differences between Flask and FastAPI.

? Flask vs FastAPI Flask is based on the Werkzeug WSGI (Web Server Gateway Interface) toolkit, which is synchronous by default. However, Flask can still be used to build asynchronous applications. You will need to use a third-party library like gevent or asyncio. With these libraries, Flask can use coroutines and event loops to handle I/O operations asynchronously. FastAPI, on the other hand, is designed to be fully asynchronous from the ground up. It uses the async/await syntax of Python to write asynchronous code. It is based on the ASGI (Asynchronous Server Gateway Interface) specification. FastAPI uses the Starlette framework as its foundation. the framework provides a high-performance event loop and asynchronous request handlers.

Both the speed and the asynchrony determined my choice for FastAPI.

Those of you familiar with Flask will know about its built-in development server. As FastAPI doesn’t have this, we’ll need to install a separate server.

Uvicorn Server



This is where I encountered my first small hiccup. I code on Windows (I know, sue me ?), and I wanted to use Uvicorn. As this only runs on Linux, I needed to get it to function in WSL.

I’ll not go into all the details here, but I could write something about it if anyone has an interest in it. Let me know!

After getting Uvicorn to function as it should, we can continue. It is important to remember that the Python interpreter on WSL does not share anything with its Windows counterpart. This means that you either need two separate virtual environments or that you install pip packages for each OS.

Creating Basic FastAPI App


Once all this annoying prep work is done, creating a basic FastAPI app is very easy. We first import FastAPI as below:

from fastapi import FastAPI

All you need to do afterward is define the basic app and create an endpoint.

#---APP INIT---#
app = FastAPI() @app.get("/")
async def root(): return {"message": "Hello World"}

To get this to run, you need to navigate to the working directory of your FastAPI project via WSL. Afterward, you call the Uvicorn server. The command below assumes you called your Python file main.py!

uvicorn main:app --reload

I usually run the Uvicorn server in a separate terminal instance of WSL.

That way, I can leave it on and test any changes I make immediately. Later, when I’ll be working on the client also, I can split the terminal. You can then make API calls through the client terminal window. FastAPI’s response in the server WSL window is then visible immediately.

Receiving “Hello World” from Server


If you now navigate to 127.0.0.1:8000 you should get a JSON response with the "Hello World" we returned in the endpoint above. We will change this endpoints function later, but for now, it works to prove our API is working.

For the API server, I have the following layout in mind. It might change throughout the development process. I currently foresee two endpoints that do not require the user to be logged in with a JWT token. The first will be to get that token, and the second to register a new user. Everything else will require the user to be authenticated.

I stated earlier that I would change the root’s endpoint function. Its new role is now to allow a user to request a JWT token. The token is only granted after providing a correct combination of username and password. This requires a dedicated set of both helper functions and Pydantic models to work.

I will go into this in another article, as it requires much explaining :-). It was something I am still learning myself.

Endpoint Layout


The current layout of my endpoints at a high level is the following:

#---OPEN ENDPOINTS---# #Root route to get token
@app.post("/", response_model=Token) #Route to create a new user
@app.post("/api/v1/users") #---AUTH ENDPOINTS---# #Route to get all current users and their attributes(development only)
@app.get("/api/v1/users") #Route to test if the token is valid, used while authenticating
@app.get("/api/v1/token-test") #Route to get all thoughts/messages created by a certain user
@app.get("/api/v1/thoughts/{username}") #Route to return all thoughts/messages containing the query string
@app.get("/api/v1/thoughts/{query_str}") #Route to create a new message/thought
@app.post("/api/v1/thoughts") #Route to return all info about the current user(like a user profile)
@app.get("/api/v1/me", response_model=User)

The current setup should allow for the barebones functionality of the application. At least from a server point of view. The routes above and/or their function are liable to change during development.  I do find it helps to have a visual reminder of what I am working toward. That is why I created the high-level outlay. As you might recall, I am a visual learner ?.

Database Considerations



I will dedicate the last part of this article to the database part. As we need to store both users, user credentials, and messages/tweets somewhere, a database is a must.

If you have read any of my previous articles, you will know I like Deta a lot.

Their NoSQL databases work great for development. They recently evolved into Deta Space. This change makes their ecosystem even more interesting for developers. The fact that they are free is also important for a single developer coding this app on his own time ?. Make sure to check them out!

The next article will focus on both the database code and the Pydantic models we will need to get our API to function.

As always, feel free to ask me questions or pass suggestions! And check out the GitHub repository for participation!

? GitHub: https://github.com/shandralor/PeerBrain



https://www.sickgaming.net/blog/2023/02/...ic-server/

Print this item

  (Indie Deal) FREE Drop Hunt, Tropico & NMS Deals
Posted by: xSicKxBot - 02-27-2023, 11:06 AM - Forum: Deals or Specials - No Replies

FREE Drop Hunt, Tropico & NMS Deals

Drop Hunt - Adventure Puzzle FREEbie
[freebies.indiegala.com]
Be prepared for next impossible challenge in the adventure

https://www.youtube.com/watch?v=I6ISYwy_l9M
https://www.youtube.com/watch?v=FW1SzMv0jSQ
Tropico Franchise Sale
[www.indiegala.com]
New Vorax Short
https://www.youtube.com/watch?v=ruEMPgLJ9Co
https://www.youtube.com/watch?v=t3bWhhsbeXA
[discord.gg]


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

Print this item

  PC - Akka Arrh
Posted by: xSicKxBot - 02-27-2023, 11:06 AM - Forum: New Game Releases - No Replies

Akka Arrh



A cascade of words, color, shapes and sound flows around your turret as you desperately fight off swarms of inbound attackers. If enemies penetrate your perimeter you need to zoom into close range combat and beat them back, adjusting to a completely different perspective in the blink of an eye. Welcome to Jeff Minter's Akka Arrh.

This modern take from the fine developers at Llamasoft combines the intrigue of an incredibly rare Atari arcade prototype with a unique creative vision that delivers a wave shooter that is insanely addictive. Akka Arrh drips with Minter's sense of humor, love of psychedelic color, and ability to create games that are a joy to play.

Publisher: Atari

Release Date: Feb 21, 2023




https://www.metacritic.com/game/pc/akka-arrh

Print this item

  [Oracle Blog] IoT Certification and Java Card
Posted by: xSicKxBot - 02-26-2023, 02:45 PM - Forum: Java Language, JVM, and the JRE - No Replies

IoT Certification and Java Card

I have been a little bit surprised to hear during travels and events, or even within private meetings, that security certification for IoT devices is too expensive and in a way not a strict business requirement.


https://blogs.oracle.com/java/post/iot-c...-java-card

Print this item

  [Tut] How To Extract Numbers From A String In Python?
Posted by: xSicKxBot - 02-26-2023, 02:45 PM - Forum: Python - No Replies

How To Extract Numbers From A String In Python?

5/5 – (4 votes)

The easiest way to extract numbers from a Python string s is to use the expression re.findall('\d+', s). For example, re.findall('\d+', 'hi 100 alice 18 old 42') yields the list of strings ['100', '18', '42'] that you can then convert to numbers using int() or float().

There are some tricks and alternatives, so keep reading to learn about them. ?

In particular, you’ll learn about the following methods to extract numbers from a given string in Python:

Problem Formulation



Extracting digits or numbers from a given string might come up in your coding journey quite often. For instance, you may want to extract certain numerical figures from a CSV file, or you need to separate complex digits and figures from given patterns.

Having said that, let us dive into our mission-critical question:

Problem: Given a string. How to extract numbers from the string in Python?

Example: Consider that you have been given a string and you want to extract all the numbers from the string as given in the following example:

Given is the following string:

s = 'Extract 100, 1000 and 10000 from this string'

This is your desired output:

[100, 1000, 10000]

Let us discuss the methods that we can use to extract the numbers from the given string:

Method 1: Using Regex Module



The most efficient approach to solving our problem is to leverage the power of the re module. You can easily use Regular Expressions (RegEx) to check or verify if a given string contains a specified pattern (be it a digit or a special character, or any other pattern).

Thus to solve our problem, we must import the regex module, which is already included in Python’s standard library, and then with the help of the findall() function we can extract the numbers from the given string.

Learn More: re.findall() is an easy-to-use regex function that returns a list containing all matches. To learn more about re.findall() check out our blog tutorial here.

Let us have a look at the following code to understand how we can use the regex module to solve our problem:

import re sentence = 'Extract 100 , 100.45 and 10000 from this string'
s = [float(s) for s in re.findall(r'-?\d+\.?\d*', sentence)]
print(s)

Output

[100.0, 100.45, 10000.0]

This is a Python code that uses the re module, which provides support for regular expressions in Python, to extract numerical values from a string.

Code explanation: ?

The line s = [float(s) for s in re.findall(r'-?\d+\.?\d*', sentence)] uses the re.findall() function from the re module to search the sentence string for numerical values.

Specifically, it looks for strings of characters that match the regular expression pattern r'-?\d+.?\d*'. This pattern matches an optional minus sign, followed by one or more digits, followed by an optional decimal point, followed by zero or more digits.

The re.findall() function returns a list of all the matching strings.

The list comprehension [float(s) for s in re.findall(r'-?\d+\.?\d*', sentence)] takes the list of matching strings returned by findall and converts each string to a floating-point number using the float() function. This resulting list of floating-point numbers is then assigned to the variable s.

? Recommended: Python List Comprehension

Method 2: Split and Append The Numbers To A List using split() and append()


Another workaround for our problem is to split the given string using the split() function and then extract the numbers using the built-in float() method then append the extracted numbers to the list.

Note:

  • split() is a built-in python method which is used to split a string into a list.
  • append() is a built-in method in python that adds an item to the end of a list.

Now that we have the necessary tools to solve our problem based on the above concept let us dive into the code to see how it works:

sentence = 'Extract 100 , 100.45 and 10000 from this string' s = []
for t in sentence.split(): try: s.append(float(t)) except ValueError: pass
print(s)

Output

[100.0, 100.45, 10000.0]

Method 3: Using isdigit() Function In A List Comprehension


Another approach to solving our problem is to use the isdigit() inbuilt function to extract the digits from the string and then store them in a list using a list comprehension.

The isdigit() function is used to check if a given string contains digits. Thus if it finds a character that is a digit, then it returns True. Otherwise, it returns False.

Let us have a look at the code given below to see how the above concept works:

sentence = 'Extract 100 , 100.45 and 10000 from this string'
s = [int(s) for s in str.split(sentence) if s.isdigit()]
print(s)

Output

[100, 10000]

☢ Alert! This technique is best suited to extract only positive integers. It won’t work for negative integers, floats, or hexadecimal numbers.

Method 4: Using Numbers from String Library


This is a quick hack if you want to avoid spending time typing explicit code to extract numbers from a string.

You can import a library known as nums_from_string and then use it to extract numbers from a given string. It contains several regex rules with comprehensive coverage and can be a very useful tool for NLP researchers.

Since the nums_from_string library is not a part of the standard Python library, you have to install it before use. Use the following command to install this useful library:

pip install nums_from_string

The following program demonstrates the usage of nums_from_string :

import nums_from_string sentence = 'Extract 100 , 100.45 and 10000 from this string'
print(nums_from_string.get_nums(sentence))

Output

[100.0, 100.45, 10000.0]

Conclusion


Thus from the above discussions, we found that there are numerous ways of extracting a number from a given string in python.

My personal favorite, though, would certainly be the regex module re.

You might argue that using other methods like the isdigit() and split() functions provide simpler and more readable code and faster. However, as mentioned earlier, it does not return numbers that are negative (in reference to Method 2) and also does not work for floats that have no space between them and other characters like '25.50k' (in reference to Method 2).

Furthermore, speed is kind of an irrelevant metric when it comes to log parsing. Now you see why regex is my personal favorite in this list of solutions.

If you are not very supportive of the re library, especially because you find it difficult to get a strong grip on this concept (just like me in the beginning), here’s THE TUTORIAL for you to become a regex master. ??

I hope you found this article useful and added some value to your coding journey. Please stay tuned for more interesting stuff in the future.



https://www.sickgaming.net/blog/2023/02/...in-python/

Print this item

  (Indie Deal) FREE CC2 | Prison Architect Bundle & Spider-Man Deals
Posted by: xSicKxBot - 02-26-2023, 02:45 PM - Forum: Deals or Specials - No Replies

FREE CC2 | Prison Architect Bundle & Spider-Man Deals

Control Craft 2 FREEbie
[freebies.indiegala.com]

https://www.youtube.com/watch?v=Tsf5Wjb1uAM
Prison Architect - Total Lockdown Bundle DEAL
[www.indiegala.com]
Get everything you need to run a top-notch correctional facility. Immerse yourself in the prison life with the base game, the original soundtrack + digital artbook, and all Prison Architect expansions.

https://www.youtube.com/watch?v=DMxzG-z_qDw
Ubisoft Sale, up to 80% OFF
[www.indiegala.com]

[www.indiegala.com]


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

Print this item

  PC - Like a Dragon: Ishin!
Posted by: xSicKxBot - 02-26-2023, 02:45 PM - Forum: New Game Releases - No Replies

Like a Dragon: Ishin!



In 1860s Kyo, a solemn samurai's fight for justice stands to change the course of Japan's history forever. Draw your blade and join the revolution in this heated historical adventure.

Publisher: Sega

Release Date: Feb 21, 2023




https://www.metacritic.com/game/pc/like-a-dragon-ishin!

Print this item

  [Oracle Blog] Trusted Peripherals
Posted by: xSicKxBot - 02-25-2023, 12:23 PM - Forum: Java Language, JVM, and the JRE - No Replies

Trusted Peripherals

In this blog entry we will be covering the Java Card I/O framework, and how implementers can use it to extend the platform and enable new use-cases for secure elements in IoT devices.


https://blogs.oracle.com/java/post/io-an...eripherals

Print this item

 
Latest Threads
World Cup 2026 Lemfi Jobs...
Last Post: Silky121
14 minutes ago
Is Lemfi Safe? World Cup ...
Last Post: Silky121
15 minutes ago
World Cup 2026 Lemfi Prom...
Last Post: Silky121
19 minutes ago
World Cup 2026: Is Lemfi ...
Last Post: Silky121
21 minutes ago
Lemfi Rebrand + World Cup...
Last Post: Silky121
22 minutes ago
World Cup 2026 Lemfi Foun...
Last Post: Silky121
24 minutes ago
World Cup 2026 Lemfi Redd...
Last Post: Silky121
26 minutes ago
World Cup 2026 Lemfi Code...
Last Post: Silky121
28 minutes ago
(Xbox One) Vantage - Mod ...
Last Post: levihaxk
4 hours ago
News - Christopher Nolan’...
Last Post: xSicKxBot
5 hours ago

Forum software by © MyBB Theme © iAndrew 2016