• Breaking News

    Tuesday, January 9, 2018

    Sorting 3 variables without arrays Ask Programming

    Sorting 3 variables without arrays Ask Programming


    Sorting 3 variables without arrays

    Posted: 09 Jan 2018 09:31 PM PST

    This question is making me feel real stupid. Is it possible to do this without a lot of nested ifs?

    Given 3 variables a,b,c (e.g. a=30, b =20, c =10) updated their ranks (a_rank, b_rank, c_rank) so that the largest number has the rank 1 and the lowest 3. If two variables have the same amount then compare their alts (a_alt, b_alt, c_alt) such that the one with the higher alt is ranked higher (alts will not be the same.

    example

    a = 50

    b = 50

    c =10

    b_alt is greater than a_alt so it will be ranked higher

    a_alt = 10

    b_alt = 20

    c_alt = 5

    result

    a_rank = 2

    b_rank = 1

    c_rank = 3

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

    [Java] Help calling a method on every object inside of an ArrayList

    Posted: 09 Jan 2018 09:03 PM PST

    Hello! I don't know how to call a method on every object inside of an ArrayList when I'm iterating through it. I am trying to figure out the number of "living people" in a population using my method isAlive:

    public boolean isAlive(String n){ return isAlive; } 

    The variable isAlive is set to true when the program starts. I have this method so far for iterating through my ArrayList of people:

    public int peopleLiving(){ for(int i=0; i<list.size(); i++){ //size is the name of my ArrayList 

    This is what I have so far. If I try to do something like:

    list.get(i).isAlive 

    It tells me I have an illegal start of type. Please help!

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

    simplification mathematical expressions in sympy

    Posted: 09 Jan 2018 02:26 PM PST

    Hi everyone, I hope this isn't a repost (I don't think it is).

    I am a graduate student in mathematics who knows how to script in Python. I am working on a project where the calculations are getting out of hand (literally) and I'd like to utilize Python's sympy library as a supplement.

    After reading some of the Python documentation, it is clear to me that simplifying mathematical expressions is not as easy as one would think. However, I've come across an example that I think should be easy. Here is the example:

    from __future__ import division from sympy import * n = symbols('n') a = 1/(2*n) b = 0.5/n 

    Clearly a and b are equal for any value of n (except 0). So it is not surprising that

    a - b 

    returns the value 0. However, when I exponentiate these values before subtracting them,

    exp(a) - exp(b) 

    does not return the value 0. Rather, it returns the following:

    -exp(0.5/n) + exp(1/(2*n)) 

    I've tried lots of simplification commands, including

    simplify(exp(a) - exp(b)) 

    None of them work.

    What is going on here? How can I force exp(a) - exp(b) to be zero when a and b are equal?

    Thank you!

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

    Art Project. Visualize data from social media in creative way

    Posted: 09 Jan 2018 07:39 PM PST

    Basically I want to take data from social media and project/visualize it using LED's and a raspberry PI or something similar. I got the idea from here: http://emojitracker.com/ but translate the data in the form of assigned colors.

    Im trying to make a proof-of-concept for a submission for a show and been researching and cant find an answer. Any help would be appreciated

    submitted by /u/Lab-0X219
    [link] [comments]

    What's the easiest way to monetize an API?

    Posted: 09 Jan 2018 11:18 AM PST

    A colleague and I have developed an API that is fairly useful. In the short amount of time it has been published, it has been downloaded over 100 times. Comparable packages are out there that the commercial versions are well into the thousands of dollar price range. What's the easiest way we can monetize this? For what it's worth, it was built in the .NET core framework. We are also interested in keeping it open source for individual use but any commercial entities would need a license.

    I'm looking for a technical guide to a monetisation path. TIA

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

    Teaching at a coding bootcamp

    Posted: 09 Jan 2018 02:14 PM PST

    Has anyone worked as an instructor for a coding bootcamp? Mind sharing your experiences?

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

    Read coordinates from geography sql data type to SqlDataReader in C#

    Posted: 09 Jan 2018 05:59 PM PST

    iv searched around and iv seen you can acess the latitude with myGeography.Lat but it dosnt seem to work when tryin to read to sqldatareader, this is what im tryin

    String sql = "SELECT * FROM myTable WHERE myGeography.STDistance(geography::Point(somelatitude, somelongitude, 4326)) <somerange

    SqlDataReader reader reader = command.ExecuteReader()

    int lat,long

    lat = reader["myGeography.Lat"]

    long = reader["myGeography.Long"]

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

    What do you use to sync private projects between your computers?

    Posted: 09 Jan 2018 02:02 PM PST

    I have a laptop and a desktop computer that I use at home for little projects and was curious what people here use to sync their project files as they work on them

    I was thinking of using github but that would make all of my projects open to the public, and I'd have to figure out a way to automate pushing and pulling

    There's also Google Drive but I hate how it syncs files as soon as you make a small change, I'd rather have something where it syncs the files after I close my IDE

    I'm thinking I might use an external hard drive I have and hook it up to my router and just store everything on there instead of on the internet

    submitted by /u/hopeful-heart
    [link] [comments]

    HELP! Users talk in Implementation not Business Needs.

    Posted: 09 Jan 2018 11:49 AM PST

    I am looking for some advice in how to start a culture shift with our users.

    Background: I have been put in charge of an application whose users are all internal users managing the data of their programs. Once upon a time this application was in Oracle forms and they were essentially directly connected to the database and were making changes willy-nilly and had a very good grasp on the database structure. This resulted in requests coming to the programmers in charge of these forms in the form of implementation requests instead of business needs, i.e. "We need a 'has been printed' flag in the certificate table." These Oracle forms at some point were converted into an application with a flash front end with services that talked to the database. This created some uneasiness with the users since there was now a layer of code between them and the database and they felt they didn't have control anymore. Couple that with short staffing that made every fix for them a band-aid that only fixed part of the problem and the result is no trust in the programming staff and broken communication channels.

    The problem now: As I see it there needs to be a culture change to get the users to start talking in business needs and trust me to figure out the best implementation. I have an opportunity to take the time to fix the mess of business rules being scattered across the front-end, services, directly in the database itself, or not defined at all (my predecessor ran a number of scripts manually routinely to fix bad data the code was creating). However, the users see me as trying to take away what little control they have left. I have started gaining a little trust from some of the users just by showing them that I am not looking for band-aid solutions and permanently fixing some of their smaller frustrations and making sure they are involved in the process appropriately. Some of the trust wall has started tearing down but I need some bigger movements if this project is to move forward. It is also worth noting that I seem to have my supervisor's back. I had a brief conversation with him earlier and he said this isn't the first time he has heard this complaint from our team and wants to have a larger conversation on what our next steps are but I am not sure myself what the best next step should be!

    TLDR; My users talk in implementation and not business needs and I am looking for suggestions in how to start changing the conversations.

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

    My professor wants me to develop a mobile application which will be used for real-world purposes. Don't know where to begin.

    Posted: 09 Jan 2018 01:21 PM PST

    Just as the title says, I am currently doing research with a professor who wants me to develop a mobile application. To functionality of the mobile app is relatively simple: read in weather station / air quality monitoring data from a .csv file (may be hosted on a website) and display it in real-time to users. To top it all off, the mobile application will also display graphs about the data. All of the data that is displayed will be collected in real-time.

    The problem is, even though I have done much more complex programming (i.e., parallel processing to solve a PDE on a supercomputer), I do not know where to begin with such a task. Any advice or pointers would be appreciated! Thank you!

    I would prefer to do all of this with iOS as I am more familiar with it over Android.

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

    Shuffleboardscorenoard with vision tracking

    Posted: 09 Jan 2018 04:56 PM PST

    Our office has as shuffleboard. You could also apply this to outdoor shuffleboard or curling

    Players roll pucks down a wooden board. The one closest to edge scores. He gets points based on the zone they landed. He gets points in all that is closer to the edge than the closest one from the opponent

    We want the computer to automatically keep score. We would install one or multiple cameras. Either press a button or audio clue for the computer to use the camera sim, see where the pucks are, and calculate score.

    Anyone ever build such a thing? Not sure what technologies to use to architect a design. I'd love to hear any high level thoughts.

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

    What IDE do y'all recommend for a java developer looking to learn C# preferably, but really any of the C-family of languages?

    Posted: 09 Jan 2018 10:39 AM PST

    I use Eclipse pretty much exclusively these days. I've used Atom, which I like for webdev stuff. And a handful of smaller, feature-poor editors (textwrangler, e.g.). Is eclipse's C/C++ perspective my best bet?

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

    [java] Tial call Elimination

    Posted: 09 Jan 2018 11:40 AM PST

    how to achieve tail call Elimination in java.

    plz see : https://www.geeksforgeeks.org/tail-call-elimination/.

    from the above link

    QuickSort is also tail recursive (Note that MergeSort is not tail recursive, this is also one of the reason why QuickSort performs better).

    is this true for java too.

    I know that this true for C/C++ but is it in java too, and what are the reasons!!

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

    JS: How to WAIT for an element to appear, and then do something IN a loop

    Posted: 09 Jan 2018 02:57 PM PST

    This isn't the first time I've run into this issue, and after searching thoroughly, I've seen a lot of people with the same problem, but no solutions. I'm hoping for a magical API I've never heard of before, or maybe for someone to tell me I'm just plain-old doing it wrong. :-P

    I have a script that simulates a click on an element as the first action in a loop block.

    This causes a custom modal dialog to appear.

    Then I need to do some stuff to this dialog, followed by simulating a click on a button.

    for (day in daysOfWeek) { if (daysOfWeek.hasOwnProperty(day)) { daysOfWeek[day].click(); fillOutTime(dailyTimes); } } 

    Here, I'll simplify the code in fillOutTime and include it in the loop so you can sort of see what I'm doing:

    var day, submitButton; for (day in daysOfWeek) { if (daysOfWeek.hasOwnProperty(day)) { daysOfWeek[day].click(); //opens dialog //fill out some stuff submitButton = document.getElementById('time_entry_submit'); //get submit button submitButton.click(); //click the submit button } } 

    However, after the first click, there is apparently a delay where the dialog loads asynchronously.

    What I would like to be able to do, is to wait until this dialog appears, and THEN execute the rest of the code in the loop.


    Okay, here's what I've already tried:

    setTimeout() and setInterval() - These didn't work of course, because they're asynchronous, so the loop just carries on at hyper-speed queueing up these asynch events.

    A custom sleep function (see below). This just locks up the browser so the dialog doesn't start loading until it's done. I end up with the same problem, which is that the rest of the code still runs before it's loaded.

    function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds) { break; } } } 

    Any suggestions would be monumentally appreciated!

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

    help with restricting permission modifications for different users. PLEASE help

    Posted: 09 Jan 2018 01:24 PM PST

    I work in a contractor Java position and I have a programmer question. please help me figure out how to code from scratch for a test requirement that says that a workstation must "restrict modifications of software libraries to authorized roles as defined in the program directive." I have already looked at java.net library in the javadocs looking at permissions and such, but I have a long way to go. Specifically, I was thinking I need some sort of public void method that allows write permissions if a sysadmin, and just read an regular permissions if just a regular user logging on. Please help ??

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

    NLP: Agreeing/Disagreeing opinions

    Posted: 09 Jan 2018 01:23 PM PST

    I'm working on a project that involves analyzing Reddit comments, particularly parent child comments. I'm trying to figure out a method to determine whether a child comment agrees or disagrees with what the parent comment is stating. I.e. Parent: I think X is good. Child: I don't think X is good. A very simple example, but that's kind of what I'm trying to achieve in general. Does anyone have any areas I should be looking into? (Using Python and NLTK, but haven't found any obvious methods)

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

    2048 in Pygame

    Posted: 09 Jan 2018 12:07 PM PST

    I basically have 4 lists of length 4, where I play my game.

    So my question is. What is the best way to animate and display the results in Pygame?

    Should I just import the text based mode to a new file and try to display the numbers whit fonts and a grid in background?

    Or should I import my engine (where all the game features except the list displays are), to a new Pygame file, and work from there?

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

    Voxel 2D planets using noise function

    Posted: 09 Jan 2018 12:00 PM PST

    [Java] I need help figuring out what's going on in this code.

    Posted: 09 Jan 2018 11:33 AM PST

    int clr= image.getRGB(x,y); int red = (clr & 0x00ff0000) >> 16; int green = (clr & 0x0000ff00) >> 8; int blue = clr & 0x000000ff;

    So here's how I understand it.

    Line 1 assigns clr to an RGB value of the pixel located at x,y

    I don't understand Lines 2-4. For example in Line 2, I see int red is initialized but I don't understand it's assignment. Isn't "clr & 0x00ff0000" a Boolean value? Furthermore it is shifted ">>16"?

    Would someone please help me understand this block of code?

    Thank you in advance.

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

    Opinions on tech stack for inventory system

    Posted: 09 Jan 2018 08:42 AM PST

    Hello all,

    I'm developing a centralized inventory system that will take in data from various selling platforms (ebay, amazon, etc.), aggregate the date as well as update the data on each platform (keeping tabs on what has sold and whatnot) and store that information on my websites DB.

    I was hoping I could get some opinions on the best tech to use for this job. I'm currently on AWS, so I'd prefer if the tech was in the AWS wheelhouse.

    This is the stack that I was thinking about using:

    EC2 - Working Instance to make and requests Kinesis - to handle live feeds and processing of data Master/slave DB setup - as to not bog down the website

    All suggestions are appreciated

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

    Bit Twindling related.

    Posted: 09 Jan 2018 06:42 AM PST

     #include <iostream> using namespace std; int main(){ int v = -89; unsigned int r; int const mask = v >> sizeof(int) * 8 - 1; r = (v + mask) ^ mask; //this line cout << r << endl; } 

    This program abs the value but the line should first add one then flip the bits which should be incorrect but it is giving correct result, how? I am here following the basic arithematic rule of calculating what's inside the bracket first. refer

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

    Best laptop for programming?

    Posted: 09 Jan 2018 08:52 AM PST

    Hi,

    Forgive me if this sub is not the correct sub. I am a Rails / React developer. I have been using a MacBook Pro for the last 10 years to build software / web sites.

    My current Macbook is on it's last legs and before I just go and buy another Macbook Pro I wanted to see if anyone has opinions on a laptop that is better for programming? I do not mind installing Linux on the laptop as I develop on Linux when working from home on my desktop machine. The budget is $900 - $1000. I am not so concerned about GPU, obviously a semi decent one to display things good and support an external monitor. More concerned about CPU as I can upgrade RAM and SSD.

    Suggestions are welcome!

    Thanks

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

    What EXACTLY is the bug afflicting Intel processors?

    Posted: 09 Jan 2018 03:51 AM PST

    No comments:

    Post a Comment