Skip to content

Instantly share code, notes, and snippets.

toDigitsRev :: Integer -> [Integer]
toDigitsRev x
| x <= 0 = []
| otherwise = (x `mod` 10) : (toDigitsRev (x `div` 10))
toDigits :: Integer -> [Integer]
toDigits x = reverse (toDigitsRev x)
doubleEveryOther :: [Integer] -> [Integer]
doubleEveryOther [] = []

Current code:

class PaymentSummaryViewSet(viewsets.ModelViewSet):
    queryset = PaymentSummary.objects.all()
    serializer_class = PaymentSummarySerializer
 
    @action()
    def send(self, request, pk=None):
 # code to send individual payment summary
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):
class PaymentSummaryViewSet(viewsets.ModelViewSet):
queryset = PaymentSummary.objects.all()
serializer_class = PaymentSummarySerializer
@action()
def send(self, request, pk=None):
# code to send individual payment summary
@jacobh
jacobh / gist:9884192
Created March 31, 2014 02:39
LIFX build status light
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
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
@jacobh
jacobh / gist:8491282
Created January 18, 2014 14:25
scraping my own flickr photos
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'
@jacobh
jacobh / gist:8277335
Created January 6, 2014 02:34
nltk stop words
i
me
my
myself
we
our
ours
ourselves
you
your
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',
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',