• Breaking News

    Saturday, February 10, 2018

    What was your last little victory, coding-wise? learn programming

    What was your last little victory, coding-wise? learn programming


    What was your last little victory, coding-wise?

    Posted: 09 Feb 2018 02:52 PM PST

    I'm stoaked because I adapted a pre-written random quotes script in a book to include a button to refresh the screen rather than hitting reload to change the quote (I'm just a couple of weeks in). It's only a tiny victory but I feel I've taken a tiny bit of ownership and solved a (tiny) problem. What's boosted your confidence recently?

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

    I'm a convicted felon.... what's my chances of actually getting hired?

    Posted: 09 Feb 2018 04:14 PM PST

    So a little background about myself, I'm 26 years old and I recently served an 18 month sentence for class a distribution. Before you jump to conclusions and assume I'm some dirt bag drug dealer please give me a chance to explain myself. I've made a lot of mistakes in life, I became addicted to opiates and sold drugs to support my habit. Got busted and served some time but I'm trying to turn my life around.... I've always been interested in computers since I was a teenager. I attended ITT Tech for one semester back in 09 but drug addiction led me down a bad path and I dropped out, currently I work as a carpenter for my family's business. Although I've struggled with drug addiction on and off my whole life during periods of sobriety I've been able to teach myself some basic codeing skills. I have the ability to build a basic website, html, CSS, and some JavaScript. I'm currently enrolled in a micromasters java program through edX that's made up of 5 courses. My dream is to one day have the skills to develop mobile applications but here's my question to you all..... Will I ever be able to get a job as a programmer with a felony drug charge on my record? Am I wasteing my time trying to learn to code? Should I just stick to my day job as a carpenter? (I'm actually a really good carpenter and I'm paid decent). Is my past always gunna come back to haunt me? I hear all the time story's about regular guys like myself who taught them self to code and landed a sweet job with a nice salary and benifits. I'm ok with being a carpenter for the rest of my life but there's times were I dream of having an office job, wearing a tie to work, having a 401k and good health insurance. I just want the American dream I guess..... My thoughts are maybe if I can become skilled (more skilled then your average programmer) that maybe an employer would overlook my criminal past?

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

    [Homework] [Python] Help: Displaying an error message to a user for inputting something the program can't use

    Posted: 09 Feb 2018 10:35 PM PST

    I almost feel ashamed for having to ask about something that should be quite simple.

    So, in my programming course, we've made a program that converts meters to feet and vice versa. The problem that I can't seem to figure out is how to display an error message to the user if they input a string instead of a number. Here's what's confusing me: I have it so that their input in converted to a float so the program can do calculations with it, but since Python can't convert strings to float, I need to give the user an error message if they try to input something like 'two.' Here's my code:

    def meters_to_feet(distance):

    if type(distance) is str: print("Distance must be a number. Please try again") else: result = round(distance * 3.28, 2) return result 

    def feet_to_meters(distance):

    if type(distance) is str: print("Distance must be a number. Please try again") else: result = round(distance * 0.3048, 2) return result 

    def check_selection(s):

    s = s.lower() if s == "f" or s == "m": return s else: return False 

    def main():

    print("Welcome to the distance conversion program") print() while True: f_or_m = input("Do you want to convert to feet (f) or to meters (m)?\t") if check_selection(f_or_m): if check_selection(f_or_m) == "f": m = float(input("Enter distance in meters:\t")) print(m, "meters is", meters_to_feet(m), "feet") elif check_selection(f_or_m) == "m": f = float(input("Enter distance in feet:\t")) print(f, "feet is", feet_to_meters(f), "meters") else: print("You must enter a valid choice (f) or (m)") print() again = input("Would you like to try again? (y/n)\t") print() if again.lower() != "y": print("Goodbye") break 

    So, we went over the type() function and how that can help, as seen in my first two functions. But since I'm converting their input to float, that doesn't trigger and instead causes an exception in which the string can't be converted. If I remove the float() function, it defaults their input to string, which triggers it when I don't want it to. What am I missing here? Any help is greatly appreciated.

    Note: We aren't very far into the course and haven't gone over actual exception handling, so I don't believe my instructor is looking for try and except keywords.

    Edit: I didn't realize it would format this way, sorry. I'll try to fix it.

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

    [Java] - ArrayList question. Size of ArrayList and object occurrences.

    Posted: 09 Feb 2018 11:29 PM PST

    Hi. I'm working on some classes containing arraylists. At first I thought I could just use .size() to check the number of objects in the arraylist. But when I read up on it further someone said that if you delete one of the objects the size of the arraylist don't shrink. So does that mean it doesn't "follow" the number of the objects in the list and that is not a good way to count the objects?

    currently I use something along:

    ArrayList<myObject> list = new ArrayList(myObject);


    So my question is how can I check the number of myObjects currently in my arraylist? I've until now just used .size().

    Is there a "simple" way to do this?

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

    Sorting program using bubblesort ,wrong output ,Help!

    Posted: 09 Feb 2018 10:47 PM PST

    I tried sorting program using bubble sort ,but program is malfunctioning ,plz take a look at code https://pastebin.com/hKyMBxnP and tell me if you see any mistakes or errors

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

    My Experience with a Programming Bootcamp

    Posted: 09 Feb 2018 05:58 PM PST

    TL;DR if you want to make a serious career change and have had an established career, a boot camp may very well help you transition careers. Be wary if you do not have some sort of professional experience.

    If you want to attend a boot camp I encourage you to read this short blurb.

    I wanted to post this because I know boot camps get a weird mix of opinions, and this is how I feel after attending one.

    First off, I worked as a project manager for a large construction company for 3 years after graduating from college with a bachelor's degree in structural engineering. So consider this an established career.

    Given that, I absolutely hated my job and felt entirely that I was stuck. I wished I could have taken it all back and gone to school for computer science. I wanted a job as a developer.

    Now, for the people interested in my opinion:

    I did my research for a few boot camps and ended up finding one I felt safe enough to invest in. They specifically taught a full stack for web development. (will not mention to avoid any sort of bias) If you are looking for a boot camp, THIS IS WHAT THEY WILL MOST LIKELY OFFER, but do not be thrown off by the idea of learning to create a website. This is the backbone to almost all development careers. Learning this skill set will introduce you to many opportunities and is a great way to begin working towards any sort of dev job.

    If you are like me and want to establish a new career, I would lean towards the side of; you will do fine finding a job with your new skill set. Granted, you have the background similar to mine.

    If you do not have that professional background, I found it much harder for my classmates in that position to find a job. If this is your case, make sure the boot camp you attend has some sort of career service. One that is actually spoken highly of. It helps exponentially if you have a strong knowledge base of everything tech. The classmates that were inexperienced but we're truly nerd at heart did just fine finding a job. The other classmates are having a very tough time.

    Timeline to find a job:

    It took me a month and a half. The inexperienced classmates that knew their stuff took them the same amount of time. The classmates that did not have a strong grasp on any tech related jargon are still looking for employment, 4 months out.

    Out of the 20 people who attended, currently 15 are employed.

    Edit: sorry this turned into a bit of a rant as I ran out of time.

    I do encourage everyone to follow their dreams, but do your research and ask yourself what you really love. If you know this is the right choice for you, chase that dream. Good luck and I hope this helps. Please reach out if you have more direct questions, I'd be happy to answer the best I can!

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

    [Web] I know HTML and CSS, what's next if I want to build Web Applications?

    Posted: 09 Feb 2018 10:47 AM PST

    Hi All,

    I used to detest web development (thanks to CSS), but I'm starting to get back into it. I never did a lot of it, but I know enough to make static websites with HTML and CSS. I want to start making web applications, but have no idea where to go. JavaScript is on my list to learn next, but there are so many libraries that I'm not sure what are worth learning, or what any of them actually do. It's worth noting that I want to do both the front-end stuff, and back-end.

    I've already got a project lined up, whose end goal is a web application that display telemetry data in real-time graphs and graphics (with a slight delay of course). So I guess my question is, what language/frameworks would handle the graphics on the client? What language/frameworks would handle the server side code? Is there anywhere I can go/books I can read to help me on my quest to learn web application development?

    Thanks!

    Edit: I should have clarified I'm a fairly experienced programmer, and am experienced with Python, Java, C/C++. Curious more about PHP vs Ruby vs Python vs All the goddamn JavaScript libraries like JQuery, AngularJS, ReactJS, Express

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

    PHP: JSON value remains the same after button click event with HTTP request

    Posted: 10 Feb 2018 12:18 AM PST

    If an HTML button click event occurs and a variable is set to 'two', An HTTP request sends to delete 'two' from the JSON file if the num variable value matches 'two' in the JSON file.

    Why does the same value returns after button click?

    HTML file (index.html):

    <html> <head> <title>Button Writer</title> </head> <body> <button id="button1" type="button">Write to File</button> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="./app.js"></script> </body> </html> 

    JS file (app.js):

    $('#button1').click(function() { let num = 'two'; $.ajax({ type: "POST", url: "./update.php", data: num }); }); 

    PHP file (update.php):

    <?php $jsonContents = file_get_contents('./codes.json');//Read here the json file into text $array = json_decode($jsonContents); $value = $_POST; if (($key = array_search($value, $array )) !== false) { unset($array [$key]); } $jsonString = json_encode($array); //Here you can save the content of $jsonString into the file again file_put_contents("./codes.json", $jsonString); echo $jsonString; ?> 

    JSON file (codes.json):

    ["one","two","three"] 
    submitted by /u/claOnline
    [link] [comments]

    Simple website hosting for student learning HTML, CSS, JavaScript, server side programming

    Posted: 09 Feb 2018 08:23 PM PST

    I took a web development course last semester and we had our own servers to work with, but I'm not in that course anymore so I'm trying to learn web programming on my own. The only problem is opening HTML documents in a browser don't work with server side programming(unless there is a way to try that without using an actual server hosting it).

    I'm currently reading through wd3schools JavaScript tutorial, and other resources for the server side(professor for web dev class posts slides on his website).

    I'd appreciate any help really, whether it's in resources for learning or hosting websites, or if there's free hosting anyone would recommend(I looked at vlexofree and it said they're not taking any new free users).

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

    why cant i install software in ubuntu virtualbox?

    Posted: 09 Feb 2018 11:46 PM PST

    there isnt much to screenshot here, its just like it sounds... i have virtual box, distro - ubunto 16.04.3

    i'v download visual studio code for python successfuly, but as far as installation goes, it "installing" for one sec and then stopped...

    any ideas why?

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

    (Java) I'm confused about the time complexity of the add() method of ArrayLists. (Add() at end of list)

    Posted: 09 Feb 2018 11:12 PM PST

    Does it count as O(1) or O(n)? I originally thought it would be O(n) because eventually you need to reallocate, meaning you need to create a new array and what not which is O(n) time

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

    Why in the world is my mock suddenly running on the class under test?

    Posted: 09 Feb 2018 07:23 PM PST

    Just when I think I have the concept of mocks understood, a piece of code comes along and completely destroys my understanding. Here's a little background info:

    • I'm running PowerMock and EasyMock in tandem, with the object in question being an EasyMock. I honestly don't know if use of both is necessary or causing issues in and of itself.
    • I'm putting this object, mockTableStatus, to use in two ways. For test cases that are working, I'm doing the following:

    EasyMock.expect(mockCallFloozie.getTableStatus()).andReturn(mockTableStatus); List<TableStatus> tableStatuses = new ArrayList<TableStatus>(); tablesStatus.add(mockTableStatus);

    mockDb.addEntry(tableStatuses);

    My problem rears it head when I throw an exception on a preceding method and have to update the mockDb via another means. The actual class under test looks like this:

    private void updateStatusToFailed(DataSource dataSource){ TableStatus ts = new TableStatus(dataSource, Status.ERROR,ApplicationContext.getScanId()); List<TableStatus> failedTableStatuses = new ArrayList<TableStatus>(); failedTableStatus.add(ts); realDb.addEntry(failedTableStatuses); }

    My ignorant self says 'Well ok, I can just add my mockTableStatus to a local TableStatus list in my test class and have my mockDb add the mock failed entry' as so:

    List<TableStatus> failedTableStatuses = new ArrayList<TableStatus>(); failedTableStatuses.add(mockTableStatus); mockDb.addEntry(failedTableStatuses); EasyMock.expectLastCall();

    This is where my understanding of mocked objects breaks down. When I run the test, eclipse reports an Unexpected method call on the exact method I'm mocking but on the actual class under test: ClassUnderTest.addEntry([here..... with an '@123435' value at the end. The actual mocked method is beneath the trace with an expected:1 actual: 0. Why oh why would this want to look at the actual class? Please lend a hand. Let me know if you need more info and I'll be happy to provide it.

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

    How to show the permalink as a text in site?

    Posted: 09 Feb 2018 10:56 PM PST

    For a project I have to show some text in the body which changes according to permalink!

    Ex: xyz.xyz/?texthere

    This displays texthere in the body

    Xyz.xyz/?anothertext

    This displays anothertext in the body

    Xyz.xyz/?example

    This displays example in the body

    Is there any way to do this? I could't figure this out, no database.. No php..

    :/

    I asked this in r/html5 but no one responded over there, is this not possible?

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

    When should I break up a function into smaller functions?

    Posted: 09 Feb 2018 10:36 PM PST

    I usually try to break up my problem into the smallest possible parts, but I feel like I end up with so many functions just to do one thing. For example, I'm going through a problem that has me searching (not a school problem) a 20x20 grid where I'll look in 8 different directions. Now I could just make 1 function that searches in all 8 directions, or break this function into smaller parts so that in the end I have 8 functions minimum for each direction of the search. It does make test cases easier, though. And it does help me refactor in the future, but I end up with more code than I feel I need. Any thoughts?

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

    Programming Interviews

    Posted: 09 Feb 2018 11:10 AM PST

    Hi, I've bookmarked this 4 posts about intreview questions.

    Are all these necessary?

    How to Succeed in any Programming Interview

    Entry Level Interview

    Collection of Interview Questions

    Bad Questions

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

    How to make window same size as Scene/ Pane?

    Posted: 09 Feb 2018 10:27 PM PST

    import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Background; import javafx.scene.layout.BackgroundFill; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.stage.Stage; public class Graph extends Application{ @Override public void start(Stage mainStage) throws Exception { Pane graphDisplay = new Pane(); Scene scene = new Scene(graphDisplay,401,401); graphDisplay.setMaxHeight(scene.getHeight()); graphDisplay.setMaxWidth(scene.getWidth()); loadGraph(graphDisplay,scene); mainStage.setResizable(false); mainStage.setTitle("Graph Calculator Tester"); mainStage.setScene(scene); mainStage.show(); } public void loadGraph(Pane graphDisplay, Scene scene) { graphDisplay.setBackground(new Background(new BackgroundFill(Color.WHITE, null, null))); Line xAxis = new Line(); xAxis.setStartX(0); xAxis.setStartY(scene.getHeight() / 2); xAxis.setEndX(scene.getWidth()); xAxis.setEndY(scene.getHeight() / 2); Line yAxis = new Line(); yAxis.setStartX(scene.getWidth() / 2); yAxis.setStartY(0); yAxis.setEndX(scene.getWidth() / 2); yAxis.setEndY(scene.getHeight()); Label mouseLocation = new Label("X Cord: " + " | " + " Y Cord: "); graphDisplay.setOnMouseMoved(e -> { mouseLocater(mouseLocation, e); }); graphDisplay.getChildren().addAll(xAxis,yAxis,mouseLocation); } public void mouseLocater(Label mouseLocation, MouseEvent e) { int x = (int)e.getX(); int y = (int)e.getY(); mouseLocation.setText("X Cord: " + x + " | " + " Y Cord: " + y); } public static void main(String[] args) { Application.launch(args); } } 

    When running you can see the line drawn at the x and y axis don't line up with the center as expected due to the window being slightly larger. When hovering in the bottom right corner it says the size is 410 x 410 instead of 401 x 401.

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

    Need help with understanding this problem's solution

    Posted: 09 Feb 2018 10:24 PM PST

    https://www.hackerrank.com/challenges/kangaroo/problem

    I don't even know how people even come up with this. I understand the first condition, but the second one (x2-x1) % (v1-v2) == 0, I don't get it at all. I know what it does, but I don't know how.

    f(v1 > v2 && ((x2-x1)%(v1-v2) == 0)) printf("YES"); else printf("NO");

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

    Can an object file be used without (for example) a .cpp file?

    Posted: 09 Feb 2018 10:10 PM PST

    Hello, not sure if I worded that question correctly but I have a midterm coming up in my c++ class. For the practice my teacher provided us sample code from a few different files:

    • array.cpp
    • array.h
    • main.cpp
    • supplied.o

    The array.h file has a couple of function declarations that are commented out saying they are already written and "supplied".

    So it seems that I would have a supplied.cpp file but that was not given to us.

    I guess my question is how do object files really work? Would the supplied.o file have information in it without a .cpp file to compile with it? Or is it possible this was just an example for a midterm practice?

    Probably a dumb question but I'm really confused by this.

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

    Need help with running Pascal repeatedly.

    Posted: 09 Feb 2018 09:50 PM PST

    Hey there, so I just started to program with pascal, i'm a noob programmer with no experience in programming. And I would like to ask if there's a way to run pascal repeatedly, without have to run the .exe file every time it close. here's my code. program maths; uses crt; var x,y:real; begin clrscr; write('value of x: '); read(x); write('value of y: '); read(y); writeln('sum: ',x+y); readln(); end.

    if there's anyway to run the code repeatedly without the .exe closing.

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

    [Java] Realtime screen grabber that can be analyzed

    Posted: 09 Feb 2018 05:55 PM PST

    I want to be able to detect if an entire section of my screen at any point(realtime) is white or black how would I do that? How would I make it so when it updates an action is taken?

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

    Having trouble calculating standard deviation from array in java program.

    Posted: 09 Feb 2018 09:41 PM PST

    I have tried basically everything and cant figure out how to get the standard deviation. I have the mean and know the formula to calculate it, but cant put it into the code. I know i have to get each number from the array and subtract the mean from it then square it, but i cannot figure out how to pull each number from the array within the text file. Here is my code:

    https://pastebin.com/QbbYUFC3

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

    Books for learning python

    Posted: 09 Feb 2018 03:26 PM PST

    I know how to code in C# but python is the one language that I really want to know how to code with it, can you guys give me any good book or books to learn python, I like to read a lot and I don't mind so don't be afraid to send me big books :D

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

    Recursion is a complicated topic, but I made this clock to make fun of it

    Posted: 09 Feb 2018 09:03 PM PST

    Here is the blog post with the running clock and code: https://blog.ktbyte.com/2018/02/09/clock-illustrating-the-idea-of-recursion/

    Did you know that if you google "recursion", google will suggest that you click on a link for recursion?

    This clock uses recursion (the code) to draw an image that needs recursive thinking to understand =)

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

    (Java) Animation Timer, an abstract class that doesn't need to be extended?

    Posted: 09 Feb 2018 08:56 PM PST

    Hey, I'm a self taught java dev just messing around for fun, I came across the AnimationTimer in JavaFX, and I wanted to mess around with a bit, so I went online to find some examples. I found some, imported them and played around with what they had, but then I wanted to try my own from scratch. I loaded it up, however when I attempt to create a AnimationTimer, it says that its an abstract class that cannot be instantiated, yet in many examples, namely this

    public class FXSandbox extends Application { private static final int STAR_COUNT = 20000; private final Rectangle[] nodes = new Rectangle[STAR_COUNT]; private final double[] angles = new double[STAR_COUNT]; private final long[] start = new long[STAR_COUNT]; private final Random random = new Random(); @Override public void start(final Stage primaryStage) { for (int i=0; i<STAR_COUNT; i++) { nodes[i] = new Rectangle(1, 1, Color.WHITE); angles[i] = 2.0 * Math.PI * random.nextDouble(); start[i] = random.nextInt(2000000000); } final Scene scene = new Scene(new Group(nodes), 800, 600, Color.BLACK); primaryStage.setScene(scene); primaryStage.show(); new AnimationTimer() { @Override public void handle(long now) { final double width = 0.5 * primaryStage.getWidth(); final double height = 0.5 * primaryStage.getHeight(); final double radius = Math.sqrt(2) * Math.max(width, height); for (int i=0; i<STAR_COUNT; i++) { final Node node = nodes[i]; final double angle = angles[i]; final long t = (now - start[i]) % 2000000000; final double d = t * radius / 2000000000.0; node.setTranslateX(Math.cos(angle) * d + width); node.setTranslateY(Math.sin(angle) * d + height); } } }.start(); } public static void main(String[] args) { launch(args); } 

    }

    and

    public class Baubles extends Application { private static final int MAX = 64; private static final double WIDTH = 640; private static final double HEIGHT = 480; private static final Random RND = new Random(); private final Queue<Bauble> queue = new LinkedList<>(); private Canvas canvas; @Override public void start(Stage stage) { CanvasPane canvasPane = new CanvasPane(WIDTH, HEIGHT); canvas = canvasPane.getCanvas(); BorderPane root = new BorderPane(canvasPane); CheckBox cb = new CheckBox("Animate"); cb.setSelected(true); root.setBottom(cb); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); for (int i = 0; i < MAX; i++) { queue.add(randomBauble()); } AnimationTimer loop = new AnimationTimer() { @Override public void handle(long now) { GraphicsContext g = canvas.getGraphicsContext2D(); g.setFill(Color.BLACK); g.fillRect(0, 0, canvas.getWidth(), canvas.getHeight()); for (Bauble b : queue) { g.setFill(b.c); g.fillOval(b.x, b.y, b.d, b.d); } queue.add(randomBauble()); queue.remove(); } }; loop.start(); cb.selectedProperty().addListener((Observable o) -> { if (cb.isSelected()) { loop.start(); } else { loop.stop(); } }); } private static class Bauble { private final double x, y, d; private final Color c; public Bauble(double x, double y, double r, Color c) { this.x = x - r; this.y = y - r; this.d = 2 * r; this.c = c; } } private Bauble randomBauble() { double x = RND.nextDouble() * canvas.getWidth(); double y = RND.nextDouble() * canvas.getHeight(); double r = RND.nextDouble() * MAX + MAX / 2; Color c = Color.hsb(RND.nextDouble() * 360, 1, 1, 0.75); return new Bauble(x, y, r, c); } private static class CanvasPane extends Pane { private final Canvas canvas; public CanvasPane(double width, double height) { canvas = new Canvas(width, height); getChildren().add(canvas); } public Canvas getCanvas() { return canvas; } @Override protected void layoutChildren() { super.layoutChildren(); final double x = snappedLeftInset(); final double y = snappedTopInset(); final double w = snapSize(getWidth()) - x - snappedRightInset(); final double h = snapSize(getHeight()) - y - snappedBottomInset(); canvas.setLayoutX(x); canvas.setLayoutY(y); canvas.setWidth(w); canvas.setHeight(h); } } public static void main(String[] args) { launch(args); } 

    }

    never actually extend it, yet can create an AnimationTimer? What am I missing here?

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

    No comments:

    Post a Comment