• Breaking News

    Saturday, March 21, 2020

    Theoretically, could you change a file extension to something arbitrary? For example, could I change ".txt" to ".arbitrary", and, after making the appropriate associations at the OS level and within applications, ".arbitrary" could be treated like a ".txt." file? Ask Programming

    Theoretically, could you change a file extension to something arbitrary? For example, could I change ".txt" to ".arbitrary", and, after making the appropriate associations at the OS level and within applications, ".arbitrary" could be treated like a ".txt." file? Ask Programming


    Theoretically, could you change a file extension to something arbitrary? For example, could I change ".txt" to ".arbitrary", and, after making the appropriate associations at the OS level and within applications, ".arbitrary" could be treated like a ".txt." file?

    Posted: 21 Mar 2020 11:12 AM PDT

    What programming language?

    Posted: 21 Mar 2020 10:13 PM PDT

    Basically, I'm stuck with what direction I want to head in with software development, and it's because I don't know what programming language to choose.

    Should I go with C, a nice and tried procedural language? Or something similar like Go? Should I go with C++ or Java, nice and tried object oriented languages? Or something similar like Rust?

    Or should I, which I want to do because I'm fond of making my own things, create my own programming language? If so, how should I design it?

    The options are endless, and I can't decide. Could you guys please help me? I don't even care if the answers are subjective, I just need some type of direction to go in.

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

    Code that can classify data according to topic and copy data to categorised database files and compare data to reduce redundancy and basically use data in a ml algorithm in solving various problems

    Posted: 21 Mar 2020 10:07 PM PDT

    The ml algo should be able to interpret natural problems and provide various solutions

    Also If you can point me to a book or a YouTube channel or a course I'd really appreciate it

    Also how do you create an algo that can distinguish commands with natural language input

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

    Read testcase and list of numbers from a file in C

    Posted: 21 Mar 2020 09:45 PM PDT

    I'm new in C language and I'm really confused on how to read test cases and list of numbers from a file.

    Sample input from a file:

    2

    6 1.0 2.0 3.0 4.0 5.0 6.0

    3 -2.0 4.0 44.0

    On which 2 is the number of test case, in the new line the size and the list of numbers. Thank you for the help.

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

    Why pointers?

    Posted: 21 Mar 2020 09:01 PM PDT

    I have been getting into learning C++. I am not a beginner to programming, but I am only around intermediate, at best.

    I have followed many tutorials and videos on how to use pointers and references, and have a pretty good grasp on them. However, none of the videos or tutorials seems to teach when or why they are used or why they are useful.

    I've done a lot of searching, but I cannot seem to find a reason why they are such a great thing. I believe they are, but just want to understand the 'why' of it!

    So, as my title says: Why pointers?

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

    [Java] Sorry, this is a hard question to ask, but... If I have a Queue<location>, where location is a class containing the variables - location parent and int row, how would I print out the row for each parent? More detailed explaination inside:

    Posted: 21 Mar 2020 08:42 PM PDT

    I can't add all my code right now, but I will add what I can so this makes sense.

    Alright, so the Queue is declared like this:

    Queue<location> q = new LinkedList(); //location is a class. here is a stub: location { int row; int col; int dist; location parent; LocType type; //LocType is an enum {start, open, wall, target } } 

    Sorry if this is confusing. What comes next even more so.

    Near the end of my code, the contents of q looks like this:

    q[0] { row = 0; col = 1; dist = 3; type = target parent { row = 1; col = 3; dist = 2; type = open; parent { row = 2; row = 2; dist = 1; type = open; parent { row = 3; col = 4; dist = 0; type = start 

    If that makes sense, how would I print the rows and cols of each level?

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

    What is your favorite abstraction system of any language? What do you hate?

    Posted: 21 Mar 2020 07:53 PM PDT

    Maybe you're a diehard OOP Java guy. Or maybe you're a snooty, academic Haskeller.

    Some people are composers, others are inheriters.

    Do you get a bad taste in your mouth every time you use a generic? Or do you start to develop a rash unless your code is entirely template-generated?

    Folks from the frontend realm religiously opine the wonders of the component model. But maybe you're in systems and the mere thought of aggregating your state in one place butters your bread, grinds your gears, and shimmies your shingles.

    Wherever your preferences lie on the polymorphic spectrum, I want to know what YOU are into! What language scratched that abstraction itch for you the best? (Do Lisp's macros turn you on? Are Rust's traits one of your kinks?) What language had the least ergonomic polymorphism for your needs? (Does Go's lack of generics make your stomach turn over? Do Elixir's protocols give you a migrane?)

    What did you like/dislike and why did you like/dislike it? What was *your particular* use case and why did it work/not work?

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

    JavaFX .setScene() is crashing my program. Could I get some help?

    Posted: 21 Mar 2020 07:39 PM PDT

    Hello all, I'm pretty new to java and am stuck trying using the setScene method to switch between scenes in javaFX. Every guide I've read says it should work but I must be missing something. I've been at it for five hours now but just cant see where I'm going wrong?

    This two scene app has a home and a form, I'm simply trying to navigate between the two scenes.

    I am trying to start with homeScene in the stage and then switch to formScene when button1 is clicked, however it just crashes whenever I click the button.

    I've tried declaring the button in different ways, I've tried starting with formScene and switching to homeScene, I've tried having them as separate methods and many other things but always it crashes when I try to set a new scene using .setScene()

    Woule anyone so kind to help me out and have a look as I'm at a dead end :/

    paste.ofcode.org/D7TuWpxkFRuTNXug7cbwpF

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

    Anyknow know the name of the editor on the BBC Micro?

    Posted: 21 Mar 2020 10:47 AM PDT

    The first machine I ever used was a BBC Micro at school. I remember the text editor had a blue screen, with white text and a blocky console font. Does anybody know what this editor was called?

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

    Web Dev: scrollLeft not going all the way to the right of div in jQuery

    Posted: 21 Mar 2020 01:26 PM PDT

    function mirror(){

    $('.LeftMirrorDiv').scrollLeft($('.InsideMirror').innerWidth());

    console.log($(".LeftMirrorDiv").scrollLeft());

    }

    Even though the div width is 2500, it's only going 2334 pixels to the right. Any parameter over 2334 still results in 2334 even though I want it to go all the way to 2500.

    Any help is appreciated! Thanks in advance.

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

    Sending a whatsapp message with javascript

    Posted: 21 Mar 2020 07:27 AM PDT

    Hi, I know that there is an api for that. But my motivation is solely learning, so I'm trying to do everything through the browser's console.

    Injecting this code to the console when you are inside whatsapp web chat types 'Hello'

    var text = document.getElementsByClassName('_3u328 copyable-text selectable-text')[1];text.innerHTML = "Hello";

    The problem is that the send button does not exist unless you type something, and although we have changed the value to 'Hello' and it indeed says that in the chat, the application does not recognize that there is a value in the input field. And therefore the click() function does not work.

    but if we manually add a character after the "Hello" for example pressing the letter "A" and and therefore changing it to "HelloA", the button now appears and I am able to click it:

    var send = document.getElementsByClassName('_3M-N-')[0];

    send.click();

    So, what I really need help with is letting the program know that I have inserted something as an input. I have even tried artificially adding the button, but the button could be pressed:

    var button = "<button class='\_3M-N-' >" + "<span data-icon='send' class>" +"<svg xmlns='[http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'>" +](http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'>" +)"<path fill='currentColor' d='M1.101 21.757L23.8 12.028 1.101 2.3l.011 7.912 13.623 1.816-13.623 1.817-.011 7.912z'>" +"</path>" +"</svg>" +"</span>" + "</button>";

    Would love to get your help

    Edit: if anyone comes across this thread from google/reddit, here is the solution :

    //gets the input fieldconst inputField = document.getElementsByClassName('_3u328 copyable-text selectable-text')[1];// declares input functionconst inputEvent = new Event('input', {bubbles: true }); //types the textinputField.textContent = 'Hello world';// calls the input function in the test fieldinputField.dispatchEvent(inputEvent);//clicks the buttondocument.getElementsByClassName('_3M-N-')[0].click();

    //After using the code once, you can spam this message again and againinputField.textContent = 'Hello world';inputField.dispatchEvent(inputEvent);document.getElementsByClassName('_3M-N-')[0].click();

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

    Linker Error 2019 C++

    Posted: 21 Mar 2020 04:46 PM PDT

    Hello all, im currently working through a sorting project in C++ and keep getting this linker error, if anyone could help I would greatly appreciate it.(I believe to have my linker settings correct)

    edit: the exact error is

    LNK2019 unresolved external symbol _main referenced in function"int_cdecl invoke_main(void)" (?invoke_main@@YAHXZ)

    Here is my source code:

    #include <stdio.h>

    #include<stdlib.h>

    #include<time.h>

    #include<omp.h>

    using namespace std;

    #define _CRT_SECURE_NO_WARNINGS

    class Sorting {

    private:

    [//1.0](//1.0) Initialization //Global Variables int\* myAry = new int; int\* copyAry = new int; int size = sizeof(myAry); double startTime, endTime = 0.0; int i = 0; int temp = 0; int phase = 0; int sorted = 0; double shrink = 1.3; int gap = size; 

    //copy constructor void copy(const Sorting& original) { size = original.size; for (i = 0; i < size; i++) myAry\[i\] = original.myAry\[i\]; } 

    public:

    void bubbleSort() { for (i = 0; i < size; i++) { copyAry\[i\] = myAry\[i\]; } int i = 0; int temp = 0; //temp value to hold elements when swapped int n = sizeof(myAry); //get variable to hold size of array startTime = omp\_get\_wtime(); //start the clock for (i = 0; i < n - 1; i++) if (myAry\[i - 1\] > myAry\[i\]) 

    myAry[i - 1] = myAry[i]; //sorts array

     temp = i; endTime = omp\_get\_wtime(); n = temp; [//2.1](//2.1) Output BubbleSort Results printf("\\nBubbleSort Timing Results: %3e\\n\\n", endTime - startTime); //print results } void OddEvenSort() { free(myAry); for (i = 0; i < size; i++) { copyAry\[i\] = myAry\[i\]; } int n = size; startTime = omp\_get\_wtime(); //start the clock for (phase = 0; phase < n; phase++) { if (phase % 2 == 0) //checks even phases 

    for (int i = 1; i < n; i += 2)

    if (myAry[i - 1] > myAry[i]) {

    temp = myAry[i + 1];

    myAry[i - 1] = myAry[i];//sorts array while holding

    myAry[i] = temp; //swapped ints in temp

    }

    else {

    for (i = 1; i < n - 1; i += 2) { //non-even phases

    if (myAry[i] > myAry[i + 1]) {

    temp = myAry[i + 1];

    myAry[i + 1] = myAry[i]; //sorts array

    myAry[i] = temp;

    }

    }

    }

     } endTime = omp\_get\_wtime();//stop the clock [//3.1](//3.1) Output Odd Even Results printf("Odd/Even Sort Timing Results: %3e\\n\\n", endTime - startTime);//print results } void sCombSort() { 

     free(myAry); for (i = 0; i < size; i++) { copyAry\[i\] = myAry\[i\]; } startTime = omp\_get\_wtime(); while (sorted == 0) { gap = gap / shrink; if (gap <= 1) 

    gap = 1;

     sorted = 1; i = 0; while (i + gap < size) { 

    if (myAry[i] > myAry[i + gap])

    myAry[i + 1] = temp;

    myAry[i] = myAry[i + 1];

    temp = myAry[i];

    sorted = 0;

    i += 1;

     } 

     } endTime - omp\_get\_wtime(); printf("Serial Comb Sort Timing Results: %3e\\n\\n", endTime - startTime);//print results } int main(void) { printf(">>> Normal Termination <<<"); free(myAry); return 0; } 

    };

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

    What is the URL Scheme for opening android webview ?

    Posted: 21 Mar 2020 03:25 PM PDT

    Learn to Hack Website

    Posted: 21 Mar 2020 02:34 PM PDT

    So one or two years ago, I found a website where you could learn to defend your webpage by learning how hackers hack. And now I can't find it. It gave you theory of how one specific hacking trick worked(for example SQL injection) and then it let you practice it. Does anyone know name of this website?

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

    How binding is implemented in frameworks ? (UI to database)

    Posted: 21 Mar 2020 06:36 AM PDT

    Why does this function work only with 1 digit integers?

    Posted: 21 Mar 2020 04:10 AM PDT

    Basically, I am trying to write this function to merge 2 arrays and it works only if they contains 1 digit integer.

    int* merge(size_t n, int Cw[3], int Dw[3]){

    int C[] = {4,5,12};

    int D[] = {1,3,8};

    int *B = malloc(sizeof(int) * n);

    int i=0, j=0;

    for (int k=0; k<n; k++) {

    if (C[i] < D[j]) {

    *B = C[i];

    printf(" C = %d , %d\n",C[i],i);

    i++;

    }else{

    *B = D[j];

    printf(" D = %d , %d\n",D[j],j);

    j++;

    }

    printf("%d\n",*B);

    B++;

    }

    return B;

    }

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

    Need Help... C++20

    Posted: 21 Mar 2020 11:39 AM PDT

    I want to know what are the features in C++20 that help me to create an Matrix class (addition operation)... Help me if you please.

    So...

    how i can write in C++20 "Matrix m = a + b;"

    where a and b are matrices two with the most modern C++20 features.

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

    Get data from api using PHP

    Posted: 21 Mar 2020 11:29 AM PDT

    Asked this already on another thread yesterday, no answers(sigh).

    I have a task of getting data from an api using PHP.

    It uses **POST** request, which also sends json body.

    There is not mentioning of setting any headers, which confused me. I dealt with api's using ajax before, never php. And since json goes both ways, to api and as a response from api, i'm a bit confused.

    I tried doing it vanilla php way, but on various posts on SO, it is said it's not recommendable.

    Many have said that using **cURL** is correct way of doing it, so i'm guessing, it's the correct way without involving third party libraries which i(also) cannot use in this case.

    My code so far:

    Json body:

    ```

    $str = '{"username":"[mymail@mymail.com](mailto:mymail@mymail.com)","password":"blah"}';

    //or

    $arr = [

    "username" => ["mymail@mymail.com](mailto:%22mymail@mymail.com)",

    "password" => "blah"

    ];

    ```

    function post1($url,$data){

    $ch = curl_init();

    //Example1

    curl_setopt($ch, CURLOPT_HEADER, false);

    $query = http_build_query($data);

    //curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type" => "application/json"]);

    //Alt header for Example2

    //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));

    $query = $data;

    curl_setopt($ch,CURLOPT_URL, $url);

    curl_setopt($ch,CURLOPT_POST, true);

    curl_setopt($ch,CURLOPT_POSTFIELDS, $query);

    curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($ch);

    curl_close($ch);

    return $response;

    }

    //Example1

    //echo post1($url1,$str);

    //VS

    //Example2

    echo post1($url1,$arr);

    Both json and non-json example produce the same error:

    ```

    {"type":"https://tools.ietf.org/html/rfc7231#section-6.5.13","title":"Unsupported Media Type","status":415,"traceId":"80002328-0002-ff00-b63f-84710c7967bb"}

    ```

    If i use alternative header for example2, it produces different one:

    ```

    {"errors":{"":["Input string '--------------------------7abe186689ac2978' is not a valid number. Path '', line 1, position 42."]},"title":"One or more validation errors occurred.","status":400,"traceId":"8000232a-0002-ff00-b63f-84710c7967bb"}

    ```

    In api document that i have, there is no mention of setting any headers, nonetheless, i tried even setting headers up. Both ways didn't work. Just throws an error. So either i'm missing something in cURL, or they sent me incomplete documentation. Either way, i'm not sure since i never used cURL, nor i ever used this api.

    I also tried it in Postman, with headers and without, i even tried setting json body with quotation marks(it's silly, i know) just to eliminate whatever possibilities.

    None of it worked.

    Mucho kudos in advance to any good people who can present me with solution based on previously stated or at least pointed me in the right direction.

    Addendum:

    ```

    function post2($url,$data){

    $headers = array(

    "Accept-Encoding: gzip",

    "Content-Type: application/json"

    );

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_HEADER, 0);

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    //$query = $data;

    $query = http_build_query($data);

    curl_setopt($ch,CURLOPT_POST, true);

    curl_setopt($ch,CURLOPT_POSTFIELDS, $query);

    curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($ch);

    curl_close($ch);

    return $response;

    }

    ```

    I tried 4 variations of it.

    1. Data as an array and `$query = $data;`.

    Error:

    ```

    {"errors":{"":["Input string '--------------------------ae9f656894b99247' is not a valid number. Path '', line 1, position 42."]},"title":"One or more validation errors occurred.","status":400,"traceId":"80002dd0-0002-fe00-b63f-84710c7967bb"}

    ```

    1. Data as string and `$query = $data;`.

    Error:

    ```

    Internal server error

    ```

    1. Data as an array and `$query = http_build_query($data);`.

    Error:

    ```

    {"errors":{"":["Unexpected character encountered while parsing value: k. Path '', line 0, position 0."]},"title":"One or more validation errors occurred.","status":400,"traceId":"80002dd2-0002-fe00-b63f-84710c7967bb"}

    ```

    1. Data as string and `$query = http_build_query($data);`.

    Error:

    ```

    Warning: http_build_query(): Parameter 1 expected to be Array or Object. Incorrect value given in C:\xampp\htdocs\xmlovi\test1.php on line 56

    {"errors":{"":["A non-empty request body is required."]},"title":"One or more validation errors occurred.","status":400,"traceId":"800022db-0002-f700-b63f-84710c7967bb"}

    ```

    Tried another approach, as suggested on SO, still only errors.

    Edit1:

    Ok, i tried my original code with proven api (repo) which i made it myself. Both variations of original code is good, be it either json or query paramaters example. My api is tested using standard ajax(jquery and vanilla js), Postman and now even cURL from PHP. Readme.md in it is quite verbose and points in it are easily tested.

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

    Running Gunicorn Flask on Specific Python Thread

    Posted: 21 Mar 2020 10:57 AM PDT

    I am trying to run a Gunicorn Server for my Flask app, but due to a specific requirement of my application, I need to run it on a specific Python Thread. How do I do that?

    Eg: ``` from flask import Flask

    app = Flask(name)

    @app.route("/") def home(): return "Hello World"

    app.run(host="127.0.0.1", port=5000) ```

    ``` from threading import Thread

    class CustomThread(Thread): #some code

    ```

    Now how do I use, the thread in second module to run my Flask app?

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

    CSS =/

    Posted: 21 Mar 2020 10:50 AM PDT

    Hi Everyone,

    Im trying to learn CSS, but im finding it hard to understand, mostly remembering . Any advice on how to tackle it ? Also, was wandering if anyone would reccomened a bootcamp?

    Many thanks !

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

    Does anyone know of a macro Microsoft Word that centers captions?

    Posted: 21 Mar 2020 10:03 AM PDT

    need a helping hand

    Posted: 21 Mar 2020 12:49 PM PDT

    I am working on a project not programming but transport I need someone who could help me and create a few phone apps that rely on the scensors in a phone to do some shit the creator of that app can do what ever he wants with it as long as I get a copy I did find some apps that have my needs but they are paid and one of them costs about 3k a year and I need to save money for the project any ways who can help me plz email me on [craftx1234@gmail.com](mailto:craftx1234@gmail.com) I will then contact you on discord if that fits you

    submitted by /u/mahmoud-othman
    [link] [comments]

    Monitor changes to a list of files and log the filename, the timestamp and the diff

    Posted: 21 Mar 2020 08:00 AM PDT

    Hello everyone,

    I want to write a script/program that can monitor a given list of files on a server. When any of these files are changed it should log to the console: the filename, the timestamp and the diff.

    Now I have tried writing a Python script using the watchdog library but am facing the following issues:

    • How to watch just a specified list of files?
    • And most importantly, how can I log the diff?

    I would highly appreciate any help.

    submitted by /u/ess-que-el-injector
    [link] [comments]

    Google API OAuth2 credentials question

    Posted: 21 Mar 2020 07:27 AM PDT

    Not entirely a direct programming question, but I'm not sure where else to ask, so feel free to kick me elsewhere :)

    I wish to get OAuth2 credentials for the Gmail (GSuite) account for my work emails. This so I could access them programmatically with Python.

    However, in order to do this, it seems I need to register an application, and this can only be done under the Organization of my employer. I can create the credentials, but it's not clear if and how this application or these credentials appear to the rest of the company. Obviously this is just for personal access, and I don't want anyone else to see an application meant for me personally, let alone credentials.

    Any help on how to set this up properly would be appreciated. Thanks!

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

    No comments:

    Post a Comment