• Breaking News

    Thursday, February 25, 2021

    Tampermonkey method to drop the “.webp” extension for all “.jpg.webp” and “.png.webp” images on a page? Ask Programming

    Tampermonkey method to drop the “.webp” extension for all “.jpg.webp” and “.png.webp” images on a page? Ask Programming


    Tampermonkey method to drop the “.webp” extension for all “.jpg.webp” and “.png.webp” images on a page?

    Posted: 25 Feb 2021 04:59 PM PST

    I have to download and re-upload a lot of images for work. Generally, the images I download from the webpage/server will come in the format of "XXX.jpg.webp" and "XXX.png.webp." Unfortunately, upon re-uploading them elsewhere, the system I use will not accept the ".webp" file extension. After I download the images with the ".webp" filetype, I'll have to convert them into pure ".jpg" and ".png" sans ".webp" to use them for my purposes.

    As it stands, I have written a Tampermonkey script (in Javascript) in an attempt to remedy this problem, but it only works if I open a given ".webp" image in a separate tab and then right-click and save. This method strips the image of the ".webp" upon saving, but if and only if I open it in a separate tab and right-click to save. Instead, I would like to strip the images of the ".webp" extension and convert them into their ".png" or ".jpg" format on the very page that I find them, without having to open the image in a separate tab at all. Here's the current script I'm working with - again, it only works when I open the image in a separate tab:

    document.querySelectorAll('img[src$=".jpg.webp"]').forEach(item => item.src = item.src.replace('.webp', ''));

    document.querySelectorAll('img[src$=".png.webp"]').forEach(item => item.src = item.src.replace('.webp', ''));

    And here is an example of a webpage that I do this for: http://www.shareably.net/mom-helps-single-dad-groceries/. Notice how the images have a ".webp" extension.

    How can I go about altering the above script or getting a solution that converts these images on the original webpage and not in a separate tab? It would ultimately save me a ton of time. Any and all guidance would be much appreciated. Cheers!

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

    How does docker not require extra overhead?

    Posted: 25 Feb 2021 08:00 AM PST

    My understanding is that docker is kind of like an emulator for a micro-linux environment, but unlike an emulator there isn't a ton of overhead. How exactly does that work?

    Per the docker website:

    Containers take a different approach: by leveraging the low-level mechanics of the host operating system, containers provide most of the isolation of virtual machines at a fraction of the computing power.

    Can someone help me understand what exactly they mean by that?

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

    How can two APIs of two different apps/platforms be connected so that their data is kept in sync?

    Posted: 25 Feb 2021 08:44 PM PST

    I have played around a bit with APIs before. Mostly just consuming simple APIs using axios in React. And once I even created a small test app with its API using express. But when it comes to getting two APIs from two different places to talk to each other I have no idea how to even begin. And finding information online on how to do it has not been easy. Most tutorials just show how to do simple connections to an API using a tool like Postman, or they are based on React from the front end.

    I haven't found anything, after several days of looking, for how and where to write the code to connect two APIs on a real server for a real project and not just testing with tools.

    My specific goal at the moment is to connect a WooCommerce store with a CRM so that the products are in sync. At first I thought to use JS since it's what I have most experience with. But then I figured that would require node.js on the server (right? since there is authentication to be done) and I can't count on having node on the server. Same with Python, I must assume Python is not available on the server. So what's left is PHP, since that is available for sure.

    How would one go about it? Would I just create a .php file, write all the code in this one single file, and upload it to the server? What's the best way to connect to an API through PHP? cURL or something else? How should the authentication work? Authenticate to both APIs from the same file and write the logic in that same file? If there are API keys on that file just sitting there on the server like that, would that be a security issue? Would the code basically just GET data from one API and POST it to the other and back and forth? How would the code know when a product is changed in one place so it knows to let the other one know to update it on its end?

    Lots of questions as you can see, and no place that I know of where I can look up for the answers. The documentation of the platforms are of no help at all. I'm looking to learn how to do all this. Normally I have no problem finding tutorials to find out how to do things, but in this case, for some reason I can't find anything.

    Any help or pointers in the right directions are greatly appreciated.

    submitted by /u/s-e-b-a
    [link] [comments]

    Visual Studio Android Xamarin App Connection to SQL Server (How do I do this?)

    Posted: 25 Feb 2021 04:30 PM PST

    Hoping someone can help me out here, I've been attempting to Google for a couple of days to no avail.

    I'm new to creating Android apps, but the premise is that I want to access SQL Server data from my Android app. For my specific issue, I want to create a login page that checks the credentials against a SQL Server table to determine if the credentials are valid. I've been reading only that a REST Web Service is the way to go but am not able to find some kind of tutorial that shows me how one can set this up from beginning to end. I feel like I must not be searching for the right thing because I figured something like this would come up quite often! Can anyone point me in the right direction? Thank you in advance!

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

    Easiest GUI app-bundler for windows/mac

    Posted: 25 Feb 2021 08:07 PM PST

    What langauge/framework has, in your experience, the best/easiest method to create an executable installer for windows machines from a Linux machine? Currently looking into JEP 343 but wanted to gather more options.

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

    What would it take to develop a top notch anti botting program? (Not a programmer)

    Posted: 25 Feb 2021 04:09 PM PST

    (Besides money) what would we need to develop the end all be all "anti bot" program? Is it even possible? How realistic is something like this? I'm a big sneakers/fashion guy, and I can't stand the anti consumer tactics from the likes of Nike and Jordan and this botting nonsense from scummy little trust fund resellers buying 200 pairs of sneakers while the rest of us get nothing. I'd like to know if there's something that can be developed that would help out the rest of us. Apologies if this is the wrong place for this question. Also, I'm not even close to being a coder or programmer, so sorry if any of this sounds silly.

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

    What is this code :(){ :|: & };: and how do I execute it? Read somewhere that this code can crash pc

    Posted: 25 Feb 2021 07:09 AM PST

    I read somewhere that this code can crash your pc:

    ``` :(){ :|: & };:

    ``` What is this code and where do I execute it?

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

    Best way to keep track of which in-app events/announcements a user has seen?

    Posted: 25 Feb 2021 06:16 PM PST

    I'm trying to come up with the best schema for handling which events a user has come across.

    Example 1: after a new user has gone through the onboarding process of the app, we don't want to show them the "Getting Started" dialogue on subsequent logins, so it should persisted somewhere that the user has gone through that onboarding event.

    Example 2: If a new major version of the app has been released, we don't want to display the announcement popup that details the new features more than once.

    I was thinking of doing this one of two ways:

    1. embedding the event id in the User's (MongoDB) model, so that on future logins, the user's model will be checked if it contains the event id, which will determine whether they need to see the event or not
    2. saving the id of the event in a cookie so the id can be checked in a similar manner to option 1 ^

    I'm hesitant about using cookies, because for instance, if a longtime user clears their cookies, they shouldn't have to see the onboarding process again just because they cleared their cookies. Plus this also needs to be done for iOS and Android as well, so I can't leverage cookies for those platforms. But I'm exploring options beyond database persistence just for the sake of minimizing server payload,if possible.

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

    How to Read Bin file and output to console in C

    Posted: 25 Feb 2021 02:04 PM PST

    So I have a homework assignment that is supposed to mimic the functionality of HexDump and display the hex files of a bin/binary file to console. I am NOT looking for an answer to this problem (I actually want to solve this), I'm just really confused as to start solving it.

    The only information I was given was the fread documentation and the requested output. I read the documentation repeatedly and understand the example on the website. However I don't know how I'm supposed to output the data to console.

    I have the FILE variable named "file" and try to "printf(file)" and it errors out for me. My train of thought was that I was trying to have it output the current loaded file to console, to see what the contents were. I thought it would just output the binary contents to screen then I could work with that and translate them into Hex data. But since that didn't happen I'm just confused.

    I know theoretically how to solve the problem. I can do it on paper, I'm just really confused on the coding part. Since I know I'm supposed to take in the binary, then find each 4 bits and represent them as a Hex Bye (So like 1000 1010 as 1A), and go down the file. But I don't know how to do it programmatically. I hope its okay to ask, since I'm not trying to cheat.

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

    How to store a Todo list in Qt

    Posted: 25 Feb 2021 05:28 PM PST

    Essentially I am making a simple todo list application using Qt. I want to categorize the list based on which project the task is for. The tasks can be exclusive to one category (no need to share tasks between categories).

    How should I store the files so that it has separate fields for a title, category, and a paragraph description? I may want to add additional fields later. I am trying to avoid using any database or library that would require maintenance. I just want simple txt files with these fields.

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

    I need to develop my own software, help me figure out which languages to do this in.

    Posted: 25 Feb 2021 01:04 PM PST

    I do research for a living and I'm sick of shitty reference management tools, so I need to build my own.

    Essentially this software program would run nearly identical to Windows File explorer but allow me to essentially add something like a pseudo-metadata to a .pdf file so that I can organize files based on something like "Field" "Sub-Field" "Methods" etc.

    I have some programming experience in Python, but to do this I think I will need other languages. I have never built a program before, so what would be some languages I can look into that would help me get this going?

    On Going List of Potential Languages:

    CSS - Make the file explorer have some amount of style

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

    What is the best way to learn C++?

    Posted: 25 Feb 2021 12:49 PM PST

    So i did the whole Codeacademy free curriculum and started reading a book about JUCE. I feel i do understand in theory how everything works but i feel i should read more about standard traditional C++ stuff before advancing towards DSP processing, audio plugin programming, JUCE etc...

    What are the best ways to advance so i learn enough terminology needed to work myself towards my goals and be able to make my own small projects?

    Any advice is appreciated! Thanks!

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

    Is it possible to estimate the run time of an algorithm if I know its complexity?

    Posted: 25 Feb 2021 07:35 AM PST

    I have an algorithm that is O(n2). if I wanted an estimate of how long it would take to run on a very large input n, would it be possible to run the algorithm for a couple of smaller tests, plot the curve, and get an estimate for how long it would take for larger values?

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

    I have a media server I'm setting up, and I have a weird idea that I need a little guidance with.

    Posted: 25 Feb 2021 03:00 PM PST

    So I'm planning on building a small film 'archive' room. It's going to be running a dedicated plex server.

    But instead selecting files through the player, I plan on having each movie/show physically represented with it's corresponding dvd case all on a set of shelves.

    Inside each case, instead of a disc I want a small removable card with a QR code. Mounted directly under the tv will be a scanner to scan the code which will in turn, load the correct movie and begin playback. Basically simulating putting in a dvd.

    I wrote a script that generates a 32 bit hash based on each files name. These hashes will be the seeds for creating the QR codes.

    What I would like a bit of guidance on, is what would be least cumbersome route to do this?

    These are the main points where I am unsure of the optimal method:

    • Keeping the scanner persistently watching for input

    • Batch creating the different QR codes

    • How to point Plex to the correct file after receiving the hash, and begin playback

    • I have about 30 terabytes total in the library. Roughly 5,000 hashes in the master db. Is this going to be fine in an unordered list as far as lookup speed goes?

    Sorry for the wall of text lol. I appreciate any help you guys can give.

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

    Help with HTML connecting to a database

    Posted: 25 Feb 2021 02:42 PM PST

    Hello everyone I am making a website and I am going to need to connect my html forms to a database. The HTML pops up just find but when I press submit the screen only displays my PHP code and not my confirmation message. Additionally the database appears to not be receiving any data so something is going wrong when I hit submit and I cannot seem to figure out what I'm possibly doing wrong

    Here is my html

    <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New user sign up form</title> </head> <body> <fieldset> <legend>New User Sign up</legend> <form name="frmContact" method="POST" action="contact.php"> <p> <label for="firstName">First Name </label> <input type="text" name="txtFirstName" id="txtFirstName"> </p> <p> <label for="Last Name">Last Name </label> <input type="text" name="txtLastName" id="txtLastName"> </p> <p> <label for="email">Email </label> <input type="text" name="txtEmail" id="txtEmail"> </p> <p> <label for="password">Password</label> <input type="text" name="txtPassword" id="txtPassword"> </p> <p>&nbsp;</p> <p> <input type="submit" name="Submit" id="Submit" value="Submit"> </p> </form> </fieldset> </body> </html> 

    Here is my PHP

    <?php // database connection code // $con = mysqli_connect('localhost', 'database_user', 'database_password','database'); $con = mysqli_connect('localhost', 'root', '','beatswap'); // get the post records $txtEmail = $_POST['txtFirstName']; $txtPhone = $_POST['txtLastName']; $txtEmail = $_POST['txtEmail']; $txtPhone = $_POST['txtPassword']; // database insert SQL code $sql = "INSERT INTO `new_user_signup` (`firstName`, `lastName`, `email`, `password`) VALUES ('$txtFirstName', '$txtLastName', '$txtEmail', '$txtPassword')"; // insert in database $rs = mysqli_query($con, $sql); if($rs) { echo "New user information successfully added to the system!"; } ?> 
    submitted by /u/beansandbeams
    [link] [comments]

    How do you check if a large file is safe?

    Posted: 25 Feb 2021 02:34 PM PST

    Normally, I rely on the functionality of google via:

    Google Drive can't scan this file for viruses. quotes_dataset.csv (157M) is too large for Google to scan for viruses. Would you still like to download this file?

    However, this time the file is too large.

    Would there be a way to scan the file for viruses via python / javascript? Are there any signals that might indicate a virus is present?

    Thanks!

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

    What should I use if I'm going to be working with a big(ish) set of data?

    Posted: 25 Feb 2021 02:33 PM PST

    So I want to make a ruby program for this game I enjoy playing called Dragonvale. I want it to be like a breeding information thing where you choose 2 dragons and it gives you what different dragons it will produce and also the chances for each. I found an up to date list of every dragon but I don't know how I should store it. Should I just use a big list of every dragon or should I have an external file like json for them and read from that?

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

    Localisation via JSON: What do I do after loading the json object?

    Posted: 25 Feb 2021 01:21 PM PST

    I'm having conceptual problems on how to distribute all of the strings pulled from a JSON file for my program. For example let's say my JSON looked like this

    { "en": { "title": { "title": "My Program", "author: "Hatefiend from Reddit", "date": "2/25/2021" }, "prompts": { "name": { "prompt": "Please enter your name", "error": "Your name must be two words maximum" }, "age": { "prompt": "Please enter your age: ", "error": "The age you entered is invalid" } } } } 

    Imagine that, but WAY bigger and more expansive. The problem I'm now having with my design is how does my program now look up the string it's supposed to use? How do I do it without having a mess? Also I want to avoid being like:

    StringLookup.getCurrentLocale().get("prompts/age/invalid")

    Part of putting all the strings my program will use into a file implied that I won't have strings all over my source code. There's got to be a better way. I was thinking creating nested enums so that it would look like

    StringLookup.PROMPTS.AGE.INVALID.get()

    But to make that work, the nested enums class would be extremely messy and would be a complete headache to edit every time I need to add a new string or restructure the hierarchy of my existing strings. There must be a better way.

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

    How to synchronize global state among decentralized socket connections

    Posted: 25 Feb 2021 12:21 PM PST

    Let's say I have a scenario where I have python sockets as clients connected to each other, so each socket is listening for other sockets and also sending msgs to other sockets. There is no central server. Each msg is updating some global state. What would be at a high level the optimal solution to manage this? I'm having trouble especially when thinking about different socket connections starting up sequentially where not only can they start affecting global state, but they need to sync up with the current global state as well. This needs to be done all locally. I'm not looking for a literal or code block answer, just some ideas at a high level would be perfect. My initial though was writing and reading from a shared file, but it doesn't seem like a scalable solutions if I have it filled up with stuff.

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

    Skipping the initial technical interview

    Posted: 25 Feb 2021 09:26 AM PST

    So this is a little strange. I am in the interview process for one of the big tech companies and it usually goes Recruiter call -> 1 hour technical interview -> day long interview. Recently though after the recruiter call I got an email stating I am eligible to skip the 1 hour technical interview. This has never happened to me before. Has this happened to anyone else and if so do you know why? I'm not complaining just curious on why it happened.

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

    Checking arrays in java

    Posted: 25 Feb 2021 08:53 AM PST

    I have to write a method that checks an array to see if it is filled with the value 2 and return false and otherwise return true and I can't figure it out. Can anyone help? This is what I have so far:

    public boolean notDone(){

    for(int r = 0; r < 4; r++) {

    for(int c = 0; c < 4; c++){

    while(show[r][c] == 2){

    return false;

    }

    }

    }

    return true;

    }

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

    How do applications draw polynomial equation graphs, just calculating y values for all x pixels?

    Posted: 25 Feb 2021 08:53 AM PST

    The graph below is what I got by typing y=x^3+x^2+x in Google.

    https://i.imgur.com/grfca0Q.png

    There are many applications and websites that can show such graphs when the user enters an equation. But how do they draw it? Do they just calculate the y value for all x pixel values and draw a point? If they don't calculate the y value for all x pixel values, then they must somehow draw a smooth connecting curve between points. But how do they draw such a smooth curve?

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

    How do I interface C and Verilog?

    Posted: 25 Feb 2021 02:42 AM PST

    I'm on a Mac. I want to learn the basics of Verilog before I go out and buy an FPGA.

    I have a toy program written in C. I have a pure function that computes a value. I want to run that function on a simulated FPGA.

    So my question is what Verilog compilers and FPGA simulators are out there? How do I interface these with my C program?

    When I've done this, will it be possible to swap the simulated FPGA for a real one?

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

    Learning Java again

    Posted: 25 Feb 2021 08:29 AM PST

    I don't know where to start, but it's been a year since the last time I code using Java (which is the first programming language that I learn in school) in Netbeans IDE and seriously I'm not that good. That last time was about OOP which I remember I am having a hard time to learn the logic of that. So fast forward, now I am learning and trying to improve my knowledge again, but now using the VS Code.

    Is it okay that I switch a platform? Or should I stick to the Netbeans? And any tips to improve my skills and knowledge? Because right now I feel like I am back to zero again, but with a little experience.

    PS: I am 2nd year college student whose taking Computer Science.

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

    No comments:

    Post a Comment