ios – What is the best way to indicate that the text of a text entry field is editable?

Imagine an application like a yelp. In this case, you select the number of stars you want to evaluate. When you do, a pre-generated text is displayed in the text entry field. You can either keep this text because it is a useful pre-generated replay, or delete this text and write your own.

I'm trying to decide what is the best way to indicate that this text is something that you do not have to use, that it's an option, not imposed on you. That it is editable.

I can:
– have an icon that says that it is editable (pencil?) (not very clear)
– have a text that says for example "touch to edit" (a bit rough, having a clue to the screen)
– that the text is "selected" when it appears on the screen. (cleanest way, but is it clear enough?)

Something obvious I miss? What do you think best?

photoshop – how can I make the text visible in this photo

It will not happen, I'm afraid. Samsung 500T is all you are going to extract from this image.

Aside from the fact that it was shot in a very dim light with a flash, which flooded a lot, it was also resized and perhaps refined by a much smaller image.
This will not give any information. You can not create information that is not really there.

That's what's there, you can not recreate what's not there.

enter the description of the image here

The could to be better information in the original of this photo, but there is none in this particular copy.

The only solution I can see is to take the picture again under good lighting and preserve the resolution of the image.

See also – Improving CSI Image Resolution: How Real Is It?

mojave – text highlighting bug in Chrome 76

I'm using Google Chrome 76+ on macOS Mojave 10.14.6.

I have encountered a problem where highlighting text in the browser fails randomly. I have met him enough times to try to reproduce it (underlining the text). You can see the problem here:

When the cursor remains an i-cursor, the touchpad is still held down, but the text is not highlighted. It seems that Chrome might not respond for a split second and not see the event?

I asked a few people to try to reproduce that and they were not able to do it. I'm starting to think that it's a problem MacBook Pro 15 "(maybe some kind of interaction between MacOS Mojave / Google Chrome 76+ graphics drivers?)

This does not seem to happen in Safari or Firefox.

How to quickly change the text color of a cell in Google Sheets?

How can I quickly, in one or two clicks, assign a color to the text of a cell in Google Sheets?

In order to quickly determine the status of certain data in a worksheet that I manage, I assign a text color to the value of a cell. I do this dozens of times several times a month, and it's very tedious because it depends on an external manual process (for example, looking at the value of a cell, going to do a process manual, return and manually update the color of the text cell).

I have examined the execution of a script or a macro when I double-click on each cell (not currently available), adding a drop-down menu to the cell as well as the value existing cell (impossible, as far as I know), add a check box to the cell with the existing cell value (this does not seem possible), and use text formatting from the context menu ( not available).

SUM column except for cells where there is text in a cell in a separate column but in the same row? Google Sheets

I need a formula but I do not know how to do it and I do not know if it's even possible.

Here is a photo to show what I want. I hope you understand.
visual explanation

forms – Populates a dynamic drop-down list from text in a description using cf7

I already know how to dynamically include the title of a page on a cf7 form, but I need to be able to populate a drop-down menu dynamically with content from text from the same page. Is it possible? and how?

The form consists of capturing a course application. That's why I have the post_title to know which course they are learning, but the courses have several different start dates and I would like them to fill automatically depending on the course page.

swift – Text Combination of Selected Text Fields in 1 TextView – Conditionally

ViewController2 (source) Has multiple TextFields, each with its own switches.

ViewController1 (destination) has a TextView waiting to send data from ViewController2 (source). But I only need text from TextFields whose "switches" are enabled.

I can operate it individually with TextField1 when Switch1 is enabled, but I do not know how to combine the text of several others once enabled.

Example: If the switches for TextField1 and TextField2 are enabled, the text form must be placed in the same TextView on ViewController1.

Question How to combine the text of several texts once switched on? At the same time, there could only be one switch on, or sometimes many switches turned on.

My code that I'm using up to now

ViewController2 (Source)

 let defaults = UserDefaults.standard
    var switchON : Bool = false
    @IBAction func checkState(_ sender: AnyObject) {

        if Switch1.isOn{
            switchON = true
            defaults.set(switchON, forKey: "switch1ON")
        }
        if Switch1.isOn == false{
            switchON = false
            defaults.set(switchON, forKey: "switch1ON")
        }
        if Switch2.isOn{
            switchON = true
            defaults.set(switchON, forKey: "switch2ON")
        }
        if Switch2.isOn == false{
            switchON = false
            defaults.set(switchON, forKey: "switch2ON")

ViewController1 (Destination)

override func viewDidLoad(){
        super.viewDidLoad()
        // Do any additional setup after loading the view.

  // Select Comments -----------------------------------
        if defaults.value(forKey: "switch1ON") != nil{
            let switch1ON: Bool = defaults.value(forKey: "switch1ON")  as! Bool
            if switch1ON == true{
                let userDefaults = UserDefaults.standard
                Reference.text = userDefaults.value(forKey: "PredefinedText1") as? String
            }

        if defaults.value(forKey: "switch2ON") != nil{
            let switch2ON: Bool = defaults.value(forKey: "switch2ON")  as! Bool
            if switch2ON == true{
                let userDefaults = UserDefaults.standard
                Reference.text = userDefaults.value(forKey: "PredefinedText2") as? String
            }
           // else if switch1ON == false{
            //    let userDefaults = UserDefaults.standard
            //    Reference.text = userDefaults.value(forKey: "") as? String
            //}
        }
        }

abstract algebra – Let $ phi: mathbb {Z} _7 times mathbb {Z} _7 $ be a homomorphism such that $ phi ^ 5 = text {id} $. Show that $ phi $ is the identity.

Let $ phi: mathbb {Z} _7 times mathbb {Z} _7 to mathbb {Z} _7 times mathbb {Z} _7 $ to be a homomorphism such as $ phi ^ 5 = text {id} $. CA watch $ phi $ is the identity.

My attempt: Since $ ker ( phi) subset ker ( phi ^ 2) subset cdots subset ker ( phi ^ 5) = 0 $it follows that $ phi $ is injective. Since $ | mathbb {Z} times mathbb {Z} | $ is finished, $ phi $ is automatically an isomorphism.

then $ phi $ should map a subgroup to a subgroup. Consider $ phi ( mathbb {Z} _7 times 0) $, so he should be associated with $ mathbb {Z} _7 times 0 $ or $ 0 times mathbb {Z} _7 $. Without loss of generality, we consider the first case. In particular, $ phi ($ 1.0) should be a generator for $ mathbb {Z} _7 times 0 $. assume $ phi (1,0) = (a, 0) $. then $ (1,0) = phi ^ 5 (1,0) = phi ^ 4 (a, 0) = phi ^ 3 (a ^ 2,0) = cdots = (a ^ 5,0) $. So, $ a ^ 5 = 7k + 1 $ for some people $ k in mathbb {Z} $. By testing $ a in mathbb {Z} _7 $, we see that the only possibility is that $ a = $ 1. The discussion for $ phi (0,1) $ Is similar.

Could someone help me take a look at my attempt? Is my approach reasonable and is there a better way to solve this problem?

seo – Which one is more likely to rank in google image post vs text post?

Which publication will be ranked in search engines such as (Google, Yahoo, Bing) if I create two publications, one with the entire page image with alt and title tags and the other with the full text.

I know that text will be better ranked than image-based messages, but I want to rank image-based messages rather than text.

python – A queue of persistent file system operations using sqlite and JSON text fields

I want to implement a persistent queue for file system operations (copy, delete, move) that must be secure for processes and threads. The module will be used by a daemon (called qcpwho can accept Tasks of several customers. It must also be possible to process multiple items in parallel queue.

I'm a python novice and I'm looking for general advice (even punk) on python best practices and object-oriented programming in general. I am particularly happy if my implementation of Task.from_json() as @staticmethod is appropriate. I was not sure because it conditionally instantiates subclasses of Task rather than a plain Task.

t√Ęches.py

from pathlib import Path
from typing import Union, Optional
import shutil
import os
import json
import sqlite3    
import logging

Pathish = Union(Path, str)


class Task:
    """Abstract class for qcp Tasks. Should not be instantiated directly."""

    def __init__(self) -> None:
        self.type = 0

    def run(self) -> None:
        """Run the Task"""
        pass

    @staticmethod
    def from_dict(x, validate: bool = False) -> "Task":
        """Create a Task of the appropriate subclass from a python dict"""
        task_type = x("type")

        if task_type == -1:
            return KillTask()
        elif task_type == 0:
            return Task()
        elif task_type == 1:
            return EchoTask(x("msg"))
        elif task_type == 2:
            return FileTask(x("src"), validate=validate)
        elif task_type == 3:
            return DeleteTask(x("src"), validate=validate)
        elif task_type == 4:
            return CopyTask(x("src"), x("dst"), validate=validate)
        elif task_type == 5:
            return MoveTask(x("src"), x("dst"), validate=validate)
        elif task_type == 6:
            raise NotImplementedError
        else:
            raise ValueError

    def __repr__(self) -> str:
        return 'NULL'

    def __eq__(self, other) -> bool:
        return self.__dict__ == other.__dict__

    def __ne__(self, other) -> bool:
        return self.__dict__ != other.__dict__


class KillTask(Task):
    """Kill the qcp server"""
    def __init__(self) -> None:
        self.type = -1
        super().__init__()

    def run(self) -> None:
        raise NotImplementedError

    def __repr__(self) -> str:
        return 'KILL'


class EchoTask(Task):
    """Log a message"""
    def __init__(self,  msg: str) -> None:
        super().__init__()
        self.msg = msg
        self.type = 1

    def run(self) -> None:
        print(self.msg)

    def __repr__(self) -> str:
        return f'Echo: "{self.msg}"'


class FileTask(Task):
    """Abstract class for all file-based tasks"""
    def __init__(self, src: Pathish, validate: bool = True) -> None:
        super().__init__()
        self.validate = validate
        self.src = Path(src).as_posix()
        self.type = 2
        if validate:
            self.__validate__()

    def __validate__(self) -> None:
        if not Path(self.src).exists():
            raise FileNotFoundError(f'{self.src} does not exist')
        elif not (Path(self.src).is_dir() or Path(self.src).is_file()):
            raise TypeError(f'{self.src} is neither a file nor directory')


class DeleteTask(FileTask):
    """Delete a file"""
    def __init__(self, src: Pathish, validate: bool = True) -> None:
        super().__init__(src=src, validate=validate)
        self.type = 3

    def run(self) -> None:
        os.unlink(self.src)

    def __repr__(self) -> str:
        return f'DEL {self.src}'


class CopyTask(FileTask):
    """Copy a file"""
    def __init__(self, src: Pathish, dst: Pathish, validate: bool = True) -> None:
        super().__init__(src=src, validate=False)
        self.dst = Path(dst).as_posix()
        self.type = 4
        self.validate = validate
        if validate:
            self.__validate__()

    def __repr__(self) -> str:
        return f'COPY {self.src} -> {self.dst}'

    def __validate__(self) -> None:
        super().__validate__()
        if Path(self.dst).exists():
            raise FileExistsError

    def run(self) -> None:
        self.__validate__()
        shutil.copy(self.src, self.dst)


class MoveTask(CopyTask):
    """Move a file"""
    def __init__(self, src: Pathish, dst: Pathish, validate: bool = True) -> None:
        super().__init__(src=src, dst=dst, validate=validate)
        self.type = 5

    def run(self) -> None:
        super().__validate__()
        shutil.move(self.src, self.dst)

    def __repr__(self) -> str:
        return f'MOVE {self.src} -> {self.dst}'


class TaskQueueElement:
    """An enqueued Task"""

    task = None  #: A Task
    status = None  #: Status of the queued Task
    priority = None  #: Priority of the queued Task

    def __init__(self, task: Task, priority: 1) -> None:
        self.task = task
        self.priority = priority

    def __lt__(self, other) -> bool:
        return self.priority < other.priority

    def __gt__(self, other) -> bool:
        return self.priority > other.priority

    def __eq__(self, other) -> bool:
        return self.__dict__ == other.__dict__

    def __ne__(self, other) -> bool:
        return self.__dict__ != other.__dict__


class TaskQueue:
    """A prioritzed queue for tasks"""
    def __init__(self, path: Pathish = 'qcp.db') -> None:
        """
        Instantiate a TaskQueue

        :param path: Path to store the persistent queue
        :type path: Path or str
        """

        self.con = sqlite3.connect(path, isolation_level="EXCLUSIVE")
        self.path = Path(path)

        cur = self.con.cursor()
        cur.execute("""
           CREATE TABLE IF NOT EXISTS tasks (
              priority INTEGER,
              task TEXT,
              status INTEGER,
              owner INTEGER              
            )              
        """)
        self.con.commit()

    @property
    def n_total(self) -> int:
        """Count of all tasks in queue (including failed and completed)"""
        cur = self.con.cursor()
        return cur.execute("SELECT COUNT(1) from tasks").fetchall()(0)(0)

    @property
    def n_pending(self) -> int:
        """Number of pending tasks"""
        cur = self.con.cursor()
        return cur.execute("SELECT COUNT(1) FROM tasks WHERE status = 0").fetchall()(0)(0)

    @property
    def n_running(self) -> int:
        """Count of currently running tasks"""
        cur = self.con.cursor()
        return cur.execute("SELECT COUNT(1) FROM tasks WHERE status = 1").fetchall()(0)(0)

    @property
    def n_done(self) -> int:
        """count of completed tasks"""
        cur = self.con.cursor()
        return cur.execute("SELECT COUNT(1) from tasks WHERE status = 2").fetchall()(0)(0)

    @property
    def n_failed(self) -> int:
        """count of completed tasks"""
        cur = self.con.cursor()
        return cur.execute("SELECT COUNT(1) from tasks WHERE status = -1").fetchall()(0)(0)

    def put(self, task: "Task", priority: Optional(int) = None) -> None:
        """
        Enqueue a task

        :param task: Task to be added to the queue
        :type task: Task
        :param priority: (optional) priority for executing `task` (tasks with lower priority will be executed earlier)
        :type priority: int
        """

        cur = self.con.cursor()
        cur.execute(
            "INSERT INTO tasks (priority, task, status) VALUES (?, ?, ?)", (priority, json.dumps(task.__dict__), 0)
        )
        self.con.commit()

    def pop(self) -> "Task":
        """
        Retrieves Task object and sets status of Task in database to "in progress" (1)

        :raises AlreadyUnderEvaluationError: If trying to pop a tasks that is already being processed  (i.e. if a race
        condition occurs if the queue is processed in parallel)
        """
        cur = self.con.cursor()
        cur.execute("SELECT _ROWID_ from tasks WHERE status = 0 ORDER BY priority LIMIT 1")
        oid = cur.fetchall()(0)(0).__str__()
        self.mark_running(oid, id(self))

        cur.execute("SELECT owner, task FROM tasks WHERE _ROWID_ = ?", oid)
        record = cur.fetchall()(0)
        if record(0) != id(self):
            raise AlreadyUnderEvaluationError

        task = Task.from_dict(json.loads(record(1)))
        task.oid = oid
        return task

    def peek(self) -> "Task":
        """
        Retrieves Task object without changing its status in the queue
        """
        cur = self.con.cursor()
        cur.execute("SELECT * from tasks ORDER BY priority LIMIT 1")
        record = cur.fetchall()(0)
        oid = record(0).__str__()
        task = Task.from_dict(json.loads(record(1)), validate=False)
        task.oid = oid
        return task

    def print(self, n: int = 10) -> None:
        """
        Print an overview of the queue

        :param n: number of tasks to preview
        :type n: int
        """
        assert isinstance(n, int) and n > 0
        cur = self.con.cursor()
        cur.execute("SELECT status, task from tasks ORDER BY priority LIMIT ?", (str(n), ))
        records = cur.fetchall()
        for record in records:
            print(f"({record(0)}) {Task.from_dict(json.loads(record(1)))}")

    def mark_pending(self, oid: int) -> None:
        """
        Mark the operation with the _ROWID_ `oid` as "pending" (0)

        :param oid: ID of the task to mark
        :type oid: int
        """
        cur = self.con.cursor()
        cur.execute("UPDATE tasks SET status = 0, owner = NULL where _ROWID_ = ?", (oid, ))
        self.con.commit()

    def mark_running(self, oid: int, owner: int) -> None:
        """Mark the operation with the _ROWID_ `oid` as "running" (1). The "owner" Id is to ensure no two processes
        are trying to execute the same operation

        :param oid: ID of the task to mark
        :type oid: int
        :param owner: Id of the process that is handling the operation
        :type owner: int
        """
        cur = self.con.cursor()
        cur.execute("UPDATE tasks SET status = 1, owner = ? where _ROWID_ = ?", (owner, oid))
        self.con.commit()

    def mark_done(self, oid: int) -> None:
        """
        Mark the operation with the _ROWID_ `oid` as "done" (2)
        :param oid: ID of the task to mark
        :type oid: int
        """
        cur = self.con.cursor()
        cur.execute("UPDATE tasks SET status = 2, owner = NULL where _ROWID_ = ?", (oid, ))
        self.con.commit()

    def mark_failed(self, oid: int) -> None:
        """
        Mark the operation with the _ROWID_ `oid` as "failed" (-1)

        :param oid: ID of the task to mark
        :type oid: int
        """
        cur = self.con.cursor()
        cur.execute("UPDATE tasks SET status = -1, owner = NULL where _ROWID_ = ?", (oid, ))
        self.con.commit()

    def run(self) -> None:
        """Execute all pending tasks"""
        if self.n_pending < 1:
            logging.getLogger().warn("Queue is empty")

        while self.n_pending > 0:
            op = self.pop()
            op.run()
            self.mark_done(op.oid)


class AlreadyUnderEvaluationError(Exception):
    """This Task is already being processed by a different worker"""
    pass

A quick demo in pytest:

import tasks
import pytest

def test_TaskQueue(tmp_path):
    """TaskQueue can queue and execute tasks"""
    src = tmp_path.joinpath("foo")
    src.touch()

    q = tasks.TaskQueue(tmp_path.joinpath("qcp.db"))
    q.put(tasks.CopyTask(src, tmp_path.joinpath("copied_file")))
    q.run()
    assert tmp_path.joinpath("copied_file").is_file()
    q.put(tasks.MoveTask(tmp_path.joinpath("copied_file"), tmp_path.joinpath("moved_file")))
    q.run()
    assert not tmp_path.joinpath("copied_file").is_file()
    assert tmp_path.joinpath("moved_file").is_file()
    q.put(tasks.DeleteTask(tmp_path.joinpath("moved_file")))
    q.run()
    assert not tmp_path.joinpath("moved_file").is_file()
    assert src.is_file()

p .: I am aware that I do not care logging for a single log call, but I plan to include more logging in the future