text:
Q: Orthogonality of Instruction Set Architecture I am studying the difference between CISC and RISC recently, and I've encountered into the term "Orthogonality". After doing some research, my understanding so far is that there are two "axes", addressing modes & operations, which are independent of each other, so it produces a maximum number of (#addressing modes * #operations) instructions in the ISA.
For CISC machine, which is a register-memory architecture, operands may come from register or memory and RISC a register-register(or load-store) one on the contrary.
So, what's the role of orthogonality playing in these two ISA? Is CISC more orthogonal than RISC or vice versa?
As the wiki describes, "Modern CPUs often simulate orthogonality in a preprocessing step before performing the actual tasks in a RISC-like core. This "simulated orthogonality" in general is a broader concept, encompassing the notions of decoupling and completeness in function libraries, like in the mathematical concept: an orthogonal function set is easy to use as a basis into expanded functions, ensuring that parts don't affect another if we change one part." What does this paragraph mean? What is the preprocessing step, does it have anything to do with the microcode?
Any explanation are appreciated! Thanks a lot!

A: Maximizing total choices of possible instructions like a CISC is generally not what's meant.  Instead it's more about being a simpler compiler target, without complex interactions in what makes an instruction legal or not.  RISC machines are often highly orthogonal, and designed with being a compiler target in mind, not human programmers.

My understanding of the term is that orthogonality is more about any register being usable in any case where any other register is usable.  Unlike x86 shl reg, cl where variable-count shifts require a specific register.  (I know this is a RISC-V question, but the examples of non-orthogonality I know of come from other ISAs, primarily x86.)
And definitely not like 8086 (before 386), where if you needed to multiply, one of the operands had to be in the accumulator, AL or AX.  And sign-extension was also only available there.  386 introduced movsx reg, r/m8 and r/m16.  (And movzx, allowing easy and more efficient zero-extending of a byte from memory into SI or DI, without having to load 2 bytes and and si, 0x00ff.)
Even worse, 16-bit addressing modes only allow a few registers in very limited ways: [bp|bx] + [si|di] + disp0/8/16, vs. 32-bit addressing modes allowing stuff like lea eax, [ecx + ecx + 3] to use the same register twice, or address memory relative to the stack pointer without having to copy it to the base pointer (BP) register.
Or if some memory operands can use a certain addressing mode, can all memory operands use it?  AArch64 ldp/stp (load-pair/store-pair of registers) I think has fewer available addressing modes than single-register loads, because it needs 5 extra bits for a second register number.  Unlike ARM32 ldrd where the pair of registers is two contiguous registers, starting with an even number.
In general, the less interaction there is between a choice of one thing (like instruction) and the possible choices for another (a register), the more orthogonal.
One of the major benefits with this is being a simple compiler target.  The most optimal code can more often be found with a greedy algorithm that only takes into a account one thing at a time, not interlocking tradeoffs.  Not like x86-64 "if I use ECX instead of R9d for this variable, that'll save bytes in multiple instructions not needing REX prefix, but later mean I need an extra mov to copy a register for a shift count".  (x86 BMI2 introduced variable-count shifts that can use a count from any register, like shlx ebx, eax, r15d)
Or far worse targeting 8086 or 286, where 16-bit addressing modes impose a lot more constraints on register allocation.  And you'd more often you'd want to use instructions that needed their operands in specific registers, especially the accumulator.
But if you're not worried about every byte of code size, x86-64 is a fairly orthogonal ISA, usually you don't need to care about which register you use for what.  One change in that direction beyond 386's important changes was making the low byte of every register addressable, like bpl, spl, sil, dil  as the low bytes of RBP, RSP, RSI, RDI.  (But those require REX prefixes, overlapping encodings with AH/CH/DH/BH which are only usable in instructions without REX prefixes.)

Another example of non-orthogonality is x86's notorious integer SIMD extensions, MMX and SSE2.  Want to do minimum of unsigned integers 16 bytes at a time? In SSE2 we have pminub for unsigned byte elements.  And pminsw, signed 16-bit elements.  But no other combination of size and signedness until SSE4.1, several years later, which filled in the gaps allowing signed bytes and u16, as well as i32 and u32.  And then AVX-512 added i64 and u64.  Every min available always had a corresponding max, but other than that, SSE2 was highly non-orthogonal in that and many other ways, including signed/unsigned saturating add/sub, and pack of wider to narrower elements with signed or unsigned saturation.  And FP vs. integer shuffles, e.g. there's no integer equivalent to shufps that takes two elements from one vector, two from another, using an immediate control operand.  Fortunately for shuffles you can use FP shuffles on integer data.
x86 SIMD is still not very orthogonal in many ways, for example in integer multiply where not all combinations of element size are available for everything; 16-bit has 16x16 => 16-bit low half, signed high half, or unsigned high half.  (And a widening multiply and horizontal-add, pmaddwd).  32-bit has signed and unsigned widening 32x32 => 64-bit, and with SSE4.1 also non-widening.  8-bit only has a multiply and horizontal-add where one operand is treated as signed, the other as unsigned.
Again, if I'm picking on x86 a lot, it's because it's what I know.  And Intel painted a huge "kick me" sign on their back when they designed MMX and SSE2, only taking some steps to fix things later with SSE4.1. (I'm sure there are reasons for some of those choices, including transistor budget and opcode coding-space in x86's notoriously cramped machine-code.)  But a lot of programs don't want to assume SSE4.1 as a requirement to run at all, even now, over a decade since the first SSE4.1 CPUs.  Most other SIMD ISAs are more orthogonal than x86, like ARM NEON or PowerPC AltiVec.
Anyway, in general, it's more orthogonal if all operations are available in all combinations of size and signedness that exist for any operation.  This isn't always a big deal for compilers per-se, more for humans not realizing that a compiler could make their code faster if this variable was unsigned or something.

Modern CPUs often simulate orthogonality in a preprocessing step before performing the actual tasks in a RISC-like core

That sounds like they're talking about decoding to uops, but I don't see how that would gain orthogonality.
Unless they're counting the concept of any instruction allowing a memory source operand as being more orthogonal.  Normally you wouldn't, being a load/store architecture is basically a fixed constraint that doesn't make other things harder.
But if you do consider that more orthogonal, then yes, decoding add eax, [rdi] to 2 uops lets it run on a back-end that separates the load work from the store work, like a RISC.

A: I hadn't heard this term orthogonal instruction set before, however:
The VAX is perhaps the epitome of CISC.  The VAX supports many addressing modes, ranging from register itself, to memory specified by various indexing computations (some including pointer advancement, so as to do *p++ or *--p).
The VAX allows all addressing modes for all operands of any instruction.  Further, the VAX allows both 2 operand and 3 operand instructions, so addl2 is operand2 += operand1, and addl3 is operand3 = operand1 + operand2.
Basically it can encode a lot of stuff in a single instruction, so we can do for example, a[i] = *p++ + b[j]; in one instruction, assuming a, b, i, j, and p are in registers.
Other CISC-style processors limit the encoding, for example, so that we can only do two-operand instructions (no 3 operand), and some even limit the 2nd operand to a register, so only one memory operand.  I believe this is what they're getting at with the term orthogonal or not.
Meanwhile, a RISC processor instead follows a load/store architecture.  Access to memory is not allowed for any operand, but rather only via load and store instructions, and only with those instructions are there addressing modes.  Most all arithmetic operations (except the add for addressing) happen between registers alone.  (In some sense the RISC philosophy has an orthogonality since all arithmetic operations work on registers alone.)
I don't think the term orthogonality is of high value.  I wouldn't dwell on the term itself, but rather take away from that article the comparison between CISC ala VAX, vs. others CISC, vs. RISC.

@Peter also makes a good points, such as that certain registers being hard code (i.e. an implicit source/target) in some architectures for some instructions, which reduces orthogonality.
By that point I might stress that RISC architectures generally don't hard code registers, though MIPS hard codes the return address register ($31) for the jal instruction whereas RISC V does not ($sp and $ra are hard coded but only in the compressed instruction extension).  Whereas some CISC architectures (except VAX) hard code more registers.
The MC68000 divides the registers into two sets of 8: addressing registers and data registers, which helps encoding by providing 16 registers with only 3-bit register fields, but also limits what you can do with them (and there aren't enough address registers, since one is the stack pointer and another the global pointer, leaving only 6).
CISC architecture often support byte vs. word sized arithmetic, whereas RISC architectures usually support only word sized arithmetic, so if you want byte, you have to simulate it (i.e. with range check or other).


text:
Q: Query Firebase based on field and return parent in Android I'm looking to search through my Firebase database and find a field:value pairing that matches my query, and then return either that parent's key, or the parent object so that I may grab other information as well.
The Firebase database looks something like this:
Events{
  -KiXlIGhB6k-HpCKfO3n{
    name:"Breakfast at Tiffany's",
    owner:"Tim",
    startTime:{
      startHour:1,
      startMinute:30
    },
    ...
  },
  -dFgfh8Efa-Hpwe6Goqp0{...}
}

I'm currently attempting:
public void importSchedule(String ownerName){
DatabaseReference events =
FirebaseDatabase.getInstance().getReference("Events"); //Inside the Events list

Query allOwnersEvents = events.equalTo(ownerName); //Find events equalTo ownerName provided

allOwnersEvents.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        for (DataSnapshot post : dataSnapshot.getChildren()) {
           // This is where the parent's could be queried, all events belonging to an "owner" should be cycled through
        }
    }
    public void onCancelled(DatabaseError databaseError) {}
});

However when placing a break-point inside the for loop, it is never triggered. I'm wondering if I'm attempting the query correctly or if there's an easier way to accomplish this.

A: It's never triggered because your DatabaseReference is wrong. When you query, you are missing a child. In order to have the correct DatabaseReference please use this code:
    DatabaseReference events = FirebaseDatabase.getInstance().getReference("Events")
    events.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        for(DataSnapshot ds : dataSnapshot.getChildren()) {
            String eventKey = ds.getKey(); //parent key

            DatabaseReference allOwnersEvents = FirebaseDatabase.getInstance().getReference("Events").child(eventKey);
            allOwnersEvents.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    String ownerName = dataSnapshot.child("ownerName").getValue(String.class); //do what you want with ownerName
                }
                public void onCancelled(DatabaseError databaseError) {}
            });
        }
    }
    public void onCancelled(DatabaseError databaseError) {}
});

In which eventId is the unique id generated by the push() method. Hope it helps.

redpajama_set_name: RedPajamaStackExchange


text:
Q: PostScript interface for non-PostScript printers with IPP and IIS? Is it possible to use IPP and IIS to provide a PostScript interface for a printer that does not natively support PostScript?
The aim here is to provide a generic interface for printing over IPP, so that clients can standardize on a single driver (PostScript) instead of having to download drivers for different printers. I could do this with CUPS, but would like to know if it is feasible with IIS, as well.

A: Is there any particular reason that CUPS isn't an option?

A: Ghostscript is available for windows.
This indicates that you may be able to make ghostscript appear to be a local printer.
Which could then be shared.
But I don't think its worth the effort.

A: This article discusses how to set up GhostScript and use it as a printer destination on a Windows machine.  This has a list of various commercial PostScript tools including PostScript rendering software.


text:
Q: Why does 'foo' + false ? 'bar' : 'baz' evaluate to 'bar' I removed the parenthesis from the following ternary:
res.setHeader('Content-Type', 'application/' + (isMap ? 'json' : 'javascript'));

And the test failed with:
Error: expected 'json' to equal 'application/javascript'

At first I thought this is just some wired Node.js issue, but it seems that:
'foo' + false ? 'bar' : 'baz'

Evaluates to 'bar' in Firefox and Chrome.
So my question is:

*

*What happened to the first part of my string.

*Why am I getting the true value of the ternary operation when I'm passing false.

A: The false is first converted to a string and then concatenated to the foo string, since this succeeds, it returns true and you will end up with bar

A: Because you are not passing a FALSE.  You are adding a FALSE object to a string.  In this case, JavaScript would see that as an empty variable.  It's not a boolean, like you're thinking.
There is no actual evaluation going on here to resolve to false, so it will simply return true.

A: 'foo' + false ? 'bar' : 'baz'

concatenating 'foo' + false is evaluating to true because false is treated as a string so string 'foofalse' is true.
its a duplicate and the accepted answer there is a good explanation.
Using the ternary operator with string concatenation


text:
Q: Is there a "medium" \cap? When displaying the intersection symbol in equations, e.g.,
$$Hom(A,B) \cap Hom(B,C)$$

I find that the "cap" is too small; its height is, in fact, subordinate to the surrounding content. On the other hand, \bigcap is entirely too big, dwarfing the surrounding content. This is especially unnecessary if the intersection is not indexed, for example. What is needed is a "medium" cap whose size is somewhere between the big cap and the regular cap. Does such a symbol/construct exist?
Note that similar comments apply to \bigcup and \cup.

A: You can use scalerel from the scalerel package to create one:
\documentclass{article}
\usepackage{scalerel}

\begin{document}
\[ Hom(A,B) \cap Hom(B,C) \]
\[ Hom(A,B) \scalerel{\cap}{Hom(B,C)} \]
\[ Hom(A,B) \mathbin{\scaleobj{1.75}{\cap}} Hom(B,C) \]
\[ Hom(A,B) \mathbin{\scaleobj{0.9}{\bigcap}} Hom(B,C) \]
\[ Hom(A,B) \bigcap Hom(B,C) \]
\end{document}

A: You can use scalebox from the graphicx package to create one:

\documentclass{article}
\usepackage{graphicx}

\newcommand*{\medcap}{\mathbin{\scalebox{1.5}{\ensuremath{\cap}}}}%
\begin{document}
\[ Hom(A,B) \cap    Hom(B,C)\]
\[ Hom(A,B) \medcap Hom(B,C)\]
\[ Hom(A,B) \bigcap Hom(B,C)\]
\end{document}

A: I don't find it to be too small. You can use the same symbol as \bigcap, but not in the "bigger" version, so there's some work to do:
\newcommand*\mcap{\mathbin{\mathpalette\mcapinn\relax}}
\newcommand*\mcapinn[2]{\vcenter{\hbox{$\mathsurround=0pt
  \ifx\displaystyle#1\textstyle\else#1\fi\bigcap$}}}

This is the result of
\[\operatorname{Hom}(A,B)\cap\operatorname{Hom}(B,C)\]

and of
\[\operatorname{Hom}(A,B)\mcap\operatorname{Hom}(B,C)\]

You need \usepackage{amsmath} to use \operatorname and you might want to say
\DeclareMathOperator{\Hom}{Hom}

in the preamble, in order to be able to use \Hom as an abbreviation.


text:
Q: Active Directory: need to authenticate and get the user details in c# I am connecting to AD and checking the username exists and validating the credentials in my local machine and it is working fine.
bool userAuthenticated = false;
var domainName = DomainName;

if (useSSL)
{
    domainName = domainName + ":636";
    ContextOptions options = ContextOptions.SimpleBind | ContextOptions.SecureSocketLayer;

    using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, domainName, null, options, domainuser, domainpassword))
    {
        userAuthenticated = pc.ValidateCredentials(username, password, options);
    }
}
else
{
    using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, domainName))
    {
        userAuthenticated = pc.ValidateCredentials(username, password);
    }
}

return userAuthenticated;

But when the code is deployed in the server it is throwing an error

Invalid username / password

But our team is providing only GMSA account and it is not having the password.
How do I authenticate the credentials and check the username in AD exists or not?


text:
Q: Japan math Olympiad 2013 solution Here is the link to the problem

Given an acute-angled triangle $ABC$, let $H$ be the orthocentre. A circle passing through the points $B,C$ and a circle with a diameter $AH$ intersect at two distinct points $X,Y$. Let $D$ be the foot of the perpendicular drawn from $A$ to line $BC$, and let $K$ be the foot of the perpendicular drawn from $D$ to line $XY$. Show that $\angle{BKD}=\angle{CKD}$.

Here is my photo

Could someone give me the proof with more details? I'm a normal high school student so I'm having a hard time understanding what's going on there.
For me I draw $BZ//XY$ and $BZ$ also intersect $P$, but I don't know whenever it  intersect or not.( sorry I'm not good at explaining it I hope you could take a look at my photo). Then I draw $YP$ and $KP$. For what I want is to prove that $KB=YP$ and $YP=KP$ so $KB=KP$ and since $BZ//XY$ so $\triangle{KBP}$ isosceles and $KD$ is the height so it prove the statement above. But I don't think everything will work as I plan out. So I come here searching for some help

A: Let M be the midpoint of BC.
The circle passing through B, Y, X, C is marked in green with center (G) located on the perpendicular bisector (MG) of BC.

Construct the red circle passing through BKC with center (R). Since BC is also a chord of the red circle, R is located somewhere on MG extended. Let the circle BKC cut XY at Z.
From the facts that (1) M(G)R is part of a diameter of the red circle; (2) K and Z are points on the red circle; and (3) $\angle ZKD = 90^0$, we can say that Z is one extremity of the diameter (RGM extended). Then, when KD extended meets Z(M)(G)R produced at T, T is another extremity of the mentioned diameter.
Therefore, T lies on the perpendicular bisector of BC. This means (chord TB) = (chord TC). This further leads to the result required.


text:
Q: Infinite trigonometry Summation: $ \sum_{k=1}^\infty \left( \cos \frac{\pi}{2k}-\cos \frac{\pi}{2(k+2)} \right) $ I would like to evaluate
$$
\sum_{k=1}^\infty \left( \cos \frac{\pi}{2k}-\cos \frac{\pi}{2(k+2)} \right)
$$
Summation image please view before solving
I saw a pattern and realized the answer will converge and the final summation will be 1-(1/√2) but I am going wrong somewhere .Answer given is 2-(1/√2)
Plz help

A: This may be seen as a telescoping series, one may write for $N\ge1$,
$$
\small{\sum_{k=1}^N\! \left( \cos \frac{\pi}{2k}-\cos \frac{\pi}{2(k+2)} \right)\!=\sum_{k=1}^N \!\left(\! \cos \frac{\pi}{2k}-\cos \frac{\pi}{2(k+1)}\! \right)\!+\!\sum_{k=1}^N\! \left(\! \cos \frac{\pi}{2(k+1)}-\cos \frac{\pi}{2(k+2)} \!\right)}
$$ giving
$$
\small{\sum_{k=1}^N \! \left( \cos \frac{\pi}{2k}-\cos \frac{\pi}{2(k+2)} \right)=\!\!\left(\cos \frac{\pi}{2}-\cos \frac{\pi}{2(N+1)}\right)\!+\!\left(\cos \frac{\pi}{4}-\cos \frac{\pi}{2(N+2)}\right)}
$$ then by letting $N \to \infty$, one gets
$$
\sum_{k=1}^\infty \left( \cos \frac{\pi}{2k}-\cos \frac{\pi}{2(k+2)} \right)=(0-1)+\left(\cos \frac{\pi}{4}-1\right)
$$I think you can take it from here.


text:
Q: Sudoer inside schroot (on Debian) This is a typical schroot.conf configuration I use:
[label]
description=whatever
type=directory
personality=linux
preserve-environment=true
directory=/wherever
users=UserForSchrootOnly
profile=desktop_no_tmp

No root-users directive.
Separate home directories for schroot env, not using host's /home.
I login with host OS's UserForSchrootOnly user to these schroot environments. I usually add this user to the /etc/sudoers.d/someConf file inside schroot, with a line,
UserForSchrootOnly ALL=(ALL:ALL) ALL

One of my goals of this setup is to have a quite isolated environment (not for audit kind of strict isolation, but efficient in practice), both through schroot and by using an OS user only for this purpose and nowhere else. On the other hand, for practical reasons it's much easier to have this dedicated user to be sudoer also, inside the schroot env of course.
A use case is to run an untrusted closed source app.
My concern is:
Since UserForSchrootOnly user is a sudoer inside the schroot env, is it possible to be any compromise of security for the host system due to this? Any way to use sudo elevation inside schroot env, to access something outside of schroot or outside UserForSchrootOnly's home dir on the host system?
Man page of schroot.conf mentions that root access to chroot is a serious risk; I'm not concerned about user's misbehaviour. My concern is about the untrusted, closed source app, taking advantage of the sudoer user it runs.

I'd like to point out that although this seems like an ideal scenario for a sandbox like firejail, I've failed to run some apps with it, even adding the --no-profile parametre. Also other scenarios include apps that need more recent libs, so I need to setup a Debian Testing or Ubuntu schroot env to run the untrusted app inside.


text:
Q: How do I initiate particles to grow from anywhere on stage upon mouseClick? I want to be able to create new particles from wherever I click on stage. I'm just stuck on adding the mouse portion and I've tried to add/pass parameters and I always get errors while I try setting the parameters. Any suggestions?
This is my current code:
float parSpeed = 1; //speed of particles
int   nParticles = 1000; //# of particles
Particle[] particles;

void setup() {
  size(700,700); //size of image (8.5 x 11 @ 300px) is 3300,2550)
  frameRate(60); //framerate of stage
  background(0); //color of background
  particles = new Particle[nParticles];

//start particle array
for(int i=0; i<nParticles; i++) {
    particles[i] = new Particle();
  }
}

void draw() {
  fill(0,0,0,5); //5 is Alpha
  rect(0,0,width,height); //color of rectangle on top?
  translate(width/2, height/2); //starting point of particles

//start particle array
  for(int i=0; i<nParticles; i++) {
    particles[i].update();
    particles[i].show();
  }
}

//Particle Class
class Particle {
  PVector pos; //position
  float angle; //angle
  float dRange; //diameter range
  float dAngle; //beginning angle?
  color c; //color

  Particle() {
    pos = new PVector(0,0);//new position for the particles.
    angle  = 1; //controls randomization of direction in position when multiplied
    dRange = 0.01; // how big of a circle shold the particles rotate on
    dAngle = 0.15; // -- maximum angle when starting
    c = color(0,0,random(100, 255)); //set color to random blue
  }

  void update() {
    float cor = .25*dRange*atan(angle)/PI;
    float randNum = (random(2)-1)*dRange-cor;  //Random number from (-dRange, dRange)
    dAngle+=randNum;                       //We don't change the angle directly
                                       //but its differential - source of the smoothness!

    angle+=dAngle;                         //new angle is angle+dAngle -- change angle each frame

    pos.x+=parSpeed*cos(angle);//random direction for X axis multiplied by speed
    pos.y+=parSpeed*sin(angle);//rabdin durectuib for y axis multiplied by speed
  }

void show() {
    fill(c); //fill in the random color
    noStroke(); //no stroke
    ellipse(pos.x,pos.y,10,10); //make the shape
    smooth(); //smooth out the animation
  }
}

void keyPressed() {
  print("pressed " + int(key) + " " + keyCode);
  if (key == 's' || key == 'S'){
    saveFrame("image-##.png");
  }
}

void mouseReleased() {
   print("mouse has been clicked!");
}

A: Overwrite the mouseReleased() method:
In there you'll need to:

*

*capture the position of the mouse

*create the new particle

*update the position of the newly created particle.

*add it to the array (the particle system)

This may look simple but you'll have to keep in mind an array cannot change sizes. I would advise that you create a ParticleSystem class that takes care of adding and removing particles from the system.
Edit: You might want to consider using an ArrayList instead of an Array of Particles. Have a look at this
In pseudo code this would look like this:
void mouseReleased() {
    int particleX = mouseX;
    int particleY = mouseY;

    Particle P = new Particle();
    P.setPos ( new PVector ( particleX, particleY ) ); // this needs to be implemented

    ParticleSystem.add ( P ); // this needs to be implemented
}

I hope this will be a good start.
AH


text:
Q: Desktop and Documents in Finder In the Finder of my new Mac, there are two things I don't understand:
1) in the sidebar Desktop and Documents are placed under iCloud.
2) the Desktop and Documents folders are not shown in Macintosh HD ==> Users ==> SoftTimur in Finder, even though in a terminal we can see that they are physically in the folder of SoftTimur.
Does anyone know why it is like that?
PS: ls -lO returns
total 0
drwx------@  5 softTimur  staff  -  160 Dec 21 10:50 Applications
drwx------@  5 softTimur  staff  -  160 Dec 22 22:29 Applications (Parallels)
drwx------@ 13 softTimur  staff  -  416 Dec 22 17:41 Desktop
drwx------@  5 softTimur  staff  -  160 Dec 22 17:41 Documents
drwx------+ 20 softTimur  staff  -  640 Dec 22 21:53 Downloads
drwx------+ 63 softTimur  staff  - 2016 Dec 21 20:47 Library
drwx------+  5 softTimur  staff  -  160 Dec 22 17:41 Movies
drwx------+  6 softTimur  staff  -  192 Dec 22 17:41 Music
drwx------   4 softTimur  staff  -  128 Dec 22 22:45 Parallels
drwx------+  6 softTimur  staff  -  192 Dec 22 17:41 Pictures
drwxr-xr-x+  4 softTimur  staff  -  128 Dec 20 16:41 Public
drwxr-xr-x   5 softTimur  staff  -  160 Dec 22 22:34 Startup

PS: in Mac Finder:

A: It is like that because your Documents and Desktop folders are stored in iCloud. Thus, they are no longer shown in your Home folder (the folder with your username) as they are now in the iCloud one.
This mean that files in Documents and Desktop are stored both locally on your Mac and online on iCloud as long as there is enough space available on your disk.  If your computer runs out of space or for files you have not opened in a while, they are deleted from your disk but remain available online for a download when needed.
You can remove this feature at any time in system pref.
PS: I'not an expert with the terminal but I guess artifacts could be aliases to those folders or maybe your Mac shows Documents & Desktop above iCloud by convenience.


text:
Q: What does C++ iostreams have to offer in comparison with the C stdio library?
Possible Duplicate:
Which I/O library do you use in your C++ code?

I asked this question in a comment to another question, and I was asked to make it a proper question instead.
Why do I want to use iostream instead of stdio? More specifically, what do std::getline have to offer over the C equivalent?
Please, no language bashing.

A: The biggest gain is type safety.  Format strings in C have no type (unlike in say, OCaml or boost::format) and so you can do some pretty nasty things with them by accident.

A: *

*You gain abstract input/output/seekable stream that can be implemented in any way.
You write to /read from stream that may be file, memory, string or even custom filter or zlib compressor!
Some C libraries provide an option for setting read/write handlers (BSD and Linux) but still do not have
same power as std::streambuf and these are not standard.

*You may use stream specific locale allowing you to format data according to any locale to stream in
thread specific way.

*Type safety.

*Writing to and reading from stream generic objects (complex variables, XML object etc.)

More?

A: There are several advantages, mostly with the << and >> operators.  Getting a line isn't all that different, although being able to read it into a std::string is a considerable advantage.
C++ I/O has type safety.  You don't write your parameter list as a quoted string, and then again as variables and such.  You write what you're going to print once, and C++ figures out how many parameters and what type they are.  When you have type mismatches, C I/O might get the I/O wrong, or even try to access protected memory.
C++ I/O is easily to extend.  You can write operator<<() and operator>>() easily, once you've got a sample to copy.  printf() and friends cannot be extended.  You have a fixed list of format types.
C++ I/O, while it looks fairly simple at first, has a lot of programmer-accessible structure, and therefore a good C++ programmer can modify it to cover cases that C I/O can't.  (Don't overuse this.)

A: For one, if you use iostream then you get to work with std::string, rather then with char arrays, meaning that you have a lot less memory management to worry about.

A: Well, if you use C++ you might want to use OOP, right? I guess cstdio (aka stdio.h) is there just for compatibility with C.


text:
Q: node.js create hex buffer from utf8 file I have a .h264 file that looks like this:
0000 0001 674d 401f 95a0 1001 86c0 5283
0203 2000 007d 0000 1d4c 1080 0000 0001
68ee 3c80 0000 0001 65b8 041f fff6 91f2
86db 23e0 5147 1a83 b8d4 3141 87b1 43b8
e329 5fd3 5937 bf10 485f af32 4e74 6138
5611 33e3 0778 e035 85ca 2c00 9320 ffbb
45be 09f8 2e51 a039 9f8c fe17 d100 0003
0000 0300 0003 02ed 114b 87ea 1054 5a3f
bf5e 0be5 a555 24f9 edf2 72af d9a1 b329
40df 2a96 1a71 d2c7 79d3 a0d2 c13d 06ea
2bdb bf63 f237 8e61 71b1 f1be e923 5565
7714 92f9 8d86 dfc3 1578 79b5 1ef5 ce02
df78 4982 577b f89d 0141 2dcf 0176 a9db
607c 1341 9c61 0fa0 295f 8e18 fd20 00a1

Using a Node.js fs.createReadStream() I get the following:
<Buffer 30 30 30 30 20 30 30 30 31 20 36 37 34 64 20 34 30 31 66 20 39 35 61 30 20 31 30 30 31 20 38 36 63 30 20 35 32 38 33 0a 30 32 30 33 20 32 30 30 30 20 30 ...>

How do I get the the following instead? (basically, telling the buffer to read the raw input as hex codes directly):
<Buffer 00 00 00 01 67 4d 40 1F ...>

A: I created a file called t.h264 with the data you provided. Then, in test.js:
var file = require("fs").createReadStream("t.h264", { encoding: "utf8" });
file.pipe(process.stdout);

This produced the output
0000 0001 674d 401f 95a0 1001 86c0 5283 ...

which appears to be what you want.


text:
Q: How to mock an object inside main() function in python? I am trying to mock data1 and data2 and trying to provide a return value.
I have the following code:
import pandas

def main():
    data1= pandas.read_excel('path1')
    data2= pandas.read_excel('path2')

if __name__ == '__main__':
    main()

import test1
from unittest.mock import patch
import pandas

class Testdata(unittest.TestCase):

    @patch('test1.main.data1')
    @patch('test1.main.data2')
    def test_main(self, mock_data1, mock_data2):
        mock_data1.return_value = pandas.DataFrame([some dataframe])
        mock_data2.return_value = pandas.DataFrame([some dataframe])
        test.main()
        data1.assert_called_once()
        data2.assert_called_once()

if __name__ == '__main__':
    unittest.main()

I am getting the following error:
Error
Traceback (most recent call last):
  File "C:\apps\python\3.6.2\lib\unittest\case.py", line 59, in testPartExecutor
    yield
  File "C:\apps\python\3.6.2\lib\unittest\case.py", line 605, in run
    testMethod()
  File "C:\apps\python\3.6.2\lib\unittest\mock.py", line 1171, in patched
    arg = patching.__enter__()
  File "C:\apps\python\3.6.2\lib\unittest\mock.py", line 1227, in __enter__
    self.target = self.getter()
  File "C:\apps\python\3.6.2\lib\unittest\mock.py", line 1397, in <lambda>
    getter = lambda: _importer(target)
  File "C:\apps\python\3.6.2\lib\unittest\mock.py", line 1080, in _importer
    thing = __import__(import_path)
ModuleNotFoundError: No module named 'main'

How do I resolve this issue and how to mock data1 and data2 and provide a return value to it?

A: Can't say much before looking at the full-code but I thing adding import unitest in the starting shall do the job.


text:
Q: Using GCM when user logged in from multiple devices at the same time and multiple accounts have been logged in at the same device I am using GCM for online chatting application. But I think there are still some area needs to dig deeper. I know GCM gives one registration id per device/app. What if the one user logged out and another logged-in from the same device. How can I be sure that message is sent to relevant user.
To solve this problem I am registering a user everytime he/she either logged-in or register. and when he/she logged-out I am deleting the registration id from my database. I still have some doubt for this approach any information would be very helpful.

A: From the GCM documentation:

A client app should call these unregistration and unsubscription
  functions only if it needs to stop receiving messages. Developers
  should never unregister the client app as a mechanism for logout or
  for switching between users, for the following reasons:

*

*A registration token isn't associated with a particular logged in
  user. If the client app unregisters and then re-registers, the app can
  receive the same registration token or a different registration token.

*Unregistration and re-registration may each take up to five minutes to
  propagate. During this time messages may be rejected due to the
  unregistered state, and messages may go to the wrong user.

  To make
  sure that messages go to the intended user:

*

*The app server can maintain a mapping between the current user and the
  registration token.

*The client app can then check to ensure that
  messages it receives match the logged in user.

This means:

*

*(Re-)Register for GCM on app start, don't unregister on logout

*Store device token in your database on login (map token to account)

*

*Storing multiple device tokens for same account should be possible

*Remove device token from database on logout

*To send a notification to a certain account, send it to all device tokens stored for that account

*Additionally, you can check if the notification is addressed to the logged in user on the device itself (send account ID in notification payload)


text:
Q: Is the converse true? Let $G$ be a connected bipartite graph with partite sets $X$ and $Y$ such that cardinality of $X$ equals to cardinality of $Y$ $\geq$ 2. If every two vertices of $X$ have distinct degrees in $G$ then show that $G$ has a perfect matching. Is the converse true? Justify your answer.

A: We have to check that $G$ satisfies the conditions of Hall's Marriage Theorem. Indeed, let $W$ be an arbitrary non-empty subset of $X$. Since all vertices of $W$ have distinct degrees (which are positive, because $G$ is connected),
there exists a vertex $v\in W$ with degree $\deg v\ge |W|$. Then $|N_G(W)|\ge \deg v\ge |W|.$
The converse is not true. A simple example it a bipartite graph whose set of edges is a perfect matching.


text:
Q: pdfTeX warning saying about duplicate figures pdfTeX warning (ext4): destination with the same identifier (name{figure.1}) has been already used, duplicate ignored
I am using Doxygen tool to convert all my code documentation into PDF file while I am trying generating the report Finding the mentioned warning.
I have referred few suggestions online but nothing works please explain this warning and guide me to a correct path
Edit Albert: I've just pushed a proposed patch to github (pull request 8099, https://github.com/doxygen/doxygen/pull/8099).


text:
Q: How am I supposed to consume the MailChimp JSON Schema for its API? On the developer portion of its site, MailChimp links to a JSON schema describing its API.
http://developer.mailchimp.com/documentation/mailchimp/guides/get-started-with-mailchimp-api-3/#json-schema
I am familiar with JSON schemas (Draft v4). I understand their role in API payload validation, documentation generation, etc. I am also familiar with how they contrast with Swagger (OpenAPI) schemas (which are similar in some ways but more comprehensively document an API).
It seems MailChimp's schema is a Swagger-like API description, but based on a JSON schema syntax. At first, it looks like a JSON Hyper-Schema, but it has 'schema' and 'targetSchema' fields referencing other JSON files without using JSON Pointers (https://spacetelescope.github.io/understanding-json-schema/structuring.html). It also mixes in some HATEOAS concepts?
What tooling will allow me to consume this JSON schema without manually reconciling all the JSON schema files published by MailChimp?
My goal is ultimately to create a Swagger 2.0 (OpenAPI) definition of MailChimp's API. I have a tool for converting from JSON Hyper-Schemas to Swagger 2.0.

A: I took TooMuchPete's suggestion.
Here's what MailChimp said:

Hi Jordan,
Thanks for reaching out. At the current time, we use a mix of both of these specifications. We currently use Swagger to lay out our schema for documentation purposes, however, we use the JSON schemas for other functions such as request validation and other parts of the API. That said, we are currently in the process of transitioning these functions over to Swagger. With that said, below is a URL that should be helpful in consuming our schemas.
http://api.mailchimp.com/schema/3.0/Swagger.json

A: My understanding is that MailChimp is transitioning from JSON Hyperschema to Swagger, as that's how they generate their documentation. You might want to contact their API helpdesk and see if the swagger is available publicly yet.


text:
Q: Slowing down a physics defying spring I am doing a tutorial for my physics class.
I made a program that should have a cart on a box that is moved by a spring and should slow down to a stop, however, when I run it, it appears the spring is accelerating the cart (no matter which things I negate.)
I have heard that it might be an issue with vPython rounding numbers resulting in the acceleration, if this is true, can I just make all the numbers 1000 times larger and would it fix it?
Thanks!
from visual import *
from visual.graph import *

length=1.0

track=box(pos=vector(0,-0.05,0),
          size=(length, 0.05, 0.10),
          material=materials.bricks,)

# creates the track which is "length"meters in the
# x direction, 0.05m tall, and 1m deep
start=-0.5*length+0.05

cart=box(pos=vector(start+0.01,0,0),
         size=(0.1,0.05,0.1),
         color=color.green)
k=-4
#spring constant

sprL=(start-0.05)-0.1

#sets position of left end of spring
spring=helix(pos=(sprL,0,0),
             axis=((cart.x-0.05)-sprL,0,0),
             radius=0.02,
             color=color.yellow)

cart.m=0.70
#mass of cart
cart.vel=vector(0,0,0)
#initial velocity of cart
cart.force = k*(cart.x)*vector(1,0,0)
#force of the spring
cart.accel=cart.force/cart.m
#acceleration of the cart taking into account the fan
t=0
deltat=0.01
end=0.5*length-0.05
#defining the end of the track
gdisplay(x=100,
         y=500,
         xtitle='time (sec)',
         ytitle='X (cyan), Px (red)')

xcurve = gcurve(color=color.cyan)
pcurve= gcurve (color=color.red)

while cart.x<end+0.01 and (cart.x>(start-0.01)):
    #we include -0.01 so the cart does not fail immediately upon start...
    cart.pos = cart.pos + cart.vel*deltat+(0.5)*(cart.accel)*deltat**2
    #x equals x naught plus v times delta t plus one half a delta t squared
    #note that ** means "to the power of"
    xcurve.plot(pos=(t,cart.x))
    pcurve.plot(pos=(t,cart.vel.x))
    cart.vel=cart.vel+cart.accel*deltat
    #new velocity is old velocity plus acceleration times time
    cart.force=k*(cart.x)*vector(1,0,0)
    cart.accel=cart.force/cart.m
    spring.axis=((cart.x-0.05)-sprL,0,0)
    t=t+deltat
    #increments time
    rate(100)
    #rate means no more than 100 loops per second

A: You don't have a dissipative force in your system (one that leaks energy out of it).  The equation F = -kx conserves energy (this is the equation that you have somewhat circuitously encoded and represents the force that a spring exerts on an object).  Note that the equation there doesn't mean that the force is always negative, it simply points in the opposite direction of cart.pos.  This is how you get the sinusoidal motion.
A dissipative force is needed for the object to actually slow down.  The quintessential example of this would be represented by F = -kx -bv for some constant b and v is the velocity of your object.  This represents your spring being slowed down by a fluid (air/water/whatever you like).
The minimal change to your code in this case would be inside your loop:
    cart.force=(k*(cart.x)-0.1*cart.vel.x)*vector(1,0,0)

This produces an underdamped system, to try out an overdamped system you can set the 0.1 to 10 instead.


text:
Q: export csv file and get  as
 I want to export csv after fetch data from table but after open csv file I get

 tag as >br>

I want this as

.

How to get it. Please help me if anyone have a solution

A: Post your code always.
But this can solve your problem but its not a nice soluition but I cant provide more without your code.
str_replace(">br>","
",your_text);


text:
Q: does groupby concatenate the columns? i have a "1000 rows * 4 columns" DataFrame:
a       b    c   d
1       aa   93  4
2       bb   32  3
...
1000    nn   78  2
**[1283 rows x 4 columns]**

and I use groupby to group them based on 3 of the columns:
df.groupby(['a','b','c']).sum()

print(df)
a       b    c   d
1       aa   93  12
2       bb   32  53
...
1000    nn   78  38
**[1283 rows x 1 columns]**

however the result give me a "1000 rows * 1 columns" Dataframe. SO my question is if Groupby concatenate columns as one Column? if yes how can I prevent that. I want to plot my data after grouping it but i can't since it only see one column instead of all 4.
edit: when i call the columns i only get the last column, it means it can't read 'a','b','c' as columns, why is that and how can i markl them as column again.
df.columns
Index([u'd'], dtype='object')

A: you can do it this way:
df.groupby(['a','b','c'], as_index=False).sum()

or:
df.groupby(['a','b','c']).sum().reset_index()


text:
Q: What is Esri's support plan for Python 2.7 beyond 2020 for ArcGIS Desktop? According to PEP-373, Python 2.7 will retire on January 1, 2020 (Countdown Clock). That date was pushed back 5 years for those who couldn't migrate to Python 3.
According to this product life cycle page for ArcGIS Desktop, 10.6.1 will retire 4 years later on January 1, 2024. Sure, ArcGIS Pro supports Python 3, but there will be a gap of unsupported Python for those still using Desktop leading up to its retirement.
Esri's Deprecation Plan for 10.6 makes no mention of Python support beyond 2020.
I know that Python 2.7 is pretty stable, but I wonder, what are Esri's plans for support during this time?

A: I will of course defer to anyone from Esri on this, but my feeling is that in terms of Python support Esri only supports its own ArcPy and Python API for ArcGIS modules.
Even though ArcGIS Desktop ships with a copy of Python and various third party Python libraries like numpy, etc, I would expect that a bug found in any of them would not obligate Esri to try and fix Python or a third party Python library now or at any time in the future.
On the other hand I would expect that Esri will continue to make its best efforts to fix any bugs found in ArcPy for ArcGIS Desktop 10.6 up until it enters Mature Support in January 2022 using the version of Python as shipped with ArcGIS Desktop 10.6.
From https://twitter.com/Esri/status/976105503288774656 it looks like 10.7 is underway so if new dot releases of ArcGIS Desktop 10.x ship beyond Python 2.x's sunset on 1 January 2020, then I think they would just continue to use the latest version of Python 2.x that had shipped with an earlier dot release, as long as that version of Python 2.x continues to work on any certified Operating System versions.

An update from Esri in a blog post titled How sunsetting Python 2 affects ArcGIS says:

First thing to note: All the Python 2.7 code in ArcGIS will continue
  to work. Also, Esri will continue to support Python 2.7 in ArcMap,
  ArcCatalog, ArcMap extensions (including ArcScene and ArcGlobe, which
  are part of the ArcGIS 3D Analyst extension), ArcGIS Engine, and
  ArcGIS Server.
...
Is there a plan to move ArcMap to a supported version of Python (e.g., Python 3.x)?
No. However, with the ArcGIS 10.8 release, we are upgrading to the
  latest Python 2.7.x libraries available (currently 2.7.16). We also
  have plans to upgrade ArcMap to the 2.7.17 libraries when they are
  available.
…
How long will Esri continue to support Python 2.7?
Esri will continue
  to support Python 2.7 in accordance with the relevant Product Life
  Cycles


text:
Q: Using file from within JAR, while runnig app from jar I am trying to use file, when running application as JAR.
When I run application through Intelij, everything is fine. However when I try to run it via jar, I cannot access the file.
I tried to read few topics containing similar matter, but non of them help
(like Reading a resource file from within jar or How do I read a resource file from a Java jar file?
)
Here is my target tree, and resources:

When I use
String path = String
        .join("", "classpath:static\assets\config\", fileName);
File file = ResourceUtils.getFile(path);
InputStream targetStream = new FileInputStream(file)

During intelij run, everything works.
In the case of jar, I tried:
String path = String
        .join("", "static\assets\config\", fileName).replace("\\","/")).toExternalForm();
String path2 = String
        .join("", "static\assets\config\", fileName).replace("\\","/")).getFile();
String path3 = String
        .join("", "static\assets\config\", fileName).replace("\\","/")).getPath();

and many other. They result in correct path, for example:

*

*file:/D:/Projects/myProject/target/classes/static/assets/config/fileName (in case of toExternalForm)

*/D:/Projects/myProject/target/classes/static/assets/config/fileName (in case of getFile)
However all of them results in null InputStream, when I try:
 InputStream in = getClass().getResourceAsStream(everyPath);

I get an error:
java.io.FileNotFoundException: D:\Projects\myProject\target\project-app-1.0.jar\BOOT-INF\classes\static\assets\config\fileName (The system cannot find the path specified)
When the path in the project-app-1.0.jar when I open it by 7zip is exactly:
D:\Projects\myProject\target\project-app-1.0.jar\BOOT-INF\classes\static\assets\config\fileName
This is how my resource handler looks like:
  private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
      "classpath:/resources/", "classpath:/static/"};
  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/**").addResourceLocations(
        CLASSPATH_RESOURCE_LOCATIONS);
  }

A: forget about "files" when you want to use something inside your jar, its just a simple "Resource" that your have to use with getResource.
If you use a standard packaging system, everything inside "resources" folder are put at the root of your JAR, so if you want to read your "foo.txt" file inside "static\assets\config\" folder you have to do use method:
InputStream in = ClassLoader.getSystemResourceAsStream("static/assets/config/foo.txt");


text:
Q: "Connection Timed Out" on Guest Machine When I run "mvn install" on my guest VM box, I get multiple "Connection Timed Out" errors when searching for a file to download.

[WARNING] Unable to get resource 'org.apache.maven.wagon:wagon-file:pom:1.0-alpha-5' from
  repository maven-nexus (http://repository.jboss.org/nexus/content/groups/public): Error transferring file: Connection timed out

Note - I've opened the file path that maven can't find to Firefox and curl. Both of them can read/download the file based on the path that maven uses and cannot find.
I need to use a proxy, but I believe it's configured correctly. For a guest VM using a proxy, is it acceptable to use the same proxy settings as the host machine?
As I understand, port forwarding is only required from host to guest, but not vice-versa.
Please advise.
EDIT - Turns out it was a proxy issue. I had to configure my guest machine's proxy correctly.

A: As you can download the files with Firefox and curl (inside the vm?) i'd double check proxy settings for mvn.

A: Is VM a Linux? If yes, try:
export http_proxy=http://your_proxy:port
export ftp_proxy=$http_proxy
mvn install

If this does not help, you can

*

*look at logs on proxy server(is there any connection attempt?)

*use packet sniffer/analyzer program like Wireshark to see what actually is happening


text:
Q: Why Fields in debugger showing with "@" as prefix? I have a question, i have a class like the following:
public class RecordedFeatureList
    {
        public string name { get; set; }
        public string type { get; set; }
    }

and when I execute the debugger to see what i'm loading in these fields, the inspector throws me this:
name   "the name"
@type  "a string"
Any ideas what "@" means before type???
Thanks!


text:
Q: How to have `SPACE: magic-space` in ~/.inputrc without breaking Python 3 REPL? If I put SPACE: magic-space in my ~/.inputrc file for configuring Readline, then I cannot enter SPACEs in python3 REPL (v3.8.7)
How can I use SPACE: magic-space in my ~/.inputrc without breaking python3?
NB: Is the only solution to move SPACE: magic-space into ~/.bashrc (and do the same for all other applications where I'd like that key binding enable)?

A: The inputrc file supports conditionals so you can add the following to make the SPACE: magic-space keybinding only apply to Bash:
$if Bash
  SPACE: magic-space
$endif


text:
Q: Run PHP Code After Form Submission And Redirect I want to run some php code after a form is submitted on my website. It redirects to another page to email the information, then uses header() to return to the previous page. What I would like to happen is to load a small message that shows that the message was sent successfully, but I'm not sure how to do this after being redirected from another page. I'm hoping to use php or jquery to accomplish this, and I'm including the code I'm using below. I have tried to use the session_start function to do this, but the echoed text remains on the page after the user leaves.
<form method="post" action="mail.php">

Name:
<input type="text" maxlength="40" name="name" pattern="[a-zA-Z0-9]+" title="Please enter your name." required>

Email:
<input type="email" maxlength="24" name="email" title="Please enter an email address." required>

Subject:
<input type="text" maxlength="24" name="subject" title="Please enter a subject." required>

Message:
<textarea rows="9" maxlength="1000" name="message" title="Please enter a message." required></textarea>

<input type="submit" value="Submit">

</form>

<?php
$to = "kouen922@gmail.com";
$subject = "Message From Your Website: ".trim(htmlspecialchars($_POST["subject"]));
$message = trim(htmlspecialchars($_POST["message"]));
$headers = "Reply To: ".trim(htmlspecialchars($_POST["email"]))."" ."\r\n". "From: " .trim(htmlspecialchars($_POST["name"]))."";
mail($to,$subject,$message,$headers);
header("Location: index.php#contact");
?>

A: Easy.
header("Location: index.php?thankyou#contact");

Then do a conditional for isset($_GET['thankyou']) and print out a message.

A: Instead of using php, use Jquery(since you mentioned about it) and use its potential to send your form data, using ajax post request. In that way you can stay on same page without ever navigating to another page(because you are returning back), and also you can display the message once the post request is complete, ajax POST method returns a callback once the request is complete
Read about it here

A: According to your description: form page -- php email page -- back to form page, then just add the php email part into form page:
index.php:
<?php
$data = init_data();
if ($data['cmd']) {
    $err = main_send($data);
}
if (!$data['cmd'] || $err) {
    main_form($data, $err);
}

function init_data() {
    $arr = ['cmd', 'name', 'email', 'subject', 'message'];
    foreach ($arr as $k) {
        $data[$k] = isset($_POST[$k]) ? trim(htmlspecialchars($_POST[$k])) : '';
    }
    return $data;
}

function main_send($data) {
    if (!$data['name']) {
        return 'What is your name?';
    } elseif (!$data['email']) {
        return 'What is your email?';
    } elseif (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
        return 'Your email is not valid';
    } elseif (!$data['message']) {
        return 'Please say something';
    }

    $to = 'kouen922@gmail.com';
    $subject = 'Message From Your Website: ' . $data['subject'];
    $message = trim(htmlspecialchars($_POST["message"]));
    $headers = 'Reply To: ' . $data['email'])) . "\r\nFrom: " . $data['name']));
    mail($to, $subject, $message, $headers);
    echo '
Thank you very much for the feedback
';
}

function main_form($data, $err = '') {
    if ($err) {
        echo '
' , $err , '
';
    }
    echo 'your original form html here ...';
}

A: Try this code:
form code

<form method="post" id="email-form" action="">

Name:
<input type="text" maxlength="40" id="name" name="name" pattern="[a-zA-Z0-9]+" title="Please enter your name." required>

Email:
<input type="email" maxlength="24" id="email" name="email" title="Please enter an email address." required>

Subject:
<input type="text" maxlength="24" id="subject" name="subject" title="Please enter a subject." required>

Message:
<textarea rows="9" id="message" maxlength="1000" name="message" title="Please enter a message." required></textarea>

<input type="submit" value="Submit">

</form>

email.php code
<?php

//email.php

$to = "kouen922@gmail.com";
$subject = "Message From Your Website: ".trim(htmlspecialchars($_POST["subject"]));
$message = trim(htmlspecialchars($_POST["message"]));
$headers = "Reply To: ".trim(htmlspecialchars($_POST["email"]))."" ."\r\n". "From: " .trim(htmlspecialchars($_POST["name"]))."";
mail($to,$subject,$message,$headers);
echo 'Mail was successfully send';

?>

Jquery code :


text:
Q: Emacs: how to set up warning of file size significantly reduced, when saving file? I had just lost most of the content of my notes in a text file, when I used emacs, and there was a bug, but I ignored the error message, and forced a file save. After a few hours, I found that my newly saved file had only a few bytes left! Most of my notes in the file had gone.
I wish that I had set up warning of file size change significantly, when saving a file in emacs. I saw such message before from emacs before, but I don't know how I can set it up now? Please share with m me any pointer to a solution. Worst come to worst, it should be possibe to add some checking in the hook for file save to implement it.
Thanks in advance!
Yu Shen

A: Depending on what kind of warning you want, this solves your problem.  The current delta is 8M, obviously you can customize this how you want.  If you want a more intrusive warning, you can uncomment the call to 'y-or-n-p, and get rid of the message.
(defvar check-buffer-size-delta (* 8 1024 1024)
  "Delta in size over which the user will be warned when saving.")
(defun check-buffer-size-on-save ()
  "Warn user if buffer has changed by more than CHECK-BUFFER-SIZE-DELTA since last save"
  (let ((delta (abs (- (buffer-size) buffer-saved-size))))
    (when (> delta check-buffer-size-delta)
      (beep)
      ;; (y-or-n-p "WARNING: Buffer has changed by %d bytes since last save.  Do you know what you're doing? "
      (message "WARNING: Buffer has changed by %d bytes since last save." delta))))

(add-hook 'before-save-hook 'check-buffer-size-on-save)

A: This is not specific to Emacs, but if you want to avoid losing work in the future, committing your work to a version control system is very helpful. I generally use Git, but some people find Mercurial a bit simpler to use (there are lots of others, like Subversion, Bazaar, and so on, but Git and Mercurial are the most popular distributed revision control systems, which make it easier to just version control a directory on your disk without setting up a server). A version control system allows you to record the history of your work as you go, so if you make some sort of big mistake you can just revert back to an older version.


text:
Q: How to get the max retry count within an MDB? I can read the current delivery count using javax.jms.Message.getIntProperty("JMSXDeliveryCount"). I'm trying to read the current max retry setting. I configured it to be 5 using following configuration in jms-service.xml.

<attribute name="MaxDeliveryAttempts">5</attribute>

But when I try read it using

*

*javax.jms.Message.propertyExists("dLQMaxResent") JBoss

*javax.jms.Message.propertyExists("MaxDeliveryAttempts")

*javax.jms.Message.propertyExists("DLQMaxResent")

*javax.jms.Message.propertyExists("MaxDeliveryCnt") Oracle
All of the above return false. I'm using JBoss EAP 5.0.1 with jboss messaging.
Any suggestions on which property I should be looking for?

A: What you're setting by <attribute name="MaxDeliveryAttempts"> is MBean configuration, but then you're trying to read it from the message. Why should it be there?

A: As @MaDa rightly says so, this is MBean configuration.
Using following code you can read any JMX MBean setting in JBoss envrionment.
javax.management.MBeanServer server = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
server.getAttribute(new javax.management.ObjectName(mbeanName), attributeName);

e.g.
server.getAttribute(new javax.management.ObjectName("jboss.messaging.destination:service=Queue,name=testQueue"),"MaxDeliveryAttempts");

For this you will need to include jboss-jmx.jar in your maven dependencies.


text:
Q: Problems passing an ObservableProperty variable via BindableProperty into GraphicsView canvas I am trying to pass a variable into my GraphicsView canvas, but it looks like I have some problems receiving the passed variable in my drawable.
What am I doing wrong?
Drawable
public class NewDrawable : IDrawable
{

    public float Vectors { get; set; }

    public static BindableProperty VectorsProperty = BindableProperty.Create(nameof(Vectors), typeof(float), typeof(NewDrawable));

    public void Draw(ICanvas canvas, RectF dirtyRect)
    {

        canvas.StrokeColor = Color.FromRgba("ebc500");
        canvas.StrokeSize = 15;
        canvas.StrokeLineCap = LineCap.Round;
        canvas.DrawArc(40, 40, 200, 200, 90, Vectors, true, false);

View
            <GraphicsView x:Name="newDrawableView">
                <GraphicsView.Drawable>
                    <drawables:NewDrawable Vectors="{Binding TotalProcent}" />
                </GraphicsView.Drawable>
            </GraphicsView>

ViewModel
        [ObservableProperty]
        public float totalProcent;

The variable should be passed to my drawable

A: Look at code snippet in Bindable Properties / Create Accessors.
Property Vectors  is missing get/set code that uses VectorsProperty, to tell XAML what is happening:
public float Vectors
{
    get => (float)GetValue(VectorsProperty);
    set => SetValue(VectorsProperty, value);
}

To use GetValue
From Bindable Properties / Create a property:

To create a BindableProperty instance, the containing class must derive from the BindableObject class. However, the BindableObject class is high in the class hierarchy, so the majority of classes used for UI functionality support bindable properties.

Have your custom class inherit from BindableObject:
public class NewDrawable : BindableObject, IDrawable


text:
Q: Ubuntu install from USB stuck on black screen I have been trying to install Ubuntu 14.04 alongside windows 8.1 from a bootable USB. I am new to using a Linux OS. I turned off fast boot option, and I left secure boot on (I also tried off, but then it's stuck on a blank screen rather than this). I have a Nvidia 880M if that is affecting anything.
I get stuck on this screen whether I choose "try Ubuntu without installing" or "install Ubuntu". This text is shown when I am stuck on the black screen.

A: *

*Boot from USB drive and select Try Ubuntu without installing

*Press "e" and add
nouveau.modeset=0

to the end of the linux line.

*Press F10 - the Ubuntu USB installation media will boot without any issues now.
Recommendation to avoid running into the same problems with your new Ubuntu installation :
When rebooting after having finished the installation repeat the same procedure for starting the installed operating system -> ... select the Ubuntu entry from the GRUB boot menu, press "e" ...
After login to Ubuntu desktop first install the latest stable NVIDIA drivers and Optimus support.
Open a terminal and execute :
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-352 nvidia-prime
sudo reboot

Open NVIDIA X Server Settings -> Prime Profiles - switch to NVIDIA - log out and back in.


text:
Q: Unable to login after upgrading to 19.10 from 19.04 I just upgraded to Ubuntu 19.10. Upgrade was done via update manager GUI. I am using nvidia as a graphics driver.
After upgrade I get logged in but I get this screen:

How do I troubleshoot this?
I ran sudo dpkg --reconfigure -a. This resolved the first problem, but now I am at the login screen and unable to login.
I have looked at this question here:my .xauthority and .iceauthority permissions are correct although .xauthority is 0KB. /tmp permissions are also correct. I don't have lightdm installed.
I have also checked the Xorg.log and .xsession log. Renamed the extensions folder as well as the .xauthority file. no luck.

A: I had automatic login enabled. I just updated this file:
/etc/gdm/custom.conf
and commented out these lines:
AutomaticLoginEnable=True
AutomaticLogin=username

After this I am able to login. Is this a bug?


text:
Q: align image to left in angularjs html You can see rows in picture.

This is code of that view:

<product-image-thumbnail layout="row" layout-align="left center"
    src="vm.callFunction(field)"
    setter="vm.callFunction(value)" />

<md-button  ng-click="vm.onMouseOver(field.getSrc))" layout="row" layout-align="right center">
    <md-icon>zoom_in</md-icon>
</md-button>

I want to align image or uploadanimage to left, zoom button to right.
But it doesnot work.
i also tried
layout-align="start start
 layout-align="end end"

but it did not do the job.
Also i tried buttons to convert to column but it is same.
it makes two rows if i dont put first layout. i need them inside a row.
this is where src image comes

    <md-button class="md-button md-ink-ripple" ng-click="vm.Dialog($event)">
        <md-icon>file_upload</md-icon>
        upload_image
    </md-button>

A:

This is some text.  This is some text.

A: If you want to use angular material, try using the space-between param. Example Plunker.

    <button layout="row" layout-align="space-between center">Zoom</button>

A: You can try this way,

    <md-button class="md-warn">Type</md-button>

DEMO

A: Try this with flex!

    <product-image-thumbnail flex
        src="vm.callFunction(field)"
        setter="vm.callFunction(value)" />

    <md-button  ng-click="vm.onMouseOver(field.getSrc))" flex="5">
        <md-icon>zoom_in</md-icon>
    </md-button>

The flex Will take up as much space as it can till 95% of the available width and flex=5 will ensure it is 5$


text:
Q: NodeJs-MySQL SELECT not returning proper output W3School tutorial on NodeJs-MySQL: SELECT cmmand does not provide output in proper format. In each row of output "RowDataPacket" word is appearing. How to avoid it?
C:\Users\Raju>node demo_db_select.js
[ RowDataPacket { id: 1, name: 'John', address: 'Highway 71' },
  RowDataPacket { id: 2, name: 'Peter', address: 'Lowstreet 4' },

I used the following code:
    var mysql = require('mysql');

    var con = mysql.createConnection({
      host: "localhost",
      user: "yourusername",
      password: "yourpassword",
      database: "mydb"
    });

    con.connect(function(err) {
      if (err) throw err;
      con.query("SELECT * FROM customers", function (err, result, fields) {
        if (err) throw err;
        console.log(result);
    });
  });

A: var data = [
    RowDataPacket { id: 1, name: 'John', address: 'Highway 71' },
    RowDataPacket { id: 2, name: 'Peter', address: 'Lowstreet 4' }
]

This means the inside object is the instane of the class RowDataPacket. You can still simply use it like:
data[0].id // 1
data[0].name // John
data[1].name // Peter

A: You are executing a MySQL query and storing the selected rows and columns in result variable. Actually result is a object. So run a for loop and print all the values as I written in code.
Try this code:
var mysql = require('mysql');
var con = mysql.createConnection({ host: "localhost", user: "yourusername", password: "yourpassword", database: "mydb" });
con.connect(function(err) {
if (err) throw err;
con.query("SELECT * FROM customers", function (err, result, fields) {
if (err) throw err;
for(let i in result){
    console.log("id="+result[i].id);
    console.log("Name="+result[i].name);
console.log("address="+result[i].address);
}
    });
});


text:
Q: docker-compose: difference between networks and links I'm learning docker. I see those two terms that make me confused. For example here is a docker-compose that defined two services redis and web-app.
services:
  redis:
    container_name: redis
    image: redis:latest
    ports:
      - "6379:6379"
    networks:
      - lognet

  app:
    container_name: web-app
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    volumes:
      - ".:/webapp"
    links:
      - redis
    networks:
      - lognet

networks:
  lognet:
    driver: bridge

This docker-compose file defines a bridge network named lognet and all services will connect to this network. As I understand, this action makes those services see others. So why app service still needs to link to redis service in the above case?
Thanks

A: Links have been replaced by networks. Docker describes them as a legacy feature that you should avoid using. You can safely remove the link and the two containers will be able to refer to each other by their service name (or container_name).
With compose, links do have a side effect of creating an implied dependency. You should replace this with a more explicit depends_on section so that the app doesn't attempt to run without or before redis starts.
As an aside, I'm not a fan of hard coding container_name unless you are certain that this is the only container that will exist with that name on the host and you need to refer to it from the docker cli by name. Without the container name, docker-compose will give it a less intuitive name, but it will also give it an alias of redis on the network, which is exactly what you need for container to container networking. So the end result with these suggestions is:
version: '2'
# do not forget the version line, this file syntax is invalid without it

services:
  redis:
    image: redis:latest
    ports:
      - "6379:6379"
    networks:
      - lognet

  app:
    container_name: web-app
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    volumes:
      - ".:/webapp"
    depends_on:
      - redis
    networks:
      - lognet

networks:
  lognet:
    driver: bridge


text:
Q: Rails - How to create relationships between objects in the same table I am creating a family album application. A user can sign on and create a "Family" object. Once the family object is created, the user can then populate the family with "Members." The application allows you to create one member as a standalone object. After the first member has been created, all later members must be created from an existing member's show page. When they are created, the member being created needs to establish how it is related to the current member (the show page). Relationships should be 'parent', 'child' or 'sibling.'
I am having some extreme difficultly figuring out how to do this. The solution needs to do BOTH of these things:

*

*When a new 'member' is created, both objects will have a record of the new relationship.

*The type of relationship needs to be specified. It can't JUST be "member" belongs to "member." It needs to be "member" #1 is "member"#2's parent.

Right now, this is the schema for the member table:
create_table "members", force: :cascade do |t|
t.string   "first_name"
t.string   "last_name"
t.string   "birthplace"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer  "family_id"
t.integer  "parent_id"
t.integer  "child_id"
t.integer  "sibling_id"
end

I have NOT established a has_many relationship between members yet. When a new member is created, I simply make that new member's "parent_id" or "child_id" or "sibling_id" equal the id of the current member being shown (again, form is in member show page)
        <%= form_for [@family, @new] do |m| %>

            <%= m.text_field :first_name, placeholder: "First Name", class: 'form-control' %>

            <%= m.text_field :last_name, placeholder: "Last Name", class: 'form-control' %>

            <%= m.text_field :birthplace, placeholder: "Birthplace", class: 'form-control' %>

            Parent
            <%= m.select :child_id, @members.collect { |m| [ m.full_name, m.id ] }, include_blank: true %>

            <%= m.submit "Add", class:"btn btn-primary" %>

        <% end %>

This is a very silly way to do it imo. Ideally, I want to have a set of radio buttons that say "Parent", "Sibling" and "Child." The user must click on one of the buttons, but can only click on one of them. When the form is submitted, the relationship between the current member and the new member is then established according to which radio button was clicked. My current strategy does not update the current member at all. The relationship can only be referenced in one direction. This method also requires a selection of the other member... which is not what I want.
Should I be using has_many through tables? Help!

A: You should indeed be using has_many_through because I would imagine you need to support multiple relationships... a parent can have more than one child so having a child_id in the parent isn't enough to handle that condition.
class Member < ApplicationRecord
  has_many :parent_links, class_name: 'ParentChildLink', foreign_key: :child_id
  has_many :parents, through: :parent_links, class_name: 'Member', foreign_key: :parent_id
  has_many :child_links, class_name: 'ParentChildLink',  foreign_key: :parent_id
  has_many :children, through: :parent_links, class_name: 'Member', foreign_key: :child_id
end

The 'parent_child_links' table would have
class ParentChildLink < ApplicationRecord
  belongs_to :parent, class_name: 'Member', foreign_key: :parent_id
  belongs_to :child, class_name: 'Member', foreign_key: :child_id
end

And now through the magic of rails you can do...
tommy = Member.create(name: 'Tommy')
peter = Member.create(name: 'Peter')

peter.children << tommy


text:
Q: Is it possible to move the LAMP server to another drive on the same computer? I want to move the /var/www/ folder to a different partition drive and start the server from there, how can I do that?

A: You will need to edit the configuration for apache. The default configuration is stored in /etc/apache2/sites-available/default.
Edit this file with (sudo -H gedit /etc/apache2/sites-available/default for example) and locate the line
DocumentRoot /var/www
and change the path to your new path. Afterwards, you can reload the apache configuration with
sudo service apache2 reload

If you are serving over SSL you'll need to edit /etc/apache2/sites-available/default-ssl as well.

A: Move the content of /var/www to the new partition and mount this partition with an entry in fstab at /var/www.
On Ask Ubuntu there are many answers for the correct entry in the fstab.


text:
Q: Why didn't Professor Umbridge inspect Professor Binns' class? When Professor Umbridge becomes Hogwarts High Inquisitor, she proceeded to hold inspections of all the other Hogwarts teachers to assess whether or not they are 'up to scratch'.  However, despite the fact that Harry, Ron and Hermione mentioned several times that they looked forward to seeing Professor Binns' class being inspected ('Bet Umbridge is in History of Magic,' said Ron grimly, as they set off for Binns's lesson. 'She hasn't inspected Binns yet ... bet you anything she's there ...'), it appears that Professor Umbridge never bothered.  I was curious why?  Seems interesting to have the main characters mention it twice and then give no reason why it never occurrs.

A: I guess Binns doesn't matter because he doesn't do anything but teaching. He doesn't oppose her, he doesn't criticise her and most importantly he is not a follower of Dumbledore.
I mean come on. That guy is so indifferent he couldn't care less about his own death. :-)

A: You have to remember that Hogwarts has 7 different years worth of students, from 4 different houses. Each class seemingly is taken by 2 houses at once, though it is possible that some are taught to more or less depending on attendance (i.e. when the students get older and can select their own courses). Assuming Professor Binns' teaches at least one course to each of the 7 years, this gives us (approximately) 14 courses total that he will be teaching (7 * 2). Harry had already witnessed Umbridge inspecting several teachers, and it seems unlikely that he would end up witnessing all of the inspections.
Also as @AnthonyGrist pointed out in his comment, it is unlikely that an inspection of Binns' class would be interesting in the least. He is known to be a bore, and teaches History. Professor Umbridge was more concerned with dispelling rumors about Voldemort and the present rather than facts about the past.
So in conclusion, it is safe to assume that Umbridge did inspect Professor Binns' class, but that it was (as expected) dull and uneventful, and therefore unworthy of discussing in the books. Especially since it seems unlikely that Harry even witnessed the inspection himself.

A: Nobody has yet mentioned the reason why Umbridge is at Hogwarts in the first place, and why she was made High Inquisitor. She is there to stop the students from learning self-defense or any spells that could be used against the Ministry. Classes such as Transfiguration, Charms, and especially DADA would likely be teaching spells that can be used offensively. History of Magic does not teach spells at all, which greatly decreases Umbridge's interest in it.
Additionally, as mentioned in other answers, Binns is not a great ally of Dumbledore like McGonagall or Flitwick. Umbridge does not see History of Magic or Flitick as a threat to the Ministry. She more likely sees Binns as a model teacher. He does everything by routine, he teaches straight from the textbook, there are no wands at all, and everything in his class is cold, hard fact.

A: I think probably she did inspect him, but with a different class, like in Flitwick's case. Another thing I think is that since Professor Binns is a ghost, it is probable that even if she did find dirt against him, it is unlikely she could do anything.


text:
Q: EgisTec 0570 Fingerprint Sensor - fprintd-enroll not working I have an Acer Swift 3 (SF314-57) running arch, which has an 0570 LighTuning Technology Inc. EgisTec Touch Fingerprint Sensor. Support for this device was just made available in the latest libfprint release (v1.92.1), so naturally I have been trying to get it working.
I installed the fprintd package from the official arch repo, however, when I try to enroll a fingerprint, it just 'gets stuck' saying Enrolling right-index-finger finger with a blinking cursor, and no amount of trying to scan my fingerprint will get it to give any sort of indication that something is happening.
The device is seen by my system and fprintd.service is running:
[sudo] password for mipy:
● fprintd.service - Fingerprint Authentication Daemon
     Loaded: loaded (/usr/lib/systemd/system/fprintd.service; static)
     Active: active (running) since Sun 2021-08-08 16:04:25 AEST; 3s ago
       Docs: man:fprintd(1)
   Main PID: 7381 (fprintd)
      Tasks: 6 (limit: 18803)
     Memory: 1.6M
        CPU: 57ms
     CGroup: /system.slice/fprintd.service
             └─7381 /usr/lib/fprintd

Aug 08 16:04:24 ruby-swift314-57 systemd[1]: Starting Fingerprint Authentication Daemon...
Aug 08 16:04:25 ruby-swift314-57 systemd[1]: Started Fingerprint Authentication Daemon.

Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 04f2:b5c5 Chicony Electronics Co., Ltd HD WebCam
Bus 003 Device 002: ID 1c7a:0570 LighTuning Technology Inc. EgisTec Touch Fingerprint Sensor
Bus 003 Device 004: ID 8087:0026 Intel Corp. AX201 Bluetooth
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The only errors I get from journalctl -f -u fprintd.service are:
fprintd[6957]: Failed to clear storage before first enrollment: Device has no storage.

(I should add, my disk has ~50GB of storage available, so the problem isnt with my disk's storage - I assume the reader's?)
When I build libfprint from source, using meson compile and then meson test, and try to enroll using the examples, it shows:
This program will enroll the selected finger, unconditionally overwriting any print for the same finger that was enrolled previously. If you want to continue, press enter, otherwise hit Ctrl+C

Choose the finger to enroll:
  [0] left thumb
  [1] left index
  [2] left middle
  [3] left ring
  [4] left little
  [5] right thumb
  [6] right index
  [7] right middle
  [8] right ring
  [9] right little
> 6
(process:5575): libfprint-context-DEBUG: 15:21:02.406: No driver found for USB device 1D6B:0003
(process:5575): libfprint-context-DEBUG: 15:21:02.406: No driver found for USB device 04F2:B5C5
(process:5575): libfprint-context-DEBUG: 15:21:02.407: No driver found for USB device 8087:0026
(process:5575): libfprint-context-DEBUG: 15:21:02.407: No driver found for USB device 1D6B:0002
(process:5575): libfprint-context-DEBUG: 15:21:02.407: No driver found for USB device 1D6B:0003
(process:5575): libfprint-context-DEBUG: 15:21:02.407: No driver found for USB device 1D6B:0002
Selected device 0 (Egis Technology Inc. (aka. LighTuning) 0570) claimed by egis0570 driver
(process:6437): libfprint-image_device-DEBUG: 15:33:00.490: Image device open completed
(process:6437): libfprint-device-DEBUG: 15:33:00.490: Device reported open completion
(process:6437): libfprint-device-DEBUG: 15:33:00.491: Completing action FPI_DEVICE_ACTION_OPEN in idle!
Opened device. It's now time to enroll your finger.

You will need to successfully scan your right index finger 5 times to complete the process.

Scan your finger now.
(process:6437): libfprint-image_device-DEBUG: 15:33:00.492: Activating image device
(process:6437): libfprint-image_device-DEBUG: 15:33:00.492: Image device internal state change from FPI_IMAGE_DEVICE_STATE_INACTIVE to FPI_IMAGE_DEVICE_STATE_ACTIVATING
(process:6437): libfprint-SSM-DEBUG: 15:33:00.492: [egis0570] SM_STATES_NUM entering state 0
(process:6437): libfprint-SSM-DEBUG: 15:33:00.492: [egis0570] SM_STATES_NUM entering state 1
(process:6437): libfprint-SSM-DEBUG: 15:33:00.492: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-image_device-DEBUG: 15:33:00.492: Image device activation completed
(process:6437): libfprint-image_device-DEBUG: 15:33:00.492: Image device internal state change from FPI_IMAGE_DEVICE_STATE_ACTIVATING to FPI_IMAGE_DEVICE_STATE_IDLE
(process:6437): libfprint-image_device-DEBUG: 15:33:00.492: Image device internal state change from FPI_IMAGE_DEVICE_STATE_IDLE to FPI_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON
(process:6437): libfprint-device-DEBUG: 15:33:00.492: Device reported finger status change: FP_FINGER_STATUS_NEEDED
(process:6437): libfprint-SSM-DEBUG: 15:33:00.492: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.492: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.492: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.492: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.493: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.493: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.493: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.493: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.493: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.493: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.494: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.494: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.494: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.494: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.494: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.494: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.494: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.495: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.495: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.495: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.495: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.495: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.495: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.495: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.495: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.495: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.496: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.497: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.497: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.497: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.497: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.497: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.497: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.497: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.497: [egis0570] SM_STATES_NUM entering state 4
(process:6437): libfprint-image_device-DEBUG: 15:33:00.564: Image device reported finger status: off
(process:6437): libfprint-SSM-DEBUG: 15:33:00.564: [egis0570] SM_STATES_NUM entering state 5
(process:6437): libfprint-SSM-DEBUG: 15:33:00.564: [egis0570] SM_STATES_NUM entering state 1
(process:6437): libfprint-SSM-DEBUG: 15:33:00.564: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.564: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.564: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.565: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.565: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.565: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.565: [egis0570] SM_STATES_NUM entering state 2
(process:6437): libfprint-SSM-DEBUG: 15:33:00.565: [egis0570] SM_STATES_NUM entering state 3
(process:6437): libfprint-SSM-DEBUG: 15:33:00.565: [egis0570] SM_STATES_NUM entering state 4
(process:6437): libfprint-egis0570-DEBUG: 15:33:00.632: Finger status (picture number, mean) : 0 , 0
(process:6437): libfprint-egis0570-DEBUG: 15:33:00.632: Finger status (picture number, mean) : 1 , 0
(process:6437): libfprint-egis0570-DEBUG: 15:33:00.632: Finger status (picture number, mean) : 2 , 0
(process:6437): libfprint-egis0570-DEBUG: 15:33:00.632: Finger status (picture number, mean) : 3 , 0
(process:6437): libfprint-egis0570-DEBUG: 15:33:00.632: Finger status (picture number, mean) : 4 , 0
(process:6437): libfprint-image_device-DEBUG: 15:33:00.632: Image device reported finger status: off

And just keeps looping through the "Finger status" and "SM_STATES_NUM" bit until I kill it.
When I then try using manage-prints from the examples, I get:
This program will report the prints saved in device
(process:7187): libfprint-context-DEBUG: 15:56:24.549: No driver found for USB device 1D6B:0003
(process:7187): libfprint-context-DEBUG: 15:56:24.549: No driver found for USB device 04F2:B5C5
(process:7187): libfprint-context-DEBUG: 15:56:24.549: No driver found for USB device 8087:0026
(process:7187): libfprint-context-DEBUG: 15:56:24.549: No driver found for USB device 1D6B:0002
(process:7187): libfprint-context-DEBUG: 15:56:24.549: No driver found for USB device 1D6B:0003
(process:7187): libfprint-context-DEBUG: 15:56:24.549: No driver found for USB device 1D6B:0002
Selected device 0 (Egis Technology Inc. (aka. LighTuning) 0570) claimed by egis0570 driver
(process:7187): libfprint-image_device-DEBUG: 15:56:24.690: Image device open completed
(process:7187): libfprint-device-DEBUG: 15:56:24.691: Device reported open completion
(process:7187): libfprint-device-DEBUG: 15:56:24.691: Completing action FPI_DEVICE_ACTION_OPEN in idle!

(process:7187): libfprint-WARNING **: 15:56:24.691: Device Egis Technology Inc. (aka. LighTuning) 0570 doesn't support storage

(process:7187): libfprint-device-WARNING **: 15:56:24.691: User destroyed open device! Not cleaning up properly!
libusb: warning [libusb_exit] application left some devices open

When I try and run fwupdmgr update, I just get:
Devices with no available firmware updates:
 • System Firmware
 • UEFI Device Firmware
 • UEFI dbx
 • WDC PC SN520 SDAPNUW-512G-1014
No updatable devices

Does anybody know what is going on? I feel like I am missing something obvious, but I can't figure out what.
Thanks :)


text:
Q: I started making a qt6 widget application. How do I get it to start in the upper right corner of the screen when I run the application ⁸I started making a qt6 widget application. How do I get it to start in the upper right corner of the screen when I run the application.I've been struggling for hours but couldn't find the appropriate code to do this with cmake.Is there a way to install the cmake QDesktopWidget library ?
I hoped that the code in the bold text would start in the upper right corner, but it was not as I expected, I can't find the problem.
#include "widget.h"
#include "./ui_widget.h"
#include <QScreen>
#include <QRect>
#include <QSize>
#include <QApplication>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::WindowType::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
    this->setStyleSheet(".QFrame{background-color: red; border: 1px solid black; border-radius: 10px;}");
       QRect sc = QGuiApplication::primaryScreen()->geometry();
       QWidget::move(sc.top( ),sc.right());
       Widget::show();

}

Widget::~Widget()
{
    delete ui;

A: Assuming that the window is the size of the screen, swapping sc.top() and sc.right() and subtracting the width of the widget from sc.right() should work
This plus removing either the call to setWindowFlags or to setAttribute will display the widget in the top right corner
Alternatively you can add something to display in the widget, and that would show up, its just that the combination makes the widget itself invisible

A: Try this:
this->move(QApplication::primaryScreen()->geometry().right()- this->rect().right(),
           QApplication::primaryScreen()->geometry().top()- this->rect().top());


text:
Q: Conditionally reload component based on previous route Perhaps someone can help me with a React Native issue I'm having with react-navigation (2.0.4). I have a page (Page C - RouteShowScreen) that I want to conditionally reload, depending on whether or it was navigated to from Page A (RoutePrepareScreen) or Page X (Any other page navigating to Page C), and I just can't seem to get the lifecyle methods correct. To be clear, I want the page to reload if it is navigated to from Page A (RoutePrepareScreen), but not if it is navigated to from any other screen.  I tried using the willFocus listener, but then Page C reloads regardless of whether it was navigated to from Page A or Page B.
RoutePrepareScreen
...

this.props.navigation.navigate("RouteShow", {
  currentLat: latitude,
  currentLng: longitude,
  destinationAddress: this.state.destinationAddress,
  currentAddress: this.formatCurrentAddress(),
  destinationLat,
  destinationLng,
  speed,
  hoursUntilBreak,
  estimatedShiftLength});
}

...

RouteShowScreen
/** This caused the page to reload, regardless of how it was navigated to **/

willFocus = this.props.navigation.addListener(
  'willFocus',
  () => {
    this.handleRouteLoad();
  }
);

/** I also tried using componentWillReceiveProps and adding an additional "reload" navigation parameter, but this threw the
app into an infinite loop **/

componentWillReceiveProps(nextProps) {
  if (nextProps.navigation.state.params.reload) {
    this.handleRouteLoad();
  }
}

A: In my particular case, I was able to get this to work by resetting the navigation stack when navigating from within RoutePrepareScreen - like this:
    const resetAction = StackActions.reset({
      index: 0,
      actions: [
        NavigationActions.navigate({
          routeName: "RouteShow",
          params: {
            currentLat: latitude,
            currentLng: longitude,
            destinationAddress: this.state.destinationAddress,
            currentAddress: this.formatCurrentAddress(),
            destinationLat,
            destinationLng,
            speed,
            hoursUntilBreak,
            estimatedShiftLength,
          }
        })
      ],
    });
    this.props.navigation.dispatch(resetAction);

However, this feels a little dirty to me (and might be untenable if the use case cannot handle a full reset of the navigation stack). I'd be curious to see another solution!


text:
Q: Min-height 100% inner div I want to have two nested div's:

A div in a div!!!

Which both should be at least the height of the window. So of course, I set the height of html and body to 100%, such that the outer div can have a min-height:100%, and since the height of the html and body elements are known, this is well defined.
However, min-height does not say anything about the actual height of the outer div. Hence it is not defined when the inner div is 'calculated'. The inner div may force the outer one to become bigger, or the inner div may be less tall than the outer div.
As far as I googled, I found 2 solutions, which each break in the situations above:
http://jsfiddle.net/5ML3W/
.outer {
    min-height: 100%;
    height: 100%;
    width: 500px;
    background: green;
}
.inner {
    width: 250px;
    margin-left: 50px;
    min-height:100%;
    background: red;
}
html, body{
    height:100%;
}

http://jsfiddle.net/bkjHa/1/
.outer {
    min-height: 100%;
    width: 500px;
    background: green;
}
.inner {
    width: 250px;
    margin-left: 50px;
    min-height:100%;
    background: red;
}
html, body{
    height:100%;
}

Essentially the difference is the height property for the outer div.
How can I force my inner div to be at least 100% of the window size and my outer div to stretch if the inner div becomes larger?
In my real world application the outer div is transparent, so I wouldn't really care. However, I am a bit curious, a fix or an explanation that what I want is not possible would be nice!

A: I actually got quite curious about how to solve this "issue". It works the way you want it if you apply display: table to the outer div and display: table-cell on the inner div.
1. Fiddle: Minimum height 100% without any content
http://jsfiddle.net/5ML3W/1/
2. Fiddle: Both div's expand if content is added to the inner div
http://jsfiddle.net/TVY6K/
And here is the CSS:
html, body{
    height:100%;
    margin: 0;
}

*, *:before, *:after {
  -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
 }

.outer {
    height: 100%;
    width: 500px;
    background: green;
    display: table;
    padding: 0 50px;

}
.inner {
    display: table-cell;
    width: 250px;
    background: red;
}


text:
Q: take multiple photos for file input field I have this form as part of my flask-based website:

<form action="/{{ order_number }}/receive-order"  method="POST" enctype=multipart/form-data>

    <input type=file name="packing_slip" multiple="multiple">

    <input type="text" name="name_first" placeholder="Your First Name" required>

    <input type="text" name="name_last" placeholder="Your Last Name" required>

  <input type="submit" class="btn btn-primary">

</form>

When user clicks the "Choose Files" button an a phone or ipad, they get an option to take a photo, which is exactly what I want. But they can only take one photo, and if the click the button again and take another, the first one is lost. On the other hand, if they try to choose an existing image file, they can select as many as they want.
I would like the user to be able to take multiple photos on the spot, and for the back-end  to retrieve them all once the form is submitted. Is this possible? If so, how could I achieve that?
Also, I am tagging this question as best I know how, but please do help me by suggesting more appropriate tags/title.


text:
Q: How to implement Configurations class in Java? I am using this example to read from configuration file (data such as host name, password, etc) . But they did not include the Configurations class itself.
So I am not really sure how that should be implemented.
Here is how I am trying to read the properties from Main class:
Configurations configs = new Configurations(); // Error: cannot find symbol symbol: class Configurations location: class Main
try {
    Configuration config = configs.properties(new File("database.properties"));
    String dbHost = config.getString("database.host");
    int dbPort = config.getInt("database.port");
    String dbUser = config.getString("database.user");
    String dbPassword = config.getString("database.password", "secret");  // provide a default
    long dbTimeout = config.getLong("database.timeout");
} catch (ConfigurationException cex) {
    cex.printStackTrace();
}

And this is how my database.properties file looks:
database.host = "dbname";
datatabase.port = 5005;
datatabase.user = "root";
datatabase.password = "";
database.timeout = 60000

P.S. Sorry for my stupidity, I am very new to Java.

A: You can use the properties class in java, which has a load method that specifies an inputstream.
Then, you can read your properties file via FileInputStream.
example:
public class Test {

    public static void main(String[] args) throws Exception {
        Properties properties = new Properties();

        InputStream inputStream =
                new FileInputStream("D:\\work_space\\java_workspace\\test-mq\\src\\main\\resources\\database.properties");
        properties.load(inputStream);

        String host = properties.getProperty("database.host");
        // get more properties......
        System.out.println(host);

    }

}