I need to rewrite the following function using only the python standard library.  def request_release_info(self):     req = requests.get('https://api.github.com/repos/user/repo/releases/latest',                        auth=('user', 'token'))     content = req.json()     return content   So I need to replace Requests by Urllib/Urllib2 but I'm unable to find a way to pass my username and my token in a similar way.  Thank you for your help !
I'm playing around, trying to write some code to use the  APIs to shorten a URL.  After reading , I tried:     TRIM_API_URL = 'http://api.tr.im/api'    auth_handler = urllib2.HTTPBasicAuthHandler()    auth_handler.add_password(realm='tr.im',                              uri=TRIM_API_URL,                              user=USERNAME,                              passwd=PASSWORD)    opener = urllib2.build_opener(auth_handler)    urllib2.install_opener(opener)    response = urllib2.urlopen('%s/trim_simple?url=%s'                               % (TRIM_API_URL, url_to_trim))    url = response.read().strip()   response.code is 200 (I think it should be 202).  url is valid, but the basic HTTP authentication doesn't seem to have worked, because the shortened URL isn't in my list of URLs (at ).  After reading  I also tried:     TRIM_API_URL = 'api.tr.im/api'    password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()    password_mgr.add_password(None, TRIM_API_URL, USERNAME, PASSWORD)    auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr)    opener = urllib2.build_opener(auth_handler)    urllib2.install_opener(opener)    response = urllib2.urlopen('http://%s/trim_simple?url=%s'                               % (TRIM_API_URL, url_to_trim))    url = response.read().strip()   But I get the same results.  (response.code is 200 and url is valid, but not recorded in my account at .)  If I use query string parameters instead of basic HTTP authentication, like this:     TRIM_API_URL = 'http://api.tr.im/api'    response = urllib2.urlopen('%s/trim_simple?url=%s&amp;username=%s&amp;password=%s'                               % (TRIM_API_URL,                                  url_to_trim,                                  USERNAME,                                  PASSWORD))    url = response.read().strip()   ...then not only is url valid but it's recorded in my tr.im account. (Though response.code is still 200.)  There must be something wrong with my code though (and not tr.im's API), because  $ curl -u yacitus:xxxx http://api.tr.im/api/trim_url.json?url=http://www.google.co.uk   ...returns:  {"trimpath":"hfhb","reference":"nH45bftZDWOX0QpVojeDbOvPDnaRaJ","trimmed":"11\/03\/2009","destination":"http:\/\/www.google.co.uk\/","trim_path":"hfhb","domain":"google.co.uk","url":"http:\/\/tr.im\/hfhb","visits":0,"status":{"result":"OK","code":"200","message":"tr.im URL Added."},"date_time":"2009-03-11T10:15:35-04:00"}   ...and the URL does appear in my list of URLs on .  And if I run:  $ curl -u yacitus:xxxx http://api.tr.im/api/trim_url.json?url=http://www.google.co.uk   ...again, I get:  {"trimpath":"hfhb","reference":"nH45bftZDWOX0QpVojeDbOvPDnaRaJ","trimmed":"11\/03\/2009","destination":"http:\/\/www.google.co.uk\/","trim_path":"hfhb","domain":"google.co.uk","url":"http:\/\/tr.im\/hfhb","visits":0,"status":{"result":"OK","code":"201","message":"tr.im URL Already Created [yacitus]."},"date_time":"2009-03-11T10:15:35-04:00"}   Note code is 201, and message is "tr.im URL Already Created [yacitus]."  I must not be doing the basic HTTP authentication correctly (in either attempt).  Can you spot my problem?  Perhaps I should look and see what's being sent over the wire?  I've never done that before.  Are there Python APIs I can use (perhaps in pdb)?  Or is there another tool (preferably for Mac OS X) I can use?
Why does a bezier curve twist when rotated? If I create a bezier curve and rotate it in edit mode it does not accordingly rotate the tilt of the handles which creates an undesirable twisting along the curve.  Here is an example using a bezier circle with a square used for a bevel object:   Here it is after being rotated 90° about the y-axis:   How do I prevent/fix this? Can you be refused a visitor visa to US if you have bad Credit there? I have complicated math expression:    Vertical spacing between text and fraction line is too small. I tried to define new \frac command (with amsmath package) with adjustable vertical spaces. As you can see, the result is not satisfying:    \documentclass[a4paper,fleqn,leqno]{article} \usepackage{polyglossia} \usepackage{color,pifont,fontspec} \usepackage[top=2.54cm,bottom=2.54cm,left=2.54cm,right=2.54cm]{geometry} \usepackage{tikz,tikz-3dplot,graphicx} \usepackage{mathtools,breqn,amsmath} \usepackage[fontsize=12]{scrextend} \usepackage{array,multirow} \usepackage{pgfplots} \DeclareMathSizes{12}{14}{14}{10} \newcommand{\myfrac}[3][0pt]{\genfrac{}{}{}{}{\raisebox{#1}{$#2$}}{\raisebox{-#1}{$#3$}}} \begin{document} \begin{dmath*}[breakdepth={0},style={\mathindent=0pt},spread={10pt}] {n=\myfrac[3pt]{\myfrac[3pt]{0,0625N+0,0215}{2}-0,043}{\myfrac[3pt]{\myfrac[3pt]{\scriptstyle 0,0625N+0,0215}{\scriptstyle 2}-0,043}{\myfrac[3pt]{\scriptstyle N}{\scriptstyle 2}-1}+0,0215}} \end{dmath*} \end{document}   How can I enlarge verticall spacing in whole fraction? Is the proposal creator guaranteed moderator status? When an Area 51 site goes into public beta is the person who created the proposal one of the pro tem moderators or not?  They are talking on Area 51 about combining all the sports proposals into , including one I proposed. Would I still be one of the pro tem moderators on the merged site?  Is the proposal creator afforded any elevated status or perk? Let $x$ and $y$ be integers not congruent to $0$ modulo $p$ where $p$ is a prime. Prove that if $p \equiv 3 \pmod{4}$ then $x^2+y^2 \not \equiv 0 \pmod{p}$.   I thought about proving this algebraically and by contradiction. So we say $x^2+y^2 = pz$ and have to show this is impossible. Fibonacci sequence and Euclidean algorithm's connection. Let $f_1, f_2,\dots,f_i,\dots$ be the Fibonacci sequence with $f_1=f_2=1$. For any $a,b\in\mathbb{N}$ with $a&lt;b$, suppose the Euclidean algorithm takes $n$ long divisions to compute $\gcd(a,b)$. If $a\le f_j$, then $n\le j-1$, for $j\ge2$.   I want to prove this problem. But I can't see any connection between Fibonacci and Euclidean algorithm. If anyone can give a hint about first step, it will be very thankful.  My guess is to use induction. How to sort a list of objects based on an attribute of the objects? I've got a list of Python objects that I'd like to sort by an attribute of the objects themselves.  The list looks like:  &gt;&gt;&gt; ut [&lt;Tag: 128&gt;, &lt;Tag: 2008&gt;, &lt;Tag: &lt;&gt;, &lt;Tag: actionscript&gt;, &lt;Tag: addresses&gt;,  &lt;Tag: aes&gt;, &lt;Tag: ajax&gt; ...]   Each object has a count:  &gt;&gt;&gt; ut[1].count 1L   I need to sort the list by number of counts descending.  I've seen several methods for this, but I'm looking for best practice in Python. Show that $8 \mid (a^2-b^2)$ for $a$ and $b$ both odd If $a,b \in \mathbb{Z}$ and odd, show $8 \mid (a^2-b^2)$.   Let $a=2k+1$ and $b=2j+1$. I tried to get $8\mid (a^2-b^2)$ in to some equivalent form involving congruences and I started with $$a^2\equiv b^2 \mod{8} \Rightarrow 4k^2+4k \equiv 4j^2+4j \mod{8}$$ $$\Rightarrow k^2+k-j^2-j=2m$$ for some $m \in \mathbb{Z}$ but I am not sure this is heading anywhere that I can tell.  Second attempt: Use Euler's Theorem and as $\gcd(a,8)=\gcd(b,8)=1$ and $\phi(8)=4$, $a^4 \equiv b^4 \equiv 1 \mod 8$ so $a^4-b^4\equiv 0 \mod{8}$.  I haven't gotten too much further are there any hints? How can angular velocity be constant even when there is a torque by friction? A cylinder at rest lying on a rough ground is given an impulse which imparts a translational velocity (no angular velocity) to it. The question goes ahead with finding time after which rolling starts etc. etc.  But I have another question: The friction from the ground will decrease the translational velocity but increase the angular velocity (as the torque of friction will be in the direction of rolling). After some time, the translational velocity will become equal to angular velocity and hence pure rolling will start.  After this time work done by friction will be 0 as the point of contact is not moving and hence translational velocity will be constant. Now my doubt is that, when translational velocity is constant, it implies angular velocity will also be constant (as translational velocity is a multiple of angular velocity). But the torque from friction (about the centre of mass) will not be zero which means angular velocity will not be constant. In some book where there was the same problem it was written friction will vanish. How can friction vanish? How can anguluar velocity be constant even when there is a torque by friction? Keyboard shortcut to focus on (idle) terminal I would like to know, if there is possible to use keyboard shortcut to focus on first idle (non working) terminal window in unity (13.10)? Something like Ctr+Alt+T, but before opening the new instance of terminal, searching for any idle instance? Does seam itself affect baking? How to run scripts without typing the full path? What's the difference between "cd ../" vs. "cd /.."? How do I resolve a recurrence relation when the characteristic equation has fewer roots than terms? I know how to solve "simple" recurrence relations. For instance, say you have:  $$c_0 = 20$$ $$c_1 = 30$$ $$c_n = 3 c_{n-1} - 2 c_{n-2}$$  We can write the characteristic equation as:  $$3x^{n-1} - 2x^{n-2} = x^n$$  Solving this with $n=2$, we get $x = 1$ or $x = 2$. This lets us write the relation $c_n = \alpha_1 1^n + \alpha_2 2^n$, and we can solve for $\alpha_1$ and $\alpha_2$ with the initial states $c_0$ and $c_1$.  However, this depends on the fact that $3x^{n-1} - 2x^{n-2} = x^n$ has two roots.  Now, I'm stuck on another problem where the characteristic equation has fewer roots than terms.  Say I have this recurrence relation instead:  $$a_0 = 0$$ $$a_1 = 2$$ $$a_2 = −1$$ $$a_n = 9a_{n-1} - 15a_{n-2} - 25a_{n-3}$$  The characteristic equation would be:  $$9x^{n-1} - 15x^{n-2} - 25x^{n-3} = x^n$$  However, solving with $n=3$, we only get two roots: $x=-1$ or $x=5$. There are not enough roots to write a relation in the form of $a_n = \alpha_1 r_1^n + \alpha_2r_2^n + \alpha_3r_3^n$. How do I proceed? How can I confirm that my I-94 form was correctly processed after leaving the US in 2007? Trying to remember a short story (most likely from the sixties).  It starts with a soldier at the front line fighting an unknown enemy on the other side of the front line.  He then gets withdrawn and you realise that time is passing slower the further he moves from the front. He then spends years in peace away from the front, before being sent back to the front where only a short time (hours or days perhaps) have passed.      I seem to remember their was an inference that they were actually fighting against themselves, with their attacks coming back at themselves, which was perhaps the entire cause of the war, and an interesting critique on war.  I can't remember if this all this was stated explicitly, or just left for the reader to infer. If $f(x)$ is differentiable at x, I need to prove that $\lim_{h\to0}\frac{f(x+h)-f(x-h)}{2h}$ exist and is finite.  so if $f(x)$ is differentiable at a $x$, the difference quotient exist for this point, and also $f(x)$ must be continuous at x as well  so that mean that:  $\lim_{h\to0^+}\frac{f(x+h)-f(x)}{h} =  \lim_{h\to0^-}\frac{f(x+h)-f(x)}{h}$  and that: $\lim_{x\to x_0^+}=\lim_{x\to x_0^-}=f(x_0)$  I know I should probably use arithmetic limit laws to prove this but I can't see how what I figured out could help me. any help with that?  Thanks! Can Git hook scripts be managed along with the repository? We'd like to make a few basic hook scripts that we can all share -- for things like pre-formatting commit messages.  Git has hook scripts for that that are normally stored under &lt;project&gt;/.git/hooks/.  However, those scripts are not propagated when people do a clone and they are not version controlled.    Is there a good way to help everyone get the right hook scripts?  Can I just make those hook scripts point to version controlled scripts in my repo? How is double negation interpreted in English? I've been looking around and I can't seem to find an automatic (i.e. buzz- or Twitter-like) way to follow users inside Stack Exchange. Why haven't the developers added such a feature? It could help beginner users follow other beginners with the same interests. We would be able to learn from each others' questions and pitfalls. Also, it would reduce double posting.