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
String.prototype.format = function (obj) { | |
/** | |
* Does the same as a simple form of python "".format | |
* that will not work for anything else than number or string. | |
* Array form : | |
* "I have {} replacements to {}".format("two", "make") | |
* "I have {} replacements to {}".format(["two", "make"]) | |
* "I have {0} replacements to {1}".format(["two", "make"]) | |
* Dict form : | |
* "Hello {name} !".format({name: "Bob"}); |
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
define(["jq"], function($){ | |
"use strict"; | |
var Class = function(){}; | |
var minimal_class_definition = | |
{ | |
init: function() | |
{ | |
} | |
}; | |
var extend = function (base_class, additionnal_definition) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 get_linked_objects(obj): | |
""" | |
Returns all the objects that would be deleted if a cascade deletion were to be done. | |
""" | |
links = [rel.get_accessor_name() for rel in obj._meta.get_all_related_objects()] | |
return [liked_obj for link in links for liked_obj in getattr(obj, link).all()] |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 inspect | |
def debug(): | |
""" | |
Anywhere in the code: | |
debug() # opens ipython shell | |
""" | |
from IPython.terminal.embed import InteractiveShellEmbed | |
ipshell = InteractiveShellEmbed() |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/env python3 | |
# coding=utf-8 | |
""" | |
Borrowed and updated from | |
https://adamj.eu/tech/2014/09/21/using-ipython-notebook-to-write-jekyll-blog-posts/ | |
""" | |
from __future__ import print_function |
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
from math import cos, sin, radians, atan2, sqrt | |
radius = 6371 # km | |
def distance(origin, destination): | |
""" | |
Determine distance between 2 sets of [lat,lon] in km | |
""" |
OlderNewer