• Breaking News

    Thursday, December 10, 2020

    Might be a dumb question, but when you're compiling code, when you call the compiler on your terminal, is that itself a runnable file? Ask Programming

    Might be a dumb question, but when you're compiling code, when you call the compiler on your terminal, is that itself a runnable file? Ask Programming


    Might be a dumb question, but when you're compiling code, when you call the compiler on your terminal, is that itself a runnable file?

    Posted: 10 Dec 2020 09:29 PM PST

    So I know that the typical process is something like this on the terminal (example will be c++): g++ -o program program.cpp.

    So I get that the -o flag creates an object file for the linker, which then in turns makes allows an executable to be created (in our case it would create a file called program.o object file and an executable called program).

    So... what is happening when we call gcc. Is this itself an executable or what exactly is happening behind the scenes when we call this?

    I know that it's a command like grep or diff or ls (at least in a UNIX system). But like... what is going on behind the scenes? Does the compiler itself have an executable and g++ is just an alias to call that executable?

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

    How a service can give a subdomain to each user?

    Posted: 10 Dec 2020 02:47 PM PST

    When I was a teenager, I was surprised how blogger or other blogging services like wordpress allow you to have a subdomain. I experienced a lot and found some CMS's have their tricks to create some sort of "network" (Specially wordpress, it's called wordpress network if I'm right).

    But recently, I saw it's not only done by blogging services, but by PaaS, SaaS or DBaaS services as well. I am really curious about this. How can I make a web app I developed make a subdomain for each user?

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

    Javascript help with Password Generator

    Posted: 10 Dec 2020 06:08 PM PST

    I'm very new to coding and need some help finishing my first javascript assignment: creating a password of varying characters (uppercase, lowercase, numerical, and special) to a length defined by the user between 8-128 characters. All prompts and confirms run great, but I cannot get the actual password to generate in the text box!

    Any help with this would be greatly appreciated.

    var generateBtn = document.querySelector("#generate");

    var lowercaseChar = "abcdefghijklmnopqrstuvwxyz";
    var uppercaseChar = "ABCDEFGHIJKLMNOPQRSTUZWXYZ";
    var numericalChar = "0123456789";
    var specialChar = "!#$%&'()*+-./:;<=>?@[\^_`{|}~";

    function generatePassword() {
    var password = "";
    var passwordChar = "";
    // creates user prompt to select password length
    var passwordLengthUser = prompt("How many characters would you like your password to be? Password must be between 8-128 characters.");
    passwordLengthUser = parseInt(passwordLengthUser);
    if (passwordLengthUser < 8) {
    alert("Password must have more than 7 characters!");
    return "";
    }
    if (passwordLengthUser > 128) {
    alert("Password much not have more than 128 characters!");
    return ""
    }
    // creates confirm boolean for lowercase "yes or no"
    var lowercaseCharactersChoice = confirm("Sprinkle in some lowercase characters?");
    if (lowercaseCharactersChoice) {
    passwordChar += lowercaseChar;
    }
    // creates confirm boolean for uppercase "yes or no"
    var uppercaseCharactersChoice = confirm("How about a few uppercase letters?");
    if (uppercaseCharactersChoice) {
    passwordChar += uppercaseChar;
    }
    // creates confirm boolean for lowercase "yes or no"
    var numericalCharactersChoice = confirm("What's a password without a couple of numbers? Would you like to add them to yours?");
    if (numericalCharactersChoice) {
    passwordChar += numericalChar;
    }
    // creates confirm boolean for special characters "yes or no"
    var specialCharacterChoice = confirm("Your password is pretty secure already, but how about a dash of special characters?");
    if (specialCharacterChoice) {
    passwordChar += specialChar;
    }
    for (var i = 0; i < passwordLengthUser; i++) {
    password = passwordChar[Math.floor(Math.random() * passwordChar.length)]
    }

    function writePassword(password){
    var password = generatePassword();
    var pwTextArea = document.getElementById("#password");
    pwTextArea.value = password;
    return ("")

    }
    console.log(writePassword)
    }
    generateBtn.addEventListener("click", generatePassword);

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

    Is there a shorter code to do this continuous input? And shorter soultion?

    Posted: 10 Dec 2020 09:27 PM PST

    The number 3025 has a remarkable quirk: if you split its decimal representation in two strings of equal length (30 and 25) and square the sum of the numbers so obtained, you obtain the original number: (30+25)^2=3025 The problem is to determine all numbers with this property having a given even number of digits. For example, 4-digit numbers run from 0000 to 9999. Note that leading zeroes should be taken into account. This means that 0001 which is equal to (00 + 01)^2 is a quirksome number of 4 digits. The number of digits may be 2,4,6 or 8.

    Warning: Please note that the number of digits in the output is equal to the number in the corresponding input line : leading zeroes may not be suppressed.

    type 0 to end input

    Input:

    https://ibb.co/HT6Lv9P

    (miss 0 here)

    Output:

    https://ibb.co/NNqNdS8

    my code:

     printf("Please input N(2,4,6,8):\n"); int n=1; int i; int noi=0; int arr[100]; while(n!=0){ scanf(" %d",&n); arr[noi]=n; noi++; } int count=noi; while(count>0){ n=arr[noi-count]; count--; switch(n){ case 2: for(i=0;i<pow(10,2);i++){ if(pow((i/10+(i%10)),2)==i){ printf("%02d\n",i); } } break; case 4: for(i=0;i<pow(10,4);i++){ if(pow((i/100+(i%100)),2)==i){ printf("%04d\n",i); } } break; case 6: for(i=0;i<pow(10,6);i++){ if(pow((i/1000+(i%1000)),2)==i){ printf("%06d\n",i); } } break; case 8: for(i=0;i<pow(10,8);i++){ if(pow((i/10000+(i%10000)),2)==i){ printf("%08d\n",i); } } break; }; } 
    submitted by /u/JacksonSteel
    [link] [comments]

    How would you solve this coding problem?

    Posted: 10 Dec 2020 09:00 PM PST

    Given 4 arrays of integers and a threshold, count the number of possibilities for the sum of 1 element from each array to be <= threshold.

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

    dropdown svg arrow does not get assigned as ref in react useRef

    Posted: 10 Dec 2020 08:55 PM PST

    Hope you all are safe and doing well. So I was trying to create a dropdown arrow which allows you to show a popup and close it upon clicking. I have even discovered the problem and but am unable to proceed further to the solution.

    Here are my codes

    1.) // Please check from the DropdownArrowIcon code and useRef code // Main Header file

    import React, {useState, useRef, useEffect} from 'react'; import HeaderLocationPopup from './HeaderLocationDropDownComponent-Header'; import DropdownArrowIcon from './Icons/DropdownArrowIcon'; const ZomatoHeader = () => { const [showDropdown, setShowDropdown] = useState(false); const [isActive, setActive] = useState(false); const handleInputBoxClick = () => { setShowDropdown(true); setActive(true); }; const handleArrowClick = () => { setShowDropdown(!showDropdown); setActive(!isActive); }; const arrowClasses = `${isActive ? 'dropdown-logo__rotated' : ''} dropdown-logo block z-10 opacity-75`; let dropdownRef = useRef(); useEffect(() => { let handler = (event) => { if(!dropdownRef.current.contains(event.target)) { setShowDropdown(false); setActive(false); } }; document.addEventListener('mousedown', handler); return () => { document.removeEventListener('mousedown', handler); }; }); return ( <header className='section-header text-white'> <div className='section-header__topbar flex justify-between pt-4'> <div className='section-header__topbar--left font-medium'> Get the app </div> <div className='section-header__topbar--right text-lg'> <a href='/' className='mx-5'>Login</a> <a href='/' className='mx-5'>Sign up</a> </div> </div> <div className='section-header__logo flex justify-center mt-40'> <img src='/images/zomato-logo-white.webp' alt='' className='zomato--log h-16' /> </div> <h2 className='section-header__heading flex justify-center mt-5 text-4xl'>Discover the best food & drinks in Delhi NCR</h2> {/*The Input Text box begins here*/} <div className='section-header__searchbar flex justify-center items-center mt-5 text-black'> <svg className='zomato-logo w-6 h-5 z-10 pr-1 opacity-75'> <use xlinkHref='/sprite.svg#icon-location'></use> </svg> <input type='text' name='fname' className='w-1/7 p-2 rounded h-12 section- header__searchbar--left -ml-8 pl-8 pr-8 z-5' placeholder='Your Current Location' onClick={() => handleInputBoxClick()} /> <DropdownArrowIcon arrowClasses={arrowClasses} dropdownRef={dropdownRef} handleArrowClick={() => handleArrowClick()} /> <input type='text' name='fname' className='w-1/4 p-2 rounded h-12 -ml-4 section-header__searchbar--right pl-5 z-10 ml-2' placeholder='Search for restaurant, cuisine or a dish' /> <svg className='h-6 w-6 z-10 opacity-75 -ml-8 fill-current text-gray-900'> <use xlinkHref='/sprite.svg#icon-magnifying-glass'></use> </svg> </div> <HeaderLocationPopup show={showDropdown} closeDropdown={() => setShowDropdown(false)} dropdownRef={dropdownRef}/> </header> ); }; export default ZomatoHeader; 

    2.) Dropdown Icon

    import React from 'react'; const DropdownArrowIcon = ({dropdownRef, arrowClasses, handleArrowClick}) => { return ( <span className='h-12 w-12 bg-white -ml-2 flex items-center' ref={dropdownRef}> <svg className={arrowClasses} onClick={() => handleArrowClick()}> <use xlinkHref='/sprite.svg#icon-arrow_drop_down'></use> </svg> </span> ); }; export default DropdownArrowIcon; 

    The problem is from what I think is the ref does not work on a svg element, due to which when you click on the icon it changes the state twice making it in the same state all over again.

    TLDR:- useRef probably does not work on the svg icon, due to which when trying to change the state it gets changed twice and dropdown arrow does not function properly.

    here is an video link to check the problem. https://drive.google.com/file/d/1smp4DEGthi_jE33nWnR6L1m0AG1A1SQN/view?usp=sharing

    Thanks to kind soul in advance.

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

    Writing data to COM port using WriteFile

    Posted: 10 Dec 2020 11:05 AM PST

    I am trying to write data to a COM port to which my Arduino is connected. I would like the Arduino to read this data and do some action based on that.

    DCB dcb; HANDLE hCom; DWORD iBytesWritten std::string comPrefix = "\\\\.\\COM"; std::string comNum = *COM_Port; std::string comID = comPrefix + comNum; std::cout << "comID: " << comID << "\n"; hCom = CreateFile( comID.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); dcb.DCBlength = sizeof(DCB); GetCommState(hCom, &dcb); dcb.BaudRate = 14400; // Default SERIAL_8N1 for PC - USB Serial Communication dcb.ByteSize = 8; // Databits dcb.Parity = NOPARITY; // Parity // lack of any error checking dcb.StopBits = ONESTOPBIT; // Stopbits SetCommState(hCom, &dcb); // save COM-Settings dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; tUInt8 output; //set outputvalue output = static_cast<tUInt8>(pointcolumn.at(X)); WriteFile(hCom, &output, sizeof(output), &iBytesWritten, NULL); 

    By doing it like this, I think I am writing output to the port to which my Arduino is connected.

    And on the Arduino side, I am trying to turn an LED on. For example, if I send 1 using WriteFile(), I turn on that specific LED with high brightness:

    void setup() { // put your setup code here, to run once: Serial.begin(14400); } void loop() { // put your main code here, to run repeatedly: if(Serial.available()>0) { ColumnIdx = Serial.read(); analogWrite(LEDpins[ColumnIdx],255); } } 

    The problem I am getting here is it is not turning on the LEDs. That means it is not going through my ifcondition, that means Serial.available()>0is false. But my Arduino is receiving some data because the RX blinks. I am not sure exactly what is being received by the Arduino.

    I am trying to check if the WriteFile()is writing anything to the COM port. But I can say that the Arduino is receiving something because RX blinks. By this, I think I can even say my WriteFile()is writing to the particular port. Otherwise, I cannot see why the RX of the Arduino should blink.

    I certainly made sure that the Arduino is connected to the correct port which I am using in WriteFile().

    Update: I removed RTS Hand control Shake but I am not sure what is default will WriteFile set?

    submitted by /u/Mother-Beyond9493
    [link] [comments]

    Which programming language do you consider most optimized for ease of debugging?

    Posted: 10 Dec 2020 10:34 PM PST

    I want to turn my old PC into a dedicated web server, what are the cares I must take?

    Posted: 10 Dec 2020 12:34 PM PST

    Hi people!

    I have a good PC that i´m not using, and I'd like to turn it into my own dedicated server. I have a good Internet connection and the PC is better than the cheap tiers of the hosting/cloud services, so... That's it!

    JFYI, I think it will be running any debian based operative system when I use it as a server. It will be mainly used to offer a PHP website, and maybe some Springboot (Java/kotlin) service on the background... I don't know yet.... but I want to be warned about all the security and/or management aspects I should care about of doing this.

    AFAIK, there won´t be sensitive data on that server, but I have my everyday computers connected on the same LAN, which I fell is kinda weak point.

    I can answer your questions if we need extra data to discuss this.

    Thanks.

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

    When/how to consider a new technology?

    Posted: 10 Dec 2020 09:55 AM PST

    Web developer, < 5 years professional experience.

    Something I've noticed about myself is, I'm generally reluctant to adopt a new technology. In my work I occasionally have coworkers suggesting a new language, framework, an Amazon service to try, etc. I am almost always against it, because what we have now seems to work just fine. And I don't understand the point of changing things up. If what we have now works and isn't causing undue pain, why bother with something else? "If it ain't broke, don't fix it."

    That said, I hate constantly shooting down ideas for new ways of doing things. And I'm concerned I might be hamstringing my team long-term by continually not wanting to try new ways of doing things. It's not that I'm against trying new things. It just doesn't strike me as practical. Why suddenly introduce a new technology that now the whole department will end up running into at one point or another and have to learn, when what we have now works?

    I can get needing to change if security is a concern. Or if it's a framework that is old enough there's really no more support or community for it.

    I guess what I'm asking is, are there principles to use when determining when to embrace a new tech, or say we don't need it? What kind of context should I have for making that decision? How do I know when to stick to what works, and try something new - without falling into the "hype driven development" where if it's shiny and new, it must be good?

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

    Creating a Book Class

    Posted: 10 Dec 2020 09:36 PM PST

    With 5 fields title -

    String, the title of the book.

    Author - String, the author of the book.

    Pages - integer, the number of pages in the book.

    Publisher - String, the publisher of the book.

    Year - integer, the year the book was published.

    With 6 methods

    A constructor that accepts as arguments the values for the fields above, in the order listed.

    A copy constructor that makes a copy of a Book object.

    A getTitle method that returns the value of the title field.

    A setAuthor method that accepts a String argument, which is used to set the author field.

    An equals method that returns a boolean indicating if two objects contain the same information. If they do, it returns true, false otherwise. The objects contain the same information when their fields contain the same values.

    A toString method that returns a String that contains on separate lines (5 lines), the names and values for each field.

    Demonstrate the class in a program. Demo program is required to:

    Create at least two Book objects.

    Create a copy of a Book object.

    Use each of the other four methods to show they work properly. Do not explicitly call the toString method in your demo program.

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

    Does anybody know of a way to compare data types in c++?

    Posted: 10 Dec 2020 05:39 PM PST

    Python/Numpy/PyTorch: How do I speed up a linear algebra operation by un-unrolling?

    Posted: 10 Dec 2020 02:55 AM PST

    Hi everyone, I am trying to implement an algorithm in python that has been published in a scientific paper. During testing I found that the most time-consuming part of the script (by far) is the following operation that I have written as follows:

    def operation( K, P, V ): # K is an M*N matrix # P is an N*1 vector # V is an M*1 vector m = len(V) output = torch.zeros((m, m)) for i in range(m): for j in range(i,m): output[i,j] = torch.dot(K[i,]*K[j,],P)-V[i]*V[j] output[j,i] = output[i,j] return output 

    I suspect that having two loops written in python is responsible for the speed problem. However, I do not know how to effectively rewrite this function. For example, I am aware of Einstein summation, but am completely unfamiliar with how to write this formula using that notation (or if that is even possible). Any help is appreciated.

    EDIT: I have found a solution to the problem in case anyone is interested. The code is below. Using PyTorch, I was able to get substantial speedups when comparing the crude use of for loops to actual matrix operations.

    Variables:

    m = 350 n = 1000 k = torch.randn( n, m ) p = torch.randn( n ) v = torch.randn( m ) 

    Method 1: For loops

    cross = torch.outer( v, v ) mt = torch.zeros( m, m ) for i in range( m ): for j in range( i, m ): mt[ i, j ] = torch.dot( k[ :, i ] * k[ :, j ], p ) * cross[ i, j ] mt[ j, i ] = mt[ i, j ] 

    Execution time: 2.5 seconds

    Method 2: PyTorch without GPU

    cross = torch.outer( v, v ) k1 = torch.unsqueeze( k, 1 ) k2 = torch.unsqueeze( k, -1 ) kkt = ( k1*k2 ).permute( 1, 2, 0 ) kktp = torch.matmul( kkt, p ) final = kktp * cross 

    Execution time: 0.61 seconds

    Method 3: PyTorch with GPU

    device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") cross_cuda = torch.outer( v, v ).to( device ) k1_cuda = torch.unsqueeze( k, 1 ).to( device ) k2_cuda = torch.unsqueeze( k, -1 ).to( device ) p_cuda = p.to( device ) kkt_cuda = ( k1_cuda*k2_cuda ).permute( 1, 2, 0 ) kktp_cuda = torch.matmul( kkt_cuda, p_cuda ) final_cuda = kktp_cuda * cross_cuda 

    Execution time: 0.0026 seconds

    Method 4: Einstein summation with GPU

    device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") kd = k.to(device) pd = p.to(device) vd = v.to(device) final_b = torch.einsum('ij,ik,i,j,k->jk', kd, kd, pd, vd, vd).to(device) 

    Execution time: 0.00071 seconds

    Conclusion: Use actual PyTorch code, not for loops, and use a GPU if you can.

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

    help with dart language cli adventure game

    Posted: 10 Dec 2020 04:07 PM PST

    Hello world,

    I am a beginner at programming and i am trying to create a cli adventure game in Dart and i am having some trouble.

    I know everyone hates these kind of posts and that i should google and just figure it out for myself and believe me i am trying.

    I am not asking anyone to do this for me, just to look at the code and tell me if it is shit or not and maybe nudge me in the right direction.

    if you are interested in checking this out please message me. I really dont want to embarrass myself by posting the code here.

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

    How to extract info from CSV file

    Posted: 10 Dec 2020 04:03 PM PST

    Hi All,

    I'm a complete beginner at this and have trouble using the appropriate jargon, therefore, it makes it difficult for me to find the correct resources to read and learn from.

    That said, I'm hoping one of you can point me to some videos/online readings that'd help.

    I've been using python to scrape a bunch of info onto a CSV file and now I'm looking to incorporate that information into a website that I'd be creating. Essentially each container on the website would have a name, link, and image associated with it (all this info is in the csv file).

    How can I go about extract this data from the csv file to the webpage? Not looking for code answers rather I'm looking for resources that I can read/watch to better learn.

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

    Generating a random number based off C code (x86)

    Posted: 10 Dec 2020 09:54 AM PST

    I'm supposed to emulate the following C code in x86 NASM assembly to generate a random number. I'm having a bit of trouble with the syntax, and maybe some of the logic as well.

    //here is the C code I'm basing my assembly code off of int maxrand(int seed,int max) { int random_seed=0; random_seed = random_seed+seed * 1103515245 +12345; return (unsigned int)(random_seed / 65536) % (max+1); } 

    This is where I try to generate a random seed to use and pass in as a parameter to the assembly function. I will not be passing in a max as a parameter because the highest random number that I want to be generated is 16, so I will hardcode that in my random function.

    random: ; creating a random seed using rdrand, only allowed to use rdrand here rdrand r8 mov rax, r8 mov r9, 10 div r9 add rdx, 48 mov [seed], rdx ;1 numerical character stored in seed ;set up parameters for random call mov rdi, [seed] call randomFunc ret 

    randomFunc, that lives in it's own separate file. I get an error currently where I try to multiply 1103515245, saying "invalid combination of opcode and operands" so I know my syntax must be wrong there. If anyone knows why this is happenening, please help!

     randomFunc: mov r8, [rdi];moving seed value to rax bc it needs to be returned here mul r8, 1103515245 add r9, randSeed add r9, 12345 
    submitted by /u/figblu3
    [link] [comments]

    Trouble connecting Intellij, SQlite, java express and much more...

    Posted: 10 Dec 2020 09:49 AM PST

    So I'm doing a note/blog web application project. Newbie here!
    The problem is it seems like Intellij doesn't recognize/know/or something.. what java.express-0.3.5 driver is, I cant run or debug the program, it's asking for some configuration. And on top of that it doesn't connect to the database SQLite (but the driver seems to be connected) might be cause Intellij isn't working properly.

    I'm able to run the site via live server (Forgot to mention I'm using visual studio code as well) or localhost, but nothing I put in the input registers inside the database, the delete function doesn't work and the errors I find in the console log makes no sense to me.

    I've uploaded the project on GitHub https://github.com/Majonett/test.git if anyone want's to be so kind and take a look, I would really appreciate it. It's far from done but right now I'm stuck.

    THANKS!!! <3

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

    HELP , im new to programming and i dont understand why my code keeps receiving "expected expression before ___" and "too few arguments" error

    Posted: 09 Dec 2020 11:28 PM PST

    edit : this issue has now been resolved thank you to everyone especially u/Poddster

    i have done codes like these before i even clean copied some of them from my old codes but now they are getting errors in my new code.

    #include <stdio.h> #include <string.h> float daily_calc(float daily[7],float salary) { float wtax = 0; if (salary <= daily[1]) //stage 1 { wtax = 0; } else if (salary <= daily[2]) //stage 2 { wtax = (salary - daily[1])*0.20; } else if (salary <= daily[3]) //stage 3 { wtax = 82.19 + (salary - daily[2])*0.25; } else if (salary <= daily[4]) //stage 4 { wtax = 356.16 + (salary - daily[3])*0.30; } else if (salary <= daily[5]) //stage 5 { wtax = 1342.47 + (salary - daily[4])*0.32; } else if (salary >= daily[6])//stage 6 { wtax = 6672.74 + (salary - daily[5])*0.35; } return wtax; } float weekly_calc(float weekly[7],float salary) { float wtax = 0; if (salary <= weekly[1]) //stage 1 { wtax = 0; } else if (salary <= weekly[2]) //stage 2 { wtax = (salary - weekly[1])*0.20; } else if (salary <= weekly[3]) //stage 3 { wtax = 576.92 + (salary - weekly[2])*0.25; } else if (salary <= weekly[4]) //stage 4 { wtax = 2500 + (salary - weekly[3])*0.30; } else if (salary <= weekly[5]) //stage 5 { wtax = 9423.08 + (salary - weekly[4])*0.32; } else if (salary >= weekly[6])//stage 6 { wtax = 46346.15 + (salary - weekly[5])*0.35; } return wtax; } float semi_monthly_calc(float semi_monthly[7],float salary) { float wtax = 0; if (salary <= semi_monthly[1]) //stage 1 { wtax = 0; } else if (salary <= semi_monthly[2]) //stage 2 { wtax = (salary - semi_monthly[1])*0.20; } else if (salary <= semi_monthly[3]) //stage 3 { wtax = 1250 + (salary - semi_monthly[2])*0.25; } else if (salary <= semi_monthly[4]) //stage 4 { wtax = 5416.67 + (salary - semi_monthly[3])*0.30; } else if (salary <= semi_monthly[5]) //stage 5 { wtax = 20416.67 + (salary - semi_monthly[4])*0.32; } else if (salary >= semi_monthly[6])//stage 6 { wtax = 100416.67 + (salary - semi_monthly[5])*0.35; } return wtax; } float monthly_calc(float monthly[7],float salary) { float wtax = 0; if (salary <= monthly[1]) //stage 1 { wtax = 0; } else if (salary <= monthly[2]) //stage 2 { wtax = (salary - monthly[1])*0.20; } else if (salary <= monthly[3]) //stage 3 { wtax = 2500 + (salary - monthly[2])*0.25; } else if (salary <= monthly[4]) //stage 4 { wtax = 10833.33 + (salary - monthly[3])*0.30; } else if (salary <= monthly[5]) //stage 5 { wtax = 40833.33 + (salary - monthly[4])*0.32; } else if (salary >= monthly[6])//stage 6 { wtax = 20833.33 + (salary - monthly[5])*0.35; } return wtax; } int main() { char s[1000]; char* period_print [4] = {"daily","weekly","semi-monthly","monthly}; float result1 = daily_calc(float daily[7],float salary); float result2 = weekly_calc(float weekly[7],float salary); float result3 = semi_monthly_calc(float weekly[7],float salary); float result4 = monthly_calc(float weekly[7],float salary); float salary; float period; //tax borders float daily[7] = {0,685,1095,2191,5478,21917,1000000}; float weekly[7] = {0,4808,7691,15384,38461,153845,1000000}; float semi_monthly[7] = {0,10417,16666,33332,83332,333332,1000000}; float monthly[7] = {0,33332,66666,166666,666666,1000000}; //enter values printf("Enter name: "); gets(s); printf( "Enter Period: \n1 daily \n2 weekly \n3 semi-monthly \n4 monthly \n: "); scanf("%.2f",&period); printf( "Enter salary: "); scanf("%.2f",&salary); printf("salary: %d \n",salary); //printing of final values printf("\nname :%s",s); printf("\nsalary :%f",salary); if (period ==1) //daily { printf("\nperiod = %s\nwitholding tax = %f\n",period_print[0],result1 ); } else if (period ==2 ) //weekly { printf("\nperiod = %s\nwitholding tax = %f\n",period_print[1],result2 ); } else if (period ==3 ) //semi-monthly { printf("\nperiod = %s\nwitholding tax = %f\n",period_print[2],result3); } else if (period ==4) //monthly { printf("\nperiod = %s\nwitholding tax = %f\n",period_print[3],result4); } else { return 0; } return 0; } 
    submitted by /u/real_crazykayzee
    [link] [comments]

    Android project help

    Posted: 10 Dec 2020 12:25 PM PST

    Hi, I am a sophomore in college studying computer science and psychology, I am lookin for someone who is interested to work with me on an android app, I am trying to get experience so I can apply for internships, as of now I have almost zero experience, I am pretty comfortable with java and I stated learning android studio recently, if you're interested lmk.

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

    Why do I have to pay for the internet?

    Posted: 09 Dec 2020 10:53 PM PST

    I was watching Eli the Computer Guy's video on VPN's, and he says that your data goes through many routers to get to a destination. Shouldn't everyone be able to just buy a router, and then we all use each others routers when sending things to places?

    Or, when I pay for internet, is my information only going through big routers that the isp company I pay owns?

    Thank you.

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

    When installing plugin, text within terminal does not display properly

    Posted: 10 Dec 2020 02:48 AM PST

    Hi everyone, I am trying to understand how/why something is happening when installing an extension.

    (The program itself is Volumio, and the extension itself is SnapCast)

    I've noticed during the latter half of the installation, this is what is reported in the terminal:

    Progress: 100
    Status :SnapCast Successfully Installed, Do you want to enable the plugin now?
    Downloading plugin at http://127.0.0.1:3000/plugin-serve/snapcast.zip<br>END DOWNLOAD: http://127.0.0.1:3000/plugin-serve/snapcast.zip<br>Creating install location<br>Unpacking plugin<br>Checking for duplicate plugin<br>Copying plugin to location<br>Installing necessary utilities<br>Installing SnapCast and its dependencies...<br>Hit http://archive.volumio.org jessie InRelease<br>Hit http://archive.volumio.org jessie InRelease<br>Hit http://archive.volumio.org jessie/main Sources<br>Hit http://archive.volumio.org jessie/contrib Sources<br>Hit http://archive.volumio.org jessie/non-free Sources<br>Hit http://archive.volumio.org jessie/rpi Sources<br>Hit http://archive.volumio.org jessie/main armhf Packages<br>Hit http://archive.volumio.org jessie/contrib armhf Packages<br>Hit http://archive.volumio.org jessie/non-free armhf Packages<br>Hit http://archive.volumio.org jessie/rpi armhf Packages<br>Hit http://archive.volumio.org jessie/main Sources<br>Hit http://archive.volumio.org jessie/ui Sources<br>Hit http://archive.volumio.org jessie/main armhf Packages<br>Hit http://archive.volumio.org jessie/ui armhf Packages<br>Ign http://archive.volumio.org jessie/contrib Translation-en<br>Ign http://archive.volumio.org jessie/main Translation-en<br>Ign http://archive.volumio.org jessie/non-free Translation-en<br>Ign http://archive.volumio.org jessie/rpi Translation-en<br>Ign http://archive.volumio.org jessie/main Translation-en<br>Ign http://archive.volumio.org jessie/ui Translation-en<br>Reading package lists...<br>Detecting CPU architecture and Debian version...<br>CPU architecture: armv6l<br>Debian version: jessie<br>Defaulting to known working version of SnapCast components (0.15.0)<br>Selecting previously unselected package snapclient.<br>(Reading database ... 26611 files and directories currently installed.)<br>Preparing to unpack .../snapclient_0.15.0_armhf.deb ...<br>Unpacking snapclient (0.15.0) ...<br>Setting up snapclient (0.15.0) ...<br>Processing triggers for systemd (215-17+deb8u8) ...<br>Selecting previously unselected package snapserver.<br>(Reading database ... 26620 files and directories currently installed.)<br>Preparing to unpack .../snapserver_0.15.0_armhf.deb ...<br>Unpacking snapserver (0.15.0) ...<br>Setting up snapserver (0.15.0) ...<br>Processing triggers for systemd (215-17+deb8u8) ...<br>Reading package lists...<br>Building dependency tree...<br>Reading state information...<br>0 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.<br><br> #SNAPCAST<br> pcm.!snapcast {<br> type plug<br> slave.pcm snapConverter<br> }<br> <br> pcm.snapConverter {<br> type rate<br> slave {<br> pcm writeFile # Direct to the plugin which will write to a file<br> format S16_LE<br> rate 48000<br> }<br> }<br><br> pcm.writeFile {<br> type file<br> slave.pcm null<br> file "/tmp/snapfifo"<br> format "raw"<br> }<br> #ENDOFSNAPCAST<br> <br>mode of '/etc' changed from 0755 (rwxr-xr-x) to 0777 (rwxrwxrwx)<br>Finalizing installation<br>Finalizing installation

    What seems to be happening is <br> is simply not being interpreted as a line break. I believe it has something to do with the fact that the original SnapCast client is written in C++ but this version for Volumio appears to be "translated" by something else in the respository (I've cloned it and been messing around to try to understand) but if anyone was able to give some advice on where to start looking or how to automate the "translation" of <br> into a true line break I would be greatly appreciative!

    If links to the specific repositories would be helpful too I can post them

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

    Remote work: Are you sometimes rushed into a call?

    Posted: 10 Dec 2020 11:08 AM PST

    I live in Miami where it gets incredibly hot and humid, and electric is also fairly expensive. I'm content at home with a fan just wearing boxers but would need a few minutes to put on work clothes before a call.

    Do you guys think I'll generally be okay with most work related video calls or do they tend to be more spontaneous than that when working remote ("Phil, we need to talk now, get on Zoom")?

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

    Are startups more picky than mid level companies?

    Posted: 10 Dec 2020 10:58 AM PST

    I've had about 5 interviews at startups found on AngelList. 5 is not a lot but none have gone past the first round.

    I have had one interview at a mid level with a national presence and am on round 3.

    I should note I am only applying to companies who offer full remote. The startups all seemed to want more experience than my 2 years (React, Typescript, Node/Express, Postgres). The national firm probably would have DQed me by now if experience was an issue.

    As 6 interviews is not enough to really make conclusions I wanted to ask you guys if your experience was the same or not. I am actually thinking of devoting more time to Indeed.com remote job posts. There's more of them every day and I think maybe I didn't give non-startups a fair trial. My outreach plan focused on startups because I heard they were more flexible in general, with hiring and remote terms (About 2/3 of AngelList startups are at least partially distributed, so there's some truth to it on that level).

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

    [C] When i put "54" in the Console it should give me an array [54] back, but instead gives me [5] [4] back. Can anyone fix that for me?

    Posted: 10 Dec 2020 10:09 AM PST

    This Programm should give me an Array back when i write the Number eg. i write 54, it should put [54] in the console, but it only takes one Character each time for some reason and gives [5] [4] back. Can someone tell me where my error is?

    int main (void){ Stack stack; clear_stack(&stack, STACK_SIZE); int input_size = 128; char input[input_size]; for(int i = 0; i< input_size; i++){ input[i] = '\0'; } int input_index = 0; int c; while((c = getchar()) != 'q'){ if(c == '\n'){ for(int i = 0; i< input_index; i++){ if( is_operation(input[i])){ push(make_Operation(input[i]), &stack, STACK_SIZE); compute(&stack, STACK_SIZE); } else if( is_digit(input[i])){ push(make_Value(input[i] - '0'), &stack, STACK_SIZE); } print_stack(&stack, STACK_SIZE); } for(int i = 0; i< input_size; i++){ input[i] = '\0'; } input_index = 0; }else{ input[input_index] = c; input_index++; } } return 0; } 

    i think the error lies here: push(make_Value((input[i] - '0'), &stack, STACK_SIZE); because it pushes just one character, how do i fix it?

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

    How to prevent spamming the user with Notification / Email based on triggering of a Event ?

    Posted: 10 Dec 2020 09:47 AM PST

    I have a use case where, based on a event that can trigger at anytime. The trigger in question is with respect to a access token expiring for an API.
    I want to send user a notification that their access has expired but i want to limit the email / notification to only once per week. How would I do that because once the token expires the condition will get triggered multiple times in a day with a 401 status.

    Would i store something like notification sent and topic and time in a Database somewhere, but wouldn't that cause extra latency on the request as each time it triggers the event, it will check in the database if the notification was sent and end up blocking the processing till it checks the database?

    I may have a large number of requests to process continuosly, so I don't want to bogdown the database with multiple queries for a notification check each time the event is triggered. Any help would be much appreciated ?

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

    No comments:

    Post a Comment