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 add_url(self, endpoint): | |
"""Adds additional urls to the resource | |
:endpoint: the end point API to be added | |
:returns: the url created ( for tastypie ) | |
""" | |
api = r'(?P<resource_name>%s)/(?P<endpoint>%s)%s$' % ( | |
self._meta.resource_name, endpoint, trailing_slash()) | |
endpoint = endpoint.replace('/', '_') |
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 tweepy | |
import argparse | |
def main(handle): | |
try: | |
CONSUMER_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxx' | |
CONSUMER_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
ACCESS_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
ACCESS_TOKEN_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxx' |
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 PIL import Image | |
if self.thumbnail: | |
try: | |
image = Image.open(self.thumbnail.path) | |
(width, height) = image.size | |
"Max width and height 800" | |
if (700 / width < 471 / height): | |
factor = 471 / height | |
else: |
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 tweepy | |
import random | |
CONSUMER_KEY = '' | |
CONSUMER_SECRET = '' | |
ACCESS_TOKEN = '' | |
ACCESS_TOKEN_SECRET = '' | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET) |
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
var quer = {}; | |
var pagination = {}; | |
Restangular.addFullRequestInterceptor(function(element, operation, what, url, headers, params) { | |
var query = params; | |
if (operation === 'getList') { | |
if (Common.query) { | |
query = _.cloneDeep(Common.query); | |
angular.extend(query, params); | |
if (query.limit === 0) { | |
delete query.page; |
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
# base tastypie class | |
class BaseResource(ModelResource): | |
# Endpoint refers to function in the Resource eg. function_data_whatever | |
# IMPORTANT: URL will be replaced to function/data/whatever | |
def alter_list_data_to_serialize(self, request, data): | |
""" Used to return only meta data, if we have meta_only = true """ | |
if request.GET.get('meta_only'): |
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
# Git branch in prompt. | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
GRAY="\[\033[1;30m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" |
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
# Base Resource | |
class MultipartResource(object): | |
def deserialize(self, request, data, format=None): | |
if format == 'application/x-www-form-urlencoded': | |
return request.POST | |
if format.startswith('multipart'): | |
data = request.POST.copy() | |
data.update(request.FILES) |
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
var express = require("express"); | |
var app = express(); | |
app.use(require('prerender-node').set('prerenderServiceUrl', 'http://localhost:1337/').set('prerenderToken', 'TOKEN')); | |
app.use(express.static(__dirname + "/app")); | |
app.use("/app/bower_components", express.static(__dirname + "/app/bower_components")); | |
app.use("/app/dist/min/css/fonts/", express.static(__dirname + "/app/dist/min/css/fonts/")); | |
app.all('/*', function(req, res, next) { | |
res.sendFile("/app/index.html", { root: __dirname }); | |
}); |
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
var express = require("express"); | |
var app = express(); | |
app.use(express.static(__dirname + "/app")); | |
app.use("/app/bower_components", express.static(__dirname + "/app/bower_components")); | |
app.use("/app/dist/min/css/fonts/", express.static(__dirname + "/app/dist/min/css/fonts/")); | |
app.all('/*', function(req, res, next) { | |
res.sendFile("/app/index.html", { root: __dirname }); | |
}); | |
app.listen(process.env.PORT || 3000); |
OlderNewer