First, make sure you use the SessionAuthentication in Django. Put this in your settings.py
# Django rest framework
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication'
// Boring | |
if (isThisAwesome) { | |
alert('yes'); // it's not | |
} | |
// Awesome | |
isThisAwesome && alert('yes'); | |
// Also cool for guarding your code | |
var aCoolFunction = undefined; |
sub vcl_recv { | |
#FASTLY recv | |
# We don't do other methods | |
if (req.method != "GET") { | |
return(error); | |
} | |
# Handle IPv4 or IPv6 provided in url path (nothing extraneous allowed, perform basic matching) | |
if (req.url.path ~ "^/([a-f0-9:.]+)$") { | |
set client.geo.ip_override = re.group.1; |
Multiple asynchronous jQuery operations such as .ajax() and animations can be sequenced (chained) using the accompanying patterns which make use of jQuery Deferred techniques rather than the less extensible and non-ideal recursive call techniques.
There are three usage patterns, each implemented herein and tested using the supplied data for .ajax() transactions...
/** | |
* A Javascript test runner in 20 lines of code | |
* From http://joakimbeng.eu01.aws.af.cm/a-javascript-test-runner-in-20-lines/ | |
*/ | |
(function () { | |
// The test queue: | |
var tests = []; | |
// Function to add tests: | |
this.test = function test (name, cb) { |
These are some notes on my process when I review dependency updates for both JavaScript and Python projects at Hypothesis.
Before adding a dependency to a project, consider the impact on future maintenance. If what the dependency does for the project can be implemented with only a few lines of code, or can be implemented in an alternative way using dependencies the project already has, it may be a better choice to do that and avoid the dependency.
mWebView.setResourceClient(new XWalkResourceClient(mWebView) { | |
@Override | |
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) { | |
WebResourceResponse ret = null; | |
try { | |
URL tmpUrl = new URL(url); | |
mConn = (HttpURLConnection)tmpUrl.openConnection(); | |
mConn.addRequestProperty("Authorization", authHeader); | |
mConn.addRequestProperty(getString(R.string.app_version_header_key), ((MyApplication)getApplication()).getVersioName()); |
predicate should be a function that accepts three arguments and returns a value that is coercible to the Boolean value true or false. findIndex calls predicate once for each element present in the array, in ascending order, until predicate returns true and immediately returns the index of the current array element. Otherwise, findIndex return -1. predicate is called only for elements of the array which actually exist; it is not called for missing elements of the array.
predicate should be a function that accepts three arguments and returns a value that is coercible to the Boolean value true or false. find calls predicate once for each element present in the array, in ascending order, until predicate returns true and immediately returns the current array element. Otherwise, find returns null. predicate is called only for elements of the array which actually exist; it is not called for missing elements of the array.