• Breaking News

    Wednesday, March 28, 2018

    What percent of of the code bases you have worked would you consider "good"? Ask Programming

    What percent of of the code bases you have worked would you consider "good"? Ask Programming


    What percent of of the code bases you have worked would you consider "good"?

    Posted: 28 Mar 2018 02:57 PM PDT

    Keep in mind that what is "good" to one programmer is *** **** to another.

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

    What route to take to become a digital nomad?

    Posted: 28 Mar 2018 03:54 PM PDT

    Hello guys,

    I have a good knowledge of Javascript and PHP but no real experience. I also know wordpress and some html/css and how to use pagebuilders to build websites, but honestly I'm not very gifted in designing.

    I'm a bit confused about how to get from here. I guess the fastest way to work remotely is to offer to build websites on fiverr ? But then I don't really advance in my PHP/Javascript skills.

    I know it's subjective but what would you recommend me to do? Or what questions should I ask myself? My main goal is to work remotely as fast as I can while developing my skills. I love programming more than designing websites, but not sure how to get a remote job without experience.

    Thanks a lot in advance!

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

    [Java] Extreme amount of flashing in Java game

    Posted: 28 Mar 2018 09:46 PM PDT

    https://ufile.io/q4lga

    That's the program "Game Main" is the main method. I've googled very hard but I'm struggling to fix my problem.

    Also the program lies. Press up to begin not space.

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

    Need an easy modification for an RPG Maker MV script call (maybe Java?) LESS THAN 10 LINES

    Posted: 28 Mar 2018 09:46 PM PDT

    Hey there,

    First of all sorry if this isn't the right place to ask, and even more sorry if this isn't Java. I'm working on an RPG Maker game but barely know anything about programming language, so yeah, I don't know what I'm doing. I'm having a lot of fun tho!

    https://pastebin.com/LVVHGkPJ

    This is what I need edited. Long story short, when the player presses UP or DOWN, they move in a direction. Instead I would like to have them look UP and DOWN instead of moving. It seems to be an easy modification to do.

    IF POSSIBLE, too, I would appreciate if you could shorten the lines to 10. That's the maximum lines the software can get but I've seen guys shrink so much code into a line I'm quite sure it shouldn't be an issue.

    Thanks for your time and if there's anything I can do to help, please tell me! Thanks a lot.

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

    HTML cannot find JavaScript function in <script>

    Posted: 28 Mar 2018 02:56 PM PDT

    I am attempting to make a button run a script called 'start', but whenever I choose to call it, if there is anything else other than the 'start' function, it'll say "Uncaught ReferenceError: start is not defined at HTMLButtonElement.onclick"

    Nothing I do seems to work, so I'm assuming I just don't know how to do functions in java. Can anybody help me out here?

    Excerpt of code:

    <body> <form onsubmit="start()"> translatearea = <input type="text" name = "textbox" value="Write here"><br> </form> <button onclick="start()">BUTTON</button> <script> function start(){ alert("START"); } static String readFile(String path, Charset encoding) throws IOException { byte[] encoded = Files.readAllBytes(Paths.get(path)); return new String(encoded, encoding); } </script> </body> 
    submitted by /u/lumps17
    [link] [comments]

    [mac terminal] When altering the info of a file, is it possible to find if I used terminal to make those changes?

    Posted: 28 Mar 2018 02:28 PM PDT

    I altered the 'creaated' date on one of my files. I'm wondering if it's possible for me to find the true date of creation or to find if I even altered the date in the first place.

    Thanks, heaps :)

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

    Need help understanding how I should use Dependency Inversion in my project

    Posted: 28 Mar 2018 07:24 PM PDT

    I have a project for work I'm writing in c++. To explain briefly, this project uses an infrared sensor connected to a raspberry pi to take measurements for tree fruit research to then put in a csv file and push to dropbox. My original version of the project had the higher level App wrapper class dependent directly upon the lower level driver for the sensor, namely, the MLX90614. After reading about Dependency Inversion and Dependency Injection, I thought I would apply this to my project for the next iteration. So in this case, App should only depend upon an ISensor interface which MLX90614 implements. This works to decouple the App class from the MLX90614 class, but this leads to another issue that I'm trying to figure out how to solve.

    The driver for the MLX90614 is extremely useful and can be re-used in multiple projects. I'd like to port it over to it's own separate package or repo, but the problem is if I do, I have to carry the interface library it depends on with it. This is problematic as these interfaces are really specific to the system I'm implementing and other people probably won't need to use them ever. So if this is the case, why package them together?

    The solution I came up with was to create a separate adapter class that would implement the ISensor interface and forward the MLX90614 functions to use. This way, the MLX90614 class is completely decoupled and not dependent on anything. But after reading it seems that adapters should only really ever be used in situations where interfaces are mismatched. So now I'm confused as to whether this is bad practice or not.

    Could anyone with more experience give me some tips?

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

    How different is linux from windows in therms of code and architecture?

    Posted: 28 Mar 2018 06:27 PM PDT

    My level of knoweldge in c# and java, just that, and not too far. If someone knows some good article that explains it will work too. The quetion is refered to the code and atchitecture, not the functionality.

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

    Need help on Assignment for C

    Posted: 28 Mar 2018 06:25 PM PDT

    Hi AskProgramming! I am writing a program that will output the total gross salary of an employee. I have most of the code down, but one part is stumping me.

    It's the Years of Service - The description says that for service from 0-10 Years, add 5% of the base pay to the salary calculation. That was no trouble.

    What I don't understand is the next part which says - For above 10 years of service, in addition to 5% of base pay, add 1% for each year above 10 years. Maximum service can only be 50 years. How do I write the code for that?

    Pastebin for that section: https://pastebin.com/rtZpeRu0

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

    Need help with a programming assignment

    Posted: 28 Mar 2018 06:09 PM PDT

    Hello all, the error I am getting is when the user enters a data point formatted the way I want(i.e. Jane Austen, 6) I get this error message:

    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 13 at java.lang.String.charAt(String.java:658) at DataVisualizer.main(DataVisualizer.java:64)

    import java.util.Scanner; import java.util.ArrayList; import java.io.*; public class DataVisualizer { public static void main(String[] args) { Scanner input = new Scanner(System.in); Scanner inSS = null; String title = ""; String col1 = ""; String col2 = ""; String data = ""; String dataString = ""; String dataInt = ""; String dataString2 = ""; int numCommas = 0; boolean keepGoing = true; System.out.println("Enter a title for the data:"); title = input.nextLine(); System.out.println("You entered: " + title); System.out.println(); System.out.println("Enter the column 1 header:"); col1 = input.nextLine(); System.out.println("You entered: " + col1); System.out.println(); System.out.println("Enter the column 2 header:"); col2 = input.nextLine(); System.out.println("You entered: " + col2); System.out.println(); do { System.out.println("Enter a data point (-1 to stop input):"); data = input.nextLine(); int comma = data.indexOf(','); int commaCount = 0; for (int i = 0; i < data.length() - 1; i++) { if (data.charAt(i) == ',') { commaCount = commaCount + 1; } } if (data.equals("-1")) { break; } else if (comma == -1) { System.out.println("Error: No comma in string."); System.out.println(); } else if (commaCount > 1) { System.out.println("Error: Too many commas in input."); System.out.println(); } else if (data.charAt(comma + 2) != '1' && data.charAt(comma + 2) != '2' && data.charAt(comma + 2) != '3' && data.charAt(comma + 2) != '4' && data.charAt(comma + 2) != '5' && data.charAt(comma + 2) != '6' && data.charAt(comma + 2) != '7' && data.charAt(comma + 2) != '8' && data.charAt(comma + 2) != '9') { System.out.println("Error: Comma not followed by an integer."); System.out.println(); } else { dataString = data.substring(0, comma).trim(); dataInt = data.substring(comma + 1).trim(); System.out.println("Data string: " + dataString); System.out.println("Data integer: " + dataInt); } }while (keepGoing); } } 
    submitted by /u/IICHASE55II
    [link] [comments]

    Looking for public database of SMS messages to train a NN..

    Posted: 28 Mar 2018 02:11 PM PDT

    Where can I find a public database of real SMS messages. Any suggestions would be appreciated.

    I saw the following study took place, but I can't find the actual data: https://www.forbes.com/sites/kashmirhill/2012/04/18/a-texas-universitys-mind-boggling-database-of-teens-daily-text-messages-emails-and-ims-over-four-years/#6eada8576a16

    Something like this would be appreciated

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

    [C#] Visual Basic - How do you find the batting average of players in an XML file (xml includes atBats and hits) using a linq statement

    Posted: 28 Mar 2018 05:46 PM PDT

    How to debug a program that speeds up after waking a computer from sleep?

    Posted: 28 Mar 2018 08:54 AM PDT

    I'm working on a Python project that uses PyBox2D (platform is Windows 10). As I understand it, PyBox2D is a Python wrapper for Box2D, which is written in C++, and that seems to be causing an issue that I've never come across before. The simulation usually runs fairly slowly, but I recently figured out that, for about 80 seconds after waking my computer from sleep, the program runs significantly faster. Then, for no apparent reason, the program slows down to its usual pace. The speedup occurs whether I start the program before or after putting the computer to sleep.

    I've done some preliminary benchmarking, which points to Box2D being the issue, but I'm not sure where to go from here. First of all, I checked Task Manager. When the program is running slowly, Python is using about 8% of the CPU. When the program is running quickly, it uses 25% (i.e. a full core) consistently. Then, I ran it through cProfile to see which functions were slowing things down.

    Here are the stats for the 5 most time consuming functions when the program is running normally/slowly:

     ncalls tottime percall cumtime percall filename:lineno(function) 900 69.894 0.078 69.894 0.078 {built-in method b2World_Step} 180000 4.644 0.000 8.252 0.000 layer.py:61(__Activate) 601088 3.636 0.000 3.636 0.000 {method 'normal' of 'mtrand.RandomState' objects} 1980000 3.278 0.000 4.366 0.000 functions.py:3(Sigmoid) 90000 2.921 0.000 6.439 0.000 outputLayer.py:13(Activate) 

    Here are the stats when the program is running quickly.

     ncalls tottime percall cumtime percall filename:lineno(function) 900 7.127 0.008 7.127 0.008 {built-in method b2World_Step} 180000 4.429 0.000 7.914 0.000 layer.py:61(__Activate) 601072 3.778 0.000 3.778 0.000 {method 'normal' of 'mtrand.RandomState' objects} 1980000 3.191 0.000 4.205 0.000 functions.py:3(Sigmoid) 90000 2.861 0.000 6.265 0.000 outputLayer.py:13(Activate) 

    Clearly, it's a problem with Box2D's World_Step method, but since it's a library that wraps C++ code I can't figure out what to do next. If it were just supposed to be slow, I'd be fine with that, but there's something wrong that is fixed by waking up the computer, and I want to figure out how to replicate that without actually putting the computer to sleep.

    Here are the relevant pieces of code:

    simulator.py

    from framework import (Framework, main) from Box2D import * class Simulator(Framework): name = "Simulator" experimentCount = 0 def __init__(self, showGraphics = True): self.showGraphics = showGraphics if(showGraphics): super(Simulator, self).__init__() else: self.world = b2World(gravity=(0, -10), doSleep=True) self.stepCount = 0 def Step(self, settings): if(self.showGraphics): super(Simulator, self).Step(settings) else: self.stepCount += 1 self.world.Step(1 / settings.hz, settings.velocityIterations, settings.positionIterations) self.world.ClearForces() if __name__ == "__main__": main(Simulator) 

    main.py

    from simulator import Simulator import framework import physicsSettings from learningSettings import learningSettings import cProfile def test(): simulator = Simulator(False) while(True): simulator.Step(physicsSettings.fwSettings) if(learningSettings.useGraphics): framework.main(Simulator) else: cProfile.runctx('test()', globals(), locals(), 'profileResults1.pstats') 
    submitted by /u/iceman012
    [link] [comments]

    Looking for software to help manage filesystem

    Posted: 28 Mar 2018 12:13 PM PDT

    Hello, I am currently studying CS and I've been looking at many different youtube videso to learn more and see how others think/problem solve while programming and doing all this I noticed that I have so many different languages, applications, etc installed and it annoys me that my file-system is so "messy".

    I've been using virtual machines to fix this, where I create a new machine and thereby keep everything tidy, but it is slow to create / start up a new VM every time and also it eats up hard disk storage.

    I've come across docker and I really like it, however I was wondering if there was something like docker but "bigger" with GUI almost like a VM / Vagrant.

    It's hard for me to explain, but I guess the closes thing I can come up with is "git branches" for the OS. So I'd create a new branch and there I could install new languages and applications, manages and whatever I want, and the other files from other languages would be "hidden" from me. Does this make sense? Is there any software that does this?

    For example, folders and subfolders would work well for scripts/files, but I want to do this with entire applications. So I could try installing node.js and p5js and Atom (or whatever) and have a clean "branch" to work on and if I don't like it I could just delete the branch and all related files would be deleted / uninstalled.

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

    Sending data larger than a singed byte over UDP in Java

    Posted: 28 Mar 2018 11:42 AM PDT

    We are working on an app for Android that communicates with a device in GDL90 protocol over a UDP connection. The problem is that the data we need to send can often be larger than a signed byte, the device is already set up to communicate with our iOS app that sends data in unsigned bytes and unsigned chars.

    We currently have the UDP connection set up with a DatagramPacket datatype but this requires a byte in the constructor, so since Java datatypes ate always Two's Complement I only have 7-bits to send the data and I really need 8-bits. I thought of the following solutions:

    1. Manually write over the sign bit of the byte if with a 1 or a 0 depending on if the value is greater than 128, can I do this and just change the sign bit to whatever the device expects the data to look like as a unsigned number

    2. Send data through another data type than DatagramPacket. Do I have any other options?

    Thanks for reading, any advice or thoughts on approaching this issue from another angle would be appreciated. Relatively new to programming "professionally", Java, and especially Android.

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

    Cannot play MPEG-Dash stream in Kodi

    Posted: 28 Mar 2018 10:41 AM PDT

    Hi, I am working on a project where I need to stream an MPEG-Dash stream(.mpd) using Kodi. I am new to Kodi and found that the inputstream adaptive is only available in the windows version. I am using windows 10 and I enabled inputstream adaptive and RTMP in Kodi. However if it try to run a .mpd file or a .strm file using kodi if shows the message "Cannot find next item to play". Please tell me how to fix this problem in kodi or can I use any other player or open source set top box software that can do the same?

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

    Programming Hub app. Is it good?

    Posted: 28 Mar 2018 02:10 PM PDT

    Hi! I'm looking on expanding my novice knowledge of programming and I stumbled upon that app. The reviews are good and the subscription is on sale now so I'm really considering buying it but I don't know if it is worthy the money. Does anyone here uses it? Can you tell me if it is worth the investment?

    Thank you!

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

    How do I make buttons go to links when clicked on in HTML?

    Posted: 28 Mar 2018 10:22 AM PDT

    I made some buttons but I don't know how to code them so they redirect you to another webpage when clicked on.

    Here's what I currently have on NotePad++ copied and pasted onto a google doc

    And here's a picture of what my webpage looks like when run in chrome

    submitted by /u/clorox-peach
    [link] [comments]

    Strange compilation errors using Lombok with IntelliJ

    Posted: 28 Mar 2018 07:38 AM PDT

    We have an application using Sprint Boot with Ivy for dependency management. We use IntelliJ as our IDE.

    First, the app compiles without errors. However, we're getting "compilation errors" (quoted because they look like compilation errors in the IDE but the app still compiles) such as "cannot resolve symbol" and "cannot resolve method" when it comes to trying to access getters/setters/etc created with Lombok.

    Here's some addition info:

    • @Data works - no compilation error
    • Lombok doesn't show up under Settings -> Plugins
    • lombok-1.16.10.jar is in the lib folder
    • It is listed as a dependency in the ivy.xml file
    • Annotation processing is enabled
    • Downloading the plugin itself is not an option on our network

    If anyone has any ideas we're all ears. Thanks!

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

    How to add a study below a stock?

    Posted: 28 Mar 2018 10:34 AM PDT

    Many stock trading platforms have these things called "studies" that appear below the stock chart and scale with it. I would like to embed a stock chart and a study below it in a website. There are various languages used for stock charts, and the simplest seems to be javascript. Other languages are welcome. How to make a study scale with a stock chart?

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

    What exactly is the 'NEW' keyword in SQL?

    Posted: 28 Mar 2018 12:56 AM PDT

    I was trying to input a query into my database that allows it to copy value off multiple fields in one table and putting it into another field in another table.

    I tried doing this :

    CREATE TRIGGER inquirypg AFTER INSERT ON purchase FOR EACH ROW IF purchase.ServiceTypeId = '4' THEN INSERT INTO switching.inquiry (TrxId, OrderId, ClientId, MerchantId, SubscriberNumber, BillerId, ProductCode, BillerProductCode, VendorBillerId, InquiryReceivedTime, InquirySubmitTime, dateCreated) VALUES (purchase.TrxId, purchase.OrderId, purchase.ClientId, purchase.MerchantId, purchase.SubscriberNumber, purchase.BillerId, purchase.ProductCode, purchase.BillerProductCode, purchase.VendorBillerId, NOW(), NOW(), purchase.DateCreated); END IF; 

    The code compiles without an error, but when i insert a value into the purchase table, Error 1109 (Unknown table 'purchase' in field list) occurred

    Then i change my code to this :

    CREATE TRIGGER inquirypg AFTER INSERT ON purchase FOR EACH ROW IF NEW.ServiceTypeId = '4' THEN INSERT INTO switching.inquiry (TrxId, OrderId, ClientId, MerchantId, SubscriberNumber, BillerId, ProductCode, BillerProductCode, VendorBillerId, InquiryReceivedTime, InquirySubmitTime, dateCreated) VALUES (NEW.TrxId, NEW.OrderId, NEW.ClientId, NEW.MerchantId, NEW.SubscriberNumber, NEW.BillerId, NEW.ProductCode, NEW.BillerProductCode, NEW.VendorBillerId, NOW(), NOW(), NEW.DateCreated); END IF; 

    And for some reason, it works.

    My question is, what exactly does the NEW keyword do? Shouldn't my code runs just fine if i substitute NEW with the name of the table?

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

    C++ help regarding arrays

    Posted: 28 Mar 2018 07:32 AM PDT

    Hello, i've been trying to get the size of a string entered by user into a character array and i've been trying to use strlen() but it keeps on giving me error! Although I've included the header <cstring> so whats the problem please help! Thanks

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

    PHP setting a counter.. How?

    Posted: 28 Mar 2018 01:00 AM PDT

    Hey fellow Programmer, I want to make a 'counter' that is calculated to from the current time and from the deadline '12:00 am'.. But by the love of php I can´t find a way. Additionally it should be always updating without load the wholse site new. Thank you!

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

    No comments:

    Post a Comment