I  get the REST response data from a URL. I then write it to a JSON file, however, it's put it on one line in a long string, and I need to have it in readable format in the JSON file.  My code is:  require 'rubygems' require 'json' require 'rest-client'  class Rest    def self.getData      response = RestClient.get 'http://jsonplaceholder.typicode.com/posts'     response = JSON.parse(response)      File.open('/Users/robertreed/RubymineProjects/draft/posts.json', 'w') do |f|       f.write(response.to_json)     end        puts response      end    getData  end   It's printing to the console and writing to the JSON file on one line:  [{"userId"=&gt;10, "id"=&gt;100, "title"=&gt;"at nam consequatur ea labore ea harum", "body"=&gt;"cupiditate quo est a modi nesciunt}]   Any suggestions on how I could achieve this?
I would like my JSON output in Ruby on Rails to be "pretty" or nicely formatted.   Right now, I call to_json and my JSON is all on one line.  At times this can be difficult to see if there is a problem in the JSON output stream.  Is there way to configure to make my JSON "pretty" or nicely formatted in Rails?
Why on average does each bootstrap sample contain roughly two thirds of observations? (p.236)  has a proof that the equation $e^z-z=0$ has infinitely many complex solutions:    I'm curious if there are any particularly elegant ways to see this, other than that given in the text. Let $F : X → X$ be continuous. Prove that the set $\{x ∈ X : F(x) = x\}$ of fixed points of F is closed in X Here X is a Hausdorff Space.  I know that singleton sets, {x}, are closed in a Hausdorff space. Although Im not sure if thats how to use the Hausdorff property.   Should I investigate $h=F(x)-x$?  Can anyone give a hint How to make the tick thickness as the axis line? I am trying to make the thickness of the ticks equal to the axis line thickness. That is what I have so far:  \documentclass{article}   \usepackage{pgfplots}  \pgfplotsset{compat=1.5}   \begin{document}     \begin{tikzpicture}     \begin{axis}[         xlabel=Binding Energy (eV),         ylabel=Intensity (a.\,u.),         xtick pos=left,         x dir= reverse,         ytick = \empty,         every x tick/.style={color=black, thin},         tick align=outside,         xlabel near ticks,         ylabel near ticks,         xmin = 96,         xmax = 108     ]         %\addplot[mark=none] table[x=BE,y=cnts] {si2p.txt};         % This data looks similar:         \addplot[mark=none, smooth] table[x=BE,y=cnts] {             BE      cnts             95      1             98      1             99      10             99.5    5             100 6             101 2             108 2         };      \end{axis}     \end{tikzpicture} \end{document}     But if you take a closer look on the ticks on the outside, you'll see that they are somehow clipped or a least thinner. They are also black so the style seems to work for them.    Is this a bug or can I change the clipping region? And as a second question: is thin the correct value for the thickness? I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?  For example:  I get back:  &amp;#x01ce;   which represents an "ǎ" with a tone mark.  In binary, this is represented as the 16 bit 01ce.  I want to convert the html entity into the value  u'\u01ce' For the bar chart proposed, I would like to use different color for each single bar. How can I  do this?  \documentclass{article} \usepackage{pgfplots}  \begin{document}  \begin{tikzpicture}   \begin{axis}[     title=Title,         xbar,         xmajorgrids = true,         bar width=6mm,          width=12cm, height=5.5cm,          enlarge y limits=0.2,         xlabel={\#number},         symbolic y coords={A,B,C,D},         ytick=data,         nodes near coords, nodes near coords align={horizontal},   ]    \addplot coordinates {(1,A) (7,B) (5,C)(2,D)}; \end{axis} \end{tikzpicture}  \end{document} Using sed with an integer variable I want to sed using a variable.  For example, sed -n '1,10p' file. So, instead of 10, I want to use $k where k is an integer. For the recently reported production (January 2017) of metallic hydrogen in the laboratory - what is the evidence exactly? My google news page has burst forth the news that metallic hydrogen has been produced in a laboratory using a diamond anvil cell. Only  mentions (at this particular moment) that it has been called into question at - at least - premature. That can be read about in Nature:   Here I only want to ask about the evidence. Is it only the sudden change in visual appearance change as recorded in a camera on top of the microscope, at a specific temperature and pressure? That it "looks shiny?" Or is there actually more direct data than that?  note: I am not asking if the data is sufficient or not, nor if it is convincing, or metallic or not. Just a narrowly defined question about the extent of the observations that have lead to the proposal that a metallic state was achieved.     above: potentially three states of hydrogen as viewed in a diamond anvil cell, from . Possible to do a MySQL foreign key to one of two possible tables? Well here's my problem I have three tables; regions, countries, states.  Countries can be inside of regions, states can be inside of regions.  Regions are the top of the food chain.  Now I'm adding a popular_areas table with two columns; region_id and popular_place_id.  Is it possible to make popular_place_id be a foreign key to either countries OR states.  I'm probably going to have to add a popular_place_type column to determine whether the id is describing a country or state either way. How to address a professor in person at US universities? At US universities, how should one address a professor while talking to him or her? In my home country, we usually address the professors as either "sir" or "madam" while talking about our queries in person.   What's the norm at US universities? I am looking for a package to create bullet gauge graphs, but I couldn't find any.  A bullet graph looks like this:    and an ample description/specification can be found   It is available in Mathematica 9 ()  Is it possible create this kind of graphs in a easy way with TeX (like Matehmatica 9 or similar)? How can I create documents in LaTeX using a calligraphic first letter for chapters? Can Wubi use the ISO I already have? The Windows Installer for Ubuntu desktop instructions say that an ISO image for Ubuntu is downloaded during the installation process.  But what if I already have an ISO image for Ubuntu. Can I make the Windows Installer use that, so it doesn't have to download an ISO image again?  12.04 LTS and 12.10 are the versions of Ubuntu I'm interested in installing, in case that matters. Prove that $ \sum_{n=0}^\infty \frac{z^{2^n}}{1-z^{2^{n+1}}}=\frac{z}{1-z} $ Show that for $|z|&lt;1$, one have $$ \frac{z}{1-z^2}+\frac{z^2}{1-z^4}+\cdots+\frac{z^{2^n}}{1-z^{2^{n+1}}}+\cdots = \frac{z}{1-z} $$ and $$ \frac{z}{1+z}+\frac{2z^2}{1+z^2}+\cdots+\frac{2^k z^{2^k}}{1+z^{2^k}}+\cdots = \frac{z}{1-z} $$ Use the dyadic expansion of an integer and the fact that $2^{k+1}-1=1+2+2^2+\cdots+2^k$. Can't understand a proof: Let $a,b,c$ be integers. If $a$ and $b$ divide $c$, then $lcm(a,b)$ also divides $c$  Proof I've been shown:  Since $c$ is a common multiple of $a,b$, it means that $lcm(a,b) \leq c$.  So: $c=q\cdot lcm(a,b)+r$, $q \in \mathbb Z$ and $0\leq r \leq lcm(a,b)$  Since $c$ and $lcm(a,b)$ are common multiples of $a,b$, then so is $r$. But $m$ is the least common divisor, then it means $r=0$.   [Proof taken from: http://www.math.utah.edu/~wood/4400/hw1sol.pdf]  I cannot understand the last step... Why does it imply that $r=0$?   Thank you! I have a card that is 50% used with 7% interest. The max credit limit on the card is $10,000, and I used $5000. I have another card that is $14,000 and I have $2900 used, but the interest is 14.9%. I want to move the $2900 card to the other card that has a lower interest rate (7%). This will bring the balance close to the max, but the idea is to focus on this one card and bring the balance down as quickly as possible. is this a wise choice? I am looking to purchase a house in 6 months so I thought that this might be enough time to pay it off and keep my score up. My scores are currently in the low 700s. Scala 2.10 + Json serialization and deserialization How to detect, from browser, if user is running in Remote Desktop session? How do I set a featured image (thumbnail) by image URL when using wp_insert_post()? While looking through the , I noticed that there's no parameter in the array it requires which will allow me to set the 'Featured Image' for a post, displayed as the  in my theme.   I have looked into functions like , as suggested by Mr. Bennett, but this seems to be a relatively new addition to WordPress itself and the WordPress codex. As such, there aren't any sources that I can find which explain how the $thumbnail_id parameter should be acquired and supplied. If this really is the function to use, in what way could I provide it with a valid $thumbnail_id parameter when all I have is an image URL?  Thanks in advance! Continuity of Integration for a measurable function I am having difficulties with this problem:  Let $f$ be a measurable function on $R$. Show that $\lim\limits_{n \to \infty} \int\limits_{-n}^{n} | f | = \int\limits_{R} | f | $  My idea is to use Continuity of integration: We need an ascending collection of measurable sets. These are $E_n = R \cap [-n, n]$ $R = \bigcup E_n$ Now if we apply Continuity of Integration we have:  $\lim_{R} |f| = \lim\limits_{n \to \infty} \int_{E_n} =\lim\limits \int_{-n}^{n} |f |$. My problem is Continuity requires f to be intergrable and all i know is that f is measurable.  Another way i was thinking to use monotone convergence theorem, but i am not sure how to create the sequences.  Any Ideas? thanks