Skip to content

Instantly share code, notes, and snippets.

View jrm2k6's full-sized avatar

Jeremy Dagorn jrm2k6

View GitHub Profile
# custom Authorization
from tastypie.authorization import Authorization
class SimpleReaderAuthorization(Authorization):
def read_list(self, object_list, bundle):
return object_list.filter(email=bundle.request.user.email)
# resource
@jrm2k6
jrm2k6 / gist:6661410
Created September 22, 2013 16:12
adapter
package com.jumy.twitterclient.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
->./hist log_history_parser dney4mhqe2oy 2013-09-15 2013-09-20
Process Process-2:
Process Process-1:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/multiprocessing/process.py", line 88, in run
self._target(*self._args, **self._kwargs)
@jrm2k6
jrm2k6 / gist:6637633
Created September 20, 2013 13:33
brew doctor error.
->brew doctor
Error: no such file to load -- requirements/minimum_macos_requirement
Please report this bug:
https://github.com/mxcl/homebrew/wiki/troubleshooting
/usr/local/Library/Homebrew/requirements.rb:4:in `require'
/usr/local/Library/Homebrew/requirements.rb:4
/usr/local/Library/Homebrew/dependency_collector.rb:4:in `require'
/usr/local/Library/Homebrew/dependency_collector.rb:4
/usr/local/Library/Homebrew/formula.rb:1:in `require'
<component name="libraryTable">
<library name="support-v4-18.0.0">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../../Android/android-sdk-mac_x86/extras/android/m2repository/com/android/support/support-v4/18.0.0/support-v4-18.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component
@jrm2k6
jrm2k6 / gist:6584648
Created September 16, 2013 18:37
Longest words
import System.Environment (getArgs)
stringToArray :: String -> [String]
stringToArray s = words s
findLongestWord :: String -> [String] -> String
findLongestWord x [] = x
findLongestWord l (w1:s1)
| length w1 > length l = findLongestWord w1 s1
| otherwise = findLongestWord l s1
import System.Environment (getArgs)
stringToArray :: String -> [String]
stringToArray s = words s
findLongestWord :: [String] -> String -> String
findLongestWord [] x = x
findLongestWord (w1:s1) l
| length w1 > length l = findLongestWord s1 w1
| otherwise = findLongestWord s1 l
@jrm2k6
jrm2k6 / gist:6506297
Last active December 22, 2015 17:29
Dehydrate error
from tastypie.resources import ModelResource
from simplereader_client.models import ReaderUser, Feed
from django.contrib.auth.models import User
from tastypie.authentication import (
Authentication, ApiKeyAuthentication, BasicAuthentication,
MultiAuthentication)
from tastypie.authorization import Authorization
from tastypie import fields
from tastypie.constants import ALL
class ReaderUserResource(ModelResource):
class Meta:
queryset = ReaderUser.objects.all()
resource_name = 'user'
filtering = {
'email': ['exact'],
'password': ['exact'],
}
url called http://localhost:8000/api/user/?password__exact=103a8ab6cc265e99a4ce8cea60e63d1f8fc0004f&email__exact=jeremy.dagorn@gmail.com
class ReaderUserResource(ModelResource):
class Meta:
queryset = ReaderUser.objects.all()
resource_name = 'user'
filtering = {
'email': ['exact'],
'password': ['exact'],
'query': ['exact',],