• Breaking News

    Sunday, March 3, 2019

    I just wrote a blackjack game code in C++ for the first time... learn programming

    I just wrote a blackjack game code in C++ for the first time... learn programming


    I just wrote a blackjack game code in C++ for the first time...

    Posted: 02 Mar 2019 02:05 PM PST

    For starters I am older than 25 and I had no prior coding or formal computer engineering education prior to last year. I was embarrassingly bad at coding at the beginning of last year. Like, I could barely get past the compiling stage of a "Hello World!" program type of bad. However, I took some computer engineering courses during the course of 2018 (along with a full load of courses) at my university and assembly was highly emphasized towards the very end with Verilog being emphasized in the beginning. Well, here I am today with my first piece of code that goes to about 200 lines and it actually does something cool. It feels good man. If you have a hard time teaching yourself then I recommend attending a community college or university level program. There is something about being coerced into doing something that will make you better. Just thought I'd share because I have been lurking for a while. Cheers!

    EDIT: Here we go. Actually much longer than 200 after I spruced it up a bit. Be nice! Don't be stealin my code for your own school assignment!

    https://pastebin.com/5ei6HM3D

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

    Do you need to learn data structures before learning algorithms?

    Posted: 02 Mar 2019 01:09 AM PST

    Not sure if I can begin grinding CLRS until I learn about data structures. I'm currently in an introductory elementary programming class.

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

    I just made a very simple URL shortener

    Posted: 02 Mar 2019 05:10 PM PST

    Hello everyone.

    I am a junior developer and I have created an online URL shortener, free, ad-free and with absolutly no tracking.

    It is available here : https://www.lessn.io/ You can fork the project here : https://github.com/MaxandreOgeret/lessn

    ​ I an using Symfony 4.0 and is very exemple of MVC programming.

    Please, tell me what you think and if you have any questions !

    Thanks !

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

    Why do people use very shortened variable names? Do they expect others will understand?

    Posted: 02 Mar 2019 01:12 PM PST

    I've recently started reading others' code and had difficulties understanding what those variables are for.

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

    Help with practicing multithreading in Python and C

    Posted: 02 Mar 2019 02:28 PM PST

    Hello, are there any sites or resources that provide multithreading practice? For example, a sample serial program with the challenge to parallelize it. Would prefer to have resources that focus on C or python.

    Sorry if my post sucks, first time posting.

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

    Automating my job

    Posted: 02 Mar 2019 11:29 PM PST

    I work at a hotel as the night auditor where I have to print out a bunch of reports from the hotel's online system called OPERA. Then I have to take the numbers from the reports that I print out and plug them into an excel sheet. I have always wanted to find out a way to print all the reports that I need for that specific day at the push of one single button. I have no idea how to do this, I assume it is quite complicated if it is even possible. Does anyone know how this could be done? Btw I am a noob at programming but I would love to find out how to automate this to make my job easier and less time consuming.

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

    What is the purpose of reading "design patterns" books?

    Posted: 02 Mar 2019 06:18 AM PST

    Edit: The motive of this post is to ask about "design patterns" concept rather than books specifically.

    I have just finished college and join a tech company as an intern. I have seen a few people here reading books on design patterns mainly Head First Design Patterns. Throughout the college I never heard about these books or the concept of design patterns (the most commonly used terms were data structures, algorithms, database, machine learning) but they seem to be very popular. I want to know what purpose they serve in industrial importance or for personal learning or anything else, if and when to read them etc.?

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

    My website keeps trying to access a folder that has been deleted even tho the html doesn't specify that folder

    Posted: 02 Mar 2019 09:14 PM PST

    i have an <a href="../index.html" ... to redirect from one page to the home page, but it keeps 404'ing and in the url it shows its trying to reach /directory/index.html even tho ive deleted the directory folder, moved its components to public folder in cpanel and also changed the markup to account for this change? any idea why its still trying to reach directory folder even tho its no longer specified in the markup?

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

    Are nano degrees worth it?

    Posted: 02 Mar 2019 07:54 AM PST

    I already have a BSc in an unrelated subject and I've been looking at some of the Udacity and Treehouse Nano degree's.

    I'm pretty sure i could complete them i'm just wondering if it is the best option or to just sub to something like Treehouse/Pluralsight.

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

    How to learn about APIs?

    Posted: 02 Mar 2019 06:27 AM PST

    Hello friends. I have been learning programming for the last year and a half and I can already say that I am comfortable with PHP as a beginner, MVC, OOP, PDO, they are concepts that I already understand, at least at a basic level. I have also taken my first steps in Laravel building a complete CRUD application. I have received some job offers and they always include "REST API" as requirements. What do you recommend me to learn about this topic?

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

    Doubt in Django Python.

    Posted: 02 Mar 2019 09:33 PM PST

    Why do i get two forms instead of one?

    header.html-

    <!DOCTYPE html>

    <html lang="en">

    <head>

    <title>Harrison Kinsley</title> <meta charset="utf-8" /> {% load staticfiles %} <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}" type = "text/css"/> 

    </head>

    <body class="body" style="background-color:#f6f6f6">

    <div> 

    <form action="/success/" method="post">

    {% csrf_token %}

    {{ form }}

    <input type="submit" value="Submit" />

    </form>

    </form>

    </div> 

    </body>

    </html>

    views.py-

    from django.shortcuts import render,redirect

    from .forms import ConfessionForm

    from django.views import generic

    from django.views.generic.edit import CreateView

    from .models import Post

    from confessions.forms import ConfessionForm

    from django.views.generic.edit import FormView

    from django.contrib import messages

    # Create your views here.

    class postConfessions(CreateView):

    template_name = 'confessions/header.html'

    form_class = ConfessionForm

    success_url = '/confessions/'

    context={'form':ConfessionForm}

    # def get(self, request):

    # form=ConfessionForm()

    # return render(request,self.template_name,context)

    def form_valid(self,form):

    form.save()

    messages.success(self.request, "Confession Added")

    return render(self.request, 'confessions/header.html', self.get_context_data())

    return redirect(sucess_url)

    forms.py-

    from django import forms

    from confessions.models import Post

    class ConfessionForm(forms.ModelForm):

    confession=forms.CharField(widget=forms.Textarea)

    class Meta:

    model=Post

    fields=('text',)

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

    Is Udemy any good?

    Posted: 02 Mar 2019 06:41 PM PST

    I'm looking at: The complete web developer course 2.0, The Web Developer Bootcamp, Modern React with Redux, and iOS 12 and Swift.

    Also Ethical hacking but for my own interest and not necessarily for my professional career.

    I'm obviously not going to do them all at the same time or quickly, but they are all ten dollars each right now and I don't want to miss this deal.

    I was wondering if any of these were any good or if anyone had any other suggestions?

    I do have some experience with web development and programming but I feel like I need to go back to the beginning and polish my skills.

    Any additional information would be really helpful and appreciated.

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

    C/C++ graphics in codeblocks

    Posted: 03 Mar 2019 12:34 AM PST

    Hello, a beginner in C programming here. Im used to python where theres a module for almost everything so Im having a hard time figuring out how to use the graphics package in C/C++. I've tried to follow a lot of youtube instructions on how to do it but still, the graphics.h header is not working in codeblocks. The only thing I know will work is to do graphics programming in Turbo C but I dont really like it as an editor since it looks archaeic plus its not as user friendly as codeblocks. What are my options?

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

    Allowing Pull Requests?

    Posted: 02 Mar 2019 11:30 AM PST

    I have invited a collaborator on a private GitHub repository & I see that automatically, they have push access. How can I make it so that the only way the code is pushed is through a gate, i.e. this pull request?

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

    Made a mini-game in Python! Some code review please

    Posted: 03 Mar 2019 12:29 AM PST

    Hello, I've only been learning programming for less than two months and I just made a small blackjack game in Python! When I get better at programming, I will probably expand this project into some sort of app that contains multiple card games.

    I'd like some feedback on the readability, cleanliness, and structuring of my code. Any other feedback is welcome, of course.

    https://github.com/pepsighost/small-projects/blob/master/kates_casino

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

    Python Network Programming - TCP/IP Socket Programming

    Posted: 03 Mar 2019 12:05 AM PST

    I have created a video series of 23 videos which goes on to build a networking tool which using socket programming in Python.

    YouTube Channel - Python Network Programming - TCP/IP Socket Programming

    I have also added a couple of other video series like Web Scraping, creating GUI.

    Feel free to check them out.

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

    How to make a Linux program that runs a command?

    Posted: 02 Mar 2019 08:01 PM PST

    For example, in the linux terminal typing in: ./myprogramname <an actual command name> <arguments 1,2,3,etc.>

    ./myprogram wc file1 file2 file3 Executes as

    wc file1

    wc is executed (20 50 60 for example)

    wc file2

    wc is executed(30 50 60 for example)

    wc file3

    wc is executed (50 60 30 for example)

    How do I make the wc command actually work in my ./myprogram when it's always the first argument in the terminal? Assuming I use fork() and exec()

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

    [C++] How to throw an exception for cin input greater then 2 values

    Posted: 02 Mar 2019 11:46 AM PST

    Hello everyone. So I'm working on a project and would like to know how to throw an exception for cin when the input is more then 2 values. I want the user to input a birthday in the format (MM/DD/YYYY) and if the user inputs an incorrect type or inputs more numbers then the above format, I want an exception to be thrown.

    I read on stackoverflow that you can use the setw() to limit the number of values inputted, but I'm not sure how to set up a condition using an if statement for that. I've included all of my code in the link below: https://codeshare.io/5NQVJm

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

    Basic ATM Interface using C#

    Posted: 02 Mar 2019 11:26 PM PST

    I picked up programming again after a few year hiatus. Been enjoying it and just completed my first super basic project and got it up onto a GitHub page even. I wrote a program in C# that would accept a hard coded ID number and PIN to login. If the user incorrectly logged in more than 3 times it would timeout the user for 5 seconds. Once logged in then they could deposit, withdraw, or exit. Eventually I'm thinking about adding a GUI but for now this is enough.

    I started more reading and looking into things and wanted a few tips/pointers.

    The code design was mostly what I was asking about because I would like to keep it well organized. What are good practices for keeping everything nice looking and readable? I know readability is one of the most important for what makes code 'good'. What kind of things would you suggest to me? What would you change about this? Perfect practice makes perfect.

    Here is the GitHUB for my project. https://github.com/Djohnson4224/ATM-Interface

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

    Good place to learn JS prototype and js methods

    Posted: 02 Mar 2019 11:14 PM PST

    Anyone have a good resource for learning and practicing protoype as well as JS methods like map, filter, spread, reduce, etc.

    Can be a tutorial videos, exercises, online courses etc. just whatever you have found to be really good.

    Thanks

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

    Data is not showing/updating in the SQLite table when the data is inserted through my C# code

    Posted: 02 Mar 2019 08:49 AM PST

    Currently, I have been doing some simple coding related to SQL and C#. I have created this a registration form which will store the data, username and password, in an SQLite database. This is the code that I am currently using:

    private void AddLoginInfo(string username, string password) { auth = new Authentication(); auth.getConnection(); using (SQLiteConnection con = new SQLiteConnection(auth.connectionstring)) { SQLiteCommand cmd = new SQLiteCommand(); con.Open(); string que = @"INSERT INTO LoginInfo(Username, Password) VALUES (@username, @password)"; cmd.CommandText = que; cmd.Connection = con; cmd.Parameters.Add(new SQLiteParameter("@Username", username)); cmd.Parameters.Add(new SQLiteParameter("@Password", password)); cmd.ExecuteNonQuery(); MessageBox.Show("Account Created!"); } } 

    This code currently works and does add to the correct table in the database however whenever a new user is added. The user information can be used to login but it does not show within the table, which is viewed using DB Browser for SQLite.

    For example, if I create a new user; 'admin' as the username and 'password' as the password, through the form, I get the message box saying 'Account Created' and I can use that very account to login. However, if I go view that very data in the DB browser the data doesn't show even after refreshing the table.

    After doing some digging, I found this and saw that they were using sqlCommand.Parameters.AddWithValue so I tried this within my code:

    SQLiteCommand cmd = new SQLiteCommand(@"INSERT INTO LoginInfo(Username, Password) VALUES (@username, @password)", con); cmd.Parameters.AddWithValue(new SQLiteParameter("@Username", txtBoxUsername.Text)); 

    I tried this and I got a CS7036 error. Then I realised that they had not used the new SQLiteParameter() part and so I removed it cmd.Parameters.AddWithValue("@Username", txtBoxUsername.Text); and tried again but it still wouldn't update in the table but the data could still be used to log in.

    I have also found a similar post but no one had answered it.

    Now I don't know what to do, so I am asking for your help.

    I also asked on Stack Overflow.

    EDIT: I figured out what was the problem; I was checking the database that was stored in the solution but what I should have checked is the database stored in the ...\bin\debug folder. The database within the folder shows the added data.

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

    Resources for a Beginner?

    Posted: 02 Mar 2019 11:02 PM PST

    I landed a job as a software developer, but I am actually a mechanical engineer by trade. I have been learning a lot on the job, but I am looking for some good resources to expedite my learning. I am really excited by this job, and I am really enjoying software development. Hopefully one day I am good at it. Some info. I am doing web development. Our team is small, so I am hoping to develop a skill set that lets be become a full stack developer. Some technologies we are using. Angular, SQL Server, and most of our work is done in C#. Thanks in advance it is appreciated!

    edit: I got excited I found the sub and just posted this, but now that i look at the sidebar it seems this is covered. I am still willing to take any pointers/perspectives/information you might be willing to give!

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

    Can someone explain why this splice outputs what it outputs?

    Posted: 02 Mar 2019 10:48 PM PST

    import numpy as np k= np.array([[2, 4, 8, 16], [16.0, 8.0, 4.0, 2.0]]) print k[1,2:-1]/k[-2,-2] 

    The output is [.5] but i don't understand why. Can someone walk me through this?

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

    Help editing or creating a Python function for cryptanalysis?

    Posted: 02 Mar 2019 10:45 PM PST

    I am currently taking a cryptological mathematics course. Most of the work we do is by hand but we're allowed to create programs/functions to assist us if we want. I am trying to create a function for an affine cipher that takes the input from a frequency analysis of the english language (p1, p2) and a frequency analysis of the cipher text (C1, C2) and the alphabet lenght (AL) and it calculates the multiplicative and additive keys needed to decipher the cipher text. Here are two pictures from the textbook explaining the math behind calculating the multiplicative and additive keys from a cipher text but my implementation of this math in Python isn't working. Here is my code:

    def ModInverse(a, m):

    if gcd(a, m) != 1:

    raise ValueError('The input arguments, {} and {}, are not coprime.'.format(a, m))

    # Calculate using the Extended Euclidean Algorithm:

    u1, u2, u3 = 1, 0, a

    v1, v2, v3 = 0, 1, m

    while v3 != 0:

    q = u3 // v3

    v1, v2, v3, u1, u2, u3 = (u1 - q * v1), (u2 - q * v2), (u3 - q * v3), v1, v2, v3

    return u1 % m

    def decryption_keys_affine(p1, p2, C1, C2, AL):

    s = p2 - p1

    p3 = s * p1

    p4 = (p3 % AL)

    p5 = C1 - p4

    p6 = AL + p5

    p7 = ModInverse(s, AL)

    p8 = p7 * p6

    r = p8 % AL

    multi = ModInverse(p7, AL)

    add = AL - r

    print(multi, add)

    I do not understand why this doesn't work. If I am to input decryption_keys_affine(3, 20, 19, 20, 42) then the output should be 17, 16 but it's 17, 34 instead.

    I am also trying to apply it to this practice cipher text problem:

    X0N30NL8Q98G4N1T0G8I4M83QNR8WR8D .8WR8IQNLXWRYLQR,8WR1W4R498X08I4M84PPQWRL0182XW0Z8QZ8LX08R0I82NGPLQ4R4TGLW28KRWL,8SW 9

    I know the multiplicative key should be 41 and the additive should be 30 but my function never outputs that no matter what combinations of letters I use from the frequency analysis of english and the cipher text.

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

    How do I use the Python Re library to return a capture group in the form of a singular list.

    Posted: 02 Mar 2019 10:36 PM PST

    I recently learned the re library to assist me with a personal project to extract dates from an ocr'd image in an automated fashion, however, I have been unable to get the information in a reusable format(ie: a string that can be used an an input). Here is a barebones version of my code.

    path='home/desktop/fake.jpg' processed_image=pytesseract.image_to_string(path) compiled_regex=(r'(([0-9]|[0-9])+:[0-9][0-9])+ \w\w') matches=compiled_regex.finditer(processed_image) for match in matches: match_storage=(match) date_match_group= match_storage.group(0) Print(date_match_group) 

    That piece of code returns the match object as a usable string. It literally reads:

    • 10:00PM
    • 8:00PM
    • 6:00PM
    • 10:00PM

    Which is what I want, however I cannot do anything with that information, because for some reason the data is in a list of tuples. if I write print(date_match_group[0])

    I am simply breaking up the match grouping and get some fragmented pieces of data such as:

    • 1
    • 8
    • 6
    • 1

    I want to be able to manipulate the whole grouping so I can enter an index number and get an item ie: print(time[0]) >>> 10:00PM

    I looked into the problem and it appears that I need to unzip the list of tuples into multiple lists, but that confused me even more and gave me a TypeError, and in an another instance returned just match objects. There has to be something else that I am doing wrong.

    I know I am doing something wrong but I am not sure what. I would appreciate it if someone pointed me in the right direction! I used a combination of documentation and YouTube videos to figure things out.

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

    No comments:

    Post a Comment