• Breaking News

    Sunday, April 22, 2018

    Gladiator Fight Lab in C++ - Actual fight function seems to do nothing? Ask Programming

    Gladiator Fight Lab in C++ - Actual fight function seems to do nothing? Ask Programming


    Gladiator Fight Lab in C++ - Actual fight function seems to do nothing?

    Posted: 22 Apr 2018 04:09 PM PDT

    Huge thanks to /u/BeigeAlert1 for the help! :D

    Repo with the file

    I'm working on a lab where you use structs to make gladiators and then make them fight each other until one gladiator wins. I seem to have everything set up for the fight but when I run the program and get to the 'fight', it outputs "Fight Timeline" and then a system("pause"), meaning it skips over all of the takeTurn function calls and outcomes. Where did I mess up? I can't put my finger on it.

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

    Web developers, how do you usually respond when people tell you how much more lucrative other programming fields like video game development and app development and other fields are?

    Posted: 22 Apr 2018 03:54 PM PDT

    Java, How to establish a ring of server/client connections.

    Posted: 22 Apr 2018 09:35 PM PDT

    I know messages between clients can be done with one server and multiple clients connected to it.

    But how would it be done if we want them communicating in a ring. I believe it takes "n" server sockets to wait on one connection. But this implementation makes me confused because the server is waiting for a client, but the same server will then be a client to another server. How would the server and client code be divided up into files in this case?

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

    How to know what datatype comes next in a text file with C

    Posted: 22 Apr 2018 02:56 PM PDT

    So I have this text file that goes like this: Army 7234 Navy 5200 Marine 6500 Air Force 8765 Merchant Marine 345 Coast Guard 676

    This is supposed to go into a struct array with a char array[16] in order to store the service and an unsigned int in order to store the number of recruits. So naively I did this.

    void main(void) { struct recruiting recruitRegister[SIZE]; FILE* filePointer; int i = 0;

    filePointer = fopen("Recruiting.txt", "r"); while (!feof(filePointer)) { fscanf(filePointer, "%s", &recruitRegister[i].service); fscanf(filePointer, "%d", &recruitRegister[i].recruits); i++; } function1(recruitRegister, SIZE); return; 

    }

    So of course this works for the services that have only one word like the Army but with the Air Force it just reads in Air into the string and then looks for an int and everything gets messed up.

    How can I check whether what's next is a string or int so I know what to fill in, or any other approach that will make this work?

    Thanks!

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

    Building an IOT Garage door opener/closer

    Posted: 22 Apr 2018 08:39 PM PDT

    I want to build an internet-connected garage door opener / closer using a raspberry PI. I will also build an Android app to control it. Conceptually this is simple, but I want to be sure that I'm considering security the "right way".

    I'm brainstorming architecture right now and was thinking about just SSHing into the webserver (raspberry pi) and just have that run commands (open / close) based on my external commands to it. I once did a project where i simply wrote to a local file on the webserver via SCP and it had an internal process that polled the file to see if it contained any commands. That worked but was ugly.

    I'm an embedded guy and don't have a lot of experience with web stuff and would really appreciate high-level pointers especially this early in the project about the "right way" to do this.

    What would be a good architecture that would also consider security? Obviously I wouldn't hard-code a password or something into my android app, right? HELP

    Thanks guise!

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

    Need help with Intel Assembly language x86 program to print a 9x9 sudoku board/grid

    Posted: 22 Apr 2018 08:22 PM PDT

    So I need an assembly x86 Intel program to make a sudoku grid (just needs to be a 9x9 grid with random numbers in each box). I have asked this question on chegg and have gotten a code but it doesn't run on emu8086 nor dosbox. I found another code in some website and same issue. I also found a c file, then converted it to intel asm from some converting website and same issue. I think either the codes are wrong or im running it wrong? please help me fix the codes or figure out my issues. Im going mental trying to figure this out. Im using windows 10 btw


    Code Verison 1: chegg; https://pastebin.com/Wkp1m7zR Error codes on line 19,23,23 (19) mismatched: data Ends (23) wrong parameters: MOV ax,data (23) probably no zero prefix for hex; or no 'h' suffix; or wrong addressing; or undefined var: data

    Code Version 2: chegg: https://pastebin.com/UcApF676 Errors on lines 37,45,45 (37) mismatched: data Ends (45) wrong parameters: MOV ax,data (45) probably no zero prefix for hex; or no 'h' suffix; or wrong addressing; or undefined var: data

    Code version 3: some site: http://www.kernel-panic.it/software/sudokiller/sudokiller.asm.html

    Error on line 250. (250) duplicate declaration of: .RETURN


    HOW I RUN PROGRAMS

    Where everything is on my PC: So idk if im running asm correctly but heres how my C drive looks like: in my c drive, i have emu8086 folder, TASM folder(i directly save my .asm files here and run them via "tasm filename" in DOSBox). My DOSBox is located in my D drive: D:\Program Files (x86)\DOSBox-0.74

    Please help me figure out whats going on

    submitted by /u/MRK-01
    [link] [comments]

    Easiest way to create a GUI in c++

    Posted: 22 Apr 2018 05:57 AM PDT

    Hi, I code in c++ and I have tried Gtk+ and Gtkmm but I have to change a lot my code. I would like to implement a basic GUI changing as little as possible of my original code

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

    Declarative statements in Verilog

    Posted: 22 Apr 2018 04:01 PM PDT

    For some reason, I can't figure out the syntax to write out simple declarative statements for boolean logic in Verilog. How would we, for example, write an always block for something like (A ^ B ^ C) v (~B ^ ~D)?

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

    Is there a way to use codes in conjunction with Google Maps Satellite images, to, for example, show me the addresses of every baseball field near me?

    Posted: 22 Apr 2018 08:57 AM PDT

    I'm just wondering if something like this would be possible.

    Where the code would automatically highlight certain things like baseball fields, strictly based on the visual images (since all baseball fields look similar I'm guessing we would tell the computer to just look for that specific shape and pattern of the grass/sand/chalk-lines/etc that make up a baseball field).

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

    What is the most straightforward way to pull data from a database to a website?

    Posted: 22 Apr 2018 06:17 PM PDT

    Thought this would be a simple question but my Google searches have turned up nothing helpful, probably poor wording. I know at the most basic is creating a table in HTML and populating it manually, but what would be one step up from that? What language(s) would I use to save a spreadsheet as a separate file and then access it with HTML?

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

    VB.NET - Set a Form BackgroundImage to a TextBox URL

    Posted: 22 Apr 2018 12:01 PM PDT

    So, I am trying to some code so that when you hit a "Change Form Background" a TextBox and a Submit button pops up. I know that, but I do NOT know how to make it when you enter a direct image URL in the TextBox, it changes the form's background image to the direct image URL. I have tried one thing because I have not found any posts like this. The code is: Me.BackgroundImage = (textbox name, ex: TextBox1).Text and that gives me the error: Value of type 'String' cannot be converted to 'Image'. I understand what this error means but I do not know how to solve it.

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

    How to develop on Windows?

    Posted: 22 Apr 2018 11:52 AM PDT

    Hey all,

    Since I've been programming I've worked exclusively on my laptop which runs Linux. Recently I've been wanting to develop on my desktop instead which is more comfortable to use, however, it runs on Windows. I've dual-booted it in the past, however, at this point I just want to develop in the Windows environment, however, I just had some questions about the best way to do so.

    When I program in Linux I write all of my programs in vim, and am able to quickly run them from the command line using ./example_program.py <example_input>. I think that this is a very simple and effective way to develop, however, I know that Windows lacks a command line, so how do I run the programs I develop?

    In place of vim I'm trying to use Pycharm, however, I'm still unsure of how to make a single file using it. In vim you can make a simple Python file for a one-off program. However, Pycharm works in projects and will create many extra files to accommodate a small Python file when I only need the one file. As best practice, is it better to create a new project for each of these small programs, or should I make one project in a parent directory and make multiple small programs as part of that?

    Any other tips or tricks for developing in Windows are appreciated, as I'm just getting started and would prefer to start off with good habits!

    submitted by /u/BRAF-V600E
    [link] [comments]

    1 For my C++ Data structures class my Professor wants us to implement insertBack, insertAt, deleteBack and deleteAt

    Posted: 22 Apr 2018 01:45 PM PDT

    The files are located here: https://github.com/PaulConradSBVC/CS265_SP2018/tree/master/SingleLinkedList

    In the Snode.h file he has this code:

    SNode<T> *next ; // Pointer to the next node public: SNode(T); SNode<T> * getNextNode();

    I'm very confused here. I know SNode(T) is the constructor. But what are SNode<T> *next and SNode<T> * getNextNode()

    why does it need to be SNode<T> *next and not just T *next? I don't get that what kind of data is that? And why does it need the class name?

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

    Best way to approach complex system with a lot of dependent variables?

    Posted: 22 Apr 2018 01:31 PM PDT

    Like the title says. I have a project that involves a lot of dependent variables. I haven't started yet, I'm still in the how the heck do I approach this phase.

    I've done some similar work before but nothing of this scale, everything I can come up with is too rigid and would affect the simulation.

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

    Working as a programmer as a high school dropout. Am I deluding myself?

    Posted: 22 Apr 2018 11:12 AM PDT

    As in the title. I am twenty and I left high school when I got a 1-year contract as a penetration tester. Since the contract expired, I have not been able to find a job - just extremely low-paying freelance gigs. Since I feel that sites such as Freelancer.com are a developer's hell - you need to compete with a number of developers, some of whom are from third-world countries, and some even accept one-digit hourly fees - I am searching for a better option. Problem: everyone is requiring a degree, even for managing Wordpress installs... this frustrates me a lot. I have been studying programming for six years, I know a number of languages and frameworks - from web languages down to cold x86 assembly, even on bare-metal, passing through C and Python - I am a proficient Linux user, I know how to assess the security of web/desktop software and a couple of other things. I am clearly no Dennis Ritchie, but I feel like I may be skilled enough to land a junior position somewhere. It's not like I am sending CV to the NASA...

    So the question is, am I deluding myself? Won't I be able to find a job? Should I return to school and spend two years on school subjects instead of investing my time into software development? Even then, without a degree, wouldn't it be hard anyway to land a job?

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

    Compare CSV with .txt files

    Posted: 22 Apr 2018 07:16 AM PDT

    I can use either powershell or python 3.6. I have a list of csv with thousands of router names and and IP addresses. I need to compare the data of the csv with corresponding txt files i have(the txt files are thousands of programming coding each txt file are programmed differently). I need to see the IP addresses in the csv is found or not found on the corresponding text files and produce results like pass/fail.

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

    AIY voice kit question

    Posted: 22 Apr 2018 09:35 AM PDT

    Which raspberry pis work with it? I got a voice kit without a Pi and target sells one with a Pi Zero WH, and I want to get a Pi 3 for myself.

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

    "Computer Systems: A Programmer’s Perspective" book for experienced programmers?

    Posted: 22 Apr 2018 10:19 AM PDT

    A few weeks ago I was asking about reading material on high performance C++ coding and I was recommended "Computer Systems: A Programmer's Perspective by Bryant et al.". I've a BS degree and a few years experience of using C++ professionally.

    I've perused the TOC of this book and while the topics are very interesting, they're all covered in detail in BS degree. Is it still worth it to read this book for an "experienced" programmer? The reason I am asking is that I've a lot of reading material on my plate these days and this book is more than a thousand pages long.

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

    Automate calendar event creation for scheduling?

    Posted: 22 Apr 2018 06:04 AM PDT

    So I have a dilemma, actually two: 1) My work schedule is not currently syncable (is that a word?) 2) I do not have a lot of experience programming. I am looking for help making a script or program that can grab my currently known schedule from my work calendars' site using my login information 1x a day, whether it being directly from the site or reading the information from a printed PDF copy of the calendar site's home page. Is this possible, and can someone help me?

    submitted by /u/Registered-Redditer
    [link] [comments]

    Is making a collapsible cell in a table possible? Details inside (PHP and HTML)

    Posted: 22 Apr 2018 09:44 AM PDT

    I'm a student and still learning about programming and making a system for our project.

    This is my table . My problem is I wanna try make the 3rd column (of each name) turn into a single cell. So instead of appearing 5 times, each name(student) will only occupy one row, and then just a clickable item or something on the third column.

    So the table will look like something like this.

    Name1 ||test || +Collapsible item here that will expand and list the 5 items

    The items are files uploaded per user. Here is my database . And my code

    Thank you so much. Sorry for my grammar :(

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

    Need help with syntax design for a specific text file. Writing and parsing questions.

    Posted: 22 Apr 2018 05:22 AM PDT

    I'm build a page based on GitHub pages and as usually there will be code snippets. The problem is that both Pygments and Rogue do not work well with C++. They get confused on complex syntax and do not recognize new keywords. And since the website is going to be also about new stuff, I need my own syntax coloring tool.

    Both Pygments and Rogue work by transating Markdown to HTML giving tons of <span class="keyword">for</span> etc. Since writing an own tool to correctly syntax-highlight C++ would be close to writing an own compiler, I dediced to make a text + text => text converter. It would be feed 2 files: code + color specification and output generated HTML.

    Here is an example (not real code, just variety of things for the example):

    template <EqualityComparable... Args> constexpr decltype(auto) build(Args&&... args); // constrained C++20 function template { if constexpr (sizeof...(args) == 0) throw std::logic_error(std::string("error in file: ") + __FILE__ + "on line: " + __LINE__); return std::tuple(std::forward<Args>(args)...); } 

    And here is how the syntax highlight specification would look like for it:

    keyword <concept... tparam> keyword keyword(keyword) func(tparam&&... param); @@comm_single { keyword keyword (keyword...(param) == num) keyword namespace::class(namespace::class(string) @"+"op_ol@ macro_ref @"+"op_ol@ string @"+"op_ol@ macro_ref); keyword namespace::class(namespace::func<tparam>(param)...); } 

    The first line of generated HTML would be:

    <span class="keyword">template</span> <span class="op">&lt;</span><span class="concept">EqualityComparable</span><span class="op">...</span> <span class="tparam">Args</span><span class="op">&gt;</span> <span class="keyword">constexpr</span> 

    How it works:

    • the parser splits code into word tokens and replaces each token with a proper HTML based on the used name in color text file
    • some names in the color file will have fixed unique behaviour: string,char and num - first catches any double quoted sequence of characters, second any single quoted sequence of characters and third any sequence of digits
    • few symbols will be reserved for color file: @ and $ as they are not (yet) used in C++ and can be used for special color file commands

    The problems

    1. The color file should match line-by-line with code file. It makes writing such file quite easy on a splitted screen and allows me to very easily catch any errors. You can see in the example that both code and color file have the very same layout of elements.

    2. Sometimes I want to have a full-line color. Currently what I have come up with (using reserved symbols) is writing @@comm_single which means it will color with 1-line comment color untill the end of line. However, what would be a good syntax for multi-line color spans? - make @ a single line comment and @@ multi-line comment begin/end?

    3. Sometimes I need to color operators too. Because the parser uses operators to split text into tokens, I will need to escape them - the current idea is to quote escapted sequences - however, this brings another problem if the code contains #include <thread> and I want to color both # and include:

    • I can not write "#"hash preprocessor <file> because in the code there is no space between # and include
    • I can not write "#"hashpreprocessor <file> because it will parse # to give <span class="hashpreprocessor"> and not color include

    Currenly the solution I have come up with is @"#"hash@preprocessor where @ delimits the token and allow me to place next name without using space (that does not exist in the code). Is this a good solution?

    Alternative solution: "#"hash$preprocessor <file> where $ delimits the tokens. Does not require space and allows me to stick with perfect match of white characters.

    4.

    For the code file:

    decltype(auto) 

    Such color file would be incorrect:

    keyword( keyword) 

    because there is no space after (. Is this a good decision to throw errors on such thing? Shoud I allow spaces in the color file and ignore white character differences?

    1. Any other suggestions? Note: there is no IDE with copy-with-syntax-highlighting that would recognize new syntax and keywords.

    2. Any more appropriate subreddit? I have check /r/pldesign and syntax/parsing related subreddits but they are mostly dead

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

    Arguments against hiding state, using encapsulation, etc?

    Posted: 22 Apr 2018 12:00 AM PDT

    Something that came to mind was the idea of encapsulation, of hiding the state of some code from other pieces.

    It started to not make much sense to me, except for hiding it from external programs. Internally, there doesn't seem to be any point, if the program is coded decently. Want to alter a structure or set of data? Use a function or something that can do the job safely, etc.

    What are the best arguments against the idea of encapsulation and state-hiding?

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

    Does an 'async' web/service framework exist?

    Posted: 21 Apr 2018 10:37 PM PDT

    During my career, I've had a few instances where I've been part of projects ripping apart a monolithic prototype/proof-of-concept that got successful.

    The pattern is usually this:

    • Either a project in a company or young entrepreneur writes a simple web app or REST service whatever in your basic 3-tier structure. Why? Because it's easy to write something that way. It's easy to iterate on a single repo code base. It's easy to debug because it all runs as a single process so you just his F5 (or whatever) and start dropping break points.

    • The thing is useful and wildly successful so it grows

    • It hits a size where either the team needed to support it is so large that working off a single application/code base is unwieldy or scale requires massive refactoring. Or both

    • Pieces get carved off into services and maintained on their own. Big things like: profiles, messaging, ordering etc

    The best example I can think of is Facebook. Zuckerberg wrote it as a college kid in PHP and years later the FB mega-corp is wrestling with that legacy. Inventing crazy but cool things like PHP-to-C cross compilers to help scale it.

    Now this makes sense. A single person writing something as a trial balloon isn't going to make some premature SOA architecture for scale that may never come when it's more important to make sure the functionality is useful. This is why microservices is a current hotness, try to break the services up sooner rather than later and think about decoupling early.

    Anyways like I said, I've done a few of these refactor projects where we work to decouple some big piece of functionality from one of these monoliths. One of the biggest challenges is that so much work is done in the HTTP request scope and there are lots of assumptions tied to that. So large fundamental changes have to be made to accommodate a new work flow such as throwing image uploads on to a queue to be processed asynchronously. No one starts with message buses, event streams or queues out the gate because it's a lot more work to provision all that infrastructure which you might not need.

    This is because when the simple prototype is made it's done with a well-known web framework where everything is about responding to HTTP requests. Is there a framework out there that will allow for simple async message/event management? For example, I could easily create POST /order endpoint and have it return 200 after some validation but then write the rest of the order flow outside of the HTTP request scope but in the same application (to take advantage of the single repo, simple debugging etc). This would allow one to iterate quickly and develop those prototypes at the same speed but make the system flow more decoupled and less tied to HTTP requests for easier scaling (if needed) later.

    Does this framework exist? Anyone seen something like it?

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

    No comments:

    Post a Comment