• Breaking News

    Monday, February 26, 2018

    Has anyone done a frequency analysis of standard library function usage? Ask Programming

    Has anyone done a frequency analysis of standard library function usage? Ask Programming


    Has anyone done a frequency analysis of standard library function usage?

    Posted: 26 Feb 2018 11:36 AM PST

    Has anyone done a frequency analysis of standard library function usage?

    For natural languages this kind of analysis has been done (for many reasons) https://en.wikipedia.org/wiki/Word_lists_by_frequency https://en.wikipedia.org/wiki/Most_common_words_in_English

    Clearly for programming languages the analysis would be more difficult because there's a distinction between 1) static usage: occurrence in code 2) dynamic usage: how many times a given library function is called during execution

    Even for 1) there's the additional difficulty of determining what an 'occurrence' is. If a library function is thinly wrapped, does usage of that wrapper function count as an occurrence of the library function? Etc.

    Despite these difficulties I'd like to know if someone has done something similar. I'm most interested in Python, Javascript, or a functional language like Haskell, etc. But, any language would be helpful to look at. Any links or keywords to search would be helpful.

    Thanks for any responses!

    Note: I'm not particularly soliciting opinions about the utility of any of this. But, if you can't resist then I suppose post them

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

    How to write a custom JSON decoder for a complex object?

    Posted: 26 Feb 2018 09:00 PM PST

    I've detailed my issue with this concept in this unanswered stackoverflow post. I thought I'd post it here as well for additional visibility, since it seems like the SO post is probably going to stay unanswered. Here's the body of it:

    Like the title says, I'm trying to write a custom decoder for an object whose class I've defined which contains other objects who class I've defined. The "outer" class is an Edge, defined like so:

    class Edge: def __init__(self, actor, movie): self.actor = actor self.movie = movie def __eq__(self, other): if (self.movie == other.movie) & (self.actor == other.actor): return True else: return False def __str__(self): print("Actor: ", self.actor, " Movie: ", self.movie) def get_actor(self): return self.actor def get_movie(self): return self.movie 

    with the "inner" classes actor and movie defined like so:

    class Movie: def __init__(self, title, gross, soup, year): self.title = title self.gross = gross self.soup = soup self.year = year def __eq__(self, other): if self.title == other.title: return True else: return False def __repr__(self): return self.title def __str__(self): return self.title def get_gross(self): return self.gross def get_soup(self): return self.soup def get_title(self): return self.title def get_year(self): return self.year class Actor: def __init__(self, name, age, soup): self.name = name self.age = age self.soup = soup def __eq__(self, other): if self.name == other.name: return True else: return False def __repr__(self): return self.name def __str__(self): return self.name def get_age(self): return self.age def get_name(self): return self.name def get_soup(self): return self.soup 

    (soup is just a beautifulsoup object for that movie/actor's Wikipedia page, it can be ignored). I've written a customer encoder for the edge class as well:

    class EdgeEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, Edge): return { "Actor": { "Name": o.get_actor().get_name(), "Age": o.get_actor().get_age() }, "Movie": { "Title": o.get_movie().get_title(), "Gross": o.get_movie().get_gross(), "Year": o.get_movie().get_year() } } return json.JSONEncoder.default(self, o) 

    which I've tested, and it properly serializes a list of edges into a JSON file. Now my problem comes when trying to write an edge decoder. I've used the github page here as a reference, but my encoder deviates from his and I'm wondering if it's necessary to change it. Do I need to explicitly encode an object's type as its own key-value pair within its JSON serialization the way he does, or is there some way to grab the "Actor" and "Movie" keys with the serialization of the edge? Similarly, is there a way to grab "Name". "Age", etc, so that I can reconstruct the Actor/Movie object, and then use those to reconstruct the edge? Is there a better way to go about encoding my objects instead? I've also tried following this tutorial, but I found the use of object dicts confusing for their encoder, and I wasn't sure how to extend that method to a custom object which contains custom objects.

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

    Only odd digits - Java

    Posted: 26 Feb 2018 08:58 PM PST

    Hello - I am taking a first year Java course and can't figure out why my code won't run.. The question is to write a boolean class that evaluates if an integer (length unspecified) only contains even digits.

    The following is what I have:

    public boolean evenDigits(int n) { if(n < 0) { n = -n; } while(n > 0) { int last = n % 10;
    if(last % 2 == 0) {return true;} n = n / 10; } return false; }

    Any help would be appreciated!

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

    Please help me port my js program from my ide to codepen

    Posted: 26 Feb 2018 08:09 PM PST

    So I recently wrote my first Javascript program with CSS and HTML elements making a 3d scene using three.js that can run on a local server. I have successfully written the program and am running it on a local server now using the atom-live-server plugin (using atom as my ide naturally). What I would like to do is move it to codepen, so I can place it in my portfolio project (doing via freecodecamp). I have two source files, OrbitControls.js as well as three.js which I linked to the online sources in codepen. These were linked to locally when running from ide. I also have a font loaded in, which is a json file, also linked locally in ide, also changed to link to online source when moved to codepen. I think I made the needed changes, but codepen is not showing anything and I wanted to see if anybody might take a look and tell me what I am missing here.

    Pastebin to full code from ide: https://pastebin.com/uqVArrcb

    Link to codepen: https://codepen.io/darobbins85/pen/OQaWzJ

    I appreciate any help!

    EDIT: I debugged in codepen and removed a bunch of errors using 'Analyze js' and now no errors are found, but animation is still not showing as expected

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

    [Java] How do i shuffle an array of objects?

    Posted: 26 Feb 2018 07:36 PM PST

    For my assignment in class I'm to make an object that is a card then fill an array with 52 objects/cards then print out the "deck" in a random order. Everything works fine except the shuffle method. The shuffle method is not in the driver. public void shuffleDeck() { for(int i = 0; i < 100; i ++) { int ran1 = (int)(Math.random() * 52); int ran2 = (int)(Math.random() * 52); if(ran1 != ran2) { Card taco = this.deck[ran1]; this.deck[ran1] = this.deck[ran2]; this.deck[ran2] = taco; } } } is what i have for the shuffler but everytime I go to print it the array/deck it prints it out in order, not random. Does anyone know how to point me in the right direction?

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

    Storing Temporary Data across Pages in a Web Application: Are Sessions the Best Way to do It (Node/Express/MongoDB)?

    Posted: 26 Feb 2018 06:56 PM PST

    Hello there! New web developer here, and I was wondering what the most efficient way to store temporary data is across all the pages of a web app. I'm trying to design something similar to PcPartPicker, where you create a build/add parts to it without having to have a user account.

    Right now, I'm using express-session to store this temporary data across all pages (Ex. user goes to an item's main page, you can click to add it to your build and the button adds the item to a session variable array, it then redirects to the main build page and uses EJS to loop through the array, showing all of the items the user has chosen thus far).

    I'm just wondering if this is the most efficient way to do it? I'm storing data that I would be later passing into a mongoose schema if a user were to sign in and save their build (a javascript object with the name, price, description, tags, etc. of the item), so each item totals about half a kilobyte. If I'm looking to potentially scale up to a large amount of users, is this a bad practice? I read something about memory caching but I'm not sure whether that's appropriate to use in this case. Or, is it best to just store it to a "temporary_builds" collection in mongo and then just delete that after a given time.

    Thanks so much if you made it this far lol.

    TL;DR are session variables a scalable way to store temporary data for an anonymous user across my web application that is similar to PcPartPicker.

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

    Refactoring to align with product terminology

    Posted: 26 Feb 2018 12:27 PM PST

    I'd like to solicit some opinions on refactoring code solely to align with product terminology. Example:

    Say our product has a dropdown list of "Vehicles". All through the tech stack we use the word "vehicle" - class names, variable names, tables in the DB, etc. The product team has decided that "Cars" is a better word and wants to update everything in the UI to say "Cars" instead of "Vehicles".

    On one hand we can very simply update a few labels and call it a day. But then we have a misalignment between the business/product terminology and the technical terminology - our implementation/support team go around referring to the "Cars" dropdown while the engineering team still thinks of "Vehicles" because that's what all the code references. Cross-team communication becomes confusing because no one is speaking the same language.

    On the other hand we can go about a non-trivial refactoring effort just to change "vehicle" to "car" - updating class names, DB migration script, etc. It's not a lot of work, but it's certainly a good deal more than simply updating a few labels.

    Of course the answer to most of these kinds of questions is that it's a balance, we need to weigh the cost of refactoring with the cost of having business/engineering speaking different languages. Curious to hear how this plays out in other companies - do your business/engineering teams have totally different terminologies for your product? Any time the product team changes the name for something do you make sure you refactor all references, even if you're adding no other value than a rename? Do you put extra effort into naming things initally and then just live with those decisions?

    A few points as I think about how folks may answer these:

    • Please don't get hung up on the "vehicles"/"cars" example. I was trying to demonstrate that "vehicles" was the more technical sounding word that the engineering team came up with when first building the feature and "cars" is what the product team ultimately came up with after getting customer feedback and mulling it over for a while.
    • I'm sure the idea that a basic rename is non-trivial indicates some issues in our codebase - would be great if I could just do a rename and have Visual Studio update all references for me, but that's just not the current state of our codebase.
    submitted by /u/yDgunz
    [link] [comments]

    Any Examples of People Doing Artsy Things With Software?

    Posted: 26 Feb 2018 08:39 AM PST

    Do you know/ have examples/ sites of how programming/ code/ software is being explored through the arts? Curious about the creative, "art for arts sake" direction of programming. It's something I'm interested in exploring. However, I'm fearful of becoming discouraged without clarity on the possibilities (even though I know that it's the present future and that all of these worlds are merging). VR is growing, but it feels like a huge jump with lots of low-lying fruit in between.

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

    Is it worth it to invest in a Mac?

    Posted: 26 Feb 2018 02:27 PM PST

    I've been doing app development for 2 years now and recently started grad school. I've been programming on Linux, but it seems that about 80% of my classmates (and coworkers for that matter) are programming on Macs. Also, I have found that for various projects that my bosses have wanted to use some very specific technology, it's been significantly easier for Macs to set up the environment.

    I'm looking to upgrade my laptop, but I never realized that Macs were so expensive, sometimes more than 3x what I might spend on a Windows laptop. so I was wondering, why do you Mac users use Mac? Do you think it's worth the investment?

    Side question: For you webdevs programming on Windows, what are you using to program with? Is it mostly IDEs?

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

    Trying to find some more information about retrieving information from online vendors and aggregating this information into one place.

    Posted: 26 Feb 2018 10:36 AM PST

    I'm trying to learn and hopefully implement a way to retrieve information about online sales such as price, and what the item is , and what website it is from and then host this information on its own website. Any information regarding what i should look into to begin researching this topic would be greatly appreciated.

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

    Does ram need to be installed in pairs?

    Posted: 26 Feb 2018 10:34 AM PST

    It's funny that I know to code, but am clueless about hardware. I have a Dell XPS 15 with only 8gb ram, and I want to upgrade. This laptop can be upgraded up to 32gb. So I'm wondering if I could add a single stick of 16gb ram to my current 8gb for a total of 24gb?

    I'm looking online now and it seems that everything comes in pairs. If I want one 16gb stick I need to buy two. Ideally, I'd like to buy one 16gb now (with my 8gb), then later (when my budget allows for it) replace the 8gb with another 16gb.

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

    What tools are you using to plan a feature's minutiae?

    Posted: 26 Feb 2018 07:49 AM PST

    I've been googling, but have only found high-level software planning methods like Agile. I'm looking for something that is more in-depth because I've been surprised by some surprise requirements for features I failed to think about during specification. There's got to be a codified, tried and tested way to nail these details down, I just can't find it. What are you guys using?

    Essentially, I'm looking for something that will look at a process and zoom in on all the stakeholders and front- and backend activities, like:

    • You have created a report and some attached artifacts (like custom fields).
    • Who is notified?
    • Who has access to the report?
    • Then you delete the report.
    • What happens to the custom fields?
    • Who is notified?

    Edit: Just to clarify, I'm not looking for project planning tools. I'm looking for a sort of a work sheet that lets me take down all the details of a specific feature and how it incteracts with connected features.

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

    Good programming podcast

    Posted: 26 Feb 2018 01:32 PM PST

    Hi I am looking for a good programming podcast where things like coding, programming languages, best pratices and computer science related topics are dicussed. Most podcasts I found are gaming related and I hope someone can recommend a good one without gaming topics. Thanks for your answers.

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

    Hiring a programmer - how do we best approach this and salary expectations?

    Posted: 26 Feb 2018 05:51 AM PST

    Hi there, just to give everyone an idea of our requirements:

    • Programming Language: node.js
    • Frameworks: meteor, handlebars, jquery.
    • Database: MongoDB
    • Web Server: Nginx

    Would this be realistic to get one person to look at all of this?Also, what expectation should we put on salary?

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

    Question on software distribution: Germany

    Posted: 26 Feb 2018 09:12 AM PST

    So... a niche/specialty program I use is written by a fellow in Germany, and resold state-side on physical CDs. Given that computers that actually have CD drives anymore are getting somewhat rare, a lot of customers are wondering 'why?'.

    The US distributor swears that its a requirement from the German government, that they absolutely forbid any downloadable version of the software.

    My counter is that I've used SuSE Linux, which was/is German based, for well over a decade. Back when a 5 CD install set was a bit tough to download, sure, I bought physical copies. Now (as in the last ten years at least)... not so much. And it's very much available online for download.

    Anyone here have any experience with this sort of restriction, specifically the German gov't aspect?

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

    [Planning a program] How to get ETA from location, route waypoints, and distance to one waypoint

    Posted: 26 Feb 2018 08:44 AM PST

    I have an idea for a project that involves processing API data from my college's bus route in order to find out how far away each bus is from my apartment. The end result would show each bus on the route, and an estimate of how long until it would pick me up.

    Sparing the unneeded details, I have:

    • For each bus stop:
      • Name
      • Lat-long
    • For each bus on the route:
      • Lat-long
      • Next stop name
      • Next stop estimated depart time

    So I have almost all the information I could ever need. But, I need to find a way to convert this all into a (time) distance from one stop. In a perfect world, I'd just use the timetables, but Transportation Services is very under-staffed and they often won't put enough buses on the routes to fulfill those timetables.

    So conceptually, what are some ways that I could go about this? I've considered just plugging the location of each bus and the stop waypoints into the Google Maps API, but am I missing a way to do it with just the data on hand?

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

    Can anyone suggest any code styling extensions for Chrome for when viewing the source?

    Posted: 26 Feb 2018 08:36 AM PST

    Sort an array and echo values out in descending order from a while loop?

    Posted: 26 Feb 2018 07:28 AM PST

    I have done research but cannot find an exact working method of doing this. I tried jquery plugins and of course following stack overflow solutions sort rows of HTML table that are called from MySQL I also tried asking stackoverflow....but you can imagine how that went.

    1) I query the two tables in the same database using inner join

     $sql = "SELECT users.empid, users.empfirst, users.emplast, prodata.monval, prodata.montar, prodata.tueval, prodata.tuetar, prodata.wedval, prodata.wedtar, prodata.thuval, prodata.thutar, prodata.frival, prodata.fritar FROM users INNER JOIN prodata ON users.empid = prodata.empid WHERE users.level = 2" ; $result = mysqli_query($db, $sql); // Set total variables to 0 for later use $totalscore = 0; $totaltarget = 0; 

    2) then I echo these values out into a basic table within a while loop and sum values for $totalscore & $totaltarget

     while($res = mysqli_fetch_array($result)) { //Add all echo "<tr>"; echo "<td>".$res['empid']."</td>"; echo "<td>".$res['empfirst']."</td>"; echo "<td>".$res['emplast']."</td>"; $totalscore = $res['monval'] + $res['tueval'] + $res['wedval'] + $res['thuval'] + $res['frival']; $totaltarget = $res['montar'] + $res['tuetar'] + $res['wedtar'] + $res['thutar'] + $res['fritar']; echo "<td>".$totalscore."</td>"; //Score total echo "<td>".$totaltarget."</td>"; //Target total } 

    How can I order the table contents to show in descending order, $totalscore (numeric)

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

    Looking for Ways to Visualize Large Amounts of Data.

    Posted: 26 Feb 2018 03:09 AM PST

    I am at the start of a programming project. The goal is to visulalize the interference of solar winds (the charged particles) with the earth's magnetosphere. I will write a Python programm for the calculation-part but I still need a way to make an earth-like model with the particle's paths depicted as lines. I will have large amounts of numbers (as in a spreadsheet) and I need to make either a 3d model or a 2d projection of the 3d model. I am looking for either a Python library that allows me as such or any other ways you can think of. Thank you and have a nice day!

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

    How do I create this database for web/mobile app?

    Posted: 26 Feb 2018 06:52 AM PST

    I'm trying to create nutrition progressive web/mobile app. The main focus of the app is that the user can select any recipe and it would be custom made for his body type and his fitness goal. How do I create an actual database that I can insert into my app, so a user can interact with it. Currently I am putting recipe info into excel sheets as seen in this picture: https://imgur.com/a/YGKWZ What are the next steps? Is it microsoft access, sql, other apps?

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

    quick question: find the length of integer starting with 0 without converting the integer to string first?

    Posted: 26 Feb 2018 05:58 AM PST

    title
    asking because log10 or while(n>0) n = n/10 only works for integers that isn't starting from 0

    edit: i should've asked this on /r/learnprogramming but i found this sub first so i guess i'll leave it here

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

    C# or Python as second language

    Posted: 25 Feb 2018 10:43 PM PST

    Hello, im need a help to choose one between C# or Python. Im tried both and both looks awesome.

    First, im not new in programming, now im work as Oracle developer and use only plsql in my work, no new opportunities in my company in near future. Im want to learn new language for my self, and may be for new work. As kid im learned and tried many languages so now im want a good, interest language that good supported and have a good future and im pick 2 variants: C# and Python, but cant decide to focus on one. Im check jobs and im have similar vacations on both languages.

    As interests, in learning im want to try various bots, some web technologies, work with .xls file(no data analysis, just read, create) , may be ML(but not sure, looks super hard), but also want to try GUI and Android development(but no focus on it). small amout of all.

    That you can advice to me? im know, this bad question, but im stuck in choosing that to pick( or that to pick first between this two).

    best regards.

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

    How do you integrate deep learning/AI to your programs?

    Posted: 25 Feb 2018 10:38 PM PST

    Hey, I'm curious about how simple or complicated is integrating machine learning to a program, specially in Java

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

    No comments:

    Post a Comment