Skip to content

Instantly share code, notes, and snippets.

View meoooh's full-sized avatar

han meoooh

  • 뉴비 주식회사
View GitHub Profile
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
hhash = {}
(0..10000000).each{ |i| hhash[i] = rand };
parallel_sum = Parallel.map(hhash.each_slice(1000)) do |ele| # https://github.com/grosser/parallel
ele.sum{|value| value.last}
end.sum
puts parallel_sum
// dependencies
var async = require('async');
var AWS = require('aws-sdk');
var gm = require('gm')
.subClass({ imageMagick: true }); // Enable ImageMagick integration.
var util = require('util');
// constants
var MAX_WIDTH = 100;
var MAX_HEIGHT = 100;
class UserSerializer(serializers.HyperlinkedModelSerializer):
password2 = serializers.CharField()
class Meta:
model = VomUser
fields = ('url', 'id', 'email', 'sex', 'birthday',
'name', 'password', 'password2')
read_only_fields = ('email',)
def __init__(self, *args, **kwargs):
class MyUserManager(BaseUserManager):
def create(self, email, name, birthday, sex, password):
return self.create_user(email=email,
password=password,
name=name,
birthday=birthday,
sex=sex,
)
def create_user(self, email, name, birthday, sex, password):
class UserSerializer(serializers.ModelSerializer):
password2 = serializers.CharField()
class Meta:
model = VomUser
fields = ('id', 'email', 'sex', 'birthday',
'name', 'password', 'password2')
def __init__(self, *args, **kwargs):
# Don't pass the 'fields' arg up to the superclass
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from rest_framework import serializers
class UserSerializer(serializers.ModelSerializer):
password2 = serializers.CharField()
class Meta:
model = User
$ ./manage.py shell
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from app.serializers import *
>>> u=UserSerializer(data={'username':'test1','password':'pass','password2':'pass'})
>>> u.errors
Traceback (most recent call last):
File "<console>", line 1, in <module>
from django.contrib.auth.models import User
from rest_framework import viewsets
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.response import Response
from myapp.serializers import UserSerializer, PasswordSerializer
class UserViewSet(viewsets.ModelViewSet):
"""
A viewset that provides the standard actions
class RightDoor(object):
def right_open(self):
print "RightDoor open complete"
self.beep()
class LeftDoor(object):
def left_open(self):
print "LeftDoor open complete"
self.beep()