I have a string which I want to cast to a byte array, however, my string is the actually representation of an image byte array (eg. String x = "00123589504e47..."). So, I'm stuck because doing x.getBytes(); doesn't do the job.. I need a way to cast the string to byte array and then save that byte array to an image in a specific directory. How can I cast it?
I am looking for a way to convert a long string (from a dump), that represents hex values into a byte array.  I couldn't have phrased it better than the person that posted .  But to keep it original, I'll phrase it my own way: suppose I have a string "00A0BF" that I would like interpreted as the  byte[] {0x00,0xA0,0xBf}   what should I do?  I am a Java novice and ended up using BigInteger and watching out for leading hex zeros. But I think it is ugly and I am sure I am missing something simple.
I have a managed C# dll that uses an unmanaged C++ dll using DLLImport. All is working great. However, I want to embed that unmanaged DLL inside my managed DLL as explain by Microsoft there:    So I added the unmanaged dll file to my managed dll project, set the property to 'Embedded Resource' and modify the DLLImport to something like:  [DllImport("Unmanaged Driver.dll, Wrapper Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", CallingConvention = CallingConvention.Winapi)]   where  'Wrapper Engine' is the assembly name of my managed DLL 'Unmanaged Driver.dll' is the unmanaged DLL  When I run, I get:     Access is denied. (Exception from HRESULT: 0x80070005   (E_ACCESSDENIED))   I saw from MSDN and from  that's supposed to be possible... Paucity of words for relationships Is there any way to favorite/bookmark an answer? Lots of questions are very generic, &quot;share an experience&quot; kinds of questions. In these cases, I am quite often interested in specific answers that may not have gotten that many upvotes. These questions also tend to elicit lots of responses, so going back to find the answers I'm interested in somewhere in the middle of a sea of responses is a pain. Is there a way to favorite or bookmark these answers? What does "mostly" modify? "My friends are mostly non-smokers."  Is "mostly" a focusing adverb that modifies "non-smokers"? Failed upgrade from Ubuntu 19.10 to 20.04 "Please update the microcode" While installing the Ubuntu 20.04 updates during upgrade from 19.10 to 20.04, my screen suddenly went completely white and displayed a message saying  Please logout and try again.  But I could not locate my cursor and so I switched off my laptop. After restarting it again, it was showing an error message saying  Please update the microcode  Why did this happen? How can I solve this problem? How do I programmatically determine operating system in Java? I would like to determine the operating system of the host that my Java program is running programmatically (for example: I would like to be able to load different properties based on whether I am on a Windows or Unix platform). What is the safest way to do this with 100% reliability? The table cards were A,K,K,8,3. All four suits were on the board. Player one had A,8. Player two had A,3.   Is this a split pot? How should we treat questions that are, or have seeds of, evil or malicious purposes and actions, such as writing spambots and malware?    Should they be answered like regular "everybody keeps their pants on" questions? Or should there be some other type of response to this bad behaviour lot? In Iron Man 3, we saw that Tony was able to control Mark 42 armor remotely.  Talking about the Hulkbuster armor used in Avengers: Age of Ultron, it was very dangerous because Hulk's unpredictable rage could rip it apart any time.  Why didn't Iron Man simply control the Hulkbuster armor remotely? Construct ideals in $\mathbb Z[x]$ with a given least number of generators Suppose I want to know whether $\sqrt{7}\in\mathbb{Q}_5$, or more generally, whether $\sqrt{n}\in\mathbb{Q}_p$ for $n\in\mathbb{Z}$, $p$ an odd prime. What are the techniques for determining this? Am I supposed to "lift" it from $\mathbb{Z}/p\mathbb{Z}$ using Hensel's lemma? Could I see an example? Can you use your off-handed weapon for your main attack action? My friend is 2 weapon fighting a flesh golem. He has one sword that does lightning damage, and one sword that does fire damage. His right hand holds the lightning sword, and his left hand holds the fire sword.  My friend wants to attack with his left hand because lightning heals the golem. However, the DM says that because his left hand is his left hand, he can't use it as his "main" hand, and only attack with it. Is this rules as written/intended? $R/Ra$ is an injective module over itself Let $R$ be a PID, $a\in R$ be a nonzero nonunit in $R$. Prove that $R/Ra$ is an injective module over itself.   If $R$ is a PID, every $R$- divisible module is injective, but the question concerns with $R/Ra$-module, so I have no idea to solve this problem. Help me. How can I stream the same music to multiple computers? Is there a way to stream the same playlist on multiple computers at the same time? I want to be able to sync what's playing on multiple computers (for parties etc). Prison problem: locking or unlocking every $n$th door for $ n=1,2,3,...$ I have a problem called "The Prison Problem" that I need to explain to my 9-year-old cousin. I would think that he has just started learning about divisors and perfect squares, and as such, I have a proposed solution. Any input from you guys would be welcome, as to what is the best way to go about this.  Problem:  There was a jail with 100 cells in it, all in a long row. The warden was feeling very jolly one night and told his assistant that he wanted to give all the prisoners a wonderful surprise. While they were sleeping, he wanted the assistant to unlock all the cells. This should be done, he told the assistant, by putting the key in each lock, turning it once. The assistant did this, then came back to report that the job was done. Meanwhile, however, the warden has second thoughts. "Maybe I shouldn't let all the prisoners free," he said. "Go back and leave the first cell open, but lock the second one (by putting the key in and turning it once). Then leave the third open, but lock the fourth, and continue in this way for the entire row." The assistant wasn't very surprised at this request as the warden often changed his mind. After finishing this task, the assistant returned, and again the warden had other thoughts. "Here's what I really want you to do," he said. "Go back down the row. Leave the first two cells as they are, and put your key in the third cell and turn it once. Then leave the fourth and fifth cells and turn the key in the sixth. Continue down the row this way." The assistant again did as instructed. Fortunately, the prisoners were still asleep. As a matter of fact, the assistant was getting pretty sleepy, but there was no chance for rest yet. The warden changed his mind again, and the assistant had to go back again and turn the lock in the fourth cell and in every fourth cell down the row. This continued all through the night, next turning the lock in every fifth cell, and then in every sixth, and on and on, until on the last trip, the assistant just had to turn the key in the hundredth cell. When the prisoners finally woke up, which ones could walk out of their cells?  Proposed solution:  Ten cells are left open after this process. Every cell that is a perfect square will remain open (1, 4, 9, 16, 25, 36, 49, 64, 81, and 100). If a number is not a perfect square, then it has an even number of divisors, therefore it will be "toggled" an even number of times and end up where it started (closed). Perfect squares have an odd number of divisors, so they will end up the opposite of where they started (open). Bmp to jpg/png in C# So, I'm running linux Mint (but I guess the same applies to Ubuntu) and as is common knowledge, their TeX distribution tends to be slightly outdated. Now I can't have none of that and decide to install it with the install-tl from the TeXlive homepage. Somehow, I cannot install it as a normal user (this I find normal as it is installing in the root directory), so I proceed to install TeXlive   sudo perl ./install-tl   and add the paths to .bashrc. All is well and my TeXlive installation works. Except for the texhash option. Running it as a normal user is no problem, except that I installed TeXlive as root, and so running texhash as normal user doesn't do anything (directory not writable. Skipping...). No problem I think, I'll just do it as root. But somehow texhash isn't installed for root.  Now, texhash is somehow connected to updating the directory tree, but I don't really know what it does. I use it on my ~/texmf/ folder to add my packages to a global path (I think), but when looking at info for this question I see in a comment for  question that this is apparently not needed, though I don't understand what I'm to do now.  So if I'm not adding new packages from CTAN or updating, I really don't need texhash and all is good?   To summarize: I'd like to know:    Why should I need texhash? Can I avoid installing as root on linux Mint/ubuntu ( they say you don't have to be root, that it's even discouraged)? Should I somehow install texhash for root?   I realize this might be a vague question at best, but I didn't find an answer I readily understood, so I'd appreciate any thought on this. Proof of this fairly obscure differentiation trick? Suppose we're tying to differentiate the function $f(x)=x^x$. Now the textbook method would be to notice that $f(x)=e^{x \log{x}}$ and use the chain rule to find $$f'(x)=(1+\log{x})\ e^{x \log{x}}=(1+\log{x})\ x^x.$$  But suppose that I didn't make this observation and instead tried to apply the following differentiation rules:  $$\frac{d}{dx}x^c=cx^{c-1} \qquad (1)\\ \frac{d}{dx}c^x = \log{c}\ \cdot c^x \quad (2)$$  which are valid for any constant $c$. Obviously neither rules are applicable to the form $x^x$ because in this case neither the base nor the exponent are constant. But if I pretend that the exponent is constant and apply rule $(1)$, I would get $f'(x)\stackrel{?}{=}x\cdot x^{x-1}=x^x.$ Likewise, if I pretend that the base is constant and apply rule $(2)$ I obtain $f'(x)\stackrel{?}{=}\log{x}\cdot x^x$.  It isn't hard to see that neither of the derivatives are correct. But here's where the magic happens: if we sum the two “derivatives” we end up with $$x^x+ \log{x}\cdot x^x=(1+\log{x})\ x^x$$ which is the correct expression for $f'(x)$.  This same trick yields correct results in other contexts as well. In fact, in some cases it turns out to be a more efficient way of taking derivatives. For example, consider $$g(x)=x^2 = \color{blue} x\cdot \color{red} x.$$ If we pretend the blue $\color{blue} x$ is a constant we would get $g'(x)\stackrel{?}{=}\color{blue}x\cdot 1=x$. Now if we pretend the red $\color{red}x$ is constant we get $g'(x)\stackrel{?}{=}1\cdot \color{red} x=x$. Summing both expressions we end up with $2x$ which is of course a correct expression for the derivative.  These observations have led me to the following conjecture:     Let $f(x,y)$ be a differentiable function mapping $\mathbb{R}^2$ to $\mathbb{R}.$ Let $f'_1 (x,y)=\frac{\partial}{\partial x} f(x,y)$ and $f'_2 (x,y)=\frac{\partial}{\partial y} f(x,y)$. Then for any $t$ we have: $$\frac{d}{dt}f(t,t)=f'_1 (t,t) + f'_2 (t,t).$$   (I apologise for the somewhat awkward notation which I could not seem to get around without causing undue ambiguity.)  This formulation also seems to lend itself to following generalisation:     Let $f:\mathbb{R}^N \to \mathbb{R}$ be a function differentiable in each of its variables $x_1,x_2,\ldots,x_N$. For $n=1,2,\ldots,N$ define $f'_n(x_1,x_2,\ldots,x_N)=\frac{\partial}{\partial x_n}f(x_1,x_2,\ldots,x_N)$. Let $t$ be any real number and define the $N$-tuple $T=(t,t,\ldots,t)$. Then one has: $$\frac{d}{dt} f(T)=\sum_n f'_n(T).$$   Thus my question is:   Is this true? How can it be proven? (Specifically in the case $N=2$ but also in the general case.) Give moderators the option to select a deletion reason when removing posts Does a shortcode with a single attribute have to use an array?