• Breaking News

    Wednesday, February 21, 2018

    Any good resources for identifying test cases for interviews? Ask Programming

    Any good resources for identifying test cases for interviews? Ask Programming


    Any good resources for identifying test cases for interviews?

    Posted: 21 Feb 2018 07:55 PM PST

    It has become evident to me that coming up with test cases is really important for doing well in technical interviews.

    Beyond the null case, incorrect type case, etc., I was wondering if you guys knew of any resources, like maybe a list of different test cases, to consider when tackling programming questions.

    Thanks!

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

    How to get started making a GroupMe scraping bot?

    Posted: 21 Feb 2018 05:30 PM PST

    I'm a sophomore Computer Science major and my friend group frequently uses Groupme for communication. I thought it would be a fun little learning experience/project to make a bot that would record our messages and pictures and write them to a file that can be easily saved in case we ever want to access them. I know the best method for this would be to utilize Groupme's API, but I have no experience doing any API work and I'm completely ignorant to it and borderline intimidated by the process.

    I really would appreciate if someone could point me in the right direction for either learning API stuff/how to use GroupMe's API, or informing me of a better way to do this. I program mainly in C++ and really have no experience in anything like Javascript or PHP, but I would be very down to learn it.

    Thanks for any help!

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

    I need help with something in Triple Des. I am getting an exception error and do not know what to do next.

    Posted: 21 Feb 2018 06:58 PM PST

    I am getting an error that says the specific key is not a valid size for the array. I am confused with triple des and cannot figure out this code. Even the online examples seem to not help.

    I have specific parameters to be imputed so this is what is throwing me off.

    the keysize is 128. the key is "0123456789ABCDEF" the IV is "ABCDEFGH" the encoded input is ABvAsOKcGXqc5uQ4O5Z53isJaH31Pa8+PeddljE4mSU= 

    Here is my code thus far: using System; using System.Configuration; using System.Text;

    namespace System.Security.Cryptography { class MainClass { protected static void Main(string[] args) { string keyString = "ABvAsOKcGXqc5uQ4O5Z53isJaH31Pa8+PeddljE4mSU="; byte[] data = Convert.FromBase64String(keyString); string decodedString = Encoding.Unicode.GetString(data); Console.WriteLine(decodedString); TripleDES decoder = TripleDES.Create(); byte[] key = Convert.FromBase64String("0123456789ABCDEF"); int keySize = 128; byte[] vector = Convert.FromBase64String("ABCDEFGH"); //keyResults = Encoding.UTF8.GetString(key); //vectorResults = Encoding.UTF8.GetString(vector); ICryptoTransform decryptor; decryptor = decoder.CreateDecryptor(key, vector); // creates the decryptor Console.WriteLine(decryptor.ToString()); } } } 
    submitted by /u/JediNinjas
    [link] [comments]

    How to solve a system of 2 trig equations?

    Posted: 21 Feb 2018 06:52 PM PST

    I've got 2 equations of the form

    r1sin(a1) + r2sin(a2) = c1 and

    r1cos(a1) + r2cos(a2) = c2

    I know it's possible using a fixed point iteration and newton's method for non-linear systems, but I want to know if there's a more analytic solution to it, since I want to do this in a simulation and it needs to be done in constant time.

    Is there any way I could come up with a way to solve this programatically, or convert this to a linear system?

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

    How to compress a string in python, not using for loops.

    Posted: 21 Feb 2018 06:42 PM PST

    I'm trying to compress a string like aaaabbbccd numbers like to a4b3c2d, but I can't get the last character to return. (a4b3c2)

    Here is the link: (https://gist.github.com/anonymous/a7bcc296acf33bc1929b170f1bdd0978)

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

    half of code is working and the other half isn't

    Posted: 21 Feb 2018 09:56 PM PST

     //if button 11 is unavailable if (buttons[11].getText().toString() == circle) { buttons[10].setVisibility(View.VISIBLE); } else { buttons[10].setVisibility(View.GONE); } if (buttons[11].getText().toString() == cross) { buttons[10].setVisibility(View.VISIBLE); } else { buttons[10].setVisibility(View.GONE); } 

    when 'buttons[11].getText().toString() == cross' is true, it shows button 10 but when button 11 is a circle, button 10 isn't shown. whats going wrong?

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

    [Image Processing] When trying to find a matching colour with a given sensitivity function what does delta in the pure source simplification mean?

    Posted: 21 Feb 2018 06:01 PM PST

    I'm going over class notes for image processing and noticed there is a use of delta that I can't figure out what it's meant to mean. I don't even know if it's a constant or a function. Specifically I'm trying to find the m_ij values using the colour matching equation from the pure source values of 700nm, 546.1nm 435.8nm. Is delta a constant that I need to find some how or is there a part of the lesson I didn't take notes on?

    Here is a link to my class notes. The use of delta I'm unsure about is on page 9 https://www.cs.unm.edu/~williams/cs530/color3.pdf

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

    How can I build this???

    Posted: 21 Feb 2018 09:36 PM PST

    I want a device that would act as a keyboard that can type up to 10,000 characters at the press of a button. I want to be able to load a program and database to it the press a button for the program to run and it would type out everything on the computer it is plugged into. It is important that it would be selected to run from the device and not the computer it is plugged into. I'm not sure whether it comes down to modifying a keyboard or using a USB. Any ideas on this would be greatly appreciated. Essentially what I need this to do is 1. Type a 10 digit UPC 2. Hit ENTER 3times 3. Type the quantity 4. Hit ENTER once 5. Type the price of an item 6. Hit ENTER 7. Hit F2 8. Then repeat steps 1-7 until all items in database have been done

    I cannot use the computer I would be plugging this into to store the program or database on, it would all have to be on the device/keyboard.

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

    Can someone help me find this memory leak?

    Posted: 21 Feb 2018 10:23 AM PST

    Hi! I'm typing up some code for my programming class and everything works just fine except it has a memory leak. Can someone please help? Any help is appreciated!:

    //----------------------------------------------------------------------------- // Dictionary.c // Implementation file for Dictionary ADT written in C similar to pa3 //----------------------------------------------------------------------------- #include<stdio.h> #include<stdlib.h> #include<string.h> #include<assert.h> #include"Dictionary.h" // private types -------------------------------------------------------------- // Creates node data type typedef struct NodeObj{ char* key; char* value; struct NodeObj* next; } NodeObj; // Reference size typedef NodeObj* Node; // newNode() // Constructor of the node type Node newNode(char* k, char* v){ Node N = malloc(sizeof(NodeObj)); assert(N!=NULL); N->key = k; N->value = v; N->next = NULL; return(N); } // freeNode() // destructor for the Node type void freeNode(Node* pN){ if( pN!=NULL && *pN!=NULL ){ free(*pN); *pN = NULL; } } // Creates Dictionary ADT typedef struct DictionaryObj{ Node top; Node bottom; int numItems; } DictionaryObj; // public functions ----------------------------------------------------------- // newDictionary() // constructor for the Dictionary ADT Dictionary newDictionary(void){ Dictionary D = malloc(sizeof(DictionaryObj)); assert(D!=NULL); D->top = NULL; D->bottom = NULL; D->numItems = 0; return D; } // freeDictionary() // destructor for the Dictionary ADT void freeDictionary(Dictionary* pD){ if( pD!=NULL && *pD!=NULL){ makeEmpty(*pD); free(*pD); *pD = NULL; } } // isEmpty() // returns true if D is empty, false otherwise int isEmpty(Dictionary D){ if( D==NULL){ fprintf(stderr,"Stack Error: calling isEmpty() on NULL stack reference\n"); exit(EXIT_FAILURE); } return(D->numItems==0); } // size() // returns size of stack int size(Dictionary D){ if( D==NULL ){ fprintf(stderr, "Dictionary Error: calling size() on NULL Dictionary reference\n"); exit(EXIT_FAILURE); } return(D->numItems); } // lookup() // returns value with associated key, if it in the stack char* lookup(Dictionary D, char* k){ Node N = D->top; if( D==NULL){ fprintf(stderr, "Stack Error: calling lookup() on NULL stack reference\n"); exit(EXIT_FAILURE); } while( N!=NULL){ if( strcmp(N->key, k)==0 ){ return N->value; } N = N->next; } return NULL; } // insert() // inserts key and value into stack void insert(Dictionary D, char* k, char* v){ if(lookup(D, k) != NULL){ fprintf(stderr, "Stack Error: cannot insert an existing key\n"); } else if(D->top == NULL){ Node N = newNode(k, v); D->top = N; D->numItems++; } else{ Node N = D->top; while(N != NULL){ if(N->next == NULL){ break; } N = N->next; } N->next = newNode(k, v); D->numItems++; } } // delete() // removes key and value from stack void delete(Dictionary D, char* k){ Node N = D->top; if( lookup(D,k)==NULL ){ fprintf(stderr, "Dictionary error: key not found\n"); exit(EXIT_FAILURE); } if(strcmp(N->key,k)==0){ Node A = D->top; Node B = A->next; D->top = B; freeNode(&A); } else{ while(N !=NULL && N->next != NULL){ if(strcmp(N->next->key, k)==0){ Node B = N; Node C = N->next; B->next = C->next; N = B; freeNode(&C); } N = N->next; } } D->numItems--; } // makeEmpty() // resets the dictionary void makeEmpty(Dictionary D){ D->top = NULL; D->bottom = NULL; D->numItems = 0; } // printDictionary() // prints dictionary in output file void printDictionary(FILE* out, Dictionary D){ Node N = D->top; if( D==NULL ){ fprintf(stderr, "Stack Error: calling printDictionary() on NULL stack reference\n"); exit(EXIT_FAILURE); } while( N!=NULL ){ fprintf(out,"%s %s \n",N->key,N->value); N = N->next; } } 
    submitted by /u/Fox5023
    [link] [comments]

    I am using node and express for the first time for a school project. How can I find what the cause of these 500 errors are?

    Posted: 21 Feb 2018 05:08 PM PST

    I am very new to server side programming, and I am basically creating a hangman app that can store multiple games and for each game there are many different settings, such as colors, level of difficulty, font, etc. I have created many endpoints and the one I am working on currently is a POST endpoint (jquery and AJAX calls to reach the endpoints), and this endpoint creates a new game and assigns it to an SID I created earlier, but now I am getting a 500 error and it doesn't really give any useful information in the debugging process. How would a good programmer approach this problem?

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

    Advise on handling resistance against Coding Guidelines

    Posted: 21 Feb 2018 01:38 PM PST

    I've received some great resistance from team members in relation to establishing a set of Guidelines for Software development and utilising standards typically used in our industry.

    The existing code - works. But that's it. There are a great number of style and best practises misuses in the code base. There is a code guideline document, but there is no way to enforce it as there are no peer reviews.

    I've put some files from multiple projects through a static analysis tool and it consistently brings up 50+ faults per file.

    The current thought within the team is - if the code implements the specification, it compiles and no issues were found in testing (based on test plan), it is deemed good bullet-proof code.

    I have some serious problems with this type of thinking - am I crazy? Every company I've worked at, we had Guidelines and utilising them was not an issue.

    The points I am trying to stand against:

    • We do not need Guidelines because the team is too small.

    • We do not need Guidelines because they stifle creativity.

    • We do not need Guidelines because we do not carry out peer reviews.

    • We do not need Guidelines because every programmer should be free to write in the style they prefer.

    • We do not need static analysis tools because they more than likely will create false positives.

    • We do not need unit tests, because we will find bugs through the testing phase (after development).

    • We do not need unit tests, because we test while we develop.

    I should point out that software development at the company is very recent venture and the team is less than 5 engineers. 1 with experience in the industry and others are graduates.

    Any advise?

    edit: formatting

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

    Shuffle array based on alpha numeric hash

    Posted: 21 Feb 2018 07:33 PM PST

    I need to shuffle an array based on a unique hash, assuming I already have a unique hash is there an algorithm that I can pass the hash to create a unique shuffle?

    Say my array is [0..9]

    Thanks.

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

    My vector class isn't working when I create objects(c++)

    Posted: 21 Feb 2018 03:34 PM PST

    Whenever I try to create an object I get this error: "Implicit instantiation of undefined template 'std::1::vector<int, std::1::allocator<int> >'"

    Here is the main file, I've commented where the error occurs. https://pastebin.com/tSHPFzVe

    Here is the header file with the class. https://pastebin.com/1SRUMChZ

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

    How can I make a SQL call from js?

    Posted: 21 Feb 2018 03:27 PM PST

    I'm kinda in a shit spot right now with this project in terms of clarity. I was asked to add address fields for the new low income housing program downtown. So programs you can qualify for have required areas your house needs to be in. I was given two SQL calls, and told that they didn't have the other areas mapped, so I personally wrote a function that checks the user input address, and checks it against all the addresses that are in these areas, with a few false positives.

    My issues: I have no idea what gets returned with these calls, since I don't have access to their back end, and I don't even know how to make this call from my Js project. I keep seeing references to Node.js, but I think they expect me to be able to use these calls within my own Js project.

    Worst part is I didn't start this project, and this task I'm given has been just word of mouth. No clean user story. It's just a confusing shit show.

    submitted by /u/2ZettaSlow
    [link] [comments]

    How long would it take to build a reputation system for a Wordpress blog?

    Posted: 21 Feb 2018 03:05 PM PST

    Sorry for my ignorance on this, but I'm working with a wordpress blog, and we essentially want to create a system for users to downvote/upvote comments on articles or reviews.

    Just trying to get an idea of how long (even a rough estimate) this could take.

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

    TCL expect question

    Posted: 21 Feb 2018 01:37 PM PST

    I'm writing an expect script to automate an interactive software installation process so that it might be containerized. The interactive setup script starts by extracting a bunch of data from several zips and prints a message like "extracting x of y" to stdout where y is not known before running. Do I have to do anything in expect for those lines, or can I safely just expect lines that require input in the order they occur and send the desired input and assume that anything that doesn't match the next expect statement is ignored?

    The interactive script is linear and not threaded in any way. I can predict exactly which prompts will appear and in what order they will occur, just not variable output. I also don't need to do any fault checking. If it fails for some reason, I don't need to handle errors in the expect script.

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

    Sources for learning

    Posted: 21 Feb 2018 01:33 PM PST

    Hy

    I'm interested in knows sources(what you consider your base of learning) about some topics(listed down). Books, youtube tutorials and anything what is capable of guideing me or anybody else in depth of a topic is well appriciated. The whole knowledge of a subject is better than a small topic cut down to understand, so long books,tutorials just as well welcomed as some quick explanations. Thank for the help!

    Topics: Networks,Internet as a whole,protocols: SQL and their databasis: webpage development,maybe javascript?: Python:

    I'm going to update this post and make links to the sources so anyone interested in these topics can find them more quickly. Thanks again!

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

    C# method for SubString not returning proper value

    Posted: 21 Feb 2018 12:31 PM PST

    I'm trying to get the info of a NFC card and then extract it's ID. Then if the ID is recognized this form would close and another would open. So Card Info -> Extract ID -> Check if it matches with previously saved ID -> Open another form.

    The ID is extracted and it works but then I get this error

    "An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: Input string was not in a correct format."

    when it reaches to parse int as you see below

    Here's my code:

     private void foundID() //this method takes the RFID card data output and strips it to the bare ID { string findID = textBox1.Text; string decID = findID; int indexOfFirstPhrase = findID.IndexOf("Card UID: "); if (indexOfFirstPhrase >= 0) { indexOfFirstPhrase += "Card UID: ".Length; int indexOfSecondPhrase = findID.IndexOf("Card SAK:", indexOfFirstPhrase); if (indexOfSecondPhrase >= 0) { decID = findID.Substring(indexOfFirstPhrase, indexOfSecondPhrase - indexOfFirstPhrase); } else { decID = findID.Substring(indexOfFirstPhrase); } MessageBox.Show(decID); string cardID = decID.Replace(" ", String.Empty); //Remove the spaces for the RFID ID code 

    This is where I get the Exception error:

     long intID = Int64.Parse(cardID); //Parse to Int 

    Rest of the code:

     if (intID == 9615987126) //Identify Each Card { MessageBox.Show("Welcome Card No.1"); } if (intID == 104382516) { MessageBox.Show("Welcome Card No.2"); } } } 

    The error is triggered after the scan as seen in this screenshot.

    I can't get my head around the error here.. I've tried changing the long variable into an Int, parse it differently. It's just not working, or I'm too dense to see an obvious issue. I hope it's the later since I need a quick fix.

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

    C++ Function not returning properly

    Posted: 21 Feb 2018 07:30 AM PST

    I'm writing a C++ function that takes a user's first and second name, and generates an email address in the format firstInitial.secondName@email.co.uk

    The code I currently have is as follows:

    string emailAddress(string fName, string sName) { return fName.at(0) + '.' + sName + "@email.co.uk"; } 

    This doesn't seem to apply the first initial or the dot. Any ideas why?

    EDIT: Thanks guys! I've managed to figure it out. I ended up changing the single quotes around the full stop to double quotes, and wrapping it in string(), therefore changing the line to return fName.at(0) + string(".") + sName + "@email.co.uk";

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

    I want to hear your opinion on SDK Docs. Best features, good examples etc.

    Posted: 21 Feb 2018 07:37 AM PST

    I'm doing research on SDK Docs. I'm looking to find good examples, what users like, what they don't like, and best practices. Anyone have any input?

    Thanks!

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

    C++ incomplete type error

    Posted: 21 Feb 2018 11:19 AM PST

    I get an incomplete type error for the following program for lines 10 and 11 , where I declare intcols and int kercols. what am i doing wrong?

     #include<iostream> using namespace std; int out[6][6]; int in[4][4] = { { 1, 2, 3, 4 },{ 5, 6, 7, 8 },{ 2, 1, 3, 7 },{ 3, 2, 4, 8 } }; int kernel[3][3] = { { 0, 1, 1 },{ 1, 0, 1 },{ 0, 1, 2 } }; int cols = sizeof(int[]) { 1, 2, 3, 4 } / sizeof(int); int kerCols = sizeof(int[]) { 0, 1, 1 } / sizeof(int); void conv2d(int rows, int cols, int kRows, int kCols) { int kCenterX = kCols / 2; int kCenterY = kRows / 2; int outHeight = rows + kRows - 1; int outWidth = cols + kCols - 1; for (int i = 0; i < outHeight; ++i) // rows { for (int j = 0; j < outWidth; ++j) // columns { for (int m = 0; m < kRows + 1; ++m) // kernel rows { int mm = kRows - 1 - m; // row index of flipped kernel for (int n = 0; n < kCols + 1; ++n) // kernel columns { int nn = kCols - 1 - n; // column index of flipped kernel // index of input signal, used for checking boundary int ii = i + (m - kCenterY); int jj = j + (n - kCenterX); // ignore input samples which are out of bound if (ii >= 0 && ii < outHeight && jj >= 0 && jj < outWidth) out[i][j] += in[ii][jj] * kernel[mm][nn]; } } } } } int main() { int rows = sizeof in / sizeof in[0]; int kerRows = sizeof kernel / sizeof kernel[0]; conv2d(rows, cols, kerRows, kerCols); int outRows = sizeof out / sizeof out[0]; int outCols = sizeof out[0] / sizeof(int); for (int i = 0; i < outRows; i++) { for (int j = 0; j < outCols; j++) { cout << out[i][j] << " "; } cout << endl; } } 
    submitted by /u/metalloidica
    [link] [comments]

    ELI5 what does #include <stdio.h> mean?

    Posted: 21 Feb 2018 02:09 PM PST

    I've looked up the definition everywhere but it's so dry and complicated to understand that I just don't understand what it means.

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

    Wanting to have a website where I can import, in real time data from Square POS. How do you do this?

    Posted: 21 Feb 2018 06:53 AM PST

    I have seen it done before but I can't for the life of me figure out where to get started with this. My restaurant uses Square POS and I want to set it up so I can view data such as "Sales from 9am to 10am" for a specific employee on a specific date.

    I'm sorry if this is in the wrong place but my understanding is that there is some decently, heavy programming involved to do so.

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

    Programming task for work application?

    Posted: 21 Feb 2018 12:12 AM PST

    So I've applied for some dev jobs in my life and some companies gives a programming test after the first interview if they liked me. You can do the test at home. Some times you have 48 hours deadline some times you can take as long as you want and it usually takes about 2-5 days.

    What is your thaught about this kind of tests? I find them fun and challenging and a good way to show my developing skills. However is it really fair that you shoould spend 6-20 hours on something for free? It's not even sure it will get you the job. I'm young I don't have kids or anything so I have the time. But for people with kids? I would never sacriface 10 hours in a week for free if i had kids and things to do.

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

    No comments:

    Post a Comment