• Breaking News

    Friday, July 24, 2020

    Does any language have syntax for X is equal to EITHER Y or Z ? Ask Programming

    Does any language have syntax for X is equal to EITHER Y or Z ? Ask Programming


    Does any language have syntax for X is equal to EITHER Y or Z ?

    Posted: 24 Jul 2020 12:27 PM PDT

    Any time I write:

    (ThisLongWindedObjectName == x or ThisLongWindedObjectName == y) 

    I really wish I could write something like :

    ThisLongwindedObectName =| [x,y] 

    Which would return true if the variable is equal to any of the things. Note I am not comparing the object to the boolean returned by x or y, but I am comparing the thing to list a of other things. Is there any common syntax that handles this, or is there any languages that have this shorthand??

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

    Help with decorator design pattern

    Posted: 24 Jul 2020 03:38 PM PDT

    Hello everyone I am working on an assignment that uses the decorator problem and I am getting an error and i've tried everything I can to get rid of it.

    I have a class called ice cream that looks like

    public abstract class IceCream { public IceCream(String d) { description = d; } public String getDescription() { return description; } abstract public double cost(); abstract public int calories(); abstract public String toString(); } 

    I am now attempting to create the decorator class and so far I have

    public abstract class toppingsDecorator extends IceCream { public abstract String getDescription(); public abstract IceCream(String d){ return d;} } 

    However when I go to compile all of my toppings compile fine except for the toppingsDecorator class and it tell me that

    error: invalid method declaration; return type required public abstract IceCream(String d){return d;} ^ 

    Can anyone please let me know what it is I'm doing wrong. I feel like im so close at this point I just cannot seem to make this part work

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

    What are programming techniques

    Posted: 24 Jul 2020 11:41 PM PDT

    Hello,

    I got following task from a teacher (I don't need help for it):

    Write an calculator using Java swing OR JavaFX, it should allow for whole terms, variables and builtin functions like sine or cosine..... (Translation mine, some parts left out)

    Please use programming techniques, we hadn't used in the lessons yet. But what are programming techniques, I never heard it before

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

    Can someone explain Decision vs Optimization Problems?

    Posted: 24 Jul 2020 11:41 PM PDT

    can't understand what geeksforgeeks is talking about.

    https://www.geeksforgeeks.org/np-completeness-set-1/

    "NP-completeness applies to the realm of decision problems. It was set up this way because it's easier to compare the difficulty of decision problems than that of optimization problems. In reality, though, being able to solve a decision problem in polynomial time will often permit us to solve the corresponding optimization problem in polynomial time (using a polynomial number of calls to the decision problem). So, discussing the difficulty of decision problems is often really equivalent to discussing the difficulty of optimization problems."

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

    C Code loop works sometimes, infinite loops other times

    Posted: 24 Jul 2020 05:32 PM PDT

    Having a really weird issue with a C code lab. It works but keeps breaking.... I have a while loop that asks for the char 'y'. If I enter my data quickly then it will prompt for y. If i take my time with my data inputs it gets wild. It either crashes, starts an infinite loop, or says i said y already... I dont really understand why its being so weird.

    Weird outputs: https://imgur.com/a/l9trQKv

    Code:

    #include <stdio.h>

    #include <math.h>

    /* Define our account structure */

    struct account {

    int invoice_number;

    char company[50];

    int date;

    float balance;

    };

    char answer;

    /* Define the variables that use the account structure type */

    struct account ledger;

    int main(void)

    {

    answer = 'y';

    while (answer == 'y') {

    struct account ledger;

    FILE *newacct;

    newacct = fopen("robco.txt", "a+");

    printf("Enter Company Name and Invoice Number: ");

    scanf("%s %d", &ledger.company, &ledger.invoice_number);

    printf("Enter Date and Total Balance: ");

    scanf("%s %f", &ledger.date, &ledger.balance);

    fprintf(newacct,"%s %d %d %f\n", ledger.company, ledger.invoice_number, ledger.date, ledger.balance);

    fclose(newacct);

    printf("\nWould you like to create another input? Y or N\n\n"); //Start loop again

    scanf("%s", &answer);

    }

    return 0;

    }

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

    Java 2D scrolling confusion

    Posted: 24 Jul 2020 11:16 PM PDT

    I'm playing around with java to make a simple 2d side tile side scroller. I'm trying to get my map to scroll with the player and have come across this code

     int offsetX = screenWidth / 2 - Math.round(player.getX()) - TILE_SIZE; offsetX = Math.min(offsetX, 0); offsetX = Math.max(offsetX, screenWidth - mapWidth); 

    Now doesn't that mean that offsetX is being assigned new values one after the other? I don't get why you would call the min and max methods to assign the value to offsetX, surely then when offsetX is used next it will only be the max value that is used. Or am I completely missing something here?

    The full code was from this post

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

    Any recommended way to learn React? (Book? Online course? Youtube?) And is there a preferred IDE for it?

    Posted: 24 Jul 2020 11:05 PM PDT

    I want to broaden my JavaScript skills to become more employable. I've only ever used vanilla JS. Any advice to get better would be awesome!

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

    Is it common/possible for a server to block traffic from AWS IP addresses, similar to how there are known ranges for VPNs and proxies that facilitate blocking traffic from those sources?

    Posted: 24 Jul 2020 07:03 PM PDT

    How much of what you do at work can be shared outside of work?

    Posted: 24 Jul 2020 11:42 AM PDT

    Sorry the title is not better, and I hope this is ok to ask here. I'm a novice developer but have recently started developing some things for my company. Since the projects I work on live outside of the company's larger tech ecosystem, logins, servers, etc. are all separate they don't have anyone I can go to for coding questions.

    I know that the extent of what you do at work, and how much can be shared outside of that will vary...but is this something you all do when you run into walls in some way? Do you just share code/problems/etc. that are someway non-specific to your company?

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

    I am a backend ruby dev for a website with 3 years of experience and I don't have basic theoretic knowledge about programming

    Posted: 24 Jul 2020 11:47 AM PDT

    Hey everyone, I got invited to this job just because my boss noticed that I wrote a very basic script to simplify my previous job in a call center.

    He basically just gave me 3 months to learn ruby and vue-js and I did by simply brute forcing a project without reading almost anything. I whipped up an incredibly simple website that my boss deemed good enough proof that I know basic stuff.

    So I've been working on the main website for almost 3 years now and I know the ins and outs of its database, backend AND frontend. I can do almost any task given enough time, but here's the problem:

    I have so little theoretic knowledge that I wouldn't pass an interview to a junior position, no fucking way. I have no idea what a relational database means, or what the fuck OOP means, or almost any of the other terms programmers casually throw around.

    I feel so fucking stupid, like I really don't deserve my job. 99% of the people here know a lot more than me in just about everything related to programming. I don't have ANY education in programming or anything close and I feel incompetent when I read stuff like this: http://www.yacoset.com/Home/signs-that-you-re-a-bad-programmer, I basically don't even understand most of the symptoms listed on that page.

    Is that a problem you can relate with? Is it possible to be a decent programmer without even knowing the basics? What do I do to fix this?

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

    Trying to deploy python/flask website to heroku , gets Application Error.

    Posted: 24 Jul 2020 02:13 PM PDT

    Hello , that's all , I created a simple project using python and flask. I did everything in the video, but I get this error when I am trying to view the project.

    This is what heroku logs --tail showed me

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

    FREE Udemy C Programming Course - Sign of Gratitude! ♥

    Posted: 24 Jul 2020 02:30 PM PDT

    Hey there!

    About a month ago, some amazing users from this subreddit helped me out by reviewing my NEW online C Programming Course, so I decided, as a Sign of Gratitude to Give you all on this community my course totally for FREE!

    TL;DR: Click here to claim the course for free

    ----------------------------------------------------------------------

    Why I'm giving you this course for FREE?

    1. It doesn't hurt my sales.
    2. Your Review & Feedback has made me a better instructor! :)

    [About the Course]

    After more than a year of Practicing & Perfecting - I'm glad to announce that it has been released.

    There are a lot of good feedbacks and review from beginners to experts on the course. It covers the Fundamentals of Programming using C Language such as:

    1. General Programming Concepts.
    2. Input & Output.
    3. How variables work.
    4. Conditions & Control Flow.
    5. Different types of Loops.
    6. Functions.
    7. Arrays.
    8. Pointers.
    9. Strings.
    10. Recursions.
    11. INTERVIEW QUESTIONS SECTION! :)
    12. And maybe some additional sections.

    * I've added FREE PREVIEW LESSONS - so you may also check them out :)

    That's a great time to invest in yourself and learn something new!

    ***

    Get the course:

    Claim the course for free!

    ***

    Pay attention: This FREE Coupon expires in 3 days. Feel free to enroll & share it with friends and family!

    ***Moderators - A lot of people on this subreddit will be more than happy to get some VALUABLE information and skills, for totally FREE, during these days while they're staying at home.

    YOU CAN REMOVE THIS POST ONCE THE FREE COUPON EXPIRES - SO YOU CAN BE SURE I'M NOT DOING ANY PROMOTION! :)

    Thanks so much for your support. I am looking forward to releasing more content. If you have any questions about the course, please shoot them here and I'll be happy to respond!

    Stay Home & Stay Safe!

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

    Is it no longer possible to get someone else's Instagram posts using the Basic Display API? (Interview task)

    Posted: 24 Jul 2020 11:51 AM PDT

    I've been given a coding challenge as part of a job interview. I need to make an iOS app that shows the last ten Instagram posts from a user of my choosing. I've learned that Instagram's API changed last month, and from what I've researched so far it looks like it's now only possible to get posts of which that user has permission to, meaning you can't just pull anyone's Instagram's posts anymore. Can anyone confirm if this is true or not?

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

    Should I start a blog as a junior developer?

    Posted: 24 Jul 2020 03:55 PM PDT

    I have been coding for a few years now, but as a professional I have been coding since about a year. I learnt c++, java, object oriented programming in college and data structures and algorithms too, so I have a decent grasp of time/space complexity.

    i mean to say, if i find a piece of code written in a object based programming language like python/ruby, cpp etc, i can find my way around it.

    i was hired as a backend dev at a Rails startup and I have learnt ruby/rails while going through the app which has been in production more than 10 years now, so there's a lot of code to learn from.

    i learn something new almost everyday and i learn it till i can explain it in the easiest possible way. i want to start a blog which would detail my progress.

    i feel that its too "amateurish", that it would actually make a recruiter think negatively of me since i am writing a whole blog post for a very basic concept. a basic concept that has probably been covered a million times. basically, i am afraid someone would judge me for what i write and my opinions.

    should i even start a blog?

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

    Trying to Follow Tutorial on Python-Google Sheets Integration

    Posted: 24 Jul 2020 03:44 PM PDT

    Hey all! I was following this simple tutorial, but run into an issue at the point where I actually try to access the spreadsheet by running the provided spreadsheet.py

    This is the output I'm getting:

    Traceback (most recent call last):

    File "spreadsheet.py", line 12, in <module>

    sheet = client.open("Kuhinjski Aparati").sheet1

    File "/home/snailien/PythonExperiments/test_one_venv/lib/python3.7/site-packages/gspread/client.py", line 119, in open

    self.list_spreadsheet_files(title),

    File "/home/snailien/PythonExperiments/test_one_venv/lib/python3.7/site-packages/gspread/client.py", line 95, in list_spreadsheet_files

    res = self.request('get', url, params=params).json()

    File "/home/snailien/PythonExperiments/test_one_venv/lib/python3.7/site-packages/gspread/client.py", line 73, in request

    raise APIError(response)

    gspread.exceptions.APIError: {'errors': [{'domain': 'global', 'reason': 'insufficientPermissions', 'message': 'Insufficient Permission: Request had insufficient authentication scopes.'}], 'code': 403, 'message': 'Insufficient Permission: Request had insufficient authentication scopes.'}

    Anybody knows what I'm doing wrong? I double checked and am sure I have shared edit privileges for the sheet to the email provided in the .json file.

    Thanks in advance!

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

    Starting with Python. Help!

    Posted: 24 Jul 2020 02:56 PM PDT

    I wanted to learn Python and iam wondering where i can possibly start.

    I got my hands on "HandsonPython" (pdf) but i really dont like the style the author is using so i searched a bit more.
    I found the Python Tutorial on Python.org and the Tutorial on w3schools.
    Moreover I've found "LearnPython3thehardway" (book).

    I feel like the Online Tutorials are pretty short and skip some important information but i cant afford the book right now (yeah i know its "cheap" but iam currently unemployed until 1st september).

    I dont want to wait till september to start, so if you have any suggestions for tutorials I would be very grateful.

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

    C++ question with if statement

    Posted: 24 Jul 2020 11:04 AM PDT

    Hey everyone,

    I am trying to understand the code below. Can somebody please explain what is going on here and why the if statement is behaving like a loop? The output is HiHiHiHiHiHi and I don't understand why.

    Anything helps as I'm a beginner. Thanks!

    #include <iostream> using namespace std; int X = 5; int main() { cout << "Hi"; if(X --> 0) main(); return 0; } 
    submitted by /u/EmeraRose
    [link] [comments]

    Some questions about how compilation works under the hood on different architectures?

    Posted: 24 Jul 2020 10:43 AM PDT

    I may write misunderstood facts below but it is how I think of it now, please correct me in case I understand it wrong

    I know that high-level languages like c/c++ are translated into assembly language of the compiler that was used and then compiler translates assembly code into the machine one that is processor-dependent. Different architectures require their own instructions (because it is not guaranteed different vendors or even versions of architectures have the same instruction sets). Some architectures require a single instruction to make operation X and some require multiple instructions to execute the same operation X (Roughly speaking).

    Do gcc or clang know which machine code or codes need to execute operation X on any possible processor (I mean we can compile the same program on PC having AMD Ryzen 2600 or Intel Core i7 or i5 and I think they all require different instructions, at least AMD and Intel do require different ones)?

    Does compiler even turn a c/c++ code into its own assembly language or it translates it directly into machine code?

    There is a thing called "cross-compilation", does it mean we can compile AMD-understandable machine code on Intel?

    Why c/c++ libraries (popular ones) often have a precompiled format? Doesn't it depend on architecture of PC where they gonna be used too? Why there are always no such precompiled binaries for Linux?

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

    What are some Useful/Practical Projects to Build Programming Skills (Relative Beginner)?

    Posted: 24 Jul 2020 02:19 PM PDT

    Hello Everyone!

    Title says most of it. I'm just starting out in programming and I've just completed a Python bootcamp course which kicked my ass, so I'm taking some intro classes/watching videos to review.

    I have some specific very large projects I eventually want to be able to work on, but for now I want to try building smaller projects that I can actually do something with. Currently I'm thinking mostly in the realm of automation.

    1) What types of projects have you built to help you out in daily/work life?

    2) What are things other than web-scraping and automation that could be useful for everyday things that people may not immediately think of as something that they could create a script/program to do?

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

    I'm having trouble choosing between what field of work to invest in this early on

    Posted: 24 Jul 2020 01:50 PM PDT

    Is 20 too late to start?

    Posted: 24 Jul 2020 01:48 PM PDT

    I'm a 20-years-old Turkish student. In my country, the university entrance exam is very competitive (2,5 million participants). As a result, I had to try 3 times to get an outstanding score (%0.0014 percentile). With my current score, I can study at one of the best universities both for medicine and computer science. Even though I don't have a strong programming background, I know very well what needs to be done. I'm quite smart and passionate.

    The problem is even though my passion is computer science (more precisely data science), I'm worrying if it is too late to start studying Computer Science at university. Because, as I may see, computer science go in young blood favor. I want to be one of the best in my area -data science- if I'm going to start from this way. If it is not possible or a chance in a million, I won't take that risk and get into a medical school which I'm less interested in but is a guaranteed job.

    I need your advice, please help. I'm so confused at the moment

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

    C++ question with structure

    Posted: 24 Jul 2020 01:42 PM PDT

    Hi everyone!

    I've been trying to understand this code but I'm struggling.

    How is the output 34? Can someone also explain what is going on with s.c.a and s.c.b?

    I am a beginner. Thank you!

    #include <iostream> using namespace std; struct S{ int a; char b; struct { float a; int b; } c; }; int main (int argc, const char *argv[]) { S s = {1, 2, 3, 4}; cout << s.c.a << s.c.b; } 
    submitted by /u/EmeraRose
    [link] [comments]

    Data structures challenges

    Posted: 24 Jul 2020 07:19 AM PDT

    I'm still a beginner at coding , I want some good coding challenges (using data structures) to improve my coding skill

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

    IOS Dropdown behavior hybrid app

    Posted: 24 Jul 2020 12:19 PM PDT

    so i have this hybrid app in cordova with angular using bootstrap, and the select behave correctly in android, but in ios there is a blinking cursor with blue color

    https://streamable.com/gkmwmz

    i have tried everything but it always happen, even some things like:

    .selector {
    text-shadow: 0 0 0 gray;
    color: transparent !important;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -o-user-select: none;
    user-select: none;
    }

    .selector:focus {
    outline: none;
    }

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

    No comments:

    Post a Comment