• Breaking News

    Wednesday, May 5, 2021

    How are tree structures stored (in databases)? Ask Programming

    How are tree structures stored (in databases)? Ask Programming


    How are tree structures stored (in databases)?

    Posted: 05 May 2021 10:12 AM PDT

    Reddit comments follow a tree structure - ie nodes with any number of children and no limit to how many levels exist.

    Do reddit servers store comments in databases? If so, how? Or if not, how are these things stored efficiently?

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

    In ruby, why does the digits method get the array in reverse order?

    Posted: 05 May 2021 04:15 PM PDT

    In ruby, digits method on an Integer returns the array in reverse order of the integer. It doesnt happen with the chars method for a String object, chars returns array in original order

    why is digits doing that

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

    How do I read a value from msr register in C++?

    Posted: 05 May 2021 10:17 PM PDT

    (I'm using Visual studio on windows 10 )I've been trying to read the value of the msr 0x150 registry on my intel chip using inline assembly language in c++ with no luck. I either get compile errors that I can't resolve, or get no output. I see code examples on GitHub such as winMSR read from this registry so I know it's possible, but even looking at their code I am lost. Could anyone recommend some resources for me to learn what's going on here? I'm not looking for a code solution, but I could really use some direction about what I need to learn to where this will make sense. My background is in C# and python, so working at such low level is new to me. I understand basic assembly memory registries, but the msr registries seem to be different. Any help is appreciated.

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

    Can I query a database for similar values?

    Posted: 05 May 2021 06:29 PM PDT

    I have an sqlite3 database containing trademark data. One column is the name that is trademarked(ex. Pepsi). Is there a way that I could query this database for it to return values where the column contains a similar value. Like querying for WePull and getting back WeBull. How would I go about solving this problem?

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

    What is the difference between library and package?

    Posted: 05 May 2021 03:59 PM PDT

    Both are set of predefined classes.So what's the difference?

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

    Is it ok to use code you don't understand?

    Posted: 05 May 2021 12:11 PM PDT

    I'm just starting to learn coding and google a bunch. How often do you guys use code others have come up with and it is ok if you don't totally understand all the details of the code as long as it does what you want?

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

    Is there a flow-chart on identifying file types and formats?

    Posted: 05 May 2021 10:18 AM PDT

    In an ideal world I'd never have to extract information from any file and even if I did it'd be so well documented that I'd be able to quickly and easily identify the tools I need to parse it. Unfortunately, that situation is more the exception than the rule, and I often find myself dealing with files that have data in them... somewhere and somehow. (Often proprietary programs and companies who don't want to be helpful)

    Is there some standard process you go through to figure out what the hell you're dealing with? I know a number of tricks, but I'm almost certainly missing most of them and I find myself struggling with this sorta thing way too often. I often start by trying to extract the file assuming its some compressed file type. I go on to start opening things in notepad++ sometimes with a hex editor. Usually those two tricks will sort me, but other times I have to go see if anyone as made something that opens the files on github. Also what actually is a binary file?

    I apologize if this is too vague. I really don't know how to be more specific. I'm just a novice python programmer.

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

    C++ Question

    Posted: 05 May 2021 05:30 PM PDT

    So I am using the queue STL in the C++ class.

    #include <queue> #include <string> #include <iostream> using namespace std; class A { }; class B: public A { } int main() { queue<A> q; B b; q.push(b); } 

    When I make the queue called "q" and then I make a var called b of type B would I be able to push it onto the queue without any problems even if the queue is of type A? Would it work if I used the inheritance I did above?

    Thank you.

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

    Does any course/certification exist that can actually get me a job within this field in a 1-2 year time period?

    Posted: 05 May 2021 05:15 PM PDT

    At the point I'm my life where I've decided to change my career to something I actually want to do. I've always wanted to get a job in some type of programming but have always figured it would take years to learn, and many more years to get any form of proof that I was competent in any form of programming. I see countless adds for courses that guarantee employment that we all know are BS so it makes it very difficult to find any that I know will be of value to me or an employer.

    Is there any certificate or course I can take in a 1-2 year time period that an employer might actually care about? If not, how would someone get into this field without a college degree in programming?

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

    Are there relational databases without enforced heuristics for algorithm choice?

    Posted: 05 May 2021 01:27 PM PDT

    I'm recently working mostly with Microsoft SQL Server, and one annoying thing is that it has a lot of heuristics to select algorithms used for queries. This is nice most of the time, as the programmer doesn't have to think whether to do a hash join or merge join, etc., but once in a while it hurts us a lot when the engine chooses the wrong algorithm and a query usually taking seconds starts taking hours. I know that PostgreSQL is another database software where these heuristics are unavoidable. And this is not just my observation.

    So now I am curious, is there any relational database software that support either explicit choice of algorithms or some kind of a predictable performance mode, one where performance of a query does not depend on some hidden database state like cardinality estimates or precomputed execution plans that sometimes need to be updated explicitly?

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

    Python I/O: is concatenating strings faster than writing multiple times?

    Posted: 05 May 2021 11:37 AM PDT

    I'm writing a script that has to write a lot of lines to text files. Is there any benefit to concatenating several strings so it writes one line at a time, or is a series of smaller write operations faster?

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

    C++ Delimiter & Reading Lines

    Posted: 05 May 2021 02:06 PM PDT

    Hi,

    I was trying to read the contents of a line into an array in C++. The text is formatted as: part1:part2:part3:part4

    When I try to read the line into an array using getline and stringstream ss, with a delimiter of :, it works as I want it to up until part 4, where it does not realise its the end of the line and it continues on to the next line and checks for the delimiter there. For example:

    nth line part 4 segment is merged with n+1 line's part 1 segment because it detects the delimiter on n+1 lines after part 1 instead of ending at part 4 on n line.

    Anyone know how to read a line with delimiters, and only have it read that one line of strings into an array?

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

    [Discussion] A class should have state or dependencies, but not both

    Posted: 05 May 2021 08:04 AM PDT

    This principle "feels" right, but I'm working through trying to formulate it properly.

    Consider a point class (in pseudo-code because lazy):

    class Point private x, y construct(x, y) draw(Drawable surface) 

    (Instead of surface, it could also be a save-function with a database connection as argument (or indeed any type of persistence)).

    If the surface was instead injected into the constructor, the point would look like:

    class Point private x, y, surface constructor(x, y, surface) 

    Isn't that weird, to have two properties related to state, and then a third property related to something completely different? Especially when it's something effectful, like drawing or writing to disk.

    On the other hand, you can imagine a command object class like this:

    class InstallApp private db, io, logger, mailer constructor(db, io, logger, mailer) execute(app) 

    In this case, all dependencies are effectful classes. Makes more sense, right? And then the app class has only "pure" properties, like User or Configuration.

    A rectangle depending on points is also OK, since the points are pure:

    class Rectangle private bottomLeft, topRight constructor(Point bottomLeft, Point topRight) // draw, save, etc 

    Another way to phrase it is that classes should only depend on other classes in the same layer (domain layer vs "effectful" layer).

    The major drawback is that no language can actually distinguish between a dependency and "normal" class property. Possibly they should have different semantics? Or the possibility to separate pure and effectful classes.

    Thoughts?

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

    simple question on 'or' operator

    Posted: 05 May 2021 12:31 PM PDT

    I'm trying to make some code that only prints the tester if the inputed number is 5, 8, or 10. Why does my code print the inputed number regardless of whether it equates to those numbers or not. Does the 'OR' operator not work in this instance?

    tester = input('chose a number') if tester == 5 or 8 or 10: 

    print(tester) else: end

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

    Can someone help me understand this code? (paper.js)

    Posted: 05 May 2021 12:13 PM PDT

    Hello

    i was looking for a code that demonstrates zooming functionality in paper.js library and i found this useful code snippet on code pen that has exactly what i needed, but i can't understand the code used very well, can someone please explain it to me? i will be very grateful!

    Code

    I'm trying to understand the mousewheel event handler function

    $('#myCanvas').on('mousewheel', function(event) { var newZoom = paper.view.zoom; var oldZoom = paper.view.zoom; if (event.deltaY > 0) { newZoom = paper.view.zoom * 1.05; } else { newZoom = paper.view.zoom * 0.95; } var beta = oldZoom / newZoom; var mousePosition = new paper.Point(event.offsetX, event.offsetY); //viewToProject: gives the coordinates in the Project space from the Screen Coordinates var viewPosition = paper.view.viewToProject(mousePosition); var mpos = viewPosition; var ctr = paper.view.center; var pc = mpos.subtract(ctr); var offset = mpos.subtract(pc.multiply(beta)).subtract(ctr); paper.view.zoom = newZoom; paper.view.center = paper.view.center.add(offset); event.preventDefault(); paper.view.draw(); }); }); 

    Thanks!

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

    Is controller and api good name for this function and module?

    Posted: 05 May 2021 10:40 AM PDT

    I have application and I made a command line interface file called run.py

    run.py uses command line arguments to receive commands.

    Things to name:

    1. Controller

    In run.py I have functions which I called controllers and they basically just take the command line arguments data object which is called args, unpack and calls the functions doing stuff. Like this:

    def import_sectors(args): test = args.test dev = args.dev api.import_sectors(test=test, dev=dev) 

    Is that what you call Controller?

    1. API

    In api.py I have all the actions, commands, use cases that I want this application to do. I am putting in this one file so it's all in one place and know what is available.

    Same command as above is:

    def import_sectors(test: bool, dev: bool): groups.import_sectors(test=test, dev=dev) 

    It's doing basically nothing new except just having these 'API points' in one place. Is API a good name for this or something else?

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

    Where to start in web development?

    Posted: 05 May 2021 10:08 AM PDT

    Hello, I'm a Software Engineer and have experience with application development, graph theory, AI, creation of compilers, etc. But I would like to expand my knowledge in web development.

    This field confuses me and I don't know where to start. I keep hearing about Angular, Node.js, ASP.NET, React, SOAP, REST, PHP, JavaScript, WordPress, etc. I also hear about web services using SprintBoot, Entreprise Java Beans etc. All of this seems like a lot and not all of these technologies seem to be widespread.

    I learned how to develop a website using ASP.NET and Entity Framework with Bootstrap's CSS styling for a small-scale project but from what I saw ASP.NET is quite different from other ways to implement a website and only a few companies use it.

    I would like to be a modern web developper, someone attractive to the market that can make functional, responsive with good UX websites.

    I know a lot of people recommend going back to basics with JavaScript, HTML, CSS etc. but I'm more of a practical learner and will do my research based upon what I need.

    Some directions would really help.

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

    How do you Software Engineers program stuff?

    Posted: 04 May 2021 10:41 PM PDT

    I'm looking into majoring in Software Engineer, but I cant imagine what programming looks like. From what I see, it's just commands or letters being put into place that somehow.... translate to what needs to be done.

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

    Struggling with some simple logic - can anybody help?

    Posted: 05 May 2021 09:50 AM PDT

    I essentially have two settable times for an automated power sequence in hours and need to make sure that the the off time is at least 8hrs or by extension, the on time is no longer than 16hrs.

    They're just two integers. Let's say that the start time is 8am and the end time is 8pm. That should be valid as it's 12hrs on and 12hrs off. The values would be coded at 8 and 20. In this case I could subtract the on time from the off time and verify that it's 16 or less. However that doesn't work for all cases. If the start time was 8 and the off time was 2 it would pass that check and then allow things to run for 18hrs straight, which is bad.

    Can anyone offer me some advice?

    Thank you!

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

    Make life easier?

    Posted: 05 May 2021 08:45 AM PDT

    Dear users of reddit,

    Have you all used selenium to make your life easier everyday? If yes could you share for what you used it?

    Like for example:

    I made a selenium program to automatically play a Spotify song by entering a text in command line. I made another program to keep records of my expenditure and upload it on the cloud.

    I made this because sometimes here the net becomes terribly slow. And it becomes a waste of time trying to keep entering the data and pressing login button or save records button.

    P.S.

    Am planning to automate WhatsApp, Telegram web too. Do you have any advise before I proceed with it ahead?

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

    How do you design an application, small or large?

    Posted: 05 May 2021 07:22 AM PDT

    3rd year CS student, full time software dev internship, and I teach myself and code every day after work.

    So far all my CS courses have been here's a file with the bare minimum classes and functions declared. Now code the classes and logic and to make it work.

    We very rarely build from scratch. So on my person projects I have 0 idea how to design my code.

    What kind of classes should I use, when to use inheritance or polymorphism. how should I define my tables in my DB, what frameworks do I need, how should I layout my website, etc.

    I feel extremely confident if I'm given already written code and tasked with either adding a feature to it or fix something. But I absolutely struggle when it comes to a fresh design. I don't really have access to an experienced programmer so I can see what they do.

    At my internship I work with estb code so it works great.

    Any points or books that help beginners with this?

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

    No comments:

    Post a Comment