• Breaking News

    Tuesday, January 15, 2019

    What are some common pieces of bad advice you read on Reddit? Ask Programming

    What are some common pieces of bad advice you read on Reddit? Ask Programming


    What are some common pieces of bad advice you read on Reddit?

    Posted: 15 Jan 2019 05:53 PM PST

    Odd pronunciations you've inherited or heard?

    Posted: 15 Jan 2019 11:38 AM PST

    I had a collaborator early on in my programming life who pronounced "fopen" as "faux-pen" and fwrite as "fright." Similarly scanf was pronounced as one syllable instead of "scan-eff." In general he did all the permutations as pronounced syllables. I inherited all these pronunciations and to this day I'll still say things like "sss-scanf" with a hiss or "fuh-dope-en" for fdopen, like I'm some sort of really lame Ryu who dropped out of street fighting to do develop financial services software.

    I'm curious what the other odd pronunciations are out there. Pandas vs pan-duss, etc.?

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

    Replacing HTML character codes from selenium scraping with the actual character

    Posted: 15 Jan 2019 06:48 PM PST

    I'm using Selenium (Chromedriver) with Python 2.7 to scrape a website for some dynamic text that shows up in <script> tags. Inside is HTML code nested in a JSON object, which is used to create a list of content on the page I'm viewing, but I'm only interested in getting the textual content. I was able to figure out how to clean out the HTML tags using re, but the text still contains HTML character codes for special characters, which I want to replace with the character they correspond to.

    So, for example, say my json (after cleaning out HTML tags) is as follows:

    [ { "data": { "published_on": "2019-01-15T08:46:00+00:00", "id": "somealphanumericid", "short_description": "Albert Einstein&#8217;s Theory of Relativity&#58; Should We Worry&#8230;&#63;", "series": "Science", "long_description": "Albert Einstein does an interview with Mr&#46; John Smith about the application of the theory of relativity&#44; and what it could mean for the future of the pizza industry&#33;", "duration": "752000", "type": "video", "title": "Albert Einstein&#8217;s Theory of Relativity&#58;" }, "links": { "permalink": "https://www.stackoverflow.com" }, "key": "somealphanumericid" }, ... ] 

    FYI: The JSON object is actually an array of JSON objects, hence the []. The site I'm scraping is paginated, so I obtain the JSON from each page and at the end just concatenate them into one array so it's easier to work with.

    You can see that characters such as periods, commas, colons, etc are scraped as their corresponding HTML character codes.

    Now, I'm iterating over the JSON and putting everything into an sqlite database, so it doesn't matter if I replace the character codes in the JSON itself, or if I do the replacement right before pushing the data into the db.

    The first thing I tried to do was to use a secondary function that took a string as the argument and returned the string with characters replaced. I basically modified the solution that can be found here. So this function was:

    from BeautifulSoup import BeautifulStoneSoup def HTMLEntitiesToUnicode(text): text = unicode(BeautifulStoneSoup(text, convertEntities=BeautifulStoneSoup.ALL_ENTITIES)) return text 

    I utilized this in a loop that creates the dataset for a row of data to be pushed to sqlite as such:

    def json_to_rows(json_file): with open(json_file, 'r') as infile: data = json.load(infile) data_as_rows = [] length = len(data) for i in range(0, length, 1): data_as_rows.append(( data[i]['key'], data[i]['data']['id'], data[i]['links']['permalink'], HTMLEntitiesToUnicode(data[i]['data']['series']), HTMLEntitiesToUnicode(data[i]['data']['title']), data[i]['data']['published_on'], data[i]['data']['type'], data[i]['data']['duration'], HTMLEntitiesToUnicode(data[i]['data']['short_description']), HTMLEntitiesToUnicode(data[i]['data']['long_description']), )) return data_as_rows 

    However, this resulted in the following error when parsing HTMLEntitiesToUnicode(data[i]['data']['series']):

    File "BeautifulSoup.py", line 1918, in _detectEncoding '^<\?.*encoding=[\'"](.*?)[\'"].*\?>').match(xml_data) TypeError: expected string or buffer 

    I can't figure out why BeautifulSoup isn't seeing this as a string, but I attempted to modify it to:

    HTMLEntitiesToUnicode(str(data[i]['data']['series'])) 

    Which then gave me the error:

    File "support.py", line 162, in json_to_rows HTMLEntitiesToUnicode(str(data[i]['data']['series'])), UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 129: ordinal not in range(128) 

    Adding .encode('utf-8') did not resolve the error either (this was recommended on various other posts with the same error message).

    My end goal is just to scrape all this info in to a db such that it's formatted as normal legible text (other than duration, which is of type INTEGER anyway).

    I'd like to do the replacing of the characters before/as data is being fed into the DB, but it's also possible that I can iterate through the DB in a separate function and clean it up, though that seems like a much less efficient way of doing it.

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

    How would I go about making a call flooder?

    Posted: 15 Jan 2019 09:40 PM PST

    I remembered the video {link below} of the guy who got mad at call scammers and created a call flooder to mess with them. An he never released an open source or public use copy. I want to learn how make one so everyone can fight back against these people. I am not very tech savvy, but willing to learn for this.

    https://www.youtube.com/watch?v=EzedMdx6QG4

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

    What text-editor do you prefer and why?

    Posted: 15 Jan 2019 09:07 PM PST

    I'll start - I use Atom because I love the debugging packages. What text-editor do you guys use and why?

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

    Do I have this right about dev libraries?

    Posted: 15 Jan 2019 08:39 PM PST

    I can only find explanations that I can't be sure if I understand or not, so here goes in my own words.

    Dev libraries are pre-made blocks of code that is used often but is time-consuming to write out and are in a file on your computer and in your IDE you can "call" these pre-made blocks of code from that file so you don't have to write it all out.

    Like if I want to make some code for a drone and make it so that when I move my button left it goes left and so on, I would get a dev library with blocks of code like that and then in my IDE i would say like " call on <direction.h>" or something?

    Am I close? Thanks!

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

    Question about com from powershell

    Posted: 15 Jan 2019 08:09 PM PST

    Hi all, using COM api in powershell to populate information via this method Is there any way to access open and existent workbooks via this method? Any help is appreciated...

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

    Boss keeps praising anything that says it has Artificial Intelligence

    Posted: 15 Jan 2019 07:01 PM PST

    As programmers, we all know what AI is, how it works, and what it does. However, my boss keeps on showing me random stuff (that definitely doesn't need AI) and saying, "Isn't this cool? And it even has AI!" and I'm like, trying to stop myself from explaining how it is just marketing strategy.

    Should I explain, or should I just ignore the AI part?

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

    Tracking github project quality metrics over time?

    Posted: 15 Jan 2019 06:15 PM PST

    For the next few months, my team is going to be helping another team uplift their Java projects from Java 1.6 to 1.8, and introduce Spring Boot. I'd like to a way to demonstrate the value of the work that we'll be doing for them, and the value that Spring Boot brings to their projects.

    • Are there any interesting metrics you think we should be tracking as we do this? (unit test coverage? total lines of code? some sort of "readability" metric?)
    • Are there any tools you think we should be using to track those metrics?

    Thanks for any input.

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

    How to break a loop in C# by pressing Ctrl Z (or Ctrl D)?

    Posted: 15 Jan 2019 12:00 PM PST

    In C++ this is done with EOF and in Java it's done with a scanner object, say sc, with !sc.hasNext(). What's the equivalent in C#?

    Also please tell me if this is a question relevant to this subreddit :/

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

    Do you take notes while programming?

    Posted: 15 Jan 2019 05:44 PM PST

    For my more complicated tasks, I try to take notes about what I've tried and learned, but I don't have a reliable system to keep the notes from becoming a useless mess. I've tried nvAlt, command line gtd files, paper, stickies, etc. Does anyone have a tool/system that works for them?

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

    Why does pinging 10.1 work as a shorthand for 10.0.0.1?

    Posted: 14 Jan 2019 11:17 PM PST

    This might be the wrong subreddit, but I never realized that this was something that worked... 10.255 translates to 10.0.0.255, and 10.256 translates to 10.0.1.0.

    10.1024 translates to 10.0.4.0.

    192.168.1279 translates to 192.168.4.255

    All of this makes sense, and I don't know why, but I find this so intriguing to discover after being active with internet/networking technologies for the last 24 years or so.

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

    How do I read The Algorithm Design Manual?

    Posted: 15 Jan 2019 05:52 AM PST

    Every time I open my html file, it opens up in chrome. I want it to open in TextEdit

    Posted: 15 Jan 2019 02:09 PM PST

    When I open my html file, even in TextEdit, it shows up as the version that shows in-browser. I want to edit my code but I don't know how to get it back.

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

    C# Record Date and Text recall if current date

    Posted: 15 Jan 2019 01:43 PM PST

    Hello all,

    I don't know anything about programming and wanted to see if someone could help me out. After a bit of googling I am having a hard time finding what I am looking for. Is it possible to code something that does the following and if so, could you help me code it?

    User inputs a date and a note. (Ex: 1/21/19: I'll be late)

    Another user calls !Attendance which looks at the current date and reports the any "notes" that are set for that date (and the user who set it)

    Thanks for any thoughts, direction, or help.

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

    How to find the right tool for the job?

    Posted: 15 Jan 2019 01:06 PM PST

    I have a lot of little hobby project ideas I want to poke at and (being a curious language hopper) I would like to try something well suited to the task instead of falling back to the languages I'm more experienced in. My question is somewhat geared at generality, ie is there a tool or list for finding recommended languages/frameworks/libraries for a particular purpose, but I'll also suggest a few particular projects I had in mind if anyone has insight on them. I'm awful at search engines so if the answer is google, I'd appreciate good terms to include.

    • Simple cross-plat application GUIs
    • Weather simulation
    • Audio analysis/manipulation
    submitted by /u/xensky
    [link] [comments]

    How can I create a camera that can zoom in, out, and move in a 2d game?

    Posted: 15 Jan 2019 12:31 PM PST

    i have no clue self taught lad, using a calculator with a sort of basic-like thing theoretically how could i do this

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

    Not very young programmers who haven't made a career how do you keep going?

    Posted: 15 Jan 2019 08:38 AM PST

    Hi.

    I was just wondering people who had worked more than 10 years and didn't become a project lead or some sort of expert in the team or not working at something particularly interesting - how do you continue going? What makes you do what you do beside the paycheck?

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

    Recommendation: Reliable Remote-in software?

    Posted: 15 Jan 2019 09:57 AM PST

    Thank you.

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

    Why Nevercode?

    Posted: 15 Jan 2019 08:40 AM PST

    Hi Everyone!

    I am beginner programmer almost ready to release first mobile app. I am question: why use service like Nevercode? I have read devs say it speed up development and make dev easier.

    Why? Should I use?

    Thanks!

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

    How would you build a secure cluster of info screen servers?

    Posted: 15 Jan 2019 08:40 AM PST

    Hello everyone.

    I am thinking of creating a small cluster of 3-6 Raspberry Pis (or do you have a better suggestion?) each connected to a monitor, to work as some public display screens at my work place.

    However, I find some interesting challenges, and I have trouble Googling for inspiration, as I am not sure what this type of system is actually called. PSA-systems? Public Display systems? ¯\_(ツ)_/¯.

    Some challenges I am interested in inspiration for:

    1) How do I remotely keep all Rasbian OS's on the machines up to date, without manually going to each of them to do updates?

    2) Same question, but related to the software I have made on each machine

    3) Security? How do I auth against my server? Give each of them a unique key for HTTP auth and store it locally on the SD-card?

    Thanks for your time.

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

    How do I set boundaries for a graph like this?

    Posted: 15 Jan 2019 08:03 AM PST

    Graph

    The graph has four potential choices. "No Vanes", "One Vane", "Two Vanes", "Three Vanes".

    I'm using my X value and Y value to determine which range it would fall into. E.G. 0.3 x 4 falls into "One Vane". So I then proceed. However, I'm having issues setting up my boundaries and taking this graph and turning into something I can reference in a script.

    Using C# .net

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

    C#/RabbitMQ - wait for consumer events to complete

    Posted: 15 Jan 2019 06:40 AM PST

    I have an IHostedService that listens for RabbitMQ messages to do micro-service work. When the app shuts down (IHostService.StopAsync called), I want to give all the consuming channels the chance to complete whatever events they are processing. What's the proper way to do this?

    Asking because neither IModel.BasicCancel or IModel.Close are blocked while an IEventingConsumer is handling a message (or vice-versa).

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

    What are some cool, yet impractical ways to encode text?

    Posted: 15 Jan 2019 05:32 AM PST

    I intend to make a digital scavenger hunt. I want to make one of the steps challenging by adding text that needs to be decided from a format that won't be familiar to most people. Some examples would be the ZX spectrum data from Bandersnatch or this binary square the game Doki Doki literature club.

    What are some other creative and frivolous ways people have encoded data in the past?

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

    Need help on design principles (methods)

    Posted: 15 Jan 2019 04:03 AM PST

    Hey,

    for example I have a method which looks like this (it's just an example, which returns the amount of divisions needed):

    class Calc { static getDivisionCountByTwo(num) { let quotient = num; let iterations = 0; do { quotient = Math.trunc(quotient / 2); iterations ++; } while (quotient !== 0); return iterations; } } 

    So far I only used it to get the division count, e.g.:

    console.log(Calc.getDivisionCountByTwo(4)); // returns 3 console.log(Calc.getDivisionCountByTwo(6)); // returns 3 console.log(Calc.getDivisionCountByTwo(8)); // returns 4 

    So far so good. Now I would like to return each quotient as an array. How would I do this, assuming I would like the method to do what its name says? I could return an object, which would hold all the information I need, but it wouldn't be something you would expect to get returned from a method named getDivisionCountByTwo

    Or, to keep it more abstarct: I have a working method where I would like to access 'internal' data. How could I do this, without modifying the method? How would you approach this and why?

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

    No comments:

    Post a Comment