This file contains 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 base64 | |
from django.contrib.auth import authenticate | |
''' | |
In your views you can call has_basic_auth(request) to check if request headers have a valid Authorization header or not. | |
Returns False if header is absent or based on invalid username/password combination. | |
Handle the result in your view accordingly |
This file contains 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
def dehydrate(self, bundle): | |
x = bundle.obj.get_x() | |
ur = UserResource() | |
ur_bundle = ur.build_bundle(obj=x, request=bundle.request) | |
bundle.data['x'] = ur.full_dehydrate(ur_bundle) | |
return bundle |
This file contains 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 json, ast | |
def dehydrate_metadata(self, bundle): | |
metadata_dict = ast.literal_eval(bundle.data['metadata']) | |
metadata_dict_str = dict([(str(k), str(v)) for k, v in metadata_dict.items()]) | |
return json.dumps(metadata_dict_str) |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Checkbox grid" /> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script> | |
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> |
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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
package com.drc.paytm_example; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Random; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.Window; |
This file contains 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 Node: | |
def __init__(self, key=None, word_count=0): | |
self.key = key | |
self.word_count = word_count #Since word and prefix counts are same | |
self.edges = [] #List of Nodes | |
class Trie: | |
def __init__(self, root=None): | |
self.root = root |
This file contains 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 Node: | |
def __init__(self, value): | |
self.value = value | |
self.left = None | |
self.right = None | |
class BST: | |
def __init__(self, root=None): |
This file contains 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
var MyString = function(source){ | |
var arr = []; | |
for(var index in source){ | |
arr.push(source[index]); | |
//Public property | |
this[index] = source[index]; | |
} | |
//Public property |
This file contains 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
it.only('Async should work with Recursion', function (done) { | |
var n = 10; | |
var f = function(callback) { | |
async.waterfall([ | |
function (cb) { | |
n--; | |
cb(null, n); | |
}, | |
function (b, cb) { |