Snippets Collections
/** select-text.js
 * Set selected text to the element passed to the function.
 */
function selectText(el) {
	let sel, range;
	// Browser compatibility
	// older ie
	if (window.getSelection && document.createRange) {
		sel = window.getSelection();
		// creates range object
		// set range to elements range
		// remove window range
		// set window range
		window.setTimeout(function() {
			range = document.createRange();
			range.selectNodeContents(el);
			sel.removeAllRanges();
			sel.addRange(range);
		}, 1);
	} else if (document.selection) {
		sel = document.selection.createRange();
		// creates range object
		// set raselectnge
		// call  event listener
		if (sel.text == '') {
			range = document.body.createTextRange();
			range.moveToElementText(el);
			range.select();
		}
	} else {
		// do nothing
	}
	return;
}
extension ServiceProviderProfileViewController : UICollectionViewDelegate, UICollectionViewDataSource {
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return categories.count
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let cell = categoryCollectionView.dequeueReusableCell(withReuseIdentifier: "CategoryCollectionViewCell", for: indexPath) as! CategoryCollectionViewCell

            cell.categoryLabel.text = categories[indexPath.row]
        
            if indexPath.row == selectedCellIndex {
                cell.categoryView.layer.borderColor = UIColor.blue.cgColor
                cell.categoryLabel.textColor = UIColor.blue
            } else {
                cell.categoryView.layer.borderColor = UIColor.lightGray.cgColor
                cell.categoryLabel.textColor = UIColor.gray
            }
            return cell
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        selectedCellIndex = indexPath.row
        self.categoryCollectionView.reloadData()
    }
    
}
     let currentSelectedCell = playersTableView.cellForRow(at: indexPath) as! PlayerDetailsTableViewCell
        
        if selectedRow == -1 {
            currentSelectedCell.playerDetailsView.layer.borderColor = hexStringToUIColor(hex: "F34141").cgColor
            currentSelectedCell.playerDetailsView.layer.borderWidth = 1
            selectedRow = indexPath.row
        } else if indexPath.row == selectedRow {
            currentSelectedCell.playerDetailsView.layer.borderWidth = 0
            selectedRow = -1
        } else {
            currentSelectedCell.playerDetailsView.layer.borderColor = hexStringToUIColor(hex: "F34141").cgColor
            currentSelectedCell.playerDetailsView.layer.borderWidth = 1
            
            let newIndexPath = IndexPath(item: selectedRow, section: 0)
            if let cell = playersTableView.cellForRow(at: newIndexPath) as? PlayerDetailsTableViewCell {
                cell.playerDetailsView.layer.borderWidth = 0
            }
            selectedRow = indexPath.row
        }
var arrData = [String]() // This is your data array
var arrSelectedIndex = [IndexPath]() // This is selected cell Index array
var selectedSkills = [String]() // This is selected cell data array

extension ViewController: UICollectionViewDelegate, UICollectionViewDataSource
{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return arrData.count
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell : CollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCell", for: indexPath) as! CollectionViewCell
          if selectedSkills.contains(arrData[indexPath.row]) {
            cell.skillsView.backgroundColor = cell.skillsView.hexStringToUIColor(hex: "FEDA22")
        }
      return cell
    }
  
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        print("You selected cell #\(indexPath.item)!")
        
            if let cell = collectionView.cellForItem(at: indexPath) as? SkillsCollectionViewCell {

                let selectedCategory = subCategoriesPopUpArray[indexPath.item]

                if selectedSubCategories.contains(selectedCategory) {
                    cell.skillsView.backgroundColor = cell.skillsView.hexStringToUIColor(hex: "F0F0F0")
                    selectedSubCategories = selectedSubCategories.filter {
                        $0 != selectedCategory
                    }
                } else {
                    selectedSubCategories.append(selectedCategory)
                    cell.skillsView.backgroundColor = cell.skillsView.hexStringToUIColor(hex: "FEDA22")
                }
        }
    }
}
# here we use WHERE column_name but we don't know what is the data 
# To fetch result of given string to match in column_data we use LIKE
#syntax SELECT * FROM <table-name> WHERE <column_name> LIKE '%<data-to-fetch>%' with out
#space both sides

SELECT * FROM employees WHERE department LIKE '%Clo%';
# NOTE : %Clo% is departement feches related data which start with that string

#ref below
course_data=# SELECT * FROM employees WHERE department LIKE '%Clo%' LIMIT 10;
 employee_id | first_name | last_name  |             email             | hire_date  |    department     | gender | salary | region_id
-------------+------------+------------+-------------------------------+------------+-------------------+--------+--------+-----------
           3 | Sydney     | Symonds    | ssymonds2@hhs.gov             | 2010-05-17 | Clothing          | F      |  95313 |         4
           7 | Ardeen     | Curwood    | acurwood6@1und1.de            | 2006-02-19 | Clothing          | F      |  28995 |         7
          10 | Redford    | Roberti    |                               | 2008-07-21 | Clothing          | M      |  72225 |         7
          21 | Bernardo   | Davage     |                               | 2013-07-11 | Clothing          | M      | 124949 |         6
          38 | Edna       | Erwin      |                               | 2003-04-09 | Children Clothing | F      |  91397 |         5
          48 | Birgitta   | Stanbrooke | bstanbrooke1b@netvibes.com    | 2016-09-12 | Clothing          | F      |  77259 |         1
          54 | Verney     | McQuirk    | vmcquirk1h@ning.com           | 2012-06-17 | Clothing          | M      |  97156 |         2
          55 | Norina     | Yea        | nyea1i@cnet.com               | 2005-06-14 | Children Clothing | F      |  45959 |         1
          56 | Wilek      | Cossor     | wcossor1j@merriam-webster.com | 2014-09-17 | Children Clothing | M      |  91859 |         4
          62 | Lek        | Camplin    |                               | 2007-07-16 | Children Clothing | M      | 124190 |         6
# so the scenario is we have table called employees
# in employees table there is column called department 
# there are different departments are included in table
# now we want some department which we dont know how its spelled there so we are just
# trying to fetch the data in column which matched or containes 
# ex: word 'Clothing' is in stored in table but we dont know exactly how data spelled there
# so we try to match something like '% clo %'
# or 'C% thing %'

SELECT * FROM emploees  WHERE department like '% thing %';
# or 
SELECT * FROM employees WHERE department like 'C% thing %';
star

Sun Dec 03 2023 08:17:33 GMT+0000 (Coordinated Universal Time) https://codepen.io/dixie0704/pen/jOVxGXL

#alpinejs #select #tailwind
star

Thu Jul 20 2023 03:14:07 GMT+0000 (Coordinated Universal Time)

#select #text #selection
star

Wed Mar 01 2023 08:01:14 GMT+0000 (Coordinated Universal Time)

#ios #swift #cell #select #selection #single
star

Sat Jul 23 2022 19:56:49 GMT+0000 (Coordinated Universal Time) https://sharepains.com/2019/04/01/update-a-multi-select-choice-power-automate/

#powerautomate #multiselect #sharepoint #array #select
star

Wed Feb 23 2022 10:49:25 GMT+0000 (Coordinated Universal Time)

#psql #like #select #where

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension