While building a flask website, I'm using an external JSON feed to feed the local mongoDB with content. This feed is parsed and fed while repurposing keys from the JSON to keys in Mongo.  One of the available keys from the feed is called "img_url" and contains, guess what, an url to an image.  Is there a way, in Python, to mimic a php style cURL? I'd like to grab that key, download the image, and store it somewhere locally while keeping other associated keys, and have that as an entry to my db.  Here is my script up to now:      import json     import sys     import urllib2     from datetime import datetime      import pymongo     import pytz      from utils import slugify     # from utils import logger      client = pymongo.MongoClient()     db = client.artlogic      def fetch_artworks():     # logger.debug("downloading artwork data from Artlogic")  AL_artworks = [] AL_artists = [] url = "http://feeds.artlogic.net/artworks/artlogiconline/json/"  while True:     f = urllib2.urlopen(url)     data = json.load(f)      AL_artworks += data['rows']      # logger.debug("retrieved page %s of %s of artwork data" % (data['feed_data']['page'], data['feed_data']['no_of_pages']))      # Stop we are at the last page     if data['feed_data']['page'] == data['feed_data']['no_of_pages']:         break      url = data['feed_data']['next_page_link']  # Now we have a list called ‘artworks’ in which all the descriptions are stored # We are going to put them into the mongoDB database, # Making sure that if the artwork is already encoded (an object with the same id # already is in the database) we update the existing description instead of # inserting a new one (‘upsert’).  # logger.debug("updating local mongodb database with %s entries" % len(artworks))  for artwork in AL_artworks:     # Mongo does not like keys that have a dot in their name,     # this property does not seem to be used anyway so let us     # delete it:     if 'artworks.description2' in artwork:         del artwork['artworks.description2']     # upsert int the database:     db.AL_artworks.update({"id": artwork['id']}, artwork, upsert=True)       # artwork['artist_id'] is not functioning properly     db.AL_artists.update({"artist": artwork['artist']},                       {"artist_sort": artwork['artist_sort'],                        "artist":  artwork['artist'],                        "slug": slugify(artwork['artist'])},                       upsert=True)  # db.meta.update({"subject": "artworks"}, {"updated": datetime.now(pytz.utc), "subject": "artworks"}, upsert=True) return AL_artworks      if __name__ == "__main__":         fetch_artworks()
I have a small utility that I use to download an MP3 file from a website on a schedule and then builds/updates a podcast XML file which I've added to iTunes.  The text processing that creates/updates the XML file is written in Python. However, I use wget inside a Windows .bat file to download the actual MP3 file. I would prefer to have the entire utility written in Python.  I struggled to find a way to actually download the file in Python, thus why I resorted to using wget.  So, how do I download the file using Python?
Why aren't hash values for "nothing" (empty) defined as all zeros? Any decent hash algorithm will produce basically "random like" values for any given input including the empty input.  For example MD5 produces d41d8cd98f00b204e9800998ecf8427e on an empty input.  I wonder, however, why the MD5 algorithm wasn't defined to have a final step where the output is XORed with d41d8cd98f00b204e9800998ecf8427e. This should not affect the cryptographic strength of the hash algorithm, and it would have the convenient property that a hash of all zeros represented a zero input.  Would it simply just because adding that step would slow the hash down a bit? Hello native English speakers!  I want to ask you about either and both. I tried to find similar questions in this site but I think they were not same with these ones.  My questions are;   I was invited to two parties, but I couldn't go to ------- of them.  I took two books with me on holidays, but I didn't read ------- of     them.   I choose both for questions 1 and 2. But the right answers were either. But I think both and either are correct either. Am I right?   Thank you in advance! Setting width/height as percentage minus pixels Can the coefficient of static friction be less than that of kinetic friction? Was Mjolnir ever used for building something? In the movie Thor (2011), while he was about to crown Thor as the next king of Asgard, Allfather Odin describes the mighty hammer Mjolnir as the following:      So long entrusted with this mighty hammer, Mjolnir. Forged in the heart of a dying star, from the sacred metal of Uru. Only one may ift it. Only one is worthy. Who wields this hammer commands the lightning and the storm. Its power has no equal -- as a weapon, to destroy, or as a tool, to build. It is a fit companion for a King.   We know Mjolnir as a weapon of destruction but are there references where it is used to build something? Folders Completely Hidden Except via Save As I'm using an audio program called Supercollider on Windows 10. I have saved some files in a folder called "tunes" from SC via Save As, but Windows Explorer and CMD both seem unable to recognise access or recognise the "tunes" folder.  C:\Users\HP&gt;cd "C:\Program Files (x86)\SuperCollider-3.7.2\supercollider-robin\tunes" The system cannot find the path specified.  C:\Program Files (x86)\SuperCollider-3.7.2\supercollider-robin&gt;dir/a doesn't show it either.  However, when saving from SC with Save As, it's there clear as day. I can even shift+right-click to get the path: "C:\Program Files (x86)\SuperCollider-3.7.2\supercollider-robin\tunes"  This makes no sense to me. Can anyone explain and tell me how to access my folder tunes folder please? I love admin-ajax.php. But I hate having to localize in order to point frontend scripts to it, and I wish there was an equivalent, easy-to-find file for themes. (It also just bothers me to see frontend requests go through "/wp-admin/". No practical reason, just looks ugly IMO.)  So I've simply copied admin-ajax.php to the root dir at "/ajax.php", adjusted the include paths and removed the WP_ADMIN constant definition. Seems to work like gangbusters (I can now just direct all my frontend AJAX requests to /ajax.php! And I can still use the normal wp_ajax hooks in my plugins!).  But is this safe? What might go wrong? Since this isn't built into core, I assume there's a good reason as to why not. But looking through the code, I can't see any immediate problems.   You're smart--tell me if this approach is crazy. Or if there's a simpler method that I'm overlooking. What is the maximum or minimum tire width I can fit on my bicycle We often get questions on bicycles.stackexchange about fitting wider or narrower tires to bicycles. We have a large number of these with answers suiting the specific bike or style of bicycle in question, but I have been unable to find one that provides a generic answer covering off all things that need to be considered. For most bicycles, the answer is the same regardless of the specific style and sizes of tires in question.   This is intended as a canonical question that we can point closed questions to. "Reality" of length contraction in SR I was in argument with someone who claims that length contraction is not &quot;real&quot; but only &quot;apparent&quot;, that the measurement of a solid rod in its rest reference frame is the &quot;real length&quot; of the rod and all other measurements are somehow just &quot;artificial&quot; and &quot;apparent&quot;. Seemed to me like a bad conversation about poorly defined words and not really relevant to physics, but then some quotes were offered:  ...so that the back appears closer to the front. But of course nothing has happened to the rod itself.  (Rindler)  The effects are apparent (that is, caused by the motion) in the same sense that proper quantities have not changed.  (Resnick &amp; Halliday) At the same time, the  insists that length contraction and time dilation are &quot;real&quot;, with observable consequences:  Time and space dilation are often referred to as ‘perspective effects’ in discussions of STR. Objects and processes are said to ‘look’ shorter or longer when viewed in one inertial frame rather than in another. It is common to regard this effect as a purely ‘conventional’ feature, which merely reflects a conventional choice of reference frame. But this is rather misleading, because time and space dilation are very real physical effects, and they lead to completely different types of physical predictions than classical physics. [...] However, this does not mean that time and space dilation are not real effects. They are displayed in other situations where there is no ambiguity. One example is the twins' paradox, where proper time slows down in an absolute way for a moving twin. And there are equally real physical effects resulting from space dilation. It is just that these effects cannot be used to determine an absolute frame of rest.  I went through a lot of Einstein, Minkowski and Lorentz original material, and didn't find anything about what is &quot;real&quot; and what is not. Finally, I know about muons, where the effects of SR seem to be very real (from , but I had seen it in a physics class before):  When a cosmic ray proton impacts atomic nuclei in the upper atmosphere, pions are created. These decay within a relatively short distance (meters) into muons (their preferred decay product), and muon neutrinos. The muons from these high energy cosmic rays generally continue in about the same direction as the original proton, at a velocity near the speed of light. Although their lifetime without relativistic effects would allow a half-survival distance of only about 456 m (2,197 µs×ln(2) × 0,9997×c) at most (as seen from Earth) the time dilation effect of special relativity (from the viewpoint of the Earth) allows cosmic ray secondary muons to survive the flight to the Earth's surface, since in the Earth frame, the muons have a longer half life due to their velocity. From the viewpoint (inertial frame) of the muon, on the other hand, it is the length contraction effect of special relativity which allows this penetration, since in the muon frame, its lifetime is unaffected, but the length contraction causes distances through the atmosphere and Earth to be far shorter than these distances in the Earth rest-frame. Both effects are equally valid ways of explaining the fast muon's unusual survival over distances.  So which is which? Why do Rindler, Resnick &amp; Halliday use the word &quot;apparent&quot;? Graphing $y = \frac{x^2-4}{x-2}$ I'm trying to graph the function $y = \frac{x^2-4}{x-2}$.  I factored the numerator into $(x+2)(x-2)$, and then canceled the common factor (x-2), leaving the function as $y = x + 2$.    Is it acceptable to graph the original function as $y = x + 2$, a straight line with domain and range all real numbers?  Or do you have to restrict the domain as in the original function?  Thanks, Sean Prove that every terms of a sequence defined by a recurrence relation is a perfect square. i just finished updating my Macbook pro to macOS Catalina and after the installation finished i got this error message that keeps reappearing. i do not know or have a file named "qnmqkmkrqwfq" (i tried searching for it) and when i press show in finder or ok it disappears for a second and then pops up again for no reason and i am not trying to open any files or apps. i searched and the only solution i found was setting "Allow applications downloaded from: Anywhere" but it did not work. Please Help. The computed moments of log normal distribution can be found . How to compute them? Use of inequality $1 - \cos (x) \leq x^2 /2$ In  answer the value of $1 - \cos(x)$ has to be evaluated in order to find its upper limit, if it exists.  In particular, $x = 2 \pi / n$. The answer is related to the length of a side of a regular $n$-gon inscribed into a unit-radius circumference; because the perimeter of the $n$-gon is always less than $2 \pi$, the single side must always be less than $2 \pi / n$.  The inequality  $$1 - \cos (x) \leq \displaystyle \frac{x^2}{2}$$ (1)  is used and the proof is completed with   $$2(1 - \cos(x)) \leq (2 \pi / n)^2$$  $$\sqrt{2(1 - \cos(x))} \leq 2 \pi / n$$  But it is well known that the cosine is a function $f(x) \in [-1;1]$, so $1 - \cos (x) \in [0,2]$. By using this information, we would obtain  $$1 - \cos (x) \leq 2$$ (2)  The proof would provide  $$2(1 - \cos(x)) \leq 4$$  $$\sqrt{2(1 - \cos(x))} \leq 2$$  which is a completely different result.   Why in that case it is preferable to use (1) instead of (2)? How to choose when it is convenient to use (1) and when to use (2) in a proof? Breaking single polygon into multiple polygons? I created voronoi polygons after which I dissolved them on the basis of one attribute. Now there are cases where in for one single attribute "abc" I have3 polygons at different places with same object id. I would like to break these into 3 polygons as they are at different locations.  Is there any tool in ArcGIS Desktop or QGIS which can help me in doing that? I know that we don't have automatic login for the Data Explorer, but what's with the automatic timeout/logout?  There have been times that I am logged into the site, maybe I walk away for a little bit, and I come back to being logged out.    Is there a reason for logging us out of Data Explorer?  If so, is it possible to either remove the timeout or extend the period of time before timeout? Converting points to raster in ArcGIS? Timeout for Always On Synchronous Commit Mode For SQL Server Enterprise's Always On availability groups, how can you configure the timeout for Synchronous Commit mode?  Is there a maximum?  Can it work, for example, between continents? Thanks Wikipedia says "In the mathematical discipline of linear algebra, a matrix decomposition or matrix factorization is a factorization of a matrix into a product of matrices. There are many different matrix decompositions; each finds use among a particular class of problems."  But in my opinion decomposition term should be used to represent breaking a matrix in different sub-matrices or some new matrices created after some operation on original matrix which if used together and passed through some algorithm(not necessarily product), shall reproduce the original matrix.  Is there some different terminology to represent what I am expecting to say? Opening document library files in popup or new window Is there any easy way to open the document library files in a new window or popup depending on the file types?  e.g. PDF - In Adobe reader (currently opens in IE)  Image file (currently opens in IE)