This file contains hidden or 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 PaymentSummaryViewSet(viewsets.ModelViewSet): | |
queryset = PaymentSummary.objects.all() | |
serializer_class = PaymentSummarySerializer | |
@action() | |
def send(self, request, pk=None): | |
# code to send individual payment summary | |
@collection_action() | |
def send_pending(self, request): |
This file contains hidden or 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 PaymentSummaryViewSet(viewsets.ModelViewSet): | |
queryset = PaymentSummary.objects.all() | |
serializer_class = PaymentSummarySerializer | |
@action() | |
def send(self, request, pk=None): | |
# code to send individual payment summary |
This file contains hidden or 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
require 'LIFX' | |
require 'net/http' | |
require 'json' | |
# LIFX setup | |
green = LIFX::Color.green saturation: 1 | |
red = LIFX::Color.red saturation: 1 | |
white = LIFX::Color.white | |
off_color = LIFX::Color.white brightness: 0 |
This file contains hidden or 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
for WAV_FILE in `ls | grep .wav` | |
do | |
MP3_FILE=`echo $WAV_FILE | sed s/.wav/.mp3/` | |
if [ ! -f $MP3_FILE ] | |
then | |
lame -q0 -V0 $WAV_FILE $MP3_FILE | |
fi | |
done |
This file contains hidden or 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 gevent.pool import Pool | |
import json | |
import os | |
import requests | |
from tqdm import tqdm | |
from urllib import urlretrieve | |
ENDPOINT = 'http://api.flickr.com/services/rest/' | |
API_KEY = 'nope' | |
USER_ID = '48735087@N06' |
This file contains hidden or 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
i | |
me | |
my | |
myself | |
we | |
our | |
ours | |
ourselves | |
you | |
your |
This file contains hidden or 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 timeit | |
setup = ''' | |
from proposals.models import Proposal | |
from proposals.serializers import ProposalSerializer | |
from rest_framework.renderers import JSONRenderer | |
from drf_ujson.renderers import UJSONRenderer | |
proposals = list(Proposal.objects.all().prefetch_related( | |
'media_items', |
This file contains hidden or 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
GizmagAdmin.factory "proposalUtils", ($http) -> | |
base_url = '/api/proposal/' | |
transitions = ['submit', 'request_changes', 'reject', 'approve', 'accept'] | |
output = | |
save: (proposal, opts={}) -> | |
if proposal.id | |
if opts.partial | |
return $http | |
method: 'PATCH', |
This file contains hidden or 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 Proposal: | |
def _get_state_log(self, memo={}): | |
print memo | |
# return cached log if it appears to be correct | |
if 'log' in memo: | |
if self.status == memo['log'].state: | |
print 'returning cached value' | |
return memo['log'] | |
print 'executing query' |
This file contains hidden or 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 MyClass(models.Model): | |
@fsm_log_by | |
@transition(...) | |
def my_transition(self, by=None): | |
... |