• Breaking News

    Friday, September 28, 2018

    Using references vs using return. Ask Programming

    Using references vs using return. Ask Programming


    Using references vs using return.

    Posted: 28 Sep 2018 02:50 PM PDT

    I have a function which will need to change the value of an argument that I supply. If I understand this correctly, I could do this in two ways. I could pass in the argument, change the value inside the function, return that new value and then make the original argument variable equal to the returned value. Alternatively, I could pass in a reference to the variable I want to change as an argument and then change the variable directly inside the function, without having to return anything.

    Is one of these methods more 'acceptable' or 'correct' than the other? From what I know, references should be used when dealing with large variables or objects (as making a copy of them is inefficient). However, is the size/complexity of the argument the only factor that needs to be considered? Is using references for small simple variables like int inefficient and if not, then why not always use references when you want to alter an argument? What if you want to alter several arguments, not necessarily all of the same type; would you have to use references then?

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

    [Looking for software] Is there a command line tool which supports IDE-like searching?

    Posted: 28 Sep 2018 07:00 PM PDT

    In most IDEs you can search for things like class definitions and usages. Are there command line programs that let you do similar queries? Grep wouldn't work for me because it doesn't guarantee correctness in a lot of cases -- it doesn't understand anything about any given programming language.

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

    C# (ASP.Net Core): services.AddDbContext question

    Posted: 28 Sep 2018 09:49 PM PDT

    Hello,

    I am trying to create a new asp.net core web application using Razor pages. I want to add my db context in the startup.cs file, but I am using something called IDesign.

    I have a project tree like this:

    1. Clients
      1. The project with the cshtml files, startupcs and all of that is here
      2. Can only reference managers and utilities projects
    2. Managers
      1. Used for chaining calls to engines/accessors to accomplish tasks at a high level
      2. Used to make calls to accessors
      3. Can only reference accessors, engines, and utilities project
    3. Engines
      1. Used for business logic
      2. Can only reference the accessors and utilities projects
    4. Accessors
      1. resource accessors. Hits dbs/services.
      2. This is where my dbcontext class lives
      3. can't reference anything except for utilities
    5. Utilities
      1. Used to store global classes and utility functions that apply to all projects

    My problem is that if my DbContext lives in the accessors project, how do I pass that up from the managers so that I can use it in the clients? Has anyone had experience with this before?

    Just to reiterate, I know t hat I could easily reference accessors project in the clients project and use the dbcontext from there. My problem is that I want to avoid being able to reference accessors so that other people who are working with this code aren't able to see any accessors classes.

    Hopefully this makes sense. Thanks!

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

    What is the best way to track my knowledge of programming?

    Posted: 28 Sep 2018 09:09 PM PDT

    I have been interested in computers and have been programming off and on for the past few years. I have had a lot of exposure to programming, so I definitely feel like I am beyond a beginner in terms of skill/knowledge. I feel like it'd be really helpful for me to know where I stand in terms of knowledge level. Is there any way I can gauge this? Thanks.

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

    Rant: My Intro to Programming is boring as hell

    Posted: 28 Sep 2018 08:20 PM PDT

    Intro to Programming Class

    I loved learning to code BEFORE this semester in school. I was learning Python and found great pleasure in it. I found computer science fascinating.

    But now I'm learning Java by some sloppy teacher with a strong European accent that can never seem to get to the point or answer questions well, and her lecturing is poor. Her powerpoints are boring. The labs are also pretty dry, run by a very unhelpful TA.

    Other than that, I find that it's sucks the fun out when I feel like I'm learning programming to get a good grade in the class. I KNOW programming is much bigger than this uninteresting reality I'm in.

    I could just shift my focus towards building my SKILLS rather than thinking about the grade. That was definitely what made things enjoyable before I started school but it's so much easier said than done.

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

    Instascan library not working as a native application

    Posted: 28 Sep 2018 06:46 PM PDT

    I am using this library to scan QR code in my website. The QR code scanner works on all browsers both PC and mobile. However, when my website is converted to a native application the QR code scanner does not work. Is there a way to fix this issue?

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

    Newbie Python question

    Posted: 28 Sep 2018 01:43 PM PDT

    I'm having trouble learning how to translate my thought process into code. I'm writing a code where I'm rolling a six sided die x amount of times and then having to find the average value it rolls for all attempts(and displaying all attempts) This is my code so far:

    import random
    import sys
    import math

    amount_of_rolls = int(sys.argv[1])

    for i in range(amount_of_rolls):
    dice_number = random.randrange(1,7)

    print('Rolling', amount_of_rolls, 'times' )

    I understand that I have to somehow save the dice_number for each loop and then average it out somehow but I'm having trouble translating that into the python language. Or maybe I'm looking at this completely wrong. Let me know if my brain left something out that might be important.Thanks for any help :)

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

    Best options for local customer database?

    Posted: 28 Sep 2018 12:17 PM PDT

    (C# Windows Form Application)

    So I've got a basic self made customer database type program that I've been using for my Computer Repair shop, and I am wanting to improve it from my hacked together DataGridView pulling data from ini files and rtf files. I'm considering using a MySQL database to store the information and to edit it on multiple computers, but I am not sure if that's the best option for this, since I will be storing thousands of customers with multiple paragraph long work orders.

    I would probably keep what I have now, but I would like to be able to access all of my files on different computers so I don't have to run back and forth between computers. I've tried doing a simple Windows file share server to share what I have now, but it seems that the way I have everything coded it does not like local server file paths.

    Any suggestions/help would be appreciated

    Here's my github for what I have currently.

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

    Fast Pixel by Pixel Graphics in Golang

    Posted: 28 Sep 2018 03:15 PM PDT

    I need a library/method for fast/efficient real-time pixel-by-pixel graphics. Getting input is also necessary. I'm not looking for hardware accelerated drawing. Is drawing directly into the frame via openGl best?

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

    fortran gaussian elimination code unclear

    Posted: 28 Sep 2018 03:08 PM PDT

    Trying to understand this pseudocode of gaussian elimination with partial pivoting.

    Given pen and paper, this is easy for me to carry out; i am confused by the pseudocode, in the (1) Forward Elimination section, specifically the loop

    Do j = k+1,N (*) a(i,j)+=-m(i,k)*a(k,j) 

    Doesn't the fact that j begins at j=k+1 mean that, for example, the first column is missed (because j=k+1, but k starts at index 1, so j is 2,3,...,N -- but never is j=1, ie the first column isn't touched)? What if I had a matrix like

    2 6 3 0 4 5 (**) 1 2 7 

    It seems, this algorithm would miss the 1 at the (3,1) position! Whereas the (3,1) entry should be 0, not simply by setting it equal to zero, but rather by doing () on the last row, i.e. for (3,1) 1 - (1/2)2 = 0, (3,2) 2 - (1/2)6 = -1 (3,3) 7 - (1/2)3 = 5.5 It seems this algorithm completely misses that? Am i overlooking something?

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

    Data Structures in Python: Syntax/formatting errors, program that removes an item in a list and puts it at the end of a queue?

    Posted: 28 Sep 2018 02:40 PM PDT

    So this is my "completed" code for my homework assignment which was to modify a program to remove an item from a list and add it to the back of the queue.

    I went from Java to Python so I am still having trouble understanding and learning the proper syntax and formatting. I have an error on Line 41 where it keeps saying invalid syntax. What would be a better way to rewrite this? I will put a comment next to the exact line in the code. Also, I'm aware that I've used two else clauses but I still get a syntax error when I try elif or attempt a while loop haha.

    Also any formatting help would be deeply appreciated (is there a better way to write a loop, is there too much redundancy, etc), I'm trying my best!

    My Code:

    class Queue(): def __init__(self): self.items = [None] * 10 self.size_ = 0 self.front = 0 self.rear = -1 def size(self): return self.size_ def isEmpty(self): return self.size_ == 0 def peek(self): if self.isEmpty(): raise Empty('Queue is empty') return self.items[self.front] def enqueue(self,item): self.addRear(item) def dequeue(self): return self.removeFront() def addRear(self, item): if self.size_ == len(self.items): self.resize(2 * len(self.items)) avail = (self.rear + 1) % len(self.items) self.items[avail] = item self.rear = self.rear + 1 self.size_ += 1 def addFront(self,item): if self.size_ == len(self.items): self.resize(2*len(self.items)) avail = 0 if self.front == 0: if self.rear == -1: self.rear = 0 avail = 0 else: avail = len(self.items) - 1 else: ################# ########## Syntax error is here!! Should I rewrite the above as a while loop and then make this into an elif? avail = (self.front - 1) % len(self.items) self.items[avail] = item self.front = avail self.size_ += 1 def removeFront(self): if self.isEmpty(): raise Empty('Queue is empty') answer = self.items[self.front] self.items[self.front] = None self.front = (self.front + 1) % len(self.items) self.size_ -= 1 return answer def removeRear(self): if self.isEmpty(): raise Empty('Queue is empty') answer = self.items[self.rear] self.items[self.rear] = None if self.rear == 0: self.rear = len(self.items) - 1 else: self.rear = (self.rear - 1) % len(self.items) self.size_ -= 1 return answer def resize(self, cap): old = self.items self.items = [None] * cap walk = self.front for k in range(self.size_): self.items[k] = old[walk] walk = (1 + walk) % len(old) self.front = 0 self.rear = self.size_ - 1 q = Queue() q.isEmpty() q.addFront (100) print(q.size()) q.addFront (200) q.addFront (500.58) print(q.size()) print(q.peek()) # print the front item of the queue q.addRear(500) q.addRear(600) q.addFront(3.14) print(q.size()) print(q.peek()) # print the front item of the queue q.removeFront() print(q.size()) print(q.peek()) # print the front item of the queue q.addRear("True") q.addRear("False") print(q.size()) q.isEmpty() q.addRear(8.4) q.removeRear() print(q.size()) print(q.peek()) # print the front item of the queue q.addRear("C++") q.addRear("Python") q.addRear("Java") print(q.size()) q.addFront ("Go") q.addFront ("C") print(q.size()) print(q.dequeue()) q.removeFront() q.removeFront() print (q.size()) 

    Okay! If I'm not being specific enough, just let me know. I'm here to learn so anyone who is a master at Python please teach me the art of efficient Python code!

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

    Is not a function, even though it is...

    Posted: 28 Sep 2018 02:28 PM PDT

    Why do I get " Uncaught TypeError: controls.getObject is not a function" ?

    main file : https://pastebin.com/3AYkENAh (embed)

    the module of pointerlocks : https://pastebin.com/etgHdNpr (embed)

    I mean clearly getObject IS a function. Sorry if I'm being naive but I'm also a JS beginner too but this should have been straightforward.

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

    What is the best way to extract the following data from this site?

    Posted: 28 Sep 2018 06:37 AM PDT

    My university recently switched to this system: https://www.exlibrisgroup.com/products/campusm-mobile-campus-app-platform/

    Basically I previously could export my timetable to any calendar of my choosing, now I have to use this app exclusively in order to view my timetable, it is awkward and irritating method and I can't link it up to things like my amazon echo anymore this way. The front end looks like it is done in bootstrap however I have to login before I view the timetable, what would be the best way or code example or method or programming language or all of them in order to extract this calendar timetable data?

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

    [C++] Quick question about a boolean intialization

    Posted: 28 Sep 2018 01:06 PM PDT

    This is the first time seeing this in C++ and I want to know what this line means.

    bool IamZero = !((rank&bit) == bit); 

    'rank' and 'bit' are both integers. Is it saying that when 'rank' and 'bit' are equal to 'bit', 'IamZero' is 'false'?

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

    Literature about NLP and voice recognition software?

    Posted: 28 Sep 2018 10:41 AM PDT

    Hello there,

    next week I'll do an interview for an entry-level position in NLP and voice recognition software. I'm a translator, but I've never worked in that industry before, so I want to know as much as possible and prepare well before the interview.

    I'm reading atm all documentation and papers I can find, but I would be very happy if you guys could point me out to entry-level to intermediate NLP and voice recognition literature. Especially, on how it works on a theoretical and programming level.

    Thank you all.

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

    Looking up leaves in dictionary

    Posted: 28 Sep 2018 08:56 AM PDT

    I have a dictionary in python that loads from a json file and looks like the following:

    EDIT: Need to format, reddit is being tough with spaces/tabs:

    dictionary[A][1] = [a]

    dictionary[A][2][a] = [x]

    dictionary[A][2][a] = [y]

    dictionary[A][2] = [b]

    With each layer being another key in the dictionary. What I need to do is go through the dictionary and create something that flattens it out to look like this:

    A/1/x

    A/2/a/x

    A/2/a/y

    A/2/b ... and so on

    How can I look through the dictionary without multiple for loops, Is there someway to get to every leaf and have a history of each key you left behind so I can create that string?

    I am sure there are posts all over bout this but I had a hard time wording my question.

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

    Kotlin, How can I access this information?

    Posted: 28 Sep 2018 08:55 AM PDT

    Here is my code: https://pastebin.com/GVrHbATk

    I am trying to access the parameter: sectionNumber (line 207) in the placeholder fragment class. I am trying to get this number, so that I know what information (based on that sectionNumber index) to pass to the newly created fragment. Thanks all that can help

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

    Is it legal to use a third-party html player like bitmovin to play youtube videos on my site? And display ads on it?

    Posted: 28 Sep 2018 08:19 AM PDT

    I was reading the terms of services of Youtube and i found the following:

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    YouTube hereby grants you permission to access and use the Service as set forth in these Terms of Service, provided that:

    1. You agree not to distribute in any medium any part of the Service or the Content without YouTube's prior written authorization, unless YouTube makes available the means for such distribution through functionality offered by the Service (such as the Embeddable Player).
    2. You agree not to alter or modify any part of the Service.
    3. You agree not to access Content through any technology or means other than the video playback pages of the Service itself, the Embeddable Player, or other explicitly authorized means YouTube may designate.
    4. You agree not to use the Service for any of the following commercial uses unless you obtain YouTube's prior written approval:
    • the sale of access to the Service;
    • the sale of advertising, sponsorships, or promotions placed on or within the Service or Content; or
    • the sale of advertising, sponsorships, or promotions on any page of an ad-enabled blog or website containing Content delivered via the Service, unless other material not obtained from YouTube appears on the same page and is of sufficient value to be the basis for such sales.
    1. Prohibited commercial uses do not include:
    • uploading an original video to YouTube, or maintaining an original channel on YouTube, to promote your business or artistic enterprise;
    • showing YouTube videos through the Embeddable Player on an ad-enabled blog or website, subject to the advertising restrictions set forth above in Section 4.D; or
    • any use that YouTube expressly authorizes in writing.
    • (For more information about what constitutes a prohibited commercial use, see our FAQ.)
    1. If you use the Embeddable Player on your website, you may not modify, build upon, or block any portion or functionality of the Embeddable Player, including but not limited to links back to the YouTube website.

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    I was working on an update to put a player on my site that loads videos from youtube and then i was using javascript to extend some functionalities (and i was even thinking of displaying some ads on it to monetize some) but it seems like none its possible right?

    submitted by /u/Don-g9
    [link] [comments]

    Is Microsoft’s “Professional Certificate Program” worth the $300 investment?

    Posted: 27 Sep 2018 11:36 PM PDT

    I understand the courses are free, but I was wondering if there is any value in investing $300 to have certification that we completed the program. i.e. is it something we can put on a resume?

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

    How to make Chrome Dinosaur game?

    Posted: 28 Sep 2018 03:40 AM PDT

    I want to make a game that is similar to the game when you have no Internet. The dinosaur jumping over cactus but with a different character and obstacles. I want it to be an Android app. I have only basic knowledge of Java and the only app I made in Android Studio was a calculator type app. Are there any tutorials that I could use to make an android app game like this? I am also open to using Unity and assets but as this is my first time, I'm not sure where to begin.

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

    Best/recommended language to solve this problem?

    Posted: 28 Sep 2018 02:22 AM PDT

    I like fantasy football (soccer) and want to work out the highest possible score for a season and the players/trades required.

    Picking the highest scoring possible team each week would be simple enough to do manually, but I'm interested in finding out the optimal solution: (you get a free trade every week, further trades subtract 4 points from your score, unless you use a 'wildcard' of which you can use two in a season).

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

    Master's Thesis Programming Question

    Posted: 28 Sep 2018 01:07 AM PDT

    Hi guys, I'll try to keep this short. Basically I want to know if it would be possible to create a web crawler / scraper to fill out different answer combinations on this robo advisor site and then store their final portfolio recommendation in an excel file (as well as the answer combinations).

    If this is even possible, would Python be an appropriate language to use ? Is this extremely advanced or doable for a beginner programmer in a month or two?

    Here's the site. Simply click on "Depot eröffnen" at the top right to get to the "survey". Sorry it's in German but you'll get the idea of what I'm trying to do.

    Any help would be greatly appreciated! Thanks guys :)

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

    Value Error in python

    Posted: 27 Sep 2018 11:16 PM PDT

    Posted this on stackoverflow and already got a downvote for some reason... I would really appreciate if someone knew the answer to this one!

    I'm really unsure on what is going on with this, and was unsure how to explain. this is the code

    coords = tuple([float(i) for i in coords]) im = Image.open('tmp') im = im.crop(coords) im.save(filename) return filename 65 image = face_recognition.load_image_file(crop(coords, 'save.png'))`

    The error is as follows in this link : https://imgur.com/a/LbYB29Z

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

    No comments:

    Post a Comment