• Breaking News

    Saturday, December 2, 2017

    Coding challenge (Aimed towards beginners) learn programming

    Coding challenge (Aimed towards beginners) learn programming


    Coding challenge (Aimed towards beginners)

    Posted: 02 Dec 2017 10:41 AM PST

    Hey I created a blog post for developers. If you want to get more efficient in your coding skills then you should give this a read. It can be helpful. This article is not about quantity over quality as I state in the article you need to be focusing on writing clean and organized code while incorporating new concepts each day. good luck! here is the link : https://medium.com/@Nhollins1/beginning-of-60-locad-lines-of-code-a-day-challenge-c0b9e41f757a

    UPDATE

    I have now added my code and results to the blog post let me know what you think. good,bad, whatever.

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

    Creating a Real-time Chat Application with Python and Socket.IO - [XPOST - /r/python]

    Posted: 02 Dec 2017 11:45 AM PST

    Hi All,

    Thought some may be interested here - I'm starting a new tutorial series on creating a chat application with Angular and Python. The first of which gets you started with creating a simple socket.io server with aiohttp.

    Let me know your thoughts! - https://www.youtube.com/watch?v=BSGGAzsgFvk

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

    Why do people “uglify” code?

    Posted: 02 Dec 2017 09:28 AM PST

    I was messing around with Firefox dev tools and came across an option to beautify JS code. So I put in google's homepage domain to beautify it and compared it to viewing page source. Same text but the beautify made it easier to read.

    My question is what is the purpose of uglyfying it if there are programs that can beautify it? Is it to save memory or processing power? Please explain in layman's.

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

    As a programmer, what is a sign of expertise in a certain programming language?

    Posted: 02 Dec 2017 06:29 PM PST

    I understand there's no sign set in stone but generally what is a sign of expertise in a certain language?

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

    Advent of Code 2017 has started

    Posted: 02 Dec 2017 07:39 AM PST

    Hey, I didn't see any posts about this yet this year.

    Advent of Code is a yearly programming challenge, with one (two-part) puzzle every day December 1–25.

    The puzzles vary in difficulty, but they're all things you can solve with algorithms in any language.

    People compete to solve every puzzle as quickly as possible to get on the leaderboard (and to solve them as elegantly as possible to get bragging rights over at /r/adventofcode), but you don't have to care about that stuff. It's simply a great challenge for people who are pretty new to programming.

    Join in! It's fun!

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

    [Homework][Haskell] Monads... I don't get them

    Posted: 02 Dec 2017 09:35 PM PST

    We are tasked with creating an Error monad with the following skeleton code

    data Error a = Ret a | Err String deriving Show {- to satsisfy GHC, we have these empty instances of Functor and Applicative -} instance Functor Error instance Applicative Error {- GHC will give a warning here, but thats okay. We only care about the monad instance -} instance Monad Error where return x = error "unimplemented" (Ret a) >>= f = error "unimplemented" (Err s) >>= f = error "unimplemented" 

    I kind of get the theory behind monads but I don't even know where to start when it comes to implementing one. Can anyone give me some guidance?

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

    (Python & Pygame) Efficient method to display image in specified tile of a tile-map

    Posted: 02 Dec 2017 09:20 PM PST

    I am building a game that uses a tilemap, which of course involves displaying different sprites to different tiles(and in large numbers). I cannot think of a way to do this without using tedious / bad code. The end goal of the project is to also be able to create levels for the game efficiently. Any help is appreciated.

    import pygame as pg from settings import * pg.init() display_width = 1280 display_height = 768 tilesize = 32 teal = (0, 150, 150) black = (0, 0, 0) screen = pg.display.set_mode((display_width, display_height)) def drawGrid(): for x in range(0, display_width, tilesize): pg.draw.line(screen, black, (x, 0), (x, display_height)) for y in range(0, display_height, tilesize): pg.draw.line(screen, black, (0, y), (display_width, y)) playing = True while playing: for event in pg.event.get(): if event.type == pg.QUIT: playing = False screen.fill(teal) drawGrid() pg.display.flip() 

    As of now, the tilemap is displayed on the screen, and that is all.

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

    [homework] In search of CS graduate who utilized Python and C++ in class for short questionnaire

    Posted: 02 Dec 2017 11:29 PM PST

    I am writing a feasibility report for my local community college, and I am trying to locate a Computer Science graduate who has completed courses utilizing Python and C++ as the languages of choice. The interview -- which may be too short to even call it so -- is only five questions. The main objective of the interview is to determine if Python would be more suitable as the language used in introductory courses over the current C++ curriculum. Please comment if you are willing to participate and I'll shoot you a PM.

    To moderators: I'm unsure of rules involving posts without code, though it does involve programming. I will remove immediately if this does break the rules.

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

    I made a HDI calculator, however in the end, it always returns 0. Any solutions?

    Posted: 02 Dec 2017 11:29 PM PST

    I tried to change all the int values to doubles and cast the variables but nothing worked.

    I started learning c++ fairly recently, and I tried to make a HDI calculator with the knowledge, however no matter what I do, I always recieve an output like this: I

    What is the life expectancy of this country? 45 What is the mean years of schooling? 33 What is the expected years of schooling? 2 What is the GDP per capita of this country? 80000 The human development of this country is 0

    The HDI always returning 0.

    Here is a link to the code: https://gist.github.com/c00lme/53556b92d736575093064dc405df8b2a

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

    Can someone point me in the right direction?

    Posted: 02 Dec 2017 11:02 PM PST

    I'm not exactly sure if this is in violation of the rules but if it is I apologize. With that being said, I know absolutely nothing about computers or programming, but I'd like to start learning. As of now my current goal is simple, I just finished customizing the sound system in my car and I'd like to have a custom head unit as well. Ideally a touch screen computer that I could do things like view CANBUS and OBDII information, music playback, app integration, sorta like CarPlay or Android Auto but I want to make it. Some questions in particular I had, what concepts do I need to learn? Is there a term for what I want to do? I'm currently dating a graphic designer, she makes cool stuff and if it's possible, how would I integrate a user interface?

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

    How do I feel more confident about programming?

    Posted: 02 Dec 2017 11:25 AM PST

    So I've been trying to Python for a year and a half. Where I did eventually get a hang of the basics, I still feel like I know nothing about programming it self. I don't feel confident at all and its really messing with me. Its all I want to do in university there's really nothing else I'd rather invest my time and money on. So what can I do to feel a bit more confident or at least feel like I'm getting better at programming even if it's slightly better. The reason I ask this is because I'm surrounded by a bunch of students who are apparently geniuses at programming and it really bums me out because I cant even get close to their level. Thanks guys

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

    does anyone know what backend SnapChat uses for there mapping friends location feature?

    Posted: 02 Dec 2017 10:37 PM PST

    Is that google maps? I don't think so but I can't tell. I just learned about the feature today

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

    Typescript course

    Posted: 02 Dec 2017 05:53 PM PST

    I've encountered some typescript courses, but they are either go over syntaxes or is not interactive. Do you have any recommended course on typescript where it is interactive and thorough? A book, or online course, any resource is fine. Thanks!

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

    [JS] Could someone help me debug this (what I think is simple) JavaScript problem?

    Posted: 02 Dec 2017 08:54 PM PST

    https://jsfiddle.net/dx5bjtLb/5/

    So a couple of questions:

    1. How come the "i" variable isn't incrementing each time it adds 'item' to 'output' in the getData() function?

    2. How come 'e.target' is undefined on the button onclick function?

    It seems like it's probably something simple that I'm missing.

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

    How does database sharding work?

    Posted: 02 Dec 2017 02:55 PM PST

    The concept of DB sharding at high level makes sense, split up DB nodes so not a single one is responsible for all of the persistent data. However I'm a little confused on what constitutes the "shard". Does it duplicate entire tables across shards, or usually just a single one?

    For instance if we take twitter as an example, at the most basic level we need a users and a tweets table. If we shard based on user ID, with 10 shards, it would reason that the shard function is userID mod 10 === shard location. However what does this mean for the tweets table? Is that separate (a single DB table) or then is every single tweet divided up between the 10 tables, based on the whichever user ID created the tweet?

    If it is the latter, and say we shard on something other than user ID, tweet created timestamp for example, how would we know where to look up info relating to the user if all tables are sharded based on tweet creation time (which the user has no concept of)?

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

    How to shift an array element to the right by a given number?

    Posted: 02 Dec 2017 08:49 PM PST

    Q .Write a method, rotateRight, which takes a non-empty int array and a positive integer shift and returns a new int array containing the numbers in input array rotated right by shift. Assume shift is smaller than the size of the input array. E.g., int[] a1 = { 1, 2, 3, 4, 5, 6 }; rotateRight(a1,2) ==> {5, 6, 1, 2, 3, 4}, rotateRight(a1,5) ==> {2, 3, 4, 5, 6, 1}.

    For the past hour I have been trying to come up with a solution for this question and I still can't even come with the a basic code to solve it. My approach is to use two for loops with

    temp = array[i+shift]; a[i + shift] = array[i]; 

    but this severely is flawed. I am pretty lost. Any tips?

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

    Java - Resize BufferedImage produces fully white image

    Posted: 02 Dec 2017 08:28 PM PST

    I am trying to resize a BufferedImage in Java. However, the code produces a fully white 128x128 image. I have tried altering the BufferedImage.type. Using TYPE_INT_RGB produces a black image. I also tried using jpg for the input and destination file types, which did not work. Removing the resize displays the correct image. Any help would be appreciated.

    import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; public class ReadImage { public static void main(String[] args) { BufferedImage img; try { img = ImageIO.read(new File("path/to/file/file.png")); img = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB); File outputfile = new File("path/to/file/destination.png"); ImageIO.write(img, "png", outputfile); } catch(Exception e) { System.out.println(e); } } } 
    submitted by /u/CertificatoryCad
    [link] [comments]

    My code about generating powers in a 2D table is inefficient. The better approach required.

    Posted: 02 Dec 2017 08:13 PM PST

    The question was: Write a method, genPowerURT, which takes two positive integers n and base, returns a 2D integer array (n rows, n columns) that contains an upper right triangle of base's powers starting from 1 (base0). You may not use an external method to compute power.

    so genPowerURT(3, 2) would return

    [32, 16, 8]

    [0, 4, 2]

    [0, 0, 1]

     My program: int[][] g(int n, int base) { int[][] board = new int[n][n]; int alpha = 1; int number = 1; int col = n-1; int row = n-1; for ( int r = 0; r < n; r++) { for ( int c = 0; c < (r+1); c++) { board[row][col] = alpha; alpha = alpha * 2; col--; } number++; row = n - number; col = n-1; } return board; } 
    submitted by /u/Lover_hater_9
    [link] [comments]

    I'm hoping to learn programming, but I don't know if I can do it

    Posted: 02 Dec 2017 04:10 PM PST

    I'm hoping to start soon, but I struggle to use computers at times and fail at even the simplest of things. Should I just not do programming?

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

    Connecting an AngularJS Ionic App to the Cloud???

    Posted: 02 Dec 2017 07:48 PM PST

    I'm trying to learn how to set up my backend and connect it to my front end. And I'm SO out of my depth.

    Does anyone have a source on this that they like? If not, what should I Google? Are there any easy tools I should look into?

    Thanks.

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

    Loop ending before end of file

    Posted: 02 Dec 2017 07:33 PM PST

    Hey everyone, I'm working on a C++ project where I need to read information from a file into an array. The first piece is the name of a customer. The second is how many items they ordered.

    Since they get a discount for ordering dozens, I use three spaces in the array for each customer - the first is the name, the second is the number of dozens they purchased, and the third is extra single items that don't get the discount.

    Here is the for loop I am using to do this:

    for (int i = 0; !fin.eof(); i+=3) //this reads only 4 things in, not all??? { fin >> name; //read in name from file, then puts it in first spot in array customers[i].setCustomerName(name); fin >> number; //read in number related to name, then puts info in spots 2 and 3 customers[i + 1].setNumDoz(number/12); customers[i + 2].setNumExtra(number % 12); count++; //counting to find number of customers, will return value to main } 

    For the record, I also wrote this while loop which is essentially the same:

    int i = 0; while (!fin.eof()) { fin >> name; customers[i].setCustomerName(name); fin >> number; customers[i + 1].setNumDoz(number / 12); customers[i + 2].setNumExtra(number % 12); count++; i += 3; } 

    Then, I am supposed to print this information (name, total items, total cost):

    for (int i = 0; i < numCustomers; i+=3) //should print the same way they are loaded in and then sorted { int numDoz = customers[i + 1].getNumDoz(); //grabs the number of dozens purchased plus extras int numExtra = customers[i+2].getNumExtra(); cout << setw(15) << customers[i].getCustomerName() << setw(15) << (numDoz * 12 + numExtra); cout << setw(15) << (numDoz*COST_PER_DOZ) + (numExtra*COST_PER_SINGLE_EGG); // calculates and prints total cost cout << endl; } 

    But when I run this, I only get four lines printing, instead of all the customers; orders (there are nine total). why are both loops ending before end of file?

    Also, any ideas why names of customers are not printing?

    P.S. I know from browsing this sub and other forums that .eof() is in bad form, but that is the way our professor wants it done.

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

    The wee little ones

    Posted: 02 Dec 2017 07:20 PM PST

    Hey All. Like most young boys, my 7 yo is really into Minecraft and video games. I would like to get him started on the path of learning programming. Does anyone have any experience or advice on the resources available at his age group? I've searched a bunch out, but not sure what's the "best" or better over something else.

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

    [C++] When is an object destroyed?

    Posted: 02 Dec 2017 03:32 PM PST

    I understand an object is destroyed when it goes "out of scope" but what does "out of scope" mean in this situation? I'm using C++ and the standard list.

    Example:

    class Object {} class ObjecHolder { list<object> list; void addtolist() { Object obj; list.add(obj); } } main() { ObjectHolder objectHolder; objectHolder.addtolist(); } 

    In addtolist, I created obj. In a normal situation, I would assume obj would be destroyed at the end of the function call. However, I added obj to the list which exists inside objectHolder in main. So how could objectHolder.list still hold on to obj when it is destroyed after calling addtolist?

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

    No comments:

    Post a Comment