• Breaking News

    Friday, November 2, 2018

    Storing prices as cents - benefits? Ask Programming

    Storing prices as cents - benefits? Ask Programming


    Storing prices as cents - benefits?

    Posted: 02 Nov 2018 08:46 AM PDT

    So I was looking at SO the other day and ran across an interesting example where the developer was storing the price of an item in a variable expressed as cents.

    Put another way, say the item was $2, he'd store the value as 200. If it was $32.99 the value would stored as 3299.

    I got to wondering why this would be done. Why not store it as a decimal or (at least for .NET) a MONEY type?

    As I dug into this on my own I learned that for SQL the storage size for an integer is 4 bytes and money or decimal is 8 bytes and 5 bytes respectively.

    So is this being done to save on storage size?

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

    Clean Code book - Appendix C

    Posted: 02 Nov 2018 11:20 AM PDT

    Hello,

    This is not related to programming, but does anyone knows how to read the appendix C of Clean Code book?

    I'm referring to this:

    https://www.oreilly.com/library/view/clean-code/9780136083238/images/f0410-01.jpg

    What do those numbers on the right mean?

    ----------------------------------------------------------------------------------------------------------------------

    Edit: solution can be found here http://user.engineering.uiowa.edu/~wwalls/clean_code_errata/

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

    Simple Java Question - Why is the answer 10?

    Posted: 02 Nov 2018 01:29 PM PDT

    I saw this question as an ad on Facebook and I'd thought I'd try to solve it, but I have no idea how the answer is 10. I know the loop sets the variable 'i' up to 9.

    int i; for (i = 0; i < 10; i++) {} int x = i; What is x? 
    submitted by /u/vehemoth94
    [link] [comments]

    Opening a pdf in another application from Assets folder (Android)

    Posted: 02 Nov 2018 11:44 AM PDT

    I know this has been answered multiple times, but none of the answers have worked for me.

    I've tried these solutions:

    how to open pdf file from assets folder

    Trying to open PDF file from assets folder using fileProvider but it gives FileNotFoundException: No such file or directory

    Read a pdf file from assets folder

    Trying to open pdf file Android

    https://gist.github.com/alhazmy13/c93c5e083ec0b7fe6d1c

    Many of these still use the no longer supported

    out = openFileOutput(file.getName(), Context.MODE_WORLD_READABLE); 

    which I have tired replacing with

    out = new BufferedOutputStream(new FileOutputStream(file)); 

    or

    out = openFileOutput(file.getName(), MODE_PRIVATE); 

    but none of those seem to do the trick. I consistently get a popup message that says "Cannot display PDF(correctfilename.pdf cannot be opened)."

    I also made sure to enable these in the manifest

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

    Is there anyway to open the file directly from AssetManager without copying the file to a new location? Is there a different way to use FileProvider to open this file?

    Any new angle on this issue would be appreciated, feeling thoroughly stumped.

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

    Anyone know of a good mock database for mongodb?

    Posted: 02 Nov 2018 08:23 AM PDT

    I am TA for an intro to databases course and my professor has asked me to plan a lecture and assignment on using mongo and I need a database for the students to work with. I have found a few generators online but I was wondering if anyone knew of a mock database before I spent a bunch of time with that. I know this isn't exactly programming related but I couldn't think of a better place to ask. Thanks for the help.

    Edit: Sorry I was unclear. I intend to have the students use mongo, I am looking for a dataset to use.

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

    Do I go to hell for this?

    Posted: 02 Nov 2018 01:30 PM PDT

    C# code:

    using System; using System.Text; struct Data { public int x; public string text; public byte[] postText; } class HelloWorld { static void Main(string[] args) { for (Data[] data = new Data[3] { new Data() { text = "Hello " }, new Data() { text = "Brave " }, new Data() { text = "New ", postText = Encoding.ASCII.GetBytes("World") } }; data[0].x < data.Length; data[0].x++) { Console.Write(data[data[0].x].text + ((data[0].x == 2) ? $"{Encoding.ASCII.GetString(data[2].postText)}\n" : "")); } } } 

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

    How to call a function within GLFW window using C++ ?

    Posted: 02 Nov 2018 11:54 AM PDT

    I have GLFW window, and I've defined a specific height, width , and title for it. Here's my GLFW window :

    GLFWwindow *window = glfwCreateWindow( WIDTH, HEIGHT, "Exercise 3" , nullptr, nullptr ); 

    And I want to call FPS in my window title. Side by side with my own title, like "Exercise 3.." | FPS.
    I came across FPS counter function with input parameter of time interval and window name, here :

    double calcFPS(double theTimeInterval = 1.0, string theWindowTitle = "NONE"){... 

    I can't seem to call the function from my main loop where I also created my GLFW window. When I call the function and replace the function input parameter (2nd parameter) using my own GLFW window, I get error :
    "No matching function for call to function",
    "Candidate function not viable: cannot convert argument of incomplete type * to string".
    Because the necessary input for the function is string, I'm a bit at loss about how to do that. Any suggestion ?

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

    Why is there no any legit courses[not books] about refactoring & debugging?

    Posted: 02 Nov 2018 10:03 AM PDT

    I wonder how such important topics have been overlooked?

    Tons of stuff about every language tiny details...front&back end etc.

    But no actual working with code, refactoring it etc.

    Do you know any?

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

    AngularJS: Content in ng-view Disappears when Drop-Down Navigation Menu Activated

    Posted: 02 Nov 2018 08:46 AM PDT

    So I made a StackOverflow post about this issue a few days ago, but it hasn't gotten any traction.

    I am new to AngularJS and am trying to create a Single Page Application. I have an ng-view that changes based on which route/controller is active. My problem is that I have made a separate controller for the navigation menu, and now whenever the menu button is clicked, all content in ng-view disappears.

    Can anyone tell me what I'm doing wrong?

    UPDATE: Wow. Less than 30 minutes after posting I found the solution on my own. Now I feel like an idiot.

    1. Switched from AngularJS 1.4 to latest version 1.7.5 (not sure why I was using 1.4....)
    2. Updated navigation links to be href="#!/..." instead of href="#/..."
    3. Removed href="#" from drop-down menu button (this was probably the root cause of my problem)
    submitted by /u/le_renard_rouge
    [link] [comments]

    Somewhat confused about SQL Schema-Users (using oracle sql developer)

    Posted: 02 Nov 2018 08:39 AM PDT

    So, as I understand it: A single user is tied to a schema and has a corresponding schema of the same name assigned to it.

    Starting out in sql developer, I create an initial connection as user SYSTEM with a password. Under this schema, is apparently where I create my actual user: e.g John w/password.

    Initially my intention was to create a new schema with this new user; but that doesn't seem to be possible as the created user is under the schema. If so, and if I will proceed with this, how does this work if I attempt to access the tables of "john" with my C# program?

    Do I identify the system user & password for my connection string or John's user & password. Or is it that I would need to first log-in to a schema than log-in again to subscribe to John's available tables. (?)

    Is this correct?

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

    How would I make this game?

    Posted: 02 Nov 2018 06:24 AM PDT

    Best native IDEs like atom or vs code

    Posted: 02 Nov 2018 03:19 AM PDT

    I really liked atom and vs code but they use electron which is not native and slower than Java's JVM.

    So I am looking for IDEs which runs native on Linux . Not IDEs based on electron or Java

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

    High Number of Credit Card Declines inside Braintree: Processor Response Code 2046

    Posted: 01 Nov 2018 09:56 PM PDT

    Hi I am experiencing a high number of credit card declines, about 87% percent of all my customers payments have been declined. Currently I am using braintree and have already contacted them to help solve my issue but they don't know what the problem is and have told me to contact my customers to have them contact their banks, which is ridiculous and not doable. Most of the declines codes are 2046 or 2038 all originating from different banks from all around the world. Which is why I am assuming that this has to be a global issue inside my account or within my code. But these codes are just a generic decline codes so it is hard for me to pinpoint what the issue is. [1]: https://i.stack.imgur.com/rFM80.png

    I have card verification enabled and CVV check. Also I have AVS verification but from what I have read this is mostly only applicable for US banks as many international banks don't support AVS check and 99% of all my customers payments are coming from international banks. Even with this my customers cards are being declined.

    I do have some payments going though and when testing with test cards and my own personal card it works. Although, my own card was working in the beginning it ended being declined as well for a while and when I called my bank they couldn't give me a reason to why it was being declined and had told me to contact the business responsible for making the charge which is me. They told me that it should be working. In order to test if something was wrong with the way my website is coded, I ended up making another website quickly on wordpress woocommerce that accepts braintree payments and after setting up I get the error "duplicate card exists in the vault" after trying to verify my own personal card inside braintree that was being decline earlier. So I deleted all instances of my card from the braintree vault and after doing this my card was able to be verified and was no longer being declined, although this time it had my address as well. So I am not sure if it was accepted because of my address or because I deleted my card from the vault. Right after doing this I tested my card on my original website and it was working again too without my address and just card number.

    If someone can provide insight into how banks process transactions and how braintree submits the credit card information to the banks to verify that would be helpful. I really think something is wrong with how my website is setup but don't really understand what this problem could be or how I can go about solving it.

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

    Java banking system project

    Posted: 02 Nov 2018 04:28 AM PDT

    Hello everyone, I'm working on a java banking system project and i was wondering what are the possible classes I could use? Note: i'm restricted to 6 classes only including inheritance. Thanks

    submitted by /u/3beer1919
    [link] [comments]

    Hello everyone i’m working on a banking system java project and i was wondering what are the possible classes i could use. Note: I’m restricted to 6 classes including inheritance. Thanks

    Posted: 02 Nov 2018 04:06 AM PDT

    No comments:

    Post a Comment