• Breaking News

    Friday, May 7, 2021

    What is your opinion on Rob Pike's 5 Rules of Programming? Ask Programming

    What is your opinion on Rob Pike's 5 Rules of Programming? Ask Programming


    What is your opinion on Rob Pike's 5 Rules of Programming?

    Posted: 07 May 2021 06:46 PM PDT

    https://users.ece.utexas.edu/~adnan/pike.html

    Rob Pike's 5 Rules of Programming

    Rule 1. You can't tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you've proven that's where the bottleneck is.

    Rule 2. Measure. Don't tune for speed until you've measured, and even then don't unless one part of the code overwhelms the rest.

    Rule 3. Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.)

    Rule 4. Fancy algorithms are buggier than simple ones, and they're much harder to implement. Use simple algorithms as well as simple data structures.

    Rule 5. Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming.

    Pike's rules 1 and 2 restate Tony Hoare's famous maxim "Premature optimization is the root of all evil." Ken Thompson rephrased Pike's rules 3 and 4 as "When in doubt, use brute force.". Rules 3 and 4 are instances of the design philosophy KISS. Rule 5 was previously stated by Fred Brooks in The Mythical Man-Month. Rule 5 is often shortened to "write stupid code that uses smart objects".

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

    Does anyone else find solace in having coding livestreams on in the background while working remotely?

    Posted: 07 May 2021 08:32 AM PDT

    I have found it really hard to work remotely completely (I am used to a mix). But something about being alone all day aside from slack and the occasional zoom meeting makes me feel a bit depressed or maybe just less in-touch. As much as I enjoy the WFH format and would prefer it to stay this way I feel like I have a subconscious void.

    Recently, I started following programmers of all walks of life on Twitch and have one on off to the side where I occasionally glimpse over to see them coding away and it gives me a good feeling like I'm not working alone.

    Sorry if this falls under off-topic, but I am curious if anyone else shares this feeling (especially during the pandemic where things can get a bit extra solitary) and if you've found some comfort in watching other developers work on live streams? I feel weird asking this as someone approaching his 40s but I can't imagine I'm alone.

    (I will delete if this isn't a suitable question for this sub).

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

    Does it make logical sense to merge projects of similar types into one major project?

    Posted: 07 May 2021 09:57 PM PDT

    I have many many small projects (think probably 250 or so) that do one specific thing and aren't really large. Maybe just a few hundred lines of code at most. They are all individual git projects and I have one main project that is my AI and manages everything from my daily life to solving CTF problems automagically etc...

    My main question is should I merge my smaller projects into my AI main project and be able to access them all via a hosted Amazon cloud instance for example or keep them all individual projects. I can think of many pros and cons to each situation so I'd like to see if anyone else has some compelling arguments or solutions of their own.

    I could also work with submodules I guess, but I haven't really found a really easy way to work through this. For example, my AI has several 'modes' that accomplish different tasks, think CTF, math-related, combinatoric explanations etc... And I also have many other 'modes' that I could add with other projects that I've created.

    Has anyone else worked through a project managment problem like this before?

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

    Is comprehension ability understated as a skill developed as a programmer

    Posted: 07 May 2021 11:16 AM PDT

    Everyone says that coding builds your logical thinking ability but I honestly was always pretty good at leetcode stuff. I swear the biggest hurdle I have had to overcome is my ability to read and understand documentation and speed read articles etc.

    What do you guys think?

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

    Controls/libraries to make WYSIWYG text editor?

    Posted: 06 May 2021 11:24 PM PDT

    I need to make a lightweight WYSIWYtG text editor for desktop with syntax highlight to a C-like language. I'm doing some research, if there are some free controls/libraries that would help do the job(so I don't need to reinvent the wheel and spent quite a time in something like RichText box control) , flexible enough to add support to a custom C-like language. What are some options? if you have used the library/control, please let me know your experience with it. I haven't decided the language yet it can be written in C, C++ or C#. I think C# might not be a good choice because it isn't as portable as I thought, WinForms and WPF doesn't seems good on Linux and Mac OS soon.

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

    Quick Question: I've linked a site that pulls betting odds from different sites, does it most likely scrape this data, retrieve it through APIs, or use another method?

    Posted: 07 May 2021 03:37 PM PDT

    https://www.bestfightodds.com/

    Hi, I'm still fresh but some things are finally starting to click. Other things though I still haven't come across yet in my studies (like APIs) so I'm hoping someone can point me in the right direction of what I should be googling.

    If it makes a difference, I'm trying to use Vue and AWS as my backend.

    Thanks

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

    Frustrating issue regarding copying and pasting formatted text from a web application into a text editor

    Posted: 07 May 2021 03:36 PM PDT

    I have created a web application which is essentially a "smart" template which does real time calculations with a user input and creates a nicely formatted report including tables which the user can then click a button to copy the formatted text. The problem I am having is that when the text is pasted into Microsoft word, the text is very nicely formatted exactly how it appears in the web application. However, when pasting directly into the separate text editor application we must use to submit our reports, the formatting is completely gone. I know this other text editor can handle the formatted text though because when you paste the text into word, then copy the text from word and paste it into the other text editor, the text is formatted perfectly.

    I have searched all over for a solution for a user to be able to copy text from the web application and paste directly into this separate text editor without having to use Microsoft word as an intermediary between the two applications. Is there a way to use javascript/html to simulate what happens when you copy text in Microsoft word?

    I am not an expert, so I am really struggling with this issue. I hope I provided enough information. Thanks for reading!

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

    Dumb question: maximum amount of keyword like static, private, sealed, override, abstract, virtual that can be used to declare a class, method, struct, field or interface

    Posted: 07 May 2021 05:44 AM PDT

    Title. I just want to know this for some reason. Language doesn't really matter but I would like to know this in as many as possible. Just for entertainment. I know, this is dumb and useless

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

    Best Monospaced fonts

    Posted: 07 May 2021 08:03 AM PDT

    Hello! Can you guys recommend me a nice monospaced font?

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

    Question about openpyxl

    Posted: 07 May 2021 01:42 PM PDT

    I have code that sometimes work but sometimes doesn't. The code is not relevant to the issue, the problem is between openpyxl and Excel itself.

    For some reason, when reading a worksheet with:

    Worksheet.iter_rows(values_only=True)

    Sometimes, the function returns the result of Excel formulas. Sometimes the function returns "None" instead of the result of the formula or the formula itself. I have disabled protected view in Excel but that doesn't seem to be the issue. Does anyone have experience with openpyxl? Have you encountered this issue before?

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

    Please help me! The sprint ends on Tuesday!

    Posted: 07 May 2021 12:51 PM PDT

    Jenkins or the user account that it's using to run selenium scripts on a windows vm is under some kind of proxy due to which I wasn't able to automate the desired website. I can't get the proxy removed as it is essential to other services. I asked the sysadmin to give me a functional account for the vm and disabled the proxy for that user. I used selenium rc to connect the script on Jenkins to the remote driver running on the vm using the functional account. I have automated the testing successfully. However, I want this jar to never stop running. This test script could be triggered by anyone at any moment and if the selenium rc stand-alone jar isn't working at that moment, then I'm gonna be in some trouble. I have tried solutions like using sc to create a new service and running the jar like a service on mu personal laptop so that I can replicate the same on the vm.(which doesn't work btw: something like the service wasn't able to start properly. Command: sc start "seleniumRC" binPath= "Java absolute path -jar Path\JarName.jar") and a task scheduler(don't have access. Can get access but worried it might create multiple instances of the jar). Most of the solutions point me towards a paid application (I cant install random software). What can I do to ensure that the jar doesn't gets killed when I log off or the server gets restarted?

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

    Help with C++ CUDA development environment

    Posted: 07 May 2021 12:39 PM PDT

    I am new to CUDA an recently i installed it on my windows pc.

    I have been running a small test with some memcpy's and they weren't working. I tried running cuda-memcheck tst.exe and oh surprise there were errors.

    This is one of the error i get (The rest are the same but with other functions like memcpy and launchkernel):

    Program hit cudaErrorUnsupportedPtxVersion (error 222) due to "the provided PTX was compiled with an unsupported toolchain." on CUDA API call to cudaMalloc. 

    My nvcc version:

    > nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2021 NVIDIA Corporation Built on Sun_Mar_21_19:24:09_Pacific_Daylight_Time_2021 Cuda compilation tools, release 11.3, V11.3.58 Build cuda_11.3.r11.3/compiler.29745058_0 

    Other command i found:

    > nvidia-smi Fri May 7 14:30:55 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 470.14 Driver Version: 470.14 CUDA Version: 11.3 | |-------------------------------+----------------------+----------------------+ | GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA GeForce ... WDDM | 00000000:01:00.0 On | N/A | | N/A 58C P3 24W / N/A | 1417MiB / 6144MiB | 33% Default | | | | N/A | +-------------------------------+----------------------+----------------------+ 

    Any help is greatly appreciated!

    Edit:

    Nvidia Forum Link: https://forums.developer.nvidia.com/t/the-provided-ptx-was-compiled-with-an-unsupported-toolchain-windows/177328?u=a01704320

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

    Making a 1:1 Website Clone of Business for Portfolio Legal?

    Posted: 07 May 2021 11:23 AM PDT

    As a CS grad looking to break into their first job, I've had an internship where I was given a Zeplin wireframe that I was able to implement into code just fine, but when it comes to solo projects that I design myself, the UI always comes out....rather lackluster. It's infinitely easier for me to just copy designs, and as of now, my current project is literally a Pizza Hut landing page clone made with React and Material UI.

    I'm almost done with some creative liberties sprinkled in here and there, but I'm totally stealing their logo, their ads, their images for their products, and etc. After all, I'm no UI designer or graphic designer who knows how to make logos and banners. Of course this website will never be used to make money and it's just to show off on my resume, but will companies that I'm applying to care that I stole assets or can I possibly get in trouble with Pizza Hut?

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

    Displaying a Table of strings in a window using GTK

    Posted: 07 May 2021 09:13 AM PDT

    I am trying to Display a Table just like this one in a scrolled window which i wrote a code that prints it into a file :

    https://ibb.co/b2SgnDQ

    I tried to do the same thing but instead write it in a textview widget , but the characters are not treated the same as in .txt file for instance "AAAAA" and "jjjjj" are both composed of 5 characters , in the .txt file they line up but in the textview the "AAAAA" takes more space which makes the whole table asymmetrical , is there a way to fix it ?

    Or maybe there's a better way of implementing it , when i searched for an answer i came upon the treeview widget but i really didn't find examples or clear documentation to follow ,i'd really appreciate an example of how to use it.

    And thanks <3.

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

    [Python] Why can I not understand Regex

    Posted: 07 May 2021 09:11 AM PDT

    Alright so I am trying to parse through WSJ and grab all the articles from the news tabs. Right now I can access the HTML, but using my regex to grab the links it grabs way more than I need and I cannot figure out how to stop the regex at the ". Here is what I have in my code to grab and print what I am supposed to be getting to check.

    import requests, re wsj = requests.get('https://www.wsj.com/?mod=nav_top_section').text links = re.findall(r'href="https://www.wsj.com/(articles/.+")"', wsj) print(links) 

    And here is some of what I get. I want everything until the " after error_page

    ['articles/millions-are-unemployed-why-cant-companies-find-workers-11620302440?mod=error_page"><img src="https://images.wsj.net/im-334715?width=300&amp;height=200" alt="Millions Are Unemployed. Why Can't Companies Find Workers?" title="Millions Are Unemployed. Why Can't Companies Find Workers?" height="auto" width="300px" class="WSJTheme--image--At42misj " srcSet="https://images.wsj.net/im-334715?width=300&amp;height=200, https://images.wsj.net/im-334715?width=300&amp;height=200&amp;pixel_ratio=1.5 1.5x, https://images.wsj.net/im-334715?width=300&amp;height=200&amp;pixel_ratio=2 2x, https://images.wsj.net/im-334715?width=300&amp;height=200&amp;pixel_ratio=3 3x"/></a></div><div class="WSJTheme--articleType--34Gt-vdG "><span class="">Economy</span></div><div class="WSJTheme--headline--7VCzo7Ay "><h2 class="WSJTheme--headline--unZqjb45 reset WSJTheme--heading-3--2z_phq5h typography--serif-display--ZXeuhS5E "><a class="" href="https://www.wsj.com/articles/millions-are-unemployed-why-cant-companies-find-workers-11620302440?mod=error_page">Millions Are Unemployed. Why Can't Companies Find Workers?</a></h2></div></article></div><div class="style--column--1p190TxH style--column-top--3Nm75EtS style--column-4--2Ng-GQLy "><article class="WSJTheme--story--XB4V2mLz WSJThem 
    submitted by /u/DrDuke22
    [link] [comments]

    Confused about how to go about this program [Python]

    Posted: 07 May 2021 07:50 AM PDT

    I'm taking a intro to programming class and this final homework question is confusing me. I'm trying to read in a file to a set and split each word from both text files into their own strings so I can compare them with set methods (intersection, symmetric, etc). However whenever I do line.split() it doesn't split the characters. I've looked all throughout my book and can't get a grasp on this. I just need to be pointed in the right direction as I've spent days coming back to this and not being able to solve it.

    def main(): file1 = open("firstFile.txt","r") file2 = open("secondFile.txt","r") set1 = set() set2 = set() for line in file1: for word in line.split(): line = str(line.lower()) line = line.replace('.','') set1.add(line) print(set1) for line in file2: for word in line.split(): line = str(line.lower()) line = line.replace(',','') line = line.replace('.','') set2.add(line) print(set2) return main() 
    submitted by /u/hollowzzzz
    [link] [comments]

    How to make a c shared library

    Posted: 07 May 2021 05:14 AM PDT

    I have recently gotten back into hobby programming and have downloaded the Unity unit testing library for c from Github. In future, I would like to use this library for all projects and don't want to keep copying it over / referring to it's path during compilation. What is the recommended method of doing this? I have attempted to create a .so file and store it in /usr/local/lib (which is a search directory for the linker) as detailed in this video but that hasn't really worked. The error I get when attemtping this is a simple "undefined reference to etc", so it can't find it. I also attempted copying the two .h files (unity.h and unity_internals.h) into /usr/include and changing the include statements from #include "unity.h" to #include <unity.h> and recompiling but that didn't help. Is there a way for me to store the library in my home directory somewhere as opposed to under root?

    Thank you

    submitted by /u/conor-smith
    [link] [comments]

    Please estimate the cost of this project

    Posted: 07 May 2021 04:54 AM PDT

    Hello!

    I might be interested in financing a game mod sometime in the future. The game in question is Diablo 2 Remastered and I would only like to change characters' faces. How much would it cost, how many people should be doing it, how long would it take...? I don't know anything about the process itself, so let me know if I have to add more info for a better cost estimate.

    Also, if there's a better place to ask something like this, let me know!

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

    Is it possible to add some comments to a URL that do nothing?

    Posted: 07 May 2021 12:20 AM PDT

    just like comments in programming

    but it can send some message

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

    Is it me or is this site being very pushy about variable definitions?

    Posted: 07 May 2021 05:39 AM PDT

    Individual score calculation c# - Is my approach right?

    Posted: 06 May 2021 11:36 PM PDT

    I am a beginner in c#. This is the problem statement. Is my approach to the problem right? . I am stuck at a few test cases.

    Bill, Tommy and Daisy are playing basket ball. Bill's father is capturing the score. Each player gets 2 chances. Prompt the user to input the player's name who scored the basket. If a player is not scoring in his/her chance, enter a space. Calculate each player's basket scored based on the given condition.Scoring Condition:Bill's father records the basket scorer's name. Each basket gives the player 1 point . If any player is scoring continuous basket , then they will get one bonus point.For example, if Bill baskets 1st and 2nd consecutively, he gets a bonus point (which means, he gets 3 points)

    Sample Input 1:

    Player Name : DaisyPlayer Name: DaisyPlayer Name : BillPlayer Name : BillPlayer Name : Tommy<space>

    Sample output :

    Bill Score : 3Tommy Score : 1Daisy Score : 3

    Sample Input 2:

    Player Name : TommyPlayer Name : BillPlayer Name : BillPlayer Name : Daisy<space>Player Name : Tommy

    Sample output :

    Bill Score : 3Tommy Score : 2Daisy Score : 1

    using System; using System.Collections.Generic; class HelloWorld { static void Main() { Console.WriteLine("Hello World"); int n=6; int daisy=0,bill=0,tom=0; int i=0; List<string> arr = new List<string>(); for(int g=0;g<n;i++) { Console.WriteLine("enter value"); arr.Add(Console.ReadLine()); } while(i<n) { if(arr[i]==arr[i+1]) { if(arr[i]=="Daisy") { daisy = 3; i=i+2; } else if(arr[i]=="Bill") { bill = 3; i=i+2; } else if(arr[i]=="Tom") { tom =3; i=i+2; } } else if(arr[i+1]==" ") { if(arr[i]=="Daisy") { daisy=1; i=i+2; } else if(arr[i]=="Bill") { bill=1; i=i+2; } else if(arr[i]=="Tom") { tom=1; i=i+2; } } else { if(arr[i]=="Tommy") { tom+=1; i=i+1; } else if(arr[i]=="Bill") { bill+=1; i=i+1; } else if(arr[i]=="Daisy") { daisy+=1; i=i+1; } } } Console.WriteLine(" Daisy : {0}",daisy); Console.WriteLine(" Bill : {0} ",bill); Console.WriteLine("Tommy : {0}",tom); } } 

    Is my approach to the problem right? How to solve it

    submitted by /u/Entire-Moment-5399
    [link] [comments]

    Help needed for a networking project

    Posted: 06 May 2021 11:00 PM PDT

    I needed some help in creating a networking project.I am building a chat application with a scalable architecture.I will be using node server as backend along with any nosql db and redis or any pub sub for synchronisation.I 'll be running on my personal linux machine, since its a mini project for getting a grasp of networking. My major problem is I wanted to create a state less load balancer , one that just forwards the port of client to one of the servers , making the architecture scalable .

    Making own ,simple , http load balancer is easy but I have read that to make load balancer support websocket , I need to implement it on L3 layer.I don't know teeny tiny bit about L3 or what is OSI layers.Load balancer kind of port forward the request while being stateless and non persistent in this case.

    Is it too tough to make barebones of this load balancer. If not , what topics should I start learning to get a grasp of networking and can make my own decisions while making such kind of applications.

    Any kind of help in the right direction or suggestions is much appreciated.

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

    No comments:

    Post a Comment