• Breaking News

    Sunday, November 11, 2018

    Somebody stop me, I'm going to roll my own database Ask Programming

    Somebody stop me, I'm going to roll my own database Ask Programming


    Somebody stop me, I'm going to roll my own database

    Posted: 11 Nov 2018 04:41 PM PST

    I had this idea to make a relational database out of CSVs using Rust as an experiment to learn more about databases. I'm dangerously close to actually starting this project.

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

    C++ Code::Blocks Linking Issues

    Posted: 11 Nov 2018 01:57 PM PST

    I've been following a tutorial to write a simple 2D game engine and have run into a problem I can't solve. After having spent hours googling fruitlessly I turn to you in desperation.

    I am using Code::Blocks to work on this project and have run into what I think is some kind of linking error. I am getting an "undefined reference" message for my TextureManager::draw() function. The screenshots of my linker and compiler settings as well as the Build error messages I get can be found here.

    The project code is up on my GitHub. The primary files of concern are Map.cpp, TextureManager.cpp, and their associated header files.

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

    How do I make this Med. Calculator?

    Posted: 11 Nov 2018 01:05 PM PST

    https://docs.google.com/spreadsheets/d/1OJWhXkyAKAENJHxDJRvXP4q2IzN_LP_yOv8R4ogM0qk/edit?usp=sharing

    Someone made this Google spreadsheet for me to have an easily presentable idea to a programmer.

    I want to put in like 1oz of oral solution, and it tell me how many mgs that is of both Ingredient A and Ingredient B, and then also how many tablets it'd take to reach the aspired dose with the tablet dose I put in. Sometimes tablet mgs may be different. I've had to do mental math a million times in the past years for this stuff and always wanted something like this and now I have to make it.

    it is just for personal use/can maybe be released to help others.

    also sometimes there's medical alcohol added so I need to put in a variable or something for the % of the alcohol inside the oral solution and also maybe a variable for the alcohol % that the alcohol is.

    (oral solution for those who don't know is kinda like a syrup)

    I am no artist but I made a rough design idea of what it could look like (to start, I failed to finish, I started it like a week or two ago) https://imgur.com/a/EHRksy3

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

    Program a mouse to change its led colors?

    Posted: 11 Nov 2018 11:17 AM PST

    I've got a mouse that's advertised to be "programmable" called easterntimes tech t7 mouse. It has a "breathing" color effect lighting and the color changes when you change its DPI. How can I write a script to change its color without changing the DPI or even change the "breathing" effect?

    I'm pretty familiar with programming, but never wrote scripts in this context

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

    Can I some for-dummies examples that violate the Liskov Substitution Principle?

    Posted: 11 Nov 2018 01:17 PM PST

    PCIE LED controller and RAM LED controller

    Posted: 11 Nov 2018 08:10 PM PST

    I have some ram and and GPU with LEDs on them. I would like to change the colors on them with having to boot into windows and then changing the colors in windows only software. Does anyone know of anything I could use to reverce engineer the led changing software to custom make my own led controller for Linux?

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

    C: Issue with scanf when passing a struct into a set function as address

    Posted: 11 Nov 2018 03:01 PM PST

    Here are the structures and functions used:

    struct Employee{

    int empNum;

    }

    struct Company{

    struct Employee employee;

    }

    setName(struct Employee *employee){

    scanf("%d", &employee->empNum);

    }

    Main:

    struct Company company;

    setName(&company.employee)

    My question is why do I need to use & on employee->empNum in the scanf in setName when I'm already passing the struct as a refence into setName in main?

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

    How to program excel vba app to generate pdf documents from its database?

    Posted: 11 Nov 2018 10:19 AM PST

    Hello, I am a personal trainer and due to higher demand I was looking for a way to make and distribute my meal plans more easily and time efficiently.

    https://imgur.com/vO7Mhws

    As you can see from the picture this is the format that I am writing my recipes into excel database. Each recipe contains different amount of ingredients based on my clients bodyweight and other variants.

    https://imgur.com/0CRYlf6

    In the second picture i made an app user interface design for me as a trainer to automatically generate a meal plan based on my clients food preferences and other factors such as if they want to have no fish in their meal plan, their allergies, they want to eat more than 4 or 5 meals per day, if they want me to include protein shakes into their diet and etc.

    Is this app possible with my current database layout and naming system, also how much would this project cost for me to outsource to a vba developer and do you have any suggestions.

    Ideallly, I want this to be a separate app, but i guess that would cost too much.

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

    Help on JavaScript DOM creating number of divs and changing color and size based on user input

    Posted: 11 Nov 2018 05:33 PM PST

    Hello, I have a problem creating a script where a user inputs the number of desired boxes to be displayed and which color and then it is displayed in the output div.

    So the output div's size is also determined by the user. And the user is allowed to input a number of output color boxes from -5 to 5. If the number of boxes is negative the boxes should be displayed vertically, if positive than horizontally.

    Expected result: https://imgur.com/a/CVJEOMI

    I found some old Quora thread suggesting using an array. This is what I could come up with but its not recognizing the Id and is returning undefined.

    function updateColorChoosers() { const new_num = Math.abs(parseInt(document.querySelector('#num_colors').value)); const container = document.querySelector('#colors_container'); let newHtml = ''; for (let i = 0; i < new_num; i++) { newHtml += '<div class="subrow">\ <label for="color_sel' + i + '">Color #' + (i + 1) + '</label>\ <input id="color_sel' + i + '" type="color"/>\ </div>'; } container.innerHTML = newHtml; } document.querySelector('#num_colors').addEventListener('input', updateColorChoosers); function changeColors() { var myNode = document.getElementById("result"); while (myNode.firstChild) { myNode.removeChild(myNode.firstChild); } var count = parseInt(document.querySelector('#num_colors').value); const height_input = document.querySelector('#height').value; const width_input = document.querySelector('#width').value; var resultDiv = document.querySelector('#result'); var color_input; var array = []; var results = []; for (var i = 0; i < Math.abs(count); i++) { results[i] = document.createElement('div'); array[i] = '#div' + i; results[i].id = 'div' + i; results[i].classList.add("result_row"); //results.innerHTML = array[i]; resultDiv.appendChild(results[i]); var colorId = "#color_sel" + i; var color_input = document.querySelector(colorId).value; const myDiv = document.querySelector(array[i]); myDiv.style.backgroundColor = color_input; if (count > 0) { results[i].style.height = (height_input/Math.abs(count)) + "px"; } else { results[i].style.width = (width_input/Math.abs(count)) + "px"; } } } document.querySelector('#colors_btn').addEventListener('click', changeColors); 

    relevant .html

    <div class="container"> <div class="column"> <div class="row"> <h2>Size</h2> <div class="subrow"> <label for="height">Height (in px.)</label> <input id="height" type="number" min="100" max="800" step="1" value="200"/> </div> <div class="subrow"> <label for="width">Width (in px.)</label> <input id="width" type="number" min="100" max="800" step="1" value="200"/> </div> <div class="subrow"> <input id="size_btn" type="button" value="Change Size"/> </div> </div> <div class="row"> <h2>Colors</h2> <div class="subrow"> <label for="num_colors">Number of colors -(1-5)</label> <input id="num_colors" type="number" min="-5" max="5" step="1" value="1"/> </div> <div id="colors_container" class="subrow"> <div class="subrow"> <label for="color_sel0">Color #1</label> <input id="color_sel0" type="color" value="#ffffff"/> </div> </div> <div class="subrow"> <input id="colors_btn" type="button" value="Change Colors"/> </div> </div> <div class="row"> <h2>Border</h2> </div> </div> <div id="result-container" class="column"> <div id="result"> <div class="result_row"/> </div> </div> </div> 

    I don't why for the life of me I can't figure it out. Any help would be much appreciated, thanks!

    EDIT: I was able to manage to get the script behaving half correctly! it will behave properly only for positive values, displaying the color boxes horizontally. When using negatives the boxes are stacked under each other rather than next to each other!

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

    Programming in a SSD and the SSD's durability

    Posted: 11 Nov 2018 08:31 AM PST

    Hello,

    I'm planning on buying a SSD to upgrade my computer, but I've read that SSDs normally have a problem with extensive write operations, which could degrade their durability/performance and since during compilation and deployments there is extensive writing operations, I thought it could be a problem. So, question is: should I install my OS (Windows) and my IDE (Visual Studio 2017) in the SSD but keep the projects in my HDD to prevent the SSD degradation?

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

    Java Problem

    Posted: 11 Nov 2018 12:40 PM PST

    Hi, I am stuck on a problem that requires me to come up with a way to calculate the largest side perimeters of different shapes. I am kind of confused on how to even start with it tbh.

    This is some of the code.

    public class PerimeterAssignmentRunner {

    public double getPerimeter (Shape s) {

    double totalPerim = 0.0;

    Point prevPt = s.getLastPoint();

    for (Point currPt : s.getPoints()) {

    double currDist = prevPt.distance(currPt);

    totalPerim = totalPerim + currDist;

    prevPt = currPt;

    }

    // totalPerim is the answer

    return totalPerim;

    }

    The package was provided with points given in another file (don't know the exact the terminology).

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

    Lighthouse Labs vs Lewagon vs DeCode comparison

    Posted: 11 Nov 2018 04:09 PM PST

    Need help with code decimals points are off

    Posted: 11 Nov 2018 03:43 PM PST

    #include <iostream>

    #include <cmath>

    #include <iomanip>

    using namespace std;

    //

    // Function declarations

    double readFutureValue();

    double readInterestRate();

    int readNoOfYears();

    double calculatePresentValue(double futureValue, double interestRate, int noOfyears);

    // main function

    int main()

    {

    // Declaring variables

    double presentValue, futureValue, interestRate;

    int noOfyears;

    // calling the functions

    futureValue = readFutureValue();

    interestRate = readInterestRate();

    noOfyears = readNoOfYears();

    // calling the function by passing the result values of each function

    presentValue = calculatePresentValue(futureValue, interestRate, noOfyears);

    // Displaying the output

    cout << "\nPresent value: $" << std::setprecision(2) << std::fixed << presentValue << endl;

    cout << "Future value: $" << std::setprecision(2) << std::fixed << futureValue << endl;

    cout << "Annual interest rate: " << std::setprecision(1) << std::fixed << interestRate << "%"

    << endl;

    cout << "Years: " << noOfyears << endl;

    return 0;

    }

    // This function will read the valid future value

    double readFutureValue()

    {

    double futureVal;

    while (true)

    {

    cout << "Enter Future value :";

    cin >> futureVal;

    if (futureVal <= 0)

    {

    cout << "The Future value mmust be greater than zero" << endl;

    continue;

    }

    else

    {

    break;

    }

    }

    return futureVal;

    }

    // This function will read the valid annual interest rate

    double readInterestRate()

    {

    double interestRate;

    while (true)

    {

    cout << "Enter annual interest rate :";

    cin >> interestRate;

    if (interestRate <= 0)

    {

    cout << "The annual interest rate must be greater than zero" << endl;

    continue;

    }

    else

    {

    break;

    }

    }

    return interestRate;

    }

    // This function will read the valid no of years

    int readNoOfYears()

    {

    int years;

    while (true)

    {

    cout << "Enter number of years :";

    cin >> years;

    if (years <= 0)

    {

    cout << "The number of years must be greater than zero" << endl;

    continue;

    }

    else

    {

    break;

    }

    }

    return years;

    }

    // This function will calculate the present value

    double calculatePresentValue(double futureValue, double interestRate, int noOfyears)

    {

    double r = (interestRate / 100);

    //finalVal

    return (futureValue) / double(pow((1 + r), noOfyears));

    }

    this is my code and this is one of the errors im getting in c++ visual studios 2017

    Calling function calculatePresentValue The call to calculatePresentValue(22000.00, 0.01, 10) returned an unexpected value of 21980.21

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

    Boothcamps: LeWagon versus Lighthouse labs versus DeCode. How to choose?

    Posted: 11 Nov 2018 03:32 PM PST

    is using blank space between 'if' statements and variable declaration bad ?

    Posted: 11 Nov 2018 04:01 AM PST

    hello everyone, i appreciate the help on the last post ! i have a question thats in the topic and another one - multiplication and questionOne functions give a warning "not all control paths return a value". do i really HAVE to put in return 0; there or is it not mandatory ? (i dont want to because it makes the code clearer for me)thank you in advance!

    #include "pch.h" #include <Windows.h> #include <stdio.h> #include <math.h> #include <iostream> #include <iomanip> #include <cmath> #include <string> #include <algorithm> using namespace std; double multiplication (double firstNumber, double secondNumber, double thirdNumber, double fourthNumber) { cout << "--------------------------------------------------------------------------------------------------------\n"; if (firstNumber*secondNumber > thirdNumber*fourthNumber) { cout << "The greatest result is from the first pair, it is "; return firstNumber * secondNumber; } if (thirdNumber*fourthNumber > firstNumber*secondNumber) { cout << "The greatest result is from the second pair : "; return thirdNumber * fourthNumber; } if (firstNumber*secondNumber == thirdNumber*fourthNumber) { cout << "They're equal : "; return firstNumber*secondNumber; } } int questionOne() { cout << "--------------------------------------------------------------------------------------------------------\n"; string answerOne, answerOneTemp; cout << "Would you like to try again? (Yes/No)\n"; cout << "My answer is "; cin >> answerOne; answerOneTemp = answerOne; cout << "--------------------------------------------------------------------------------------------------------\n"; transform(answerOne.begin(), answerOne.end(), answerOne.begin(), toupper); if (answerOne == "YES") { cout << "OK, let's start from the beginning.\n"; return 1; } if (answerOne == "NO") { return 0; } if (answerOne != "YES" && answerOne != "NO") { system("cls"); cout << "The answer - " << answerOneTemp << " - is incorrect.\n"; cout << "Please type it in properly.\n"; questionOne(); } } void inputtingVariables() { double firstNumber, secondNumber, thirdNumber, fourthNumber, greaterResult; cout << "Type in four variables. They will get multiplied with their pair (first with second & third with fourth).\n"; cout << "--------------------------------------------------------------------------------------------------------\n"; cout << "Pair #1 :\n"; cin >> firstNumber >> secondNumber; cout << "\nPair #2 :\n"; cin >> thirdNumber >> fourthNumber; greaterResult = multiplication(firstNumber, secondNumber, thirdNumber, fourthNumber); // function call. cout << fixed << greaterResult << ".\n"; cout << "Or, alternatively, this is the scientific version of the result : " << scientific << greaterResult << ".\n"; } int main() { int programShouldContinue; system("cls"); inputtingVariables(); programShouldContinue = questionOne(); if (programShouldContinue == 1) { main(); } if (programShouldContinue != 1) { cout << "End of the application, thank you for using it!\n"; } return 0; } 

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

    HELP! Simple code fix that would help me out a lot!

    Posted: 11 Nov 2018 11:22 AM PST

    I have some code, the code displays a progress bar on the checkout page. Image is below to illustrate it.

    https://imgur.com/a/kGd0QSr

    The issue is:

    1) - When you are on the payment stage and you click on 'return to shipping information', it resets to the first stage of the progress bar.

    2) - I have set up a 'abandoned cart email', the customer is presented with an opportunity to 'return to checkout' and complete their purchase for a discount however, the progress bar is reset completely back to 'customer' and it may confuse the customer.

    The code is as follows:

    https://pastebin.com/tjCPKuKW

    Appreciate any help, thank you all and have a great day ahead.

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

    Never used HTML before

    Posted: 11 Nov 2018 12:43 PM PST

    I want to create a web based program that will take inputs and produce and output. Is that possible with HTML? I really like the fact that you can add text box inputs and some basic graphic user interface unlike C++ which is line by line user input. I've done a little research on HTML and it looks like you can put words in input boxes but can it incorporate an algorithm/code that uses the user inputs? Any help would be nice, thanks.

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

    JPEG compression pseudocode?

    Posted: 11 Nov 2018 08:51 AM PST

    I hope this is the right place for this. I'm looking for a pseudocode or tutorial implementation of the JPEG compression algorithm.

    I've found a lot of technical documents and plenty of libraries but both are kind of too involved.

    I just want to know how it works, what it's doing to the pixel values etc.

    Does anyone know the best resource for this?

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

    What type of questions would a client ask about APIs?

    Posted: 11 Nov 2018 04:26 AM PST

    Hi all, basically I work helping out a technology business, the problem is my manager has been given the job of "selling" parts of the business, as in liasing with customers in aspects of the business such as technology solutions and things like that.

    Now one thing we do is host data and have APIs available both for customers and for the average joe (public APIs). There has been a business need to start charging for this, and I basically had to do a big stint of creating a model on charging for APIs (which are basically done on a per call basis).

    I have some basic understanding about how it works liasing with the devs but basically my manager doesn't understand a lot of it and is essentially hoping I can help him out. The better option would have a dev involved but for some reason they refuse to (we have a very difficult company culture) but I can ask them certain questions.

    So I was hoping to get a good idea on certain aspects a client might ask about so I know when I talk to them what I should at least know. I understand the basics but i assume they won't be asking me about basics, I'm thinking its more likely things like pricing, lambda?, support?, is there really much else? Storage? Location of data? Docker? Security?

    Thanks so much for any thoughts at all, would be super helpful.

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

    Python list out of range print

    Posted: 11 Nov 2018 06:46 AM PST

    Let's say I have a list like:

    List1 = [item1, item2, item3, item4]

    But I need to print X elements from this list, so that if X = 6, it prints the whole list and then item1 and item2.

    Thanks for your help

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

    How much of an array do you need to shuffle in order for the user to think it's shuffled?

    Posted: 11 Nov 2018 08:11 AM PST

    I thought of this question out of curiosity after writing the basic shuffle algorithm of iterating through the array and 1) choosing a random index in the array, 2) swapping the element at the current index with the random one.

    And it occurred to me that you need to swap a lot less elements for it to look like it's random (probably something like ~70 %).

    So how much of an array is shuffled in real products where same as in this algorithm you don't need to go through all of the elements for it to look shuffled?

    Products such as spotify playlists (I remember they made an article about user complaints not looking random enough since they used a very random algorithm), not of course encryption algorithms or similar.

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

    [Android/Architecture] ELI5: what should live in ViewModel and what should live in Use Case?

    Posted: 11 Nov 2018 06:50 AM PST

    I am implementing an app with proper MVVM architecture for the first time, and I saw a bunch of medium articles on what use case/interactor is, but a lot of them have really simple use case of use case, and I still don't get what should live in ViewModel, and what should live in use case.

    Thanks in advance!

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

    Suggest a way to implement something easily in kotlin which can be done easily by json in web

    Posted: 11 Nov 2018 06:40 AM PST

    So i have to submit a quiz app in college in 2 days. I'm more to a web guy JavaScript is my fav.

    so what i need is what the most suitable way to store multiple choice question and its answer to use in kotlin for android app. If i was making an web app best was solution was to store as JSON and i want my data to be stored as something like this : https://api.myjson.com/bins/yvpny

    and i have thought of a way to make question and answer order to be random.

    Just need a good way to store it as i only have 2 days and json handling using library in kotlin seems confusing.

    Suggest me what should i do? I have everything else ready my app have all ui elements ready login, signup , score keeping etc.

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

    Think like Programmer / recommendation / HELP

    Posted: 11 Nov 2018 02:20 AM PST

    Hi guys!

    I was wondering what sort of sources would you recommend me in the theme of programming thinking, like this video:

    https://www.youtube.com/watch?v=azcrPFhaY9k&t=4s

    Or like this book which looks promising and was recommended by Quincy Larson (but unfortunately haven't got the time yet to read it:

    https://www.amazon.com/Algorithms-Live-Computer-Science-Decisions/dp/1627790365

    (My main aim is to write a paper comparing lawyer's and programmer's thinking approach - I can code JS)

    Thank you!

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

    No comments:

    Post a Comment