• Breaking News

    Sunday, April 5, 2020

    I'm writing code slower than 2 years ago Ask Programming

    I'm writing code slower than 2 years ago Ask Programming


    I'm writing code slower than 2 years ago

    Posted: 05 Apr 2020 11:02 AM PDT

    Hello r/AskProgramming.

    I'm writing code for more than 7 years now and started doing that professionally 3 years ago. I have experience with mostly Java, JS, C#, PHP. Within these languages I have a common problem. I'm writing code slower than before.

    What I'm doing different is I'm trying to create functions that can be used more than one place, trying to write cleaner code and do everything properly. My code is definitely higher quality than before and more useful in the long run but it takes so long to finish a project. Even the smallest bit of code is taking a lot of time and consideration.

    Did I get so obsessive with clean code or is it the new normal now? What are your opinions about this?

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

    How to Send Emails Using Python | Beginner friendly Tutorial (2020 tutorial) Link in comments

    Posted: 05 Apr 2020 08:28 PM PDT

    Do you feel the weight of your clipboard?

    Posted: 05 Apr 2020 09:30 PM PDT

    Title.

    Whenever I am working, and I copy (especially when I cut) a snippet of code, I get this 'trigger finger' sensation where I feel like whatever is in that temporary storage is critical and if I copy something else without thinking about it, I'll lose that logic to the depths of oblivion.

    Anyone else feel this ever? When?

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

    New Quiestion

    Posted: 05 Apr 2020 08:07 PM PDT

    By what metric and measure do you all see the development/developer landscape changing within the near and post future and do you think these positions (practices) will improve or disprove the lives of the developers which are contributing to many lines of daily code improvements? Would this be a good thing? I am new developer and Im not reall sure and am worried im not really sure about how these positions will affect my work cycle or what if not they will do to me and do you think there are any new technologies/tech stacks that I should/ will be learning to improve upon my current skillset or technology wheelhouse I am not sure about what to do here thank you for anything or any statements you will make on this thanks.

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

    I'm trying to learn about checking units.

    Posted: 05 Apr 2020 03:41 PM PDT

    I want to be able to check the consistency of units applied to equations. I know the go-to answer is dimensional analysis, but such dimensional analysis does not differentiate between dimensionless units.

    For example, there are the Becquerel and the Hertz, which are dimensionless units of random events and regular events, respectively. There are also Radians and Steradians, which are dimensionless units of angles and solid angles, respectively. According to dimensional analysis, these all have the dimensional product of 1.

    My problem is I don't even know what to google to learn how to solve this problem. I sort of presume learning about type systems would be the way to go, but I'm still too naive to be self-directing in my own education. Any tips and direction would be helpful. I'm intentionally remaining language agnostic about my ask because I'm not trying to solve this in the domain of just a single language.

    EDIT: Yes, I know Hertz is 1/s, the SI equivalent of s-1, but it's still considered dimensionless because SI considers all measure of cycles to be dimensionless. Google it. The question isn't about the specific examples given, but about checking consistency across dimensionless units.

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

    I’m New to To Coding

    Posted: 05 Apr 2020 06:52 PM PDT

    Hey There! I am completely New to coding and development. I was just wondering if anyone could let me know the best beginners coding language and a few starter projects to start with. Thanks!

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

    Looking for an algorithm/mathematical equation for a specific problem

    Posted: 05 Apr 2020 02:20 PM PDT

    Hello. I'm making a game that features a 2D world that is being infinitely generated by perlin noise. I calculate the y value based on the x and z coordinates in the perlin noise.

    Now what I want to find is an algorithm or an equation that sort of makes a random looking list of zeros and ones. It's hard to imagine, so I made this:

    http://imgur.com/gallery/OEKiFIl

    This is just randomly placed 0 and 1, but I want to have an algorithm that looks random, but when I for example take x=7 and y=5 I want it to always be the same value (either 0 and 1). It would also be good, if the alghorithm provides sort of a "choice" if I want more zeros or more ones.

    English isn't my primary language, so I cant really explain my needs too much, but I still hope someone can link me to a youtube video or to a wiki article etc.

    This alghorithm would serve me for tree placements that look random, but when the player returns to the same position, I still want the trees to be in the exact position (right now trees are placed randomly, but the problem is when the player returns to an already visited location, the trees are again randomly placed and not in the same position as before).

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

    What language is easiest to record system audio?

    Posted: 05 Apr 2020 06:00 PM PDT

    I was going to start writing something in Node/Electron to capture system audio (i.e., anything playing out of my speakers) for a personal project, but I don't think Node reveals an API to access that kind of thing, so I might need to learn a new language - any recommendations? Preferably something with a library that I can plug into because I'm mostly concerned with getting a POC running.

    My overall requirements are pretty simple, record audio off of my sound card and send the file to an API. I have experience with a few languages, but I'm mostly a JS dev, so I'm open to whatever you guys suggest. This will need to run on Mac and Windows. Thank you!

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

    Max sum Function call on binary search tree unresponsive

    Posted: 05 Apr 2020 04:58 PM PDT

    Hello, I can't seem to get my function to work, it's 100% correct cause it works on leetcode, but when i try a local IDE, i get like fragmentation errors on visual studio and simply nothing returned when i call the maxPathSum function. (btw my function is in a solution class, but i dont think that should be too much of a problem)

    int main()

    {

    Solution s; TreeNode\* root = new TreeNode(5); root->left = new TreeNode(10); root->right = new TreeNode(2); cout << root->val; int i = s.maxPathSum(root); cout << i << endl; [//s.pathSum](//s.pathSum)(root, 5); return 0; 

    }

    int maxPathSum(TreeNode* root) {

     res = INT\_MIN; maxPathSum1(root, 0); cout << "test"; return res; } 

    int maxPathSum1(TreeNode\* root, int rSum) { if (root == NULL) return 0; int topSum = maxPathSum1(root, rSum + root->val); int leftSum = maxPathSum1(root->left, topSum); int rightSum = maxPathSum1(root->right, topSum); res = max(res, max(max(root->val, root->val + leftSum + rightSum), max(topSum + leftSum, topSum + rightSum))); return max(root->val, max(root->val + leftSum, root->val + rightSum)); } 
    submitted by /u/billly369
    [link] [comments]

    [R] Using dnorm() Function

    Posted: 05 Apr 2020 04:25 PM PDT

    This problem might be more statistical-theory oriented than programming, but it isn't a very complex course so I assume anyone who knows R will understand the conceptual part of this problem.

    First, I generated a vector of 10,000 samples from the standard Normal distribution using rnorm. I did this with rnorm(10000).

    Now, I have to use this vector along with dnorm() in order to show that the value in the vector with the highest density (under the standard Normal distribution) is the one that is closest to zero.

    My professor hinted that I might need to use indexing for this, but I have no idea what to do. So far, I just have dnorm(normal) and it gives me a vector of 10000 values in the distribution (normal = rnorm(10000) from before).

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

    Developing a CRUD system, stuck with dynamic form elements.

    Posted: 05 Apr 2020 10:32 AM PDT

    Developing a CRUD system, stuck with dynamic elements. Not even sure what to search to find what I'm looking for.

    Any guidance would be much appreciated

    As shown in UI design (in link below) I can add clients and everything on the client page however I now need to add rooms within those clients which then has its own form for the room measurements. I've done everything up till the add rooms part as I don't know how to go about Adding rooms and keeping those added rooms listed under the respective clients.

    Using MySql and the Add Client feature is achieved through PDO method

    For a more visual take, take this for example:

    CLICK CLIENT NAME > TAKES TO CLIENT DETAILS > ADD ROOMS FOR CLIENTS HOUSE

    Ive achieved the first two steps, however on the client details page i need to dynamically add rooms which also has its own form for the rooms measurements and details.

    I can make the CRUD for the rooms however I dont understand how to make those rooms stay linked with the current Client

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

    Okay, so simply said

    - I CAN add clients to a database and display them on a clients page

    - I NEED to ADD ROOMS in those clients and have the rooms display on their client page

    CURRENTLY a Database exists for client information.

    To store new rooms I could simply have a column in the clients database for Rooms right?

    But then those rooms also need their own form and database as they will store the rooms details

    Im stuck with the entire concept of how to add rooms to the client database while also having another database with information FOR those added rooms

    https://drive.google.com/open?id=1caa3QEzdzh0E8d-AqsKPyeNO2s2nWsSD

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

    Question about Grokking the Object Oriented Design course

    Posted: 05 Apr 2020 02:12 PM PDT

    I'm preparing for an OOD interview and have been reviewing the grokking guide to study for an interview. The guide gives a lot of example "design this system" questions. However, related objects never seem to have any explicit relation in their designs, and I was wondering if anyone here could provide some insight as to why. These are the Product and ProductReview classes from their "how to design Amazon" guide:

    public class ProductReview { private int rating; private String review; private Member reviewer; } public class Product { private String productID; private String name; private String description; private double price; private ProductCategory category; private int availableItemCount; private Account seller; public int getAvailableCount(); public boolean updatePrice(double newPrice); } 

    I would have expected the Product class to have a list of product reviews inside of its class definition, but it doesn't. There is no other class in the design that has a list of ProductReviews either. I see this pattern constantly in this course, where the association between two objects is just... neglected? Is this how I should design classes in an interview? Am I just supposed to assume this association will exist in the database layer only? Or does my thinking about OOD have some serious flaws? Any help is appreciated, thanks.

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

    Chasing My Next Project.... Any Tips or Guidelines?

    Posted: 05 Apr 2020 01:51 PM PDT

    Hi people!

    I am a dumbass who is trying to learn more tech-related topics.

    I am looking for some guidance for creating a new project.

    My background is sort anything to do with javascript (React, Express, Node.js and I know the basics of SQL)

    I am looking for any fun project to do that would sort of taking under 3 weeks to complete with like 10-15h work each week.

    Basically I wanna create a "native app" for IOS and android with a backend and some realtime notification system. Also, I want to have a good authorization system.

    Topics and Tech that I want to sort of cover with my project:

    • React Native/Ionic Framework
    • Real-Time
    • Good Authorization for example Role-Based or possibly have like a JSON policy attached to a Role/User
    • Cheap hosting (for example by using serverless)
    • NoSQL (preference)
    • Golang (preference)
    • Serverless (preference)

    Preference means that if it does not fit the project or they are hindering/worsening the project I can switch them out for something more appropriate.

    Based on the topics and tech I want to cover the best idea that I found was sort of a ticketing system for different teams where users in different teams can have different roles.

    So the things that I am most concerned about is Real-Time, Authorization, What backend tech to use. If you guys have any tips or recommendation I would really appreciate it!

    Maybe you guys have a better idea of how to create the stack?

    Otherwise, I am also open to any new project ideas that could be really fun which fits the Topics and Tech that I want to cover.

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

    How to reset CSS keyframe animation?

    Posted: 05 Apr 2020 01:47 PM PDT

    Im currently trying to write some code to have CSS keyframe animations animate some text.

    When I've reached the right div, the css animation slides in from the left, and when ive left the div it slides back out.

    That's all fine, but what I can't figure out is how to revert the animation so that it will occur again. It seems to play once correctly, but then stops working.

    Can someone advise on how to revert to the initial state?

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

    Thinking of buying some books to improve on algorithms and how to write proper code. Is this bundle worth it?

    Posted: 05 Apr 2020 12:57 PM PDT

    https://www.humblebundle.com/books/software-development-oreilly-books?hmb_source=navbar&hmb_medium=product_tile&hmb_campaign=tile_index_3

    I have seen it pop up earlier today and i was wondering if the books in this bundle are a good basis.

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

    nodeJS/Express TypeError "passport.authenticate is not a function"

    Posted: 05 Apr 2020 10:51 AM PDT

    Hello I have been stuck on various issues while following a guide on how to setup a shopping cart in nodeJS/Express/MongoDb. The guide is a few years old , and I have been trying to find help in the comments with no luck. My issue is that when trying to start the server , I get an error saying : TypeError : passport.authenticate is not a function.

    it is refering to my index.js file which looks like this :

    var express = require('express');var router = express.Router();var Product = require('D:/Other/Projects/Code/Powershell/shopping-cart/models/product');var csrf = require('csurf');var passport = require('D:/Other/Projects/Code/Powershell/shopping-cart/config/passport.js');var csrfProtection = csrf();router.use(csrfProtection);/* GET home page. */router.get('/', function(req, res, next) {Product.find(function(err, docs) {var productChunks = [];var chunkSize = 3;for (var i = 0; i < docs.length; i += chunkSize) {productChunks.push(docs.slice(i, i + chunkSize));}res.render('shop/index', { title: 'Shopping Cart', products: productChunks });});});router.get('/user/signup', function (req, res, next) {res.render('user/signup', {csrfToken: req.csrfToken()});});router.post('/user/signup', passport.authenticate('local.signup'), {successRedirect: '/user/profile',failureRedirect: '/user/signup',failureFlash: true});router.get('/user/profile', function(req, res, next) {res.render('user/profile');});module.exports = router;

    And this is how my app.js file is looking :

    var createError = require('http-errors');var express = require('express');var path = require('path');var cookieParser = require('cookie-parser');var logger = require('morgan');var routes = require('./routes/index')(passport);var indexRouter = require('./routes/index');var usersRouter = require('./routes/users');var expressHbs = require('express-handlebars');var mongoose =require('mongoose');var app = express();var session = require('express-session');var passport = require('passport');var flash = require('connect-flash');const bodyParser = require('body-parser');mongoose.connect('mongodb://localhost:27017/shopping', {useNewUrlParser: true, useUnifiedTopology: true});mongoose.connection.on('error', err => {throw 'failed to connect to MongoDB';});require('passport');

    // view engine setupapp.engine('.hbs', expressHbs({defaultLayout: 'layout', extname:'.hbs'}))app.set('view engine', '.hbs');app.use(bodyParser.urlencoded({extended: false}));app.use(bodyParser.json());app.use(logger('dev'));app.use(express.json());app.use(express.urlencoded({ extended: false }));app.use(cookieParser());app.use(session({secret: 'mysupersecret', resave: false, saveUninitialized: false}))app.use(flash());app.use(passport.initialize());app.use(passport.session());app.use(express.static(path.join(__dirname, 'public')));

    app.use('/', indexRouter);app.use('/users', usersRouter);// catch 404 and forward to error handlerapp.use(function(req, res, next) {next(createError(404));});// error handlerapp.use(function(err, req, res, next) {// set locals, only providing error in developmentres.locals.message = err.message;res.locals.error = req.app.get('env') === 'development' ? err : {};// render the error pageres.status(err.status || 500);res.render('error');});module.exports = app;Any hints on what could be the issue? all help is appreciated, thanks!

    Edit : here is my passport.js file :

    var passport = require ('passport');
    var User = require('D:/Other/Projects/Code/Powershell/shopping-cart/models/user');
    var LocalStrategy = require ('passport-local').Strategy;
    var mongoose = require('mongoose');
    passport.serializeUser(function(user, done) {
    done(null, user.id);
    });
    passport.deserializeUser(function(id, done) {
    User.findById(id, function(err, user){
    done(err, user);
    });
    });
    passport.use('local.signup', new LocalStrategy({
    usernameField: 'email',
    passwordField: 'password',
    passReqToCallback: true
    }, function(req, email, password, done){
    User.findOne({'email': email}), function(err, user){
    if (err) {
    return done(err);
    }
    if (user) {
    return done (null, false, {message: 'Email is already in use'});
    }
    var newUser = new User ();
    newUser.email = email;
    newUser.password = newUser.encryptPassword(password);
    newUser.save(function(err, result) {
    if (err) {
    return done(err);
    }
    return done(null, newUser);
    });
    };
    }));

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

    What language should I use?

    Posted: 05 Apr 2020 10:25 AM PDT

    Hey guys, I'm a network engineer looking for some advice. We have a staging team that has been less than spectacular. We hire people with basically 0 experience at this position and it's meant to teach and provide experience. However, it has proven to be unsuccessful and we receive configs full of errors even though we provide them with a simple script to copy and follow.

    Basically we have them edit scripts and just copy paste that script into the CLI of the equipment we use to setup basic configs. I want to try and make this even easier. Sometimes parts of the script is removed and it ends up screwing up our configs. We use simple text files with parameters such as <IP Address> for them to look through and change manually. Instead of having them manually do this process, I want to be able to automate the config for them, so that they would be prompted with a simple interface that says "Please enters the IP address" which will then change the parameter <IP Address> in the file itself. After that I want it to print it directly to the screen for them to copy paste it into the CLI. What language would be best to handle this? I have college experience with C++, PHP, and HTML but nothing extensive. I'm pretty open on what language to use.

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

    Is my Apache server creating multiple localhosts?

    Posted: 05 Apr 2020 08:37 AM PDT

    I'm trying to set up Apache server for MacOS Mojave 10.14 and I'm running into some bizarre issues.

    Whenever I type localhost into Chrome I get a 403 Forbidden error.

    When I type in localhost:8080 I get the standard "It works!" page, even after editing the default index.html files in /Library/WebServer/Documents to something different and running apachectl restart.

    When I type in localhost/~pangloss I get a 404 error.

    However when I type in localhost/index.php I get the desired index.php from my ~/Sites folder...except it only shows the plaintext and doesn't execute.

    I've run through several tutorials on setting up Apache at this point but no changes I make seem to resolve this. Are these three separate servers? Why might they be different?

    Here are my config files:

    httpd.conf: https://pastebin.com/uNFTUygL

    httpd-userdir.conf: https://pastebin.com/R6fdNtNv

    /etc/apache2/users/pangloss.conf:

    <Directory "/Users/pangloss/Sites/">

    AllowOverride All

    Options Indexes MultiViews FollowSymLinks

    Require all granted

    </Directory>

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

    In the context of running application, is it possible to take a snapshot of the gfx card and assert that the image is live/fresh?

    Posted: 05 Apr 2020 02:46 AM PDT

    Hi all,

    I have a bit of a strange question. I'm doing some research into a potential project to work on during these boring times.

    The question is as follows; Is it possible from the context of some lightweight application to capture a snapshot from the gfx card and capture the context of that screenshot. Ideally the context would include what application/program created that snapshot (bonus points if I could guard against spoofing). The hope here is being able to differentiate between a snapshot that was captured during a live-stream and a snapshot that was captured from a pre-recorded live-stream. Is this possible from purely software pov?

    If there is any documentation on the matter or any white papers that would be awesome. Any help would be much appreciated! cheers.

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

    Help updating a program!

    Posted: 04 Apr 2020 10:11 PM PDT

    I have zero coding/programming experience. I am playing MLB the show 2020 and I have found in the past people have made programs that will search through the website associated with the game (theshownation.com) and help find which cards have the best profit margins. I have the github links for a chrome extension used in 2018 and a stand alone program used in 2018. My question is would anyone be able to update this to be used with the 2020 version of the game from the 2018 code? thank you so much!

    https://github.com/cardona150/MlbTheShow18MarketAssistant (chrome extension based of the next code *forked?*)

    https://github.com/AnthoneyKalasho (original prgram)

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

    Implementing a flat-top gaussian function

    Posted: 05 Apr 2020 03:55 AM PDT

    I'm currently designing a simple genetic algorithm framework in Java. Right now for mutation, I'm generating random numbers to deviate the genes by. However, I feel like a Gaussian function would be more appropriate, as it also gives a small chance for big mutations to occur. After researching around a bit, I found something called a flat-top Gaussian function (Not sure if it's the same as a super-Gaussian function).

    However, I couldn't even manage to find a formula to implement this. I'm not very math-savvy, so the functions on Wikipedia didn't really help me much. Does anyone know how this could be implemented?

    Any help or advice is welcome. Thanks!

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

    Is there any way of dealing with Facebook Messenger?

    Posted: 05 Apr 2020 03:36 AM PDT

    Hello guys.

    You know that when somebody is active on Messenger, you can see that:

    https://imgur.com/NPwx28g (a video camera with a green point)

    but when that person enters your conversation, the video camera turns into something like that:

    https://imgur.com/6zPsCtZ (same camera but with a circle around it)

    My question is the following: by simply knowing this fact, is it possible to create a script or something that permanently checks all the conversations and notifies you when someone is viewing the conversation with you?

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

    No comments:

    Post a Comment