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
# refered from http://www.micahcarrick.com/django-email-authentication.html | |
# need to settings.py like this, | |
# AUTHENTICATION_BACKENDS = ('backends.EmailAuthBackend',) | |
from django.contrib.auth.models import User, check_password | |
class EmailAuthBackend(object): | |
""" | |
Email Authentication Backend | |
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
""" | |
Purpose for exact match, but this's Partial matches | |
""" | |
pks = [ "1", "2", "3", "4" ] | |
query = reduce(operator.and_, [ Q(comments__pk=x) for x in pks ] ) | |
bundle.data['answer'] = Posts.objects.filter(query).distinct() |
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 This_is_Gist | |
print "not 광주 과학 기술원" |
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
/** | |
* 자주거는(전화 횟수 기준) 4명을 기본으로 가져옴 | |
* 연락한 횟수 내림차순으로 상위 4개에 대해 View를 만듬 | |
**/ | |
private ArrayList<Contact> getFrequntlyContacts() { | |
String selection = Contacts.HAS_PHONE_NUMBER + " == ?"; | |
String[] selectionArgs = new String[]{"1"}; | |
ContentResolver cr = context.getContentResolver(); | |
Cursor cur = cr.query(Contacts.CONTENT_URI, new String[]{Contacts._ID, Contacts.DISPLAY_NAME, Contacts.PHOTO_ID, Contacts.TIMES_CONTACTED, Contacts.HAS_PHONE_NUMBER}, selection, selectionArgs, Contacts.TIMES_CONTACTED + " DESC"); |
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
TableRow last_row = (TableRow) contact_table.getChildAt(contact_table.getChildCount() - 1); | |
TableRow row; | |
if (last_row == null || last_row.getChildCount() == 2) { | |
row = new TableRow(context); | |
if (last_row != null) { | |
int color = ((ColorDrawable) last_row.getChildAt(1).getBackground()).getColor(); | |
view.setBackgroundColor(color); | |
} | |
} else { | |
row = last_row; |
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 android.content.Context; | |
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.graphics.PorterDuff; | |
import android.graphics.PorterDuffXfermode; | |
import android.graphics.Rect; | |
import android.graphics.drawable.BitmapDrawable; | |
import android.graphics.drawable.Drawable; |
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
public class MLRoundedImageView extends ImageView { | |
public MLRoundedImageView(Context context) { | |
super(context); | |
} | |
public MLRoundedImageView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} |
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
device : Nexus 5 4.4.3 | |
I want events in one day. So I use CalendarContract Instance query with start to end time in today. Problem is yesterday all day event in result. | |
Uri.Builder builder = CalendarContract.Instances.CONTENT_URI.buildUpon(); | |
ContentUris.appendId(builder, Today start time) | |
ContentUris.appendId(builder, Today end time) | |
time log here. |
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 -*- | |
# 블디님이 화성 개념글을 보고 만든 파이썬 코드 | |
# Ref: http://www.todayhumor.co.kr/board/view.php?table=music&no=104169&s_no=104169&page=2 | |
MAJOR_SCALE = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B' ] | |
while True: | |
root = raw_input(u'루트음은?(종료=Q) : ') | |
root = root.upper() | |
if root == 'Q': |
OlderNewer