Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

conditional-statements

Makefile : contains string

February 4, 2023 by Tarik

The findstring function is what your heart desires: $(findstring find,in) Searches in for an occurrence of find. If it occurs, the value is find; otherwise, the value is empty. You can use this function in a conditional to test for the presence of a specific substring in a given string. Thus, the two examples, $(findstring … Read more

Categories string Tags conditional-statements, makefile, string Leave a comment

Conditional Count on a field

February 2, 2023 by Tarik

I think you may be after select jobID, JobName, sum(case when Priority = 1 then 1 else 0 end) as priority1, sum(case when Priority = 2 then 1 else 0 end) as priority2, sum(case when Priority = 3 then 1 else 0 end) as priority3, sum(case when Priority = 4 then 1 else 0 end) … Read more

Categories sql Tags conditional-statements, count, sql Leave a comment

Why would you use an assignment in a condition?

January 20, 2023 by Tarik

It’s more useful for loops than if statements. while(var = GetNext()) { …do something with ‘var’ } Which would otherwise have to be written var = GetNext(); while(var) { …do something var = GetNext(); }

Categories conditional-statements Tags conditional-statements, language-agnostic, variable-assignment Leave a comment

Check if year is leap year in javascript [duplicate]

January 17, 2023 by Tarik

function leapYear(year) { return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0); }

Categories javascript Tags conditional-statements, date, date-arithmetic, javascript Leave a comment

Run an Ansible task only when the variable contains a specific string

January 15, 2023 by Tarik

If variable1 is a string, and you are searching for a substring in it, this should work: when: ‘”value” in variable1’ if variable1 is an array or dict instead, in will search for the exact string as one of its items.

Categories linux Tags ansible, ansible-2.x, conditional-statements, linux Leave a comment

Angular 2 Pipe under condition

January 13, 2023 by Tarik

You need to change the syntax a bit: {{variable.value ? (variable.text | SomePipe) : (variable.text | pipe2)}} Plunker example

Categories angular Tags angular, angular-pipe, angular2-pipe, conditional-statements Leave a comment

How to check whether a str(variable) is empty or not?

January 6, 2023 by Tarik

You could just compare your string to the empty string: if variable != “”: etc. But you can abbreviate that as follows: if variable: etc. Explanation: An if actually works by computing a value for the logical expression you give it: True or False. If you simply use a variable name (or a literal string … Read more

Categories python Tags conditional-statements, python, string Leave a comment

Determining if a number is either a multiple of ten or within a particular set of ranges

January 3, 2023 by Tarik

For the first one, to check if a number is a multiple of use: if (num % 10 == 0) // It’s divisible by 10 For the second one: if(((num – 1) / 10) % 2 == 1 && num <= 100) But that’s rather dense, and you might be better off just listing the … Read more

Categories c++ Tags c++, comparison, conditional-statements, integer-arithmetic Leave a comment

querying WHERE condition to character length?

January 2, 2023 by Tarik

Sorry, I wasn’t sure which SQL platform you’re talking about: In MySQL: $query = (“SELECT * FROM $db WHERE conditions AND LENGTH(col_name) = 3”); in MSSQL $query = (“SELECT * FROM $db WHERE conditions AND LEN(col_name) = 3”); The LENGTH() (MySQL) or LEN() (MSSQL) function will return the length of a string in a column … Read more

Categories sql Tags conditional-statements, sql, where Leave a comment

MySQL IN condition limit

December 27, 2022 by Tarik

No there isn’t, check the manual about the IN function: The number of values in the IN list is only limited by the max_allowed_packet value.

Categories mysql Tags conditional-statements, mysql Leave a comment
Older posts
Newer posts
← Previous Page1 … Page11 Page12 Page13 Page14 Next →

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa