• Breaking News

    Saturday, September 1, 2018

    Here's a list of coding exercises to help get you from "Beginner" to "OK" in a language learn programming

    Here's a list of coding exercises to help get you from "Beginner" to "OK" in a language learn programming


    Here's a list of coding exercises to help get you from "Beginner" to "OK" in a language

    Posted: 01 Sep 2018 06:56 AM PDT

    EDIT: By "OK" I mean that you can stumble your way through a relatively basic problem. If someone says "I can speak French OK", I wouldn't expect them to seamlessly translate complex thoughts from English to French. I would expect them to be able to walk around Paris, order food from a menu, ask where something is, etc. You may disagree with the word I chose to use, but that was the intent I was going for. Obviously there is MUCH more to programming that this stuff.

    Hey all,

    I'm currently a developer in the industry and I see a lot of posts on "How should I get started with learning XYZ language" so I thought I'd make a list of exercises (that increase in difficulty) that should familiarize yourself with any given language. If anyone finds this useful, I can continue to add more exercises with more difficulty:

    1. Hello World: Create a program that outputs "Hello World".

    2. Loop: Create a program that loops 10 times and output the current loop (ex. "I'm on loop 6", then "I'm on loop 7").

    3. First Class: Create a class called "Car" that has 1 variable called "licensePlate". Within the class, create a default constructor that sets "licensePlate" to 'Unknown' and a method/function called "getLicensePlate" that returns the variable "licensePlate".

    4. Second Class: Add a second Car constructor to our class that takes 1 input of type String. This is the license plate number. Assign the value of the inputLicensePlate to our variable licensePlate.

    5. Inheritance: Create an abstract class called "Vehicle". Within "Vehicle", create a variable called 'wheels" and create a method/function called "getWheels" and return the variable wheels with that method. In addition, create an abstract method/function called "washVehicle". NOTE: Usually you would create an Abstract class BEFORE creating the concrete class implementation (so you'd create Vehicle and then extend Car/Motorcycle after that) but in this specific case I wanted to make sure everyone knew how to create a simple class before going on to an Abstract class.

    6. Inheritance pt. 2: Make your Car class from before inherit from the Vehicle class. Alter the constructors accordingly and override the necessary functions/methods. In the Car class, your "washVehicle" method should output a String that reads "I'm going through the car wash!".

    7. Inheritance pt. 3: Create a "Motorcycle" class that inherits from the Vehicle class. Create the necessary constructors (wheels = 2, etc). For the "washVehicle" method, output a String that reads "I'm washing my motorcycle by hand!".

    8. I/O: Create a text file with 10 lines of license plates in it followed by the type of vehicle (for example, one line in the file would read "ABC123 Car"). Add an instance variable of type String called "make". Read the file and create an ArrayList of Vehicle objects with the corresponding attributes from the file. Every time a vehicle object is created, ask the user for an input for the make of the vehicle (ex: "Ford"). After array list is created and the file is read, output the contents of the ArrayList.

    9. Put it all together: Create a text based game that lets a player role play as Frodo as he goes from the Shire to Weathertop. There is no combat system necessary, this is entirely story based. Allow the player to pick from a few choices to further the story along. Certain choices should kill the player if he chooses incorrectly. Every choice should be output to a text file. Bonus points if you implement an inventory function. Try and think about sources of errors when you go along. Any time a user is allowed input into your program, that can open your program up to a ton of bugs.

    10. Bonus: Write unit tests for your code in step 9. Unit tests are VERY important. Any dev team worth its weight in gold will test (ha) you on this in your interviews.

    11. Bonus pt. 2: Go back to number 8 and start from the ground up using the "Test Driven Development" methodology. TDD is a different way of approaching coding design and I've been quizzed on a it a couple of times in interviews.

    Version Control: Create a GitHub project repository and upload your code there.

    Critique: Share your GitHub project here if you have any questions or want any critiques!

    Profit: Make $200k because you're now the greatest developer since Bill Gates.

    In all seriousness, feel free to reach out to me for any advice or guidance! If you run into a brick wall and can't figure it out, don't sweat it! Half of my coding time is spent reading documentation, StackOverflow, and google. I won't give you the right answer, but I'll point you in the right direction!

    EDIT: More problems. These will be a little more in-depth and assume you have the basics of your language down. I'll try and throw in some problems from my past interviews. A lot of them can probably be found online on leetcode or the like, so don't expect any groundbreaking stuff here.

    1. Fibonacci Sequence Calculator: From an interview with a fairly popular messaging app company in Asia. Create a program that calculates the nth number in the Fibonacci sequence. What is the your runtime? Can you think of any better ways to calculate it?

    2. Design Exercise: You are tasked with creating the battle system for Creative Assembly's "Total War Warhammer". The following are the requirements:

    • A battle is in real time between 2 players (one AI, one human player)

    • Each player has anywhere from 1 to 20 units (or squads)

    • Each unit is comprised of anywhere from 1 to 120 individual models.

    • Every model within the unit has the same stats (attack, defense, armor, etc) EXCEPT for "current health" (which will change as the battle progresses).

    • Each model does damage to an enemy model based on a formula Creative Assembly uses (I'll add this when I remember where it was)

    • A player wins when the enemy has no more units

    • For simplicity's sake, start off with Player A having 1 unit of melee units and Player B having 1 unit of melee units.

    • Minimum Viable Product: Battle Report should output a list of each player's units before the battle. Upon 1 player's victory, another Battle Report should be generated that states the winning players current unit's, unit size, etc. No need to display graphics, a simple text will do.

    • At a high level, how would you design this? Would you use an inheritance structure or something different? How would you scale your program from 2 total units in combat to 20 vs 20 (with potentially thousands of models engaging in combat)? Are there any constraints to the language you're using? If I added a requirement of "only IndividualModels within X distance of the enemy can attack", how would you approach this?

    1. Island Counter: This was from an interview with a midsized company for a Backend Dev position: You have a 2-dimensional array (or grid) of 1's and 0's. The 1's represent "land" and the 0's represent "water". An island is defined as a group of at least 1 "1" that is surrounded by water. It is assumed that the edges outside of our grid are water for the sake of simplicity. Create an algorithm that calculates how many UNIQUE islands are present in our grid. What is your runtime? Is there any improvement that can be made to your runtime?

    2. Multi-threading: I'd like to input a multi-threading problem in here, but I can't think of one off the top of my head. I'll edit later as I think of it.

    3. Data Pulls: You are the developer for an organization that needs data from different data sources. These data sources are comprised of databases (Oracle, MySQL, Postgres), copying and pulling flat files (.txt, .csv, .tsv), using FTP to pull an XML file, and a potential for many future data sources to be added. You are tasked with creating a brand new "data pull program" that manages the various data source pulls. All data sources must be written to a file of some kind and stored on a generic file server in any format you wish (so SQL query results should be written to a file and then sent to the destination).

    • How would you design this? What language would you use? Are there any frameworks/libraries you can think of that would assist you?

    • What are some potential issues you could run into? What sort of Unit Tests would you write to test out the various pulls?

    • How would you manage to QA each file to ensure it is complete and accurate (with no dropped data between source and destination)?

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

    Feeling like a speck in the ocean of aspiring programmers and programmers

    Posted: 01 Sep 2018 10:34 PM PDT

    I've simply flirted with the idea of programming this year, jumping into a python course and stopping at the 6th episode or taking a Codeacademy course up to lesson 3, somethings always been pushing me away from finishing it. I began to think about this more thoroughly when my aunt said she was going to take a programming course to become a web developer to get a better job, and when I heard someone at school talking about how their little brother is making a programming project with his friends.

    "Seems like everyone's starting to program now."

    I felt.. disposable.

    Not that I believed that my cousin or the person's brother were disposable, but it was an invasive intrusive thought. "So many programmers! Who am I to jump into this when so many other people are doing it too, some for steel-like motivations? Who am I to try and learn this when there are people doing this because they have mouths to feed? Who am I to try and learn this when I've never been considered gifted or technically capable in my life, and frankly most often- the opposite?" This train of thinking assaulted me with every second I spent trying to learn or follow the course, any mistake or failure or question or lack of knowledge simply making this voice in my head louder and louder, "You definitely can't do this!" Mixed in with my general feelings of vulnerability and being condescend upon showing lack of education to other people.

    I wonder why I don't feel this way about art. When i'm making a piece, i'm not thinking about all the other people watching a drawing course or making an animation in a studio, I generally think about the piece. Maybe it's because I've seen multiple artists be appreciated for the individual unique work they do to a point that I may feel occasionally that it isn't bad that there are millions of other artists out there, because there's something that I and they individually bring to the table and that I can hone upon to make it my own for other people, and if not; whatever! I like the feeling of making lines on paper, even if it's "garbage" to other people. I can't deny that the aspect of not being able to make money off of my art when things get hard has scared me into putting as much time as I like, but in my heart for some reason I just enjoy it.

    In programming, however, this feeling takes a quick 180. I've generally felt that my love for programming wasn't that genuine (despite these feelings being influenced by other things like this) and that I didn't seem to have anything innate being able to help me laugh even when I was stumbling on the floor wondering what this or that is. I can't deny that some of my feelings upon wanting to program and do STEM things has been from being in a lower income family (The prospect of having to get a scholarship to do anything academically after high school has been waved to me more than anything else in my life right now), and wanting to prove all the people that said I was less capable and "not built for this" wrong that I can learn to do the technical things that I've wanted to do, and anyone else can, too!

    I generally don't possess the knowledge on any programmer topics, but despite people saying that different programmers do things differently and individual problem solving ideas are embraced in coding, I keep feeling that it's more technical and rigid, especially when people talk about 'good' and 'bad' programmers. I already only have a brief idea of the types of programming people do for certain things, and maybe I might stumble upon something that makes me want to do it every waking second of the day, regardless of what anyone thinks. But right now, I can't even get through a single course without feeling like a nobody who doesn't deserve to try. How do I stop being fussed about all the other people learning to program or making projects or just anything with their programs, and start focusing on how I feel going on this journey and exploring more about what programming is? How do I stop feeling like the field of programmers is so saturated and it's like a candy shop for employers to choose and spit out as they please because they'll always be someone else at the door who's just trying to feed their kids? I feel that I don't even deserve to take up space, much less be seen as a ""dummy"" for all the things I don't know, can't solve and need help with?

    I don't know, i'm just lost. Has anyone else felt like this, and what did they/you do? Thanks.

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

    A Collection Of Projects For Learning Multithreading/Concurrency

    Posted: 01 Sep 2018 02:57 PM PDT

    Hi everyone. Recently someone posted a question on here about learning multithreading/concurrency by doing projects. I wrote up a really simple answer, but it got me thinking about different types of projects you could do in order to get better with some of the concepts. I put together this collection not as a definitive set of projects, but more as a list of things I personally find interesting. If you want a truly in-depth look into this area of CS/programming, I would recommend finding a book written by one of the experts (i.e., C++ Concurrency In Action).

    These are split into categories, but I think you can actually skip around if you feel comfortable doing so. Also note that you can just try for a working solution on all of these. I've found that professional-grade solutions to these tend to be far and above the more obvious implementations efficiency-wise, so don't worry too much about it unless you want an added challenge.

    First

    1. Implement a simple, thread-safe linked list. Any number of threads should be able to attempt a write/read of the list at any time. There are no restrictions about how you do this, just that it should be safe to use for [1..n] threads. The simplest way to do this would be to use one mutex per linked list, and anytime a thread wants to use that list it acquires the mutex.
    2. Implement a semaphore. It should have two methods: acquire() and release(). Since semaphores can be used to only allow a certain number of threads to progress at any given time, an initial count should be specified (ex: 10 or 0). If more threads call acquire() than there are available slots, the extra threads will block until a slot does become available. Any thread can call release() to signal that a new slot has just opened up.
    3. Implement a busy-waiting lock (spinlock). It has two methods: lock() and unlock(). It gets its name from the fact that for any thread calling lock(), that thread will loop (spin) while it waits for the lock to become available without ever explicitly yielding to other threads. This way, it always tries to use up its full time slice on the CPU core its running on. The restrictions are as follows: lock() should cause the calling thread to block if another thread owns the lock. unlock() should never succeed if the calling thread does not actually own the lock. You can assume that a thread will never call lock() twice in a row without calling unlock() (this is sometimes called a recursive lock).
    4. Implement an atomic variable. This should only use atomic operations rather than a locking mechanism. It should support three operations: load(), store(), compare_exchange(). The load operation performs an atomic load and returns that value. The store operation performs an atomic set of the variable, meaning that if 2 threads call store() at the same time, there is no race condition. Compare_exchange is interesting because it is saying "If the variable is equal to expected, set it to newValue, otherwise fail." The method's signature might look something like: bool compare_exchange(var expected, var newValue). A return value of "false" means that the value of the variable was not equal to expected, so it failed to set it to the new value.
    5. Implement a shared lock. It supports 4 methods: lock(), unlock(), shared_lock(), shared_unlock(). Lock and unlock work the same as the spinlock mentioned above. However, shared_lock() has the special property that any number of threads can call this to signal that the lock is occupied. If lock() is called when some number of threads have already called shared_lock(), that thread will block until all of those threads have called shared_unlock. Likewise, if any thread has called lock() and then another thread calls shared_lock(), the second thread will block until unlock() has been called.

    Second

    1. Implement a concurrent stack. This should support two operations: push() and pop(). The only restriction is that it must be lockfree, meaning you can use atomic operations, but using something like a mutex to secure access to the stack is not allowed.
    2. Implement a concurrent queue. You can draw inspiration from APIs like boost::lockfree::queue or Java's ConcurrentLinkedQueue.
    3. Implement an amusement park ride similar to Jurassic Park from Universal Studios. There is one station that dispatches the rides, and [1..n] cars. With this setup, the station is its own thread and the cars are also their own threads. All car threads start off as parked at the station. Every update, people randomly arrive at the station's queue. Whenever there are enough people to fill a ride and there is an available car, they are loaded up and the car is sent off. The car then begins its own simulation which lasts for a certain number of seconds before it arrives back at the station. It must then wait for its presence to be acknowledged so that the people inside the recently-arrived car can be unloaded, and the car marked as ready for departure once again.

    Third

    1. Implement a concurrent hash map. Note that there are existing concurrent hash maps that are ridiculously fast in the face of a high number of threads accessing the table, so my requirements will attempt to make it more doable. This version can use a mixture of atomic operations and locking and is subject to the following requirements:
      1. If two threads are writing to different segments of the hash table, they will not block each other.
      2. If one thread is writing to a segment of the hash table while another is reading from another segment of the hash table, they will not block each other.
      3. If all threads are performing read-only operations on any segment of the hash table, they should never block each other.
      4. If two threads write to the same segment at the same time, or one is writing while another is trying to read the same segment, they are allowed to block each other.
    2. Design Conway's Game of Life using a 10,000 by 10,000 grid. It should be configurable to run with 1+ threads. When there are 2 or more threads, the grid should be sectioned off such that each thread updates a specific region of the board. In this way, synchronization will largely be unnecessary except on the boundaries where one thread's section crosses over into another thread's section. When a thread completes one iteration of an update, it should wait until the control thread signals that it's ok to start the next iteration (this way, all threads are all working on the same time step). This should display a very simple, 2D cell-based grid to show the board as it changes at each update.
    3. Implement a custom job scheduler that runs with 1+ threads, where the number of threads is configurable. With this set up, a "job" is simply a function to execute. In C this might be a function pointer whereas in C++/Java/Haskell it would be a first-class function object. The job scheduler will have two main methods: submit() and waitForJobList(). submit() is used whenever a thread wants to submit a new list of jobs to be executed on the scheduler's pool of threads. waitForJobList() is for a thread that has submitted a job list but now wants to wait until that list has completed before it continues its execution. Here are the requirements:
      1. If there is only 1 thread managed by the job system and it calls waitForJobList(), it should not cause a deadlock. The job scheduler should be smart enough to deal with this situation so that multiple jobs can be running concurrently.
      2. If there are [n] threads managed by the job system and all of them call waitForJobList at the same time, this still should not cause a deadlock.
      3. If a thread that is not managed by the job system calls waitForJobList (i.e., the program's main thread calls this), the job system should be able to deal with this. It should either cause the external thread to spin until the job list finishes, or it should temporarily convert it to a job worker thread so that it can help execute jobs.

    And that's my list! I hope at least one of those sounded interesting to you. If I remember something I left out or someone writes something up in the comments then I'll add to this list.

    Feel free to comment here or send me a PM if you're starting on one of them and want some clarification or some reading material. I'll try to dig up whatever I can.

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

    ELI5: What exactly does Apache Zookeeper do and why is it needed in the Hadoop ecosystem

    Posted: 01 Sep 2018 11:48 PM PDT

    As title says, Im confused about what exactly zookeeper does, how the z nodes of zookeeper are related to data nodes of Hadoop. How would you use Zookeepr in conjunction with Hadoop (any simple example would do) Thanks.

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

    C# inn- Community for people who want to learn programming (either from 0 or become better) while sharing their experience

    Posted: 01 Sep 2018 11:35 PM PDT

    Hello! Are you someone who would like to learn programming from 0 and (or) at the same time are afraid to start, because you don't think you can handle it? Maybe you're someone who would like to convert to C# or learn object oriented programming. Maybe you simply want to help or share your experience? Well then, how about learning with a help of a teacher, within a community full of people just like you?

    We're a growing community on Discord- C# Inn, focused on sharing our experience and help people to start off as programmers or become better at what they do and grow.

    Twice a week I offer free lessons on Discord for two groups of people: For those who know nothing (programming principles) and for those who know some (oop and c#). Lessons are in a format of live coding on cooperative wall on Rextester.com. Lessons material is being added every week, written by me and posted on Discord. I try to record everything too, but so far I was a bit lazy about it. Everything is free of charge.

    The best way of learning, in the end, if by doing something yourself. So we are forming groups of 3-5 people and by the end of September will try to start making group projects.

    If any of that interest you, go ahead and join our community :) Our Discord can be found at: https://discord.gg/vWE4Pc9

    -Have a good day :)

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

    Learn NodeJS Asynchronous Programming

    Posted: 01 Sep 2018 10:31 PM PDT

    Hello. I want to be a full stack developer.

    Posted: 01 Sep 2018 10:23 PM PDT

    TLDR at bottom.

    Hey reddit, since the age of 8 I've always been fascinated about computers and considered choosing a job that included something to do with computers, one of my dreams were to be a video game developer, it's still one of my dreams but not as strong as it was before. As I am 13 years old, my school has a program that helps us decide our careers, for me, I had no idea. It seemed like all my friends had clues of what they wanted to be except me. Not until I heard about web developing, I heard about it on a certain article, specifically "front-end and back-end developers" shortly after I learnt about full-stack developing and spent 2 weeks thinking about doing that for my career. (I was always interested in how people made websites, lol when I was little I did inspect element on webpages and showed them to people "bragging" about how I could hack, stupid me) Anyways after 2 weeks passed and no other careers interested me, (except ethical hacking, always wanted to troll those damn scammers) I made the final decision of choosing to be a full-stack developer, since I have already started to learn html and css (just the basics, nothing fancy) I wanted to get a clue on what I should do from there, I practice everyday and try and perfect the basics of html and css before I move on to more advanced levels of it, (I know html and css aren't the only necessary languages to become a full-stack developer but I have to start somewhere,) these are the videos I have watched to learn the basics of html and css: this, this, and this.

    tldr; I'm a complete noob in web developing and want to become a full-stack developer. I only know the basics of html and css and want to get help from there, what should I do?

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

    I'm not sure if i am an idiot or this is some sort of trick question but what's the size of a bit vector?

    Posted: 01 Sep 2018 09:49 PM PDT

    We are learning implementation of algorithm in class and the teacher asked our class, what was the size of a bit vector. We all gave answers except him. He just told us that we should study it and try to find out. Now unless I don't understand this, since a bit vector uses ones and zeros, wouldnt it just be the same as the int? 4 bytes?

    Is this some sort of trick question or do but vectors have a different size from ints? I did some Google searching and couldn't find a conclusive result?

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

    Help with lists

    Posted: 01 Sep 2018 09:46 PM PDT

    For assignment 1 print a list of your three favorite places to visit in the Los Angeles area (e.g. Griffith Observatory at night, Annenberg Beach House, Santa Monica Pier, etc.). Do not just copy the list provided but create your own list. Number your list as shown in the example without using the numbers 1, 2, or 3. Use only the number 5 in your program to print 1, 2, and 3.

    number = 5 print("My three favorite places to go in the Los Angeles area are: \n" + str(number - 4) + " The Santa Monica Pier\n" + str(number - 3) + " Little Tokyo\n" + str(number - 2) + " The Promenade after school") 

    I went with this at first and the teacher said to not use the number 1 2 or 3 anywhere in the script. So i'm guessing he means

    for i in range(5): 

    idk I suck at this :/" Use only the number 5 in your program to print 1, 2, and 3"

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

    Tech Interview Crash Course/Reviews

    Posted: 01 Sep 2018 09:40 PM PDT

    So I'm planning to start applying to companies in a few weeks, and I am looking for some crash course or review resources to go through in preparation.

    I've read all of Algorithms by Robert Sedgewick, have worked on personal projects (so I'm up to speed with web frameworks and such), I majored in CS and have completed Colt Steel's Web Deb Bootcamp online, so I think I have a pretty good understanding of most structures and algorithms and web programming fundamentals, but I keep forgetting ones that I don't use a lot, such as ones for graphs (Prim, Kruskal, etc), Red/Black trees, Tries, Union Set/Find.

    I just want to make sure that if asked during the interview, I don't pull up blank, which tends to happen to me sometimes in discussions with teachers or friends. I know the algorithms and structures, but sometimes I forget them by name.

    For example, back in the day, if someone asked me "write out the code for a quick sort algorithm", I know quick sort algorithm via 3 partition, but I would forget what quick sort was, even if I knew how the algorithm worked.

    I'm basically looking for some sort of checklist to go through or some way to solidify the mapping between name of algorithm/structure and it's code.

    All recommendations and tips are greatly appreciated.

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

    Part Time, Remote, Junior Developer Job?

    Posted: 01 Sep 2018 08:56 PM PDT

    I'm currently teaching myself to develop web applications using various front end javascript frameworks, node, and mySQL. I'm currently going to school full time for software engineering and working only part time. For family reasons I'm moving out of Phoenix and to Spokane Washington where there seems to be close to no tech presence, hence my desire for a remote job. Do part time, remote, junior developer jobs exist? If so, is there another way to track them down other than sites such as indeed? There seems to be hardly anything that explicitly fits this description on those sites. Thanks for your input!

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

    Executing WebApp on server

    Posted: 01 Sep 2018 08:53 PM PDT

    I extracted a WebApp on my server but I don't know what file is required to execute ? I naturally thought of going to the absolute path which contained the index file, but that didn't produce any results.

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

    Is there a way to edit a command I've pasted into Putty?

    Posted: 01 Sep 2018 08:48 PM PDT

    I'm using Putty to manage a MYSQL database, and I just found out I can paste commands in by right-clicking.

    But, once I've pasted something, there doesn't seem to be a way to edit the command--short of erasing from the end until I get to the part I want to edit.

    Is there a trick to this?

    Ideally, I'd like to be able to paste a basic command, then highlight passages I need to change--like a filename or the number of lines to ignore on an import.

    (For what it's worth, I tried Googling things like "edit MYSQL commands" to figure this out myself. But, everything I could find was about editing files with commands--rather than editing the commands themselves. So, if anyone has any guidance, I'd be grateful.)

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

    Will stuff I learned from writing scripts for games on roblox help me out learning other languages?

    Posted: 01 Sep 2018 08:34 PM PDT

    This is kind of a strange question, but I want to go into game development eventually so I want to start learning other languages so I was wondering if the knowledge I learned would help out learning it. Roblox itself uses Lua (technically it's a slightly modified Lua called rbx.Lua)

    I don't want to be a "roblox game developer" because ya I can make money from it I don't know how long roblox will last for. I feel like if I got into actual game development I would have a better chance for a more stable career.

    That's why I am asking this question.

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

    [bash] Best method of creating data structures?

    Posted: 01 Sep 2018 07:29 PM PDT

    I've been doing a lot of bash lately, and I'm struggling to find the best way to get around the lack of objects. For example, instead of having a BackupJob object with 3 associated attributes, I'll use 3 separate arrays and keep up with here I am in the array for each object. Is there a better way to accomplish this in bash?

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

    Why is this returning an empty list?

    Posted: 01 Sep 2018 07:11 PM PDT

    Hey there! I'm developing a piece of software that will return the title and price of a user chosen game from Amazon. It was working great, but now suddenly the program returns an empty list when parsing the hrefs on the Bing page looking for Amazon.

    To make sure I wasn't crazy I wrote a quick script to do this same thing but with pre set parameters for testing purposes and it works pefectly. I'll include the link to the problem script and I'll also post the working script down below.

    problem script

    Line 64 is where the link is grabbed, line 68 is where the error gets raised, and line 76 is where I handle the error. I just print the response object (which is a 200 btw) and a quick error message to keep the program from crashing.

    Keep in mind I've only been coding under a year so I'm sure my code can be greatly improved, I'm just looking to see if I'm overlooking anything thats breaking my program here.

    Here's the test code that works with no issues

    import requests from lxml import html header = { 'USER-AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36', } bingPage = requests.get('https://www.bing.com/search?q=gta+v+xbox+one') bingPageContent = html.fromstring(bingPage.content) link1 = bingPageContent.xpath('//*[@id="b_results"]/li[1]/h2/a/@href') amazonPage = link1[0] getAPage = requests.get(amazonPage, headers= header) print(amazonPage) print(getAPage) # print(bingPageContent.text()) amazonPage1 = requests.get(amazonPage, headers= header) amazonContent = html.fromstring(amazonPage1.content) price = amazonContent.xpath('//*[@id="priceblock_ourprice"]/span[2]/text()') print(price) 

    Thanks in advance!

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

    C++ Help with arrays

    Posted: 01 Sep 2018 06:42 PM PDT

    Hi I am posting in regards to arrays and for loops. Earlier today i had my program filling two arrays with a random generator number. I then saw I am only suppose to use one for loop while alternating filling up both arrays. I then tried getting the average of each array but now I just keep getting 0 when I type in 1 or if i type any other number I just that same output over and over again it never generates any new numbers. Any ideas on where I went wrong? I figured its in my for loop but I am not entirely sure.

    My code:

    https://github.com/ag0715/assign4ee/blob/master/program1

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

    Programing courses in Spanish?

    Posted: 01 Sep 2018 06:41 PM PDT

    My cousin is a native Spanish speaker and wants to learn to code. Anyone know of any Spanish coding course?

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

    What Programming techniques are used in these photo editing apps?

    Posted: 01 Sep 2018 06:27 PM PDT

    First of all: Not sure if this is the correct subreddit, if not --> pls inform me about this

    Q: I've been looking to some apps that can manipulate pictures lately. To name a few:

    - Enlight Quickshot

    - Manly

    - FaceApp

    And there are many more. What I'm really wondering about is what kind of machine learning (if any?) techniques these apps use to generate a realistic looking output for each different picture. Because I have to admit after trying some, the results are quite impressive.

    Do they use machine learning (or some other AI technique) at all, or am I totally missing the point?

    All the best,

    Mr. Shrimps

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

    What is the time complexity of this algorithm?

    Posted: 01 Sep 2018 06:15 PM PDT

    This is my (correct) solution to the leetcode problem: https://leetcode.com/problems/generate-parentheses/description/

    class Solution { public: // time: O(2^n) void generateParenthesis(vector<string> &combos, string cur, int l, int r) { if (r < l) return; // not balanced if (r == 0 && l == 0) { combos.push_back(cur); return; } if (r == 0) return; if (l != 0) { string cur_left = cur + "("; generateParenthesis(combos, cur_left, l - 1, r); } string cur_right = cur + ")"; generateParenthesis(combos, cur_right, l, r - 1); } vector<string> generateParenthesis(int n) { vector<string> combos; string cur; generateParenthesis(combos, cur, n, n); return combos; } }; 

    I'm stuck on calculating the space + time complexity of this. I think it is 2n but it doesn't really sound right to me since there are many instances where I cut a string off and don't continue (that's what the first if statement checks for). It should be less than 2n but I don't know what it would be. Similar question regarding space complexity (in terms of recursive stack space).

    Also, if there are any ways I could improve my code in terms of style, please mention those as well! Thanks!

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

    My php variable in image src not working

    Posted: 01 Sep 2018 05:56 PM PDT

    I'm trying to add this php from a database into my text so it can go to the right source, but the php isn't going into the text correctly. From stackoverflow answers I think I'm supposed to add dots to do this, but what I did isn't working. I'd appreciate help with this

    https://pastebin.com/TiwW3HF4

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

    About blogs for personal progress...

    Posted: 01 Sep 2018 05:22 PM PDT

    I'm starting off on a programming self-education Journey. While immersing myself in tech stuff I came across an interesting piece of advice from an early interview on the Code Newbies podcast: making a blog to mark your progress as you continue to learn.

    I've gotten myself a Wordpress and done a couple posts. I'm wondering though if anyone has good examples of similar "personal learning journey" blogs? I'm just wondering what typical posts cover and what pitfalls to lookout for in the content I post.

    If any of you keep a blog similar to this I'd love to see it. If it's not in bad form to do so I can link mine here as well.

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

    Visual Studio Question

    Posted: 01 Sep 2018 05:16 PM PDT

    Don't roast the noob! I'm in an intro object orientated programming class and doing C# in Visual Studio. There's an assignment, I wrote my very first lines of code! Happy geek dance! Question. The check points show every line returning values through the auto screen with a breakpoint on the very end; when I run and debug, my auto screen only shows the last line. I've googled it and saw info that says it only shows the prior 3 lines but everything else from my instructor and random googles show I should be able to see every line executed. Which is it? Did I miss some setting during the initial install?

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

    How do I go about making this website?

    Posted: 01 Sep 2018 05:13 PM PDT

    Soo. I have absolute 0 experience with coding, but I know that there's something that I want to try to make.

    I want to make a chat website that's a mixture of Omegle and 7 cups. Basically each person would have a user profile and a rating, and you can connect and chat with a random person based on things such as age/interest/user rating. Things like that. There would also be user profiles/friends list if you want to keep in contact with the person, and the website could be used for things such as emotional support.

    I know something like that is probably way complex for a beginner, but I have no clue how I would even begin to go about learning how to make something like this, could someone point me in the right direction and show me the kinds of things I would need to learn to create this specifically?

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

    No comments:

    Post a Comment