• Breaking News

    Monday, February 14, 2022

    What new C++ features are you using? Ask Programming

    What new C++ features are you using? Ask Programming


    What new C++ features are you using?

    Posted: 14 Feb 2022 08:33 AM PST

    I'm mostly interested in 2020 and 2023 features. So far I'm using Concepts, abbreviated function templates and std::span. I have some SaaS code that only has to run on one platform (was FreeBSD , but have gone back to Linux recently). So I have a lot of flexibility in that case in terms of using newer features. Thanks in advance.

    submitted by /u/Middlewarian
    [link] [comments]

    [http] What response do I send back?

    Posted: 14 Feb 2022 08:13 AM PST

    I have a signin where the user needs to check the Terms and Conditions, if it's not checked I send back a error, what response code do I send back?

    submitted by /u/Effective_Common_473
    [link] [comments]

    Some help for a design

    Posted: 14 Feb 2022 09:05 AM PST

    Hey guys I have a project where I'm making some printed graphics for programmers but know nothing about code. I've seen people say the following is laughable:

    //life motto if (sad() === true) { sad().stop() beAwesome() }

    Don't want to use anything dumb but I need some language in my graphics. Any suggestions for something similar?
    I was thinking like this in Python -

    if sad > 0: print(beawesome) else: print(beawesome)

    Sorry, don't know much but appreciate the help!

    submitted by /u/awfuckthisshit
    [link] [comments]

    What do you do when you don't want to be on a project?

    Posted: 14 Feb 2022 07:16 AM PST

    Was training for 2 months angular and spring and was excited to start but got put on a project with a language I never heard of and they have high expectations because they are so desperate for help, but don't have any documentation for people joining.

    I get an email asking if I accept this role, otherwise I will get a bad appraisal. All the training videos they want us to watch has nothing to do with what they are asking from the team.

    submitted by /u/Czekraft
    [link] [comments]

    I would like help with shortening my code in Python.

    Posted: 14 Feb 2022 10:21 AM PST

    I am working with python and I would like to know if there is a way I can just put one print statement inside the loop and then add one each time to the student/job parameters. It works correctly the way it is I would just like to find a way to minimize the amount of print lines I have.

    import random

    student_list = [confidential]

    job_list = confidential]

    for x in job_list:

    student = random.sample(student_list, 17)

    job = random.sample(job_list, 8)

    print(job[1] + ": " + student[1])

    print(job[2] + ": " + student[2])

    print(job[3] + ": " + student[3])

    print(job[4] + ": " + student[4])

    print(job[5] + ": " + student[5])

    submitted by /u/JBreezeC
    [link] [comments]

    Anyone using any 3rd party tools for task scheduling on kubernetes?

    Posted: 14 Feb 2022 10:10 AM PST

    I'm looking for some 3rd party solutions that I can integrate my services with to schedule tasks on containers on a kubernetes cluster.

    Some of the requirements I'm considering are dynamic creation and editing of the schedules on arbitrary groups of containers on my cluster performed from the services themselves. Some of them are possibly created by end-user, and as such I don't want to expose kube-api to any of the related service, so kubernetes Jobs/CronJobs are not really what I'm looking for.

    Ideally this system would have a relatively simple but robust API to manage the task schedules, as well as life-cycle management for the tasks, such as status and possibly retries.

    I have prototyped a few home-brew systems for this, but wanted to know if there are some tools people are using out there to compare to. They need not be open-source.

    submitted by /u/zlance
    [link] [comments]

    Feasibility of making a program to download my university reading lists and organise to folders?

    Posted: 13 Feb 2022 08:13 PM PST

    Hi there,

    I was wondering if it's possible to create a program to search through the online reading lists in my modules, then download the PDFs associated with them? The reading lists themselves provide links to the books and articles - I just need to sign in on an external site to download them (think JSTOR) - but it'd be less time consuming for something to download it all and then organise it in folders pertaining to each module on my computer.

    I'm sorry if this is long winded but I just wanted to know what I would need to learn in order to do something like this.

    (Out of concern for rule 6 I should probably clarify that I have legal access to all these documents, it's simply a matter of ease as I have a lot of different modules and my course is pretty text-dense)

    submitted by /u/Materialine
    [link] [comments]

    I'm struggling to learn how to access data from HTML forms.

    Posted: 14 Feb 2022 09:54 AM PST

    I'm a super beginner at programming. I'm coding a business website for my knitting projects and am currently trying to make some HTML forms useable. From many internet searches it seems like using PHP or something similar is necessary, but I still haven't been able to figure out how I can access form data. I've gone down a rabbit hole looking for answers but now I just have more questions. To use FormMail (https://www.tectite.com/fmdoc/def_alert.php) do I need a domain for my webpage? I'm not sure I want to invest actual dollars into this yet, right now it's just HTML and CSS files on my laptop. Also, is a web server necessary to access data? I'm hoping to use the "POST" method to protect user email addresses. I hope this isn't too long-winded, basically, I just want something to happen when users click submit and I want to see what they wrote in their (HTML) form. I tried making a PHP action page but it doesn't really ...do anything. I can upload any code or webpages or anything that'd be helpful-- I am new here so my apologies if I've come up short in some regard. Thank you for your time!

    submitted by /u/gabistrying
    [link] [comments]

    Help with Images in HTML

    Posted: 14 Feb 2022 09:47 AM PST

    I'll preface this with I'm really not tech savvy, so apologies if I use incorrect terminology. I have a HTML file that when opened on explorer, I have two images. One of these images I want to delete for good to anonymise the image, I'm not looking for a method that will just hide the second image and allowing it to be unhidden later.

    I've got as far as right clicking and selecting inspect on the second image and finding the layer in the HTML code the image is associated with. I just want to know what I'd need to do to delete this image layer, and secondly, is this something I can automate with a python script? Any advice would be great!

    submitted by /u/stomo022
    [link] [comments]

    How do you keep yourself awake, organized and motivated?

    Posted: 14 Feb 2022 09:31 AM PST

    Hello!

    I have been working as a Software Engineer for 2 years in Agile SCRUM and I have been studying about Software/Web Development for 4 years

    I am happy with the following - Able to work remote - Decent Money - Skillset

    However, this past month I have been struggling with my wakefulness, motivation, organization and boredom.

    I don't have the same energy, motivation and interest as when I started learning and neither when I was in my first year.

    Nowadays, things have become a routine, at 9:30 I join my Daily Stand Up, give a report about how my tickets go, if I'm having any spill overs or any problem at all and that's it.

    I either spend my time on the implementation of the ticket, up skilling: learning by myself new stuff (not from the company)

    While I have started going outside more to socialize, having my sun therapy, doing a diet and going to the gym at least 3 times per week.

    When it comes to work & learning, I am extremely sleepy, unmotivated and having 0 cares about my career.

    I have also been thinking doing a different job but that's a big NO from me.

    I want to continue my learning and I want to fix my motivation.

    Do you have any tips?

    submitted by /u/leonheartx1988
    [link] [comments]

    what's Boilerplate?

    Posted: 14 Feb 2022 09:06 AM PST

    How do you add a regex text filter to html / css?

    Posted: 14 Feb 2022 09:06 AM PST

    As in this... but applying to the html document itself and not a text box input.

    <!DOCTYPE html>

    <script>

    function clean(el){

    var textfield = document.getElementById(el); var regex = /\[a-z|A-Z|0-9|?!.,|\\<|\\>|\\/|\\s\]/gi; if(textfield.value.search(regex) > -1) { textfield.value = textfield.value.replace(regex, ""); 

    }

    }

    </script>

    <textarea id="ta" name="ta" onkeyup="clean('ta')" onkeydown="clean('ta')"></textarea>

    submitted by /u/SiegeRhino472
    [link] [comments]

    "Streaming" media in terminal emulator?

    Posted: 14 Feb 2022 03:06 AM PST

    Hey guys, not sure exactly how to word this. I want to basically achieve a similar functionality to the *nix package SoX (lets you play sound files from the command line right in your terminal emulator, ie without an external media player), only, I want to be able to play sounds from non-local files on the internet, without having to download them. I don't know if this is possible, I tried going to an audio streaming site in Lynx and it didn't work. But if it is, I would appreciate being pointed in the right direction! Ty

    submitted by /u/AzurasTsar
    [link] [comments]

    Do programmers spend a lot of time on setting up a new project folder structure?

    Posted: 14 Feb 2022 05:12 AM PST

    When you start a new project, usually you will have some logical structure. For example, you might want to put all your entities in one folder and common methods in a different folder. You will need a structure that makes managing the project easier. Do programmers spend a lot of time setting up this project structure? I do not remember reading this anywhere during my academic years. But recently I personally find that I spend time setting my project structure. Is it a common problem or is it just me?

    submitted by /u/aiai92
    [link] [comments]

    How to buy domain from “website for sale"?

    Posted: 14 Feb 2022 08:42 AM PST

    There is a specific domain that I fancy. I think it would look good for my upcoming project.

    Bad news. Somebody else already owns it. Good news. It is for sale.

    I wish to buy it. Just not familiar with process.

    Any help or advice would be appreciated.

    submitted by /u/where-were-you-hmm
    [link] [comments]

    Is Flutter ready for production?

    Posted: 14 Feb 2022 08:00 AM PST

    Hello, my company needs an app for iOS, it's something like cabify, do you think we can program in flutter?

    submitted by /u/ViggoGod
    [link] [comments]

    Randall Hyde’s The Art of Assembly Language — still a useful resource?

    Posted: 14 Feb 2022 07:56 AM PST

    I found this book at a yard sale and paid 75¢ for it (well, I paid $3 for it, a copy of Pale Fire, and a set of two cassettes of the Berliner Philharmoniker playing Holst's Planets, I don't know how that $3 actually divided among each thing), I'm not interested in programming to make video game or websites or anything like that, I want to learn assembly to do calculations in the most efficient way.

    This edition of the book was published in the late 90s, so well into the 32 bit/Pentium era, but since x86 is x86 I am hoping that it will still be applicable to my computer (which to be fair, is pretty ancient, it's a Lenovo ThinkCentre with a Core 2 Duo processor, but it works for my purposes) and in a broader sense modern 64 bit PCs.

    Yes? No?

    submitted by /u/plzforgivemyart
    [link] [comments]

    What are some non-English programming Q&A/tutorial/documentation websites?

    Posted: 14 Feb 2022 06:41 AM PST

    There's a Japanese Stack Overflow, and when researching a Git error, Bing's top result was in Japanese, on a website called Qiita. Every now and then, I'll search something and get results from numerous websites in Chinese, and Refactoring.guru is available in Spanish, French, Polish, Portuguese, Russian, Ukrainian, and Chinese. This has got me to thinking that expanding my language profile might improve my research capabilities.

    Whether it's the largest, the most useful, or just your favorite, does anyone know of some particularly good programming sites in languages other than English?

    submitted by /u/GrillOrBeGrilled
    [link] [comments]

    DNS service that resolves dashed-ip subdomain to arbitrary IP

    Posted: 14 Feb 2022 06:10 AM PST

    This is a bit of a weird one,

    Some time ago I helped a colleague to set up a Chromecast development environment - one of the challenges was to point the Chromecast device to the developer's local machine.

    We found a DNS service that would allow arbitrary dashed IPs in the subdomain and resolve them to the IP address (see example above).

    Example:

    10-8-13-128.dns-service.com resolves to 10.8.13.128 

    I need to do almost the same thing again, but, through the magic of changing jobs and incomplete documentation, we forgot what the service is called. Would greatly appreciate a pointer to a service that can do this and doesn't require setting up something locally.

    I tried searching this on Google, but everybody is just trying to explain how DNS works or offers me domain registration services.

    submitted by /u/deafmalice
    [link] [comments]

    Using only client id and client secret for token generation in FastAPI

    Posted: 14 Feb 2022 01:03 AM PST

    Hi, this is my 1st post in reddit so please forgive any mistakes . I am using fast api for oauth2 implementation, I want to use client id and Client secret to generate a token without username and password, but in fast api's OAuth2PasswordRequestForm username and password field is compulsory.

    **This is the Code**

    [from fastapi import FastAPI, Depends, HTTPException, status
    from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm

    from passlib.hash import bcrypt
    import jwt

    from tortoise import fields
    from tortoise.contrib.fastapi import register_tortoise
    from tortoise.models import Model
    from tortoise.contrib.pydantic import pydantic_model_creator

    app = FastAPI()

    # This should be more complex
    JWT_SECRET = 'JwtSecret'

    class User(Model):
    id = fields.IntField(pk=True)
    clientId = fields.CharField(200, unique=True)
    clientSecret = fields.CharField(200)

    def verifyPassword(self, clientSecret):
    return bcrypt.verify(clientSecret, self.clientSecret)

    userPydantic = pydantic_model_creator(User, name='User')
    userInPydantic = pydantic_model_creator(User, name='UserIn', exclude_readonly=True)

    oauth2_scheme = OAuth2PasswordBearer(tokenUrl='token')

    async def authenticateUser(clientId: str, clientSecret: str):
    user = await User.get(clientId=clientId)
    if not user:
    return False

    if not user.verifyPassword(clientSecret):
    return False
    return user

    @ app.post('/token') #I have kept space between @ because its getting converted u/ .
    async def generateToken(form_data: OAuth2PasswordRequestForm = Depends()):
    user = await authenticateUser(form_data.client_id, form_data.client_secret)

    if not user:
    raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail='Invalid client ID or client Secret')

    userObj = await userPydantic.from_tortoise_orm(user)
    token = jwt.encode(userObj.dict(), JWT_SECRET)
    return {'access_token': token, 'token_type': 'bearer'}

    # async def get_Current_User(token: str = Depends(oauth2_scheme)):
    # try:
    # payload = jwt.decode(token, JWT_SECRET, algorithms=\['HS256'\])
    # user = await User.get(id=payload.get('id'))
    # except:
    # raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail='Invalid Username or Password')
    # return await userPydantic.from_tortoise_orm(user)

    async def get_current_user(token: str = Depends(oauth2_scheme)):
    try:
    payload = jwt.decode(token, JWT_SECRET, algorithms=\['HS256'\])
    user = await User.get(id=payload.get('id'))
    except:
    raise HTTPException(
    status_code=status.HTTP_401_UNAUTHORIZED,
    detail='Invalid username or password'
    )
    return await userPydantic.from_tortoise_orm(user)

    @ app.get('/users/list', response_model=userPydantic)
    async def get_user(user: userPydantic = Depends(get_current_user)):
    return user

    @ app.post('/users', response_model=userPydantic)
    async def createUser(user: userInPydantic):
    user_obj = User(clientId=user.clientId, clientSecret=bcrypt.hash(user.clientSecret))
    await user_obj.save()
    return await userPydantic.from_tortoise_orm(user_obj)

    register_tortoise(
    app,
    db_url='sqlite://db.sqlite3',
    modules={'models': \['FastAPIWithJWT'\]},
    generate_schemas=True,
    add_exception_handlers=True
    )][1]

    submitted by /u/Darkangle1911
    [link] [comments]

    Project documentation tool advice/tips

    Posted: 14 Feb 2022 04:35 AM PST

    Hi all! I'm about to begin a new project at my company. The team is very small, 3 people at the moment, more will hopefully come aboard. I'm looking for a simple tool to keep the project "notes" together, the requirements, the API documentation, database structure, diagrams, etc. I prefer free, even with limitations, because the team is small and asking management for resources at this stage is unfeasible. I liked Notion but I wanted to know what you use or prefer regarding that kind of tools. Thanks in advance

    submitted by /u/zabumba
    [link] [comments]

    Is it possible to learn how to make good looking websites?

    Posted: 14 Feb 2022 02:47 AM PST

    I'm currently building a little website for myself, not a client yet. I can built the backend just fine and I feel like the layout is fine. It just doesn't look good. I think it's my colour choices, the way my fonts look etc.

    Is it possible to really learn this or is it something you're just born with? Are there any online courses or books that go through things like this?

    submitted by /u/MaiaLovesCode
    [link] [comments]

    What exactly do you send in an HTTP error message response?

    Posted: 13 Feb 2022 04:00 PM PST

    Some sites seem to produce something pretty when you 404. Postman (the program) seems to complain if I just respond with "404 Not Found\r\n" or "500 Internal Server Error\r\n"

    What exactly do I send? Is it "HTTP/1.1 404 Not Found\r\n" and "HTTP/1.1 500 Internal Server Error\r\n"

    Am I meant to send some kind of pretty body after the message?

    submitted by /u/XiPingTing
    [link] [comments]

    How can I add text filtering?

    Posted: 13 Feb 2022 11:30 AM PST

    The goal is to start with random garbage like this that is automatically imported text:

    " ></iframe>Write this in English心配しないで!"

    and filter it to :

    " 心配しないで!"

    The full story : I am trying to make automated flashcards by using the browser extension Yomichan to import data from websites like Duolingo into a program called Anki. Everything works flawlessly except the example sentence field which pulls a bunch of random text and code from around the target sentence.

    Notes :

    Usually there is a lot more garbage, this is a fairly simple example.

    I would think a regex filter would be perfect since I only want to keep Japanese and not English.

    I hardly know anything about coding but I would be able to figure out the regex parameters if I knew how to IMPLEMENT it to Yomichan or Anki.

    submitted by /u/SiegeRhino472
    [link] [comments]

    Can you help me make this generic?

    Posted: 13 Feb 2022 06:29 PM PST

    I'm trying to figure out the best way to make this controller generic enough for me to reuse along many types.

    The controller has some logic that exists in application start, it also registeres itself to the Static controller. From there the static controller handles all the logic, I pass in many ID's and the controller creates objects that are initialized through a external API.

    `Champions` in this case I can't see how I can swap out with T, any ideas?

    public class ChampionController : ExistsInApp { [SerializeField] Champions entitys; public void Awake() { StaticChampionController.championController = this; } public async Task SetAll(uint[] championsID) { for (int i = 0; i < championsID.Length; i++) { await Set(championsID[i]); } } public async Task Set(uint n) => await entitys.Set(n); public Champions GetAll() => entitys; public Champion GetByID(uint n) => entitys.GetByID(n); } public static class StaticChampionController { public static ChampionController championController; public async static void SetAll(uint[] championsID) => await championController.SetAll(championsID); public async static void Set(uint n) => await championController.Set(n); public static Champions GetAll() => championController.GetAll(); public static Champion GetByID(uint n) => championController.GetByID(n); } 
    submitted by /u/Effective_Common_473
    [link] [comments]

    No comments:

    Post a Comment