RT @newrelic: VIDEO: Make your 2016 'work-life awesome.' Our own @nickfloyd on achieving #worklifebalance http://goo.gl/jQpkYu https://t…
12/30/2015, 10:16:08 AM
Favs: 0
Retweets: 0
link--- layout: tweet ---
RT @newrelic: VIDEO: Make your 2016 'work-life awesome.' Our own @nickfloyd on achieving #worklifebalance http://goo.gl/jQpkYu https://t…
12/30/2015, 10:16:08 AM
Favs: 0
Retweets: 0
link


Advanced Usage¶
This document covers some of Requests more advanced features.
Session Objects¶
The Session object allows you to persist certain parameters across
requests. It also persists cookies across all requests made from the
Session instance, and will use urllib3
’s connection pooling. So if
you’re making several requests to the same host, the underlying TCP
connection will be reused, which can result in a significant performance
increase (see HTTP persistent connection).
A Session object has all the methods of the main Requests API.
Let’s persist some cookies across requests:
s = requests.Session()
s.get('https://httpbin.org/cookies/set/sessioncookie/123456789')
r = s.get('https://httpbin.org/cookies')
print(r.text)
# '{"cookies": {"sessioncookie": "123456789"}}'
Sessions can also be used to provide default data to the request methods. This is done by providing data to the properties on a Session object:
s = requests.Session()
s.auth = ('user', 'pass')
s.headers.update({'x-test': 'true'})
# both 'x-test' and 'x-test2' are sent
s.get('https://httpbin.org/headers', headers={'x-test2': 'true'})
Any dictionaries that you pass to a request method will be merged with the session-level values that are set. The method-level parameters override session parameters.
Note, however, that method-level parameters will not be persisted across requests, even if using a session. This example will only send the cookies with the first request, but not the second:
s = requests.Session()
r = s.get('https://httpbin.org/cookies', cookies={'from-my': 'browser'})
print(r.text)
# '{"cookies": {"from-my": "browser"}}'
r = s.get('https://httpbin.org/cookies')
print(r.text)
# '{"cookies": {}}'
If you want to manually add cookies to your session, use the
Cookie utility functions to manipulate
Session.cookies
.
Sessions can also be used as context managers:
with requests.Session() as s:
s.get('https://httpbin.org/cookies/set/sessioncookie/123456789')
This will make sure the session is closed as soon as the with
block is
exited, even if unhandled exceptions occurred.
Remove a Value From a Dict Parameter
Sometimes you’ll want to omit session-level keys from a dict parameter. To
do this, you simply set that key’s value to None
in the method-level
parameter. It will automatically be omitted.
All values that are contained within a session are directly available to you. See the Session API Docs to learn more.
Request and Response Objects¶
Whenever a call is made to requests.get()
and friends, you are doing two
major things. First, you are constructing a Request
object which will be
sent off to a server to request or query some resource. Second, a Response
object is generated once Requests gets a response back from the server.
The Response
object contains all of the information returned by the server and
also contains the Request
object you created originally. Here is a simple
request to get some very important information from Wikipedia’s servers:
>>> r = requests.get('https://en.wikipedia.org/wiki/Monty_Python')
If we want to access the headers the server sent back to us, we do this:
>>> r.headers
{'content-length': '56170', 'x-content-type-options': 'nosniff', 'x-cache':
'HIT from cp1006.eqiad.wmnet, MISS from cp1010.eqiad.wmnet', 'content-encoding':
'gzip', 'age': '3080', 'content-language': 'en', 'vary': 'Accept-Encoding,Cookie',
'server': 'Apache', 'last-modified': 'Wed, 13 Jun 2012 01:33:50 GMT',
'connection': 'close', 'cache-control': 'private, s-maxage=0, max-age=0,
must-revalidate', 'date': 'Thu, 14 Jun 2012 12:59:39 GMT', 'content-type':
'text/html; charset=UTF-8', 'x-cache-lookup': 'HIT from cp1006.eqiad.wmnet:3128,
MISS from cp1010.eqiad.wmnet:80'}
However, if we want to get the headers we sent the server, we simply access the request, and then the request’s headers:
>>> r.request.headers
{'Accept-Encoding': 'identity, deflate, compress, gzip',
'Accept': '*/*', 'User-Agent': 'python-requests/1.2.0'}
Prepared Requests¶
Whenever you receive a Response
object
from an API call or a Session call, the request
attribute is actually the
PreparedRequest
that was used. In some cases you may wish to do some extra
work to the body or headers (or anything else really) before sending a
request. The simple recipe for this is the following:
from requests import Request, Session
s = Session()
req = Request('POST', url, data=data, headers=headers)
prepped = req.prepare()
# do something with prepped.body
prepped.body = 'No, I want exactly this as the body.'
# do something with prepped.headers
del prepped.headers['Content-Type']
resp = s.send(prepped,
stream=stream,
verify=verify,
proxies=proxies,
cert=cert,
timeout=timeout
)
print(resp.status_code)
Since you are not doing anything special with the Request
object, you
prepare it immediately and modify the PreparedRequest
object. You then
send that with the other parameters you would have sent to requests.*
or
Session.*
.
However, the above code will lose some of the advantages of having a Requests
Session
object. In particular,
Session
-level state such as cookies will
not get applied to your request. To get a
PreparedRequest
with that state
applied, replace the call to Request.prepare()
with a call to
Session.prepare_request()
, like this:
from requests import Request, Session
s = Session()
req = Request('GET', url, data=data, headers=headers)
prepped = s.prepare_request(req)
# do something with prepped.body
prepped.body = 'Seriously, send exactly these bytes.'
# do something with prepped.headers
prepped.headers['Keep-Dead'] = 'parrot'
resp = s.send(prepped,
stream=stream,
verify=verify,
proxies=proxies,
cert=cert,
timeout=timeout
)
print(resp.status_code)
When you are using the prepared request flow, keep in mind that it does not take into account the environment.
This can cause problems if you are using environment variables to change the behaviour of requests.
For example: Self-signed SSL certificates specified in REQUESTS_CA_BUNDLE
will not be taken into account.
As a result an SSL: CERTIFICATE_VERIFY_FAILED
is thrown.
You can get around this behaviour by explicity merging the environment settings into your session:
from requests import Request, Session
s = Session()
req = Request('GET', url)
prepped = s.prepare_request(req)
# Merge environment settings into session
settings = s.merge_environment_settings(prepped.url, {}, None, None, None)
resp = s.send(prepped, **settings)
print(resp.status_code)
SSL Cert Verification¶
Requests verifies SSL certificates for HTTPS requests, just like a web browser. By default, SSL verification is enabled, and Requests will throw a SSLError if it’s unable to verify the certificate:
>>> requests.get('https://requestb.in')
requests.exceptions.SSLError: hostname 'requestb.in' doesn't match either of '*.herokuapp.com', 'herokuapp.com'
I don’t have SSL setup on this domain, so it throws an exception. Excellent. GitHub does though:
>>> requests.get('https://github.com')
<Response [200]>
You can pass verify
the path to a CA_BUNDLE file or directory with certificates of trusted CAs:
>>> requests.get('https://github.com', verify='/path/to/certfile')
or persistent:
s = requests.Session()
s.verify = '/path/to/certfile'
Note
If verify
is set to a path to a directory, the directory must have been processed using
the c_rehash utility supplied with OpenSSL.
This list of trusted CAs can also be specified through the REQUESTS_CA_BUNDLE
environment variable.
Requests can also ignore verifying the SSL certificate if you set verify
to False:
>>> requests.get('https://kennethreitz.org', verify=False)
<Response [200]>
By default, verify
is set to True. Option verify
only applies to host certs.
Client Side Certificates¶
You can also specify a local cert to use as client side certificate, as a single file (containing the private key and the certificate) or as a tuple of both files’ paths:
>>> requests.get('https://kennethreitz.org', cert=('/path/client.cert', '/path/client.key'))
<Response [200]>
or persistent:
s = requests.Session()
s.cert = '/path/client.cert'
If you specify a wrong path or an invalid cert, you’ll get a SSLError:
>>> requests.get('https://kennethreitz.org', cert='/wrong_path/client.pem')
SSLError: [Errno 336265225] _ssl.c:347: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib
Warning
The private key to your local certificate must be unencrypted. Currently, Requests does not support using encrypted keys.
CA Certificates¶
Requests uses certificates from the package certifi. This allows for users to update their trusted certificates without changing the version of Requests.
Before version 2.16, Requests bundled a set of root CAs that it trusted,
sourced from the Mozilla trust store. The certificates were only updated
once for each Requests version. When certifi
was not installed, this led to
extremely out-of-date certificate bundles when using significantly older
versions of Requests.
For the sake of security we recommend upgrading certifi frequently!
Body Content Workflow¶
By default, when you make a request, the body of the response is downloaded
immediately. You can override this behaviour and defer downloading the response
body until you access the Response.content
attribute with the stream
parameter:
tarball_url = 'https://github.com/requests/requests/tarball/master'
r = requests.get(tarball_url, stream=True)
At this point only the response headers have been downloaded and the connection remains open, hence allowing us to make content retrieval conditional:
if int(r.headers['content-length']) < TOO_LONG:
content = r.content
...
You can further control the workflow by use of the Response.iter_content()
and Response.iter_lines()
methods.
Alternatively, you can read the undecoded body from the underlying
urllib3 urllib3.HTTPResponse
at
Response.raw
.
If you set stream
to True
when making a request, Requests cannot
release the connection back to the pool unless you consume all the data or call
Response.close
. This can lead to
inefficiency with connections. If you find yourself partially reading request
bodies (or not reading them at all) while using stream=True
, you should
make the request within a with
statement to ensure it’s always closed:
with requests.get('https://httpbin.org/get', stream=True) as r:
# Do things with the response here.
Keep-Alive¶
Excellent news — thanks to urllib3, keep-alive is 100% automatic within a session! Any requests that you make within a session will automatically reuse the appropriate connection!
Note that connections are only released back to the pool for reuse once all body
data has been read; be sure to either set stream
to False
or read the
content
property of the Response
object.
Streaming Uploads¶
Requests supports streaming uploads, which allow you to send large streams or files without reading them into memory. To stream and upload, simply provide a file-like object for your body:
with open('massive-body', 'rb') as f:
requests.post('http://some.url/streamed', data=f)
Warning
It is strongly recommended that you open files in binary
mode. This is because Requests may attempt to provide
the Content-Length
header for you, and if it does this value
will be set to the number of bytes in the file. Errors may occur
if you open the file in text mode.
Chunk-Encoded Requests¶
Requests also supports Chunked transfer encoding for outgoing and incoming requests. To send a chunk-encoded request, simply provide a generator (or any iterator without a length) for your body:
def gen():
yield 'hi'
yield 'there'
requests.post('http://some.url/chunked', data=gen())
For chunked encoded responses, it’s best to iterate over the data using
Response.iter_content()
. In
an ideal situation you’ll have set stream=True
on the request, in which
case you can iterate chunk-by-chunk by calling iter_content
with a chunk_size
parameter of None
. If you want to set a maximum size of the chunk,
you can set a chunk_size
parameter to any integer.
POST Multiple Multipart-Encoded Files¶
You can send multiple files in one request. For example, suppose you want to upload image files to an HTML form with a multiple file field ‘images’:
<input type="file" name="images" multiple="true" required="true"/>
To do that, just set files to a list of tuples of (form_field_name, file_info)
:
>>> url = 'https://httpbin.org/post'
>>> multiple_files = [
('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),
('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]
>>> r = requests.post(url, files=multiple_files)
>>> r.text
{
...
'files': {'images': 'data:image/png;base64,iVBORw ....'}
'Content-Type': 'multipart/form-data; boundary=3131623adb2043caaeb5538cc7aa0b3a',
...
}
Warning
It is strongly recommended that you open files in binary
mode. This is because Requests may attempt to provide
the Content-Length
header for you, and if it does this value
will be set to the number of bytes in the file. Errors may occur
if you open the file in text mode.
Event Hooks¶
Requests has a hook system that you can use to manipulate portions of the request process, or signal event handling.
Available hooks:
response
:- The response generated from a Request.
You can assign a hook function on a per-request basis by passing a
{hook_name: callback_function}
dictionary to the hooks
request
parameter:
hooks={'response': print_url}
That callback_function
will receive a chunk of data as its first
argument.
def print_url(r, *args, **kwargs):
print(r.url)
If an error occurs while executing your callback, a warning is given.
If the callback function returns a value, it is assumed that it is to replace the data that was passed in. If the function doesn’t return anything, nothing else is affected.
def record_hook(r, *args, **kwargs):
r.hook_called = True
return r
Let’s print some request method arguments at runtime:
>>> requests.get('https://httpbin.org/', hooks={'response': print_url})
https://httpbin.org/
<Response [200]>
You can add multiple hooks to a single request. Let’s call two hooks at once:
>>> r = requests.get('https://httpbin.org/', hooks={'response': [print_url, record_hook]})
>>> r.hook_called
True
You can also add hooks to a Session
instance. Any hooks you add will then
be called on every request made to the session. For example:
>>> s = requests.Session()
>>> s.hooks['response'].append(print_url)
>>> s.get('https://httpbin.org/')
https://httpbin.org/
<Response [200]>
A Session
can have multiple hooks, which will be called in the order
they are added.

Any callable which is passed as the auth
argument to a request method will
have the opportunity to modify the request before it is dispatched.
Authentication implementations are subclasses of AuthBase
,
and are easy to define. Requests provides two common authentication scheme
implementations in requests.auth
: HTTPBasicAuth
and
HTTPDigestAuth
.
Let’s pretend that we have a web service that will only respond if the
X-Pizza
header is set to a password value. Unlikely, but just go with it.
from requests.auth import AuthBase
class PizzaAuth(AuthBase):
"""Attaches HTTP Pizza Authentication to the given Request object."""
def __init__(self, username):
# setup any auth-related data here
self.username = username
def __call__(self, r):
# modify and return the request
r.headers['X-Pizza'] = self.username
return r
Then, we can make a request using our Pizza Auth:
>>> requests.get('http://pizzabin.org/admin', auth=PizzaAuth('kenneth'))
<Response [200]>
Streaming Requests¶
With Response.iter_lines()
you can easily
iterate over streaming APIs such as the Twitter Streaming
API. Simply
set stream
to True
and iterate over the response with
iter_lines()
:
import json
import requests
r = requests.get('https://httpbin.org/stream/20', stream=True)
for line in r.iter_lines():
# filter out keep-alive new lines
if line:
decoded_line = line.decode('utf-8')
print(json.loads(decoded_line))
When using decode_unicode=True with
Response.iter_lines()
or
Response.iter_content()
, you’ll want
to provide a fallback encoding in the event the server doesn’t provide one:
r = requests.get('https://httpbin.org/stream/20', stream=True)
if r.encoding is None:
r.encoding = 'utf-8'
for line in r.iter_lines(decode_unicode=True):
if line:
print(json.loads(line))
Warning
iter_lines()
is not reentrant safe.
Calling this method multiple times causes some of the received data
being lost. In case you need to call it from multiple places, use
the resulting iterator object instead:
lines = r.iter_lines()
# Save the first line for later or just skip it
first_line = next(lines)
for line in lines:
print(line)
Proxies¶
If you need to use a proxy, you can configure individual requests with the
proxies
argument to any request method:
import requests
proxies = {
'http': 'http://<IP_ADDRESS>:3128',
'https': 'http://<IP_ADDRESS>:1080',
}
requests.get('http://example.org', proxies=proxies)
You can also configure proxies by setting the environment variables
HTTP_PROXY
and HTTPS_PROXY
.
$ export HTTP_PROXY="http://<IP_ADDRESS>:3128"
$ export HTTPS_PROXY="http://<IP_ADDRESS>:1080"
$ python
>>> import requests
>>> requests.get('http://example.org')
To use HTTP Basic Auth with your proxy, use the http://user:password@host/ syntax:
proxies = {'http': 'http://user:pass@<IP_ADDRESS>:3128/'}
To give a proxy for a specific scheme and host, use the scheme://hostname form for the key. This will match for any request to the given scheme and exact hostname.
proxies = {'http://<IP_ADDRESS>': 'http://<IP_ADDRESS>:5323'}
Note that proxy URLs must include the scheme.
SOCKS¶
New in version 2.10.0.
In addition to basic HTTP proxies, Requests also supports proxies using the SOCKS protocol. This is an optional feature that requires that additional third-party libraries be installed before use.
You can get the dependencies for this feature from pip
:
$ pip install requests[socks]
Once you’ve installed those dependencies, using a SOCKS proxy is just as easy as using a HTTP one:
proxies = {
'http': 'socks5://user:pass@host:port',
'https': 'socks5://user:pass@host:port'
}
Using the scheme socks5
causes the DNS resolution to happen on the client, rather than on the proxy server. This is in line with curl, which uses the scheme to decide whether to do the DNS resolution on the client or proxy. If you want to resolve the domains on the proxy server, use socks5h
as the scheme.
Compliance¶
Requests is intended to be compliant with all relevant specifications and RFCs where that compliance will not cause difficulties for users. This attention to the specification can lead to some behaviour that may seem unusual to those not familiar with the relevant specification.
Encodings¶
When you receive a response, Requests makes a guess at the encoding to
use for decoding the response when you access the Response.text
attribute. Requests will first check for an
encoding in the HTTP header, and if none is present, will use chardet to attempt to guess the encoding.
The only time Requests will not do this is if no explicit charset
is present in the HTTP headers and the Content-Type
header contains text
. In this situation, RFC 2616 specifies
that the default charset must be ISO-8859-1
. Requests follows the
specification in this case. If you require a different encoding, you can
manually set the Response.encoding
property, or use the raw Response.content
.
HTTP Verbs¶
Requests provides access to almost the full range of HTTP verbs: GET, OPTIONS, HEAD, POST, PUT, PATCH and DELETE. The following provides detailed examples of using these various verbs in Requests, using the GitHub API.
We will begin with the verb most commonly used: GET. HTTP GET is an idempotent
method that returns a resource from a given URL. As a result, it is the verb
you ought to use when attempting to retrieve data from a web location. An
example usage would be attempting to get information about a specific commit
from GitHub. Suppose we wanted commit a050faf
on Requests.  If it has, we want to work out what type of content it is. Do this like so:
>>> if r.status_code == requests.codes.ok:
... print(r.headers['content-type'])
...
application/json; charset=utf-8
So, GitHub returns JSON. That’s great, we can use the r.json
method to parse it into Python objects.
>>> commit_data = r.json()
>>> print(commit_data.keys())
[u'committer', u'author', u'url', u'tree', u'sha', u'parents', u'message']
>>> print(commit_data[u'committer'])
{u'date': u'2012-05-10T11:10:50-07:00', u'email'<EMAIL_ADDRESS>u'name': u'Kenneth Reitz'}
>>> print(commit_data[u'message'])
makin' history
So far, so simple. Well, let’s investigate the GitHub API a little bit. Now, we could look at the documentation, but we might have a little more fun if we use Requests instead. We can take advantage of the Requests OPTIONS verb to see what kinds of HTTP methods are supported on the url we just used.
>>> verbs = requests.options(r.url)
>>> verbs.status_code
500
Uh, what? That’s unhelpful! Turns out GitHub, like many API providers, don’t actually implement the OPTIONS method. This is an annoying oversight, but it’s OK, we can just use the boring documentation. If GitHub had correctly implemented OPTIONS, however, they should return the allowed methods in the headers, e.g.
>>> verbs = requests.options('http://a-good-website.com/api/cats')
>>> print(verbs.headers['allow'])
GET,HEAD,POST,OPTIONS
Turning to the documentation, we see that the only other method allowed for commits is POST, which creates a new commit. As we’re using the Requests repo, we should probably avoid making ham-handed POSTS to it. Instead, let’s play with the Issues feature of GitHub.
This documentation was added in response to Issue #482. Given that this issue already exists, we will use it as an example. Let’s start by getting it.
>>> r = requests.get('https://api.github.com/repos/requests/requests/issues/482')
>>> r.status_code
200
>>> issue = json.loads(r.text)
>>> print(issue[u'title'])
Feature any http verb in docs
>>> print(issue[u'comments'])
3
Cool, we have three comments. Let’s take a look at the last of them.
>>> r = requests.get(r.url + u'/comments')
>>> r.status_code
200
>>> comments = r.json()
>>> print(comments[0].keys())
[u'body', u'url', u'created_at', u'updated_at', u'user', u'id']
>>> print(comments[2][u'body'])
Probably in the "advanced" section
Well, that seems like a silly place. Let’s post a comment telling the poster that he’s silly. Who is the poster, anyway?
>>> print(comments[2][u'user'][u'login'])
kennethreitz
OK, so let’s tell this Kenneth guy that we think this example should go in the quickstart guide instead. According to the GitHub API doc, the way to do this is to POST to the thread. Let’s do it.
>>> body = json.dumps({u"body": u"Sounds great! I'll get right on it!"})
>>> url = u"https://api.github.com/repos/requests/requests/issues/482/comments"
>>> r = requests.post(url=url, data=body)
>>> r.status_code
404
Huh, that’s weird. We probably need to authenticate. That’ll be a pain, right? Wrong. Requests makes it easy to use many forms of authentication, including the very common Basic Auth.
>>> from requests.auth import HTTPBasicAuth
>>> auth =<EMAIL_ADDRESS>'not_a_real_password')
>>> r = requests.post(url=url, data=body, auth=auth)
>>> r.status_code
201
>>> content = r.json()
>>> print(content[u'body'])
Sounds great! I'll get right on it.
Brilliant. Oh, wait, no! I meant to add that it would take me a while, because I had to go feed my cat. If only I could edit this comment! Happily, GitHub allows us to use another HTTP verb, PATCH, to edit this comment. Let’s do that.
>>> print(content[u"id"])
5804413
>>> body = json.dumps({u"body": u"Sounds great! I'll get right on it once I feed my cat."})
>>> url = u"https://api.github.com/repos/requests/requests/issues/comments/5804413"
>>> r = requests.patch(url=url, data=body, auth=auth)
>>> r.status_code
200
Excellent. Now, just to torture this Kenneth guy, I’ve decided to let him sweat and not tell him that I’m working on this. That means I want to delete this comment. GitHub lets us delete comments using the incredibly aptly named DELETE method. Let’s get rid of it.
>>> r = requests.delete(url=url, auth=auth)
>>> r.status_code
204
>>> r.headers['status']
'204 No Content'
Excellent. All gone.  Let’s find out. GitHub sends that information in the headers, so rather than download the whole page I’ll send a HEAD request to get the headers.
>>> r = requests.head(url=url, auth=auth)
>>> print(r.headers)
...
'x-ratelimit-remaining': '4995'
'x-ratelimit-limit': '5000'
...
Excellent. Time to write a Python program that abuses the GitHub API in all kinds of exciting ways, 4995 more times.
Custom Verbs¶
From time to time you may be working with a server that, for whatever reason,
allows use or even requires use of HTTP verbs not covered above. One example of
this would be the MKCOL method some WEBDAV servers use. Do not fret, these can
still be used with Requests. These make use of the built-in .request
method. For example:
>>> r = requests.request('MKCOL', url, data=data)
>>> r.status_code
200 # Assuming your call was correct
Utilising this, you can make use of any method verb that your server allows.
Link Headers¶
Many HTTP APIs feature Link headers. They make APIs more self describing and discoverable.
GitHub uses these for pagination in their API, for example:
>>> url = 'https://api.github.com/users/kennethreitz/repos?page=1&per_page=10'
>>> r = requests.head(url=url)
>>> r.headers['link']
'<https://api.github.com/users/kennethreitz/repos?page=2&per_page=10>; rel="next", <https://api.github.com/users/kennethreitz/repos?page=6&per_page=10>; rel="last"'
Requests will automatically parse these link headers and make them easily consumable:
>>> r.links["next"]
{'url': 'https://api.github.com/users/kennethreitz/repos?page=2&per_page=10', 'rel': 'next'}
>>> r.links["last"]
{'url': 'https://api.github.com/users/kennethreitz/repos?page=7&per_page=10', 'rel': 'last'}
Transport Adapters¶
As of v1.0.0, Requests has moved to a modular internal design. Part of the reason this was done was to implement Transport Adapters, originally described here. Transport Adapters provide a mechanism to define interaction methods for an HTTP service. In particular, they allow you to apply per-service configuration.
Requests ships with a single Transport Adapter, the HTTPAdapter
. This adapter provides the default Requests
interaction with HTTP and HTTPS using the powerful urllib3 library. Whenever
a Requests Session
is initialized, one of these is
attached to the Session
object for HTTP, and one
for HTTPS.
Requests enables users to create and use their own Transport Adapters that provide specific functionality. Once created, a Transport Adapter can be mounted to a Session object, along with an indication of which web services it should apply to.
>>> s = requests.Session()
>>> s.mount('https://github.com/', MyAdapter())
The mount call registers a specific instance of a Transport Adapter to a prefix. Once mounted, any HTTP request made using that session whose URL starts with the given prefix will use the given Transport Adapter.
Many of the details of implementing a Transport Adapter are beyond the scope of
this documentation, but take a look at the next example for a simple SSL use-
case. For more than that, you might look at subclassing the
BaseAdapter
.
Example: Specific SSL Version¶
The Requests team has made a specific choice to use whatever SSL version is default in the underlying library (urllib3). Normally this is fine, but from time to time, you might find yourself needing to connect to a service-endpoint that uses a version that isn’t compatible with the default.
You can use Transport Adapters for this by taking most of the existing implementation of HTTPAdapter, and adding a parameter ssl_version that gets passed-through to urllib3. We’ll make a Transport Adapter that instructs the library to use SSLv3:
import ssl
from urllib3.poolmanager import PoolManager
from requests.adapters import HTTPAdapter
class Ssl3HttpAdapter(HTTPAdapter):
""""Transport adapter" that allows us to use SSLv3."""
def init_poolmanager(self, connections, maxsize, block=False):
self.poolmanager = PoolManager(
num_pools=connections, maxsize=maxsize,
block=block, ssl_version=ssl.PROTOCOL_SSLv3)
Blocking Or Non-Blocking?¶
With the default Transport Adapter in place, Requests does not provide any kind
of non-blocking IO. The Response.content
property will block until the entire response has been downloaded. If
you require more granularity, the streaming features of the library (see
Streaming Requests) allow you to retrieve smaller quantities of the
response at a time. However, these calls will still block.
If you are concerned about the use of blocking IO, there are lots of projects out there that combine Requests with one of Python’s asynchronicity frameworks. Some excellent examples are requests-threads, grequests, requests-futures, and requests-async.
Header Ordering¶
In unusual circumstances you may want to provide headers in an ordered manner. If you pass an OrderedDict
to the headers
keyword argument, that will provide the headers with an ordering. However, the ordering of the default headers used by Requests will be preferred, which means that if you override default headers in the headers
keyword argument, they may appear out of order compared to other headers in that keyword argument.
If this is problematic, users should consider setting the default headers on a Session
object, by setting Session
to a custom OrderedDict
. That ordering will always be preferred.
Timeouts¶
Most requests to external servers should have a timeout attached, in case the server is not responding in a timely manner. By default, requests do not time out unless a timeout value is set explicitly. Without a timeout, your code may hang for minutes or more.
The connect timeout is the number of seconds Requests will wait for your client to establish a connection to a remote machine (corresponding to the connect()) call on the socket. It’s a good practice to set connect timeouts to slightly larger than a multiple of 3, which is the default TCP packet retransmission window.
Once your client has connected to the server and sent the HTTP request, the read timeout is the number of seconds the client will wait for the server to send a response. (Specifically, it’s the number of seconds that the client will wait between bytes sent from the server. In 99.9% of cases, this is the time before the server sends the first byte).
If you specify a single value for the timeout, like this:
r = requests.get('https://github.com', timeout=5)
The timeout value will be applied to both the connect
and the read
timeouts. Specify a tuple if you would like to set the values separately:
r = requests.get('https://github.com', timeout=(3.05, 27))
If the remote server is very slow, you can tell Requests to wait forever for a response, by passing None as a timeout value and then retrieving a cup of coffee.
r = requests.get('https://github.com', timeout=None)


Following the recent YAML parsing vulnerabilities in Rails, I decided to act on an idea I had a few months ago: using route constraints to define strict API contracts in Rails.
Sadly, it does not protect against the YAML parsing problem (and the probable similar vulnerabilities we will see in the following months), because the request is interpreted before going through the route constraints. But it can protect from the mass assignment vulnerability., and probably some SQL injections.
Here is the idea: Rails 3 introduced the route constraints, a way to execute fonctions on the request before it is passed to the controllers. By combining it with the json-schema gem, we can filter the JSON input quite easily.
For the following example data:
[sourcecode language="javascript"]
{"echo" : "blah", "nb" : 1, "data": [1, 2, 3]}
[/sourcecode]
We can define the following schema:
[sourcecode language="javascript"]
{
"type": "object",
"$schema": "http://json-schema.org/draft-03/schema",
"id": "#",
"required": false,
"additionalProperties": false,
"properties": {
"data": {
"type": "array",
"id": "data",
"required": false,
"items": {
"type": "number",
"id": "0",
"required": false
}
},
"echo": {
"type": "string",
"id": "echo",
"required": false
},
"nb": {
"type": "number",
"id": "nb",
"required": false
}
}
}
[/sourcecode]
(Use the JSON schema generator to create your own)
Save this schema to "data.schema" and add "json-schema" to your Gemfile. You will then be able to filter inputs with code like the following "config/routes.rb":
[sourcecode language="ruby"]
require "json-schema"
class LolJSONConstraint
def matches?(request)
if(request.headers["CONTENT_TYPE"] == "application/json")
JSON::Validator.validate("data.schema", request.headers["action_dispatch.request.request_parameters"])
end
end
end
Yamlvuln::Application.routes.draw do
resources :posts, :constraints => LolJSONConstraint.new
end
[/sourcecode]
The constraint will load the schema, and apply it to the incoming data, and return a 404 error if the JSON is invalid. The "additionalProperties" set to false in the schema is required to refuse the properties you didn't define and protect the application from mass assignment.
If I tried, for example, to send the following JSON to the application, there would be an error:
[sourcecode language="javascript"]
{"echo" : "blah", "nb" : "UNION ALL SELECT LOAD_FILE(CHAR(34,47,101,116,99,47,112,97,115,115,119,100,34))", "data": [1, 2, 3]}
[/sourcecode]
As I said before, it is not safe against the YAML parsing vulnerability. Also, I did not really test the performance of this. But it is still a nice and easy solution for API filtering.


Join Game
Create Game
Join Game
Waiting for creater to start game...
Create Game
Game Code:
Start Game


STAGE 3: The bank has asked you to verfy your data. Log in to see if your details are correct. Your user name is Jane and your password is tarzan.
You are victim Jane


The right size brewery for optimum taste
All our beers are carefully hand crafted in small batches. Really small batches.
Not your typical beer producer. We're not a family run business. We're not even a business.
Recipe follower. Beer taster.
Creative Director. Illustrator.


First Gen Pokemon Chart
Image
Name
Type
Evolves Into
Bulbasur
Grass/Poison
Ivysaur
Charmander
Fire
Charmeleon
Charmander
Water
Charmeleon
<


Data Visualization Projects
Playo Data Exploration
4 days ago
Prime Ministers of India
4 years, 5 months ago
Word clouds for my blog
4 years, 5 months ago
Floods in India
4 years, 6 months ago


{% extends "base.html" %} {% block title %}Registration Successful{% endblock %} {% block head %} Registration Completed Successfully {% endblock %} {% block content %}
Thank you for registering.
Your account will be active after the Admin approves it.
You will be redirected to the login page in in 6 seconds
Click here to proceed immediately {% endblock %}


I tried the Pomodoro technique and meditation.
I found the mediatation app helped to calm me before i went to sleep, when my mind would often be thinking about all the things that i needed to do. Also making sure i have down time before bed to swtich off.
The Pomodoro was interesting for me, as i tend to get distracted pretty easily, but once i get stuck into something i dont want to leave. So it was a way of kind of tricking my mind into doing more. Having a shower before bed also a good way to relax.
I will continue to look at multiple ways of managing my time and relaxation methods as this journey continues


| Element |
Contents |
GRIB API keys
|
| 1 |
Number of data values in array PSEC4 to be encoded or
which have been decoded. When the 'A' coding option is used, the count
is the number of image bytes stored four to an integer. When the 'B'
coding option is used, the count is the number of integers used to
return image bytes, stored four to an integer.
When a bitmap is used, this number includes the total
of both missing and present data values.
If this number is negative:
the number of field points is -KSEC4(1),
the entire field is missing,
all values in PSEC4 are 0,
the coded data has all the bits of its scale factor
are set to 1
all the bits of the exponent and mantissa of its
reference value are set to 1 (This is an ECMWF convention).
|
numberOfPoints
numberOfValues
numberOfCodedValues
numberOfMissing
|
| 2 |
Number of bits used for each encoded value. |
decimalPrecision
bitsPerValue
|
| 3 |
Type of data: 0 Grid point data. 128 Spherical harmonic coefficients (Used only if Section 2 is not included when coding data.) |
|
| 4 |
Type of packing: 0 Simple packing. 64 Complex or second-order packing.
|
packingType =
grid_simple | grid_ieee | spectral_complex | spectral_simple |
spectral_ieee | grid_simple_matrix | grid_second_order |
grid_second_order_different_width | grid_complex |
grid_complex_spatial_differencing | grid_jpeg | grid_png |
grid_simple_log_preprocessing
|
| 5 |
Data representation: 0 Floating point data. 32 Integer data.
|
|
| 6 |
Additional flags indicator: 0 No additional flags. 16 Additional flags.
|
|
| 7 |
Reserved. Set to 0. |
|
| 8 |
Number of values indicator: 0 Single datum at each grid point. 64 Matrix of values at each grid point.
|
|
| 9 |
Secondary bitmaps indicator: 0 No secondary bitmaps. 32 Secondary bitmaps present.
|
|
| 10 |
Values width indicator: 0 Second order values have constant width. 16 Second order values have different widths.
|
|
| 11 |
Number of bits for second order values when these have
constant width. |
|
| 12-15 |
Reserved for WMO reserved flag fields. Set to 0. |
|
| 16 |
For complex packing, a pointer to the start of packed
data values (ie the octet number). Otherwise set to 0. |
|
| 17 |
For complex packing, the scaling factor P, stored as
the INTEGER value P*1000 (in the range -10000 to +10000). Otherwise set
to 0. |
|
| 18 |
For complex packing, the pentagonal resolution
parameter J specifying the truncation of the subset of the data
represented as 32-bit floating point numbers (ie not packed). Otherwise
set to 0. |
|
| 19 |
For complex packing, the pentagonal resolution
parameter K specifying the truncation of the subset of the data
represented as 32-bit floating point numbers (ie not packed). Otherwise
set to 0. |
|
| 20 |
For complex packing, the pentagonal resolution
parameter M specifying the truncation of the subset of the data
represented as 32-bit floating point numbers (ie not packed). Otherwise
set to 0. |
|
| 21 |
The number of non-missing values in a field which uses
a bitmap.
When the 'B' coding option is used, this count is the
number of image bytes
(versions of GRIBEX after 13.040).
|
|
| 22-33 |
Reserved. Set to 0. |
|
| 34 |
An offset bit pointer to coded values in the GRIB
record. (This is returned by the 'G', 'I' or 'J' decoding options). |
|


s6-linux-utils
Software
skarnet.org
The s6-uevent-listener program
s6-uevent-listener spawns a long-lived helper program.
It then listens to the netlink interface for uevents (also called
"hotplug" or "udev" events), and passes those events to the
helper program's standard input, using a simple format.
Interface
s6-uevent-listener [ -v verbosity ] [ -b kbufsz ] prog...
- s6-uevent-listener spawns prog... with a pipe writing to
prog' stdin.
- s6-uevent-listener binds to the netlink interface and listens for
hotplug events, as the udev program does.
- It transmits event information to prog via the pipe.
- s6-uevent-listener, like prog, is a long-lived program.
When it receives a SIGTERM, it stops listening; it will
exit as soon as it has flushed its event queue to prog.
Options
- -v verbosity : be more or less verbose.
Default verbosity is 1. 0 will only print fatal error messages, 3 will
print warnings every time the netlink interface sends something
unexpected.
- -b kbufsz : try and reserve a kernel buffer of
kbufsz bytes for the netlink queue.  The default is 65536 (which is on
the large side).
Protocol
Notes
- s6-uevent-listener is a daemon; it should be run under a proper supervision system such
as s6.
- If you are running s6-uevent-listener, prog... should be the
only program handling uevents, which means that
/proc/sys/kernel/hotplug should be empty.
- If you want the serialization benefit of the netlink, but still
want to spawn a program such as busybox's
or toybox's mdev, use
s6-uevent-spawner mdev as
s6-uevent-listener's prog.


DfE enquiries
Central newsdesk 020 7783 8300
General enquiries 0370 000 2288
Press release
Edith Borthwick School rebuilt through the government’s flagship £4.4 billion rebuilding programme.
A special school in Essex given a spacious new building through the government’s flagship rebuilding programme is officially reopening today (2 October 2015).
Edith Borthwick School, an all-age school in Essex, is 1 of 9 schools in the East of England to be rebuilt through the £4.4 billion priority school building programme ( PSBP ), which is transforming some of the most run-down schools in the country.
As a result of £9.1 million worth of construction, the school’s old buildings have been replaced with a new 2-storey facility which includes break-out rooms, spacious hall space and external areas for each of the ground floor classrooms.
Schools Minister Lord Nash said:
Our investment in school buildings across the country is transforming the learning environment for tens of thousands of pupils and their teachers.
The reopening of Edith Borthwick School is a key milestone for the priority school building programme in the East of England.
Ensuring all children have access to the best possible schools and facilities is just one part of our commitment to help all young people reach their potential regardless of their background. These buildings will provide modern, fit-for-purpose schools for pupils for many years to come.
Ian Boatman, Headteacher of Edith Borthwick School, said:
We are delighted to take delivery of our superb new school, built by Wates Construction under the priority school building programme. The building offers us high-quality accommodation, with a wide range of spacious and inspiring learning spaces.
We are now well placed to meet locally-based special educational needs ( SEN ), and have a school fit for the future.
Ian Vickers of Wates Construction said:
Utilising our extensive education expertise, Wates Construction has worked in close partnership with the Education Funding Agency ( EFA ) and the school to gain a deep understanding of the special educational needs of the students, the result of which is an exceptional building that will complement the high-quality one-on-one care that the school provides.
Our completion and handover of the new school marks the conclusion of a very rewarding project and we look forward to seeing Edith Borthwick School continue to provide a platform for educational success for generations to come.
Thanks to the PSBP , school buildings are being rebuilt faster and cheaper than those built under the previous school building initiative - building schools for the future ( BSF ). Under the BSF it took 3 years for construction work to begin. This was slashed to 1 year for the PSBP , with projects costing around a third less.
A total of 537 schools will benefit from construction through the 2 phases of the PSBP .
Central newsdesk 020 7783 8300
General enquiries 0370 000 2288
Published: 2 October 2015


[User Administration]
[List Users]
[Add User]
Id
Username
Last Name
First Name
Account Type
1
johndoe
Doe
John
SITE


FROM CROCOMBE JOHNSON. AUDITING AND ACCOUNTING UNIT. FOREIGN REMITTANCE DEPT. DEXTRA BANK, GRAND CAYMAN, CAYMAN ISLANDS, B.W.I. PLEASE REPLY THIS MAIL TO MY CONFIDENTIAL<EMAIL_ADDRESS>I am CROCOMBE JOHNSON, the Director in charge of auditing and accounting section of DEXTRA BANK, GRAND CAYMAN, CAYMAN ISLANDS. I have decided to contact you on a business transaction that will be very beneficial to both of us at the end of the transaction. During our investigation and auditing in this bank, my department came across a very huge sum of money belonging to a deceased person who died on August 1997 in a plane crash and the fund has been dormant in his account with this bank without any claim of the fund in our custody either from his family or relation before our discovery to this development. Although personally, I kept this information secret within myself and my partner to enable the whole plans and idea be pofitable and successful during the time of execution. The said amount was USD$28m (twenty eight million united states dollars). I am glad to say that with the introduction of internet and,I was opportuned and pleasured to have come across your contact through this satellite media.As it may intrest you to know Meanwhile all the whole arrangement to put claim over this fund as the bonafide next of kin to the deceased, get the required approval and transfer this money to a foriegn account has been put in place and directives and needed information will be relayed to you as soon as you indicate your interest and willingness to assist us and also benefit your self to this great business opportunity. In fact I could have done this deal alone but because of my position in this country as a civil servant, we are not allowed to operate a foriegn account and would eventually raise an eye brow on my side during the time of transfer because, I work in this bank. This is the actual reason why it will require a second party or fellow who will forward claims as the next of kin with affidavit of trust of Oath to this bank and also present a foriegn account where he will need the money to be retransfered into on his request as it may be after due verification and clarification by designation bank account. I will not fail to inform you that this transaction is 100% risk free. On smooth conclusion of this transaction, you will be entitiled to 30% of the total sum as gratification, while 10% will be set aside to take care of expenses that may arise during the time of transfer both local and international like telephone bills,e-mail bills include the documents fees, while 60% will be for me and my partner. Please,you have been adviced to keep top secret as we are still in service and intend to retire from service after we conclude this deal with you. I will be monitoring the whole situation here in this bank until you confirm the money in your account.And ask us to come down to your country for subsequent sharing of the fund according to percentages previously indicated and further investment,either in your country or any country you advice us to invest in. All other necessary information will be sent to you when I hear from you. I suggest you get back to me as soon as possible stating your wish in this deal. Yours faithfully, CROCOMBE JOHNSON. NOTE-MAKE SURE THAT THE REPLY TO THIS PROPOSAL GOES TO MY CONFIDENTIAL E-MAIL ADDRESS(crocombe2000@702mail.co.za)


Reed-Solomon error correction is the error correcting codes that used widely in two-dimensional barcode, including QR code. It allows to correct reading when some of the data is damaged or unreadable.
This is the most essential tool of QRazyBox, since our recovery method is very dependent on Reed-Solomon.
This tool implements all type of correction process (also known as Reed-Solomon decoding).
There are three types of correction that used by Reed-Solomon codes: Error correction, Erasure correction and both of Error and Erasure correction.
Error correction is type of correction where the errors location are unknown, whereas Erasure correction is type of correction where the errors location are known.
Using Error correction, we can correct errors up to half of the number of ECC symbol (Reed-Solomon blocks) and correct errors as many as the number of ECC symbol with Erasure correction. Therefore, Error correction become twice as strong when the error location is known.
Thus, according to that fact, when we know position of the errors, the capability to restore the data of each ECC level can be doubled.
See the following table to see the difference.
| Error Correction Level | % of data that can be restored | |
|---|---|---|
| Without Erasure Correction | With Erasure Correction | |
| Level L | ± 7% | ± 14% |
| Level M | ± 15% | ± 30% |
| Level Q | ± 25% | ± 50% |
| Level H | ± 30% | ± 60% |
However, normal QR code scanner doesn't have erasure correction feature, since it difficult to recognize the error locations of QR code automatically and may resulting in slower scan.
Before using this tool, it is better to know how Reed-Solomon works generally. Take a look at the following simple example.
Suppose we will encode text "HELLO WORLD" to Reed-Solomon block.
Convert the text to decimal value :
72,69,76,76,79,32,87,79,82,76,68
Encode with Reed-Solomon using 11 ECC symbol :
72,69,76,76,79,32,87,79,82,76,68,123,80,185,183,114,194,10,36,93,160,102
Now, that we have the encoded Reed-Solomon block, we will try to calculate the correction possiblity in various damaged states.
According to the ECC symbol that being used to encode (in this case the number of ECC symbol is 11), we can correct up to 2*e+n <= 11, where e is number of error and n is number of erasure.
Suppose x as error and ? as erasure
72,69,x,x,x,x,87,79,82,76,68,123,80,185,183,114,194,10,36,93,160,102 (4 errors) = 8 <= 11CORRECTABLE
72,69,x,x,x,x,87,79,82,76,68,123,80,185,183,114,x,x,x,93,160,102 (7 errors) = 14 <= 11UNCORRECTABLE
72,69,?,?,?,?,87,79,82,76,68,123,80,185,183,114,194,10,36,93,160,102 (4 erasures) = 4 <= 11CORRECTABLE
72,69,?,?,?,?,87,79,82,76,68,123,80,185,183,114,?,?,?,93,160,102 (7 erasures) = 7 <= 11CORRECTABLE
?,?,?,?,?,?,87,?,?,76,68,123,80,185,183,114,?,?,?,?,160,102 (12 erasures) = 12 <= 11UNCORRECTABLE
72,69,x,x,x,x,87,79,82,76,68,123,80,185,183,114,?,?,?,93,160,102 (4 errors & 3 erasures) = 11 <= 11CORRECTABLE
When you use Reed-Solomon Decoder, you will be prompted by dialog. There will be total 2 page of dialog, for input and output. Although, this tool will input the Reed-Solomon blocks automatically, but you can edit and enter manually if you want to.
You also don't have to input number of ECC symbol and even the error position/location, since this tool will automatically detect from the QR code that you already drawn before (zero values of Reed-Solomon blocks will be treated as error position).
Keep in mind, that Reed-Solomon block can also consist more than one on a larger QR code.
The second page of the dialog will display output such as decoded Reed-Solomon blocks and the final message from QR code.
Jump to examples section to see the further details about using Reed-Solomon Decoder.


Teenagers arrested on suspicion of carrying BB gun in the street
Officers have recovered a BB gun
by Matt JarramTwo teenagers have been arrested on suspicion of brandishing a BB gun in public.
Police were called to a report of people 'acting suspiciously' in High Pavement in Sutton-in-Ashfield.
It happened just after 12.05pm on Friday, November 15.
Two boys, aged 14 and 16, were arrested on suspicion of possession of an imitation firearm with intent to cause fear of violence.
Officers also recovered a BB gun.
The two boys remain in police custody.
Detective Inspector Steve Wragg, from Nottinghamshire Police, said: "We are not looking for anyone else in connection with this isolated incident.
"We treat any reports involving firearms extremely seriously. Even imitation firearms have the potential to cause fear and distress and we will not tolerate people carrying weapons of any kind on our streets."
The teenagers have now been released on conditional bail


Creepy Chinese facial recognition system puts your name and photo on a billboard if you jaywalk
Writer Matthew Brennan tweeted a shocking video of the strange system, although it remains unclear where it was filmed
by Shivali Best, https://www.facebook.com/shivalibestjournalist/It’s something that many people do without giving it a second thought, but if you jaywalk in China , you could be publicly shamed.
Facial recognition technology is being used in several Chinese cities, including Shanghai and Shenzhen, which can spot people jaywalking, and post their photo and ID to a huge billboard.
Writer Matthew Brennan tweeted a shocking video of the strange system, although it remains unclear where it was filmed.
He wrote: “Chinese facial recognition system to discourage minor traffic violations. Cross the road when you shouldn't and a picture of you with your name, ID card number pop up on the big screen for everyone to see.”
His tweeted has garnered over 3,000 retweets and almost 5,000 likes (at time of writing), with many people replying to express their shock at the system.
However, while it may be shocking to us, it’s pretty common place for locals, who have had to endure the system since 2018.
Speaking to Channel News Asia , Janine Wong, a news researcher in Shanghai explained: “It doesn’t matter if you’re walking or riding a bicycle.
“(Your picture) will be captured, and your face will show up on a screen nearby so everyone can see your face.
“Once they identify your face, all your information (like mobile phone number) is linked.”
Facial recognition is widely used across China, including in several airports.
Earlier this year, Mr Brennan discovered a kiosk at the Chengdu Shuangliu International Airport, which scanned his face to display his flight detials.
He tweeted a video of the kiosk in action, and explained how it worked.
He wrote: “Wow! China Airport face recognition systems to help you check your flight status and find the way to your gate.
“Note I did not input anything, it accurately identified my full flight information from my face!”


Spotting your parking spot!
We have created a way to make the parking process easier. Park4You is a platform to connect people with unused parking spots to pepole who need those spots. If you search for parking you can use Park4You in order to locate a nearby spot and rent it. If you have an extra parking spot you can publish it on Park4You and make the extra parking to an extra money!


hubot-gitter2
Improved Hubot adapter for Gitter
There was already one adapter hubot-gitter but after trying to fix many missing things from it, I decided to write one from scratch.
At the time this is written, here is the advantages of this one:
- namespaced environment variables for the configuration
- handling
robot.send room: 'room id or uri', 'my message'
- gathering information from users in all rooms correctly
- not handling messages that the bot itself is sending
Installation
- install Hubot and CoffeeScript:
npm install -g hubot coffeescript
- create your bot and install its dependencies:
hubot --create my-bot; cd my-bot; npm install
- save hubot-gitter2 as dependency:
npm install --save hubot-gitter2
- start the bot using the right adapter:
HUBOT_GITTER2_TOKEN=<your token> ./bin/hubot -a gitter2
HUBOT_GITTER2_TOKEN
: get your personal token there after sign-in- the bot will automatically listen on the rooms it has joined.
Changelog
0.1.3 -
2014-08-20
- Added the ability to ignore all rooms except given one(s) for testing with
HUBOT_GITTER2_TESTING_ROOMS
- Implemented a room ignore-list to not handle messages from some rooms with
HUBOT_GITTER2_IGNORE_ROOMS
- Added the ability to ignore all rooms except given one(s) for testing with
0.1.2 -
2014-08-16
- Re-wrote everything in a cleaner, object oriented way
- Better handling of users
- Auto-listening on the rooms the bot's user has already joined
- Do not overwrite brain user names, only update if not set
0.0.3 -
2014-08-11
- First functional pre-version


Module sdl2::surface::ll[src]
Structs
| SDL_BlitMap | |
| SDL_Surface |
Statics
pub static SDL_DONTFREE: SDL_SurfaceFlag = 0x00000004 |
|
pub static SDL_PREALLOC: SDL_SurfaceFlag = 0x00000001 |
|
pub static SDL_RLEACCEL: SDL_SurfaceFlag = 0x00000002 |
|
pub static SDL_SWSURFACE: SDL_SurfaceFlag = 0 |
Foreign Functions
Type Definitions
| SDL_Rect | |
| SDL_SurfaceFlag | |
| SDL_bool |


Base class for all DatabasePlatforms. The DatabasePlatforms are the central point of abstraction of platform-specific behaviors, features and SQL dialects.
They are a passive source of information.
Base class for all DatabasePlatforms. The DatabasePlatforms are the central point of abstraction of platform-specific behaviors, features and SQL dialects.
They are a passive source of information.
Provides the behavior, features and SQL dialect of the MySQL 5.7 database platform.
They are a passive source of information.
The MySqlPlatform provides the behavior, features and SQL dialect of the MySQL database platform. This platform represents a MySQL 5.0 or greater platform that uses the InnoDB storage engine.
They are a passive source of information.
Provides the behavior, features and SQL dialect of the PostgreSQL 9.1 database platform.
They are a passive source of information.
Provides the behavior, features and SQL dialect of the PostgreSQL 9.2 database platform.
They are a passive source of information.
The SQLAnywhere11Platform provides the behavior, features and SQL dialect of the SAP Sybase SQL Anywhere 11 database platform.
They are a passive source of information.
The SQLAnywhere12Platform provides the behavior, features and SQL dialect of the SAP Sybase SQL Anywhere 12 database platform.
They are a passive source of information.
The SQLAnywhere16Platform provides the behavior, features and SQL dialect of the SAP Sybase SQL Anywhere 16 database platform.
They are a passive source of information.
The SQLAnywherePlatform provides the behavior, features and SQL dialect of the SAP Sybase SQL Anywhere 10 database platform.
They are a passive source of information.
Platform to ensure compatibility of Doctrine with SQL Azure
On top of SQL Server 2008 the following functionality is added:
The SqlitePlatform class describes the specifics and dialects of the SQLite database platform.
They are a passive source of information.
Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2005 version and higher.
Differences to SQL Server 2008 are:
Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2008 version.
Differences to SQL Server 2005 and before are that a new DATETIME2 type was introduced that has a higher precision.


Analyze the text This tool helps you decrypt a message which was
encrypted by means of a substitution cypher.
The technique for breaking the cypher is the
frequency analysis attack
which you will be performing here.
The first step is typing the cypher-text in the box above.
Then you must select which language you think the original text was written into.
Analyze the histograms and confront the peaks in order to find the original letter association.
Encript or decrypt In order to encrypt or decrypt the message you need to use a key.
If you decrypt, you must calculate the key as a result of the analysis performed by using the histograms,
once you find the letter associations, use them to build the key.


Input date is a set of bootstrap components (mainly input-group and modal) to build a control that allows users to navigate in the calendar and select a date. See the example below:
@@include('includes/code-examples/input-controls/input-date/input-date.html')
@@include('includes/code-examples/input-controls/input-date/input-date.js')
It is possible have only one calendar for the entire application if you want to.
The calendar is displayed in a bootstrap modal
and defined by the class .modal-calendar
.
The navigation of the calendar is placed in the modal header. The modal body contains the current page (.table-calendar
)
and the calendar links (today and selected date). The buttons for confirm and cancel are placed in the modal footer.
See the basic structure below:
@@include('includes/code-examples/input-controls/input-date/calendar-modal-empty.html')
The calendar header contains the navigation that allows the user to go to the next pages or to the previous pages of the calendar. Also, the user can select a month in the dropdown or type the desired year. See the example below:
@@include('includes/code-examples/input-controls/input-date/calendar-modal-header.html')
The calendar body contains the current page and allows the user to select the desired date. In addition, the body contains the links to today's date and to the selected date.
@@include('includes/code-examples/input-controls/input-date/calendar-modal-body.html')
The calendar footer contains the buttons to confirm or cancel the selected date. See the example below:
Options can be passed via data attributes:
| Option | Type | Description |
|---|---|---|
data-calendar-link |
string | Navigates directly to the calendar page: today or selected (selected date). |
data-calendar-month |
string|number | The month for which it will be navigated: 0..11 (January to December), previous or next . |
By design these attribute options only work for children of a .modal-calendar
.
A few methods are available to control the calendar:
| Method | Description |
|---|---|
calendar('date') |
Gets the selected date. |
calendar('date', myDate) |
Sets the selected date (automatically queries the selected date).
Triggers the events calendar:change and calendar:query .
|
calendar('query:date') |
Gets the queried date (does not reflect the selected date). |
calendar('query:date', myDate) |
Sets the queried date (recalculates the calendar page).
Triggers the event calendar:query .
|
calendar('query:nextMonth') |
Go to next month. Triggers the event calendar:query . |
calendar('query:nextYear') |
Go to next year. Triggers the event calendar:query . |
calendar('query:previousMonth') |
Go to previous month. Triggers the event calendar:query . |
calendar('query:previousYear') |
Go to previous year. Triggers the event calendar:query . |
Events triggered from the calendar can be listened to write custom logic:
| Event | Description |
|---|---|
calendar:change |
Triggered after select a date. |
calendar:each |
Triggered for each date while loading the calendar page. |
calendar:query |
Triggered after querying the date. |
@@include('includes/code-examples/input-controls/input-date/calendar-events.js')