• Breaking News

    Tuesday, April 30, 2019

    25 Practical Blogs To Sharpen Your Coding Skills learn programming

    25 Practical Blogs To Sharpen Your Coding Skills learn programming


    25 Practical Blogs To Sharpen Your Coding Skills

    Posted: 30 Apr 2019 06:50 PM PDT

    A bunch of free Git tutorials

    Posted: 30 Apr 2019 03:15 AM PDT

    Hey everyone!

    I just published a number of Git tutorials aimed at beginners here:

    https://www.deployhq.com/git

    If you've got some feedback, please let me know so I can make some improvements.

    Thanks!

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

    Where to go next - learning Python

    Posted: 30 Apr 2019 12:56 PM PDT

    Hi all,

    Over the last two weeks I've completed the Intro to Python: Absolute Beginners and Intro to Python: Fundamentals, run by Microsoft on EdX. Now that I've completed them I feel that my understanding of the basics is good, but am not sure where to go next!

    I wondered if anyone had an recommendations of specific intermediate level courses/practice exercises/videos (preferably free or cheap) that I can move onto next - a lot of the online courses that I've seen start back at the basics, and as I feel comfortable with this I don't want to feel like I'm repeating everything!

    Thanks in advance :)

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

    Do I need a flowchart?

    Posted: 30 Apr 2019 06:37 PM PDT

    Hello,

    I am a pretty junior dev building a node.js application that will do a bunch of api calls and database updates to keep an inventory database current and maintained for accurate up-to-date querying. I'm a little hung-up on the organizational side of things. I continue to build this app and it does what I want, but I would prefer to start tidying things up a bit.

    My instinct is to create a chronological flowchart and using that flowchart, turn my code into a chain (or multiple chains) of promises. I know there will be many alternate ways to do this, so my question is this:

    Would you do it this way? If so, what are some tips going forward. Tools you would use (like a favorite flowchart builder?)

    If not, how would you do it, and why would that way be better?

    Thanks for being such an awesome community and giving me some help when I was very very new to programming and struggling lots!

    ~D

    Edit for clarity

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

    Is there someone who is willing to help me with programming?

    Posted: 30 Apr 2019 11:40 PM PDT

    i have a lot of questions and I would like to improve a lot in programming, but I tend to do mistakes, is there someone who might be available to help me?

    Thank you, to who is going to help me.

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

    What exactly is The Odin Project teaching me?

    Posted: 30 Apr 2019 05:35 PM PDT

    Hello, I'm 17 years old, and interested in learning how to code. I'm interested in developing/designing websites, and jumped right into The Odin Project without much knowledge about it; I just saw it being recommended as a great way to go from Beginner to Web Developer. So far, its made me install Git, Heroku, and Ruby, and it seems to me that these programs/languages(I really have no idea what I'm doing) are more specifically tailored to the end goal of getting a job as a programmer working for a company. That is my problem, I have no interest in doing so; I want to be a freelance web developer. Should I continue learning from The Odin Project, or will it just be teaching me what I need to learn in order to land a job as a programmer? Any help would be much appreciated, thanks!

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

    [C++] In a header file, how do you know what to put in public or private?

    Posted: 30 Apr 2019 11:21 PM PDT

    Reading through the Gaddis text and I'm confused on defining public and private in the header file for your classes.

    How do I know what deserves to be public and what deserves to be private? It all seems so darn random

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

    Object methods and 'this'

    Posted: 30 Apr 2019 11:20 PM PDT

    Here one can read "When a function is called as a method of an object, its this is set to the object the method is called on." (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#As_an_object_method). However, on the Bind page's (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) first example (line 8) the same example returns 'undefined' instead of returning 42. What am I missing?

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

    Checking if element from 1 list is available in another

    Posted: 30 Apr 2019 10:50 PM PDT

    def check(guess,code): count = 0 for x in guess: if guess[x] in code: count += 1 guess.remove(x) return print("{} correct".format(count)) 

    Both guess and code have been converted to lists. Why isn't this code working? If I input code to be 210987654321 and guess to be 210987654321 it only returns 6

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

    Writing Testable Code

    Posted: 30 Apr 2019 11:24 AM PDT

    I have written a blog post about software engineering principles for writing cleaner and testable code and though it could be useful for people who are learning how to program and want to learn more about best practices: https://medium.com/feedzaitech/writing-testable-code-b3201d4538eb

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

    How else could I write this sequential search in Python?

    Posted: 30 Apr 2019 10:11 PM PDT

    lst = [(a0, b0), (a1, b1), ... (aN, bN)] lst2 = [] ... a = ??? index = -1 for i in range(lst): if a == lst[i][0]: index = i if index >= 0: lst2.append(lst.pop(i)) 

    edit: The objective is to find an element in a list by the element's first member, then to remove the entire element from the list, and append it to a second list.

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

    [C] Segmentation Fault when switching for loop style?

    Posted: 30 Apr 2019 10:09 PM PDT

    When I switch how I handle my for loops, I get a Seg Fault. The first code block doesn't work, but the second one does. Why does it do this? Any help much appreciated.

    int i; int j; for(i = 0; i <= (requests - 1); i++){ foundFlag = 0; currentRequest = list[i].value; for(j = 0; j <= (frames - 1); j++){ if(currentRequest == holdFrame[j]){ printf("Page %d already in Frame %d\n", currentRequest, j); foundFlag = 1; } } 

    for(int i = 0; i <= (requests - 1); i++){ foundFlag = 0; currentRequest = list[i].value; for(int j = 0; j <= (frames - 1); j++){ if(currentRequest == holdFrame[j]){ printf("Page %d already in Frame %d\n", currentRequest, j); foundFlag = 1; } } 
    submitted by /u/Datchcole
    [link] [comments]

    Should I stick with web development or get into software development?

    Posted: 30 Apr 2019 05:31 PM PDT

    So, about 2 years ago, i went through a coding bootcamp and we covered basics of web development and then went into python and java development. When i finished, i felt so drained and felt like i had only just scratched the surface and also felt lost in what i wanted to focus on within programming. I quit for a bit but always come back for some reason, like i need to do it.

    I have been practicing front end web development (html, css, basic javascript, and react) for the past year and half. I work for a big company now not doing any programming but i do it freelance on the side while i continue to learn. I really like the company i work for now but there are always JAVA developer roles within our internal job listings and no web dev jobs.

    My question is, should i stick with web development or re learn JAVA and pursue software development instead? I know its sort of a hard question to ask but i just wanted the general opinion of people on reddit.

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

    Attempting to create a trigger in MySQL Workbench. Not very familiar with SQL.

    Posted: 30 Apr 2019 09:13 PM PDT

    I'm building a small library database in MySQL Workbench. My table CHECKOUT has an attribute CheckoutDate. I have another table CHECKIN that has an attribute CheckinDue. I'm trying to figure out how to get the value of CheckoutDate and use it to calculate CheckinDue and insert that into CHECKIN.

    This is the 3rd place I've posted to, I've tried youtube tutorials, online examples, the book, and I still can't seem to get it.

    I know that the way I've set up my database and tables isn't the most efficient, but I'm still learning here. I want to figure out how to do it. Even if you don't give me the answer, can you PLEASE point me in the right direction?

    here's a link to my post on StackExchange that shows the code and more detail: https://stackoverflow.com/questions/55931399/how-to-use-an-attribute-in-one-table-to-calculate-a-different-attribute-in-anoth

    ANY HELP IS APPRECIATED.

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

    setOnItemClickListener not making any action on click in fragment

    Posted: 30 Apr 2019 08:57 PM PDT

    I have set this setOnItemClickListener() for the listview. However, when I press the list item, it doesn't do anything. I have already gone through all of the same questions on StackOverflow and none of them answers my question. However, the context menu appears fine when I long pressed the list item.

    My code:

    public class FragmentText extends Fragment implements LoaderManager.LoaderCallbacks<Cursor>

    {

    private static final int TEXT_LOADER = 0;

    View textView;

    FloatingActionButton fabText;

    TextAdapter mTextAdapter; ListView editorList;

    @Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

    {

    textView = inflater.inflate(R.layout.text_fragment, container, false);

    fabText = textView.findViewById(R.id.add_text);

    editorList = (ListView)textView.findViewById(R.id.editor_list);

    fabText.setOnClickListener(new View.OnClickListener() {

    @Override

    public void onClick(View v) {

    Intent editorIntent = new Intent(textView.getContext(), TextEditor.class)

    startActivity(editorIntent);

    }

    });

    mTextAdapter = new TextAdapter(textView.getContext(), null);

    editorList.setAdapter(mTextAdapter);

    registerForContextMenu(editorList);

    editorList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

    @Override

    public void onItemClick(AdapterView<?> parent, View view, int position, long id){

    Toast.makeText(getContext(), "Clicked", Toast.LENGTH_SHORT).show();

    }

    });

    getLoaderManager().initLoader(TEXT_LOADER, null, this); return textView;

    }

    xml for listview:

    <?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent">

    <ListView android:id="@+id/editor_list"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:divider="@android:color/transparent" />

    <android.support.design.widget.FloatingActionButton

    android:id="@+id/add_text"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:layout_alignParentBottom="true"

    android:layout_alignParentRight="true"

    android:layout_margin="20dp"

    android:src="@drawable/text"/>

    </RelativeLayout>

    xml for list item:

    <?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    xmlns:tools="http://schemas.android.com/tools">

    <android.support.v7.widget.CardView

    xmlns:card_view="http://schemas.android.com/apk/res-auto"

    android:layout_width="match_parent"

    android:layout_height="50dp"

    android:layout_margin="3dp"

    card_view:cardCornerRadius="4dp"

    card_view:cardElevation="2dp"

    android:longClickable="true"

    android:foreground="?android:attr/selectableItemBackground">

    <FrameLayout

    android:background="@color/colorPrimaryDark"

    android:layout_width="3dp"

    android:layout_height="match_parent"/>

    <TextView

    android:id="@+id/editor_text"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    tools:text="About panda" android:textSize="20sp"

    android:layout_gravity="center_vertical"

    android:paddingLeft="8dp"/>

    </android.support.v7.widget.CardView>

    </RelativeLayout>

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

    Blackjack game: Count Hand Value method

    Posted: 30 Apr 2019 04:58 PM PDT

    I am about to complete my BlackJack version in Javascript. But, I realize that my count hand value method might have extra loops. Any way to reduce this extra loops?

    Here are some of my code:

    const cardSuit = ["hearts", "diams", "clubs", "spades"]; const cardFace = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]; // In JavaScript, functions are objects. // You can work with functions as if they were objects. function card(suit, face) { this.suit = suit; this.face = face; switch (face) { case "A": this.faceValue = 11; break; case "J": case "Q": case "K": this.faceValue = 10; break; default: this.faceValue = parseInt(face); break; } }; const deck = { cards: [] } var tempCard; const player = { cards: [], handValue: 0 } const dealer = { cards: [], handValue: 0 } const hasAceInHand = (cardsOnHand) => { for (let key in cardsOnHand) { let arr = cardsOnHand[key]; for (let i = 0; i < arr.length; i++) { let obj = arr[i]; for (let prop in obj) { if (prop === "face") { if (obj[prop] === "A") { return true; } } } } } return false; } const countHandValue = (cardsOnHand) => { //console.log(hasAceInHand(cardsOnHand)); let sum = 0; for (let key in cardsOnHand) { let arr = cardsOnHand[key]; for (let i = 0; i < arr.length; i++) { let obj = arr[i]; for (let prop in obj) { if (prop === "faceValue") { //console.log(prop + " = " + obj[prop]); sum = sum + obj[prop]; debugger; if (sum > 21 && hasAceInHand(cardsOnHand)) { // Transfer Ace's face value from 11 to 1 sum = sum - 11; sum = sum + 1; } } } } } return sum; } const dealOneCardToPlayer = () => { // Take a card from the top deck to be assigned to tempcard. tempCard = deck.cards.splice(0, 1); player.cards.push(tempCard); player.handValue = countHandValue(player.cards); document.getElementById("handValuePlayer").innerHTML = player.handValue; makeCardPlayer(tempCard[0]); } 

    I have uploaded the whole program at http://js.findingsteve.net/bj

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

    Best free C++ courses for beginners?

    Posted: 30 Apr 2019 08:27 PM PDT

    What are the best free C++ courses for beginners?

    Thank you.

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

    how do i make a similar xml layout to this ?

    Posted: 30 Apr 2019 08:24 PM PDT

    the layout looks like this (https://ibb.co/4FQCJVW) , i am gonna use a relative layout with 1 image view for the logo, 2 edit texts for the input, one button and one more image view. my questions are :

    1- how do i change the size of the logo at the top so it fits more nicely ?

    2- how do i change the edittext to look like this with round edges and the hint not taking the whole space and not to be stuck to both edges ?

    3 - should i use padding or margin so the spaces between the views look nicer ?

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

    C# Found a bug that I can not figure out a fix for (Unity)

    Posted: 30 Apr 2019 11:38 AM PDT

    The project I'm working on involves a simple level editor, where players can spawn in several objectives and obstacles that can be saved and loaded for others to play. In the level editor, I have a camera that pans around by mouse dragging, and zooms by scroll wheel. There are also buttons that spawn an object. Once an object is spawned, you can then drag the object around to where you want it to be situated. However, I've run into the issue where once I drag the object, I can no longer drag it again by clicking on the object. Instead, I have to click the spot where the object was initially spawned, in which case the object moves back to that location and I can drag it again. I have two scripts that are involved in the camera movement, and the dragging of objects.

    public class DragMovementController : MonoBehaviour { private void OnMouseDrag() { float distanceToScreen = Camera.main.WorldToScreenPoint(gameObject.transform.position).z; transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distanceToScreen)); } } public class MouseScreenMovement : MonoBehaviour { float PanSpeed = 20f; float zoom; float zoomSpeed = 10f; float[] BoundsX = new float[] { 0f, 100f }; float[] BoundsY = new float[] { 0f, 100f }; private Camera cam; private Vector3 lastPanPosition; void Awake() { cam = GetComponent<Camera>(); } void Update() { HandleMouse(); } void HandleMouse() { if (Input.GetMouseButtonDown(2)) { lastPanPosition = Input.mousePosition; } else if (Input.GetMouseButton(2)) { PanCamera(Input.mousePosition); } ZoomCamera(); } void PanCamera(Vector3 newPanPosition) { Vector3 offset = cam.ScreenToViewportPoint(lastPanPosition - newPanPosition); Vector3 move = new Vector3(offset.x * PanSpeed, offset.y * PanSpeed, 0); transform.Translate(move, Space.World); Vector3 pos = transform.position; pos.x = Mathf.Clamp(transform.position.x, BoundsX[0], BoundsX[1]); pos.y = Mathf.Clamp(transform.position.y, BoundsY[0], BoundsY[1]); transform.position = pos; lastPanPosition = newPanPosition; } void ZoomCamera() { if (Input.GetAxis("Mouse ScrollWheel") > 0f && transform.position.z <= -12) { transform.Translate(Vector3.forward * 2f, Space.Self); } if (Input.GetAxis("Mouse ScrollWheel") < 0f && transform.position.z >= -50) { transform.Translate(Vector3.back * 2f, Space.Self); } } } 
    submitted by /u/tcrouch199205
    [link] [comments]

    How to get into machine learning from scratch

    Posted: 30 Apr 2019 11:23 AM PDT

    I have little programming experience, I know how to somewhat code in C but all my knowledge comes from a first year engineering course that teaches you barely anything. I want to start getting into machine learning but I don't know how to go about it. Any help is greatly appreciated.

    Edit: I meant to ask what are the steps from the beginning so that I can gradually work my way up to machine learning.

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

    Is this a good way to validate input? (Python)

    Posted: 30 Apr 2019 07:49 PM PDT

    So I am a high school student who has some experience in competitive programming but is a total noob in software development. Just want to ask: is the following code a good way to validate input in a software?

    def isTryAgain(): inputDecision = input("One more time? (y/n): ") if inputDecision=="y": return True elif inputDecision=="n": return False else: print("Invalid Input.") return isTryAgain() 
    submitted by /u/titusng074
    [link] [comments]

    Image heavy website

    Posted: 30 Apr 2019 07:42 PM PDT

    Not sure what the best path is to make an image-heavy website. Possibilities are: storing all images in S3, storing images locally where servers are hosted, storing images into third party cloud services like cloudinary

    The main focus of this problem is to reduce the cost while not compromising to speed and reliability of serving images.

    What are your thoughts?

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

    Problem using Nested Loops in Python

    Posted: 30 Apr 2019 07:38 PM PDT

    Hey,

    I'm running into some issues: I'm learning the basics of Python and I'm stuck on a problem that's asking me to use nested loops to make a star pattern for the letter "E." I've been racking my brain over it for a good hour and I'm getting frustrated since I've gotten no where after trying to look up some help.

    Can someone help me understand this a little clearer?

    Here's what I have to work with:

    # LetterE.py - This program prints the letter E with 3 asterisks

    # across and 5 asterisks down.

    # Input: None

    # Output: Prints the letter E.

    NUM_ACROSS = 3 # Number of asterisks to print across

    NUM_DOWN = 5 # Number of asterisks to print down

    # Write a loop to control the number of rows.

    for row in range (3):

    # Write a loop to control the number of columns

    for col in range (2):

    # Decide when to print an asterisk in every column.

    if col == 0 or col == 2:

    print("**", end="")

    # Decide when to print asterisk in column 1.

    if col == 1:

    print("*")

    # Decide when to print a space instead of an asterisk.

    print(" ")

    # Figure out where to place this statement that prints a newline.

    print("\n")

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

    How am I supposed to learn information from a 900+ page book?

    Posted: 30 Apr 2019 07:34 PM PDT

    How are you meant to retain so much information from a book of that size? I feel like by the end of the book, I would've forgotten an extremely large portion of it.

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

    No comments:

    Post a Comment