This file contains hidden or 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
| #' Install/update necessary packages from CRAN, Bioconductor, GitHub, or local sources | |
| #' | |
| #' @param file a file with packages; overrides packages parameter | |
| #' @param packages a vector of strings with names of packages from CRAN, Bioconductor, GitHub | |
| #' @param failFast whether to immediately stop with an error upon first package installation failure | |
| #' @param updatePackages whether to update existing packages (Default: FALSE) | |
| #' @param dryRun whether to test for missing packages (Default: FALSE) | |
| #' | |
| #' @example | |
| #' \dontrun { |
This file contains hidden or 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
| [values.pop(), values.join(', ')].filter(v => v).reverse().join(' and ') | |
| // ['this'] => 'this' | |
| // ['this', 'that'] => 'this and that' | |
| // ['this', 'that', 'the other'] => 'this, that and the other' |
This file contains hidden or 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
| /* | |
| * Join the elements in an javascript array, | |
| * but let the last separator be different eg: `and` / `or` | |
| * Stackoverflow link: http://stackoverflow.com/questions/15069587/is-there-a-way-to-join-the-elements-in-an-js-array-but-let-the-last-separator-b | |
| * Credit: Chris Barr - http://stackoverflow.com/users/79677/chris-barr | |
| */ | |
| function formatArray(arr){ | |
| var outStr = ""; | |
| if (arr.length === 1) { | |
| outStr = arr[0]; |
This file contains hidden or 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
| /** | |
| * Retrieves all the rows in the active spreadsheet that contain data and logs the | |
| * values for each row. | |
| * For more information on using the Spreadsheet API, see | |
| * https://developers.google.com/apps-script/service_spreadsheet | |
| */ | |
| function readRows() { | |
| var sheet = SpreadsheetApp.getActiveSheet(); | |
| var rows = sheet.getDataRange(); | |
| var numRows = rows.getNumRows(); |
This file contains hidden or 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
| #' Install/update necessary packages from CRAN, Bioconductor, GitHub, or local sources | |
| #' | |
| #' @param file a file with packages; overrides packages parameter | |
| #' @param packages a vector of strings with names of packages from CRAN, Bioconductor, GitHub | |
| #' @param updatePackages whether to update existing packages (Default: FALSE) | |
| #' @param dryRun whether to test for missing packages (Default: FALSE) | |
| #' | |
| #' @example | |
| #' \dontrun { | |
| #' source("https://gist.githubusercontent.com/cannin/6b8c68e7db19c4902459/raw/installPackages.R") |
This file contains hidden or 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 MultiFormMixin(ContextMixin): | |
| form_classes = {} | |
| prefixes = {} | |
| success_urls = {} | |
| grouped_forms = {} | |
| initial = {} | |
| prefix = None | |
| success_url = None |
This file contains hidden or 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 waitForEl = function(selector, callback) { | |
| if (jQuery(selector).length) { | |
| callback(); | |
| } else { | |
| setTimeout(function() { | |
| waitForEl(selector, callback); | |
| }, 100); | |
| } | |
| }; |
This file contains hidden or 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 ValidateModelMixin(object): | |
| """Make :meth:`save` call :meth:`full_clean`. | |
| .. warning: | |
| This should be the left-most mixin/super-class of a model. | |
| Do you think Django models ``save`` method will validate all fields | |
| (i.e. call ``full_clean``) before saving or any time at all? Wrong! |
This file contains hidden or 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
| jQuery(function($) { | |
| // returns an array of the potential selector components for the first element in the jQuery object. IDs, classes, and tagNames only. | |
| var getSelectorComponents = function($el) { | |
| var components = []; | |
| var id = $el.attr('id'); | |
| if (typeof(id)!='undefined' && /[^\s]/.test(id)) { | |
| components.push('#'+id); | |
| } |
This file contains hidden or 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 time | |
| from django.utils.http import http_date | |
| AJAX_NEGATIVE_CHECK_EXPIRES = 60 # object is still available | |
| AJAX_POSITIVE_CHECK_EXPIRES = 60*10 # if object is not available (or taken) | |
| def check_ajax(request): | |
| # do stuff here | |
| timeout = AJAX_NEGATIVE_CHECK_EXPIRES if avail else AJAX_POSITIVE_CHECK_EXPIRES |
NewerOlder