Update the actual file associated with a file entity while keeping the fid?

Media module provides a generic.png file that it copies into /sites/default/media-icons/generic. That file is used on my site ~300 times, but I’d like to replace it with another PNG. Is it possible to replace the actual file that is associated with that file entity? Ideally I’d keep the generic.png name, but I can use an updated file name if needed.

I’ve tried simply replacing the file in /sites/default but that had no effect.

Keeping CLI tools in sync on Mac clients

I manage around 10 Macs in a network. We have a lot of scripts that rely on tools like ffmpeg, 7z, jpegoptim, etc. I use mostly homebrew to install and update the tools. So far homebrew is running on each machine and it’s kind of hard to keep everything in sync. Ideally I would do all the installing / updating on one machine (server) and all the clients would sync it to their local drive. Another option would be to share all bins on a public folder and add this to PATH. What is best practice?

Copy Paste Word To Excel Keeping Formatting

I’m transferring data from a table in Word To Excel via VBA. I want to keep all the formatting (carriage returns, bullet points etc)

When pasting a word table cell value normally or using paste special excel automatically distributes it between cells based on where the carriage returns are and removes some of the formatting.

The way to keep the formatting is to put the cursor in the formula bar and paste it there rather than having a cell selected.

However there seems to be no way of programatically accessing the formula bar and pasting what’s on the clipboard.

I tried recording a Macro but that seems to skip how the text is parsed into the formula bar.

Does any one know how to do this?

The only other approach I can think of is to use windows API to literally get the handle of the formula bar and paste that way but I’d rather not!

Can we approximate maps in $W^{1,2}$ while keeping the third derivatives small?

Let $ \mathbb{D}^n=\{ x \in \mathbb{R}^n \, | \, |x| \le 1\}$ be the closed unit ball, and let $ f:\mathbb{D}^n \to \mathbb{R}^n$ be smooth (on the entire closed ball), such that $ \det df>0$ everywhere.

Do there exist smooth maps $ f_k \in C^{\infty}(\mathbb{D}^n ,\mathbb{R}^n)$ such that:

  1. $ f_k \to f$ in $ W^{1,2}$ .
  2. $ \det df_k >0$ on all $ \mathbb{D}^n $ .
  3. $ \|\nabla(\Delta f_k^i)\| \to 0$ in $ L^1$ for every $ 1 \le i \le n$ .

Here $ f_k^i$ refers to the $ i$ -th component of the map $ f_k$ , $ \Delta f_k^i$ is its laplacian, and $ \nabla(\Delta f_k^i)$ is the gradient of $ \Delta f_k^i$ .

Writing this in more geometric terms, I want $ \|\Delta_{h}df_k\|_{L^1}$ to be small, where $ \Delta_{h}$ is the (Euclidean) Hodge-de Rham Laplacian acting on $ \Omega^1(\mathbb{D}^n,\mathbb{R}^n)$ (the space of $ \mathbb{R}^n$ -valued one-forms).

Since $ \Delta_{h}df=(\delta d+d\delta) df=d(\delta df)$ we can identify it with $ \nabla(\Delta f)$ .

My hope is that even though $ \|\Delta_{h}df\|_{L^1}$ may not be zero, we might be able to make $ \|\Delta_{h}df_k\|_{L^1}$ small while still keeping the first derivatives of $ f_k$ close to those of $ f$ .

(i.e. I wonder if we have enough flexibility in the third derivatives while still controlling the first derivatives). Is there any chance for such flexibility?

Keeping associative bracketing in place

The following Mathematica code displays the vertices of a given graph after converting an expression into a suitable format (using heads that are tensor and parallel notation. The labels are displayed at the vertices, but associativity rules are used. How can I prevent this from happening (i.e. how can I keep the brackets when vertices are displayed?

DiplayGraph[g_] :=    With[{vlist = VertexList[g]},      Graph[g, VertexLabels ->       Thread[      vlist -> Map[# /. {ExpProduct -> (ToString[               HoldForm[CircleTimes[##]]] &),            Parallel -> (ToString[               HoldForm[DoubleVerticalBar[##]]] &)} &, vlist]],     EdgeLabelStyle -> Directive[10, Background -> White],     VertexLabelStyle -> Directive[10, Background -> White]]] 

When executing this code on a graph:

DisplayGraph[Graph[{A[1, 2] -> B[2, B[3, 4]]}]] 

the following output is generated:

displaygraph

I would like 2 || 3 || 4 to appear as 2 || (3 || 4) consistent with the parentheses in B[2, B[3, 4]] (i.e. I don’t want the associative removal of the parentheses). Which command can be inserted to ensure this?

Keeping secrets from root on Linux

I am looking for ways to harden a linux system so that even when gaining full root access (through legit or non-legit means), some secrets remain inaccessible. But first a little background.

Many of the different linux security models (SELinux, TOMOYO, etc.) concentrate on limiting what processes can do by policy and making sure they do not need full root access. They aim to keep any exploits contained so other parts of the system can not be compromised. However, it seems that these do not directly tackle the case where full root has already been gained – or, even further, keeping secrets from the valid root user. It seems that usually these can be just turned off by the real root at runtime.

Another approach is to limit the ways of gaining full unrestricted root – for example not allowing all access to a remotely connected root user, but requiring a login from the physical console. However, this is not my goal either – the assumption is that any such protections have been overcome already and the root is as legit as it can be.

It is obvious that anyone with physical access to the machine can get everything stored on the harddrive and possibly also everything stored in memory. It is also obvious that if the root user has the power to modify binaries or kernel images, no security promises can be given after reboot. I am only interested in attacks that can be done without rebooting the system.

Also, during the start up process, secrets will most likely be transmitted in through many places and many security critical functions are needed. It is ofcourse great if secrets can be protected during the start up process as well, but what is enough for me is a step during start up where elevated privileges can be dropped and after which there are no ways of regaining them.

So, with these limitations, what are the ways on Linux to prevent the full root user from accessing some secrets?

  • Can there be files on the filesystem that are not accessible even to the full root by any means, but accessible to some processes? Some currently running processes, or even new processes started by the processes currently having access?

  • Can secrets be kept in memory by running processes so that even the full root can not gain access to them by any means? Can these secrets be transmitted to new processes by some means that the root cannot affect?

This is a hard question to write so that I get answers relevant to me, so I will try to edit the question to be more specific if necessary.


Obvious things coming to mind that need to be limited would be:

  • Disable access to /proc/mem

  • Disable access to /proc/<pid>/mem

  • Disable access to /proc/<pid>/fd/*

  • Disable module loading (only after some modules have been loaded, preferably)

  • Disable ptrace access to any process

Keeping scaled internal display when plugging in a new external monitor

I have a problem caused by two things:

  1. I use a ‘scaled’ setting for my Macbook; one down from normal so that it ‘looks like 1440 × 900’.
  2. I work in a hot desking office on a different desk most days.

Every time I plug into a new monitor I have to do the dance of going into display settings and rearranging the monitors; this is fine. Unfortunately it also changes my scaling setting for the internal monitor.

Is there any way I can force the internal scaling to be consistent? Just because I use different external monitors doesn’t mean that I want the internal display’s settings changed.

(Macbook Pro 15″ 2017, macOS 10.14.4, various mostly Dell monitors)

Configure haproxy to only disable affected services, while keeping it easy to take down entire box quickly

We are using haproxy for loadbalancing across several machines. Our application includes a number of services, each deployed as an independent war in tomcat, that can be requested. Currently I have a single backend that get’s loadbalanced to, which means if any one server starts returning errors the entire box will be considered ‘bad’ and removed from the load balancer.

so for example if box A were to start throwing bad responses when someone makes requests to https://myAwsomeApp/foo/ Then box A would be removed entirely from the load balancer, meaning that a request to https://myAwsomeApp/bar/ would never get routed to box A, even if that separate service was functional and could still support requests to it.

I want to change this so that each of the services are independent, so that even if the foo app goes down on box A then request to /bar will still be routed to A.

I know I could do this using ACl to cause requests to https://myAwsomeApp/foo to go to a difference backend then request to https://myAwsomeApp/bar; but that seems a little silly since the two backends would have the exact same hosts in them.

I also want a quick way to take an entire box down at once for when we deploy new code or have issues at specific sites, and having to modify 10 backends (one for each service the box supports) seems annoying and prone to errors where one backend is missed.

So is there a cleaner way to have my cake and eat it to? To allow haproxy to disable only services that are proven to be bad, but also make it easy to turn off all services on a box in one go.

How can i have an Hhibernate entity field keeping track of the number of elements in a List relation attribute?

I have the next entities structure in the project:

@Entity public class A {     // Some attributes     @OneToMany(mappedBy="a")     private List<B> bs; } public class B {     // Some attributes     @ManyToOne     private A a; } 

And I want to add an attribute on A to keep track of the number of bs that are related to A. Something like this:

@Entity public class A {     // Some attributes     @OneToMany(mappedBy="a")     private List<B> bs;      private Integer numberOfBs; } public class B {     // Some attributes     @ManyToOne     private A a; } 

The main reason is the efficiency, because I’m also looking the way of keeping track of the mean value from some B attribute that also are related to A.

I would also like to know how to do it with a ManyToMany relation.

I’ve looked for some information and I saw the Hibernate entity lifecycle callbacks as @PrePersist, @PostUpdate… but I’m not sure how to implement it . It would be great if this number is only recalculated when a new B is added to bs List.

Is there any way of doing this?