How to conditionally map two identical variables in nginx?

I would like to set the variable $ sub conditionally dependent on $ request_uri and $ host.

map $  request_uri $  sub {     default       front;     ~^/api/.*     api;     ~^/rest/.*    rest; }  map $  host $  sub {     hostnames;      #default    $  sub; # Tried, no success      ping.*     ping;     admin.*    admin; }  server {     listen 80;     server_name _;      root /usr/share/nginx/html;      location / {         add_header X-Sub $  sub;         try_files $  uri $  uri/ /index.html;     } } 

I thought nginx will not overwrite $ sub in map $ host $ sub if the hostname is not in the list, but unfortunatly it just blanks out $ sub.

So basically it should be like if $ host is “ping” or “admin” set $ sub accordingly. If hostname did not match, check for $ request_uri.

Any idea how to archive that statement?

SPFX Conditionally display fields in custom web part (react-list-form)

New to SPFX – I’d like to implement the custom web part react-list-form. Everything looks and works great, except I also need the ability to conditionally show / hide certain fields based on other field values.

I’m wondering what the best approach would be to customize this sample for this purpose – maybe adding an additional field for custom javascript in the web part’s edit property pane… Does anyone know the best approach / or how I might go about it?

Clearing conditionally hidden inputs

Am I misunderstanding how this works?

https://www.drupal.org/node/3003163#comment-13134024

We have checked “Clear Value(s) When Hidden” but the values in the hidden fields are not cleared and are submitted with visible form fields.

  1. Enter value in fields Sitting and Year.
  2. Hide “Sitting” and “Year” fields by selecting another conditional field, General Assembly.
  3. “Sitting” and “Year” fields are not cleared when hidden.
  4. Values are submitted for “Sitting” and “Year”.

&general_assembly=65&sitting=spring&year=2016

Pandas styling: Conditionally change background color of column by absolute value

I had posted question in stackoverflow.com about how I can apply conditionally change background color of column by absolute value. https://stackoverflow.com/questions/56202218/pandas-styling-conditionally-change-background-color-of-column-by-absolute-valu. But, I have not received respond yet. Later, my friend helped me to write small code to replicate the case. He was inspired from this post in stackoverflow.com https://stackoverflow.com/questions/38931566/pandas-style-background-gradient-both-rows-and-columns. But, for some reason, this code does not work. But, i can not figure out where is a problem.

import pandas as pd import matplotlib.pyplot as plt from matplotlib import colors df = pd.DataFrame([[3,2,10,4],[20,1,3,2],[5,4,6,1]])  def background_gradient(s,m=None,M=None,cmap="PuBu",low=0,high=0):     s = s.applymap(lambda x:abs(x-6))     if m is None:         m = s.min().min()     if M is None:     M=s.max().max()     rng = M-m     norm=colors.Normalize(m-(rng*low),M+(rng*high))     normed =s.apply(norm)     cm = plt.cm.get_cmap(cmap)     c = normed.applymap(lambda x: colors.rgb2hex(cm(x)))     ret = c.applymap(lambda x:"background-color: %s" %x)     return ret df.style.apply(background_gradient,axis=None) 

Best way to conditionally exclude unused code (C++)

I’m working on a bare-metal embedded system, with a class that can be compiled for different hardware versions. The class takes in a pointer to a device and uses it, or takes in NULL if the device is not present on that hardware.

When the device is not present, I want the device code to be left out of the compiled binary, to save space. I can use #defines, but that gets messy. I can create multiple copies of my class, but that is not as maintainable. Is there a better solution to this problem?

Example:

main.cc

#include "my_class.hh"  int main() {     My_Class my_class(NULL);      my_class.perform_tasks();      return 0; } 

my_class.hh

#include "device.hh"  class My_Class { public:     My_Class(Device* device = NULL);      void perform_tasks();  private:      Device* m_device; }; 

my_class.cc

#include "my_class.hh"  My_Class::My_Class(Device* device) : m_device(device) {  }  void My_Class::perform_tasks() {     if(m_device != NULL)     {         m_device->use();     }      // perform other tasks } 

Conditionally enable/disable #autocomplete from client side js

I have a custom search field which searches for a type of content depending on the radio box selected. I have applied autocomplete functionality to the field using hook_form_alter but only want the autocomplete functionality to be available for one of the search types.

Is it possible to conditionally detach the Drupal.behaviors.autocomplete from the text field using my own js?

Update: I have managed to disable the autocomplete functionality by unbinding the events, but I do not know how to add/bind it again:

// update search box text when search type is changed $  (SI_SEARCH.radio).change(function() {   // get search type   SI_SEARCH.search_type = $  (this).val().trim();   switch(SI_SEARCH.search_type) {     case 'course' :        break;     case 'university' :       // disable autocomplete       $  ('#edit-search').unbind('keydown keyup blur');       break;   } }) 

Complex Conditionally Driven Django View

I’m a crop scientist and am currently building a web app that collects weather data then generates and displays modeled agriculturally relevant output. My question centers around an increasingly complex Django view and a desire to learn about a potentially superior implementation if one exists.

I have a Django view that allows the user to select a location from a Google maps layer when the page in initially rendered. Once a selection is made the view will check for location in URL request and render the template for an individual location. Once the individual location page is rendered the user has further options, like selecting a date range for desired data. The selection is made and submitted at which point the view will check for selectstartdate and selectenddate in the URL request and, if present, will render the single location view with data for the desired range. As I plan on adding several other interactive features, I’m beginning to realize that this view is going to get complicated quickly.

Is an intricate, conditionally driven Django view a reasonable implementation or is there a better way to do something like this?

Code

import time from django.shortcuts import render from locations.models import Location from metload.models import Obsset from datetime import datetime from ETo_py.eto import EToEstimator  def single_location(**kwargs):      """      Process a bunch of weather parameters and return modeled output.     This function is not a view, just a helper function for processing data.     I have left out the lengthy inner workings of this function.       """      return context   def index(request):      print('hello')      # Single location without date range selected.     if 'location' in request.GET and \             'selectstartdate' not in request.GET and \             'selectenddate' not in request.GET:          location = request.GET['location']         selectstartdate = None         selectenddate = None          params = {             'location': location,             'selectstartdate': selectstartdate,             'selectenddate': selectenddate,         }          context = single_location(**params)          return render(request, 'locations/location.html', context)      # Single location with a date range selected.     elif 'location' in request.GET and  \             'selectstartdate' in request.GET and \             'selectenddate' in request.GET:          location = request.GET['location']         selectstartdate = request.GET['selectstartdate']         selectenddate = request.GET['selectenddate']          print(selectstartdate, selectenddate)          params = {             'location': location,             'selectstartdate': selectstartdate,             'selectenddate': selectenddate,         }          context = single_location(**params)          return render(request, 'locations/location.html', context)      # Initial page.     else:         # Get locations from db.         locations = Location.objects.all()          # Prepare locations dictionary for google map layer js.         locs_ls = []         for loc in locations:             lat = loc.latitude             lon = loc.longitude             name = loc.name             site_id = loc.site_id              locs_ls.append({'site_id': site_id, 'name': name, 'lat': lat, 'lon': lon})          context = {             'locs_ls': locs_ls,         }          return render(request, 'locations/index.html', context) 

Current Implementation:

https://aerial-analytics.us/locations/

*** This is purely a personal project although I’ve purchased a domain name.

How do I conditionally format text color to match across sheets in Google Sheets?

Edit: I couldn’t figure out how to post pics without editing, so I added them to the OP. The first photo is the process form. On the form, as the boxes are checked the color changes from black to red to green, etc. The second is the schedule for use by field photographer to track what teams need their photo taken. I’d like for the color of on the field schedule to change as it changes in the process tracker. However, since the names of the teams will change from one event to the next, it’s important that I not format the color change to correlate with specific text; rather, it should change based on any color change of text. If that makes sense.

Thank you so much for helping. I’ve still got some hair left that hasn’t been pulled out over this. Any other questions, just let me know.

enter image description hereenter image description hereMy problem is as follows:

I am creating a schedule for a sports photography company that uses several photographers to shoot team photos at tournaments. There are 2 sheets in this instance; the first is a dynamic schedule for the photographers in the field. In this sheet column C is the first team playing on a given field, D is the name of the field they are playing on, and E is the second team playing on the field.

The second sheet is a master sheet with the teams listed in column A. Columns B, C, D, and E have check boxes indicating where in the process the photos are (Photo Taken, Photo Uploaded, Proof Created, Proof Shown). As each box is checked the color of the team name changes to a different color to indicate at a glance what stage the process is in.

My question is; what formula would I use to have the color on the first sheet change in tandem with the color on the first sheet? This would allow the field photographers to know at a glance which photos have been taken and which are ready to be shown. Additionally, it is important to note that this form is meant to be reused at each event, so the team names will change as well. Is it possible to create a formula that states something along the lines of: =IF any text from sheet 2 matches text from sheet one then the color of text much also match?

Apologies for the length of this question. I just wanted to make sure that I included as much information as possible. Any other questions you have, please let me know, and MANY MANY thanks for any and all help!

How can I conditionally format cells to denote past/future/current dates?

I have a church rota Google Sheet. Column A shows the date of each service.

To make it more obvious at a glance, I would like cells in column A to apply formatting so that dates in the past are colored differently. Ideally, the next upcoming date would be highlighted (or at least dates in the current month or something like this).

I am somewhat familiar with conditional formatting but not using it on dates – is this feasible and if so how can I do it? In a perfect world, the entire row would be colored for past weeks but just the cell is sufficient if this is getting tricky.

Conditionally formatting duplicate values in Google sheets with exclusion criteria?

I’m currently working in a Google sheet where I use the following formula to catch duplicate values with conditional formatting:

=countif($ B:$ B,B2)>1

While this works on its own, I find that it does not account for duplicate values I do not want to be counted. In column O, I have values marking the row as “Canceled”. So I want to have Google sheets only conditionally format cells if the following criteria are met:

  • The value in column B has a duplicate

AND

  • Neither duplicate value has the word “canceled” in column O for that row.

This is the formula I tried, but it no longer formats duplicates:

=AND((countif($ B:$ B,B2)>1=TRUE),ISNUMBER(SEARCH("Cancelled",$ O:$ O)=FALSE))

I think what this has done has told the logic to not format duplicates unless there are no instances of “canceled” in column O.