• Breaking News

    Tuesday, May 8, 2018

    I am confused about SASS and Curly Braces... Ask Programming

    I am confused about SASS and Curly Braces... Ask Programming


    I am confused about SASS and Curly Braces...

    Posted: 08 May 2018 03:21 PM PDT

    So I am pretty new to SASS. I am trying to figure out how the nesting works. When I look on SASS's website, they are shown using curly braces. To my knowledge, (and the fact my editor is yelling at me) you don't add curly braces and SASS is just used with indentation.

    EDIT I figured out how to do it without the curly braces, but I am still confused as to why the documentation is showing that you use curly braces when I am pretty confident that you don't in a .sass file.

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

    [language] Infix to Postfix program. Having a bit of trouble.

    Posted: 08 May 2018 05:05 PM PDT

    My professor has provided me with a tokenizer class - https://github.com/PaulConradSBVC/CS265_SP2018/tree/master/CStrTokenizer . And he gave me the pseudocode - https://uploadfiles.io/gjy0r . However, i'm having trouble on one part. I don't understand what's going on on 5.C.ii.b . Can someone please explain. thank you.

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

    Infinite recursion in a Minimax Algorithm

    Posted: 08 May 2018 09:35 AM PDT

    I making the AI for a tic tac toe program using the minimax algorithm in Ruby, but it is hitting the recursion depth limit. Can anyone tell me why?

    My full code is here: https://github.com/CorySpitzer/tic_tac_toe/tree/ai

    My method is below:

    def minimax(board, game) #depth can be here if board.game_over? mark return get_score(@mark) end # depth += 1 scores = [] best_moves = [] board.available_moves.each do |move| scores.push self.minimax(board.make_move(move, @mark), game) moves.push move end # directly from https://tinyurl.com/yanf74x8 if game.current_player == @mark max_score_index = scores.each_with_index.max[1] @choice = moves[max_score_index] return scores[max_score_index] else # This is the min calculation min_score_index = scores.each_with_index.min[1] @choice = moves[min_score_index] return scores[min_score_index] end end 
    submitted by /u/red1_lost
    [link] [comments]

    Where to swim?

    Posted: 08 May 2018 02:16 PM PDT

    Let's say Programming Languages are a ocean.

    In April someone asked me to make some Excel sheets. I said yes, I studied a bit before taking the job and in three weeks I learned how to use Excel properly (for the task) and how to write in VBA very pretty codes.

    I can say I'm proficient now. It was like watching the ocean, but inside a pool. Now, I don't want to go deep sea diving, or to explore the Marianna Trench, but I want to ask you, what's the best language to start swimming considering my background?

    I'm looking for commercially viable options. So I'm looking for the "learn this, is fun and leads to work" type of Language, not the "learn that obscure programming language I use to write algorithm to find a solution for Riemann-Zeta fuction and small sudoku apps".

    SIDENOTES:

    I used to write simple codes on PERL, I'm not that good by the way, let's say I can confront the PERL sea with a nice pair of armbands. I just float.

    I know HTML and CSS basics, given with my VBA proficiency I can say I'm at least good with any fake programming language (funny emoji)

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

    Why Is The First Row of These Floating Divs Descending?

    Posted: 08 May 2018 11:31 AM PDT

    I've put a few <img> elements into a div and then set them to float: left; in o`rder to get them to line up side-by-side, but I'm getting this strange behavior where the first row slowly descends. Every following row has the intended behavior of nicely lining up next to each other.

    This is how the <div> that holds the <img> is styled:

    .display_being { position: relative; width: 112px; height: 164px; float: left; } 

    https://i.imgur.com/PlW9RG3.png

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

    On euclidean algorithm

    Posted: 08 May 2018 01:15 PM PDT

    When implementing the euclidean algorithm to find the gcd it usually goes like this:

    int temp; while( x!=0 ) { temp = y % x; y = x; x = temp; 

    My question is: does it matter whether x is bigger than y? Do I have to determine which one is bigger before calling gcd() ?

    submitted by /u/NickTesla-
    [link] [comments]

    Need Help with Interview Question

    Posted: 08 May 2018 04:46 PM PDT

    Given a large stream of integers, how will you sort them if you have limited RAM and no hard disk.

    During the phone call I got flustered and couldn't answer the question. However, afterwards, I googled the time/space complexities of sorting algorithms and found that heap sort had space complexity O(1) meaning it only needs a fixed amount of RAM and among its peers with the same space complexity, it had the best "worst time-complexity". So I messaged the interviewer on WhatsApp with this answer. They did not respond. It's been itching me ever since... did I get it right? If not, can you give me the correct answer with an explanation?

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

    Does 'Programming as a Craft' exist, and how does one engage in it?

    Posted: 08 May 2018 08:21 AM PDT

    Are there any programming languages that allow Classes (or whatever paradigm you subscribe to) to access classes in sub packages when access level for the sub package class is packaged?

    Posted: 08 May 2018 09:34 AM PDT

    For example let's say I have class foo.Foo and another class at foo.bar.Bar. Are there any languages where if Bar is only given package access Foo would still be able to access it?

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

    Need help with an API (Golang)

    Posted: 08 May 2018 01:20 PM PDT

    I have a flight API that returns in text about where flights come from. Its based from one airport - and the list changes depending on what flight is landing ect. I hosted it on the localhost and it worked well. Only problem is that i want a little flag besides country. "Cou" in json is country. I just want a flag with it.

    This is how the result looks like, i want a flag besides whatever country is: https://imgur.com/fWtDrTZ - In that example its Morocco, if i refresh its another flight from another country

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

    Help with requiring a checkbox before form submission

    Posted: 08 May 2018 08:38 AM PDT

    Hello Redditors, I have been stumped for the past week on this problem. I was hoping someone from this great community could help me solve this. I am not a professional programmer but I do know more than the basics. I am trying to add a terms and conditions checkbox right before you checkout on my store. I have the checkbox added and everything, my trouble is making the checkbox a required check before the order is submitted. I am working with a .php file and I want something as simple as possible.. Thank you very much!!

    Here is what my code looks like;

    public function save_payment_method_checkbox() { printf( '<p class="form-row woocommerce-SavedPaymentMethods-saveNew"><input checked id="wc-%1$s-new-payment-method" name="wc-%1$s-new-payment-method" type="checkbox" value="true";/><label for="wc-%1$s-new-payment-method" style="display:inline;">%2$s</label></p>', esc_attr( $this->id ), esc_html( apply_filters( 'wc_stripe_save_to_account_text', __( 'I agree to the Terms and Conditions.', 'woocommerce-gateway-stripe' ) ) ));}

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

    Binary tree remove function not deleting node

    Posted: 08 May 2018 08:30 AM PDT

    hello, I have been working on my binary tree, and have gotten the add and print to work(print is a work in progress). However, my remove function never deletes anything. Any tips?

    /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import javax.swing.JOptionPane; /** * * @author student */ public class BinarySearchTree { String print = ""; //used for clearing in the print function Node head; //creates head node variable boolean finished = false; //sets a global boolean that will be used in the print function BinarySearchTree() { } //empty binary tree constructor void setHead(Node n) { this.head = n; } //allows the head node to be set public void addNode(Node n) { //calling the add node function if (head == null) { head = n;//if the head is null, set head to n } else { Node focusNode = head; Node parent; while (true) { parent = focusNode; if (focusNode.data.compareTo(n.data) > 0) { focusNode = focusNode.left; if (focusNode == null) { parent.left = n; return; } //starts at the left node } else { //if else, move to the right node focusNode = focusNode.right; if (focusNode == null) { parent.right = n; return; } } } } } boolean remove(Node n) { Node parent = head; Node focusNode = head; boolean isleft = true; if (focusNode == null) { return false; } while (focusNode != null) { parent = focusNode; if (n.data.compareTo(focusNode.data) > 0) { isleft = true; focusNode = focusNode.left; } else { isleft = false; focusNode = focusNode.right; } if (focusNode == null) { return false; } } if (focusNode.right == null && focusNode.left == null) { if (focusNode == head) { head = null; } else if (isleft) { parent.left = null; } else { parent.right = null; } } else if (focusNode.right == null) { if (focusNode == head) { head = focusNode.left; } else if (isleft) { parent.left = focusNode.left; } else { parent.right = focusNode.left; } } else if (focusNode.left == null) { if (focusNode == head) { head = focusNode.right; } else if (isleft) { parent.left = focusNode.right; } else { parent.right = focusNode.right; } } else { Node replacement = findReplacementNode(focusNode); if (focusNode == head) { head = replacement; } else if (isleft) { parent.left = replacement; } else { parent.right = replacement; } replacement.left = focusNode.left; } return true; } Node findReplacementNode(Node replacedNode) { Node replacementParent = replacedNode; Node replacement = replacedNode; Node focusNode = replacedNode.right; while (focusNode != null) { replacementParent = replacement; replacement = focusNode; focusNode = focusNode.left; } if (replacement != replacedNode.right) { replacementParent.left = replacement.right; replacement.right = replacedNode.right; } return replacement; } // Node find(Node f){ // Node focusNode = head; // // while (focusNode!=null){ // if (f.data.compareTo(focusNode.data)>0){ // focusNode = focusNode.left; // //look left // } else { // //look right // focusNode = focusNode.right; // } // if (focusNode==null){ // return null; // } // } // // return focusNode; // //while loop ends when they are equal // } public String print(Node focusNode) { if (focusNode != null) { print(focusNode.left); // if(finished==false){ // print = ""; } // print = print+" "+focusNode.data; System.out.println(focusNode.data); print(focusNode.right); finished = true; } //before it reaches the last one, print. // if(finished==true){ // JOptionPane.showMessageDialog(null,print); // } return print; } } 

    /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import javax.swing.JOptionPane;

    public class main { public static void main(String args[]) { boolean finished = false; BinarySearchTree theTree = new BinarySearchTree(); while (finished != true) { //keeps the code running until stopped String start = JOptionPane.showInputDialog("Press 'A' to add a Node to the list\n" + "press 'D' to delete a Node from the list" + "\npress 'F' to traverse the list"); //sets a JOptionPane that prompts the user to enter a letter which will redirect them to the specific function. if (start.equals("a") || start.equals("A")) { Node focus = new Node(); focus.data = JOptionPane.showInputDialog("enter the name of the child you would like to ADD to the tree"); theTree.addNode(focus); //adds the inputted node into the list. //proceeds to print out the list from left to right } if(start.equals("d")||start.equals("D")){ Node focus = new Node(); focus.data = JOptionPane.showInputDialog("What would you like to delete?"); //if user inputs a node that is within the tree, delete that node. theTree.remove(focus); } if(start.equals("f")||start.equals("F")){ JOptionPane.showMessageDialog(null,theTree.print(theTree.head)); theTree.finished=false; } } } } 
    submitted by /u/blankbleak
    [link] [comments]

    Buying a computer?

    Posted: 08 May 2018 03:58 PM PDT

    I want to buy a computer but not sure if it is worth buying a pc or laptop I think it is more cost efficient for a pc but laptops are more convenient

    I am in 10th grade and have a decent budget of like 800-1k I've been saving from my two jobs

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

    Creating new packages in NetBeans for an easy project

    Posted: 08 May 2018 08:13 AM PDT

    I'm having issues organizing new packages for a project in NetBeans. The MOOC that's grading it says to create a certain package, even though I already did. It's not letting me create the packages without putting them in the src folder if that's the issue.

    https://imgur.com/a/91dGaax

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

    Am I a bad programmer?

    Posted: 07 May 2018 10:19 PM PDT

    I am very close to finishing my bachelor's degree.

    I decided to contribute to a project that I'm interested in. I looked through its issues on GitHub and found one that looked simple enough, the project crashing on a certain input. It wasn't marked as an easy hack or anything, but it was contained entirely within the program (it has some weird external things that are harder to debug) and had a clear test case to reproduce.

    Here is a rough list of what I did in my programming sessions over several days. I didn't log my time or anything, but each of these sessions was 1-2 hours long.

    1. Set up debugger and environment.
    2. Very quickly discovered the low-level cause of the bug thanks to the stack trace the program produced on crash.
    3. Followed that low-level cause up the stack until I hit a dead end. At about this point I started keeping a bottom-up log of the reason for the bug (e.g. "The crash is caused by A, A is caused by B") so I could follow my reasoning between sessions.
    4. Noting that the crash was caused by a certain constant, searched the source tree for places where that constant was assigned. In a stroke of good fortune, the first place I checked in the debugger caused the breaking test case and a very similar, working test case to diverge in their execution paths.
    5. Followed that assignment up the stack until I hit a dead end.
    6. Figuratively banged my head against the wall for lack of ideas.
    7. More banging, but late in the session discovered a lead where one of the elements of the breaking case was treated differently.
    8. Today's session. Examined the lead some more. I thought I had identified the cause of the bug, in that the code in the lead was doing the thing that caused the divergence found in session 4, but a closer examination of the surrounding code revealed that it was probably doing that for the similar non-breaking case as well. Then I pulled from the repository and recompiled, whereupon my debuggers stopped working. Wherever I put a breakpoint they just skip to the end.

    These sessions were not on consecutive days. I sometimes didn't work on the bug for a day or two because I didn't feel like it. And I admit that I have trouble staying on task, and often stopped working to listen to music or browse reddit or something.

    And this wasn't my first time trying something like this. I have tried to contribute to this same project twice before. The first time I got as far as the specification of a certain binary file format before throwing up my hands; the bug was later determined to be the best possible behaviour in the circumstances. The second time was a feature request, and although I succeeded at implementing the feature, I discovered that no one could do so without breaking things that depended on the lack of it.

    All in all I'm worried about myself and how competent I will be when I am employed.

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

    How to use rowspan

    Posted: 08 May 2018 05:29 AM PDT

    I'm new to coding, so I made this table to practise, but I can't get the "Head with rowspan" to span multiple rows, could someone tell me where I'm going wrong. Thanks in advance!

    <table> <caption>Example Table</caption> <thead> <tr> <th>Head</th> <th colspan="2">Head with colspan</th> <th rowspan="2">Head with rowspan</th> </tr> </thead> <tbody> <tr> <td>Row 1, cell 1</td> <td>Row 1, cell 2</td> <td>Row 1, cell 3</td> </tr> <tr> <td>Row 2, cell 1</td> <td>Row 2, cell 2</td> <td>Row 2, cell 3</td> </tr> <tr> <td>Row 3, cell 1</td> <td>Row 3, cell 2</td> <td>Row 3, cell 3</td> </tr> <tr> <td>Row 4, cell 1</td> <td>Row 4, cell 2</td> <td>Row 4, cell 3</td> </tr> </tbody> </table>

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

    can someone help to create a PIC assembly program that maintains the temperature of a room by using a sensor to control a fan??

    Posted: 08 May 2018 08:34 AM PDT

    Help with Spring Security project

    Posted: 08 May 2018 04:43 AM PDT

    LINK TO GITHUB REPO: https://github.com/kableiv/Spring-Security-project

    Bit of backstory: Completing an assignment and need to create a small website where 2 predefined users can login, one with user privileges and one with admin, the privileges are buttons that redirect you to pages where you edit, delete and register new info. At first I did it without spring security and no database, using arraylists and files. When I logged in with the user it only had the user privileges like it was supposed to, however when I logged in with the admin and then went onto any of the other html pages like the one used to edit something and then clicked on the return button, the admin privileges were gone. Im assuming this was because i, in my method to login, sat its admin value to true(so the html page knew what to display and what not to) and then when that method was done and a new one was starting like the editing method the value was back to null.

    Because of this I decided to try and switch to using a MySQL database with spring security. My IDE of choice is intellij ultimate and I used MySQL Workbench to setup the database and added it into intellij using the database feature.

    I apologize for the variables being in a foreign language quick translation: MinBruger = (MyUser), brugernavn = (username), adgangskode = (password), rolle = (role), barn/boern/børn = child/children.

    Anyways to the problem: Whenever I try to login either as admin or user it fails and sets the url from: http://localhost:5000/login

    TO: http://localhost:5000/login?error

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

    Why aren't new programming languages more Pythonic?

    Posted: 08 May 2018 02:49 PM PDT

    Rust and Go are cool, but I'd use them more if they didn't have curly brackets and ...semicolons.

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

    How to select these HTML elements?

    Posted: 08 May 2018 03:15 AM PDT

    I want to select some HTML elements on YouTube so I can make some changes in CSS but when I try to Inspect them, I just can't seem to find the element.

    First, is the "Search" text element. Say, I want to change the color from gray to orange or change the font.

    https://ibb.co/cZ09G7

    Next, is this divider. I want to get rid of it.

    https://ibb.co/ga7H3n

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

    jquery ready function with undefined

    Posted: 08 May 2018 02:50 AM PDT

    $(window, document, undefined).ready(function() {

    });

    I saw above code when I am going to edit some js file. That "undefined" is correct parameter" ?

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

    Trouble getting Oracle Developer up and running on my home PC: getting a ORA-12560 error. Help, please.

    Posted: 07 May 2018 10:10 PM PDT

    I'm assuming it's okay to post "help" requests in this sub - if not, I apologize (and maybe request somewhere where I can post this question?)

    I'm very new to SQL and need to learn some for a new job - I've purchased a few courses from udemy but I'm having trouble setting up my Oracle SQL Developer locally so I can begin learning.

    Following instructions from the udemy course, I've installed the latest from Oracle (the windows 12.2.0.1.0 - Standard Edition 2 and Enterprise Edition: http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html) to E:\app\XXXXXX\product\12.2.0 but it looks like I goofed the first install as there are now two folders there "dbhome_1" and "dbhome_2" (the second install was done correctly - by, correctly, I remembered where I installed it, the credentials, etc)

    From there I've loaded the cmd prompt and from 'C:\Users\XXXXXX> set ORACLE_SID=dbhome_2' then confirmed it was set by checking with 'echo \%ORACLE_SID\%', confirming that 'dbhome_2' shows.

    Then entered 'set ORACLE_HOME=E:\app\XXXXXX\product\12.2.0\dbhome_2' and confirmed it with 'echo \%ORACLE_HOME\%'

    Then entered 'sqlplus /nolog' and got the following in return:

    SQL*Plus: Release 12.2.0.1.0 Production on Mon May 7 21:40:31 2018

    Copyright (c) 1982, 2016, Oracle. All rights reserved.

    And am now in the 'SQL>' "command prompt" (not sure what the correct nomenclature here is)\\

    Now at this point, the video I'm using says to enter 'connect / as sysdba;' but I'm getting the following error:

    ERROR:

    ORA-12560: TNS:protocol adapter error

    I googled that error code and can see it is something to do with a connection problem with the ORACLE_SID but can't seem to figure out how to make it work.

    I figured I'd try uninstalling everything and starting from scratch, but I can't find anything Oracle related in my add/remove programs list (I'm on Windows 10 Home), and if I attempt to delete the dbhome_1 or /dbhome_2 folders Windows is telling me it's being used by something and I can't delete it (I'm not seeing anything Oracle related in the task manager though)

    So my questions are:

    1. How do I fix this?
    2. Should I just do a reinstall?
    3. How do I go about uninstalling this, since traditional means aren't working

    I am not super technically proficient so help and patience would be very appreciated, thank you.

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

    No comments:

    Post a Comment