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.http import HttpResponseForbidden | |
from django.contrib.auth.models import AnonymousUser | |
from django.shortcuts import redirect | |
def deny_logged_user(fn): | |
def wrap(request, *args, **kwargs): | |
# if isinstance(request.user, AnonymousUser): | |
if request.user.is_authenticated(): | |
return fn(request, *args, **kwargs) | |
# TODO for logged user |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>jQueryMobile Test</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" /> | |
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script> | |
<script src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script> | |
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> |
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.db import models | |
class ChangedOnlySaveModel(models.Model): | |
def __init__(self, *args, **kwargs): | |
models.Model.__init__(self, *args, **kwargs) | |
self._initial_data = self.__dict__.copy() | |
def save(self, commit=True): | |
if not self.pk: | |
models.Model.save(self, commit) |
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
// | |
// 구글맵v3 상에서 위도/경도 좌표를 지도 상의 픽셀 상대좌표로의 변환은 단순히 | |
// projection 의 fromLatLngToPoint 만을 호출해서는 해결되지 않는다. | |
// 추가적으로 지도 레벨에 대한 처리가 필요하다. | |
// | |
// google-maps-js-api-v3 | |
// (http://www.mail-archive.com/[email protected]/msg08752.html) | |
// 메일링 에서 그 해답을 찾을 수 있었다. | |
// | |
// 구글맵 기본 API에서 지원해주면 좋겠는데. |
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
''' | |
aero님께서 구현하신 구글/네이버/싸이월드/콩나물 좌표변환은 펄/자바스크립트로 되어있습니다. | |
펄/자바스크립트에 익숙지 않은지라, 수식을 파이썬으로 번역해보았습니다. | |
''' | |
from pyproj import Proj | |
from pyproj import transform | |
WGS84 = { 'proj':'latlong', 'datum':'WGS84', 'ellps':'WGS84', } |
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 | |
from django.core.management import setup_environ | |
import settings | |
setup_environ(settings) | |
# blah blah ... |
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
.x-field { | |
&.x-slider-field { | |
min-height: 1.4em; | |
& .x-component-outer { | |
padding: 0.1em; | |
} | |
} | |
} | |
.x-slider { | |
height: 1.1em; |
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 openpyxl import Workbook | |
import random | |
def get_row_data(): | |
for i in xrange(1000): | |
rand_num = random.randint(0, 100) | |
yield (i, (i, rand_num, i + rand_num)) | |
def write_to_csv(filepath): | |
with open(filepath, 'wt') as f: |
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 Post(models.Model): | |
photo = models.ImageField(upload_to='photos/%Y/%m/%d') | |
class PostForm(forms.ModelForm): | |
class Meta: | |
model = Post | |
widgets = { | |
'photo': forms.FileInput(attrs={'multiple':'multiple', 'accept':'image/*'}), | |
} |
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 json | |
from datetime import datetime | |
from django.http import Http404 | |
from django.http import HttpResponse | |
class DateTimeJSONEncoder(json.JSONEncoder): | |
def default(self, obj): | |
if isinstance(obj, datetime): | |
return obj.strftime('%Y-%m-%d %H:%M') # FORMAT |
OlderNewer