This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"math" | |
"math/big" | |
) | |
// readInt reads an integer from standard input. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"math/big" | |
) | |
// readInt reads an integer from standard input. | |
func readInt() (int, error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tipfy import RequestHandler | |
from tipfyext.jinja2 import Jinja2Mixin | |
from tipfy.sessions import SessionMiddleware | |
class ChromeFrameMiddleware(object): | |
""" | |
Middleware that enables the Google Chrome frame plugin or IE edge | |
rendering engine. | |
""" | |
def after_dispatch(self, handler, response): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import division | |
def term(i): | |
# n = 4.0/(2*i + 1) | |
# return -n if i & 1 else n | |
return (-1)**i * 4.0/(2*i + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Copyright (C) 2009 Facebook | |
# Copyright (C) 2010, 2011 Tipfy.org | |
# Copyright (C) 2011 Yesudeep Mangalapilly <yesudeep@gmail.com> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
# Python 3. | |
from urllib.parse import urlparse, urlunparse, parse_qs, quote, unquote_plus | |
except ImportError: | |
# Python 2.5+ | |
from urlparse import urlparse, urlunparse | |
from urllib import quote, unquote_plus | |
try: | |
# Python 2.6+ | |
from urlparse import parse_qs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Authorization in simple words: | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
1. Construct a client with its client credentials. | |
2. Send an HTTP request for temporary credentials with a callback URL | |
which the server will call with an OAuth verification code. | |
3. Parse out temporary credentials from a successful server response. | |
4. Using the temporary credentials build an authorization URL and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Copyright (C) 2009 Facebook | |
# Copyright (C) 2010, 2011 Tipfy.org | |
# Copyright (C) 2011 Yesudeep Mangalapilly <yesudeep@gmail.com> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_random_string(bit_strength=64, decimal=False): | |
""" | |
Generates a random ASCII-encoded unsigned integral random number in decimal | |
or hexadecimal representation. | |
:param bit_strength: | |
Bit strength. | |
:returns: | |
A string representation of a randomly-generated ASCII-encoded | |
hexadecimal/decimal-representation unsigned integral number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Copyright (C) 2009 Facebook | |
# Copyright (C) 2010, 2011 Tipfy.org | |
# Copyright (C) 2011 Yesudeep Mangalapilly <yesudeep@gmail.com> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at |