• Breaking News

    Thursday, September 9, 2021

    can't delete httponly cookie in server (nodejs) Ask Programming

    can't delete httponly cookie in server (nodejs) Ask Programming


    can't delete httponly cookie in server (nodejs)

    Posted: 09 Sep 2021 08:47 PM PDT

    I'm trying to write code that when frontend requests to "/signout" controller, server sets cookie's expiration to 0.

    here's my code. but it doesn't really delete the cookie. what's wrong?

    signOut(@Req() req: Request, @Res() res: Response) { const accessToken: string = req.cookies['accessToken']; console.log('token: ', accessToken); // I got accessToken correctly res.cookie('accessToken', accessToken, { expires: new Date(Date.now()), }); } 
    submitted by /u/zxaq15
    [link] [comments]

    Help with algorithm: Speeding up a pre-computed seam carving algorithm

    Posted: 09 Sep 2021 09:06 AM PDT

    I'm writing a JS seam carving library. It works great, I can rescale a 1024x1024 image very cleanly in real time as fast as I can drag it around. It looks great! But in order to get that performance I need to pre-compute a lot of data and it takes about 10 seconds. I'm trying to remove this bottleneck and am looking for ideas here.

    Seam carving works by removing the lowest energy "squiggly" line of pixels from an image. e.g. If you have a 10x4 image a horizontal seam might look like this:

    ........x. .x.....x.x x.xx..x... ....xx.... 

    So if you resize it to 10x3 you remove all the 'X' pixels. The general idea is that the seams go around the things that look visually important to you, so instead of just normal scaling where everything gets squished, you're mostly removing things that look like whitespace, and the important elements in a picture are unaffected.

    The process of calculating energy levels, removing them, and re-calculating is rather expensive, so I pre-compute it in node.js and generate a .seam file.

    Each seam in the .seam file is basically: starting position, direction, direction, direction, direction, .... So for the above example you'd have:

    starting position: 2 seam direction: -1 1 0 1 0 -1 -1 -1 1 

    This is quite compact and allows me to generate .seam files in ~60-120kb for a 1024x1024 image depending on settings.

    Now, in order to get fast rendering I generate a 2D grids that represents the order in which pixels should be removed. So:

    (figure A):

    ........1. .1.....1.1 1.11..1... ....11.... 

    contains 1 seam of info, then we can add a 2nd seam:

    (figure B):

    2...2....2 .222.2.22. ......2... 

    and when merged you get:

    2...2...12 .122.2.1.1 1211..122. ....112... 

    For completeness we can add seams 3 & 4:

    (figures C & D):

    33.3..3... ..3.33.333 4444444444 

    and merge them all into:

    (figure E):

    2343243412 3122424141 1211331224 4434112333 

    You'll notice that the 2s aren't all connected in this merged version, because the merged version is based on the original pixel positions, whereas the seam is based on the pixel positions at the moment the seam is calculated which, for this 2nd seam, is a 10x3px image.

    This allows the front-end renderer to basically just loop over all the pixels in an image and filter them against this grid by number of desired pixels to remove. It runs at 100fps on my computer, meaning that it's perfectly suitable for single resizes on most devices. yay!

    Now the problem that I'm trying to solve:

    The decoding step from seams that go -1 1 0 1 0 -1 -1 -1 1 to the pre-computed grid of which pixels to remove is slow. The basic reason for this is that whenever one seam is removed, all the seams from there forward get shifted.

    The way I'm currently calculating the "shifting" is by splicing each pixel of a seam out of a 1,048,576 element array (for a 1024x1024 px image, where each index is x * height + y for horizontal seams) that stores the original pixel positions. It's veeerrrrrryyyyy slow running .splice a million times...

    This seems like a weird leetcode problem, in that perhaps there's a data structure that would allow me to know "how many pixels above this one have already been excluded by a seam" so that I know the "normalized index". But... I can't figure it out, anything I can think of requires too many re-writes to make this any faster.

    Or perhaps there might be a better way to encode the seam data, but using 1-2 bits per pixel of the seam is very efficient, and anything else I can come up with would make those files huge.

    Thanks for taking the time to read this!

    [edit and tl;dr] -- How do I efficiently merge figures A-D into figure E? Alternatively, any ideas that yield figure E efficiently, from any compressed format

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

    Transferring values through a graph?!

    Posted: 09 Sep 2021 07:20 PM PDT

    Hi /r/AskProgramming. I've never actually had to resort to asking on a forum but I've been wracking my head over this for a while with absolutely no success.

    I'm using a functional language that is pretty limited. No arrays, pointers, classes, nothing. I have bootleg JSON, one-dimensional lists, and I have loops, and that's about it.

    https://pastebin.com/Kx4YwsKQ

    The graph is stored in the JSON, with the "c" list as the nodes reachable by that node, and "v" is the value stored in the node. I'm just trying to have the value in the A node flow and reach equilibrium in all the other nodes (eventually having an input and output for that).

    It either doesn't transfer at all, or transfers entirely to B and continues going up once A is empty, or currently it transfers through the network once and then B gets everything else from A. I know it's pretty much just all flowing back somehow, but I can't figure out how to prevent it.

    Does anyone know a pseudocode, functional implementation of a graph, instead of object-based?

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

    What did you switch to or contemplate switching to when you hit burn out?

    Posted: 09 Sep 2021 09:02 AM PDT

    Almost every dev hits a burn out in their career. Most transition out into another job description. Some contemplate transition. What did you guys do?

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

    What would you do if you were asked to come in and maintain a series of programs in poorly written (but functional), completely uncommented code…Rebuild from the ground up or try to figure out what everything is doing, recode and comment properly?

    Posted: 09 Sep 2021 05:07 AM PDT

    Can anyone point me in the right direction to optimize a JavaFx app, and more importantly solve a memory issue?

    Posted: 09 Sep 2021 11:27 AM PDT

    So, I have a tool I made for a game that I wrote in Java 11 and used JavaFx 15 for, and while it definitely feels sluggish and probably in need of some optimization, it's not so bad that I'd feel it's urgent, and I haven't been able to find any material that could help with it anyway.

    However, today I noticed a big problem: the RAM the app uses goes out of control very quickly. The main function of the tool would be to help the player keep track of the units they have and their stats, which is done in a table view that allows editing (the Roster tab to be specific), and te problem I noticed is that after every time the user edits a value, the RAM usage goes up by like a few hundred megabytes, which seems very very wrong.

    I clearly screwed up somewhere but I have no idea how to even start solving the problem. I have created 2 heapdumps too (using VisualVM 2.1), one before and after some edits I did so it hopefully makes it easier to see what the issue is.

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

    Graph clustering libraries similar to what movie-map or music-map.com use?

    Posted: 09 Sep 2021 02:52 PM PDT

    I'm looking for a library that allows me to create clusters from an organized database of items, all of which have different (but not unique) tags.

    I've seen this done in movie-map or music-map, but the best one I've seen was done by anvaka (map-of-reddit). Do you have any tips or point me in the right direction on how I could get started to build such a map?

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

    Converting a function call into a component?

    Posted: 09 Sep 2021 12:50 PM PDT

    In this codesandbox, the following section appears, where Row is a component which automatically receives index, style, data as props:

    <List className={classes.list} height={height} width={width} itemCount={data.length} itemSize={ROW_SIZE} itemKey={itemKey} itemData={itemData} > {Row} </List> 

    Is there a way to convert it into something like:

    <List ... > <Row ... /> </List> 

    where all the props are still passed in using the component syntax? The main reason is so I can use onClick on each of the row elements, but I'm not sure how to code that in (without doing a lot of state/method passing) using the function syntax.

    Any help is appreciated. Thanks!

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

    URGENT help need for online video lecture study!

    Posted: 09 Sep 2021 12:49 PM PDT

    I am not sure if this is the place to ask this but, I am conducting a multi-tasking study where i'll need an online web program or software that can allow me to embed questions in pre-recorded video lectures. Intermittently placed during the 20 min lecture, I need 4-5 pop-up prompts Multi-tasking Question Prompts (MQPs) i.e. "what did Justin Trudeau tweet 10:30 AM on the 21st of August?" that has a short answer submission feature. There are two versions of this (2 groups of participants):

    1. In one condition (PAUSE condition) I need the MQP to interrupt and stop the lecture video and resume once an answer is submitted.
    2. In another condition (NO PAUSE condition) I need the MQPs to come up while the lecture video will continue in the background (as students search for the answer).

    I tried looking into limesurvey, macvideo, and few other programs, but they don't provide the features I need. I am a tech noob and don't really know where to begin. I already have a full pre-recorded lecture lined up. If anyone knows of any software/programs that could be of use here, It would be greatly appreciated. I know this is asking a lot, but I am willing to pay anyone who can write/create software/program that can allow me to run this and collect data ASAP.

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

    Error 429 when using youtube_dl

    Posted: 09 Sep 2021 12:26 PM PDT

    Hi Reddit,

    I have a Vue, Django integrated project. I hosted the Vue project on Netlify and the Django project on Heroku. A python script (integrated into Heroku) is called on certain buttons which extract data from a youtube livestream and posts this to the Django API and PostgreSQL database to be viewed on the frontend.

    Now I am using youtube_dl in Python to get the frames of the youtube live stream, to be analysed. I get error 429 when going through the following piece of code:

    ydl_opts = {} ydl = youtube_dl.YoutubeDL(ydl_opts) info_dict = ydl.extract_info(url_matches, download=False) formats = info_dict.get('formats', None) for f in formats: # I want the lowest resolution, so I set resolution as 144p if f.get('format_note', None) == '360p': # get the video url url = f.get('url', None) # open url with opencv cap = cv2.VideoCapture(url) 

    Where url_matches is the link to the youtube live stream. I use the cap, to read out the frames. The error appears before formats (so the problem is not in that part of the code).

    I saw online that error 429 (Too many requests), is because of that it is hosted on Heroku, and there is a limit on the requests you can make to 'download' youtube videos.

    I also saw, that people used --force-ipv4 to get around this problem, but I am not sure how I would use this solution in my specific code (as I do not have a regular command (?)). Is this the way I can solve it, and if so how? If not, is there another solution I am missing?

    Thanks!

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

    How to add TypingDNA 2FA to a WordPress site?

    Posted: 09 Sep 2021 04:46 AM PDT

    I've been trying to find how to add 2FA (two-factor authentication) using typingDNA to my WordPress site for a week. I couldn't find any sources that explain it using WordPress. The only source I found is regarding a WordPress plugin, but it's not very relevant to my problem.

    If any of you know how to do it, please let me know. A step by step answer would be great!

    Thank you so much in advance.

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

    What niches exist within C++?

    Posted: 09 Sep 2021 12:29 AM PDT

    https://youtu.be/T7aSI-E1fCE

    The above is a video by YouTuber Aaron Jack. In it he explains 4 stumbling blocks which beginner programmers face while learning.

    One piece of advice he offers is that a person shouldn't focus on just learning a language or learning programming. Instead, he should look deeper into that language and try to become proficient at one aspect or niche or that language. His rationale is that employers are looking for someone who can do something specific, not an everything man.

    That being said, what kind of niches exist within C++? I already typed this question into Google but I couldn't find an answer. So, sorry if this is a noob question. I'd appreciate any and all help.

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

    Does python script from desktop app continue after PC sleeping and waking up again?

    Posted: 09 Sep 2021 03:17 AM PDT

    Hi Reddit,

    I'm making a project in which a python script extracts data from a livestream. At the moment, I have it hosted on Heroku, so when I call the python script, it is processed on the Heroku server. However, I want to make it into a desktop application, such that the python script can be run on the PC resources of the user. However, I do not want the user to HAVE to have their PC active all day. When I make this project into a desktop application (with electron.js for example), will the python script 'pause' at the moment the PC goes to sleep and continue the work after the PC wakes up?

    Thanks a lot!

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

    Apache Community to help solve (I think) ssl problem. /etc/apache2/sites-available/domain.de-el-ssl.conf missing

    Posted: 09 Sep 2021 02:59 AM PDT

    Do you know a community wich is dedicated to the Apache Webserver?I am quite new to all this so maybe Apache2 is so familiar that I can find some help here.I have a Lamp stack where I just set up Apache.I went into /etc/apache2/sites-available and created the .conf files for my two websites.After that I ran a2ensite to activate these sites (Dont know what it means but in every tutorial its mentioned).After that I installed certbot and ran it. I chose the subdomains I want to redirect to ssl. Everything seems to work fine, no errors. Thou the Frontend already told me some ssl errors.I went back into the /etc/apache2/sites-available folder and noticed, that usually there should have been files like 'test_xxx_de_el-ssl.conf' . These are not created for my sites.Since I am pretty new and overwhelmed by all this, I dont really know If these are created when I run certbot or a2ensite, or If i needed to create these myself.If somone could explain to me how these are created and what I am missing that would be a lot of help.

    edit: note, that I do have the default-el-ssl.conf file , in the example that i used and try to replicate, there are el-ssh.conf files for every site that was activated with a2enmod

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

    Documents and assets in graph db schema: nodes or edges?

    Posted: 09 Sep 2021 12:03 AM PDT

    I have a super quick question: should transactional documents (e.g. invoices or receipts) be represented as nodes or edges? And what about titles/assets?

    [Note that I'm not a developer and just want to better understand how a schema would look like using a graph database.]

    I understand that Edges represent relationships and actions. When applied to some business context, the transaction is equivalent to a document being issued (a real document that needs to be signed, such an invoice, or a receipt, or a certificate). So, is the document a property of the Edge?

    But when a document is transferable, such as a title, then shouldn't a document be represented as a node? So when a title is transferred form Alice to Bob, there is an edge going from node:Alice to node:Bob... and then there is another node:Title that first has an edge connecting to node: Alice and later an edge connecting to node:Bob? Or how should it be?

    And if a document is issued to the public (not to someone specifically), such a self-certification, would the node/vertex have an edge looping back to the same node/vertex?

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

    No comments:

    Post a Comment