• Breaking News

    Friday, August 14, 2020

    Better way to process huge files Ask Programming

    Better way to process huge files Ask Programming


    Better way to process huge files

    Posted: 14 Aug 2020 06:39 PM PDT

    I have a huge csv file and I have to process that file and do some data manipulation. Right now I'm reading/loading the file in buffer and then doing the data processing work. I find this approach inefficient incase the file is very large. Would it be better to load/read chunk of file then process it and keep doing it until the file is completely processed? I need suggestions.

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

    How many dimes and drents would equal or goes over 100 cents while weighing the least?

    Posted: 14 Aug 2020 03:26 PM PDT

    Hey guys I'm trying to solve this problem I made. I think I can find a solution in like 100 lines of if statements but is there anything more elegant?

    # 1. How many dimes and drents would equal or go over 100 cents while weighing the least?

    # 2. Find an algorithm that would equal X cents while weighing the least.

    # a dime is equal to 10 cents and weighs 3 grams.

    # a drent is equal to 14 cents and weighs 4 grams.

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

    Using code to find my lost dog

    Posted: 14 Aug 2020 10:32 AM PDT

    Hi everyone. So this morning someone broke into my house and stole my puppy. I have already done everything that you normally do when your dog is lost or stolen (file a police report, put up posters, and ask for help on social media), but I was wondering if there was some way to use the power of computers to find my puppy. I remember seeing articles about software that allows you to upload an image of a persons face and it will scan the internet using facial recognition and return every image of that person that is on the internet. So I was wondering if there was any software out there that could do the same thing, but for an animal. I know that facial recognition on animals is probably a lot more complex that on people, but if there was a way to upload a picture of my dog and have a program return something like a Craigslist posting trying to sell my dog, then that would be pretty cool. If anyone knows of this kind of software, or knows how to make something like this, then that would greatly appreciated!

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

    How to not get addicted to programming?

    Posted: 14 Aug 2020 01:15 AM PDT

    Whenever I start doing some programming project, I get addicted to it. I spend day and night solving that project, although I know that this is not as useful as doing it in few pomodoros, taking breaks etc.

    And, I also need to study for academics. So, doing the programming projects day and night creates lack of time for studying my academics.

    How do I motivate myself to work for only few hours per day in the problem? And not get addicted in unconsciously spending lots of time in programming?

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

    How to avoid training every time I run my code [ML/VS Code]

    Posted: 14 Aug 2020 01:17 PM PDT

    I started learning deep learning using a Jupyter notebook where you can selectively run blocks of code.

    I've just created my first solo CNN in VS Code but I'm having a lot of trouble debugging since I have to wait for my model to train every time I run my code.

    Is there a way to run sections of the code and keep them in memory the way Jupyter notebook does? I know I'm doing this the dumb way but I don't know how you would normally do this.

    Thank you!

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

    Is there a C++ compiler that can quickly build the code like tcc for C language?

    Posted: 14 Aug 2020 10:33 PM PDT

    Is there a C++ compiler that can quickly build the code but doesn't really care about performance like tcc for C language?

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

    Tensorflow.js Backpropagation with tf.train

    Posted: 14 Aug 2020 10:09 PM PDT

    When I have been attempting to implement this function tf.train.stg(learningRate).minimize(loss)
    into my code in order to conduct back-propagation. I have been getting multiple errors such The f passed in variableGrads(f) must be a function. How would I implement the function above into the code bellow successfully? and Why does this error even occur?

    Neural Network:

    var X = tf.tensor([[1,2,3], [4,5,6], [7,8,9]])

    var Y = tf.tensor([[0,0,1]])

    var m = X.shape[0]

    var a0 = tf.zeros([1,3])

    var parameters = {

    "Wax": tf.randomUniform([3,3]),

    "Waa": tf.randomUniform([3,3]),

    "ba": tf.zeros([1,3]),

    "Wya": tf.randomUniform([3,3]),

    "by": tf.zeros([1,3])

    }

    function RNN_cell_Foward(xt, a_prev, parameters){

    var Wax = parameters["Wax"]

    var Waa = parameters["Waa"]

    var ba = parameters["ba"]

    var a_next = tf.sigmoid(tf.add(tf.add(tf.matMul(xt, Wax), tf.matMul(a_prev , Waa)),ba) )

    return a_next

    }

    function RNN_FowardProp(X, a0, parameters){

    var T_x = X.shape[0]

    var a_next = a0

    var i = 1

    var Wya = parameters["Wya"]

    var by = parameters["by"]

    for(; i <= T_x; i++){

    var xt = X.slice([i-1,0],[1,-1])

    a_next = RNN_cell_Foward(xt, a_next, parameters)

    }

    var y_pred = tf.sigmoid(tf.add(tf.matMul(a_next, Wya), by))

    return y_pred

    }

    const learningRate = 0.01;

    var optimizer = tf.train.sgd(learningRate);

    var model = RNN_FowardProp(X, a0, parameters)

    var loss = tf.losses.meanSquaredError(Y, model)

    for (let i = 0; i < 10; i++) {

    optimizer.minimize(loss)

    }

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

    Converting a list of strings to a list of floats

    Posted: 14 Aug 2020 09:01 PM PDT

    Let's say I have an array that looks like:

    arr = ['1' ,'1','2','3', '4','ran','dom','5','6','7','txt','in','7','8','9','in here'] 

    What I want to do is convert all the floats as strings in ```arr``` to floats and get rid of all the actual string elements. This is what I am doing right now:

    arr = ['1' ,'1','2','3', '4','ran','dom','5','6','7','txt','in','7','8','9','in here'] new_arr = [] for i in range(len(arr)): try: new_arr.append(float(arr[i])) except ValueError: pass print(new_arr) 

    Output:

    [1.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 7.0, 8.0, 9.0] 

    Is there a faster way to do this? Thanks for any advice you guys might have for many.

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

    Having some issues with ajax functions in a python based web project.

    Posted: 14 Aug 2020 07:31 PM PDT

    So I am working on a web project for a python course I have been taking. I've been having some issues with the login and registration function of the project. I noticed that this page when entering the code didn't create drop downs as the commands were entered and a lot of the text of the code was the same color when I was expecting it to be different. For this section of the project I'm working on it uses javascript and not python. I noticed it for commands like ajax, preventDefault, and log as some examples. The project uses web.py and bootstrap so that may be part of the issue. Some of the videos in this course are a bit older and I'm worried that I might not have downloaded something the professor might have and that's the reason I keep hitting this wall. This is the page that I noticed the issue on, it ties into a few other pages but if anyone can help me navigate the javascript portion of this project it be helpful.

    $(document).ready(function(){ console.log("loaded"); $.material.init(); $(document).on("submit", "register-form", function(e){ e.preventDefault(); var form = $('register-form').serialize(); $.ajax({ url: '/postregistration', data: form, success: function(response){ console.log(response) } }): }); }): 

    As a note I do have Jquery-3.5.1 downloaded in the JS file I created and have included:
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> In the mainlayout file.

    submitted by /u/Wiseman-no
    [link] [comments]

    Why are Macs not recommended for programming?

    Posted: 14 Aug 2020 07:26 PM PDT

    I heard many big companies use Macs for programming, and many programmers outside Reddit recommended me that I get a Macbook Pro 13 inch for programming.

    But Reddit people don't seem to recommend Macs for some reason.

    Why are Macs not recommended for programming? Excluding the shitty butterfly Macbooks.

    And off-topic question, but do most programmers use Android phone as their daily phones, since they don't use the apple ecosystem? Many Reddit programmers seem to recommend Android phones.

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

    When variables are passed through different platforms, should the variable names change to match the conventions of each platform?

    Posted: 14 Aug 2020 12:54 PM PDT

    I'm interested in learning how others handle variable names when working in two different programming environments at once. Most commonly, this would be a client/server app - for example, a Javascript front end talking to a back end API server.

    In my case, I have a Vue (Javascript) front end app, in which the convention is to use camel case, ex: lastStatus. It is speaking to a Laravel back-end API server. The convention for database columns in that environment is to use snake case, ex: last_status .

    I am wondering whether it makes more sense to:

    a) Use the same variable names from end to end. In other words, last_status will always be last_status, regardless of whether I'm working on the front or the back end. This seems like it may be less error-prone, but it feels a little icky to me.

    or

    b) Name the variables according to the conventions of the programming environment in which they're being used. In other words, I'd use last_status on the back end, and then map it to lastStatus on the front end. This seems more philosophically pure to me, but the mappings introduce additional overhead.

    How do YOU handle this?

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

    Is there a simple free and open source game engine written and configured in C++?

    Posted: 14 Aug 2020 06:46 PM PDT

    Is there a simple free and open source game engine written and configured in C++ that also has a GUI editor, kinda like toy engine (its abandoned though the project) https://hugoam.github.io/toy-io/

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

    Advice on how to study

    Posted: 14 Aug 2020 06:12 PM PDT

    So I have been coding for a month and I was wondering what methods should I use to get the most of what I'm learning

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

    Is it possible to forget how to code?

    Posted: 14 Aug 2020 01:17 PM PDT

    So I started coding during highschool and I only code in one language (C#) for 3 years. You could say that I got pretty confortable with the language itself and with alot of projects done. Recently I got into (I wouldn't say a college) it's something similar but in my country. I'm loving the course so far and I only got a question. I'm being forced to learn/use various languages, i'm learning like java,python,C++ and I'm picking up powershell on my own outside classes. Is it possible to be professional dominant in all of these languages in the work world, or should I stick to 1/2 or 2/3 languages and try to be the best at those? Do you forget how to code in one language if you stop using it for a while? Let me you know your experience please

    submitted by /u/Prize-Bunch-755
    [link] [comments]

    Why do complex math operators such as Sine and Cosine output a different result each time?

    Posted: 14 Aug 2020 12:10 PM PDT

    I was creating a 2D gravity simulator in HTML Canvas, and every frame I would update the velocities and positions of each body. After a while, I noticed that while I kept Javascript's standard floating point length, the positions and velocities of each body would be wildly off after a few seconds, following chaos theory. Once i realized that it was because of the main Trigonometry functions outputting different results every time, I truncated the variable to 4 digits, and then every time I ran the program after that, the positions and velocities of each body were exact each successive time.

    My question is, why do complex math operations such as the Trig functions have very close, but different outputs each time?

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

    Sockets and WebSockets

    Posted: 14 Aug 2020 03:24 PM PDT

    What is the difference? I've read that WebSockets are good for real time communication, but aren't normal sockets just as good? When and why would I use a WebSocket other than to connect to JavaScript?

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

    Flask error

    Posted: 14 Aug 2020 11:29 AM PDT

    I'm trying to run a simple hello world script to test flask but every time I try and run it in the cmd it comes back with this, error no module named 'flask.cli'; 'flask' is not a package. I do not know how to solve this I have installed flask using pop and everything but I can not fix this. Could u please help

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

    Make a function for repeated gets in Node JS Middleware

    Posted: 14 Aug 2020 01:55 PM PDT

    Hey everyone,

    I was writing a CRUD app using node.js and had to write similar code to handle getting different pages. I wanted to know how I could turn it into a function, and pass in an object containing the right parameters so that I have to repeat less code.

    router.get('/genres', function (req, res, next) { var context = {} context.title = 'Genres' context.description = 'This page shows different genres. This includes the Genre name and a description.' res.render('genres', context); }); 

    how Could I turn this into a function, such as this?

    function getPage(obj) { router.get('/'+obj.path, function (req, res, next) { var context = {} context.title = obj.title.toUpperCase() context.description = obj.description res.render(path, context); }) } 

    Thanks for your help, new to Javascript

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

    Looking for basic direction on full stack app development

    Posted: 14 Aug 2020 01:31 PM PDT

    Background: I am a Mechanical Engineer with experience using Python and SQL, experience is with databases and visualizations, and mechanical analysis. I have a basic app idea and am trying to determine how much I'd be taking on if I start it, also looking for proper taxonomy and developer tools.

    My idea: I want to create an app that allows people to share goods and services. I would like to have each user be able to create an account and create listings with various attributes. I then want to display those listings in a type of catalog. Eventually I want to integrate a payment method, but that is a long term goal to grow to and not a day 1 feature.

    To me I think it's easiest to make this web based? I'm thinking I can optimize for mobile viewing? Long term apps may be beneficial for retention and something to grow towards.

    With my background with SQL I see this as each user having an account and a portal to create entries in a databse with write access, that then gets displayed in a view all mode -with links to send messages.

    Core day 1 features:

    • User accounts
    • Form to create listings that publish to a database, ability for user to edit/remove.
    • Catalog view of listings
    • Ability for users to send DMs.
    • Transaction processing, i.e. the ability to borrow a good for a proposed time period, or bid on a feature.
    • Website format with layout optimized for mobile.

    Future roadmap:

    • Monetization feature for transactions.
    • Refinement of catalog
    • mobile apps
    • Google/FB account integration, easier if day 1?

    All I'm looking for is a reality check on how difficult this would be, are there existing tools I can leverage, or should I consider this a complete from scratch project.

    Sorry if this is the wrong place to post this.

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

    Modern compiler implementation 1st vs 2nd edition

    Posted: 14 Aug 2020 07:03 AM PDT

    I would like to build a compiler and don't know what book edition to choose.

    Does the new edition gives more up-to-date information as compared to the older (ML) one, hence provide more learning value ?

    The table of contents look very much alike (I would love to write it in OCaml, hence the ML edition here).

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

    Tools/Plugins that help with Programming [Request]

    Posted: 14 Aug 2020 08:46 AM PDT

    Recently I've started using dedicated linters in Atom and they're so helpful! They keep me from making stupid mistakes and having to wait for syntax errors to be caught at compile-time. I've actually learned stuff about programming languages from linter warnings (like that you can't do for(int i = 0; i < 10; ++i); in c99). Also, package managers like apt and homebrew blew my mind when I learned about them.

    So, I guess the question is: what tools do you guys use that helped you program better or learn more about the programming languages you use?

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

    How Facemash worked?

    Posted: 14 Aug 2020 11:41 AM PDT

    First, I know the Elo's rating used in that website. But I have questions about the site's functionality. So, I ask quickly :

    1. Did it need registration?
    2. Was it a survey with random encounters?
    3. What did it use to know a computer just ended the game? (like cookies, etc)
    4. Is there any implementation of the website available on github, etc? (Ok, I will search about this myself).

    Thanks guys!

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

    Is it bad practice to put a 100 line onload function in its on file?

    Posted: 14 Aug 2020 08:34 AM PDT

    Title. Web applications I make can sometimes have heavy onload functions, upwards of 100-300 lines. I'm always trying to learn new ways or organizing my code and compartmentalizing it. I typically put this part in its own file: onload.js. Is this alright? Do you have any tips for organizing this?

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

    Need help reducing runtime of my program

    Posted: 14 Aug 2020 06:55 AM PDT

    I'm making a GUI with tkinter that uses a large excel spreadsheet for processing but my program takes too long to work. Any advice on how to reduce the runtime?

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

    Best way to automatically interact with a website that doesn't have an API?

    Posted: 14 Aug 2020 06:39 AM PDT

    I want to automate a manual task on a website that doesn't offer an API. I need to write a script that will navigate through pages and click some buttons on a website.

    I've used python selenium for something like this in the past. Can anybody recommend other good tools for this kind of web site automation?

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

    No comments:

    Post a Comment