Skip to content

Instantly share code, notes, and snippets.

Avatar

Danny Roa dannyroa

View GitHub Profile
View rmd_test.json
[{"name" : "Washington, DC",
"country" : "USA"},
{"name" : "Berlin",
"country" : "Germany"},
{"name" : "Frankfurt",
"country" : "Germany"},
{"name" : "London",
"country" : "United Kingdom"},
{"name" : "Shanghai",
"country" : "China"},
View keybase.md

Keybase proof

I hereby claim:

  • I am dannyroa on github.
  • I am dannyroa (https://keybase.io/dannyroa) on keybase.
  • I have a public key whose fingerprint is C228 DA08 572C ED3A C4EE A34B 5F14 20AD B36E B3CE

To claim this, I am signing this object:

View q1.py
@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
if not name:
return "Please type a name"
#open shelve
filename = 'names.db'
d = shelve.open(filename)
@dannyroa
dannyroa / gist:5744412
Created Jun 9, 2013
ActionBat PullToRefresh Error Log
View gist:5744412
E/AndroidRuntime(21307): java.lang.RuntimeException: Unable to start activity ComponentInfo{uk.co.senab.actionbarpulltorefresh.sample/uk.co.senab.actionbarpulltorefresh.sample.ListViewActivity}: java.lang.RuntimeException: Unknown animation name: LinearLayout
E/AndroidRuntime(21307): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
E/AndroidRuntime(21307): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime(21307): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime(21307): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime(21307): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(21307): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(21307): at android.app.ActivityThread.main(ActivityThread.java:5041)
@dannyroa
dannyroa / access_token.py
Last active Dec 18, 2015
google oauth2 login
View access_token.py
def get_access_token(request):
token = request.GET.get('token', None)
if not token:
return HttpResponse('error')
users = GlassUser.Query.all().eq(token=token)
@dannyroa
dannyroa / gist:5528998
Created May 6, 2013
fake camera & gallery for android
View gist:5528998
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
View euler17.py
def get_val():
words = { 1 : 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five', 6 : 'six', 7 : 'seven'
, 8 : 'eight', 9 : 'nine', 10 : 'ten', 11 : 'eleven', 12 : 'twelve', 13 : 'thirteen'
, 14 : 'fourteen', 15 : 'fifteen', 16 : 'sixteen', 17 : 'seventeen', 18 : 'eighteen'
, 19 : 'nineteen', 20 : 'twenty', 30 : 'thirty', 40 : 'forty', 50 : 'fifty', 60 : 'sixty'
, 70 : 'seventy', 80 : 'eighty', 90 : 'ninety', 100 : 'hundred', 1000 : 'thousand' }
View merge_sort.py
# Sorting a List using Mergesort in Python
# 2011-05-16
def mergeSort(toSort):
if len(toSort) <= 1:
return toSort
mIndex = len(toSort) / 2
left = mergeSort(toSort[:mIndex])
right = mergeSort(toSort[mIndex:])
View backends.py
class FacebookBackend:
"""
Authenticates against django.contrib.auth.models.User.
"""
@ staticmethod
def authenticate(request):
if 'access_token' in request.session:
@dannyroa
dannyroa / backends.py
Last active Dec 11, 2015
'code' should only be used once. Once the 'code' is used to obtain the 'access_token', store the 'access_token' to the session. Use 'access_token' if available in the session.
View backends.py
from django.contrib.auth.models import User
from facebookconnect.models import FacebookProfile
from django.conf import settings
from django.core.urlresolvers import reverse
import facebook
from facebookconnect.utils import facebook_login_check, get_access_token
class FacebookConnectBackend:
"""
You can’t perform that action at this time.