• Breaking News

    Thursday, March 7, 2019

    What are some good, short, CS books that you highly recommend? learn programming

    What are some good, short, CS books that you highly recommend? learn programming


    What are some good, short, CS books that you highly recommend?

    Posted: 07 Mar 2019 08:52 PM PST

    Nearly every book I have ever purchased during my 4 year degree for a CS has been around 900+ pages long. For some reason, my mind freaks out over big books like that, and I never end up reading them. But for every short book I have gotten, I've read it to its entirety. What are some good but short (100-300) page books that you recommend? I'm interested in C++, C#, Databases, AI, Machine Learning, programming guidelines (like how to write complex, readable, or clean code), Computer Systems, Software Development, or anything else you believe a CS major should know before graduating.

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

    Where/How to start learning C++ starting from intermediate level? (Application in robotics)

    Posted: 07 Mar 2019 05:00 PM PST

    I have seen a lot of robotics jobs in the market requiring knowledge in C++ but I do not know where to begin to be productive.

    I already have basic C programming knowledge namely functions,logic(if/else),loops,arrays but I do not know where to go from there as I have not done any projects in University that requires anything more than the basic. I have already spent some time getting used to the syntax of C++ but I am currently lost on what to do as I have no projects to work on.

    My main issue is just not having any projects to work on that requires more C++ knowledge, I get easily bored watching lectures on the syntax and coding logic without any context of application in the real-world especially in my field of interests (robotics).

    Anyone in the same position that manage to find C++ help in advancing their skills?

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

    Does this count as Plagiarism?

    Posted: 07 Mar 2019 02:55 AM PST

    So I am a third year Computer Science student, and this year I am tasked with creating a website for my university which will ultimately be implemented at the end of the semester. Having little to no web development experience in the past, I went to Google and YouTube for help (I'm assuming that I'm not alone when it comes to this). The website is turning out great (thanks for asking btw) but I'm afraid as I followed one specific, in-depth video on how to create a website, that it will technically count as plagiarism.

    I would say the skeleton of the website is sort of built around the foundation of the website that is shown in the video, however I had also added a bunch of my own things to it which required me to actually go and research certain things from websites such as W3schools and StackOverflow (Also cutting out unnecessary stuff shown in the video).

    What are some of the expert opinions on this?

    P.S. I don't think I've ever enjoyed coding this much in my degree up until this project.

    *EDIT* Also variables and such aren't matching either like its all custom to fit the clients needs. Posting this cause I'm just super sketched out as it's actually going to be a real-world thing where as up until this point I was essentially making little java programs that'll never see the light of day

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

    Location Question

    Posted: 07 Mar 2019 10:05 PM PST

    I've been working on a Java app that takes in an address from the user, which I've managed to convert to coordinates in lat/long format.

    What I'm looking to do is check if those coordinates are inside of this delivery zone, which is an odd shaped polygon overlaid upon a city. I've been not having a lot of success as the shape does not make a square that runs along the lat/long lines.

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

    [C/C++] Why am I getting a write access violation from this?

    Posted: 07 Mar 2019 09:46 PM PST

    I cannot figure out for the life of me why this throws me "Unhandled exception thrown: write access violation. dice_ptr was 0x111011F"

    Here is a portion of my code, it breaks at *(dice_ptr + (diceIndice - 1)) = rand() % 6 + 1; in the debugger:

    void reroll_dice(int *dice_ptr, int size)

    {

    int diceIndice = -1; printf("Which dice would you like to reroll?: "); scanf("%d", &diceIndice); *(dice_ptr + (diceIndice - 1)) = rand() % 6 + 1; print_dice(*dice_ptr, size); 

    }

    Specifically, in this program's instance, the array pointer and size variable are being referenced from another function, which also has those as it's parameters. But the array pointer is declared in main as die[5] = { 0 } and size is just an integer being passed. The array is also populated before this function is reached.

    Can someone tell me where I'm fucking up?

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

    Python web crawler (novice)

    Posted: 07 Mar 2019 05:41 PM PST

    I'm writing a code in python to extract part numbers from a website and trying to make it as automated as possible.

    I have been able to extract the part numbers using beautifulsoup4 when I download the html file from a search result, however I am having issues automating the download. When I try to extract the html source in the python code it extracts the page without the search results. In addition I cannot get the code to find the search box to input the search parameters.

    My goal is to import parameters from a csv file, preform a search for each parameter, extract the part numbers and print them into another cvs file to import into the database.

    Most of my background is in c++ and am trying to learn python as I work on this project. Thanks!

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

    Using the latest edition of Cracking the Coding Interview? I made a little hint lookup tool, so you don't need to keep flipping to the back of the book.

    Posted: 07 Mar 2019 07:29 AM PST

    Are you prepping for interviews using the 6th Edition of Cracking the Coding interview? The practice problems have multiple hints each, and I got tired of flipping to the back of the book. Also, I really wanted to avoid studying.

    So, I made a little hint lookup thing, so you get the right hint while working on the problem. Hope it's helpful!

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

    Why is this valid C but crashes in C++

    Posted: 07 Mar 2019 01:36 PM PST

    Answer: C99 has compound literals, C++ does not.

    http://www.keil.com/support/man/docs/armcc/armcc_chr1359124238010.htm

    Question: This is distilled from an openSUSE Tumbleweed + GCC9 bug report out of curiosity, and I wanted to understand what the problem was. I figured that part out, but I'm not familiar with this syntax, and indeed it doesn't do in C++ what it does in plain C. What is that funky declaration, and why doesn't it work in C++? (ie, gcc vs g++) In C++, the compiler warns that x is uninitialized.

    #include <stdio.h> int main() { const char **x = (const char**) ((const char*[]) { "Hello", "World"}); printf("%p\n", x); printf("%p %p\n", x[0], x[1]); printf("%s %s\n", x[0], x[1]); } 

    If I reduce the C++ code to:

    auto x = (const char*[]) { "Hello", "World"}; 

    then the compiler says "error: taking address of temporary array", so seemingly C is making a static array, and C++ is making a temporary (even according to valgrind).

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

    Guidance on some books

    Posted: 07 Mar 2019 03:11 PM PST

    Hey,

    Got two questions I would like to ask.Im currently working with Java and Python, working with as in learning it, so I am a beginner. But I would like to get a book on algorithms and wish you could guide me on which book to choose from the ones I will be linking to you. The first one is: this one, or, this one?

    Second question: Ive found a collection of 4 books, the art of programming, 4 big books, and I would like to know what theyre pretty much for. Are they still relevant, are they of any use? Im talking about this one

    edit: fixed the links...

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

    Help! (C++)

    Posted: 07 Mar 2019 11:41 PM PST

    Hello I'm currently making a program that converts minutes to the price of the call. But i want to make the user to write the time in digital form and then convert it to minutes Here is what i mean:

    Starttime:08:00 Endtime:09:30 Total minutes 90.

    So i want the program the Caluculate the total minutes

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

    Need help with converting binary to hex

    Posted: 07 Mar 2019 11:35 PM PST

    1110 0110 1010 01

    (1x 2^3) +( 1x2^2) + (1x2^1) + (0x2^0), = 14 (E)

    8 + 4 + 2 + 0

    (0x 2^3) +( 1x2^2) + (1x2^1) + (0x2^0), = 6

    0 + 4 + 2 + 0

    (1x 2^3) +( 0x2^2) + (1x2^1) + (0x2^0), = 10(A)

    8 + 0 + 2 + 0

    (0x2^1) + (1x2^0), = 1

    0 + 1

    I do not understand why the answer is 39A9. I got everything correct in the calculation and if you take the last line that equals 1 away then the answer is suddenly E6A. How does it go from E6A (What I got) to 39A9 just by adding 1?

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

    How comfortable should I be with html/css before moving on to js?

    Posted: 07 Mar 2019 11:22 PM PST

    What overall concepts(or specific tags/attributes/styles etc) should I be comfortable with? I know I cant learn it all and that learning js will supplement my learning of html/css, but I dont know when to start.

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

    How do I make my dropdown menu go over the content rather than pushing it down?

    Posted: 07 Mar 2019 11:18 PM PST

    When the page is <600px I want to be able to click the collapsed menu and have it overlay the content rather than push it down.

    https://codepen.io/bestboutmachine/pen/drMgqp

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

    A “random” number generator

    Posted: 07 Mar 2019 07:11 PM PST

    I think I want to make a number generator as my first project. If you have about 20 years worth of simple data, let's say powerball numbers for instance, Could you apply the list of historical data as probability for the newly generated numbers? Also side note is this a good first project?

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

    undefined reference C++ errors when trying to build using cmake

    Posted: 07 Mar 2019 10:48 PM PST

    I am using Ubuntu 16.04 and gcc/g++ 7.4. I am trying to build the code here: https://github.com/PfAndrey/supermariohd

    I have tried the steps listed there, but it fails when I try any of the following

    sudo cmake --build . --config Release CC=gcc-7 CXX=/usr/bin/g++-7 cmake --build . --config Release CMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=1 CC=gcc-7 CXX=/usr/bin/g++-7 cmake --build . --config Release CMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 CC=gcc-7 CXX=/usr/bin/g++-7 cmake --build . --config Release 

    The entire error is here: https://pastebin.com/amt4v5hR

    Can anyone help with this?

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

    Classification Random Forest Function in R

    Posted: 07 Mar 2019 10:32 PM PST

    i wrote this function rf.ml that takes two data frames and returns the accuracy for a random forest. The function works when dat.name is number however when i convert to dat.name to a factor i got the following error :

    Error in predicted == actual :

    comparison of these types is not implemented.

    I tested the function and i know the error is located at the model.rf line. Does anyone know how to fix it?

    rf.ml <- function (dat.name, test.name) {

    #dat.name$label <- as.factor(dat.name$label)

    # extract test set

    test.set <- test.name[,1]

    # run random forest model

    model.rf <- randomForest(formula = label ~., data = dat.name)

    # predict results

    results <- predict(model.rf, test.name[,-1])

    accuracy = percentage.correctly.classified(predicted = results, actual = test.set)

    return(accuracy)

    }

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

    Why am I starting off with java?

    Posted: 07 Mar 2019 10:28 PM PST

    I'm currently a college student at the moment and I'm in my junior year (I'm paying for my classes, so taking two classes per semester). Anyways, for the computer science degree specializing in software development I am being taught java for the intro class and I guess the secondary class (it's fundamentals of programming CS219) but for the cyber security degree area starts off with python? My question is why am I starting with Java and not JavaScript or C++, do other universities do the same, and do you think I'll be taught other languages as I progress through my degree program (the degree program sheet doesn't say what language the other classes teach or whatever)? Thanks in advanced!

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

    I want to get into programming for Python and various other languages but have literally zero experience. Where could I start?

    Posted: 07 Mar 2019 09:44 PM PST

    I'm aware that these kinds of posts pop up on this sub at times since I've been a long time lurker, I really dislike having to be one of these people again but. I recently tried getting into one of my life long dreams of practicing code and programming so that I may learn web development or video game creation (mostly vg really) but I have no clue where to start learning the basics as a High School student with zero prior know how of the subject or field. But I'd want to learn how to do it right rather than trying to teach myself everything incorrectly.

    What I'm trying to say I guess is, what resources, video essays, classes, websites, books, anything really. What could help me get started, and learn the material, and continue on to learn because I really do want to learn. But I want to learn it all the right way without tripping myself up down the line. Thank you all for your time if you happen to answer and I hope all your projects do well.

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

    Where do I put libraries I download?

    Posted: 07 Mar 2019 09:14 PM PST

    This seems like a common problem for me, but I haven't seen a lot of general resources for it. There have been multiple times where I download a library to use (eg PyQT, AVR) and I don't know where to put them. I want them usable everywhere like the standard libraries for the language but I'm not sure where to put them to do that. I have a Mac, but hopefully the answers the same for Windowss and Linux too. Sorry if this is a simple question. Thanks in advance.

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

    C- Question about mmap()

    Posted: 07 Mar 2019 04:40 PM PST

    I'm doing an assignment involving shared memory. I'm supposed to use mmap, and I'm fairly certain I've implemented it correctly. However, one of the parameters for mmap() is size_t length, and I don't really know what I'm supposed to do to calculate that.

    According to the man pages,

    The length argument specifies the length of the mapping (which must be greater than 0).

    And I get that, but I'm not really sure what kind of value I should be expecting for the value of length.

    One way I've seen is using a stat struct (the st_size which is of type off_t), and another way in the man pages is to use sysconf(_SC_PAGE_SIZE).

    I checked out the return values for the two functions, and one is very different from the other. One returns the size of the file in bytes, and the other returns the number of pages. Just not really sure which to use.

    So if anyone could shed some light on either of the functions, I'd really appreciate it.

    Thank you!

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

    I'm having a hard time converting algorithms into code��

    Posted: 07 Mar 2019 08:20 PM PST

    I'm a CS undergrad student. I'm taking a class on algorithms this semester. When the teacher explains the algorithm and solves a few problems based on it on the board, I understand it. But when I try to write code for the same algorithm, I get very confused. Even when I lookup other people's programs of the same algorithm, I have a hard time understanding them. Is there any way I can train my brain so that converting algorithms to code becomes easier?

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

    How can I get started with making larger, more worthwhile projects?

    Posted: 07 Mar 2019 08:18 PM PST

    TL;DR: I know how to program basic/basic+(?) stuff pretty well, but I have no idea how to get started on something useful

    My story starts the way I'm sure many of yours do. I was maybe 13 or so and decided to learn to code, so I picked up python. I enjoyed it a lot, but I was more focused on learning concepts and how to make structures work for me. Ex: I was big on recursion for a long time. Minimax stuff was fun to do for stuff like tic tac toe and connect 4 etc. I liked it because I really had to think about how to eat everything to work.

    This continued through maybe freshman year or so, but only because I was piloting AP Computer Science Principles, where all the programming was done through snap!. I took the test later sophomore year and it was as easy as you'd imagine it being. After that though, rigorous academics took a lot of my leisure time away and I fell out of it. Now that I'm graduated and looking at college soon, I want to start more seriously learning the ropes.

    Besides the small, for fun projects that I've done just to see how things work, I've done very little programming, and I'm hesitant to start again because I have no idea how to get into the larger works.

    How should I go about learning the skills necessary to work my way into larger projects (eg websites, games, apps)? I would love to do something like this more seriously and possibly turn it into a career for myself, but I have no idea where to go or how to start. Thanks in advance.

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

    What is the proper name for specific elements of a localization?

    Posted: 07 Mar 2019 08:10 PM PST

    So my localization files are .ini files where each key is a generic name in English, and the value is what the program should output when set to the language/locale corresponding to that localization file.

    For example, if my program wants to alert the user about not having enough disk space, it would execute alert(lang.current_locale.get_localized('ALERT_INSUFFICIENT_DISK_SPACE')), which would output either "ALERT: Not Enough Disk Space" or "ВНИМАНИЕ: Недостаточно Пространства На Диске" depending on whether current_locale is set to en_US.ini or ru_RU.ini.

    My question is... what do you actually call "ALERT_INSUFFICIENT_DISK_SPACE"? A "localization element"? A "localizable string"? A "name"? I'm sure there's some kind of standardized term for this.

    For example, one could use this term like this: "This ____ corresponds to what the program's title bar will say"; "My extension adds 5 new ____ to the localizations"; "This method should raise an error if it's passed a ____ that isn't defined in the file"; "My program shows the unformatted name of the ____ itself, as used in the code, if its localization isn't defined in the files" etc.

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

    How can I submit java code that can be executed from an email attachment?

    Posted: 07 Mar 2019 07:32 PM PST

    I've written a very basic java program that I want to use as my "creative project" for a geology class. I'd like to be able to submit it to my professor, but I don't want to ask her to download an IDE or anything. Is there a way to send her my program so it'll just automatically compile and run?

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

    Passport not working

    Posted: 07 Mar 2019 07:29 PM PST

    Hello I am a CS student and for a project I need program a Web application. Currently I having some problem because the operation req.isAuthenticated always trows false, i have been several days trying to fix it but i can't find out what is happenning. Hopefully anyone can help me out... :)

    This is my www

    #!/usr/bin/env node
    /**
    \ Module dependencies.*
    */
    var app = require('../app');
    var debug = require('debug')('balneario:server');
    var http = require('http');
    /**
    \ Get port from environment and store in Express.*
    */
    var port = normalizePort(process.env.PORT || '3000');
    app.set('port', port);
    /**
    \ Create HTTP server.*
    */
    var server = http.createServer(app);
    /**
    \ Listen on provided port, on all network interfaces.*
    */
    server.listen(port);
    server.on('error', onError);
    server.on('listening', onListening);
    /**
    \ Normalize a port into a number, string, or false.*
    */
    function normalizePort(val) {
    var port = parseInt(val, 10);
    if (isNaN(port)) {
    // named pipe
    return val;
    }
    if (port >= 0) {
    // port number
    return port;
    }
    return false;
    }
    /**
    \ Event listener for HTTP server "error" event.*
    */
    function onError(error) {
    if (error.syscall !== 'listen') {
    throw error;
    }
    var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port;
    // handle specific listen errors with friendly messages
    switch (error.code) {
    case 'EACCES':
    console.error(bind + ' requires elevated privileges');
    process.exit(1);
    break;
    case 'EADDRINUSE':
    console.error(bind + ' is already in use');
    process.exit(1);
    break;
    default:
    throw error;
    }
    }
    /**
    \ Event listener for HTTP server "listening" event.*
    */
    function onListening() {
    var addr = server.address();
    var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
    debug('Listening on ' + bind);
    }

    This is my app.js

    const express = require('express');
    const expressSession = require('express-session');
    const createError = require('http-errors');
    const path = require('path');
    const logger = require('morgan');
    const passport = require('passport');
    const flash = require('connect-flash');
    // Initializations
    const app = express();
    require('./database/database');
    require('./passport/local-auth');
    // view engine setup
    app.set('views', path.join(__dirname, 'views'));
    app.use(express.static(path.join(__dirname, 'public')));
    app.set('view engine', 'pug');
    // Terminal morgan development mode
    app.use(logger('dev'));
    app.use(express.urlencoded({ extended: false }));
    app.use(
    expressSession({
    secret: 'The-best-secret-ever',
    resave: false,
    saveUninitialized: false
    })
    );
    app.use(flash());
    app.use(passport.initialize());
    app.use(passport.session());
    app.use((req, res, next) => {
    app.locals.signUpMessage = req.flash('signupMessage');
    app.locals.signInMessage = req.flash('signinMessage');
    app.locals.user = req.user;
    next();
    });
    // Load Routes
    app.use(require('./routes'));
    // catch 404 and forward to error handler
    app.use(function(req, res, next) {
    next(createError(404));
    });
    // error handler
    app.use(function(err, req, res, next) {
    // set locals, only providing error in development
    res.locals.message = err.message;
    res.locals.error = req.app.get('env') === 'development' ? err : {};
    // render the error page
    res.status(err.status || 500);
    res.render('error');
    });
    module.exports = app;

    This is my auth-local.js

    const passport = require('passport');
    const LocalStrategy = require('passport-local').Strategy;
    const User = require('../models/user-model');
    // Serialize data to session
    passport.serializeUser((user, done) => {
    done(null, user._id);
    });
    // Deserialize to finish the session
    passport.deserializeUser(async (id, done) => {
    const user = await User.findById();
    done(null, user);
    });
    // Register a new user
    passport.use(
    'local-signup',
    new LocalStrategy(
    {
    usernameField: 'username',
    passwordField: 'password',
    passReqToCallback: true
    },
    async (req, username, password, done) => {
    // Validate that the user don't exist
    const user = await User.findOne({ username: username });
    if (user) {
    return done(null, false, req.flash('signupMessage', 'This username is taken'));
    } else {
    const newUser = new User();
    // Get values from the form
    newUser.username = username;
    newUser.password = newUser.encryptPassword(password);
    newUser.email = req.body.email;
    newUser.phone = req.body.phone;
    newUser.firstname = req.body.firstname;
    newUser.lastname = req.body.lastname;
    // The system only creates employees
    newUser.administrator = username === 'admin' ? true : false;
    // Async database writting
    await newUser.save();
    // Return the user to the session
    done(null, newUser);
    }
    }
    )
    );
    passport.use(
    'local-signin',
    new LocalStrategy(
    {
    usernameField: 'username',
    passwordField: 'password',
    passReqToCallback: true
    },
    async (req, username, password, done) => {
    const user = await User.findOne({ username: username });
    if (!user) {
    return done(null, false, req.flash('signinMessage', 'No user found'));
    }
    if (!user.validatePassword(password)) {
    return done(null, false, req.flash('signinMessage', 'Incorrect credentials'));
    }
    console.log(user);
    return done(null, user);
    }
    )
    );

    This is my serialize methods

    // Method to encrypt the password applying 10 times the hashing algorithm
    userSchema.methods.encryptPassword = password => {
    return bcrypt.hashSync(password, bcrypt.genSaltSync(10));
    };
    // Method to compare the encrypted passwords
    userSchema.methods.validatePassword = function(password) {
    return bcrypt.compareSync(password, this.password);
    };

    And this are my routes

    var express = require('express');
    var router = express.Router();
    const passport = require('passport');
    router.get('/', (req, res, next) => {
    res.render('signin');
    });
    router.post(
    '/',
    passport.authenticate('local-signin', {
    successRedirect: '/managersignin',
    failureRedirect: '/signin',
    failureFlash: true
    })
    );
    module.exports = router;

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

    No comments:

    Post a Comment