• Breaking News

    Thursday, August 27, 2020

    How come its either C or C++, how come C+ never caught on? Ask Programming

    How come its either C or C++, how come C+ never caught on? Ask Programming


    How come its either C or C++, how come C+ never caught on?

    Posted: 27 Aug 2020 03:43 PM PDT

    [Javascript] Best practice for return in the middle of promise chain?

    Posted: 27 Aug 2020 09:47 AM PDT

    I'm wondering what the best practice is in the following situation. I have a promise chain that ultimately returns some string based on the result of multiple async operations. But I'd like to be able to return the final string based on some logic in the middle of the process. What's the best way to do this? Something like

    return pool.query(checkUserQuery, [From]) .then((res) => { ... return asyncFunctionA(res); .then((res) => { ... return asyncFunctionB(res); .then((res) => { if (res === 'X') return 'Final Result X'; // I'd like to break out of the promise chain here somehow and return the whole function return asyncFunctionC(res); }) .then((res) => { return asyncFunctionD(res); }) .catch((err) => { throw err; }); 
    submitted by /u/xkrap
    [link] [comments]

    Live Python Output to Node.js Parent Process

    Posted: 27 Aug 2020 10:43 PM PDT

    Hi everyone,

    I'm trying to send the live output of a child Python process, launched in Node.js, to the parent process. I've tried piping the child's output, but receive errors (see below), or inheriting the child's stdio to parent. In either case, I send the terminal output with socket.io.

    I'm able to spawn a Python process successfully, and the Python's script output is sent live (have tried synchronous and asynchronous varieties) to Node's console. However, I'm unable to display this on a web page, unless I display nothing but raw text (res.send).

    The two examples below refer to the same python script launched and the same webpage hosted on a node server (using Express).

    Example 1:

    app.post('/webpageoutput', function(req,res) { var io = require('socket.io')(http); var child = require('child_process'); var events = require('events'); var eventEmitter = new events.EventEmitter(); eventEmitter.on('logging', function(message) { io.emit('log_message', message); }); io.on('connection', function(socket) { console.log('Continuing node activities while process spawns'); var python_process = child.spawn( 'python3', ['pythonscript.py'], {stdio: 'pipe'}); python_process.stdout.on('data', function (data) { process.stdout.write(data.toString()); }); python_process.stderr.on('data', function (data) { process.stdout.write(data.toString()); python_process.on('close', function (code) { console.log("Process finished " + code); }); }) }); // Emit console.log var existingconsoleLog = console.log; console.log = function(python_process) { eventEmitter.emit('logging', python_process); existingConsoleLog(python_process); }; res.render('webpageoutput'); }); 

    As expected, using "stdio: 'inherit", throws a "TypeError: Cannot read property 'on' of null" (for stdout) and using "stdio: 'pipe' " prevents the child Python process from starting at all. I've also tried both, as well as exec, execSync, and spawnSycn (although I require asynchronous launching of processes as both parent and child must run in parallel) but piping the child's output to the parent is as far as I've gotten.

    Example 2:

    io.on('connection', function(socket){ console.log('Continuing node activities while process spawns'); var python_process = child.spawn( 'python3', ['pythonscript.py'], {stdio: 'pipe'}); var chunk = ''; python_process.stdout.on('data', function(data) { chunk += data socket.emit('newdata', chunk); }); python_process.stderr.on('data', function (data) { console.log('Failed to start child process.'); }) }) // Emit console.log (same as above, console.log & render; skipped to save space) 

    The web page (client):

    <script src="/socket.io/socket.io.js"></script> <script> $(function () { var socket = io(); socket.on('log_message', function(msg){ $('#messages').append($('<li>').text(msg)); }); }); </script> 

    2 Questions (Only need 1 solution)

    1. Is there anyway to send new messages/terminal output using socket.io from the parent process using {stdio: 'inherit'}? I understand that STDOUT and STDERR can't be used with 'pipe', and I've launched python processes using 'inherit', but although its the parent process which receives the output I can't display this to the webpage.
    2. Why does "Example 1" fail to launch the process completely?
    submitted by /u/empathyman-1234
    [link] [comments]

    Anyone know of a corpus of number words?

    Posted: 27 Aug 2020 09:13 PM PDT

    I've been looking around for a corpus of just an absurd amount of written numbers. If I could find one that started at zero and just counted up that would be amazing. What I'd like it to contain are things like:

    zero

    one

    two

    three

    twenty-one

    two hundred

    four thousand

    one million five hundred and twenty six

    twenty eight billion five hundred million and thirty two

    etc.

    I don't know if anything like this exists, but thought I might find someone here who happens to know of a resource like this. I could generate one if needed, but I already have to do a lot of post-processing on it and it would be easier to have the resource to pull from to start with.

    Thanks in advance!

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

    I don't feel like I'm getting any experinece ever - is that normal?

    Posted: 26 Aug 2020 11:58 PM PDT

    I have a problem: have extremely bad memory. And sometimes I feel like I don't get any work experience whatsoever - in a way that I really quickly forget tasks that I finished. At least it feels like it. I have 4.5 years of android development and they consider making me a senior dev, but I myself not really sure if I'm good enough for it. Also I was trying to make a CV and, when filling work experience section, realized that I don't really remember what I actually did

    So, question is, is this normal, and this is just impostor syndrome, or I'm the only one like that?

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

    What do you think is the best place to get a python certificate?

    Posted: 27 Aug 2020 08:24 PM PDT

    In a couple of months one of my co workes will change projects and will leave a space as a python dev, I consider myself a decent python coder but they look for some one certified.

    I want to be certified by a reputable org in case I find a better offer, right now i'm just help Desk but I want to change to dev.

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

    I need help understanding what my programming logic options are when starting a new project.

    Posted: 27 Aug 2020 07:09 PM PDT

    I'm getting into web app development and I don't know if I should be building my sites/projects from scratch, if I should save the time and use themes, if there is an API or library I can implement that already has the front end taken care of. I just don't know what the options are, or which one I should be choosing when I do learn about them.

    Themes seem to be wonderfully easy to implement into a project and change to your liking. I can see why a lot of senior devs would see writing everything from scratch, but I also see the benefit of just being able to upload a theme as well. I mean, talk about D.R.Y. (Don't Repeat Yourself)

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

    Should I learn a language like Rust or a broad language like Javascript?

    Posted: 27 Aug 2020 03:21 PM PDT

    I have no programming experience, but I'm giving myself a target of 5 years to master at least one language. I'm very interested in cryptocurrency & that's pretty much what led me in this direction. I think Rust would be interesting to learn because it would allow me to build blockchains using Substrate, but I know it's more challenging and probably has less tutorials available on youtube. I feel like Javascript would be a better starting point, but it seems like it would group me in with every programmer in the world, while rust would be more unique & a niche language to know.

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

    const returning undefined

    Posted: 27 Aug 2020 06:18 PM PDT

    Hi, what im trying to do is

    const equipos = JSON.parse(fs.readFileSync("./data/equipos.json", "utf-8"))
    const lista = equipos.forEach( equipo => {nuevoEquipo(equipo)})
    When i do console.log(lista) it returns me undefined.
    How can i get those values? I'm trying to save them in a variable

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

    Finding out which PNRG was used?

    Posted: 27 Aug 2020 09:46 AM PDT

    I am not sure this is the right sub, sorry if it is way out of scope.

    If you had to find out what pseudo random.number generator algorithm was used in a program for which you only have the binary (Windows). How would you approach it? I know it was done in C++. It probably uses MT1997 but I want to validate that.

    My first idea was to disassemble the program but I don't think I have enough naming information there.

    Would something like bruteforcing seeds with a different program until the numbers are the same work?

    Sorry, I am a complete n00b in this topic.

    Thank you for any insights.

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

    Does anyone else hate IDEs that close brackets and quotes for you?

    Posted: 27 Aug 2020 09:13 AM PDT

    This is 100% a shit post but I just need to rant for a second.

    Spyder, Eclipse, and a other IDEs always have this feature where they close the brackets for you. It is the worst design feature I've ever seen. I've never had a moment where not having to close a bracket has actually benefitted me but I've had plenty of times where I need to go character by character through a line and fix one of these guys []""foo""[];

    Whoever you are that keeps putting this in environments, you're on my shit list.

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

    Tools to create a "Welcome to our new UI" experience?

    Posted: 27 Aug 2020 02:47 PM PDT

    We just redesigned our MFC application's UI and are eager to unleash it on the world. First, though, I'd like to create an experience that guides users through the changes. I'm looking for a library to help build this.

    It would feature a sequence of events, highlights to emphasize controls, a darkened overlay to de-emphasize all other controls, and of course text bubbles with pointer arrows. I've been unable to find any tools using Google. (Perhaps I'm not searching with the correct terms.)

    Or is a new UI experience walkthrough considered an anti-pattern?

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

    iOS Swift: Help with parsing JSON using decodable classes

    Posted: 27 Aug 2020 11:21 AM PDT

    Hello everyone I am having trouble implementing what I learned in a couple videos from "Lets Build That App" and "CodingWithChris" videos titled "Parsing JSON Just Became Super..." & "What is JSON - JSON Parsing in Swift".

    When running the code below the system prints out the catch error instead of StoreFeed.status ):

    let decoder = JSONDecoder() do { let storeFeed = try decoder.decode(StoreData.self, from: data) print(storeFeed.status) } catch { print("Error after decoder.decode") } } 

    Any help would be appreciated, I will provide my StoreData class code as well to show how I am trying to implement the decodable. Thanks!

    Code for viewDidLoad in my ViewController: I don't believe the error comes from my "data" variable received from the walgreensGoogleDetailsURL because when I print(dataAsString) I get the proper string containing the data in JSON format.

    override func viewDidLoad() { super.viewDidLoad() let walgreensGoogleDetailsURL = googlePlacesDetailsURL(apiKey: googleKey, place_ID: walgreensID) let task = URLSession.shared.dataTask(with: walgreensGoogleDetailsURL) { (data, response, error) in guard let data = data else { return } let dataAsString = String(data: data, encoding: .utf8)! print(dataAsString) let decoder = JSONDecoder() do { let storeFeed = try decoder.decode(StoreData.self, from: data) print(storeFeed.status) } catch { print("Error after decoder.decode") } } task.resume() } 

    Code for StoreData class:

    import Foundation struct StoreData : Decodable { let html_attributions : [String]? let result : [Store]? let status : String? } 

    Code for Store class: This class was used in my StoreData so that I could store information such as the website of the store

    import Foundation struct Store : Decodable { let formatted_address : String? let formatted_phone_number : String? // var geometry : [DispensaryLocation]? let name : String? // var opening_hours // var photos let rating : String? //var types = [String]? let website : String? } 

    Thanks for reading everything!

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

    Batch download web pages based on date and a word?

    Posted: 27 Aug 2020 09:15 AM PDT

    I want a piece of code that does a search on a website and downloads as HTML every page that contains my chosen set of words. It avoids pages containing words that I've set it to exclude and searches before or after a selected date. It also auto deletes duplicate pages.

    Then I can set it to automatically run whenever I choose and have it display the amount of new pages downloaded between now and the last download.

    Is this a difficult task?

    submitted by /u/8Dataman8
    [link] [comments]

    Reference problem

    Posted: 27 Aug 2020 08:58 AM PDT

    Im building my own website and just deployed an early design. Im running into a problem and i have no idea where the origin lies.

    The website workst just fine when referencing the subpages from the site itself using the <a href="/example"> tags in the menu, but the subpages give a 404 when directly calling domain.nl/example.

    I dont know if i did something wrong in de deployment or if im missing something in the .js framework(ember.js) im using.

    You can see it it action on thijsbekkers.nl. trough the menu the subpages home, activities and contact load just fine, but when calling thijsbekkers.nl/home directly is gives a 404.

    Where whould i be looking for the origin of this problem? Thanks in advance!

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

    Converting Decimals to fractions

    Posted: 27 Aug 2020 08:23 AM PDT

    Hi all,

    To preface this i have been coding for about a week....I am trying to create a real simple program to enter 2 numbers and have the program give both the decimal and fractional answer. i am having trouble getting the decimal converted to a fraction. My internet searches have all led me to use the gcd(int a, int b) function but I cannot get it to work. I keep getting the error cant find I am programming in c++ using microsoft visual studio 2017. Any help would be appreciated I have spent a couple long nights failing haha. Is there any other way to get the greatest common denominator?

    below is my code:

    #include<iostream>

    using namespace std;

    int main()

    {

    int a; int b; double ans;

    //Prompt user for numbers cout << "Dividing App lab 2c" << endl;

    cout << "Please enter numerator: ";

    cin >> a;

    cout << "Please enter denomenator: ";

    cin >> b;

    double answer = a / b; int integer = a / b; double decimal = answer - integer; int precision = 1000000; int c = integer * precision; int d = (a/b) * precision;

    int gcd(int c, int d); { if (d == 0)return c; else return gcd(d, c % d); }

    int numerator = c / gcd; int denomenator = d / gcd;

    cout << "Decimal: " << a << "/" << b << " = " << ans << endl;

    cout << "Fractional: " << a << "/" << b << " = " << numerator << "/" << denomenator << endl;

    }

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

    Trying to install Matplotlib using pip

    Posted: 27 Aug 2020 08:21 AM PDT

    I recently tried to run an old code from a few months ago and it came up saying that the module matplotlib was not found so I'm trying to install matplotlib via pip in the command prompt, but I always get a massive screen of red text and different errors each time with the one coming up the most often being -

    "ERROR: Command errored out with exit status 1: 'C:\Users\*username*\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' 'C:\Users\*username*\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\*username*\AppData\Local\Temp\tmphr9lj7vc' Check the logs for full command output."

    Does anyone know how to fix this?

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

    How do I port this python MPV script from linux to windows?

    Posted: 27 Aug 2020 07:51 AM PDT

    Hi,

    I have a script for the MPV video player but it's for linux and I want to use it on windows. I've tried going through it myself but I have very rudimentary python knowledge and 0 linux knowledge so I can't even tell what needs to be changed. Could anyone help me out? Here's the script:

    https://pastebin.com/W5YV1A9q

    The script automatically copies the audio of the video corresponding to the interval of subtitles which you select and also copies a screenshot from this interval to an anki flashcard you've made. Here it is in action, it'll probably be clearer what it does:

    https://streamable.com/8gni4l

    thanks

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

    Good Folder Name / Structure for Folder Meant Specifically for Potentially Buggy Files

    Posted: 27 Aug 2020 07:43 AM PDT

    Hi,

    I'm trying to come up with a good folder name to store my files that are my first try at using a new language, or a possibly buggy piece of code.

    I have my GitHub projects folder (which I actively keep under 25 projects) but I need another folder to run stuff like someone else's code from GitHub that might be buggy, or I'm testing the documentation of a new language / library.

    What's a good folder name / structure for a folder like that? (keeping in mind we have a GitHub folder)

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

    I'm a complete beginner in programming

    Posted: 27 Aug 2020 07:27 AM PDT

    Good day! To be honest im still quite lost on where should I start learning programming. Do yall have any good recommendation (videos, resources or website) on where can I learn them? Just any tips or advice? What programming language do you think I should start learning first?

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

    Number sequence step by step

    Posted: 27 Aug 2020 06:54 AM PDT

    Hello,

    I'm having a bit of a brain freeze.

    I have a huge list of numbers like so: 0,150,284,147,281,146,279,145,278,144,276,143,280,148,286,152,2,151,285,149,287,153,3,154,4,156,6,155,1,150,283,145,277,141,278,142,274,90,244,68,242,57,238,56,237,58,240,59,241,72,243,66,239,67,245,86,246,81,236,55,234,54,215,71,244,79,242,74,240,57,237,80,243,65,241,58,239,56,235,75,245,70,247,87,246,78,254,71,217,72,240,88,244,83,242,77,261,80,262,76,243,85,241,57,236,56,234,81,238,58,235,73,256,78,260,79,253,70,246,66,248,84,245,91,244,76,223,55,237,82,242,81,264,77,254,69,213,54,211,etc etc etc etc

    I want to be able to create a dictated step by step guide for every two numbers so for example

    step 1: 0 to 150

    step 2: 284 to 147

    step 3: 281 to 146

    etc

    If you're wondering what this is for, it's string art.

    Any help would be appreciated. Sorry I'm a noob and just want a nudge in the right direction.

    Thanks.

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

    How to automate the following website workflow which conists of selecting entry from drop down and clicking a few button?

    Posted: 27 Aug 2020 06:24 AM PDT

    Dear all,

    Not sure if this is the right forum for this question - if not please point me to the righ one. I work in the hospitality industry and we are uploading a lost of round 500 properties on a certain website. The process the following repetitive step? How can I automate this:

    1. Enter webiste with login
    2. Press a button
    3. Select an entry from a drop down
    4. Press a button
    5. Select an entry from a drop down
    6. press two more buttons
    7. Exit.

    As you can see this is a simple work but doing this for 500 properties is a pain. How can I automate this steps? Any product or tool that can help with this

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

    I am working with SQLite and Python and I want to query data from a SQLite table using the date from Python, how to do so?

    Posted: 27 Aug 2020 06:18 AM PDT

    I am using date as type date in the SQLite database. The input of type date from the SQLite table is set using python's

     datetime.date.today() 

    Now I want to query a data where the date is equal to a certain date in the db, how to do so? Can I simply use (assuming for the sake of example that the date is of today itself )

    ...WHERE date=:date, date = datetime.date.today()... 

    in python?

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

    How do I make myself into a bot?

    Posted: 26 Aug 2020 10:46 PM PDT

    I've got a really weird question...

    I've thought about this since 2005, when I was a teenager. Then my mom died early (when I was about 30) and I wish she left behind more of herself for my future kids.

    I started making a log from a chat bot template when I was in high school. I'd answer common questions, leave teasers... Just a lot of "if this" , "then this" , etc. I'd create paths based on who was asking, little things like that.

    It's been a long time since then. Where is technology now with this? What if I answered questions for an hour a day until I die? Could I leave something really neat when I'm gone? Can I do this with audio like Alexa?

    I used to program many years ago. Not anymore. Came here to get your input.

    Just wondering...

    submitted by /u/3rickEsca
    [link] [comments]

    No comments:

    Post a Comment