• Breaking News

    Wednesday, December 6, 2017

    I've been programming for some time (just got my bachelors) but I strugle with solving those "what will this code print" questions fast and accurately in job interviews. Can someone point me to a website or book or something where I may find a lot of these questions, prefferably with answers? :D Ask Programming

    I've been programming for some time (just got my bachelors) but I strugle with solving those "what will this code print" questions fast and accurately in job interviews. Can someone point me to a website or book or something where I may find a lot of these questions, prefferably with answers? :D Ask Programming


    I've been programming for some time (just got my bachelors) but I strugle with solving those "what will this code print" questions fast and accurately in job interviews. Can someone point me to a website or book or something where I may find a lot of these questions, prefferably with answers? :D

    Posted: 06 Dec 2017 11:53 AM PST

    It's C++ , I forgot to say

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

    Get Shortest Path of an Equal Weighted Graph?

    Posted: 06 Dec 2017 09:53 PM PST

    [Java]: This is a Practice Exam Question that I can't seem to find an answer to.

    • Finds the shortest chain of people from p1 to p2.
    • Chain is returned as a sequence of names starting with p1,
    • and ending with p2. Each pair (n1,n2) of consecutive names in
    • the returned chain is an edge in the graph.
    • @param g Graph for which shortest chain is to be found.
    • @param p1 Person with whom the chain originates
    • @param p2 Person at whom the chain terminates
    • @return The shortest chain from p1 to p2. Null if there is no
    • path from p1 to p2

    public static ArrayList<String> shortestChain(Graph g, String p1, String p2) {

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

    Question about copyleft licenses and software distribution

    Posted: 06 Dec 2017 09:46 PM PST

    I work at a company that sells a proprietary SaaS product that can also be downloaded and run on a customer's computer, for example as a Docker image or rpm.

    We use plenty of open source libraries and have been quite careful to comply with the license terms of these libraries, especially when selecting libraries that we modify ourselves.

    But in reviewing the licenses of the libraries we use, there seems to be some uncertainty about copyleft licenses and what restrictions they place on us. I've tried to research the topic myself, but most of the language is quite unclear to me about whether simply bundling an unmodified copy of GPL or similar code and linking against it constitutes a derivative work or modification.

    My impression from reading the licenses and articles about them is that this is fine. As long as we don't modify the source code itself, we are free to bundle this software alongside our own code and either run it directly or import it and call it within our own code. We just need to distribute copies of the bundled library if requested.

    I'm looking for articles or other externally verifiable sources which make a definitive claim about this question. Most of what I find simply parrots the license document and doesn't clearly define or provide examples of what constitutes a modification or derivative work or what might otherwise 'infect' a codebase and product.

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

    Send a list over socket TCP Python

    Posted: 06 Dec 2017 09:27 PM PST

    Im trying to create a generator using server client that contains a lists of strings. Also its suppose to keep asking user for another string till user says no. I get the first string but when user types "yes" the whole list is spit back, not the randomly selected strings. Any help would be great.

    Server

    import random import socket Port =300 Server= socket.socket(socket.AF_INET, socket.SOCK_STREAM) Server.bind((socket.gethostname(),Port)) Server.listen(1) print ("The server is ready to recieve ") quotes = ["Hello son", "My favorite color is blood", "Where's Waldo?", "Help", "Mayo is better than ketchup"] while True: connectionSocket, addr = Server.accept() sentence = connectionSocket.recv(2048) for i in quotes: items = random.choice(quotes) connectionSocket.sendall(items.encode()) Server.close() 

    Client

    serverName = socket.gethostname() Port=3300 clientSocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) clientSocket.connect((serverName,Port)) msg = "Quote is: " while True: clientSocket.send(msg.encode()) msg = clientSocket.recv(2048) print(msg.decode()) x = input(("Would you like another quote? Type 'yes' or 'no' ")) if x =='yes': pass elif x == 'no': print ("Thanks for using me, bye! ") quit() else: print("Invalid input try again") clientSocket.close() 
    submitted by /u/Pandappl
    [link] [comments]

    Saving an array from a python program and using it in a java program.

    Posted: 06 Dec 2017 08:05 PM PST

    This might be the wrong subreddit for a question like this, but I made a program a while ago in program that will give a solution as an array, and I would like to be able to store that somehow so an app I am trying to make with android studio can access it. Currently I am thinking that I could just make the python write the array to a .txt and then have the app read from that file and make another array. Is this a bad way of doing things, would perhaps a json file work or is there something else I can do?

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

    why do non-programmers often think "destroy" is more drastic than "delete"?

    Posted: 06 Dec 2017 12:26 PM PST

    I have experienced this at two companies, with two different project managers now. The conversation goes something like this:

    Me: So, I'm going to implement the create and destroy routes.

    PM: Destroy? Haha. No, delete. Destroy sounds so drastic.

    I literally don't give a rats ass what we call the endpoint or whatever, but where does this come from? Is there any grounding to this distinction, that destroy is somehow more intense than delete?

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

    How did you get into using your rasberry pi?

    Posted: 06 Dec 2017 07:18 AM PST

    I have an idea of building a switch on my phone to start my coffee maker in the morning but I'm not sure where to start! Any tips/helpful links to get me started would be much appreciated!

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

    What do employers look for in a code portfolio?

    Posted: 06 Dec 2017 03:39 PM PST

    I have a lot of public code on my GitHub and I'm wondering if it's the kind of thing employers want to see.

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

    I need to write a simple set of "parental controls" for myself.

    Posted: 06 Dec 2017 02:47 PM PST

    I recently upgraded to Windows 10 and lost access to their parental controls and my Freedom subscription expired, so today seems like a good day to build something better.

    I'm pretty good at not doing things I shouldn't, but I have a lot of trouble getting around to things I should. I need something that will prevent me from going online or playing games in the morning until I complete a brief interactive experience in Pico 8 or Game Maker. Maybe it'll be a guided meditation or a quiz about how my goals are progressing. Whatever makes me more productive.

    The part I'm having trouble with is I have no idea how to interact with Windows 10. I need the program to run at a specified interval, read what should be blocked from a file, and block or (otherwise make inconvenient) access to websites and games. (although just steam would probably be sufficient). Is there an easy way to do this, or perhaps a program that does it already?

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

    Why does discordapp.com implement "crashing" in browser?

    Posted: 06 Dec 2017 10:38 AM PST

    Hello!

    I have seen websites implement their own loading spinner instead of using the native browsers loading bar.

    Discords "well, this is awkward. Looks like discord has crashed unexpectedly..." screen is a first to me though. I have never seen a website implement its own "crash" feature.

    I'm very curious about why this is done?

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

    New to web development - starting a project, how do I use a backend language?

    Posted: 06 Dec 2017 02:10 PM PST

    I'm starting a project creating a web application, I have some basic knowledge of HTML, CSS, PHP and have quite a bit of experience in Java.

    I am taking this project to learn some more languages, and I have been recommended to use Ruby on Rails. I have been learning some basic Ruby, but do not actually know how to implement it in the web app.

    In the basic websites I have tried to create with PHP, all I have to do is include <?php and end with ?> and put all my PHP in the middle. However, I can't really seem to figure out how to use Ruby On Rails as my backend language.

    Can anyone give me any help or any pointers? Thanks

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

    Deleting/Counting items in LinkedLists

    Posted: 06 Dec 2017 01:44 PM PST

    Small problem i am having with a program here. I am trying to create a program that adds Words to Linked Lists within a Array depending on their hashCode, determined by my hashFunction. If they have the same value for their hashCode they get added into a Linked List. I have a small count method that counts how many times a word is in the List. It works by computing the value for their hashFunction. It then goes to that value in the array, and iterates through the LinkedList until it reaches a Null value. It has a count variable which is incremented each time it finds the word in the list. This is my code:

    public class test{

    public static class Node<T>{ public T data; public Node<T> next; public Node(){ } public Node(T data, Node<T> next) { this.data = data; this.next = next; } } static Node[] array = new Node[512]; public static void add(String word){ int position = hashFunction(word); if(array[position] == null){ array[position] = new Node(word, null); }else{ Node newHead = new Node(word, array[position]); array[position] = newHead; } } public static void remove(String word){ int remove = hashFunction(word); Node head = array[remove]; if(head.data == word){ head = head.next; System.out.println("Found"); }else if(head.data != word){ for(; array[remove] != null; array[remove] = array[remove].next){ if(array[remove].data == word){ array[remove] = array[remove].next; } } System.out.println("Yusuf"); } } public static int count(String word){ int number = 0; int position = hashFunction(word); for(; array[position] != null; array[position] = array[position].next){ if(array[position].data == word){ number++; } } System.out.println(number); return number; } public static int hashFunction(String a){ int sum = 1; for(int i = 0; i<a.length(); i++){ char b = a.charAt(i); int value = (int) b; sum *= value; } return sum % array.length; } public static void addthings(String word, int n){ for(int i = 0; i<n; i++){ add(word); } } public static void main(String[] args) { addthings("abc", 500000); count("abc"); count("abc"); count("abc"); count("abc"); } 

    } My issue is the first time I add values in it and check how many times it occurs it works fine, but any more calls to the Count method after that returns 0 for some reason.

    I have another issue too which is my remove method isn't removing the items from the Linked List I want it too. The code iterates through the List, and when it finds the item which is meant to be removed, it removes the pointer from there and points it to the next value. This isn't working however.

    Can someone show me how to fix these two issues please?

    Thanks.

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

    [Java/Android]What's the most efficient method of transfering sensor data from an Android device to a computer, via wifi?

    Posted: 06 Dec 2017 09:49 AM PST

    I plan to stream sensor data from an Android device to a computer running a complex event processing engine, via wifi. The objective is to analize these information in real time and look for some specific criteria.

    I thought about serializing and deserializing the sensor data by using the Serializable interface. I considered this because this is the only way I know how I am able to transfer the data and metadata in a structured form.

    What would be the fastest and most efficient way to get the data from the device to the computer? I am pretty sure serializing isn't my only option, but I really don't know where to start looking.

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

    Is “Web Content Management” Software considered its own stack or does is it a layer within a stack?

    Posted: 06 Dec 2017 09:14 AM PST

    So my background is General Software Development, so my experience with web development outside of basic HTML, CSS, and JavaScript is limited. I recently got a temporary job as a User Experience Website QA tester, yes that is a mouthful. I want to get as much as I can out of this temporary job.

    I figured since I lack a background in web development this could help me learn a thing or two about web development.

    So what is content management software? I understand the basics of what full stack is and what a basic web stack consists of. How does web content management software fit into a stack or is it already a stack?

    And if you have sources on full stack feel free to share them with me as I wish to learn.

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

    What VM do you use for your programming job on your home PC?

    Posted: 06 Dec 2017 02:02 AM PST

    Hi all, so ftping or sshing to a client's server on my own pc really makes me scared I'll accidentally transfer a personal file over to their server of something. I don't really want a separate PC for work so I'd prefer to just use a VM.

    What VM do you use for your programming jobs? And is it free?

    Please note by VM I don't mean Linux distribution but rather software for the virtualisation. Like virtual box or vmware.

    Thanks.

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

    C/Arduino When sending input, the first IF condition gets initiated regardless of the value given by the user.

    Posted: 06 Dec 2017 10:41 AM PST

    When I send an input to the IF statement it completely ignores the input and initiates its first argument regardless of its actual value.

    I want the second statement to initiate but its not working no matter how I tackle it.

    char userInput; void loop() { userInput = Serial.read(); if (Serial.available() > 0) { 

    Changing the value which corresponds to the input does nothing.

     if (userInput = '1') { <-------- Changing it to '5' or other numbers are ignored. Serial.println("\n Sign In Initiated"); logIn::setup(); while (true) logIn::loop(); } 

    This statement gets ignored.

     else if (userInput = '2'){ Serial.print("\n Sign Up Initiated"); enroll::setup(); while (true) enroll::loop(); } else { Serial.println("Not a number."); } } // end: if (Serial.available() > 0) } 

    Full Snippet

    char userInput; void loop() { userInput = Serial.read(); // get the character if (Serial.available() > 0) { // is a character available? // check if a number was received if (userInput = '1') { Serial.println("\n Sign In Initiated"); logIn::setup(); while (true) logIn::loop(); } else if (userInput = '2'){ Serial.print("\n Sign Up Initiated"); enroll::setup(); while (true) enroll::loop(); } else { Serial.println("Not a number."); } } // end: if (Serial.available() > 0) } 

    Full Code

    #include <Adafruit_Fingerprint.h> #include <SoftwareSerial.h> SoftwareSerial mySerial(2, 3); Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); #include <Adafruit_Fingerprint.h> namespace logIn { void setup() { Serial.begin(9600); while (!Serial); delay(100); Serial.println("\n\nAdafruit finger detect test"); // set the data rate for the sensor serial port finger.begin(57600); if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1) { delay(1); } } Serial.println("Waiting for valid finger..."); } uint8_t getFingerprintID() { uint8_t p = finger.getImage(); switch (p) { case FINGERPRINT_OK: Serial.println("Image taken"); break; case FINGERPRINT_NOFINGER: Serial.println("No finger detected"); return p; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); return p; case FINGERPRINT_IMAGEFAIL: Serial.println("Imaging error"); return p; default: Serial.println("Unknown error"); return p; } // OK success! p = finger.image2Tz(); switch (p) { case FINGERPRINT_OK: Serial.println("Image converted"); break; case FINGERPRINT_IMAGEMESS: Serial.println("Image too messy"); return p; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); return p; case FINGERPRINT_FEATUREFAIL: Serial.println("Could not find fingerprint features"); return p; case FINGERPRINT_INVALIDIMAGE: Serial.println("Could not find fingerprint features"); return p; default: Serial.println("Unknown error"); return p; } // OK converted! p = finger.fingerFastSearch(); if (p == FINGERPRINT_OK) { Serial.println("Found a print match!"); } else if (p == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return p; } else if (p == FINGERPRINT_NOTFOUND) { Serial.println("Did not find a match"); return p; } else { Serial.println("Unknown error"); return p; } // found a match! Serial.print("Found ID #"); Serial.print(finger.fingerID); Serial.print(" with confidence of "); Serial.println(finger.confidence); return finger.fingerID; } // returns -1 if failed, otherwise returns ID # int getFingerprintIDez() { uint8_t p = finger.getImage(); if (p != FINGERPRINT_OK) return -1; p = finger.image2Tz(); if (p != FINGERPRINT_OK) return -1; p = finger.fingerFastSearch(); if (p != FINGERPRINT_OK) return -1; // found a match! Serial.print("Found ID #"); Serial.print(finger.fingerID); Serial.print(" with confidence of "); Serial.println(finger.confidence); return finger.fingerID; } void loop() // run over and over again { getFingerprintIDez(); delay(50); //don't ned to run this at full speed. } } // ******** namespace enroll { uint8_t id; void setup() { Serial.begin(9600); while (!Serial); // For Yun/Leo/Micro/Zero/... delay(100); Serial.println("\n\nAdafruit Fingerprint sensor enrollment"); // set the data rate for the sensor serial port finger.begin(57600); if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1) { delay(1); } } } uint8_t readnumber(void) { uint8_t num = 0; while (num == 0) { while (! Serial.available()); num = Serial.parseInt(); } return num; } uint8_t getFingerprintEnroll() { int p = -1; Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id); while (p != FINGERPRINT_OK) { p = finger.getImage(); switch (p) { case FINGERPRINT_OK: Serial.println("Image taken"); break; case FINGERPRINT_NOFINGER: Serial.println("."); break; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); break; case FINGERPRINT_IMAGEFAIL: Serial.println("Imaging error"); break; default: Serial.println("Unknown error"); break; } } // OK success! p = finger.image2Tz(1); switch (p) { case FINGERPRINT_OK: Serial.println("Image converted"); break; case FINGERPRINT_IMAGEMESS: Serial.println("Image too messy"); return p; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); return p; case FINGERPRINT_FEATUREFAIL: Serial.println("Could not find fingerprint features"); return p; case FINGERPRINT_INVALIDIMAGE: Serial.println("Could not find fingerprint features"); return p; default: Serial.println("Unknown error"); return p; } Serial.println("Remove finger"); delay(2000); p = 0; while (p != FINGERPRINT_NOFINGER) { p = finger.getImage(); } Serial.print("ID "); Serial.println(id); p = -1; Serial.println("Place same finger again"); while (p != FINGERPRINT_OK) { p = finger.getImage(); switch (p) { case FINGERPRINT_OK: Serial.println("Image taken"); break; case FINGERPRINT_NOFINGER: Serial.print("."); break; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); break; case FINGERPRINT_IMAGEFAIL: Serial.println("Imaging error"); break; default: Serial.println("Unknown error"); break; } } // OK success! p = finger.image2Tz(2); switch (p) { case FINGERPRINT_OK: Serial.println("Image converted"); break; case FINGERPRINT_IMAGEMESS: Serial.println("Image too messy"); return p; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); return p; case FINGERPRINT_FEATUREFAIL: Serial.println("Could not find fingerprint features"); return p; case FINGERPRINT_INVALIDIMAGE: Serial.println("Could not find fingerprint features"); return p; default: Serial.println("Unknown error"); return p; } // OK converted! Serial.print("Creating model for #"); Serial.println(id); p = finger.createModel(); if (p == FINGERPRINT_OK) { Serial.println("Prints matched!"); } else if (p == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return p; } else if (p == FINGERPRINT_ENROLLMISMATCH) { Serial.println("Fingerprints did not match"); return p; } else { Serial.println("Unknown error"); return p; } Serial.print("ID "); Serial.println(id); p = finger.storeModel(id); if (p == FINGERPRINT_OK) { Serial.println("Stored!"); } else if (p == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return p; } else if (p == FINGERPRINT_BADLOCATION) { Serial.println("Could not store in that location"); return p; } else if (p == FINGERPRINT_FLASHERR) { Serial.println("Error writing to flash"); return p; } else { Serial.println("Unknown error"); return p; } } void loop() // run over and over again { Serial.println("Ready to enroll a fingerprint!"); Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as..."); id = readnumber(); if (id == 0) {// ID #0 not allowed, try again! return; } Serial.print("Enrolling ID #"); Serial.println(id); while (! getFingerprintEnroll() ); } } void setup() { Serial.begin(9600); Serial.print("1- Sign In "); Serial.print("2- Sign Up "); } char userInput; void loop() { userInput = Serial.read(); // get the character if (Serial.available() > 0) { // is a character available? // check if a number was received if (userInput = '1') { Serial.println("\n Sign In Initiated"); logIn::setup(); while (true) logIn::loop(); } else if (userInput = '2'){ Serial.print("\n Sign Up Initiated"); enroll::setup(); while (true) enroll::loop(); } else { Serial.println("Not a number."); } } // end: if (Serial.available() > 0) } 
    submitted by /u/seever
    [link] [comments]

    Creating a bot to fill out Google Forms?

    Posted: 06 Dec 2017 10:31 AM PST

    Is there any way I can automate responses to a Google Form? My form consists of multiple choice answers and one text based response. How can I loop this survey multiple times for as many responses as I need?

    Thanks!

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

    Chrome extension issue.

    Posted: 06 Dec 2017 04:28 AM PST

    Hi! I am trying to upload a chrome extension and I keep getting this: https://gyazo.com/014c43266ae1b7280b3dc9c091c2202c

    Here is my manifest.json code: https://gyazo.com/6c3e9987e503d2642ff9543eb3be7b42

    The "icons" is underlined green.. Is there any way to fix it without ruining the code?

    Thanks, Effable.

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

    LinkedList in Array not working properly.

    Posted: 06 Dec 2017 09:50 AM PST

    Hi, I am trying to create a program to store words in a Array. I have a hashFunction which computes a Integer value. This value is used to put the Word in a Node if that position in the array is null. If there is already a Cell there, it should create a new Cell with the word as its data type, and it should then point to the old Cell with all the other data. However this dosen't seem to be working - I have added a few words and although it adds the first word to the Cell the other words aren't being added. I'm not sure why this is happening - can someone show my why?

    public class test2{

    public static class Node<T>{ public T data; public Node<T> next; public Node(T data, Node<T> next) { this.data = data; this.next = next; } } static Node[] array = new Node[10]; public static void add(String word){ int position = hashFunction(word); if(array[position] == null){ array[position] = new Node(word, null); }else{ new Node(word, array[position]); } } public static int hashFunction(String a){ int sum = 1; for(int i = 0; i<a.length(); i++){ char b = a.charAt(i); int value = (int) b; sum *= value; } return sum % array.length; } public static void main(String[] args) { add("abc"); add("acb"); add("bca"); add("bac"); add("cba"); System.out.println(array[4].next); } 

    }

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

    How do you extract text from a lot of websites?

    Posted: 06 Dec 2017 03:21 AM PST

    Hi, I'm a linguistics student looking to crawl the text of The Daily Telegraph website, and I need your help. I realize you can 'save as' to get the .txt file of a website, but I don't know how to do it to hundreds, potentially thousands of websites :(

    Any help would be greatly appreciated!

    Also, sorry if the description is a bit confusing; I've only recently started on programming, so everything's a bit of a challenge to grasp and I may not be using the correct (or most descriptive) jargon.

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

    406 - MIME Type Error For .xls On IIS Server

    Posted: 06 Dec 2017 05:38 AM PST

    Hi All,

    I'm working on a NetSuite script which needs to get a .xls file from a remote IIS server, save it to the NetSuite file cabinet, then serve the file to the user. The script works with all other file-types and it works for .xls files from Apache servers I tried but when I try to get a .xls from the IIS server I get:

    406 - Client browser does not accept the MIME type of the requested page.

    The MIME type on the IIS server for .xls is set to application/vnd.ms-excel and we've tried just about every different combination of 'Content-Type' and 'Accept' headers possible to no avail. Has anybody encountered a similar issue streaming .xls files from an IIS server? Any help would be greatly appreciated.

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

    No comments:

    Post a Comment