FAQ Database Discussion Community


can cljc single-file macro definitions to work with clojurescript?

clojure,macros,conditional,clojurescript,reader
I have clojurescript successfully importing macros from other namespaces. But I wonder whether a single-file construction is/should be possible with clojure 1.7, such that a macro can be defined and used. What I have tried does not work, but maybe I've missed a detail someplace. (ns cljc.core) #?(:cljs (enable-console-print!)) #?(:clj...

Cassandra CQL3 conditional insert/update

cassandra,nosql,conditional,updates,cql3
I have a list of unordered events and my task is to store first and last occurrences for them. I have following column family in Cassandra: CREATE TABLE events ( event_name TEXT, first_occurrence BIGINT, last_occurrence BIGINT, PRIMARY KEY (event_name) ); So if I have an event with the name "some_event"...

sas conditional sum into new field

sql,sas,conditional
I'm new to SAS and have a simple dataset called ORIG_DATA from which I need to create a new dataset SUMMARY which shows the total by Salesman_ID by Day_ID In essence the SUMMARY output should look like this where the numbers are the sum of totals. Salesman_ID|Day_1|Day_2 A |30 |40...

Deleting rows in R conditionally

r,conditional,delete-row
I have a data where the first column is a bunch of ID numbers (some repeat), and the second column is just a bunch of numbers. I need a way to keep each ID number only once based on the smallest number in the second column. Row# ID Number 1...

C compound conditional not working as expected (value mysteriously reassigned to other value) - possible gcc bug

c,conditional
I have a program that is stuck in a loop because of a possible bug in gcc. I have tested this on multiple versions of the compiler, and it seems to stick around. A mockup version of the bug is #include <stdio.h> #include <stdlib.h> #define db printf("t=%d\n", t) size_t t...

fill values of a column with values from another column (but not on the same row), conditionally, in R

r,loops,conditional
I have a question about how to fill values of a column with values from another column (but not on the same line), conditionally. Let me explain the situation with an example of my dataset. This is my dataset, where two individuals (ID) column are engaged in dyadic fights (fight_id...

Conditionally removing duplicate rows from a data frame

r,data.frame,duplicates,conditional
I have a data frame in R consisting of two columns: 'Genes' and 'Expression'. It has duplicate rows for some of the Genes, however these duplicate entries have differing Expression values. I want to condense the duplicate rows so there is just one row per Gene, and that this row...

MYSQL conditional update table

mysql,sql-update,conditional
I am trying to update a database table based on a certain condition. Here is the sample table. fname mname lname 1 RONALD D VALE 2 RONALD VALE 3 JACK A SMITH 4 JACK B SMITH 5 JACK SMITH I would like to update the middle names column if the...

How to set a conditional based on multiple models?

ruby-on-rails,ruby,model-view-controller,notifications,conditional
notifications/index has <%= render partial: "notifications/notification", collection: @notifications %>, which contains: <% if Comment.find_by(notification.comment_id) == @habit %> <%= link_to "your habit", habit_path(notification) %> <% else %> <%= link_to "your value", valuation_path(notification) %> <% end %> which shows gives the error for the 1st line: Couldn't find Habit with 'id'= even...

Searching python lists with loops and conditionals

python,python-2.7,loops,conditional
def ListCreate(*args): items = none for i in range(len(args)-1,-1,-1): items = join(args[i], items) return items a = ListCreate(1,2,3,4,5,6) b = ListCreate(20150602, 20150603, 20150604, 20150605, 20150606, 20150607) Lists in python are ordered, so I would like element 0 in list a to correspond with element 0 in list b. i.e. (1,20150602)(2,20150603)(3,20150604)...

How to unnest a nested cell array?

arrays,matlab,conditional,cell
Hello I am trying to create a cell array that should look something like this. '3/7/2014' '209.167.128.156' 1037 '3/13/2014' '204.205.57.137' 8 '3/18/2014' '209.167.128.156' 164 '3/27/2014' '216.178.43.209' 825 But the problem is when I run my code I get a cell array that looks like this {1x3cell} {1x3 cell} {1x3 cell}...

Wordpress Multisite Conditionals?

php,wordpress,conditional,multisite
So I have a wordpress Multisite with about 15 different sites. Just an example: country.com (main site) usa.country.com china.country.com france.country.com Now lets say in china.country I wanted an h1 tag that says "THIS IS CHINA" on the header BUT not on any other multisite not even the main one. Is...

Conditional Order by multiple columns Mysql

mysql,sql-order-by,conditional
I have a table consisting of authors, few authors have both Bio and Image, few have only image, few have only bio, and few have neither.. bio and image are stored in different columns, I want to sort my query result (order by ) in such a way that authors...

How to create a new variable with values from different variables if another variable equals a set value in R?

r,conditional,condition,subset
I have a complicated question that I will try to simplify by simplifying my dataset. Say I have 5 variables: df$Id <- c(1:12) df$Date <- c(NA,NA,a,a,b,NA,NA,b,c,c,b,a) df$va <- c(1.1, 1.4, 2.5, ...) #12 randoms values df$vb <- c(5.9, 2.3, 4.7, ...) #12 other random values df$vc <- c(3.0, 3.3, 3.7,...

Combining two for-loops that share similar properties

javascript,loops,dom,conditional
I have two divs which numerically represent the width and height of the window's screen, counting from every 100th pixel. The numeric values are wrapped inside span tags and inserted into their respective div container through two loops. Since both of these loops share almost the same exact methods and...

One liner conditional, multiple variables and check that all of them are not false?

python,if-statement,conditional,conditional-statements
How I can make a conditional in python that checks for this three keywords defined in the dictionary and that they are not False ? settings = { 'proxy_host': '127.0.0.1', 'proxy_port': 8080, 'proxy_protocol': 'socks', } I have tried with the sentence you can see below. But this is only checking...

How to set font-weight of a column text to bold based on another column value in Telerik Grid

telerik,formatting,conditional,client-templates
I have a Telerik grid in which based on whether my IsTrue value is true or false, I need to set the font-weight of Name text in only that particular row to bold. I tried the following but I seem to be missing something. columns.Bound(d => d.IsTrue).Width(0).HtmlAttributes(new { id="hdnIsTrue", style...

Is There Anything Like a Templatized Case-Statement

c++,templates,conditional,case-statement,nested-if
So I have this really ugly code: template <typename T> std::conditional_t<sizeof(T) == sizeof(char), char, conditional_t<sizeof(T) == sizeof(short), short, conditional_t<sizeof(T) == sizeof(long), long, enable_if_t<sizeof(T) == sizeof(long long), long long>>>> foo(T bar){return reinterpret_cast<decltype(foo(bar))>(bar);} I'm using nested conditional_ts to make a case-statement of sorts. Is there something out there that accomplishes this more...

Javascript var === 2 && console.log('true'). How does this work?

javascript,conditional
var test = 2; test === 2 && console.log('true'); This confuses me. I hadn't seen this before until the other day. The output of this will be true in the console. So how does this magic work?...

MySQL Conditional Left Join With Default

mysql,left-join,conditional
Is there a way to make a conditional left join, which will left join on a default value if a match is not found? I have a client table and a preference table. Record 0 in the preference table is my global default preference. There are cases in which a...

Creating a subset in R using a double loop [closed]

r,loops,double,conditional,subset
I have a very large csv file I have imported into R and need to make a subset of data. The csv looks something like this: Julian_Day Id Year 52 1 1901 56 5 1901 200 1 1968 ect, where year is 1901-2010, Id 1-58 and Julian_Day 1-200 for about...

.NET use IIF to assign value to different variables

.net,vb.net,conditional,variable-assignment,iif
Could I (and if so how) do the following in .NET language (more specifically VB.NET): Dim a,b as Integer if(somecondition=1,a,b) = 12345 Or any variant with IIF would be fine by me. Basically I'm always assign the same value but never to the same variable.....

Kendo ui grid if else condition

javascript,if-statement,kendo-grid,conditional
What is wrong with my code? I have to check in kendo UI grid is there "OrderType 20" in my column. If it is, I need to apply my css condition which includes background, but it does not work, can someone help me? thanks template: '# if (OrderType == "OrderType...

Using Razor Syntax within JavaScript Conditional Statment

javascript,c#,asp.net-mvc,razor,conditional
In an index.cshtml I have the following working code similar to: <script type="text/javascript"> if ('@Model.SomeCondition' === 'True'){ Do Something(); } </script> The === 'True' seems like an odd hack to me to force Razor and JavaScript to get along. How can I refactor to use === true? This doesn't give...

MATLAB find array element and conditionally add to a constant

arrays,matlab,conditional,addition
Given this array of angles: 123.5280 129.5280 129.0130 136.2960 139.1640 145.7430 148.9800 156.9080 168.3440 179.2340 3.0840 3.9720 I would like to identify those which are < 90 degrees angles(angles < 90) ans = 3.0840 3.9720 and add 180 to only those two having as a result 123.5280 129.5280 129.0130 136.2960...

C# conditional statements in menuitem in asp.net

c#,asp.net,conditional,menuitem
My project has been changed to C#, from VB. I do want the conditional to be done in the menuitem. I realize there may be other ways of doing it, however, I want it to be done in the menuitem. I need to do a conditional in the menuitem so...

Conditional Logic for links in ACF

php,wordpress,if-statement,conditional,acf
So here is what im trying to do. Im using Advanced Custom Fields for this and am outputting a title with a link, But sometimes their is NO link. When there is NO link I don't want this to be wrapped in a tag but I can't seem to figure...

Why does (( s )) do a variable lookup, but not [[ s ]]?

linux,bash,shell,conditional
Suppose I have the following script saved as runme.sh usage() { echo "Usage: $0 [-s <integer>] [-l <string>]" 1>&2; exit 1; } while getopts ":s:l:" o; do case "${o}" in s) s=${OPTARG} [[ $s =~ ^-?[0-9]+$ ]] || usage ;; l) l=${OPTARG} ;; *) usage ;; esac done echo "s...

Wix: Run custom action based on condition

wix,windows-installer,conditional,condition,custom-action
I'm trying to run a custom action (delete a certain file) based on the windows version. I know how to check for the windows version: <Condition Message="Windows version xxx required..."> <![CDATA[Installed OR (VersionNT >= 600)]]> </Condition> However, I do not want to display a message, but delete a file. I...

Create duplicate rows based on conditions in R

r,duplicates,conditional,data.table
I have a data.table that looks like this dt <- data.table(ID=c("A","A","B","B"),Amount1=c(100,200,300,400), Amount2=c(1500,1500,2400,2400),Dupl=c(1,0,1,0)) ID Amount1 Amount2 Dupl 1: A 100 1500 1 2: A 200 1500 0 3: B 300 2400 1 4: B 400 2400 0 I need to duplicate each row that has a 1 in the Dupl column...

Selection Condition Array In PHP

php,arrays,if-statement,conditional,condition
i have PHP code with loop: $explodeResult=explode(", ",$serviceName); foreach($explodeResult as $value) { $sql = "SELECT id,parent,code,name,xs1 as DOWNLOAD, xs2 as UPLOAD FROM sc_params WHERE rfen = 'SERVICE_REQUESTED' AND code = :param1 OR code IN ( SELECT code FROM sc_params WHERE rfen = 'SERVICE_REQUESTED' AND id = ( SELECT parent FROM...

Reguralexpresion which accepts valid float numbers [PHP]

php,regex,preg-match,conditional
I am trying to verify a valid float number. Basically i want to accept numbers with up to four numbers after the coma: 0,2342 123412,2300 1234.0000 1244 1234,12 1234.12 0.23 I also want to reject the numbers with 0 on the front, but pass the 0 if its on its...

Keep the second occurrence in a column in R

r,conditional,subset,find-occurrences
I have quite a simple dataset: ID Value Time 1 censored 1 1 censored 2 1 uncensored 3 1 uncensored 4 1 censored 5 1 censored 6 2 censored 1 2 uncensored 2 2 uncensored 3 2 uncensored 4 2 censored 5 I want to keep the first uncensored occurrence,...

change value in numpy array based on presence in another array

python,numpy,conditional
I want to change each value of an array (1D) based on whether this value is present in another array (1D) regardless of position. I tried to come along with numpy.where() but couldn't find any working solution yet. import numpy as np a = np.arange(10) b = np.array([5,6,7]) a =...

Thymeleaf compare #locale expression object with string

conditional,locale,thymeleaf,spring-el
I want to set a th:class attribute depending on the context locale using the expression object #locale. I have tried th:class="${#locale}=='en'?'active':''" th:class="${#locale=='en'}?'active':''" Both of them results in false, but whent I print it with th:text="${#locale}, I got the correct locale code (en,es). Any idea of how to compare the #locale...

Conditional subtraction Part 2

r,conditional,multiplication
I have a big data.frame (TOTAL) with some values (cols11-16) that I need to subtract a base from which is multiplied by a value depending on two conditions in TOTAL. The data.frame (TOTAL) looks a little like this Channel Hour Category cols11 cols12 cols13 cols14 cols15 base TV1 01:00:00 New...

Bash conditional statement

bash,conditional
I realize this is probably a really simple problem, but I can't figure out why this isn't working. I'm attempting to check if a folder is larger than 35GB and if so, remove all files that are older than 3 days in it. Like so: #!/bin/bash MAX=35000000000 if [ $(du...

DELETE FROM Table WHERE 'RANK' > 1

sql,sql-server,delete,conditional,rank
I am new to the RANK and CTE queries. The following is my query: SELECT * ,ROW_NUMBER() OVER(PARTITION BY name, Product ORDER BY Date desc) AS 'RANK' FROM Config WHERE Name IN (SELECT name FROM Config GROUP BY Name ,Product ,Amount ,Date HAVING COUNT(name) >1) AND Product IN (SELECT Product...

Conditional query in ElasticSearch?

elasticsearch,conditional
I'm relatively new to ElasticSearch and I need some advice. After several tries, i did not found the solution and that's why I need you. I want to make a conditional query based on the document content. Let me explain, I have those documents in ES: { "name": "Product n°1",...

ng-repeat except value 2

angularjs,conditional,ng-repeat
I have something like that: <div ng-repeat="element in data.arrayElement"> <strong>{{element.name}}</strong> </div> The previuos collection have 5 elements. Can i iterate the collection except the element that has the value 2?. I don't know, maybe like this <div ng-repeat="element in data.arrayElement | filter:element.val() !== 2"> <strong>{{element.name}}</strong> </div> ...

SQL Conditional aggregation

sql,oracle,conditional,aggregation
I'm using Oracle. Having a table as: Year Type Value 2011 1 500 2011 2 550 2011 3 600 ... ... 2012 1 600 2012 2 750 2012 3 930 I needed to subtract all the values from different types, grouped by year. The operation would be: For 2011 ->...

Elastic Search : General and conditional filters

elasticsearch,conditional,apply,exists
I'm using Elastic Search, with query match_all and filtering. In my situation I want to apply a general filter and filters by condition. Here in pseudo: query: match all (works fine) filter range date between d1 and d2 (works fine without bullet 3) filter (apply only if field exists, but...

Conditional text for certain categories within taxonomy.php

wordpress,conditional,archive,taxonomy,easy-digital-downloads
I am building a Wordpress site using 'Easy Digital Downloads'. The downloads have their own 'categories'. To display an archive of those categories (different from the standard archive.php) I am using a template called taxonomy-download_category.php as specified in their documentation. This works perfectly and I can set up the category...

Excel SUMIFS with OR, IF, and multiple criteria

excel,syntax,conditional,sumifs
I am having a problem using SUMIFS. I have columns cost, frequency, interval, and month, where frequency is a string ("monthly", "annually", "other", "once") and the others are all numerical. I am trying to do a SUMIFS where I sum costs depending on different values of frequency, and have something...

Why can't I replace if statement with conditional operator (?:)?

java,if-statement,conditional,ternary-operator
I've been struggling to turn private PlaneClass preferredClass; if (preferredClass == PlaneClass.FIRST_CLASS) preferredClass = PlaneClass.ECONOMY_CLASS; else preferredClass = PlaneClass.FIRST_CLASS; into preferredClass == PlaneClass.FIRST_CLASS ? preferredClass = PlaneClass.ECONOMY_CLASS : preferredClass = PlaneClass.FIRST_CLASS; The if-statement compiles. The conditional operator doesn't. (Error messages: 1. Type mismatch: cannot convert from PlaneClass to boolean 2....

How to write a conditional on two variables (columns) in Pandas

python,pandas,conditional
I'm trying to count instances when there was no login, but there was a card-view, and create a new column with the count (or True). I used the conditional statement below and got a key error. Can someone help me figure out what's going on? import pandas as pd import...

Chance of a conditional occurring in Swift: Xcode

xcode,swift,if-statement,conditional,percentage
I am quite new to Xcode and swift so sorry if this is a bad description. Is there a way that there is a chance of your conditional occurring so instead of it happening 100% of the time when the conditions are met, it only happens 50% of the time...

Join statement with condition in sql

sql,join,conditional
a.geosid a.Latitude a.Longitude b.Latitude b.Longitude b.geosid 9589565 -36.013472 -71.426018 -36.0135 -71.426 9589565 9586071 -36.015 -71.498 -36.1104 -71.4416 9586071 9589565 -36.013473 -71.426017 -36.0135 -71.426 9589565 The data above is formed by running a query in sql something like SELECT * FROM [ChileCSVimports].[dbo].[tLocation] a JOIN AIRGeography..tGeography b ON a.GeographySID = b.GeographySID I...

C - preprocessors multiple macros

c,gcc,macros,conditional,preprocessor-directive
Gcc 4.8.x - 4.9.x Hello, I would like to merge multiple macros in a #ifdef directive, e.g : #ifdef PLOT || GRAPH ..mycode.. #endif But it doesn't work. How may I achieve this ? This is not an option : #ifdef PLOT #ifdef GRAPH ..mycode.. #endif #endif because if plot...

Rails validations if condition

ruby-on-rails,ruby-on-rails-4,conditional
I need your help validating a simple Rails model. First i want to check if the user filled all input-fields: class Test < ActiveRecord::Base validates :firstname, :lastname, :firstvalue, :secondvalue, presence: true [...] I also want to check if the :secondvalue param is bigger than :firstvalue. Adding validate :biggerThan def biggerThan...

Replace an entry in a pandas DataFrame using a conditional statement

python,pandas,conditional
I'd like to change the value of an entry in a Dataframe given a condition. For instance: d = pandas.read_csv('output.az.txt', names = varname) d['uld'] = (d.trade - d.plg25)*(d.final - d.price25) if d['uld'] > 0: d['uld'] = 1 else: d['uld'] = 0 I'm not understanding why the above doesn't work. Thank...

Returning a value from a function within a for-loop

javascript,function,loops,dom,conditional
I want to run a for-loop that appends every hundredth numeric value of the width of the screen into a div. This works: for (var i = 50, numbers = ""; i < limit; i+= 50) { if (num % 100 === 0) { numbers += i; } } document.getElementsByClassName("width")[0].innerHTML...

Exclude subsequent duplicated rows

r,conditional,duplicate-data
I would like to exclude all duplicated rows. However, it has to be true just when they are subsequent rows. Follows a representative example: My input df: df <- "NAME VALUE Prb1 0.05 Prb2 0.05 Prb3 0.05 Prb4 0.06 Prb5 0.06 Prb6 0.01 Prb7 0.10 Prb8 0.05" df <- read.table(text=df,...

Compare multiple values in one condition [duplicate]

c#,variables,if-statement,conditional
This question already has an answer here: Equality comparison between multiple variables 11 answers Int32 int1, int2, int3 = 123; Given the above variables, how can I test that all of my variables have the value 123 without creating a collection to perform some Any or something on? What...

Storing reference (hash?) to the node for conditional manipulation

performance,xslt,conditional
Given this pseudo-code: <xsl:variable name="check0"> <xsl:value-of select="($externalFile//i[@attibute = $variable]/../@start < $genDate) and ($externalFile//i[@attibute = $variable]/../@stop > $genDate)"/> </xsl:variable> <xsl:variable name="check1"> <xsl:value-of select="($externalFile//i[@attibute = $variable]/../@start < $genDate) and ($externalFile//i[@attibute = $variable]/../@stop > $genDate)"/> </xsl:variable> Above code checks if some variable is in date range of attributes taken from...

How do I properly use conditonal execution to draw a circle based on input?

javascript,html,colors,conditional,execution
Basically my end goal is to make a function where in the end you have to finds and one button and when you press the button it adds the 2 numbers together and if that number is less than 5 it draws a red circle and if it is bigger...

Python AND OR statements

python,if-statement,conditional
I am parsing text with Python and I have this final code to write sentences, but it does not work well: opt = child.get('desc') extent = child.get('extent') if opt == 'es': opt = "ESP:" elif opt == "la": opt = "LAT:" elif opt == "en": opt = "ENG:" if opt...

change color on recordset return using php [closed]

php,html,mysql,colors,conditional
I am using a limited, known number of states for the status column in a MySQL table and would like to have an easily identifiable alert within to reflect a particular status. How can you change the background color of a cell in a php generated HTML table according to...

Looping through array and grouping data based on a criteria in perl [closed]

arrays,perl,loops,conditional,grouping
I have an array as mentioned below with four columns. Each column represents start, end position, DNA strand, and genes respectively. I want to categorize each rows into number of groups as mentioned below. Criteria: When the difference between end position of one row and start position of next rows...

Gnuplot: Conditional splot of a function

conditional,gnuplot
I want to splot the function exp(-(x²+y²)) alone and under the constraint of x+y-1=0. The result should be the surface alone as well as a line with a maximum at x=y=0.5. Or in other words, it's the intersection of the function with a (110)-plane. What I came up so far...

Create a Triangular Matrix from a Vector performing sequential operations

r,for-loop,matrix,vector,conditional
I have been trying to solve the following problem. Suppose I have the following vector: aux1<-c(0,0,0,4,5,0,7,0,0,10,11,12) where the numbers represent the number of the row. I want to calculate the distance between the differents elements of this vector fixing the first component, then the second and so on. If the...

Settings global conditional variables in Go

variables,go,conditional
I want to parse and set a variable conditionally in Go at the global package level based on the value of of an ENV var, so that I don't have to check for it every time in a utility function (as the variable would be declared once at run time)....

ActiveRecord conditional order clause

activerecord,order,conditional
I need to sort a list of tasks: |----------------------------------------------------------------------| | title | priority | due_at | | ---------------------------------|-------------|---------------------| | Mow the lawn | 1 | 2011-09-11 22:00:00 | | Call mom | 3 | 2010-01-26 09:29:03 | | Bake a cake | 2 | 2013-09-13 08:45:37 | | Feed the...

Conditional statement produces unwanted action in Android App

java,android,if-statement,conditional
I have the following code for the user to pick a winner between four options. The variables p1, p2, p3 and p4 are determined by a compare method prior to being used here (the value is always between -3 and 3, 3 being a winner). The problem I'm having is...

change the state of a textbox depending on which view is called

textbox,asp.net-mvc-5,conditional,enable-if
I'm new to MVC, and would like to know in C# mvc5, what kind of code I would need to use, if I wanted to change the state of a textbox from enabled to disabled and vice versa based on which view is calling the partial view.

Conditional Order of Operations in C#

c#,python,order,conditional
So I was recently going through the tutorial for Python on CodeAcademy and I came across this part. Where it instructs that Python has a set order in which it evaluates conditionals. I had never heard of anything like this before. I'm used to coding in C# and was wondering...

Conditional merging of row in R

r,merge,conditional
I want to create individual transcripts in .txt files for each file of my data set which contains two colones LABEL (the word) and FILE (the file the word was said in). So my DF (sample) looks like this : file label bla_1 _ bla_1 so bla_1 we bla_1 know...

C Program - Basic Calculator

c,while-loop,char,conditional
I'm trying to write a basic calculator program in C, and I'm almost there! I have one issue though, and it's concerning repeatedly querying the user for input. I can get through my loop once, but even though the user inputs the correct character, my program still breaks out of...

Show text for post with specific date and specific category in Wordpress

php,wordpress,date,conditional
So I'm trying to show text at the end of each post but from this month only and only in one category. I tried different codes that I found here but none of them really worked or what I needed. Here is example of what I like to do. Hope...

Rails 4 validation conditional on value of a hidden field

ruby-on-rails,validation,conditional,hidden-field
How can I perform a validation only if the value of a hidden_field matches a specified value? For example, I have two forms each with a separate submit button and a separate hidden_field, the value of which determines whether to run one set of validations or another. The problem seems...

ASP.NET MVC: Is there a syntax to acces a project conditional compile symobl in web.config

syntax,compilation,web-config,asp.net-mvc-5,conditional
ASP.NET MVC: Is there a syntax to acces a project conditional compile symobl in web.config e.g. I could use different databases on a per region basis, or determine whether to require HTTPS, etc. Thanks. A similar question in 2012 did not appear to be optimistic about this: ASP.NET - Conditional...

Conditional group by join in R

r,join,conditional
I am new to R and rather flumoxed by the following problem. I have two vectors of dates (the vectors are not necessarily aligned, nor of the same length). I want to find for each date in the first vector the next date in the second vector. vecA <- as.Date(c('1951-07-01',...

Macro for run-once conditioning

c,if-statement,macros,conditional
I am trying to build a macro that runs a code only once. Very useful for example if you loop a code and want something inside to happen only once. The easy to use method: static int checksum; for( ; ; ) { if(checksum == 0) { checksum == 1;...

highlight “partial” duplicates across entire sheet in Google Sheets using conditional formatting

formatting,duplicates,conditional,highlight,partial
Im trying to highlight partial duplicates in google sheets using conditional formatting. I need to highlight duplicates across multiple columns and rows in any matching cells. so far I'm using this... =countif(INDIRECT({"C2:Z18"}),C2)>1 Which works to a degree, but it only highlights exact matches. I need to find a way to...

Selecting rows which have a similar value for a particular column which occurs n times each month

mysql,date,select,conditional
I have a database with multiple columns from which I have created this view where I have multiple rows similar to the ones shown below. The data is available for each day of the month from 2009 to 2010 and for all the month for the 5 names given. I...

How to check nextInt from Scanner without consuming the int itself

java,conditional,java.util.scanner
What I am attempting to do is verify user input of an integer between 0-136, while also making sure that the input IS in fact an integer. I can't figure out a good way to do so, as using nextInt in the conditional consumes the int, and you can't compare...

Boo Language Calculation on Web Drop Down List

if-statement,conditional,boo
The software we use LanDesk Service Desk uses Boo Language calculations to allow for dynamic windows. I have a drop down list on a form that has one of two options. "Acute" and "Ambulatory". Based on which is chosen, one of two possible fields will no longer be hidden and...

how to limit users to only one comment and rating per Item?

javascript,angularjs,conditional
This is what I have in the back-end controller: 'use strict'; var Comment = require('../../../models/comment'); module.exports = { description: 'Create a Comment', notes: 'Create a comment', tags:['comment'], handler: function(request, reply){ console.log('COMMM PAY', request.payload); Comment.create({ itemId: request.payload.itemId, text: request.payload.commentText, rating: request.payload.rating, userId: request.auth.credentials._id }, function(err, comment){ reply(comment); }); } }; This...