This guide assumes a fresh install of Mac OSX 10.7 Lion.
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 urllib | |
print 'javascript:' + urllib.quote(""" | |
(function(){ | |
var e = document.createElement('script'); | |
e.src='/boot.js'; | |
e.type='text/javascript'; | |
document.getElementsByTagName('body')[0].appendChild(e);})() | |
""".strip().replace('\n', ' ')) |
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 subprocess | |
echo = subprocess.Popen(['echo','123'], | |
stdout=subprocess.PIPE, | |
) | |
sudo = subprocess.Popen(['sudo','-S','iptables','-L'], | |
stdin=echo.stdout, | |
stdout=subprocess.PIPE, | |
) |
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 django import http | |
try: | |
from django.conf import settings | |
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS | |
XS_SHARING_ALLOWED_METHODS = settings.XS_SHARING_ALLOWED_METHODS | |
XS_SHARING_ALLOWED_HEADERS = settings.XS_SHARING_ALLOWED_HEADERS | |
XS_SHARING_ALLOWED_CREDENTIALS = settings.XS_SHARING_ALLOWED_CREDENTIALS | |
except AttributeError: | |
XS_SHARING_ALLOWED_ORIGINS = '*' |
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
$(function() { | |
$("#meu-form").submit(function(e) { | |
e.preventDefault(); | |
var data = $(this).serialize(); | |
$.ajax( { | |
url: "minha-url", | |
type: "post", | |
data: data, | |
dataType: "json", | |
success: function(json) { |
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
# -*- coding: utf-8 -*- | |
import mechanize | |
br = mechanize.Browser() | |
br.open("http://www.bmfbovespa.com.br/opcoes/opcoes.aspx?Idioma=pt-br") | |
br.select_form(nr=0) | |
# data/hora yyyy-mm-dd-hh-mm-ss | |
br["ctl00$contentPlaceHolderConteudo$posicoesAbertoEmp$txtConsultaDataDownload$txtConsultaDataDownload$dateInput"] = "2012-02-22-00-00-00" |
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
.fc { | |
direction: ltr; | |
text-align: left; } | |
.fc table { | |
border-collapse: collapse; | |
border-spacing: 0; } | |
.fc .btn { | |
line-height: 1.2em; } | |
html .fc { |
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
alternatives = Alternative.objects.filter(exercise=exercise) | |
select_sql = u'''select courses_solveexercise.response | |
from courses_solveexercise where | |
courses_solveexercise.user_id=%s and | |
courses_solveexercise.alternative_id=courses_alternative.id''' | |
alternatives = alternatives.extra(select=SortedDict([('user_response', select_sql)]), | |
select_params=[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
import urlparse | |
import re | |
from django.db import models | |
from django import forms | |
def validate_youtube_url(value): | |
'''El patron lo saque de http://stackoverflow.com/questions/2964678/jquery-youtube-url-validation-with-regex''' | |
pattern = r'^http:\/\/(?:www\.)?youtube.com\/watch\?(?=.*v=\w+)(?:\S+)?$' |
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
<div class="yourFancyBoxClass"> | |
{% if success %} | |
<h2>It Worked!</h2> | |
{% else %} | |
<form action="{% url ajax_form %}"> | |
{% form %} | |
</form> | |
{% endif %} | |
</div> |
OlderNewer