performance – How can I make this C code to simply open, write to, and close a file less verbose?

All this does is safely and reliably opens, writes to, and closes the file. Yet there are so many gotos and the code is quite verbose. I am not even sure that all of what I am doing is necessary.

int WriteConfig(void) {
    FILE *ConfigFile;
RetryOpen:
    if (!(ConfigFile = fopen(Config, "w"))) {
        if (errno == EINTR)
            goto RetryOpen;
        else
            goto Err;
    }
RetryWrite:
    if (fwrite(&Conf, sizeof(struct Config), 1, ConfigFile) < 1) {
        if (errno == EINTR)
            goto RetryWrite;
        if (fclose(ConfigFile))
            goto Error;
        goto Err;
    }
    if (fclose(ConfigFile))
        goto Error;
    return 0;
Err:
    AlertFuncErrno;
    return errno;
Error:
    AlertFuncErrno;
    exit(errno);
}

AlertFuncErrno is a macro that expands to a function call that notifies the user of the error (including strerror(errno)). Config is a global char * that contains a path to the config file. Conf is a global variable of type struct Config. Am I doing too much here? What action would be appropriate when library functions fail? Should I fflush prior to close, so that if there is a write error it will be caught there? Keep in mind I am attempting to create portable code.

javascript – React Material UI create a temporary menu that do not close on item click

I am trying to create a menu using react material that has a item which holds a submenu, but everytime I click the submenu option, it closes the menu by default.

In their page, the displayed menu does not close when you click an option that displays more options, but after treying to replicate their code I have not been able to achieve this.

My code for the drawer is the following:

<Drawer
                className={classes.drawer}
                variant='temporary'
                anchor='left'
                onClose={handleDrawerClose}
                ModalProps={{
                    keepMounted: true, // Better open performance on mobile.
                    disableBackdropClick: true,
                    disableEscapeKeyDown: true,
                }}
                open={openMenu}
                classes={{
                    paper: classes.drawerTemporaryPaper,
                }}
            >
                <Link to={"/"} className='p-3' key={"link"}>
                    <img className='logoPrincipal ' src={logoAh} alt='AH' />
                </Link>

                <ContenidoMenu
                    dataUserLogged={dataUserLogged}
                    menuOptions={menuOptions}
                    localData={localData}
                    setOpenMenu={setOpenMenu}
                />

And the insides of the drawer are these:

import React from “react”;
import List from “@material-ui/core/List”;
import ListItem from “@material-ui/core/ListItem”;
import ListItemText from “@material-ui/core/ListItemText”;
import Divider from “@material-ui/core/Divider”;
import { Link } from “react-router-dom”;
import { makeStyles } from “@material-ui/core/styles”;
import Collapse from “@material-ui/core/Collapse”;
function ContenidoMenu({ dataUserLogged, menuOptions, localData, setOpenMenu }) {
const (servicesOpen, setServicesOpen) = React.useState(false);

const useStyles = makeStyles((theme) => ({
    drawerContainer: {
        overflow: "auto",
    },
    nested: {
        paddingLeft: theme.spacing(4),
    },
}));

const servicios = () => {
    setServicesOpen(!servicesOpen);
};
const classes = useStyles();
return (
    <div className={classes.drawerContainer}>
        <List>
            {dataUserLogged.usuario !== "" && (
                <>
                    <Link to={"/user"} className='linksToolbar'>
                        <ListItem className='nombreToolBar' button>
                            <ListItemText primary={dataUserLogged.usuario} />
                        </ListItem>
                    </Link>
                    <Divider className='border-bottom ml-3 mr-4' />
                </>
            )}

            {menuOptions.map((opcion, index) => (
                <>
                    {index === 2 && (
                        <Link disabled className='linksToolbar ' to={"#"}>
                            <ListItem button className='pt-0 pb-0' onClick={servicios}>
                                <ListItemText primary={localData.idioma === "es" ? "Servicios" : "Services"} />
                            </ListItem>

                            <Collapse in={servicesOpen} timeout='auto' unmountOnExit className={classes.nested}>
                                <List component='div' disablePadding>
                                    {menuOptions.map((opcionSubmenu, indexSubmenu) => (
                                        <>
                                            {opcionSubmenu.submenu === "Servicios" && (
                                                <Link
                                                    to={"/ah/" + opcionSubmenu.id_str}
                                                    className='linksToolbar '
                                                    key={opcionSubmenu.id_str}
                                                >
                                                    <ListItem button className='pt-0 pb-0 pt-0'>
                                                        <ListItemText primary={opcionSubmenu.titulo} />
                                                    </ListItem>
                                                </Link>
                                            )}
                                        </>
                                    ))}
                                </List>
                            </Collapse>
                        </Link>
                    )}
                    {opcion.submenu === "" && (
                        <Link to={"/ah/" + opcion.id_str} className='linksToolbar ' key={opcion.id_str}>
                            <ListItem button className='pt-0 pb-0'>
                                <ListItemText primary={opcion.titulo} />
                            </ListItem>
                        </Link>
                    )}
                </>
            ))}

            {dataUserLogged.usuario === "" && (
                <Link to='/login' className='linksToolbar text-success'>
                    <ListItem button className='pt-0 pb-0'>
                        <ListItemText primary={`${localData.idioma === "es" ? "Iniciar sesión" : "Log in"}`} />
                    </ListItem>
                </Link>
            )}
        </List>
    </div>
);

}

export default ContenidoMenu;

Thanks inadvance for your help!

focal length – Is there a difference between taking a far shot on a 50mm lens and a close shot on a 35mm lens?

Do you have a selection of lenses (or a zoom lens) now?

Shoot a table-top test with different focal lengths, repositining the camera to get tye same view of the foreground object. Then look carefully at the photos to see for yourself.

If you’re one of those peopke where this doesn’t just scream at you, it’s good to develop your eye to seeing the perspective.

For example, my wife takes still-life photos of food, and I say “too close! Back up!” and had to teach her to use the numbers (e.g. don’t use a focal length shorter than 40), as she doesn’t “see” the perspective when framing the shot. Even if she can “see” it in the final picture on a full-size screen, it’s too late.

In particular, the background (table and room beyond) becomes a sweeping expanse that dominates the composition, or even looks unnatural.

The other day, my Mom showed draft/concept of product shots she wanted, and knew that they didn’t look good but didn’t know why. I explained “because you were too close.” The bottles looked fatter on top and thinner at the base, because the distance was different and that distance was significant compared to the individual distances.

A person’s face will look bad if you shoot from closer than you would normally view a face. Percepually, you actually need a longer lens to look best because you view a photo as if seeing someone on stage or otherwise at a distance, beyond a normal personal conversation distance. So portrait lenses are longer again than the “normal” lens below which it simply looks bad.


I have an Alpha 6000 as you do, and use it for social events including getting pictures taken with people at an event, parties and gatherings, etc.

I use the 35mm f/1.8 OSS prime lens.

In real real situations, I still have a bit of a chore getting far enough away to frame a shot. The pictures look good. The 50mm would be too long, making it difficult to back up enough.

On the other hand, for portraits (close up to show just the face) the flatter perspective of the 50mm would look better, all else being equal. But I think that’s not the primary use for an ultra-portable camera. (Note that the 35mm is a normal perspective and ok enough for such shots, and great for anything that shows more than just the head. You can avoid crowding in and shoot the head-only by cropping the result, as you hace 25 megapixels to start with!)

So unless you have something completely different in mind, get the 35mm. Also lookmat renting first if you are not sure.

How to configure lid close action as hibernate in Ubuntu 20.04?

I want to configure my laptop (ASUS UX461UN) to go to hibernate when I close the lid. I tried 3 basic suggestions that I saw as a result of my research.

  1. Run command sudo -H gedit /etc/systemd/logind.conf and configure #HandleLidSwitch=suspend line for hibernate,
  2. Increase swap space,
  3. Disable secure boot.

None of these worked. How do I get my laptop to go into hibernate mode when I close the lid?

javascript – Pausar video cuando hago click en close en un modal

javascript – Pausar video cuando hago click en close en un modal – Stack Overflow en español

Chrome browser: how to close current tab without showing all tabs first?

When I’m browsing on my computer I can press CTRL-W or click the X on a tab to close it. That’s convenient. But it seems Android / Chrome has no similar function.

To close the current tab on Android, I need to click the “tabs” icon which brings up all tabs. This often takes 10-60 seconds on my phone because there is anything between 100-3000 tabs open/cached there and seems very unecessary.

Is there another way to close the current tab without first loading all the tabs?

keyboard – Safari: shortcut to close one single tab without loading the webpage?

I always have a lot of tabs open. I would like to close them quickly, but since there are a lot of them and they are very small, I don’t see the “x” that closes a single Safari tab. Looks like I need to click on them one by one and reload the page.

Actually, if I hover on a tab, I can see a preview, which is helpful.

QUESTION

I wonder if there is a shortcut that would allow me to close one single tab after I see the preview.

Right now, if I don’t want to open the web page, I can right-click on the tab and I see a menu, from which I can pick “Close Tab”, but how could I achieve this more quickly?

enter image description here

c# – How can I implement Windows close in MVVM pattern?

I’m newer to MVVM design pattern with WPF .Net Framework

I have a :

  • Model ( Student )
  • View Model (StudentViewModel )
  • RelayCommands
  • MainWindow.xaml.cs
  • MainWindow.xaml

Everything works fine and I have bonded WPF Commands to the button,
I have a button called Exit that will close the window in MainWindow

Actually, I’m so confused about how can implement this.close() in the button Exit using Commands that inherit from RelayCommand??!

How can I do that?

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheapest USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Proxyti.com Buy Quality Private Proxies