• Breaking News

    Sunday, January 12, 2020

    Can someone tell me what is happening in this code? Ask Programming

    Can someone tell me what is happening in this code? Ask Programming


    Can someone tell me what is happening in this code?

    Posted: 12 Jan 2020 04:56 PM PST

    Here is a code on how to create sparse matrix using the CSR format. The part I am having problem is how are the row indexes being stored? specifically the part where the while loop starts

    class SparseMatrix: def __init__(self, array): self.v = [] self.col_index = [] self.row_index = [] self.intern_represent = 'CSR' self.number_of_nonzero = 0 self.Tol = 0 self.rows, self.cols = array.shape[0], array.shape[1] for row in range(0, self.rows): for col in range(0, self.cols): value = array[row, col] if np.abs(value) > self.Tol: self.v.append(value) self.col_index.append(col) while len(self.row_index) <= row: self.row_index.append(self.number_of_nonzero) self.number_of_nonzero += 1 while len(self.row_index) <= self.rows: self.row_index.append(self.number_of_nonzero) 
    submitted by /u/Asc11111
    [link] [comments]

    Can't seem to stick to 1 language

    Posted: 12 Jan 2020 10:19 AM PST

    I want to learn a language where I can do stuff like make desktop apps, games and stuff like discord bots etc. The language I know the most of is Java thanks to AP Computer Science A+, and I also know a small amount of python. Just can't seem to stick to 1 language. Any recommendations?

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

    Do non-english speakers use non-english variables in their code?

    Posted: 12 Jan 2020 08:31 PM PST

    Just wondering this for non-English speakers.. do you choose to use english in your variable names or do you use your native language. I know some native languages have special characters so that would be a restriction but say for like number of foods, would you use a different variable than num_of_foods in your language? Silly question but I'm intrigued.

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

    How does a website detect automation is being used?

    Posted: 12 Jan 2020 01:40 PM PST

    There's applications at work that detect I'm attempting to automate some tasks. What are the ways they detect this?

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

    Blank during graduate level technical interviews

    Posted: 12 Jan 2020 02:38 PM PST

    I am a graduate programmer currently applying to jobs and going to interviews.

    Every time I have a technical interview with a time limit or have to complete an online test such as HackerRank iI get a rush of hormones and my mind goes completely blank for pretty much the whole process, meaning my answer is incomplete because I am programming so incredibly slow or it is not reflective of my real programming ability.

    I don't lack self confidence and don't have any anxiety problems normally.

    If I am given the same questions with no time limit, I'm sure that I would easily answer such questions with good code that works, and it would perhaps even be in the time limit that they otherwise would have allocated. While I'm reading through the problem all I am thinking about is time, and I am constantly checking the clock on the computer. At the end of every technical interview (only 2 so far) I am always thinking that what I wrote is not even close to my ability. I am just not getting enough done in the time allocated.

    It feels that they are not testing my programming capability, rather my ability to program under the type of stress that I would assume does not exist in the programming industry. I know that you might be under time pressure at times, but not to the same degree as "solve these 2 questions in 45 mins".

    For most of the 45 mins my mind is just blank and I am feeling nervous or large amounts of adrenaline or hormones.

    In university larger questions with problem solving was just in coursework (long time), and exams (short time) were more for rote learning or using one very specific programming technique, not combining different ones, and usually pseudo-code.

    Does anyone else have the same problem?

    Does anyone have a solution?

    Do all interview processes for Software Engineers entail a technical interview with a strict time limit? Is this accurately reflective of the impact of time stress at an enterprise level?

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

    Js CustomEvents

    Posted: 12 Jan 2020 04:01 PM PST

    Hello.

    I'm trying to write a js library and got stuck with customEvents.

    I want to dispatch a customEvent on the hole document but my eventListener doesn't receive anything if I don't target the specific element.

    My question are: Is there a way to globally emit and receive customEvents?

    Are there any good resources about customEvents except Mdn? (Mdn is good but it lacks tiny but usefull information)

    Sorry for poor writing it's like 1 am and my head isn't working right now. Ask me if I should explain things in more detail.

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

    I’m losing my motivation to learn anything related to programming. Any advice?

    Posted: 12 Jan 2020 05:05 PM PST

    Lately I've been getting depressed about the idea that I'm learning so slowly, while the technology is moving so rapidly. Everyone around me in CS and Software programs are able to keep up with the stuff. I study Engineering Physics, which I really find cool, but we don't do just as much programming. It's hard for me to stay caught up. This is really hurting my motivation to learn in my actual major, and even programming in general. I'm already in my third year and I still haven't gotten that great. I'm just scared of never catching up to my colleagues if I don't just quit my major and start learning everything I can about programming. Any advice?

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

    What advice would you have for someone looking to learn a programming language.

    Posted: 12 Jan 2020 08:42 PM PST

    I've only recently stayed looking into programming and wanted to see if anyone had any books/videos they'd recommend.

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

    Diffusion Limited Aggregation stickiness analysis

    Posted: 12 Jan 2020 07:39 PM PST

    I have been asked to make a program for Diffusion Limited Aggregation for recruitment process, which I completed and it is taking less than an hour for 500x500 matrix and 50000 points. The second part is using the data generated predict the stickiness of unknown simulation. I am trying following approach:

    1) Calculate the surface area for every 1000 points for 20 iteration for stickiness ranging from 1e-3 and 5e-2 (range mentioned in problem)

    2) Use a regression model or polynomial fitting on data generated and predict stickiness.

    I am looking for how to get surface area of the points in black (https://imgur.com/CE1WO8X)

    Any other ideas to analyze stickiness parameter

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

    Scheduling College Application

    Posted: 12 Jan 2020 12:54 PM PST

    how hard would it be to make an app for college scheduling based on the following criteria:

    Let's say there are 10 courses which take x number of rooms and y time slots. If lecturers want a specific time slot for their tutorials/ lectures then that should be taken into account. I heard this relates a bit to graph theory (coloring).

    Thanks!

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

    [CSS] Why do "collapsing margins" exist? I mean, except to force people to use hack fixes to work around them?

    Posted: 12 Jan 2020 10:53 AM PST

    Hello!

    You might or might not have heard about this, but it appears to be a well-known and researched problem. It appears to exist for existance's sake, and has made developers pull their hair out for decades:

    https://stackoverflow.com/questions/2680478/margin-top-push-outer-div-down

    https://stackoverflow.com/questions/12632125/inner-divs-margin-affecting-containing-divs-margin

    https://stackoverflow.com/questions/19718634/how-to-disable-margin-collapsing

    For those who don't know, "collapsing margins" is when you try to center your div vertically, and you apply a top-margin, and then that margin overflows to the parent element, and now you have child and parent elements snug, and the parent element having the margin on it.

    This apparently happens when parent and child div, or two adjacent divs have no margin or padding between them, or are of a different type than block.

    https://www.w3.org/TR/CSS2/box.html#collapsing-margins

    https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing

    I am really miffed by this.

    Thinking about either using:

    *{padding-top:0.05px} 

    Which would just give EVERYTHING a padding that exists, but is too small to actually show.

    OR, I should really keep a tight watch and make sure to always add vertical padding to child objects that I intend to push down via margins.

    What's your take on this, and do you have a solution different than all these mentioned? Like, why not make a css variable with which you can disable this? root: {collapsing-margins:off;} ktnxbye. Would make too much sense, I guess.

    EDIT: I kinda like the overflow:auto; solution because I will use resizeable divs, or later put other text into them which might be longer, so it's a good solution which is both useful and fixes the problem. This being said, the default overflow behaviour where it continues outside the borders of the div is also very weird...

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

    How does OpenGL get linked to your program if every graphics card manufacturer has it's own implementation?

    Posted: 12 Jan 2020 01:58 PM PST

    Is there an adapter library that you link to which then sends your function calls to whichever driver exists on the computer you are on?

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

    What is your opinion of the Agile development process?

    Posted: 12 Jan 2020 07:45 AM PST

    I did an internship that used "Agile" and I think it's just a code word for "we will micromanage you". You have "scrum meetings" (another codeword) every morning where they want to know exactly what you're doing for the day. I can't understand why they don't just trust their employees to do what they're paid to do. If I have a large task, I'm going to be doing that. I don't need managers to be breathing down my neck all the time. Do they really think people are dumb enough to hear "scrum" and "agile" and not realize what it really is? Thankfully I don't work there and I don't have to deal with it, but currently there is an initiative to try and do it but we haven't yet. I'm looking to get a new job anyway.

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

    Trying to get a specific object from a different file (using Cockpit CMS and React)

    Posted: 12 Jan 2020 02:08 AM PST

    Hi!

    I am working with Cockpit CMS and React to create a simple webshop.

    My only issue is that I can't single out the reviews I want, for a specific product.

    I need to render that specific product's review object
    (component) in the file called Details.js
    , which I get from the file called Reviews.js
    .

    The component render fine, but I can't get the spcific review without indexing for it myself. .g the reviews array, and then comparing review._by
    with result._by
    (from Details.js
    ). But there must be an easier way that I'm just not seeing? Been staring at this problem for way to long now...

    Here are the files:

    Details.js

    import React, { useState, useEffect } from 'react'; import { Helmet } from 'react-helmet'; import axios from 'axios'; import Navbar from './Navbar'; import Reviews from './Reviews'; import { FaCartArrowDown } from 'react-icons/fa'; const Details = (props, name, rating, body) => { const [result, setResult] = useState(null); useEffect(() => { axios .get( `http://192.168.99.102:8080/api/collections/get/Products?filter[_id]=${props.match.params.id}`) .then(res => setResult(res.data.entries[0])); }, [props.match.params.id]); console.log('result: ', result); function addToCart() { const cart = JSON.parse(localStorage.getItem('cart')) || {}; let newCart; // put same items together if (cart.hasOwnProperty(result._id)) { cart[result._id].quantity += 1; newCart = cart; } else { newCart = { ...cart, [result._id]: { ...result, quantity: 1 } }; } props.setCart(newCart); localStorage.setItem('cart', JSON.stringify(newCart)); console.log('item added to cart', newCart); } return ( <div> <Helmet> <title>Product Details</title> </Helmet> <Navbar /> {!result ? (<h3>Loading...</h3>) : ( <div className='bigCard' key={result._id}> <h2>{result.name}</h2> <h2>{result.description}</h2> <p>Price: {result.price}sek, in stock: {result.stock}</p> <p key={result.img}> <img src={'http://192.168.99.102:8080/' + result.img.path} alt='product' ></img> </p> <div className='gallery'> {result.gallery.map(item => ( <p> <img className='galleryItem' src={'http://192.168.99.102:8080/' + item.path} alt='gallery' ></img> </p> ))} </div> <div className='reviews'> <Reviews name={name} rating={rating} body={body} /> </div> <button className='buyBTS' onClick={addToCart} > <FaCartArrowDown /> </button> </div> )} </div> ); }; export default Details; 

    and Reviews.js

    import React, { useState, useEffect } from 'react'; import axios from 'axios'; const Reviews = (result) => { const [review, setReview] = useState(''); useEffect(() => { axios .get(`http://192.168.99.102:8080/api/collections/get/Reviews`) .then(res => setReview(res.data.entries[5])); //must give an index, or else I get the whole array of reviews. }, []); //I need the specific index for the product chosen in Details.js console.log('review: ', review); //Trying to solve the problem by comparing result._by with review._by (in the right review). //They have the same value in both result and review, but I can't access them at the same time console.log('result._by', result._by); // null console.log('review._by', review._by); //gives me a value //renders the review, but only the one indexed in line 10. return ( <div> <div className='reviewCard'> <div> <h4>Name: {review.name}</h4> <p className='rating'> Ranking: {review.rating}/5</p> <p>Comment: {review.body}</p> <hr></hr> </div> </div> </div> ); }; export default Reviews; 

    An example of a product, and what is logged in the console

    And in case it is needed, the repo: https://github.com/malinclarsson/mandatory-cms2.git

    Thankful for any input I can get.

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

    Implementing Image With Text Section In Shopify

    Posted: 12 Jan 2020 08:59 AM PST

    Hey everyone, I'm fairly new to coding and I've been trying to figure out how to properly implement an image with text section on a Shopify website. The original website implements snippets oppose to sections so there is no drag and drop functionality right now. I've been trying to add an image with text and button section similar to this:

    https://help.outofthesandbox.com/hc/en-us/articles/115006909427-Setting-up-the-Image-with-text-section-Mobilia-theme

    I would want to be able to customize the whole section on the front end theme editor. I've found the initial section but the css isn't getting configured correctly.

    Any help would be greatly appreciated.

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

    [HTML JS] What happens when you string DOM methods (like getElementById and appendChild) together, and they both have return values? Should one do this or not?

    Posted: 12 Jan 2020 07:22 AM PST

    Hello!

    I currently have:

    var parent_id = document.getElementById(parent); var new_child_address = parent_id.appendChild(child); return new_child_address; 

    But I would like to have the peace of mind and also knowledge on the inner-workings, to know that I can also do it this way and save 2 lines and that no errors or weird stuff would happen:

    return document.getElementById(parent).appendChild(child); 

    But I don't know how the execution goes. Get element returns an element, and append child returns the new address of the old child that now has a parent.

    Please help!


    PS:

    The goal of returning the child is so I can continue on adding .style stuff onto it outside the function that creates the child and appends it to a parent.

    So, my question is:

    When I first make a child with

     var child = document.createElement(child_parameter); 

    then "child" contains one pointer/identifier/address to the child. And then when I appendChild it, then the return value is another pointer/identifier/address.

    What happened to the old variable "child", and how do its contents differ from the new variable "new_child_address"? Would I get an error if I used child because it doesn't exist anymore at that address?

    Tnx!

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

    Requesting font from assets domain on LIVE site blocked by CORS

    Posted: 12 Jan 2020 09:33 AM PST

    I'm trying to access my font via my assets domain on my LIVE site. However, is returning a CORS error. This is not occurring on my development environments. Inspection has shown that the state it fails at is "stalled" - this was found using Chrome's dev tools. This issue does not seem to be happening on any other browsers however. Sometime it WILL load correctly on chrome. Any ideas?

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

    Is this right command in R?

    Posted: 12 Jan 2020 12:54 PM PST

    firm_app_data = subset(firm_app_data, select = -c(conm, gvkey))

    Is this right command in R? If I want to drop conm and gvkey?

    bcos i m getting error as :

    Error in eval(substitute(select), nl, parent.frame()) : object 'gvkey' not found

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

    How to concat buffer string in Go?

    Posted: 12 Jan 2020 01:51 AM PST

    I'm using tarm/serial package to read NMEA strings from my GPS using serial port. My code is the same as in tarm/serial example from README: https://github.com/tarm/serial#usage

    This is the output I receive:

    2020/01/12 10:46:09 "$" 2020/01/12 10:46:09 "G" 2020/01/12 10:46:09 "P" 2020/01/12 10:46:09 "V" 2020/01/12 10:46:09 "T" 2020/01/12 10:46:09 "G" 2020/01/12 10:46:09 "," 2020/01/12 10:46:09 "2" 2020/01/12 10:46:09 "5" 2020/01/12 10:46:09 "0" 2020/01/12 10:46:09 "." 2020/01/12 10:46:09 "9" 2020/01/12 10:46:09 "2" 2020/01/12 10:46:09 "," 2020/01/12 10:46:09 "T" 2020/01/12 10:46:09 "," 2020/01/12 10:46:09 "," 2020/01/12 10:46:09 "M" 2020/01/12 10:46:09 "," 2020/01/12 10:46:09 "0" 2020/01/12 10:46:09 "." 2020/01/12 10:46:09 "0" 2020/01/12 10:46:09 "0" 2020/01/12 10:46:09 "," 2020/01/12 10:46:09 "N" 2020/01/12 10:46:09 "," 2020/01/12 10:46:09 "0" 2020/01/12 10:46:09 "." 2020/01/12 10:46:09 "0" 2020/01/12 10:46:09 "0" 2020/01/12 10:46:09 "," 2020/01/12 10:46:09 "K" 2020/01/12 10:46:09 "," 2020/01/12 10:46:09 "A" 2020/01/12 10:46:09 "*" 2020/01/12 10:46:09 "3" 2020/01/12 10:46:09 "1" 2020/01/12 10:46:09 "\r" 2020/01/12 10:46:09 "\n" 

    You can see that strings are delimited with \r\n. How to properly join the characters to create proper string? Should I go with the simplest method (adding each character to string until \r\n is received, outputting it and then repeat?) or is there some smarter way in Go to do it? Maybe dedicated package?

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

    See changes made by other user's forks compared to original master?

    Posted: 11 Jan 2020 11:44 PM PST

    For a given repo with a lot of forks, and one you've not forked yourself, is there a way to see just the forks that have made changes ("are x commits ahead") compared to original master?

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

    Linux Thread question

    Posted: 12 Jan 2020 12:50 AM PST

    I'm a little confused about pthread_join, if I'm running on a single core system is there any instance where I cant join all of my threads?

    thread_func1 do something for ever main for(100 times or something) pthread_create(xx,xx,thread_func1,xx) for(100 times again) pthread_join(xx,xx) 

    Would I for example be able to launch all 100 of the threads here above or would the first thread starve the cpu?

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

    No comments:

    Post a Comment