A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
package com.my.package.services; | |
import android.app.Service; | |
import android.content.Intent; | |
import android.location.Location; | |
import android.os.Bundle; | |
import android.os.IBinder; | |
import android.util.Log; | |
import com.google.android.gms.common.ConnectionResult; |
public class MyFragment extends SupportMapFragment { | |
public static final String TAG = "MyFragment"; | |
// Milliseconds per second | |
private static final int MILLISECONDS_PER_SECOND = 1000; | |
// Update frequency in seconds | |
public static final int UPDATE_INTERVAL_IN_SECONDS = 120; | |
// Update frequency in milliseconds | |
private static final long UPDATE_INTERVAL = MILLISECONDS_PER_SECOND * UPDATE_INTERVAL_IN_SECONDS; |
{ | |
// http://eslint.org/docs/rules/ | |
"ecmaFeatures": { | |
"arrowFunctions": false, // enable arrow functions | |
"binaryLiterals": false, // enable binary literals | |
"blockBindings": false, // enable let and const (aka block bindings) | |
"classes": false, // enable classes | |
"defaultParams": false, // enable default function parameters | |
"destructuring": false, // enable destructuring |
import Ember from 'ember'; | |
const {get} = Ember; | |
export default Ember.Component.extend({ | |
_doSomething() { | |
let getSomething = get(this, 'something'); | |
} | |
}); |
import Ember from 'ember'; | |
const {on, get} = Ember; | |
let prop = function(key) { return get(this, key) }; | |
export default Ember.Component.extend({ | |
onElementInsert: on('didInsertElement', function() { | |
// In this place we just bind components context |
import Ember from 'ember'; | |
const {on, get} = Ember; | |
let make = () => function(key) { return get(this, key) }; | |
let prop = make(); | |
export default Ember.Component.extend({ | |
onElementInsert: on('didInsertElement', function() { |
const escape = { | |
'&': '&', | |
'<': '<', | |
'>': '>', | |
'"': '"', | |
// jscs:disable | |
"'": ''', | |
// jscs:enable | |
'`': '`', | |
'=': '=' |
/* | |
* Wraps axios and provides | |
* more convenient post method | |
* calls with payload data | |
*/ | |
export function post(uri, data) { | |
return axios.post(uri, data, { | |
headers: getHeaders(), | |
withCredentials: true | |
}) |
/* | |
* Returns default headers list | |
* which will be used with every request. | |
*/ | |
function getHeaders(multipart = false) { | |
let defaultHeaders = BASE_HEADERS | |
if (multipart) { | |
defaultHeaders = {} | |
} |