This file contains hidden or 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
# METODOS PARA AJAX | |
def ajax_get_subcategorias(request, id_categoria): | |
try: | |
padre = Categoria.objects.get(id = id_categoria) | |
categorias = padre.getSubcategorias() | |
json = serializers.serialize('json', categorias) | |
return HttpResponse(json, content_type='application/javascript; charset=utf-8') | |
except: | |
return HttpResponseNotFound() | |
<<<<<<< local |
This file contains hidden or 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 __vote(self,user,up_or_down): | |
if self.user is not user: | |
votes = VoteQuestion.objects.filter(question=self,user=user) | |
if len(votes)>0: | |
vote = votes[0] | |
if vote.score is up_or_down: | |
# el mismo voto | |
return -1 | |
else: | |
vote.score += up_or_down |
This file contains hidden or 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
<script type="text/javascript"> | |
$(window).load(function(){ | |
$(".mensaje img").each(function(i,e){ | |
var je = $(e) | |
if(je.width()>"550"){ | |
je.attr("width","550px"); | |
} | |
}); | |
}); | |
</script> |
This file contains hidden or 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
curl -XPUT 'http://127.0.0.1:9200/test_index/?pretty=1' -d ' | |
{ | |
"mappings" : { | |
"user" : { | |
"properties" : { | |
"user_id" : { | |
"type" : "string", | |
"analyzer" : "simple" | |
}, | |
"last_name" : { |
This file contains hidden or 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
SELECT u.id,u.first_name FROM auth_user u | |
JOIN ( | |
SELECT IF(user1 = 1,Null,user1) res1 ,IF(user2 = 1,Null,user2) res2 | |
FROM auth_user u JOIN friendship f | |
ON (u.id = f.user1 OR u.id=f.user2) | |
WHERE | |
u.id = 1 | |
) t ON (u.id=res1 OR u.id=res2) |
This file contains hidden or 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
//http://stackoverflow.com/questions/587404/java-finding-objects-in-collections | |
//http://stackoverflow.com/questions/122105/java-what-is-the-best-way-to-filter-a-collection | |
// Cat class definition | |
// I'm not kidding, nothing else is needed, but this is other topic | |
class Cat(val age: Int) | |
// With type inference and concise functional constructions | |
val a = Array(new Cat(age=1),new Cat(age=2)) | |
// Filtering 1 year old cats |
This file contains hidden or 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
curl \ | |
-F 'access_token=…' \ | |
-F 'batch=[ | |
{"method": "GET", "relative_url": "me"}, | |
{"method": "GET", "relative_url": "me/friends?limit=50"} | |
]'\ | |
https://graph.facebook.com |
This file contains hidden or 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
curl https://graph.facebook.com \ | |
-F 'access_token=...' \ | |
-F 'batch=[ | |
{"method": "GET", | |
"name" : "get-friends", | |
"relative_url": "me/friends", | |
}, | |
{"method": "GET", | |
"relative_url": "likes/?ids={result=get-friends:$.data.*.id}" | |
} |
This file contains hidden or 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 this: | |
content: (post_id,user_name,user_picture)-> | |
li = "<li class='comment-box'><a href='#' class='img tooltip'>" | |
img = "<img src='"+user_picture+"' width='40' height='40'>" | |
tooltip = "<small style='width: 68px; margin-left: -46px; '>"+user_name+"</small></a><section>" | |
form = $("<form></form>") | |
form.attr('action', '/comments/post/') | |
form.attr('method','POST') | |
csrf_value = $("input[name='csrfmiddlewaretoken']").val() | |
form.append($("<input type='hidden' name='csrfmiddlewaretoken' value='"+csrf_value+"'></input>")) |
This file contains hidden or 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 Resource(object): | |
""" | |
Handles the data, request dispatch and responding to requests. | |
Serialization/deserialization is handled "at the edges" (i.e. at the | |
beginning/end of the request/response cycle) so that everything internally | |
is Python data structures. | |
This class tries to be non-model specific, so it can be hooked up to other | |
data sources, such as search results, files, other data, etc. |
OlderNewer