File systems – How does a file system handle internal editing of a file?

If you edit information in a file but add more information than was already there, how does the file system handle it without overflowing to the next section of the file?

Here is an example. Consider having instructions 1-12 in one 512 byte block and you had instructions 13-24 in the next 512 byte block. (Photo 1) These blocks are both part of the same file. If you have edited the first block and add some new instructions (image 2) after instruction 12, this will overflow into the next block (instructions 13-24). How would this condition be dealt with? By moving all statements forward before the added statement or by inserting the new editing in a completely separate new block?

(Sorry if the images or wording is a little inappropriate; this is my first time)

Unprocessed blocks

Machined blocks

unit – Use EntityManager within a system

I'm using Entities v0.8

I'm trying to build a spawner and that's the system

using UnityEngine;
using Unity.Entities;
using Unity.Transforms;

public class ChunkSpawnerSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities.ForEach((ref ChunkSpawnerComponent spawner) =>
        {
            if (!spawner.needsRender) return;

            EntityArchetype chunkArchetype = EntityManager.CreateArchetype(new ComponentType() { typeof(Translation) });

            for (int id = 0; id < spawner.size; id++)
            {
                Debug.Log("Rendering chunk " + id);
                Entity entity = EntityManager.CreateEntity(chunkArchetype);
                EntityManager.SetName(entity, "Chunk " + id);
            }

            spawner.needsRender = false;

        }).Schedule();

    }
}

But I get the following error

ChunkSpawnerSystem.cs (9.9): Error DC0002: Entities.ForEach Lambda expression calls & # 39; get_EntityManager & # 39; on a ChunkSpawnerSystem that is a reference type. This is only allowed with .WithoutBurst () and .Run ().

Apparently I can't use EntityManager in the Lambda function. Why is this?

Networking – securing the insecure Linux system!? Looking for experts with humor?

I use Ubuntu Mate and I really want to make it safe.

Everyone knows that a Linux system is hellishly unsafe after a new installation or like Windows, whatever you want.

So I'm looking for humor experts who share their knowledge with the rest of the world.

It is a project and I want to collect all the little information to configure the system as safely as possible.

Here is the list of what I've found so far:

  1. activate ufw and deny in 1: 65535 / tcp / udp, deny all ports except 53, 80, 443
  2. edit access.conf:
    +: root: LOCAL,
    -: root: ALL
    +: myuser: LOCAL
    -: myuser: ALL
    +: ALL: LOCAL
    -:EVERYTING EVERYTHING
    add: account / auth required pam_access.so to pam-modules common-account / auth, lightdm and login
  3. Configure lightdm (files in / etc / lightdm and /usr/share/lightdm/lightdm.conf.d):
    (Seat:*)
    xserver-allow-tcp = false
    greeter-allow-guest = false
    greeter-show-remote-login = false
    allow-guest = false
    autologin-guest = false
    Autologin-in-Background = false
    (XDMCPServer)
    enabled = false
    (VNCServer)
    enabled = false

  4. securetty: only console active

  5. hosts.deny: ALL: ALL
  6. Add the file portmap with OPTIONS = "- i 127.0.0.1" in etc / default
  7. Deactivate ipv6 via the variable GRUB_CMDLINE_LINUX and the file 99-sysctl.conf
  8. pam.d: set others, ppp, samba, cups all deny
  9. Add the .xserverrc file to the home directory
  10. Stop all monitoring ports to listen on remote ports
  11. Disable LLMNR and MulticastDNS in Resolution.conf
  12. add ftpusers-file to / etc, but I'm not sure I did it correctly. What should it look like?
    So: root: x: 0: 0: root: / root: / usr / sbin / nologin or is just root enough?

Hope for your help to make the system as safe as possible.

Thanks in advance.

Domain Name System – Use CLOUD DNS to manage custom DNS for my customers

I need to manage a custom domain for my customer in my app engine.
I saw "Cloud DNS" with which I can give NS to my customers, they update their NS to their DNS and the game is finished.
So my customers will connect them customer.com to my customer.appengine.com.
URL when use go to customer.com remains customer.com.

I can't find any cloud DNS documentation used with the App Engine. Is this possible?

I actually tried to set up cloud DNS, I did

    customer.com. SOA   21600   ns-cloud-f1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600  259200 300
    customer.com.   NS  21600   ns-cloud-f1.googledomains.com.
                                ns-cloud-z2.googledomains.com.
                                ns-cloud-x3.googledomains.com.
                                ns-cloud-a4.googledomains.com.
    www.customer.com.   CNAME   300   customer.appengine.com.

My customer specified the correct configuration of the registrar (DNS was added to me by Google) for his DNS.

Differential geometry – consider a triangle ABC. Using an orthonormal coordinate system, the origin of which is at vertex A.

denote by (b1, b2) the coordinates of point B and by (c1, c2) the coordinates of point C. In these coordinates, write down the equations of the three medians of the triangle and find the coordinates of the intersection of these three medians.

Java – Registration of the JWT authentication system via the API

I am writing an authentication system for the first time. Here's how it works: The first client must provide proof of authorization within the authorization header such as {Authorization: & # 39; Basic & # 39; + Proof of Entitlement} via the API. I encoded the credential with the Base64 encoder (& # 39; username: password & # 39;). If authentication is successful, a JWT token is placed in response headers such as {authorization: & # 39; carrier & # 39; + JWTToken} returned. Is there any uncertainty about this implementation that I should be concerned with?
Here is my code

//Security config
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Autowired
    private JwtRequestFilter jwtRequestFilter;
    @Autowired
    private AccountDetailsService accountDetailsService;
    @Autowired
    private AccountService accountService;

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        // Mock an account for testing purpose
        this.accountService.saveAccount(new Account("pink", passwordEncoder().encode("1234"), 10L));
        auth.userDetailsService(accountDetailsService);
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Override
    @Bean
    public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
    }

    @Override
    protected void configure(HttpSecurity httpSecurity) throws Exception {
        httpSecurity.cors();
        httpSecurity.csrf().disable()
                .authorizeRequests().antMatchers("/api/v1/auth").permitAll().
                        anyRequest().authenticated().and().
                        exceptionHandling().and().sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
                httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);

    }
}

– –

//UserDetailsService implement
@Service
public class AccountDetailsService implements UserDetailsService {
    @Autowired
    private AccountRepository accountRepository;
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        Account account = accountRepository.findByUserName(username);
        if (account == null) {
            throw new UsernameNotFoundException(username);
        }
        return new AccountPrincipal(account);
    }
}

– –

// custom filter for jwt
@Component
public class JwtRequestFilter extends OncePerRequestFilter {
    @Autowired
    private AccountDetailsService accountDetailsService;
    @Autowired
    private JwtUtil jwtUtil;
    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
            throws ServletException, IOException {
        final String authorizationHeader = request.getHeader("Authorization");
        String username = null;
        String jwt = null;

        if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) {
            jwt = authorizationHeader.substring(7);
            System.out.println(jwt);
            username = jwtUtil.extractUsername(jwt);
        }

        if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {

            UserDetails accountDetails = this.accountDetailsService.loadUserByUsername(username);

            if (jwtUtil.validateToken(jwt, accountDetails)) {

                UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(
                        accountDetails, null, accountDetails.getAuthorities());
                usernamePasswordAuthenticationToken
                        .setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
                SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
            }
        }

        chain.doFilter(request, response);
    }

}

– –

// Jwt object for creating and validating jwt
@Service
public class JwtUtil {

    private Key SECRET_KEY = Keys.secretKeyFor(SignatureAlgorithm.HS512);
    public String extractUsername(String token) {
        return extractClaim(token, Claims::getSubject);
    }

    public Date extractExpiration(String token) {
        return extractClaim(token, Claims::getExpiration);
    }
    public  T extractClaim(String token, Function claimsResolver) {
        final Claims claims = extractAllClaims(token);
        return claimsResolver.apply(claims);
    }
    private Claims extractAllClaims(String token) {
        return Jwts.parser().setSigningKey(SECRET_KEY).parseClaimsJws(token).getBody();
    }

    private Boolean isTokenExpired(String token) {
        return extractExpiration(token).before(new Date());
    }

    public String generateToken(UserDetails userDetails) {
        Map claims = new HashMap<>();
        return createToken(claims, userDetails.getUsername());
    }

    private String createToken(Map claims, String subject) {

        return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
                .setExpiration(new Date(System.currentTimeMillis() + (1000 * 60 * 60 * 10)))
                .signWith(SECRET_KEY).compact();

    }
    public Boolean validateToken(String token, UserDetails userDetails) {
        final String username = extractUsername(token);
        return (username.equals(userDetails.getUsername()) && !isTokenExpired(token));
    }
}

– –

// Controller for authentication
@RestController
@RequestMapping("/api/v1/")
public class AuthenticationController {
    @Autowired
    private AccountDetailsService accountDetailsService;
    @Autowired
    private AuthenticationManager authenticationManager;
    @Autowired
    private JwtUtil jwtTokenUtil;
    @RequestMapping(value = "/auth", method = RequestMethod.POST)
    public ResponseEntity getAuthenticate(@RequestHeader("Authorization") String authorization) throws Exception{
        String encodedCredentials = authorization.substring(6);
        byte() decodedCredentialByte = Base64.getDecoder().decode(encodedCredentials);
        String() decodedCredentialString = new String(decodedCredentialByte).split(":");
        System.out.println(decodedCredentialString(0) + ":" + decodedCredentialString(1));
        try {
            authenticationManager.authenticate(
                    new UsernamePasswordAuthenticationToken(decodedCredentialString(0), decodedCredentialString(1))
            );
        }
        catch (BadCredentialsException e) {
            throw new Exception("Incorrect username or password", e);
        }

        final UserDetails userDetails = this.accountDetailsService.loadUserByUsername(decodedCredentialString(0));
        final String jwt = "Bearer " + jwtTokenUtil.generateToken(userDetails);
        HttpHeaders headers = new HttpHeaders();
        headers.add(HttpHeaders.AUTHORIZATION, jwt);
        return new ResponseEntity<>(headers ,HttpStatus.OK);
    }
}

– –

// Account entity and account principal
@Entity
@Table(name = "Account")
public class Account {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long accountId;
    private String userName;
    private String passWord;
    private Long nuggerPoint;

    public Account(){

    }
    public Account(String username, String password, Long nuggerpoint){
        this.userName = username;
        this.passWord = password;
        this.nuggerPoint = nuggerPoint;
    }
    public Long getAccountId(){
        return accountId;
    }
    public void setAccountId(Long accountId){
        this.accountId = accountId;
    }
    public String getUserName(){
        return this.userName;
    }
    public void setUserName(String userName){
        this.userName = userName;
    }
    public String getPassword(){
        return this.passWord;
    }
    public void setPassword(String password){
        this.passWord = password;
    }
    public Long getNuggerPoint(){
        return this.nuggerPoint;
    }
    public void setNuggerPoint(Long nuggerPoint){
        this.nuggerPoint = nuggerPoint;
    }
}
public class AccountPrincipal implements UserDetails {
    private Account account;
    public AccountPrincipal(Account account) {
        this.account = account;
    }
    @Override
    public Collection getAuthorities() {
        return new ArrayList<>();
    }

    @Override
    public String getPassword() {
        return this.account.getPassword();
    }

    @Override
    public String getUsername() {
        return this.account.getUserName();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}

Large system of implicit differential equations

We try to solve a large system of implicit differential equation systems for complex variables $ boldsymbol { alpha} left (t right) $ and $ boldsymbol { lambda} left (t right) $. The system consists of two types of equations. The first equation (Equation 1) is
$$ sum_ {j} dot { alpha} _ {j, n} S_ {ij} + sum_ {j} alpha_ {j, n} S_ {ij} sum_ {rh} left ( dot { lambda} _ {j, rh} L_ {ijrh} – dot { lambda} _ {j, rh} ^ { star} frac {1} {2} lambda_ {j, rh} right) = Gamma_ {in} , $$

free for each couple $ i, n $ Indices, with $ dot {x} left (t right) $ a time derivative of $ x left (t right) $and the second equation (Equation 2) is

$$ sum_ {j, n} dot { alpha} _ {j, n} alpha_ {i, n} ^ { star} S_ {ij} lambda_ {j, kq} + sum_ {j, n} alpha_ {i, n} ^ { star} alpha_ {j, n} S_ {ij} left ( dot { lambda} _ {j, kq} + sum_ {rh} dot { lambda} _ {j, rh} L_ {ijrh} lambda_ {j, kq} – sum_ {rh} dot { lambda} _ {j, rh} ^ { star} frac {1} {2} lambda_ {j, rh} lambda_ {j, kq} right) = Theta_ {ikq} , $$

for every triple of $ i, k, q $ Indices.

The typical dimensions of $ boldsymbol { alpha} left (t right) $ is $ 10 times5 $ and $ 10 times50 times5 $ to the $ boldsymbol { lambda} left (t right) $So the total number of equations is in thousands. The typical initial variable values ​​are $ boldsymbol { alpha} left (0 right) = 1 $ and $ boldsymbol { lambda} left (0 right) = 0 $ For all indices, the solution of the system of equations remains problematic even for small dimensions, since the system of equations becomes rigid:

nEL = 3;
nMUL = 2;
nBAT = nEL;
nMOD = 1;

Define variable tables according to which we want to solve:

a = Table((Alpha)(i, n)(t), {i, nMUL}, {n, nEL});
l = Table((Lambda)(i, r, h)(t), {i, nMUL}, {r, nBAT}, {h, nMOD});
ac = Table((Alpha)c(i, n)(t), {i, nMUL}, {n, nEL});
lc = Table((Lambda)c(i, r, h)(t), {i, nMUL}, {r, nBAT}, {h, nMOD});

and auxiliary variables and functions needed to construct Equation 1 and Equation 2:

(Gamma) = Table((CapitalGamma)(i, n), {i, nMUL}, {n, nEL}); 
(Theta) = Table((CapitalTheta)(i, k, q), {i, nMUL}, {k, nBAT}, {q, nMOD});
(Omega)(r_Integer?Positive, h_Integer?Positive) := 25*h /; (r <= nBAT) && (h <= nMOD)
g(n_Integer?Positive, r_Integer?Positive, h_Integer?Positive) := (1/50)*n /; (n <= nEL) && (r <= nBAT) && (h <= nMOD)
J(n_Integer?Positive, m_Integer?Positive) := 1 + KroneckerDelta(n, m)*(5*n - 1) /; (n <= nEL) && (m <= nEL)
S(i_Integer?Positive, j_Integer?Positive) := Exp(Sum((Lambda)c(i, k, q)(t)*(Lambda)(j, k, q)(t) - (1/2)*(Abs((Lambda)(i, k, q)(t)) + Abs((Lambda)(j, k, q)(t))), {k, nBAT}, {q, nMOD})) /; (i <= nMUL) && (j <= nMUL)
L(i_Integer?Positive, j_Integer?Positive, r_Integer?Positive,h_Integer?Positive) := (Lambda)c(i, r, h)(t) - (1/2)*(Lambda)c(j, r, h)(t) /; (i <= nMUL) && (j <= nMUL) && (r <= nBAT) && (h <= nMOD)
A(i_Integer?Positive, j_Integer?Positive, r_Integer?Positive, h_Integer?Positive) := (Omega)(r, h)*(Lambda)c(i, r, h)(t)*(Lambda)(j, r, h)(t) /; (i <= nMUL) && (j <= nMUL) && (r <= nBAT) && (h <= nMOD)
B(i_Integer?Positive, j_Integer?Positive, r_Integer?Positive,h_Integer?Positive) := -(Omega)(r,h)*((Lambda)c(i, r, h)(t) + (Lambda)(j, r, h)(t)) /; (i <= nMUL) && (j <= nMUL) && (r <= nBAT) && (h <= nMOD)
(CapitalGamma)(i_Integer?Positive,n_Integer?Positive) := -I*Sum(Sum((Alpha)(j, m)(t)*S(i, j)*J(n, m), {m,nEL}) + (Alpha)(j, n)(t)*S(i, j)*Sum((A(i, j, r, h) + g(n, r, h)*B(i, j, r, h)), {r, nBAT}, {h,nMOD}), {j, nMUL}) /; (i <= nMUL) && (n <= nEL)
(CapitalTheta)(i_Integer?Positive, k_Integer?Positive,q_Integer?Positive) := -I*Sum((Alpha)c(i, n)(t)*(Alpha)(j, m)(t)*S(i, j)*J(n, m)*(Lambda)(j, k, q)(t), {j, nMUL}, {n, nEL}, {m, nEL}) - I*Sum((Alpha)c(i, n)(t)*(Alpha)(j, n)(t)*S(i, j)*((Omega)(k,q)*((Lambda)(j, k, q)(t) - g(n, k, q)) + (Lambda)(j, k,q)(t)*Sum((A(i, j, r, h) + g(n, r, h)*B(i, j, r, h)), {r,nBAT}, {h, nMOD})), {j, nMUL}, {n, nEL}) /; (i <= nMUL) && (k <= nBAT) && (q <= nMOD) 
(CapitalGamma)c(i_Integer?Positive, n_Integer?Positive) := I*Sum(Sum((Alpha)c(j, m)(t)*S(j, i)*J(n, m), {m,nEL}) + (Alpha)c(j, n)(t)*S(j, i)*Sum((A(j, i, r, h) + g(n, r, h)*B(j, i, r, h)), {r, nBAT}, {h,nMOD}), {j, nMUL}) /; (i <= nMUL) && (n <= nEL)
(CapitalTheta)c(i_Integer?Positive, k_Integer?Positive,q_Integer?Positive) := I*Sum((Alpha)(i, n)(t)*(Alpha)c(j, m)(t)*S(j, i)*J(n, m)*(Lambda)c(j, k, q)(t), {j, nMUL}, {n, nEL}, {m, nEL}) +I*Sum((Alpha)(i, n)(t)*(Alpha)c(j, n)(t)*S(j, i)*((Omega)(k,q)*((Lambda)c(j, k, q)(t) - g(n, k, q)) + (Lambda)c(j, k, q)(t)*Sum((A(j, i, r, h) + g(n, r, h)*B(j, i, r, h)), {r,nBAT}, {h, nMOD})), {j, nMUL}, {n, nEL}) /; (i <= nMUL) && (k <= nBAT) && (q <= nMOD)

Create tables from Equation 1 for indexes $ i, n $ and Equation 2 for indexes $ i, k, q $::

eq1 = Flatten(Table(Sum(D((Alpha)(j, n)(t), t)*S(i, j), {j, nMUL}) + Sum((Alpha)(j, n)(t)*S(i, j)*(Sum(D((Lambda)(j, r, h)(t), t)*L(i, j, r, h) - (1/2)*D((Lambda)c(j, r, h)(t), t)*(Lambda)(j, r, h)(t), {r, nBAT}, {h, nMOD})), {j, nMUL}) == (CapitalGamma)(i, n), {i, nMUL}, {n, nEL}));
eq2 = Flatten(Table(Sum(D((Alpha)(j, n)(t), t)*(Alpha)c(i, n)(t)*S(i, j)*(Lambda)(j, k, q)(t) + (Alpha)c(i, n)(t)*(Alpha)(j, n)(t)*S(i, j)*(D((Lambda)(j, k, q)(t), t) + Sum(D((Lambda)(j, r, h)(t), t)*L(i, j, r, h)*(Lambda)(j, k, q)(t) - (1/2)*D((Lambda)c(j, r, h)(t), t)*(Lambda)(j, r, h)(t)*(Lambda)(j, k, q)(t), {r, nBAT}, {h, nMOD})), {j, nMUL}, {n, nEL}) == (CapitalTheta)(i, k, q), {i, nMUL}, {k, nBAT}, {q, nMOD}));

Building a system to be solved. To have an equal number of equations and unknowns $ alpha (t), lambda (t), alpha ^ * (t), lambda ^ * (t) $we also need to take a complex conjugate of Equation 1 and Equation 2:

allEqs = Join(eq1, eq2, eq1 /. {(Alpha) -> (Alpha)c, (Alpha)c -> (Alpha), (Lambda) -> (Lambda)c, (Lambda)c -> (Lambda), (CapitalGamma) -> (CapitalGamma)c}, eq2 /. {(Alpha) -> (Alpha)c, (Alpha)c -> (Alpha), (Lambda) -> (Lambda)c, (Lambda)c -> (Lambda), (CapitalTheta) -> (CapitalTheta)c});

Define a list of initial values. Again, double the number of values ​​by using a complex conjugate:

initCond1 = Flatten(Table((Alpha)(j, n)(0) == 1, {j, nMUL}, {n, nEL}));
initCond2 = Flatten(Table((Lambda)(i, k, q)(0) == 0, {i, nMUL}, {k, nBAT}, {q, nMOD}));

Define a list of variables $ alpha (t), lambda (t), alpha ^ * (t), lambda ^ * (t) $ to solve for:

vars1 = Flatten(Table((Alpha)(j, n), {j, nMUL}, {n, nEL}));
vars2 = Flatten(Table((Lambda)(i, k, q), {i, nMUL}, {k, nBAT}, {q, nMOD}));
allVars = Join(vars1, vars2, vars1 /. {(Alpha) -> (Alpha)c}, vars2 /. {(Lambda) -> (Lambda)c});

Trying to solve:

allEqsWithCond = Join(allEqs, initCond1, initCond2, initCond1 /. {(Alpha) -> (Alpha)c},initCond2 /. {(Lambda) -> (Lambda)c});
sol1 = NDSolveValue(allEqsWithCond, allVars, {t, 0, 1});

and get an error:

Enter the image description here

Trying to solve with the residual method:

sol2 = NDSolveValue(allEqsWithCond, allVars, {t, 0, 1}, Method -> {"EquationSimplification" -> "Residual"});

but now get two errors:

Enter the image description here
Enter the image description here

We managed to fix the first bug by splitting variables $ alpha (t), lambda (t), alpha ^ * (t), lambda ^ * (t) $ in real and imaginary parts of $ alpha (t), lambda (t) $However, the second error persists. We would be interested in the best approach to solving these equations.

Data flow diagram for patient information system for a hospital

I have an example of a DFD for a patient information system implemented in a particular hospital. The following illustration shows the level 0 diagram (if we consider that the first level is the context diagram, then the second level is the level 0 diagram and so on).

Enter the image description here

In this system, patients can search and make appointments. My problem is related to the flow of data that is labeled with the patient name that the process directs to make appointments for the database patients. I don't understand why we have such data in our system. In other words, in which scenario does the process appointment send the patient name to the patient database? The process already sends the patient name. Maintain patient information!