I hereby claim:
- I am coci on github.
- I am coci (https://keybase.io/coci) on keybase.
- I have a public key ASDq-_3rCbiNUWTDSixqh2ZGTxahbCxMBWoHT8X2k7pf9Qo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| $ ./manage.py shell | |
| Python 2.7.5 (default, Aug 25 2013, 00:04:04) | |
| [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin | |
| Type "help", "copyright", "credits" or "license" for more information. | |
| (InteractiveConsole) | |
| >>> from followers.models import * | |
| >>> john = User.objects.create_user('john', 'lennon@thebeatles.com', 'password') | |
| >>> paul = User.objects.create_user('paul', 'mccartney@thebeatles.com', 'password') | |
| >>> george = User.objects.create_user('george', 'harrison@thebeatles.com', 'password') | |
| >>> ringo = User.objects.create_user('ringo', 'starr@thebeatles.com', 'password') |
I hereby claim:
To claim this, I am signing this object:
| import random | |
| import string | |
| from random import randrange | |
| from rest_framework import status | |
| from rest_framework.views import APIView | |
| from rest_framework.response import Response | |
| from rest_framework.authtoken.models import Token | |
| from users.models import CustomUser |
| import time | |
| import threading | |
| class BaseThread(threading.Thread): | |
| def __init__(self, callback=None, callback_args=None, *args, **kwargs): | |
| target = kwargs.pop('target') | |
| super(BaseThread, self).__init__(target=self.target_with_callback, *args, **kwargs) | |
| self.callback = callback | |
| self.method = target |
| import threading | |
| import Queue | |
| import timeit | |
| q = Queue.Queue() | |
| number = 5 | |
| t1 = timeit.default_timer() | |
| # Step1: For example, we are running multiple functions normally | |
| result = [] |
| class Stack: | |
| def __ini__(self): | |
| self.array = [] | |
| def push(self,item): | |
| self.array.append(itme) | |
| def pop(self): | |
| return self.array.pop() | |
| def isEmpty(self): | |
| return True if len(array) > 0 else False | |
| class Stack: | |
| def __ini__(self): | |
| self.array = [] | |
| def push(self,item): | |
| self.array.append(itme) | |
| def pop(self): | |
| return self.array.pop() | |
| def isEmpty(self): | |
| return True if len(array) > 0 else False | |
| # in this seriliazer : 'user' is forignkey to customuser | |
| # i need add user name and pk instead of pk only | |
| class LandSerializer(serializers.ModelSerializer): | |
| points = PointSerializer(many=True, read_only=True) | |
| class Meta: | |
| model = Land | |
| fields = ('pk', 'user', 'name', 'create_time', 'points') |
| to create initial data for models in django : | |
| 1- create "fixtures" dir inside app | |
| 2- add fx.json file init | |
| 3- add data like : | |
| [ | |
| { | |
| "model": "activity.Todo", | |
| "pk": 1, | |
| "fields": { | |
| "name": "buy food" |