Is it possible to impose text to a data and safely Export and Import using Mathematica?

Usually, when saving data as dat. file we impose the information of the different parameters used to generate the data in the file name (at least this is what I do:-)). So, I was thinking if we can write the information of the generated data on the dat. file such that we can Import and Export it without problems. For example, assume we have a function $f(x)=a x+ b$ and we would like to obtain the set of data for {$x$, $f(x)$} with different values of $a$ and $b$

f(x_) = a x + b; a = 1; b = 1;
data = Table({x, f(x)}, {x, -3, 3, 0.1}); 

when I use Export("..\data.dat", data) this how it looks like

enter image description here

Now, my question is; can we add a headline to the dat. file contains the values of $a$ and $b$? which will look like this
enter image description here

multiplayer – Would an ‘acknowledged’ button be a good idea for text chats?

Sorry if this is off topic but I think it’s ok maybe?

I’ve been wondering about this for a while, but would a sort of ‘acknowledged’ button be okay for text chats in multiplayer games? IDK how often this happens, but sometimes there are cases where you need to tell someone that ‘yeah I saw the message’ but you don’t think it really warrants a response. If it was one of those situations, then you would select the message and click the ‘acknowledged’ button to let them know you saw it and understand.

Google chats sorta does this, showing the thumbnail of the account under the last message they read so you know they saw it.

I’m just wondering, would this be a good idea, and has it been done before? If it hasn’t been done before, is there a reason why not?

conditional formatting – How can I select all cells that contain specific text in Google Sheets?

enter image description here

This is a solution involving a workaround with a simple script.

First you want to copy the below formula next to every row in your sheet.
This will fetch all cell addresses containing “foobar” on this row.

=REGEXREPLACE("'"&join("', '",Arrayformula(if(A2:F2="foobar",address(row(), COLUMN(A2:F2)), "X")))&"'","'X', |'X'","")

Then you want to put all the addresses in one string using the below formula.

=CONCATENATE(G2:G)

The next step is to paste this string into a selection script like this:

function foobar() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRangeList(('$A$3', '$B$6', '$A$9', '$B$9', '$E$9', '$A$13', '$B$13', '$C$13', '$D$13', '$E$13', '$F$13')).activate();
};

Once you go back to the sheet and run the script it will select all cells containing “foobar”

This is the link to the example.

postgresql – Is instant text search possible in big table with HTMLs?

I have a pretty big table with HTMLs (about 500K rows, average length of text is ~150K).
It is required to make fast search (less than 1s) rows which match let say ‘%<meta name=”twitter:app%’.
First 10 results are enough.

Possible solution I have tired (on Postgres mainly):

  1. Full-text search: results look not relevant and may miss something (can not find a way to improve it).
  2. Trigram index (...USING GIN (t gin_trgm_ops)...) – a cool feature of PosgreSQL by the way. It worked fast on my synthetic tests, but when I applied to my HTMLs set – it worked minutes(!). I used explain anaylze, what showed me that index is used (what is nice), but than Postgres recheck what matched by index and this is quite slow, because it needs to make linear text search in large texts, one by one. On synthetic tests it worked because my texts were relatively small.
  3. Also I tied Elastic (I used ‘wildcard field type’, Elastic use trigram index as well in that case), but performance was even worse that in Postgres case.

I still believe that it possible, but how?

python – Printing colourful text to terminal

colors.py

type_error = "Expected an int or str type but given {} type"


def _condition_for_int(color):
    return (isinstance(color, int) and (color >= 0 and color < 256)) or (
        color.isnumeric() and (int(color) >= 0 and int(color) < 256)
    )


class Color:
    accepted_color_alias = {
        "black",
        "red",
        "green",
        "yellow",
        "blue",
        "magenta",
        "cyan",
        "white",
    }
    RESET = "33(0m"


class FontColor(Color):
    """
    Font color class
    """

    black = "33(30m"
    red = "33(31m"
    green = "33(32m"
    yellow = "33(33m"
    blue = "33(34m"
    magenta = "33(35m"
    cyan = "33(36m"
    white = "33(37m"

    @classmethod
    def get_color(self, color, value="", add_reset=True):
        if not isinstance(color, (int, str)):
            raise TypeError(type_error.format(type(color).__name__))

        _reset = self.RESET * add_reset

        if _condition_for_int(color):
            return "33(38;5;{}m{}{}".format(color, value, _reset)

        if color not in self.accepted_color_alias:
            raise ValueError("Unknown color given {}".format(color))
        return getattr(self, color) + str(value) + _reset


class BackgroundColor(Color):
    """
    Background colors class
    """

    black = "33(40m"
    red = "33(41m"
    green = "33(42m"
    yellow = "33(43m"
    blue = "33(44m"
    magenta = "33(45m"
    cyan = "33(46m"
    white = "33(47m"

    @classmethod
    def get_color(self, color, value, add_reset=True):
        if not isinstance(color, (int, str)):
            raise TypeError(type_error.format(type(color).__name__))

        _reset = self.RESET * add_reset

        if _condition_for_int(color):
            return "33(48;5;{}m{}{}".format(color, value, _reset)

        if color not in self.accepted_color_alias:
            raise ValueError("Unknown color given {}".format(color))

        return getattr(self, color) + str(value) + _reset


class FontStyle(Color):
    """
    Font style class
    """

    bold = "33(1m"
    italic = "33(3m"
    underline = "33(4m"

    @classmethod
    def get_style(self, style, value="", add_reset=True):
        if not isinstance(value, str):
            raise TypeError("Only str type allowed")

        return getattr(self, style) + value + self.RESET * add_reset


#s = f'{FontColor.get_color("red", "STOP")} {BackgroundColor.get_color("cyan", "danger")}'
# print(s)
# print(FontStyle.get_style('underline', 'HEllO'))

Output from the commented lines at the end of the file
         

utils.py

from colors import Color, FontStyle, FontColor, BackgroundColor
import sys
from time import sleep


def cprint(
    text,
    color=None,
    background=None,
    bold=False,
    italic=False,
    underline=False,
    end="n",
):
    """
    prints the given text to stdout with color `color`
    and `background` resets back to normal after printing.
    Supported colors are 'black', 'red', 'green', 'yellow',
    'blue', 'magenta', 'cyan', 'white'.
    """

    _reset = Color.RESET
    bg = "" if background is None else _set_background(background)
    font_color = "" if color is None else _set_color(color)
    font_style = _set_font_style(bold=bold, italic=italic, underline=underline)
    output_style = bg + font_color + font_style
    sys.stdout.write(output_style)
    sys.stdout.write(text)
    sys.stdout.write(_reset + end)


def _set_color(color):
    """
    For setting color of the cursor with `color`.
    Accepted colors alias are 'black', 'red', 'green',
    'yellow', 'blue', 'magenta', 'cyan', 'white'.
    Can also gives an values between 0 to 255.
    Check `get_color_codes()` for more info.
    """

    return FontColor.get_color(color, add_reset=False)


def _set_background(color):
    """
    Returns the background of the cursor with color
    `color` ansi esacape code. Accepted colors alias are
    'black', 'red', 'green','yellow', 'blue', 'magenta',
    'cyan', 'white'. Can also gives an values between 0 to 255.
    """

    return BackgroundColor.get_color(color, add_reset=False)


def _set_font_style(**styles):
    return "".join(
        (
            FontStyle.get_style(style, add_reset=False)
            for style, cond in styles.items()
            if cond
        )
    )


def get_color_codes(animation=False, background=False):
    """
    prints color codes in it's respective color,
    used for visual reference.
    """

    ansi_code = "33(48;5;{}m{}" if background else "33(38;5;{}m{}"
    v = 0.1 if animation else 0
    for i in range(32):
        for j in range(8):
            sleep(v)
            code = str(i * 8 + j)
            sys.stdout.write(ansi_code.format(code, code.ljust(4)))
            sys.stdout.write("33(0m")
        sys.stdout.write("n")


#cprint("hello world", color="123", bold=True, italic=True)

# get_color_codes(background=True)

The output from commented lines at the end of the file

microsoft powerpoint – How to remove this annoying text from power point?

I find a powerpoint on a telegram channel and I want to edit and work on that powerpoint. but there is a text on the above left of the powerpoint I try to delete this but I can’t:

enter image description here

I also tried this way:

enter image description here

And clicked on the Section Header. but the glowing line below the arrows disappeared. So how can I fix it?