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
class Pagination(object): | |
"""A Pagination object to be used for querying and displaying pagination links on frontend | |
Example usage: | |
>>> p = Pagination(total=15, per_page=5, current_page=1) | |
>>> p.start | |
0 | |
>>> p.pages | |
[1, 2, 3] |
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
redis 127.0.0.1:6379> zrevrange items:sorted-timestamp:ALL:jmoz 0 9 WITHSCORES | |
1) "Twitter-274182202210799616" | |
2) "1354205105" | |
3) "Foursquare-50b768b1e4b0c0274666efa6" | |
4) "1354197169" | |
5) "Foursquare-50b68d55e4b060c79257ccaf" | |
6) "1354141013" | |
7) "Instagram-334846753149593155_1412856" | |
8) "1354136865" | |
9) "Foursquare-50b67b51e4b037d8ee3feff8" |
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 foursquare | |
f = foursquare.Foursquare(access_token=OAUTH_TOKEN) | |
print f.users.checkins(USER_ID=USER_ID) |
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
@app.route('/oauth_authorized') | |
@twitter.authorized_handler | |
def oauth_authorized(resp): | |
next_url = request.args.get('next') or url_for('index') | |
if resp is None: | |
flash('Authorization denied. Thanks for nothing.', 'error') | |
return redirect(next_url) | |
if RedisUser.find(resp['user_id']) is None: | |
flash('Authorized but unknown user.', '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
@app.route('/') | |
def index(): | |
items = client.get_items(config.App.USER_ID, config.App.LIMIT_FRONTPAGE) | |
return render_template('index.html', items=items) |
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
<?php | |
$r = new HttpRequest('http://pinterestapi.co.uk/jwmoz/pins', HttpRequest::METH_GET); | |
$r->send(); | |
echo $r->getResponseBody(); |
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
#!/bin/bash | |
. /home/web/.pythonbrew/etc/bashrc | |
cd `dirname $0` | |
echo "* Pythonbrew use venv jmoz" | |
pythonbrew venv use jmoz | |
echo "* Pip install requirements" | |
pip install -r reqs | |
echo "* Supervisor restart gunicorn-jmoz" | |
supervisorctl restart gunicorn-jmoz |
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
while read oldrev newrev refname | |
do | |
branch=$(git rev-parse --symbolic --abbrev-ref $refname) | |
echo Update to branch $branch | |
if [ "master" == "$branch" ]; then | |
echo "git checkout -f master branch!!!" | |
unset GIT_DIR | |
GIT_WORK_TREE=/home/web/sites/jmoz.co.uk git checkout -f | |
bash /home/web/sites/jmoz.co.uk/install.sh | |
fi |
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
[program:gunicorn-jmoz] | |
command=/home/web/.pythonbrew/venvs/Python-2.7.3/jmoz/bin/gunicorn index:app | |
directory=/home/web/sites/jmoz.co.uk | |
user=nobody | |
autostart=true | |
autorestart=true | |
redirect_stderr=True |
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
# redirect www to non-www | |
server { | |
listen 80; | |
server_name www.jmoz.co.uk; | |
rewrite ^ http://jmoz.co.uk$request_uri?; | |
} | |
server { | |
listen 80; | |
server_name jmoz.co.uk; |