• Breaking News

    Monday, March 18, 2019

    Today I made my first program that actually does something useful/to help my everyday life! learn programming

    Today I made my first program that actually does something useful/to help my everyday life! learn programming


    Today I made my first program that actually does something useful/to help my everyday life!

    Posted: 17 Mar 2019 08:54 AM PDT

    I had two colleges mixing computer science with economics in two different cities in my country and read the curriculum on both of them and at first glance intuitively one of the two seemed better than the other one, but a few days ago I asked myself if it really is or is it just some sort of placebo because of things like it being in a better city?

    So considering as well that the most given advice here when people say that they don't know what to code is to make a program that solves something in your everyday life; I made a C++ program that reads the courses from one college from a file and from the other college from the other file (along with the years in which they are taught because there are some subjects which appear in both colleges but taught in different years or in a different order) and outputs in a third file the subjects which appear in both colleges (along with the year in which they are taught for each college which may differ or be the same), in a fourth file the subjects that appear in only one of the two and in a fifth file the ones that appear in the other one.

    I have to admit looking in retrospect it took WAY more than if I were to actually do it by hand and write them down on a piece of paper manually (took me 2.5h vs. probably 15 minutes if I did it manually) but I admit it was fun and I learned a lot about programming while doing it. Actually got me to raise some questions about development which I'd love to have some of you (more experienced) answer for me, for example:

    (in C++): When you have something like I had, more courses each with individual attributes (in my case which year they are taught in, 1, 2 or 3) which is the better approach? :

    -Making a struct with a string (name of the course) and an int (year in which it is taught) and then make a vector of this struct, or

    -Making a struct with a vector of strings (of the name of the courses) and a vector of ints (of the years in which it is taught) and then make a single instance of this struct

    So something like this:

    1:

    struct subject { string name; int year; }; vector <subject> Subjects; 

    2:

    struct subject { vector <string> name; vector <int> year; }; subject Subjects; 

    Which way is better/better practice? Or is there a certain use for each, if so, in which cases you use 1 and in which cases you use 2?

    edit: source code in case anyone wants it: https://pastebin.com/TrNf0Fc1 (btw lines 8 to 13 that i talk about in the first comment are actually 17 to 22, after adding the comment)

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

    I am trying to find a good introduction to data structures and algorithms book

    Posted: 17 Mar 2019 04:34 AM PDT

    Hello everyone,

    I am basically looking for a good book that explains everything thoroughly. I was reading the CLRS algorithm book, and they just threw all these mathematical proofs in without explaining how to solve it.

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

    Freshman CS major w/ little applicable knowledge - what/how can I learn beyond my classes to prepare for internships?

    Posted: 17 Mar 2019 05:18 PM PDT

    I'm not like many CS majors (that I know at least ) in that I haven't been coding since at least high school because I didn't really "discover" CS until late high school, so I feel like I am a little behind. I've been looking at engineering internships just to see what their qualifications are, and I've seen a lot of things that I have no idea about. So, I've made my goal for the next year to get to the level where I can reasonably complete the tasks on https://www.ign.com/code-foo/2019 even though I don't really know what APIs and Github are right now. What resources do you suggest so I can learn some more "real life" stuff? I just really don't know where to start, since I've only taken intro programming courses! Thanks!

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

    Any other Uni. students spending more time studying math it seem like compared to CS?

    Posted: 17 Mar 2019 09:57 PM PDT

    I know math is important, but it sucks, feel like I'm learning code at a much slower pace due to math courses..

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

    Any audio books to listen to while I work?

    Posted: 18 Mar 2019 12:34 AM PDT

    I know it is a little bit of an odd question, but I can listen to anything while I do some paper work and tasks. I wanna get the basics and learn the first part of coding, and know it like the back of my hand. I know a lot of coding is looking at it in front of you, but is there any way I can fill in some work time with some books or lectures. Any books or lectures that you recommend?

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

    I broke the score and timer in my simple Python game. Take a look?

    Posted: 17 Mar 2019 09:08 PM PDT

    Hey so I'm having some trouble getting my score counter and timer to work. I had them both working before I created the Game class but I'm still pretty confused where the variables and logic for them fit in. If someone could give me a hand that'd be awesome. Thanks.

    I placed the working code first and the broken timer/score stuff second.

    import pygame import random BLACK = (0, 0, 0) WHITE = (255, 255, 255) BLUE = (0, 0, 255) SCREEN_WIDTH = 700 SCREEN_HEIGHT = 400 class Game(object): """Contains the game logic, events, and display.""" def __init__(self): """Constructs block lists, blocks, and game conditions.""" self.score = 0 self.game_over = False #Block Lists self.good_block_list = pygame.sprite.Group() self.bad_block_list = pygame.sprite.Group() self.all_sprites_list = pygame.sprite.Group() #Player Block self.player = Player(100, 100) self.all_sprites_list.add(self.player) #Good Block List Creation for i in range(35): # Block Image block = Block("snowman_sprite.png") # Block Locations block.rect.x = random.randrange(SCREEN_WIDTH) block.rect.y = random.randrange(SCREEN_HEIGHT) # Add Blocks to Lists self.good_block_list.add(block) self.all_sprites_list.add(block) #Bad Block List Creation for i in range(25): block = Block("robot_sprite.png") block.rect.x = random.randrange(SCREEN_WIDTH) block.rect.y = random.randrange(SCREEN_HEIGHT) self.bad_block_list.add(block) self.all_sprites_list.add(block) def display_screen(self,screen): """Draws sprites and text to screen.""" screen.fill(WHITE) #Remove background_image = pygame.image.load("snowy_village.png").convert() screen.blit(background_image, [0, 0]) if self.game_over: screen.fill(BLACK) font = pygame.font.SysFont("Courier",30) text = font.render("Game Over. \nHit Space to Play Again", True, WHITE) center_text_x = (SCREEN_WIDTH // 2) - (text.get_width() // 2) center_text_y = (SCREEN_HEIGHT // 2) - (text.get_height() // 2) screen.blit(text, [center_text_x, center_text_y]) if not self.game_over: self.all_sprites_list.draw(screen) pygame.display.flip() def game_events(self): """Contains Game Processes & Events (Controls).""" for event in pygame.event.get(): if event.type == pygame.QUIT: return True if event.type == pygame.K_SPACE: if self.game_over: self.__init__() #User Presses Key Down elif event.type == pygame.KEYDOWN: #which key and adjust speed if event.key == pygame.K_a: self.player.changespeed(-3,0) elif event.key == pygame.K_d: self.player.changespeed(3,0) elif event.key == pygame.K_w: self.player.changespeed(0,-3) elif event.key == pygame.K_s: self.player.changespeed(0,3) #User Stops Pressing Key elif event.type == pygame.KEYUP: if event.key == pygame.K_a: self.player.changespeed(3,0) elif event.key == pygame.K_d: self.player.changespeed(-3,0) elif event.key == pygame.K_w: self.player.changespeed(0,3) elif event.key == pygame.K_s: self.player.changespeed(0,-3) return False def game_logic(self): """Updates block positions and checks for block collisions.""" if not self.game_over: self.all_sprites_list.update() # Block Collision Sounds good_block_sound = pygame.mixer.Sound("good_block.wav") bad_block_sound = pygame.mixer.Sound("bad_block.wav") #Check for Collisions between player and Other Blocks good_blocks_hit_list = pygame.sprite.spritecollide(self.player, self.good_block_list, True) bad_blocks_hit_list = pygame.sprite.spritecollide(self.player, self.bad_block_list, True) #Good Collisions for block in good_blocks_hit_list: self.score += 1 good_block_sound.play() print(self.score) #Bad Collisions for block in bad_blocks_hit_list: self.score -= 1 bad_block_sound.play() print(self.score) #Game Over Condition if len(good_blocks_hit_list) == 35: self.game_over = True class Block(pygame.sprite.Sprite): """Creates the attributes for all blocks.""" def __init__(self, filename): super().__init__() self.image = pygame.image.load(filename).convert() self.image.set_colorkey(WHITE) #Position Update, Setting rect.x and rect.y self.rect = self.image.get_rect() class Player(pygame.sprite.Sprite): """ Create's player controlled block.""" def __init__(self, x, y): super().__init__() #Height,Width,Color self.image = pygame.Surface([15, 15]) self.image.fill(BLUE) #Pass-in Location self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y #Starting Speed self.change_x = 0 self.change_y = 0 def changespeed(self, x, y): """ Changes Player Speed.""" self.change_x += x self.change_y += y def update(self): """ New position for player block.""" self.rect.x += self.change_x self.rect.y += self.change_y #Screen Edge Check #Left Screen Check if self.rect.x < 0: self.rect.x = 0 #Right Screen Check if self.rect.x > (700 - 15): self.rect.x = (700 - 15) #Top Screen Check if self.rect.y < 0: self.rect.y = 0 #Bottom Screen Check if self.rect.y > (400 - 15): self.rect.y = (400 - 15) def main(): pygame.init() screen = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT]) pygame.display.set_caption("Save Snowy Village!") done = False clock = pygame.time.Clock() game = Game() while not done: done = game.game_events() game.game_logic() game.display_screen(screen) pygame.display.flip() clock.tick(60) pygame.quit() if __name__ == "__main__": main() 

    Here's the countdown timer and score counter:

     # Timer Count frame_count = 0 frame_rate = 60 start_time = 90 #Score Display font = pygame.font.SysFont('Courier', 25) scoretext = font.render("Score:" + str(self.score), True, BLACK) screen.blit(scoretext, [10, 10]) #moved this back from display #Countdown Timer seconds_total = self.start_time - (self.frame_count // self.frame_rate) if seconds_total < 0: seconds_total = 0 #Modulus Remainder Calcs Seconds minutes = seconds_total // 60 seconds = seconds_total % 60 displayed_string = "Time left: {0:02}:{1:02}".format(minutes, seconds) text = font.render(displayed_string, True, BLACK) screen.blit(text, [450, 10]) frame_count += 1 game.game_timer(screen) 
    submitted by /u/Rails_Is_A_Ghetto
    [link] [comments]

    Suggestions for a language to learn as a hobby ((,e.g CLISP)

    Posted: 18 Mar 2019 12:27 AM PDT

    Hey there!

    I can already Python/Go/C/C++ but I was interested in learning something as a hobby, not focused on Job related stuff that made me learn or open my mind...

    I had in mind Common Lisp, but I am open to any other suggestions whichever they are.

    No matter if it's modern or old

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

    Learn how to make a program that can paint photographs !

    Posted: 17 Mar 2019 08:36 PM PDT

    An implementation of "A Neural Algorithm of Artistic Style" in Keras

    1. Learn how to setup an environment for deep learning.
    2. Write a program that is smart enough to paint your photos in the style of whatever painting you like

    Code Repository: https://github.com/devAmoghS/Keras-Style-Transfer

    Tutorial Blog: https://medium.com/@singhal.amogh1995/utilising-cnns-to-transform-your-model-into-a-budding-artist-1330dc392e25

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

    I would like to help contribute to open-source stuff but I don't know where to start?

    Posted: 17 Mar 2019 12:33 AM PDT

    Hello,

    I'd really like to help contribute to open-source projects because I think it's a nice thing to do. But I'm not sure how to get started. I'm not very good. Like, I guess I know the syntax and I what to do when I make something but I'm not great at sort of just getting it down.

    I only really know Python. I've played around in other languages and occasionally made super simple crap in them but I can't really program in them.

    I'm happy just to do simple stuff if it's helpful. But I also don't want to get in the way since I'm not very good.

    Anyway, I'm not really sure how to get started. So if anyone has any instructions/insight/tips/advice I would really appreciate it.

    Thank you.

    Edit: Wow, thanks for all the help guys! :D

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

    This is my first ever good (big) project idea for a resume, but I'm unsure because of it's ethics

    Posted: 17 Mar 2019 08:58 PM PDT

    People might already do this but I don't think its common because of how difficult it could be and today's protections. So we have all written brute force password attacks probably because of learning to loop. I got an idea from someone about doing dictionary attacks, which means sifting through a list (usually 100-1m) of popular passwords; and if no dice, then do a the brute force. Let's take it a step further. In AI we learned about grabbing data and make educated guesses after teaching a computer, so why not have the machine learn the data from the list of passwords, then make guesses at what it could be? Still not satisfied?

    This part is where the ethics portion get involved; even though password cracking is still unethical. So we have all seen web scrapers before which sift through websites and gather data from places like Ebay or news journals. I was thinking of creating a bunch of fake accounts for instagram, facebook, ebay, etc. with information like favorite hobbies, colors etc. You see where I'm going with this? The user enters a first and last name, the city they reside, and the program scrapes all information on the web about that person. It then uses AI to learn from the data and make educated guesses at what the password would be. If 1m tries pass and still no dice; then the password must be unique and fall back to brute force.

    Most websites lock you out after a few attempts so this is something I believe that's not possible; Plus the amount of words that could be learned from the computer could be very vague or unrelated. So I don't think there is much use but it's strictly for educational purposes to teach people about password safety and their information privacy online. In demonstrations I will use my fake account I had used when doing instagram, etc, and put a password like spidermanfan1991 or something. I'll also use disclaimer warnings before the person uses the program notifying them this is educational and if they continue forward they are liable for any destruction done.

    I'm a bit concerned that it might leak into the web and people will misuse it; obviously a *real* expert would of crafted something much better and it would make this program obsolete, but I still don't want to get sued. So I might make this a project that I don't showcase or put online at ALL unless if someone asks to see it in person, then I'll demonstrate. The dillema I have is this is the first real big project I've ever thought of, it excited me, and my soul wants to jump on it. But it is unethical and it could cause harm if someone where to get into my data and leak it or someone thought it was not right and reported me after an interview. What do you think?

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

    Confusion with finding threads spawned from a process using top

    Posted: 17 Mar 2019 08:54 PM PDT

    This is how I start my python process:

    1.) ssh server@myselfuser

    2.) sudo su anotheruser

    3.) source /folder/to/venv/bin/activate

    4.) python app.py. Inside the python script, I am using ThreadPoolExecutor module to start up new threads.

    Now to find the process, I use ps -ef|grep python and I see the following:

    anotheruser 24810 24504 1 20:45 pts/2 00:00:00 python app.py anotheruser 24815 24810 2 20:45 pts/2 00:00:01 /folder/to/venv/bin/python app.py 

    Now why is it that when i run top -H -p 24810 I cannot see the threads but using PID = 24815 does? Also, why are all the threads named "python"? I gave each thread a unique prefix name as directed here

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

    Please help! Beginner bash script problems

    Posted: 17 Mar 2019 08:51 PM PDT

    I have 2 problems I need help with. They're homework problems that are due in a few hours and I've been working desperately on them the last 6 hours and haven't really gotten anywhere. Any help is much appreciated

    Question 1)

    Write a script that receives a list of parameters. If no parameters are given, output an error message.otherwise iterate through the list and using a case statement test each item in the list to see if it starts with a capital letter, lowercase letter, number, or other. Count each type and output the totals for each at the end.

    !/bin/bash

    Echo enter parameters

    Read value

    Case $value in

    ???

    Not sure how to do it from here

    Question 2)

    Write a script to input a list of positive numbers from the user using a while loop (exit the loop upon a negative number) storing each input as an array element. Using a for loop iterate through the list and compute the sum, average, max, and min elements of the array and output the results.

    !/bin/bash

    Echo input positive numbers

    Read value

    For value in ${a[@]}; do ???

    Stuck here as well

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

    Returning a local variable without calling its destructor

    Posted: 17 Mar 2019 08:40 PM PDT

    I have a variable made by the vulkan.hpp bindings i.e I have called

    `auto instance = vk::createInstanceUnique()`

    This creates a variable that is now a unique object (cannot me copied, only moved), which resides on local memory (similar to unique_ptr).

    I want/need to return this variable, which means I need to avoid the destructor from being called, else I will return an undefined object.

    How can I do that?

    EDIT: I found that explicitly calling std::move at return time prevented the object from being destroyed

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

    How to partition an array, made simple.

    Posted: 17 Mar 2019 09:15 AM PDT

    In Python and C++, how do they give index numbers to doubly and singly linked lists?

    Posted: 17 Mar 2019 11:32 PM PDT

    I'm reading an algorithm book in which it discusses linked lists, and I remember when I implemented singly linked lists in C++ (more like copied from Github) I couldn't figure out how to give it an index number. How do lists in Python and vectors in C++ do this magic? Thanks for your response.

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

    Inserting into a Binary Tree without a stack overflow? (Ill ask my question with c++)

    Posted: 17 Mar 2019 05:13 PM PDT

    Hi guys. On mobile so I will try to format the best I can

    So usually when I write a Binary tree, my insert looks like

     Insert(T val){ If( val > this.val ){ if(this.left == NULL) this.left = new Tree(val); else this.left->insert(val); else if(this.right == NULL) this.right = new Tree(val); else this.right ->insert(val); } 

    However with larger trees this causes an overflow ( I assume from the amount of function calls going onto the call stack)

    How can I do this without overflow?

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

    Please help: working on pig latin problem

    Posted: 17 Mar 2019 11:08 PM PDT

    -- convert data to workable forms allData = LOAD 'nonrenewable.csv' USING org.apache.pig.piggybank.storage.CSVExcelStorage(',', 'NO_MULTILINE', 'UNIX', 'SKIP_INPUT_HEADER'); -- select specific columns data = FOREACH allData GENERATE (chararray) $1 as State, (int) $2 as CoalNET, (int) $3 as OilNet, (int) $4 as GasNet, (int) $5 as NukeNet; -- select specific rows pnwData = FILTER data BY State == 'Washington' OR State == 'Oregon' OR State == 'Idaho'; STORE pnwData INTO 'pig_out' USING org.apache.pig.piggybank.storage.CSVExcelStorage(',', 'NO_MULTILINE', 'UNIX', 'SKIP_INPUT_HEADER'); 

    I put a dump data after data and got this, where I believe it should be putting all of the ints instead-https://imgur.com/a/3bnGEj9

    submitted by /u/pac-sama
    [link] [comments]

    Learn Python - Introduction

    Posted: 17 Mar 2019 07:01 PM PDT

    Hey all, this is a new, no nonsense video series for learning python.

    https://www.youtube.com/watch?v=L_bJs0unYaw

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

    Would you like to learn C# and OOP design in community full of passionate developers?

    Posted: 17 Mar 2019 09:13 AM PDT

    Dear all,

    Learning is a constant process. You can learn from your own mistakes, you can do it alone. What I would like to offer, is learning inside of a community, with hundreds of people exchanging both professional and casual programming experience!

    C# inn- a friendly discord community would like to invite you to join! We're a young and growing community with almost 2000 members, with dozens of new members joining daily. Our members help each other out and we try to keep as friendly atmosphere as possible. Your opinion matters to us, our staff listens to your needs and suggestions, so we're constantly changing and trying to be a bit better than we were yesterday, by adding/removing channels, coming up with ideas, planning the future. As the name implies, we're mostly focused on C#. We have a lot of people who advocate profesionalism and we want not only to help you do stuff, but do it the right way.

    Also, every weekend we have programming lessons, for now mostly focused on Clean Code. We have some people streaming live coding and sometimes some members offer mentorship on a project or topic.

    We want to be a community where people can learn and collaborate, all while having fun. Interested?

    It doesn't matter if you want to teach or learn, as long as you are passionate about it, we will accept you with open arms 😊

    Invitation link: https://discord.gg/Bfme3PD

    Let's have fun while learning together!

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

    How can I log numbers from my phone into a data sheet from which I can extract the data later?

    Posted: 17 Mar 2019 06:36 PM PDT

    I am a junior in high school and I am starting to get my hands dirty with coding. I have pretty good overview of what programming is and I have some projects in mind to get better, but I just don't know how to get started.

    First, I want to gather data on how many times I wipe after going to the restroom. I know, it is somewhat weird but I thought it could be a fun project to get started. Basically, I want to be able to log, from my phone, the number of times I wipe my butt every time I go to the restroom and have this number be logged in some type of spreadsheet with the date and time for further use. Any ideas on how I could get started with this? I think python and a Raspberry Pi that I have might be the way to go but I don't know how I can set everything up or where to start looking. Thanks!

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

    Fuzzy searching database

    Posted: 17 Mar 2019 10:09 PM PDT

    I'm making an API and because the words searched are transliterations (Arabic words spelled with English letters) there are no specific spellings for the words, I wanted to implement a 'fuzzy' search. I've been reading up online for algorithms and different methods of implementing this concept, however I also stumbled upon MySQLs SOUNDEX() function which basically doesn't that for me (it returns words that have similar sounding tokens, based on some numeric scale).

    My question(s) is(are) is it okay to just use sounded()? Is that what other people do? Why is that not just what everyone (using mySQL) uses? What's the drawback?

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

    Just starting html and css, can somebody help me?

    Posted: 17 Mar 2019 09:40 PM PDT

    I used the tutorial of Codegrid for the parallax scrolling of pure html and css. After that, I inserted a <div> tag. The output has a white space after the parallax wallpaper and my desired <div> tag. I will post my code as comments after. I also want to post the output but my website is just a file on my computer. Thanks for any future help!

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

    [HTML,CSS]Custom Twitch Chat Help

    Posted: 17 Mar 2019 03:41 PM PDT

    Hello! I was interested in seeing if anyone could help me out on a personal project. I am a streamer on Twitch and I wanted to get some help in creating a custom chat box. I am trying to imitate this. I have done a decent bit of research into things, but I just don't know how/where to start.

    From the research I was doing I found that in order to use get their profile picture they have next to their chat message I would have to use "profile_image_url" found on the dev API for Twitch

    The thing thing I would also want is a way to change the font using the google fonts API. I was looking at this and saw it was easy to add, but again, I just don't know how/where to start.

    Here is the font that I want to use Kosugi Maru

    Here is the API to the font that I'm interested in, KosugiMaru

    I'm currently using Streamlab's chatbox widget to display chat on my stream, so there already is some HTML, CSS, and JS written there, I'm just trying to customize it.

    Also while attempting originally to do on my own I stumbled across this YouTube video that kind of gave me the same effect.

    Much appreciated to anyone that tries to steer me in the right direction or helps me out!

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

    Noob question: How do I data from a Continuation resume in Kotlin?

    Posted: 17 Mar 2019 09:09 PM PDT

    So I searched online somewhat extensively, and I couldn't find anything.

    I have a function for downloading a file that goes something like this:

    fun parseFileFromInternet(url: URL, callback: Continuation<Document>) { Fuel.get(url.toString()) .response { request, response, result -> val (bytes, error) = result val parsedData = parseFromBytes(bytes) callback.resume(parsedData) } } 

    How do I call this function in a way that I get the parsed data back? Also, is there a way to make the thread calling the function wait until I get the data?

    Edit: Title should be "How do I get data..."

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

    No comments:

    Post a Comment