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
import requests | |
s = requests.Session() | |
pool_32_adapter = requests.adapters.HTTPAdapter(pool_connections=1, pool_maxsize=32) | |
s.mount('http://', pool_32_adapter) | |
s.mount('https://', pool_32_adapter) |
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
#include <stdio.h> // printf, fflush, stdout | |
#include <fcntl.h> // open, O_RDWR | |
#include <stdlib.h> // exit | |
#include <signal.h> // signal, SIGINT | |
#include <sys/stat.h> // mkfifo | |
#include <unistd.h> // read | |
#define QUEUE "request_queue" | |
#define BUFLEN 20 |
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
""" | |
Dump item and set data from memonic into .json files. | |
Please issue ``mkdir -p data/{sets,items}`` before running the script. | |
""" | |
from __future__ import print_function, division, absolute_import, unicode_literals | |
import json | |
import requests | |
API_KEY = '<api-key>' | |
API_URL = 'https://api.memonic.com/v2/' |
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 is_owner_or_readonly(fieldname='owner'): | |
"""Function to generate a permission class that checks whether the current | |
user is the owner according to the specified field name.""" | |
class IsOwnerOrReadOnly(permissions.BasePermission): | |
"""Only allow owners of an object to edit it.""" | |
def has_object_permission(self, request, view, obj): | |
# Read permissions are allowed to any request, | |
# so we'll always allow GET, HEAD or OPTIONS requests. |
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
[2013-05-24 21:42:28,507: ERROR/MainProcess] Task celery.chord[fcff074e-692c-4c9b-8014-98a8a5bf4988] raised exception: AttributeError("'dict' object has no attribute 'type'",) | |
Traceback (most recent call last): | |
File "/home/danilo/.virtualenvs/radar/lib/python2.7/site-packages/celery/task/trace.py", line 228, in trace_task | |
R = retval = fun(*args, **kwargs) | |
File "/home/danilo/.virtualenvs/radar/lib/python2.7/site-packages/celery/task/trace.py", line 415, in __protected_call__ | |
return self.run(*args, **kwargs) | |
File "/home/danilo/.virtualenvs/radar/lib/python2.7/site-packages/celery/app/builtins.py", line 336, in run | |
return header(*partial_args, **{'task_id': group_id}) | |
File "/home/danilo/.virtualenvs/radar/lib/python2.7/site-packages/celery/canvas.py", line 406, in __call__ | |
type = tasks[0].type.app.tasks[self['task']] |
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 functools import partial | |
hexint = partial(int, base=16) | |
code = '53 65 61 72 63 68 20 59 6f 75 54 75 62 65 20 66 6f 72 20 2f 20 67 65 65 6b 77 65 65 6b' | |
numbers = map(hexint, code.split()) | |
print ''.join(map(chr, numbers)) |
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
code = '53 65 61 72 63 68 20 59 6f 75 54 75 62 65 20 66 6f 72 20 2f 20 67 65 65 6b 77 65 65 6b' | |
print ''.join(map(chr, [int(val, base=16) for val in code.split()])) |
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
# Social auth | |
AUTHENTICATION_BACKENDS = ('social_auth.backends.google.GoogleOAuth2Backend',) | |
LOGIN_URL = '/auth/login/' | |
LOGIN_REDIRECT_URL = '/' | |
LOGIN_ERROR_URL = '/auth/login-error/' | |
GOOGLE_OAUTH2_CLIENT_ID = require_env('GOOGLE_OAUTH2_CLIENT_ID') | |
GOOGLE_OAUTH2_CLIENT_SECRET = require_env('GOOGLE_OAUTH2_CLIENT_SECRET') | |
GOOGLE_OAUTH2_AUTH_EXTRA_ARGUMENTS = {'access_type': 'offline'} | |
GOOGLE_OAUTH_EXTRA_SCOPE = [ | |
'https://adwords.google.com/api/adwords', |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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" | |
"net/http" | |
"io/ioutil" | |
"encoding/json" | |
) | |
const baseUrl = "http://data.mtgox.com/api/2/%s/money/ticker" |