I have a situation where my original data have some comma. Actually that data is JSON object which contains some comma  I am reading a file which contain my JSON object by BufferedReader Now that BufferedReader output I am adding in list.  Everything is working fine but the request get failed because .toString(); added additional comma of list  too  String sCurrentLine = null; BufferedReader br = new BufferedReader(new FileReader("/home/shubham/git/productApi")); ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();  while ((sCurrentLine = br.readLine()) != null) {     System.out.println(sCurrentLine);     list.add(sCurrentLine); }  request.payload = list.toString(); System.out.println("dd =" + request.payload);   My JSON  {     "products":     {         "productsApp11": {             "code": "productsApp11",             "name": "productsApp11",             "attribute_set": "one",             "product_type": "product",             "status": "active"             }     } }   But because of .toString data is coming like below:-  [{,     "products": ,     {,         "productsApp11": {,             "code": "productsApp11",             ,             "name": "productsApp11",             ,             "attribute_set": "Apparel",             ,             "product_type": "product",             ,             "status": "active",         },     }, }]   Any solution would be appreciated
While working in a Java app, I recently needed to assemble a comma-delimited list of values to pass to another web service without knowing how many elements there would be in advance. The best I could come up with off the top of my head was something like this:  public String appendWithDelimiter( String original, String addition, String delimiter ) {     if ( original.equals( "" ) ) {         return addition;     } else {         return original + delimiter + addition;     } }  String parameterString = ""; if ( condition ) parameterString = appendWithDelimiter( parameterString, "elementName", "," ); if ( anotherCondition ) parameterString = appendWithDelimiter( parameterString, "anotherElementName", "," );   I realize this isn't particularly efficient, since there are strings being created all over the place, but I was going for clarity more than optimization.  In Ruby, I can do something like this instead, which feels much more elegant:  parameterArray = []; parameterArray &lt;&lt; "elementName" if condition; parameterArray &lt;&lt; "anotherElementName" if anotherCondition; parameterString = parameterArray.join(",");   But since Java lacks a join command, I couldn't figure out anything equivalent.  So, what's the best way to do this in Java?
When I look at the black and white photographs from professional photographers, I notice that they have a special look. Not a specific style—obviously each photographer has her own style—but a look which make them different from similar color photos, a special feeling, which makes them shine specifically as black and white and makes color irrelevant.  When I convert my own photos to black and white in Lightroom, they don't have any special look. They just look like any other of my photos, simply converted to black and white. I imagine that there are two reasons for that:   Some scenes are better for black and white. Talented and/or experienced photographers know which scenes would be beautiful in black and white, and shoot specifically those scenes. Moreover, they know how to adapt the scene itself and the lighting to black and white (for instance by not relying on the color contrast itself).  In my case, I don't think much about shooting for black and white. It comes only in post-processing, when I either think that the photo will look great in black and white (and very often, it doesn't), or I find the colors to be poor and turn the photo to black and white (which actually doesn't make the photo any better). Post-processing is much more complex than clicking on black and white button in an app. It involves not only adjusting black and white mix (i.e. raising or lowering the lightness of specific colors), but doing lots of other adjustments.  In my case, I do black and white mix, but other adjustments I do are similar to what I would do for a color photo: actually, I may even do them on a color photo, and only then turn it to black and white.   So, what should I take in account if I want to have decent black and white photographs? Are there specific techniques, tips, tricks or warnings for someone who usually shots in color and wants to start black and white photography?  Let me show some examples. Are those scenes not great for black and white photos in the first place? Or can they be salvaged through proper post-processing?  1.  First, a poorly done photo from Scotland with dubious composition and very poor colors that I was unable to correct in Lightroom.  The same image in black and white isn't much better. The difference between the trees and the grass on the hill is barely visible. Houses on the hill fade with the sky much more than in the original version.      2.  Here's a photo of a cute pet.  In black and white, the gap between the mouse's ear and the background is barely visible. There is absolutely no benefit compared to the original.      3.  Finally, an example of a much more contrasty picture. The black and white version is weird, since the lack of color makes it difficult to understand whether the soil is the actual sand or something else. I find the sky to be weird as well, and making the blue channel darker or lighter in Lightroom haven't changed that. Direct proof that nilpotent matrix has zero trace Is everything in .NET an object? When can we interchange “who/which" and "that”? So far I thought the words who and that are usually interchangeable:   There is the man who saw me.  There is the man that saw me.    Both sentences seem fine, who can be replaced with that. But in the following examples:   This is the man to whom I spoke.  This is the man to that I spoke.    The #2 sounds odd, which is why I don’t think it might be correct. The same observation for the words which and that, while   This is the ball which we used today.  This is the ball that we used today.    Seem to be in order and which can be replaced with that. But in the following examples the #2 sounds odd again.   This is the ball with which I scored.  This is the ball with that I scored.    I wonder if there’s any rule regarding the interchangeability of the above mentioned words. Does an Indian citizen need a transit visa in Australia? Indian passport holder. Do I need transit visa in Sydney? On OpenBSD and with OpenBSD's  and , is it possible to store the  of a user in a  repository of the same user?  What would be the proper way to accomplish something like this?  (To steer the answer into the correct direction, I would not be opposed to changing some permissions in the system, although I'd rather not have to recompile the binaries, nor violate any good security paradigms.) Where does de Broglie wavelength $\lambda=h/p$ for massive particles come from? I'm curious where the  $p=\frac{h}{\lambda}$ comes from?   I know that for light (which has no rest mass), the following is true:  $E=pc$ and $E=hf$  so,  $$pc=hf \Rightarrow p=\frac{hf}{c}=\frac{h}{\lambda}$$  But how is the expression $p=\frac{h}{\lambda}$ obtained for a massive particle where $E\neq pc$? I've read some people claim that the expression can be derived, and others saying it's an experimentally verified relationship. I have a burning desire to install RPMs onto my Ubuntu installation - is this possible? Can I use Yum - or another RPM Package Management tool? I wrote a regular expression which works well in a certain program (grep, sed, awk, perl, python, ruby, ksh, bash, zsh, find, emacs, vi, vim, gedit, …). But when I use it in a different program (or on a different unix variant), it stops matching. Why? I have been wondering about the differences between model paramters and model hyperparameters, as well as what their categorization means for a learning problem.  Is the distinction between model parameters and hyperparameters only about reducing the complexity of the problem or are there implications for the 'model quality' to be considered?  Let's consider an example from (1, Eq. 2.43), a linear expansion of basis functions   $$f_\theta(x) = \sum_{m=1}^{M} \theta_m h_m(x), $$  where $h_m\:\forall m=1,...,M$ is some function of $x$, $\theta=[\theta_1,...,\theta_M]^\intercal$ is a vector of the parameters of the model and $M$ is the number of basis functions.   In my understanding, we would consider $\theta$ to contain the parameters of the model, while $M$ is a .  To quote the Wikipedia article of hyperparameter that I linked above:     In machine learning, a hyperparameter is a parameter whose value is   set before the learning process begins. By contrast, the values of   other parameters are derived via training.   It makes sense treating the values in $\theta$ as parameters that should be learned from the data, similar to the coefficients in a linear model - it is surely far more reliable  and  specifying them manually would be quite annoying, although it's not impossible. But what about $M$? It surely is easier to pick some integer value for it. But would it really be terrible to determine $M$ based on the data, too? Probably not, as that is what we would do if we search a grid of possible values for the best performing one.   Let's consider the above basis expansion model and choose Gaussian kernel functions to serve as basis functions. As the Kernel itself has parameters too  this makes the problem a bit more complicated.  $$f_\theta(x) = \sum_{m=1}^{M}\theta_m K_{\lambda_m}(\mu_m,x), $$ with $\mu_1,...,\mu_m$ being the location of the kernels and $\lambda_1,...,\lambda_m$ their scales/bandwidths.  Friedman et al. write in (1, p. 36)        "In general we would like the data to dictate them as well. Including   these as parameters changes the regression problem from a   straightforward linear problem to a combinatorially hard nonlinear   problem. In practice, shortcuts such as greedy algorithms or two stage processes are used."   I see that if we were to treat $M$, $\theta_1 ... \theta_M$, $\mu_1 ... \mu_M$ and $\lambda_1 ... \lambda_M$, as model parameters, this problem would be really complex, especially with the choice of $M$ determining the number of the other parameters. But what if we simplify the model definition - let us for example use the same scale/bandwidth for each kernel, that gives us only one parameter $\lambda$. Furthermore, let's say we specify $\mu_1 ... \mu_M$ based on some heuristic, which would mean we treat it as a hyperparameter.  This gives us   $$f_{\theta,\lambda}(x) = \sum_{m=1}^{M}\theta_m K_\lambda(\mu_m,x), $$  Besides increased complexity of the involved optimization problem, does treating $\lambda$ as a parameter rather than a hyperparameter have other negative or undesired effects?      (1) Friedman, Jerome, Trevor Hastie, and Robert Tibshirani. The   elements of statistical learning. Vol. 1. No. 10. New York: Springer   series in statistics, 2001. Official reasons for "Software caused connection abort: socket write error" Can I achieve a torchlight effect (lighter area around a light source) in a 2D game? I am thinking of writing myself a simple 2D game. It will not shine with perfect graphics or gameplay at first, but I'd consider it my first step in PC game development. So, imagine such simple sprite-based 2D game (like Heroes IV or Startcraft BroodWar).  I want the gameplay to support day/night with the according lighting changes and at the same time it will be madness to have to create sprites for every lighting nuance. So, I decided adding a semi-transparent layer on top of other objects will be enough.   The issue with this solution is if I have a light source object in the game (like the hero wearing a torch, or a burning building), there must be a lighter area around it, right? Since I am putting my semi-transparent layer over everything, how would you suggest to achive the torchligt visual effect I want? Maybe redraw that layer adding 'gaps' or differently colored areas based on the lighting effect? Complicated FOR loop nesting. Having trouble cleaning up legacy code I am trying to tidy up some really bad legacy code from an old developer and I'm trying to get rid of these nested for loops. The code below shows what I'm currently working with. I've fixed this before with nested SOQL queries but nothing like this. How would this need to look to remove these for loops (except Trigger.New)? Would I use Maps? How would I do that?  map&lt;Id,SObject&gt; mapProperyIdBudDetail = util.GetObjFields(setPropertyId, 'Property'); map&lt;Id,SObject&gt; mapSpaceIdBudDetail = util.GetObjFields( PropertyMap.keyset(), 'Space');  for ( Lease__c l: Trigger.New ) {      if(mapProperyIdBudDetail.get(PropertyMap.get(l.space__c))!=null) {          lProperties = new List&lt;SObject&gt;{mapProperyIdBudDetail.get(PropertyMap.get(l.space__c))};              for ( SObject p: lProperties ) {                  for ( String fm: FieldMap.keyset() ) {                      if ( p.get(FieldMap.get(fm)) != Null) {                         l.put(fm,p.get(FieldMap.get(fm)));                     }                  }             }     } } In reading through the original GCM specification (), the composition of the 128 bit Initialization Vector as a concatenation of a 96b nonce and a 32b unsigned wrapping counter seems arbitrary and forces the scrambling pattern to repeat every 232 16-byte block.  Is the algorithm expected to be secure for significantly longer stream lengths if for example the IV were a 128b nonce XORed with a 64b or 128b counter, or are there known cryptanalysis issues that begin to arise? Ubuntu 20.04 on DualBoot fail 90% of tries - Initramfs unpacking failed: Decoding failed I just installed Ubuntun 20.04 on a Dell Latitude 7400 on DualBoot. I had to remove the RST as mentioned on this post :  It works but now I need to test 5 or more times to boot. After the grub screen, most of the time i have a black screen. Sometimes I have this error : Initramfs unpacking failed: Decoding failed And then it starts.  here is a file called initramfs.conf cat /etc/initramfs-tools/initramfs.conf MODULES=most  BUSYBOX=auto  COMPCACHE_SIZE=&quot;&quot;  COMPRESS=lz4   DEVICE=  NFSROOT=auto RUNSIZE=10% Extracting only the BibTex records relevant to the paper My colleague asked me to write a page for a paper he writes. I wrote the page in LyX, compiled it to LaTeX, and sent him the TeX files. Then he reminded me that I forgot to send the .bib file with all the references.  But, my .bib file is huge - it contains over 1000 references (I have a global BiBTeX file for all my papers). The page I wrote uses only about 20 of them.  Is there an automatic way to extract from the bib file, only the records relevant to the current paper? Convert char to int in C# What are the benefits of running chef-server instead of chef-solo? I am looking at automated deployment solutions for my team and have been playing with Chef for the past few days. I've been able to get a simple web app up an running from a base Red Hat VM using chef-solo.  Our end goal is to use Chef (or another system) to automatically deploy application topologies to the cloud as we run builds. Our process would basically run like this:   Our web app code, dependencies, and chef cookbooks are stored in SCM A build is executed and creates a single package for images to acquire and test against The build engine then deploys new cloud images that run a chef client to get packages installed. The images acquire the cookbooks from SCM or the Chef server and install everything to get up and running   What are the benefits and/or use cases for getting a Chef Server running?  Are there any major benefits to have a Chef Server hold and acquire the cookbooks from SCM vs. using chef-solo and having a script that will pull the cookbooks from SCM? Proving that if $f: \mathbb{C} \to \mathbb{C} $ is a continuous function with $f^2, f^3$ analytic, then $f$ is also analytic Let $f: \mathbb{C} \to  \mathbb{C}$ be a continuous function such that $f^2$ and $f^3$ are both analytic. Prove that $f$ is also analytic.   Some ideas: At $z_0$ where $f^2$ is not $0$ , then $f^3$ and $f^2$ are analytic so $f = \frac{f^3}{f^2}$ is analytic at $z_0$ but at $z_0$ where $f^2$ is $0$, I'm not able to show that $f$ is analytic. Macros for code annotations