Holding and dragging mouse to select multiple buttons/cells

Is it possible to create a TogglerBar-type object in which several buttons can be selected/deselected simply by holding the mouse’s left-click button and dragging it over the buttons? Similarly to the multiple selecting option when holding control and the mouse on Windows, but without the drawing box.

It seems that, by default, TogglerBar only selects a button when the left-click button is released, but I’m unaware of any way of doing what I want. Any ideas?

Just to give some context. I’m working with cell dynamics, and I intend to make it easier to select a large group of cells in an epithelium. This is, in some sense, a follow up to a question I made before regarding a “toggleable” Voronoi Mesh.

What is the most efficient way to select element specific to the H1

Let's say I'm stupid, but I really want to know the most efficient way to select this specific element:

<a href="/" title=""><h1>MySite</h1></a>
Code (markup):

Here's what I've got from the internet and it's still not specific to the H1 tag:

 a[title] {     color: red; } a[title]:hover {     color: orange;     text-decoration: none; } 
Code (markup):

I want this element as a unique one and style it differently.

Thank for your help,

Use SELECT query to retrieve UPDATE information

I am confused about inability of using UPDATE query inside SELECT queries. I got this idea, it would be amazing to use queries like follows for elegant reporting purposes

My non-working code:

SELECT (     UPDATE animals SET status=1 WHERE status=5 ) as 'total_changed_animals', (     UPDATE sports SET status=1 WHERE status=4 ) as 'total_changed_sports'; 

Problem:

In MySQL’s query docs there is written following:

UPDATE returns the number of rows that were actually changed.

That being said, in example above I would expect UPDATE subquery to return number of changed records into SELECT query. However this does not work, and query example mentioned avove will fail.

Can anyone explain why it is not allowed? I believe there may be a reason for this. Is there any workaround?

INSERT INTO… SELECT over a LinkedServer in smaller batches

I’ve written the following code to move data from one database table, to another (over a LinkedServer);

SET NOCOUNT ON  DECLARE @ApplicationURL varchar(50),     @LinkedServer nvarchar(50),     @DatabaseName varchar(50)   SET @ApplicationURL = 'Test' SET @LinkedServer = 'ABC123' SET @DatabaseName = 'Test'    /*--------------------------------------------------------------------     Table:  Notifications --------------------------------------------------------------------*/ EXECUTE ( 'INSERT INTO dbo.Notifications (     [Subject],      [Body],      [PriorityId],      [StartDate],      [EndDate],      [IsActive],      [UserId],     [SourceNotificationId] ) SELECT      [Subject],      [Body],      [PriorityId],      [StartDate],      [EndDate],      n.[IsActive],      [DS.DataMigration].[Migration].[ufnGetNewUserId](n.[UserId]),     [NotificationId]  FROM ['+ @LinkedServer +'].['+@DatabaseName+'].[dbo].[Notifications] n     JOIN ['+ @LinkedServer +'].['+@DatabaseName+'].[dbo].[Users] u ON n.UserId = u.UserId      JOIN ['+ @LinkedServer +'].['+@DatabaseName+'].[dbo].[Applications] a ON u.ApplicationId = a.ApplicationId WHERE A.ApplicationURL = ''' + @ApplicationURL + ''';') 

This works as expected, however some tables are likely to have over a million rows, and I do not want to try and move them all at the same time, in one transaction. In my intestigation, I found this post; Breaking a big insert query into smaller ones

I would like to use this method, but I’ve been unable to find out how to impliment this with Dynamic SQL. Has anybody done something like this before?

Thanks!

Select distinct combinations of rows

I try to select distinct combinations of rows (author_id, recipient_id), preserving following order and limit. Like on Facebook you have a list of recent conversations with given users. For example I’m a user with id=665 and I need a list of 20 recent conversations. My current code:

select * from (   select distinct on (author_id, recipient_id) * from private_message where author_id=665 or recipient_id=665 ) p_m order by id desc limit 20; 

enter image description here

In this case everything is ok besides that I want to keep bigger id (more recent), so message with id=10 needs to be drop, because it’s duplicate of id=18.

So the expected result is:

enter image description here

Select rows within group before condition is met

I want to select rows within each group following a condition in time. I have the following table trajectory_data in PostgreSQL 10 with daily points for each group.

| traj_id | timestamp  | height | lat   | Lon    | |---------|------------|--------|-------|--------| | 1       | 2006-01-01 | 10     | 34.55 | -70.80 | | 1       | 2006-01-02 | 9      | 34.56 | -70.88 | | 1       | 2006-01-03 | 0      | 34.56 | -70.89 | | 1       | 2006-01-04 | 5      | 34.57 | -70.90 | | 1       | 2006-01-05 | 20     | 34.60 | -70.94 | | 2       | 2006-01-01 | 10     | 34.55 | -70.80 | | 2       | 2006-01-02 | 5      | 34.55 | -70.82 | | 2       | 2006-01-03 | 3      | 34.54 | -70.89 | | 2       | 2006-01-04 | 0      | 34.53 | -70.90 | | 2       | 2006-01-05 | 10     | 34.51 | -70.95 | | 3       | 2006-01-01 | 10     | 34.55 | -70.80 | | 3       | 2006-01-01 | 9      | 34.56 | -70.75 | | 3       | 2006-01-01 | 11     | 34.54 | -70.90 | | 3       | 2006-01-01 | 15     | 34.60 | -70.95 | | 3       | 2006-01-01 | 30     | 34.67 | -70.90 | 

I want to filter the data to get the rows within each group which height is greater than zero. But, is not as simple as just removing the zeros with a WHERE statement. I want to keep the all the rows before the group reach zero for the first time:

| traj_id | timestamp  | height | lat   | Lon    | |---------|------------|--------|-------|--------| | 1       | 2006-01-01 | 10     | 34.55 | -70.80 | | 1       | 2006-01-02 | 9      | 34.56 | -70.88 | | 2       | 2006-01-01 | 10     | 34.55 | -70.80 | | 2       | 2006-01-02 | 5      | 34.55 | -70.82 | | 2       | 2006-01-03 | 3      | 34.54 | -70.89 | | 3       | 2006-01-01 | 10     | 34.55 | -70.80 | | 3       | 2006-01-01 | 9      | 34.56 | -70.75 | | 3       | 2006-01-01 | 11     | 34.54 | -70.90 | | 3       | 2006-01-01 | 15     | 34.60 | -70.95 | | 3       | 2006-01-01 | 30     | 34.67 | -70.90 | 

In this example, groups 1 and 2 are filtered and the rows after zero are removed.

I know that I can run something like:

SELECT * FROM trajectory_data GROUP BY traj_id HAVING height > 0 

But, this query will keep rows that I do not necessarily want (i.e. rows where the group already reached zero), and I have no intentions of aggregating the data, just select rows. There is another way of tackling this?

What is the best way to allow users select items from a very long list in a responsive web app?


Scenario

I’m designing a web app where the user adds predefined items from List A to a custom List B.
List A is over 100 items sorted alphabetically.
List B can be customized according to user needs.

I designed a drag-and-drop solution for the web app. The user can jump to List A items alphabetically by clicking a letter.

drag and drop feature

Problem

This drag-and-drop feature doesn’t work on tablets very well and is impossible for smartphones. So I designed a select form for mobile devices: When the user taps on a list item in List B, a picker/flipper populated with List A items is triggered.

mobile view select

Question

Is there a way to implement alphabetical filtering in a web app’s mobile interface?

How can the mobile interface for this feature solve the following requirements?

  1. Allow user filter List A
  2. Add items from List A to List B

How to select rows from two matrices to have one larger?

You are given two matrices $ $ \mathbf{A}=\begin{pmatrix}a_{11} & \ldots & a_{1n}\\vdots & \ddots & \vdots\a_{m1} & \ldots & a_{mn}\\end{pmatrix},$ $ and $ $ \mathbf{B}=\begin{pmatrix}b_{11} & \ldots & b_{1n}\\vdots & \ddots & \vdots\b_{m1} & \ldots & b_{mn}\\end{pmatrix},$ $ of positive numbers.

We want to find, for $ 1\leq j\leq n$ , a subset $ {S}_j\subset\{1,2,\ldots,m\}$ of at most two rows such that $ {S}_i\cap{S}_j=\emptyset$ (for $ i\ne j$ ) and $ \left|\bigcup_{j=1}^n{S}_j\right|$ is as large as possible and for $ i,i’\in{S}_j$ , we have: $ $ a_{ij}\geq b_{i’j}.$ $

I started by reducing the problem to a maximum matching problem. If we create $ m$ nodes. For each column $ 1\leq j\leq n$ , we create an edge between node $ 1\leq i\leq m$ and node $ 1\leq i’\leq m$ ($ i\ne i’$ ) if there is no edge already and if $ a_{ij}\geq b_{i’j}$ . Next, run a matching algorithm on the created graph to find a maximum-cardinality matching $ {M}$ .

Do you have any hints on how to solve the problem? Am I on the right direction?

Using WITH together with CREATE TEMPORARY TABLE AS SELECT … in Postgres?

I would like to create a temporary table using a select statement that uses temporary views specified in a WITH statement (not the WITH statement of CREATE TEMPORARY TABLE).

e.g. something along the lines of

WITH a AS ( SELECT 1 foo, 2 bar  ), b AS ( SELECT 4 bar, 5 baz ) CREATE TEMPORARY TABLE foo AS SELECT * from a JOIN b ON (a.bar=b.bar) 

If I comment out the CREATE TEMPORARY TABLE line, this works. How to create a temporary table using the query result of the SELECT, without rewriting the temporary views into a single query?

Country Select with region filters

I’m tinkering with a design for user to select a single country, or multiple countries that are historically/culturally grouped (eg United Kingdom).

Just looking for feedback, and wondering if anyone has seen something along these lines.

Dropdown 1: Region (whole world, Europe, Nth America, Sth America, SE Asia etc)

Drowdown 2: Country (all, then list of appropriate countries based on dropdown 1)

The user first selects a region (eg Europe) then an Country (eg Germany).

If Country=All, then the search results will return all countries in the selected region (or all countries if region=whole world).

Changing region changes the options in the Country list.

One issue I have is how to deal with regions like United Kingdom. Ignoring Brexit, the UK countries are also in the Europe region. One country being in multiple regions is not a problem. The problem is there are quite a few regions like this (UK, British Isles, Balkans, Caribbean etc). I can absolutely see users wanting to have results returned for “all countries in the UK”.

Should I just have lots of regions? All world, continents (EU, Africa etc), then these special subsets (UK etc)? Or would you go All world, then Continents+SpecialRegions [sorted a-z]?