text:
Q: hide media controller without removing it ? I have a video view which uses media controller. I want to hide the media controller somehow without doing video_view.setMediaController(null);
If I do that then the following code won't work:
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

So I want to hide the media controller permanently while the video is playing but still be able to turn the volume up and down. How can I do that

A: Try this.
MediaController mediaController = new MediaController(this);

apply on touch listener on your video view.
in that place this code.
if(mediaController.isShowing ()){
   mediaController.hide();
}

here is the link for more info.

A: This might help if to remove permanently controller...
    VideoView videoHolder = new VideoView(contex);
    MediaController controller=new MediaController(this);
    videoHolder.setMediaController(controller);

then apply this statement to hide permanently your controller...
    controller.setVisibility(View.GONE);

just call this to show it again...
    controller.setVisibility(View.VISIBLE);


text:
Q: Validating selected values against particular column of the table Please find the fiddle here
What is the issue ?
When user picks the city from the drowdown , code will validated selected city name against all td (all coulmn).  But I want to validate selected city name against column' city' only.
 $("#search").change(function () {
 var value = this.value.toLowerCase().trim();

 $("table tr").each(function (index) {
    if (!index) return;
        $(this).find("td").each(function () {
        var id = $(this).text().toLowerCase().trim();
        var not_found = (id.indexOf(value) == -1);
        $(this).closest('tr').toggle(!not_found);
        return not_found;
    });
 });
 });

A: You can use :eq() Selector to fetch 4th column like

Select the element at index n within the matched set

Code Example, Use
$(this).find("td:eq(3)")

instead of
$(this).find("td")

DEMO
Note: its zero-based index of the element to match.

redpajama_set_name: RedPajamaStackExchange


text:
Q: What's wrong with this recursion of counting codes of length $n$ formed by $a$, $b$, and $c$ such that no three consecutive letters are distinct I found the following problem in a combinatorics book and gave it a try.

Let $B_n$ denote the set of codes of length $n$ formed by using the letters $a$, $b$, and $c$, none of which contains three consecutive letters that are distinct (so at least two of the three letters are the same). Express $|B_n|$ as a recursion.

Let $X_n$, $Y_n$, and $Z_n$ denote the sets of codes of length $n$ ending with $a$, $b$, and $c$ respectively. Then $|B_n| = |X_n| + |Y_n| + |Z_n|$.
A code of length $n$ ending with $a$ can be formed from a code of length $n - 2$ by the following three ways.

*

*Appending $aa$, $ba$, and $ca$ after a code ending with $a$.

*Appending $aa$ and $ba$ after a code ending with $b$.

*Appending $aa$ and $ca$ after a code ending with $c$.

Hence $|X_n| = 3 \cdot |X_{n - 2}| + 2 \cdot |Y_{n - 2}| + 2 \cdot |Z_{n - 2}|$. By symmetry, $|Y_n| = 2 \cdot |X_{n - 2}| + 3 \cdot |Y_{n - 2}| + 2 \cdot |Z_{n - 2}|$ and $|Z_n| = 2 \cdot |X_{n - 2}| + 2 \cdot |Y_{n - 2}| + 3 \cdot |Z_{n - 2}|$.
But, $|X_n| = |X_{n - 2}| + 2 \cdot (|X_{n - 2}| + |Y_{n - 2}| + |Z_{n - 2}|) = |X_{n - 2}| + 2 \cdot |B_{n - 2}|$. Again, by symmetry, $|Y_n| = |Y_{n - 2}| + 2 \cdot |B_{n - 2}|$ and $|Z_n| = |Z_{n - 2}| + 2 \cdot |B_{n - 2}|$.
Hence, $|B_n| = (|X_{n - 2}| + |Y_{n - 2}| + |Z_{n - 2}|) + 6 \cdot |B_{n - 2}| = 7 \cdot |B_{n - 2}|$ with $|B_1| = 3$ and $|B_2| = 9$. But the book's answer is $|B_{n}| = 2 \cdot |B_{n - 1}| + |B_{n - 2}|$. What did I get wrong?

A: You have two cases to consider: strings that end in $x x$ and strings that end in $x y$ ($x \ne y$). Call the numbers of each of length $n$ respectively $u_n$ and $v_n$, set up recurrences for both. You are interested in $u_n + v_n$.

*

*$\ldots xx$: You can add a new $x$ (1 possibility) to get a new $\ldots xx$,
or anything else to get an $\ldots xy$ (2 options)

*$\ldots xy$: If you add an $x$, you get an $\ldots xy$ (1 option), if you add a $y$ you get a $\ldots xx$ (1 option)

This leads to the system of recurrences:
\begin{align}
u_{n + 1} &= u_n + v_n \\
v_{n + 1} &= 2 u_n + v_n
\end{align}
As starting points for $\ldots xx$ you have $u_2 = 3$, for $\ldots xy$ it is $v_2 = 6$, by "running the recurrences backwards" you get $u_0 = - 3$ and $v_0 = 6$. These values are pure fiction, the real starting points are $u_3 = 9$ and $v_3 = 12$.
Subtracting you get $v_{n + 1} - u_{n + 1} = u_n$,  so $v_{n + 1} = u_{n + 1} + u_n$; substituting in $u_{n + 2}$ gets you $u_{n + 2} = 2 u_{n + 1} + u_n$. But from the first recurrence the value you are really interested in, $u_n + v_n$, is nothing more than $u_{n + 1}$, which satisfies the same recurrence. Thus you have that
$$
\lvert B_{n + 2} \rvert = 2 \cdot \lvert B_{n + 1} \rvert + \lvert B_n \rvert
$$
as was requested.
Now use generating functions. Define $U(z) = \sum_{u \ge 0} u_n z^n$ and $V(z) = \sum_{u \ge 0} v_n z^n$, multiply the recurrences by $z^n$, sum each over $n \ge 0$, and express in terms of the generating functions:
\begin{align}
\frac{U(z) - u_0}{z} &= U(z) + V(z) \\
\frac{V(z) - v_0}{z} &= 2 U(z) + V(z)
\end{align}
This gives:
\begin{align}
U(z) &= - \frac{3 - 9 z}{1 - 2 z - z^2} \\
V(z) &= \frac{6 - 12 z}{1 - 2 z - z^2}
\end{align}
But you are interested in
$$
B(z) = U(z) + V(z) = 3 \frac{1 - z}{1 - 2 z - z^2}
$$
Next step is to expand as partial fractions, and read off the coefficients from the resulting terms. Sadly, the zeros of the denominator are $-1 \pm \sqrt{2}$, so this gets ugly. In the immortal words of all texbook writers, "the details are left as an exercise for the reader."


text:
Q: How to use Power Automate "uriQuery()" function on an url that contains special characters Due to some odd circumstances I have the necessity to use uriQuery() in a Power Automate flow in order to extract the query string from an url.
This works as expected in most circumstances, except when the url contains special characters like accented letters, for example
http://www.example.com/peppers/Jalapeño/recipe #1.docx

In such cases the call triggers an error and the exception message shows a (partially) encoded version of my url (why?).

The template language function 'uriQuery' expects its parameter to be a well-formed absolute URI. The provided value was '......'

Obviously the url was indeed a well-formed, absolute URI.
Since the error only triggers when the url contains special characters I assumed that I had to encode the value before calling uriQuery(), yet nothing I tried seems to work (for example encodeUriComponent() ). And as expected nothing I could find on the web mentioned a similar issue.
As a last attempt I am asking here - does uriQuery() support this use-case? And if it does... how?


text:
Q: Postfix 2.11.3 Mail gateway: Recipient address rejected: User unknown in local recipient table I am trying to recreate a mail-gateway for spam/antivirus-checks on a new debian system (Postfix 2.11.3) coming from an older OpenSuse Installation (Postfix 2.6.5). I tried to test it with "telnet localhost 25". When sending test email to the postmaster adress on the local server, everything works fine, however, if i use an existing adress on one of the mailservers managing the user accounts it returns the error 550 "Recipient address rejected: User unknown in local recipient table".
I built a new configuration trying to adapt it to the version changes.
I already rebuilt the transport maps and checked the domains in it so this is probably not the issue.
main.cf:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
masquerade_classes = envelope_sender, header_sender, header_recipient

myhostname = spamfilter.local
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, localhost.$mydomain, domain1.tld, domain2.tld, domain3.othertld
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.1.0/24 10.0.0.0/24 192.111.112.5/32
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

canonical_maps =
virtual_alias_maps =
virtual_alias_domains =
relocated_maps =
sender_canonical_maps =

relay_host = $mydestination

transport_maps = hash:/etc/postfix/transport_maps

smtpd_recipient_restrictions =
#  check_policy_service inet:127.0.0.1:10023
  permit_mynetworks,
  reject_unauth_destination,
  permit_sasl_authenticated,
  reject_invalid_hostname,
  reject_non_fqdn_sender,
  reject_non_fqdn_recipient,
  reject_unknown_sender_domain,
  reject_unknown_recipient_domain,
  reject_rbl_client cbl.abuseat.org,
  reject_rbl_client sbl-xbl.spamhaus.org,
  reject_rbl_client dul.dnsbl.sorbs.net,
  reject_rbl_client zen.spamhaus.org,
  reject_unverified_recipient,
  permit

message_size_limit = 50000000

smtpd_proxy_filter=localhost:10024

A: As this is a mail gateway, I think you should use the relay_domains parameter:
relay_domains = domain1.tld, domain2.tld, etc

In order to accept only valid users, you need to add a relay_recipient_map parameter as well.


text:
Q: Disable Facebook popup if user already likes my website Facebook page In my website I have put Facebook popup. Now I want only those people to see that pop up who didn't like my website Facebook page yet.
this is my code.
 .facebookOuter { background-color:#F4F4F4; width:230px; padding:10px 0 10px 10px; height:250px; border:1px solid #CCCCCC; } .facebookInner { height:250px; overflow:hidden; }         (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));
I looking to hear from you.
Best regards.

A: I think You need to store a flag somewhere. Guess this might be helpful. Check the link below
Facebook popup remember when user likes


text:
Q: Python Tabula Script keeps opening Java.Exe window. How do I get it to use jawaw.exe instead? I have made a python script that used tabula.read_pdf. After I convert it to an executable file, java.exe window keeps popping up when running tabula.read_pdf. Other threads indicate that I should use javaw.exe instead of java.exe. But how do I select this ?
I use auto-py-to-exe to make the executable file for my python script.
Python tabula read_pdf opens java console window
In this question they talk about changing i name in a wrapper file.

A: (Just copying my answer from the post you linked above) I was running into a similar issue and couldn't really find the wrapper.py. After some tinkering around I found a similar workaround:
Within the directory where tabula is installed "...\Lib\site-packages\tabula" edit the "io.py" file. In the "_run" function just change the "args" variable to use "javaw" instead of "java".
I was able to hide the java console when my .exe file ran this way. I hope this helps someone in the future.


text:
Q: How to use require.js to load Vue.js and my custom Vue library I wrote a widget in Vue.js and compiled it as a library.
I want to attach my widget to 3rd party website which uses require.js to load scripts.
I'm using following code to load Vue and my widget:
<script>
    require([
        'vue',
        'myWidget'
    ], function (Vue, myWidget) {
        console.log('Loaded!');
    });
</script>

but I get an error:

Uncaught TypeError: Cannot read property 'extend' of undefined
  myWidget.js:8

How I should load both Vue.js and my widget correctly?


text:
Q: Is it possible for a computer to "learn" a regular expression by user-provided examples? Is it possible for a computer to "learn" a regular expression by user-provided examples?
To clarify:

*

*I do not want to learn regular expressions.

*I want to create a program which "learns" a regular expression from examples which are interactively provided by a user, perhaps by selecting parts from a text or selecting begin or end markers.

Is it possible? Are there algorithms, keywords, etc. which I can Google for?
EDIT: Thank you for the answers, but I'm not interested in tools which provide this feature. I'm looking for theoretical information, like papers, tutorials, source code, names of algorithms, so I can create something for myself.

A: Yes, it's certainly "possible"; Here's the pseudo-code:
string MakeRegexFromExamples(<listOfPosExamples>, <listOfNegExamples>)
{
   if HasIntersection(<listOfPosExamples>, <listOfNegExamples>)
     return <IntersectionError>

   string regex = "";
   foreach(string example in <listOfPosExamples>)
   {
      if(regex != "")
      {
         regex += "|";
      }
      regex += DoRegexEscaping(example);
   }
   regex = "^(" + regex + ")$";

   // Ignore <listOfNegExamples>; they're excluded by definition

   return regex;
}

The problem is that there are an infinite number of regexs that will match a list of examples.  This code provides the simplest/stupidest regex in the set, basically matching anything in the list of positive examples (and nothing else, including any of the negative examples).
I suppose the real challenge would be to find the shortest regex that matches all of the examples, but even then, the user would have to provide very good inputs to make sure the resulting expression was "the right one".

A: I believe the term is "induction". You want to induce a regular grammar.
I don't think it is possible with a finite set of examples (positive or negative). But, if I recall correctly, it can be done if there is an Oracle which can be consulted. (Basically you'd have to let the program ask the user yes/no questions until it was content.)

A: Yes,
it is possible,
we can generate regexes from examples (text -> desired extractions).
This is a working online tool which does the job: http://regex.inginf.units.it/
Regex Generator++ online tool generates a regex from provided examples using a GP search algorithm.
The GP algorithm is driven by a multiobjective fitness which leads to higher performance and simpler solution structure (Occam's Razor).
This tool is a demostrative application by the Machine Lerning Lab, Trieste Univeristy (Università degli studi di Trieste).
Please look at the video tutorial here.
This is a research project so you can read about used algorithms here.
Behold! :-)
Finding a meaningful regex/solution from examples is possible if and only if the provided examples describe the problem well.
Consider these examples that describe an extraction task, we are looking for particular item codes; the examples are text/extraction pairs:
"The product code is 467-345A" -> "467-345A"
"The item 789-345B is broken"  -> "789-345B"

An (human) guy, looking at the examples, may say: "the item codes are things like \d++-345[AB]"
When the item code is more permissive but we have not provided other examples, we have not proofs to understand the problem well.
When applying the human generated solution \d++-345[AB] to the following text, it fails:
"On the back of the item there is a code: 966-347Z"

You have to provide other examples, in order to better describe what is a match and what is not a desired match:
--i.e:
"My phone is +39-128-3905 , and the phone product id is 966-347Z" -> "966-347Z"

The phone number is not a product id, this may be an important proof.

A: You might want to play with this site a bit, it's quite cool and sounds like it does something similar to what you're talking about: http://txt2re.com

A: The book An Introduction to Computational Learning Theory contains an algorithm for learning a finite automaton. As every regular language is equivalent to a finite automaton, it is possible to learn some regular expressions by a program. Kearns and Valiant show some cases where it is not possible to learn a finite automaton. A related problem is learning hidden Markov Models, which are probabilistic automata that can describe a character sequence. Note that most modern "regular expressions" used in programming languages are actually stronger than regular languages, and therefore sometimes harder to learn.

A: There's a language dedicated to problems like this, based on prolog. It's called progol.
As others have mentioned, the basic idea is inductive learning, often called ILP (inductive logic programming) in AI circles.
Second link is the wiki article on ILP, which contains a lot of useful source material if you're interested in learning more about the topic.

A: No computer program will ever be able to generate a meaningful regular expression based solely on a list of valid matches.  Let me show you why.
Suppose you provide the examples 111111 and 999999, should the computer generate:

*

*A regex matching exactly those two examples: (111111|999999)

*A regex matching 6 identical digits (\d)\1{5}

*A regex matching 6 ones and nines [19]{6}

*A regex matching any 6 digits \d{6}

*Any of the above three, with word boundaries, e.g. \b\d{6}\b

*Any of the first three, not preceded or followed by a digit, e.g.
(?<!\d)\d{6}(?!\d)
As you can see, there are many ways in which examples can be generalized into a regular expression.  The only way for the computer to build a predictable regular expression is to require you to list all possible matches.  Then it could generate a search pattern that matches exactly those matches.
If you don't want to list all possible matches, you need a higher-level description.  That's exactly what regular expressions are designed to provide.  Instead of providing a long list of 6-digit numbers, you simply tell the program to match "any six digits".  In regular expression syntax, this becomes \d{6}.
Any method of providing a higher-level description that is as flexible as regular expressions will also be as complex as regular expressions.  All tools like RegexBuddy can do is to make it easier to create and test the high-level description.  Instead of using the terse regular expression syntax directly, RegexBuddy enables you to use plain English building blocks.  But it can't create the high-level description for you, since it can't magically know when it should generalize your examples and when it should not.
It is certainly possible to create a tool that uses sample text along with guidelines provided by the user to generate a regular expression.  The hard part in designing such a tool is how does it ask the user for the guiding information that it needs, without making the tool harder to learn than regular expressions themselves, and without restricting the tool to common regex jobs or to simple regular expressions.

A: @Yuval is correct. You're looking at computational learning theory, or "inductive inference. "
The question is more complicated than you think, as the definition of "learn" is non-trivial. One common definition is that the learner can spit out answers whenever it wants, but eventually, it must either stop spitting out answers, or always spit out the same answer. This assumes an infinite number of inputs, and gives absolutely no garauntee on when the program will reach its decision. Also, you can't tell when it HAS reached its decision because it might still output something different later.
By this definition, I'm pretty sure that regular languages are learnable. By other definitions, not so much...

A: I've done some research on Google and CiteSeer and found these techniques/papers:

*

*Language identification in the limit

*Probably approximately correct learning
Also Dana Angluin's "Learning regular sets from queries and counterexamples" seems promising, but I wasn't able to find a PS or PDF version, only cites and seminar papers.
It seems that this is a tricky problem even on the theoretical level.

A: If its possible for a person to learn a regular expression, then it is fundamentally possible for a program.  However, that program will need to be correctly programmed to be able to learn.  Luckily this is a fairly finite space of logic, so it wouldn't be as complex as teaching a program to be able to see objects or something like that.


text:
Q: Shell set to bash but running zsh I tried out zsh, but decided to revert to bash because it's what I'm used to. I've set my "Login shell" back to /bin/bash in System Preferences > Users & Groups > Advanced options and have run chsh -s /bin/bash. When I run echo $SHELL I get the expected "/bin/bash" output. However, the top of my terminal windows says " - ZSH - bash" and when I force an error, like searching for something that doesn't exist, the message seems to indicate that it's still running zsh:
zsh: no matches found: *test
I've tried to force it to be bash in every way I know how. What am I not thinking of? Any/all suggestions appreciated.
Edit:
When I go to close the shell, here's what I see (it says it needs to terminal ZSH).

Edit 2:
When creating a new window I got this message, which is new. Setopts is in my .bashrc file, so it seems to be set to zsh in whatever is loaded after the .bashrc. The top text has now changed back to the default, so I guess ZSH is no longer the "Active process".

A: The fact that "ZSH" in the window title is in all caps leads me to believe that this is your problem:

To see if this is it:

*

*Launch Terminal

*Go to Preferences

*Go to the Profiles tab

*Select the profile marked "Default" in light gray text below its name

*Go to the Window tab

*I believe you'll find the text "ZSH" in the Title field. Change it to "waffles and ponies!" or whatever you'd like to see there instead.

These instructions are based on macOS 10.15.6 Catalina. YMMV.


text:
Q: How to start a Qt frontend of a SystemC simulation I am writing a GUI in Qt, where I have:
  QApplication app(argc, argv);

which is invoked by:
 app.exec();

Which returns only when the application terminates.
For executing SystemC simulation inside the application, I need to invoke:
sc_start(...);

Which also returns only when the simulation terminates.
Shall I hack Qt or SystemC to circumvent the problem, or is there some trick I can use? How can I avoid the deadlock of the two blocking calls?

A: You should run them inside two different threads or processes. And design a communication mechanism to exchange data between simulation and GUI.
Another common idea utilized by SystemC debuggers and interactive waveform viewers is to run SystemC under GDB and use GDB-MI protocol to control simulation from GUI.


text:
Q: Another question about iPhone application state I have another question about restoring application state, on the iPhone.
Simple data (like the selected tab) can be stored in NSUserDefaults, but it is not enough.
I want to restore the whole state, including the Navigation Controllers (go to the sub-sub-sub View Controller).
My problem is that my application is divided in several xib files, so at the beginning, all the View Controllers are not instantiated.
Is there any way to "force" the instanciation from a xib file ?
(I have no code under the hand, but I can try to write a small end if it is not clear)
Thanks a lot.

A: Calling [viewController view] will make sure that a given view controller's XIB is loaded; once it is, you can use any of its other properties normally.
Here's what I tend to do:
@class Record;  // some model object--I assume it has an integer record ID
@class DetailViewController;

@interface RootViewController : UIViewController {
    IBOutlet DetailViewController * detailController;
}

- (void)restore;
...
@end

@implementation RootViewController

// Note: all detailController showings--even ones from within
// RootViewController--should go through this method.
- (void)showRecord:(Record*)record animated:(BOOL)animated {
    [self view];    // ensures detailController is loaded

    [[NSUserDefaults standardUserDefaults] setInteger:record.recordID
                                               forKey:@"record"];
    detailController.record = record;

    [self.navigationController pushViewController:detailController
                                         animated:animated];
}

- (void)restore {
    int recordID = [[NSUserDefaults standardUserDefaults] integerForKey:@"record"];

    if(recordID) {
        Record * record = [Record recordWithID:recordID];
        [rootViewController showRecord:record animated:NO];
        // If DetailViewController has its own state to restore, add this here:
        // [detailController restore];
    }
}
...
- (void)viewDidAppear:(BOOL)animated {
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"record"];
}
@end

@implementation MyAppDelegate

- (void)applicationDidFinishLaunching:(UIApplication*)application {
    ...
    [rootViewController restore];
    ...
}
...
@end

Each level of the view hierarchy takes care of its own state saving, so the app controller doesn't have to know about all the possible views and which orders they could be in.

A: I do this in my app, Litho Graph. If you're on a page when you quit, then the next time you launch, it restores you to that page. It's pretty easy, too: in my main view controller's -viewDidLoad implementation, I check for the last page viewed key in the user defaults. If there's nothing, I continue as normal (and show a list of all pages). If there's something, I open that page (pushing the new view controller onto the navigation controller stack).
The actual loading of the view controllers is very straightforward: I just instantiate them. Each of my view controller classes has overridden -init to call -initWithNibName:bundle: on super, so calling +alloc and -init to create the view controller instance is enough to load it from the appropriate .xib file. Then, as described above, I push it onto the navigation controller's stack:
[self.navigationController pushViewController: controller animated: YES];

You can do this as many layers deep as you need to, of course, but bear in mind that you may want to push the view controllers without animation if there's going to be several transitions; it would be counterproductive for the user to have to wait through several animations (:

A: Look at apples "drilldownsave" sample code. does exactly what you want


text:
Q: When is a logarithm equal to a whole number? Are there any conditions a logarithm must meet to be a whole number?
In other words: $x=\log_y(z)$, when will $x$ be a whole number?

A: Your comments make clear that what you want is a method for deciding whether $x=\log_y z$ is a whole number, without calculating the logarithm.
It suffices to decide if $z$ is an integer power of $y$. To learn this:

*

*Let $z'=z$, and repeatedly divide $z'$ by $y$ until either:

*

*$z'=1$. The answer is yes, $x$ is an integer

*$z'$ is not an integer. The answer is no, $x$ is not an integer

For example, is $x=\log_8 1521364$ an integer? Divide $1521364$ by $8$ repeatedly: $1521364\div 8= 190170\frac12$ is not an integer, so $x$ is not either.
But $2097152\stackrel{\div 8}{\to} 262144\stackrel{\div 8}{\to} 32768\stackrel{\div 8}{\to} 4096\stackrel{\div 8}{\to} 512\stackrel{\div 8}{\to} 64 \stackrel{\div 8}{\to} 8\stackrel{\div 8}{\to}1$, so $\log_8 2097152$ is an integer.
Alternatively, you can run the algorithm backward, computing $y, y^2, y^3, \dots$ until you find an $i$ for which $y^i≥z$. Then $\log_y z$ is an integer if and only if $y^i=z$. A version of this method that computes $i$ with binary search will be faster if $z$ is very large.

A: Let $f(t):=\log_y(t)$ for $t>0$. Then
$f((0, \infty))= \mathbb R$.
Hence for each $x \in \mathbb Z$, there is $z \in (0, \infty)$ with $x=\log_y(z)$


text:
Q: get html content from epub.js By using epub.js. epub file is parsed into iframe.
like
<iframe id="epubjs-view-2d154c70-dc91-4704-bd66-821ad4de4a9f" scrolling="no" sandbox="allow-same-origin" enable-annotation="true" srcdoc="<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"><head><base href="http://localhost:4343/text/part0003.html" />
    <title></title>
</iframe>

How to get the iframe list by code.
I'm trying to display the results parsed by epub.js in turn.js.
Thanks.


text:
Q: Is there any Intent filter which can be trigger whenever some text is copied in clipboard in android? I need to perform some action in my activity whenever text has been copied in clipboard (My application is in background).Is there any intent filter which can invoke my activity or inform my app that some thing has been copied in clipboard.

A: You can create intent filter for your activity, but android provides ClipBoardManager system service which you can exploit.


text:
Q: PHP - sort arrays within assoc array I promise you I've had a look at the many existing SO Qs about PHP sorting, including this mega one
I've got a PHP associative array, with strings as keys.  Each value is an array of integers.  I want to sort each array of integers, in simple ascending numerical order.  I'm convinced this should be easy, and I've found enough examples that I think I should be doing the right thing, but it's not quite working, so there's a typo or I'm an idiot or something...
PHP:
//Each fruit corresponds to an array (series) of integers
$data = [
    'banana' => [
        1,3,2
    ],
    'orange' => [
        5,1,3
    ]
];

echo "Before sort:\n";
var_dump($data);

//For each fruit, I want to order the numbers
foreach ($data as $key => $series)
{
    //Sort array of integers
    sort($series);

    //NB I wasn't sure about value/reference details of foreach loops, so I also tried
    //retrieving a series into a variable, sorting, and then reassigning back to the same key
}

echo "\n\nAfter sort:\n";
var_dump($data);

Output:
Before sort:
array(2) {
  'banana' =>
  array(3) {
    [0] =>
    int(1)
    [1] =>
    int(3)
    [2] =>
    int(2)
  }
  'orange' =>
  array(3) {
    [0] =>
    int(5)
    [1] =>
    int(1)
    [2] =>
    int(3)
  }
}

After sort:
array(2) {
  'banana' =>
  array(3) {
    [0] =>
    int(1)
    [1] =>
    int(3)
    [2] =>
    int(2)
  }
  'orange' =>
  array(3) {
    [0] =>
    int(5)
    [1] =>
    int(1)
    [2] =>
    int(3)
  }
}

As you can see, in the output the inner arrays of integers have not been sorted.  What am I doing wrong?  (PHP 5.5.9, Windows 7)

A: Use a reference &:
foreach ($data as $key => &$series)
{
    //Sort array of integers
    sort($series);
    // OR
    // sort($data[$key]);
}


text:
Q: Fourier Expansion of a function on $\mathbb A_k/k$ Let $k$ be a number field, and let $\mathbb A_k$ be the ring adeles of $k$.  The quotient group $\mathbb A_k/k$ is compact, and the choice of a nontrivial character $\psi$ of $\mathbb A_k/k$ gives an isomorphism $a \mapsto \psi_a$ of the additive group $k$ with the Pontryagin dual $(\mathbb A_k/k)^{\ast}$ of $\mathbb A_k/k$, where $\psi_a(x) = \psi(ax)$.

Question: If $f: \mathbb A_k/k \rightarrow \mathbb C$ is a function, under what circumstances do we have a "Fourier expansion" of $f$, as
$$f(x) = \sum\limits_{a \in k} c_a \psi(ax) \tag{$x \in \mathbb A_k$}$$

The situation of $\mathbb A_k$ and $k$ is of course an analogy with $\mathbb R$ and $\mathbb Z$.  The quotient group $\mathbb R/\mathbb Z$ is compact, and the choice of the character $\psi(x) = e^{2 \pi i x}$ of $\mathbb R/\mathbb Z$ gives an isomorphism $n \mapsto e^{2\pi i nx}$ of $\mathbb Z$ with $(\mathbb R/\mathbb Z)^{\ast}$.
The complex Hilbert space $L^2(\mathbb R/\mathbb Z)$ of square integrable complex valued functions has $e^{2\pi i nx} : n \in \mathbb Z$ as an orthonormal basis (with a suitably normalized Haar measure on $\mathbb R/\mathbb Z$), so every measurable function $f: \mathbb R \rightarrow \mathbb C$ satisfying $f(x+1) = f(x)$ for almost all $x$, and $\int_0^1 |f(x)|^2 dx < \infty$ can be written as
$$f(x) = \sum\limits_{n \in \mathbb Z} c_n e^{2\pi i nx}$$
for almost all $x$ and for uniquely determined $c_n \in \mathbb C$.

A: Let $G$ be a compact Hausdorff topological group, and let $\hat{G}$ be the set of isomorphism classes of irreducible unitary representations of $G$.  It is a consequence of the Peter-Weyl theorem that each $\pi \in \hat{G}$ is finite dimensional, and the right regular representation $L^2(G)$ is isomorphic to a Hilbert space direct sum of subrepresentations
$$\bigoplus\limits_{\pi \in \hat{G}} \bigoplus_{i=1}^{\operatorname{Dim}\pi} \pi$$
Explicitly, the direct sum $V = \bigoplus_{i=1}^{\operatorname{Dim}\pi} \pi$ occurs in $L^2(G)$ as the span of the matrix coefficients of $\pi$.  If $e_1, ... , e_n$ is an orthonormal basis of $G$, then $c_{ij}(g) = \langle e_j, \pi(g)e_i\rangle$, possibly with some scalar modification, form an orthonormal basis of $V$.
In particular, assume $G$ is abelian, for example $G = \mathbb R/\mathbb Z$ or $G = \mathbb A_k/k$.  Then each irreducible unitary representation is one dimensional, i.e. a character.  If $\chi$ is a character of $G$, the corresponding matrix coefficient is just the function $g \mapsto \chi(g)$.  Thus the characters of $G$ form an orthonormal basis of $L^2(G)$.  So if $f \in L^2(G)$, we can uniquely write
$$f(g) = \sum\limits_{\chi \in \hat{G}} c_{\chi} \chi(g)$$
for uniquely determined $c_{\chi} \in \mathbb C$.  If we want to isolate $c_{\chi}$, we use the orthogonality relations
$$\int\limits_G \chi_1(g) \overline{\chi_2(g)}dg = \begin{cases} \operatorname{meas}(G) & \textrm{if } \chi_1 = \chi_2 \\ 0 & \textrm{if } \chi_1 \neq \chi_2 \end{cases}$$
which implies  $c_{\chi} = \frac{1}{\operatorname{meas}(G)} \int\limits_G f(g) \overline{\chi(g)} dg$.
EDIT: There is a problem here.  The series $F(g) = \sum\limits c_{\chi} \chi(g)$ only converges in the $L^2$ norm to $f$, not pointwise.  So I still don't know.


text:
Q: How to find which function is calling another function in C? Let's say I have a function called verify() inside verify.c and it is used to evaluate a condition and print debug message if the check fails.
void verify(int expected)
{
    if (expected < 10) {
        fprintf(stderr,"Verification failed for %d\n", expected);
        abort();
    }
}

Now, I am adding this header file verify.h in various c files throughout SW package, and many functions from different c files are calling verify(). If the check fails, verify() will print out the error message but how do I exactly find out where it is happening (i.e. which file and which function is actually calling failed verify())?
I want to find this during I compile my code and without using a debugger such as gdb.

A: Given verify.h declaring:
#define verify(e) verify_impl( (e), __FILE__, __func__, __LINE__ )
void verify_impl( int expected, const char* file, const char* fn, int line ) ;

And verify.c defining:
void verify_impl(int expected, const char* file, const char* fn, int line ) ; )
{
    if (expected < 10)
    {
        fprintf( stderr,"Verification failed for %d at %s:%s(%d)\n",
                 expected, file, fn, line );
        abort();
    }
}

The when verify(9) ; is called from foo() at line 20 of bar.c for example, you will get:
Verification failed for 9 at bar.c:foo(20)

However a more generally useful assertion mechanism is possible.  Consider:
verify.h:
#define verify(e) verify_impl( (e), #e, __FILE__, __func__, __LINE__ )
void verify_impl( int exp, const char* expression,
                  const char* file, const char* fn, int line ) ;

verify.c
void verify_impl( int exp, const char* expression,
                  const char* file, const char* fn, int line ) ; )
{
    if( !exp )
    {
        fprintf( stderr,"Verification that %s failed at from %s:%s(%d)\n",
                 expression, file, fn, line );
        abort();
    }
}

Then when verify( x >= 10 ) ; is called with x == 9 from foo() at line 20 of bar.c for example, you will get the more useful:
Verification that x >= 10 failed at bar.c:foo(20)

Any Boolean expression can be verified rather than the hard coded exp < 10.  If you still need the original hard test, then you can define another macro in terms of the new more flexible one:
#define verify_notlessthan10( e ) verify( (e) >= 10 )

Note the inversion of the logic; you are verifying that the expression is true, and aborting when false.  The semantics being that of assert.

A: If you're using gcc, you should be able to use the __FILE__, __LINE__, and __FUNCTION__ preprocessor macros, and pass them to your verify() routine to issue more useful debugging messages.  As tadman points out in his comment, it might make sense to define a macro that acts as a wrapper for verify(), capturing the file, line, and function information before passing it to verify().  Then, at the point of use, you only need to call the wrapper and pass in the expected argument, letting the preprocessor fill in the extra information while it's still available in context, then passing it all to your verify() function.

A: One solution is to modify the code like this:
void verify(int expected, char * str)
{
    if (expected < 10) {
        fprintf(stderr,"Verification failed for %d\n", expected);
        if(str)
            fprintf(stderr, str);
        abort();
    }
}

With this approach, you'll need to modify all calls. A way to get around that is to rename the function to verify_aux or something, and then write this:
void verify(int expected)
{
    verify_aux(expected, NULL);
}

This way, you could change verify to verify_aux if you feel the need to do so at a particular point.


text:
Q: SMS received broadcastReceiver is not called when app is not running I am using a broadcastReceiver to listen SMS received even when app is not running. It is working fine on Kitkat even app is removed from recent Apps, But not on Lollipop and higher devices.
In Manifest It is defined like this.
 <receiver
        android:name=".receivers.MxSMSReceiver"
        android:enabled="true"
        android:exported="true"
        android:permission="android.permission.BROADCAST_SMS">
        <intent-filter android:priority="5822">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            <action android:name="android.provider.Telephony.SMS_SENT" />
        </intent-filter>
    </receiver>

Receiver code:
public class MxSMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {

    if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED") || intent.getAction().equals("android.provider.Telephony.SMS_SENT")) {

   }
  }
 }

I don't know what is the problem. Any help is appreciated

A: Full working demo Runtime Permissions
Change the permission name which you want to get at runtime.
private String permission = Manifest.permission.RECEIVE_SMS;

Those permssions which you want to get at runtime should also be declared in
  manifest too.

public class MainActivity extends AppCompatActivity {

    private Context context;
    private Button button;
    private static final int REQUEST_RUNTIME_PERMISSION = 123;
    private String permission = Manifest.permission.RECEIVE_SMS;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override

            public void onClick(View v) {
                if (CheckPermission(MainActivity.this, permission)) {
                    // you have permission go ahead
                    YouCanReadContactNow();
                } else {
                    // you do not have permission go request runtime permissions
                    RequestPermission(MainActivity.this, permission, REQUEST_RUNTIME_PERMISSION);
                }
            }
        });
    }

    private void YouCanReadContactNow() {
    }

    @Override
    public void onRequestPermissionsResult(int permsRequestCode, String[] permissions, int[] grantResults) {

        switch (permsRequestCode) {
            case REQUEST_RUNTIME_PERMISSION: {
                if (grantResults.length > 0
                        && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    // you have permission go ahead
                    YouCanReadContactNow();
                } else {
                    // you do not have permission show toast.
                }
                return;
            }
        }
    }

    public void RequestPermission(Activity thisActivity, String Permission, int Code) {
        if (ContextCompat.checkSelfPermission(thisActivity,
                Permission)
                != PackageManager.PERMISSION_GRANTED) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
                    Permission)) {
            } else {
                ActivityCompat.requestPermissions(thisActivity,
                        new String[]{Permission},
                        Code);
            }
        }
    }

    public boolean CheckPermission(Context context, String Permission) {
        if (ContextCompat.checkSelfPermission(context,
                Permission) == PackageManager.PERMISSION_GRANTED) {
            return true;
        } else {
            return false;
        }
    }
}

layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/base"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="horizontal">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_margin="10dp"
        android:text="Request contact permissions"
        android:textSize="20dp" />

</RelativeLayout>

A: Make sure from the following :

 android:minSdkVersion="your min"
 android:targetSdkVersion="your max" />

<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS"/>


text:
Q: Why do we only check up to the square root of a prime number to determine if it is prime? Can't we use cube root? If a number n can be written as axb and m=sqrt(n). Here n=m*m. We say we only need to check upto m because min(a,b)<=m. So cant we take cube roots? Suppose we take n=21, then n=1x3x7. But Cube root is 2. Why does this method fail?

A: Consider n = 143 = 11 * 13. The cube root of 143 is between 5 and 6. If you only test divisibility by the primes up to 6, you will not find either of the two factors of n and will mistakenly conclude that 143 is prime.


text:
Q: Serial communication design pattern I'm  currently assigned to a task to develop a software module to communicate with a stepper motor controller. The project is written in C#, I have a C++ dll to communicate with the controller. The communication runs via the Serial port. I'm planning to write the whole piece in C# by importing the necessary methods by DllImport. The key method looks something like :
ComSendReceive(pHandle, bufferIn,sizeBufferIn,bufferOut,ref bufferOut)

There are several types of messages :

*

*You send message and expect confirmation (not the same for every message, sometimes it's OK, sometimes it's COMPLETE etc..

*You send message and receive message - you can receive an error or data (for instance GET_CONTROLLER_ID)

*Several other types

Of course I need to control the communication for time-outs.
My question is: Is there any "design pattern" to use for that kind of problem? I'm sure this is quite a common problem many developers have solved already.
To contribute a little - I dealt with similar problem in my last job and I solved it this way :
I had a class to communicate with the Com port and a class AT_message with bunch of overloaded constructors :
class AT_Message
{
    public bool DoResponseCheck;
    public string ExpectedResponse;
    public AT_COMMAND command;
    public string data;
    public bool AddCarriageReturn;
    ...

    //Plenty of ctors
}

class UnfriendlyInterface
{
     Response SendMessage(AT_Message msg)
     {
         //Communicates directly with C++ dll, send message, check timeouts etc....
     }
}

And I had a class the main application was communicating with, it had human friendly methods like
class FriendlyInterface
{
     bool AutodetectPortAndOpenComm();

     Result AnalyzeSignal(byte[] buffer)
     {
         Response response = UnfriendlyInterface.SendMessage(new Message(AT_Command.PrepareForSignal, (doResponseCheck)true, ExpectedResponse.Ok,Timeout.short);
         Response response = UnfriendlyInterface.SendMessage(new Message(buffer,(doResponseCheck)false,Timeout.long);

         //.... Other steps
     }

     //... other methods

}

Since last time I was really in a big hurry, I implemented first solution that came to my mind. But is there a way to do it better? Now the device I'm communicate with is more complex than the previous one so if there's a way how to do it better, I'd like to do it that way.

A: This seems like a textbook facade pattern.  The answer to all of this is to encapsulate your variation.  For example, try to create a generic interface for commands that give an acknowledgement, and write client code to use that interface.  Then concrete types can decide how to interpret various acknowledgements into a uniform signal (Ok = Complete = Good, or whatever)
Here's a good article on the facade pattern.  Also see the wikipedia article.


text:
Q: Logically speaking, why can variables be substituted? Suppose that
$$a^2+a+1=b$$
Suppose also that $a=5/4$. What makes it valid to substitute $5/4$ into the first equation? Is it because equality is transitive?

A: The reason why you can make such a substitution is that $a$ and $\dfrac{5}{4}$ are precisely the same, just written differently. Here's a long-winded way of making the substitution you describe.
\begin{align*}
a &= \frac{5}{4} & \\
a^2 &= \left(\frac{5}{4}\right)^2 &\text{squaring both sides}\\
a^2 + a &= \left(\frac{5}{4}\right)^2 + \frac{5}{4} &\text{adding the first two lines}\\
a^2 + a + 1 &= \left(\frac{5}{4}\right)^2 + \frac{5}{4}+1 &\text{adding $1$ to both sides}\\
b &= \left(\frac{5}{4}\right)^2 + \frac{5}{4}+1 &\text{using the fact that $a$ satisfies the given equation}
\end{align*}
The right hand side is precisely what you obtain when you replace $a$ by $\dfrac{5}{4}$.

A: It's just a basic principle of first-order logic with equality that if $a = b$ and $P(b)$ for a formula $P$, then $P(a)$. It's probably the most important aspect of equality that usually "goes without saying" in mathematics, except in logic courses.

A: There are at least two ways to understand equality.
One way to treat it is as a primitive logical identity sign: $a=b$ means that '$a$' and '$b$' are signs for the same thing.  Since they represent one and the same object, any property that can be proved of the object represented by $a$ must also hold of the object represented by $b$, because they are the same object. In this case one automatically gets a general substitution principle: $a$ can be replaced by $b$ because they mean the same thing: they are names for the same object.
Another way to proceed is the way that ZF set theory does, and to take equality as a defined property.  For example, ZF says that '$a=b$' is an abbreviation for $$\forall x(x\in a\iff x\in b).$$
Two sets are defined to be equal if they contain the same elements.  If one does this, substitution must be asserted axiomatically, or proved as a theorem.  Without such a proof (trivial if substitution is an axiom) it might or might not hold. Transitivity is similar.
But the usual understanding in algebra is the first type: when we write something like '$x = \frac54$' we mean that the name '$x$' is a synonym for whatever object is denoted by $\frac54$.


text:
Q: jQuery get numbers inside paragraph, but not those in classes I have the following HTML structure:

somecontent

another content content 1234214

I want to wrap only numbers in additional span (1234214). So far I've made this:
jQuery(window).load(function() {
  jQuery('.content p').html(function(index, value) {
    return value.replace(/(\d+)/g, '$1');
  });
});

However this replaces the 1 in span id. How can I exclude checking element attributes?

A: You might want not only to exclude attributes (think about the h1-element for example) but constrain your replacing on the text nodes. See this questions for some ideas on how to get only and work with text nodes: How do I select text nodes with jQuery?
This answer in above question How do I select text nodes with jQuery? gives you a collection of text-nodes on which you can do your string-replacing.

A: You should use .contents() and .replaceWith() for this:
jQuery('.content p').contents().each(function() {
    var method = this.nodeType == 1 ? 'html' : 'replaceWith';
    $(this)[method](this.textContent.replace(
        /(\d+)/g,
        '$1'
    ));
});

Here's a JSFiddle.

A: Long and hard solution, but should work in nested elements.
The idea is to handle element's .html() string character by character, wrapping numbers when they are found, but omitting numbers inside tags' definition.
Fiddle.
$(document).ready(function()
{
    $('.content p').each(function()
    {
        $(this).html(handleHtml($(this).html()));
    });
});

function handleHtml(html)
{
    var resultHtml = "";
    var numberStr = "";
    var re = /[0-9]/;
    var isTag = false, quote = "";
    for (var i = 0; i < html.length; i++)
    {
        var char = html.substr(i, 1);
        if (!isTag && re.test(char))
        {
            numberStr += char;
        }
        else
        {
            if (numberStr)
            {
                resultHtml += wrapNumber(numberStr);
                numberStr = "";
            }
            resultHtml += char;
            if (isTag && !quote && (char == '"' || char == "'"))
            {
                quote = char;
            }
            else if (quote && quote == char)
            {
                quote = "";
            }
            if (char == '<')
            {
                isTag = true;
            }
            else if (!quote && char == '>')
            {
                isTag = false;
            }
        }
    }
    if (numberStr)
    {
        resultHtml += wrapNumber(numberStr);
    }
    return resultHtml;
}

function wrapNumber(number)
{
    return '' + number+ "";
}


text:
Q: When does the Yoast SEO filter hook wpseo_sitemap_urlimages fire? I am trying to attach a simple function to the Yoast SEO filter hook wpseo_sitemap_urlimages and get the function to run, but I cannot do so.  My code is:
function tp_filter_wpseo_sitemap_urlimages($images, $post_id) {
    error_log("test message");
    return $images;
}
add_filter('wpseo_sitemap_urlimages', 'tp_filter_wpseo_sitemap_urlimages');

To get this function to run, I have tried opening the following Yoast XML sitemaps:

*

*sitemap index (https://example.com/sitemap_index.xml)

*post sitemap (http://example.com/post-sitemap.xml)

*page sitemap (http://example.com/page-sitemap.xml)

My eventual goal with this is to add additional images to the Yoast post and page sitemaps (per these Yoast instructions).
The only support Yoast has offered for this is to direct me to this page.

A: What I wanted to say in my previous comment:
This hook is only fired when the sitemap is being built. After that, it's cached and always served from cache. That means you'll never see any change on the frontend because it's all cached.
To disable the cache you can use the following code during development:
add_filter( 'wpseo_enable_xml_sitemap_transient_caching', '__return_false' );

After that, the sitemap is never served from cache but always built when viewing the sitemap in the frontend. Then you'll see some changes.


text:
Q: Converting from DGN v7 to shapefile by GRASS plugin I read two comments in several topics about conversion from DGN files  to Esri shapefile
Both of these comments are interesting for me, but I seek to have them explained in more detail.
I have DGN file v7. I would like to convert it to ESRsri shapefile to work on QGIS with all attributes.
I tried to use the GRASS plugin, but it does not support DGN file to load into this, so how can I do that as someone said in his comment

First comment:

v7 is the most current .DGN support. Have you tried loading it into QGIS and exporting it from QGIS? You can do this by right clicking on the .DGN file and choosing Save As, but again, only up to .DGN v7

How can I find save as on the file? I did not understand this point.
Second comment:

I have been wanting to do the same thing, with the same issues. I have successful imported my DGN files into QGIS using the GRASS plugin. I used the v.in.ogr tool in Grass. It allows you to bring DGN files in as lines, points and polys.

Link :Converting from dgn to shp or dwg files using QGIS?

i could not find not v.in.ogr

A: You cannot open directly a DGN file in GRASS GIS. You can import it, but before you have to create a location (see: https://grass.osgeo.org/grass76/manuals/helptext.html) with the EPSG code (projection) of your DGN. You may create a new mapset also (beside the PERNAMENT).
After these steps start your GRASS session. You will see two windows. In the Layer Manager window select File/Import vector data/Import common vector formats [v.in.ogr] from the menu and select your DGN file and set the name of output vector map.
Depending on what you would like to do with those data, I suppose QGIS is an easier option to import DGN data (see: https://docs.qgis.org/3.4/en/docs/user_manual/managing_data_source/opening_data.html). From the point of view of QGIS DGN files are similar to DWG/DXF files.


text:
Q: How to animate color of QBrush I want to animate Color of QBrush. For more details see code below
That's my .h file
class Cell : public QObject, public QGraphicsRectItem
{
    Q_OBJECT
    Q_PROPERTY(QBrush brush READ brush WRITE set_Brush)
public:
    QBrush _brush() const;
    void set_Brush(const QBrush&);
    Cell(QGraphicsItem *parent = 0); //конструктор
}

That's my .cpp file
Cell::Cell(QGraphicsItem *parent)
    : QObject(), QGraphicsRectItem(parent)
{
    this->setRect(0, 0, Scale, Scale);
}

QBrush Cell::_brush() const
{
    return this->brush();
}

void Cell::set_Brush(const QBrush & brush)
{
    this->setBrush(brush);
}

and that's animation:
QPropertyAnimation* animation = new QPropertyAnimation(selectedCell, "brush");
animation->setDuration(10000);
animation->setStartValue(QBrush(QColor(255,0,0)));
animation->setEndValue(QBrush(QColor(0,255,0)));
animation->start();

But it doesn't work, nothing happens, color of brush is the same that was before. What should I do to fix it?

A: QT does not know how to perform a transition between the start QBrush and the end QBrush. QBrush has more properties than just color, you could envisage an animation where the color stays the same and only the pattern changes. Thus there is no default support for this kind of transition.
As @fscibe hinted, you can write your own method to perform a transition in which you specify how you want to transition from one QBrush to the other.
Crude example:
QVariant myColorInterpolator(const QBrush &start, const QBrush &end, qreal progress)
{
  QColor cstart = start.color();
  QColor cend = end.color();
  int sh = cstart.hsvHue();
  int eh = cend.hsvHue();
  int ss = cstart.hsvSaturation();
  int es = cend.hsvSaturation();
  int sv = cstart.value();
  int ev = cend.value();
  int hr = qAbs( sh - eh );
  int sr = qAbs( ss - es );
  int vr = qAbs( sv - ev );
  int dirh =  sh > eh ? -1 : 1;
  int dirs =  ss > es ? -1 : 1;
  int dirv =  sv > ev ? -1 : 1;

  return QBrush(QColor::fromHsv( sh + dirh * progress * hr,
                             ss + dirs * progress * sr,
                             sv + dirv * progress * vr), progress > 0.5 ? Qt::SolidPattern : Qt::Dense6Pattern  );

}

this performs a transition in the colors but also changes the pattern halfway through the transition.
Then here would be a dummy application of this transition in your code:
int main(int argc, char** argv)
{
  QApplication app(argc,argv);
  QGraphicsView *view = new QGraphicsView;
  QGraphicsScene *scene = new QGraphicsScene;
  QDialog *dialog = new QDialog;
  QGridLayout *layout = new QGridLayout;
  layout->addWidget(view);
  view->setScene(scene);
  scene->setSceneRect(-500,-500,1000,1000);
  dialog->setLayout(layout);
  dialog->show();

  Cell *selectedCell = new Cell;
  scene->addItem(selectedCell);

  qRegisterAnimationInterpolator<QBrush>(myColorInterpolator);
  QPropertyAnimation* animation = new QPropertyAnimation(selectedCell, "brush");
  animation->setDuration(10000);
  animation->setStartValue(QBrush(Qt::blue));
  animation->setEndValue(QBrush(Qt::red));
  animation->start();

  return app.exec();
}

Obviously this is dummy example and for the color change it is re-inventing the wheel as you see from fscibe answer, but this is to show you that defining your own transition method for e.g. QBrush you can do more than simply change the color.

A: You must provide your own implementation for interpolating on QBrush type.
From Qt's doc:
"QPropertyAnimation interpolates over Qt properties. As property values are stored in QVariants, the class inherits QVariantAnimation, and supports animation of the same variant types as its super class."
(http://qt-project.org/doc/qt-4.8/qpropertyanimation.html)
See the list of supported types and an example of how to implement a custom interpolation here in the "Detailed Description" section:
http://qt-project.org/doc/qt-4.8/qvariantanimation.html
An alternative would be to interpolate between QColors only, and then update your brush:
class Cell : public QObject, public QGraphicsRectItem
{
    Q_OBJECT
    Q_PROPERTY(QColor color READ _color WRITE set_Color)
public:
    Cell()
    {
        setRect(0,0,100,100); // non-zero rect
        m_brush.setStyle(Qt::SolidPattern); // fill color is active
    }

    QColor _color() const
    {
        return brush().color();
    }
    void set_Color(const QColor& c)
    {
        m_brush.setColor(c);
        setBrush( m_brush );
    }

    QBrush m_brush;
};

With animation:
QPropertyAnimation* animation = new QPropertyAnimation(selectedCell, "color");
animation->setDuration(10000);
animation->setStartValue(QColor(255,0,0));
animation->setEndValue(QColor(0,255,0));
animation->start();


text:
Q: Bootstrap col doesn't work with Full Page JS I want to use Fullpage JS together with Bootstrap. However when I make two elements with col-lg-6 classes inside a full page section, they stack vertically and not horizontally on a large screen. Does anyone know how to fix this so my bootstrap columns are full width and stack horizontally next to each other like normally?

Test

Another test

    Test

A: Make sure you have included the bootstrap css. Adding the stylesheet solved your issue for me. Then, be aware that the two columns will only show up on large screens as defined by col-lg. I also tested it with the fullpage js plugin which was fine.
See the below code snippet for the stylesheet import and be aware that I changed col-lg-6 to col-6 so that the preview on the small viewport here on StackOverflow would show the columns.

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

Test

Another test

    Test


text:
Q: Typo3 Powermail: false spam alert with required fields I have a powermail form. I get the following error when I submit the form:
Spam recognized: uid11 This field must be filled!
Spam recognized: uid12 This field must be filled!
Spam recognized: uid14 This field must be filled!
Spam recognized: uid13 This field must be filled!

The fields uid11 ... uid14 do exist in the form - and they are transmitted to the server. For example (from Chrome network tab):
Testvalue
------WebKitFormBoundaryIIcUvgTthzftQYb6
Content-Disposition: form-data; name="tx_powermail_pi1[field][uid12]"

The 4 fields which are claimed are mandatory (required) but have no other rules added.
I have already tried to disable the spam check, but without any success:
plugin.tx_powermail.settings.setup.spamshield._enable = 0

A: Hat the same problem a couple of weeks ago, Disabled the spamshield helped. Later I just disabled badword filter. seems to work for me (check if spamshield is rly disabled in TypoScript Object Browser)

A: I found out that in table tx_powermail_domain_model_field the field for "marker"was empty. I have no idea why I have to add a marker variable, but since I added variable names (like "e_mail", "firstname", etc.) the form works.


text:
Q: Javascript change place of array element I have nested array in javascript like this:
testArray['element1'] = {par1: "value1", par2: "value2" ... }
testArray['element2'] = {par1: "value1", par2: "value2" ... }
testArray['element3'] = {par1: "value1", par2: "value2" ... }
testArray['element4'] = {par1: "value1", par2: "value2" ... }

so how can I change place of element? for example instead of
("element1", "element2", "element3","element4")
to be
("element4", "element2", "element3","element1")
or
("element1", "element4", "element3","element2")

A: First, build the object properly:
array = {
  'element1' : {par1: 'value1', par2: 'value2', par3: 'value3'....},
  'element2' : {par1: 'value1', par2: 'value2', par3: 'value3'....},
  'element3' : {par1: 'value1', par2: 'value2', par3: 'value3'....},
  'element4' : {par1: 'value1', par2: 'value2', par3: 'value3'....}
}

Then swap:
var tmp = array['element2'];
array['element2'] = array['element1'];
array['element1'] = tmp;

A: What you've posted in your question is not an array, it's not even valid javascript syntax. Since you ask about order, I'll assume you are not using objects as objects in javascript have no guaranteed order.
That being said, I'm going to assume you have an array declared as such:
var testArray = [{ ... }, { ... }, { ... }];

To swap two elements, you just need a generic swap function:
var swap = function(theArray, indexA, indexB) {
    var temp = theArray[indexA];
    theArray[indexA] = theArray[indexB];
    theArray[indexB] = temp;
};

swap(testArray, 0, 1);

http://jsfiddle.net/jbabey/gRVn5/

A: you can add it as an array prototype like so:
Array.prototype.swap = function (index1, index2) {
    if (index1 <= this.length && index2 <= this.length) {
        var temp = this[index2];
        this[index2] = this[index1];
        this[index1] = temp;
    }
};

A: arr = [0,1,2,3];
a = arr[3];
arr[3] = arr[0];
arr[0] = a;

A: I'd just write a swap function.
var letters = "abcdefghijklmnopqrstuvwxyz".split("");

function swap(theArray, index1, index2) {
  var temp = theArray[index2];
  theArray[index2] = theArray[index1];
  theArray[index1] = temp;
}

swap(letters, 2, 25); // swap "c" and "z"

A: You can now do:
let list = [1,2,3,4];
[list[1],list[3]] = [list[3],list[1]];

//Result: [1,4,3,2]


text:
Q: Sandbox - killall Operation not permitted I'm writing a small Mac application (in Obj-C) which runs the following command:
system("killall Finder");

I wanted to see what would happen if I sandbox the app (as sandboxing will be required on June 01), and the app wouldn't work. I got the following response:
killall: warning: kill -TERM 6524: Operation not permitted

Is there any way to get around that? As in a specific entitlement to add or another way to run the command?
Thanks in advance.

A: Your app completely goes against the spirit of the sandbox, so there's almost no chance that the MAS reviewers will accept it. Also, you may be surprised at what "defaults write com.apple.finder" does from inside your sandbox—basically, nothing useful. You'll have to use a temporary exception entitlement to home-relative /Library/Preferences/com.apple.finder.plist, use some non-sandbox-affected API to get the path to home (e.g., getpwent()->pw_dir), and load and save the plist directly. And then you'll discover that there is no way to call on a non-child process from a sandboxed app, period, no way around it—and if you try to system killall, it ends up running inside the same sandbox as you, and therefore has the same limitations.
However, you asked a specific question as to whether there's a way around that system killall failing, and there are at least three (not counting holes in the sandbox which have either been plugged by 10.7.4 or will surely be plugged soon):

*

*You can create a helper app that isn't sandboxed, that does the killall for you. The only two App Store-approved ways to do this are XPC and SMLoginItemSetEnabled. And you're not allowed to enable the helper without the user explicitly telling you to do so.

*You can send Finder an Apple Event asking it to quit, instead of signaling it. The easiest way to do this is to execute the Applescript 'tell app "Finder" to quit'. At least for 10.7.3 and earlier, you'll need a temporary exception entitlement to send Apple Events to com.apple.finder. (There may be different mechanisms for future OS versions, but nobody can discuss them outside the NDA forums.)

*You can send an Apple Event to some other process—like System Events—to kill Finder on your behalf.
And so on.

A: If you have a good reason you can still kill applications like this:
How can I terminate my app in a helper app with sanboxing enabled?


text:
Q: How much time passes in "Project Almanac"? In the movie Project Almanac there is plenty of time travel, and if I had to guess, based on the montage and some of the comments, the in-movie linear time was several months.  However, largely because of all the time travel, it is hard to be sure.
In terms of calendar time, how much time passes in the movie from the opening scene (David making the video of the drone for MIT) until right before David makes the final jump?

A: Near the beginning of the movie, we know it's February 18, 2014.

Chris: It is February 18th, 2014. My brother has officially lost his mind. He genuinely believes he is building a time machine.

Towards the end of the movie, we find out that it's April 23, 2014.

David: It's April 23rd, 2014. This is to keep a record. I know exactly what to do to fix this. Justin broke his leg at Walker's party. I'll fix that. Everything else will fall into place.

So only about two months elapse from the time they start building the time machine, to when things go off the rails.
From there it's impossible to know how much time passes from David's perspective, because we don't know how many times he goes back, or how long he stays each time. That's left purposely vague.

Jessie: How many times have you done this before? David, how many times have you done this before?

A: Kevin Workman's answer is correct, except for one thing: the movie shows David going back alone three times before the final jump:

*

*The first time is to change Lollapalooza

*the second time is to save the quarterback

*the third time is when Jessie got erased from existence.

We don't know how long he was in the past for with Lollapalooza and the third jump, but he went back alone three times for at least five minutes before the 2004 jump. See also this timeline.


text:
Q: Uncertainty powers In class, we are working with powers of uncertainties. The teacher, however, handed me an extremely technical article, and it makes very little sense. Could one please explain to me step by step how to solve this expression?
$$(1.234\pm0.001)^{\frac{1}{2}}$$
I appreciate any help granted

A: I like to think of uncertainties in the following form:
If $$a=b\pm c$$ then
$a^n=b^n\pm{(\frac{cn}{b})|b^n|}$
Hope that helps.


text:
Q: Mex function faster than identical C++ code When I run a program in C++, it runs slower than the identical program called by MATLAB using Mex functions.
I tried some sample code to test this, which confirmed my suspicion:
Using C++:
#include <stdio.h>
#include <ctime>

void process(int a[10000], int b[10000]) {
    const int dim[2] = {1, 10000};
    int barData[20000];
    clock_t begin = clock();
    for (int i = 0; i < dim[1]; i++) {
        for (int j = 0; j < i; j++) {
            barData[j] = a[i];
            barData[j] = b[i];
        }
    }
    clock_t end = clock();
    double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
    printf("%f\n", elapsed_secs);
}
int main() {
    int a[10000], b[10000];
    process(a,b);
    return 0;
}

Using Mex functions:
#include <stdio.h>
#include "mex.h"

void process(const mxArray *first, const mxArray *second) {
    int* a = (int *)mxGetData(first);
    int* b = (int *)mxGetData(second);

    const int *dim = mxGetDimensions(first);

    const int dims[2] = {1,dim[1]*2};

    mxArray* bar = mxCreateNumericArray(2, dims, mxINT64_CLASS, mxREAL);
    int* barData = (int*)mxGetData(bar);

    clock_t begin = clock();
    for (int i = 0; i < dim[1]; i++) {
        for (int j = 0; j < i; j++) {
            barData[j] = a[i];
            barData[j] = b[i];
        }
    }
    clock_t end = clock();
    double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
    printf("%f\n", elapsed_secs);
}

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
    process(prhs[0], prhs[1]);
}

And calling it from MATLAB as follows:
mex test.cpp -output foo
foo(rand(1,10000), rand(1,10000))

Mex function gives ~0.012s while C++ code gives 0.108s. The trends scale for larger array sizes too. Why is this, and is there a way to make the C++ code run with the Mex function speed?

A: As @Praetorian states in a comment above, you are probably not doing optimization on the C++ code.
Here is what the LLVMIR (pseudo-assembly) of your code is without optimization:
; ModuleID = 'test.cpp'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@_ZZ7processPiS_E3dim = internal constant [2 x i32] [i32 1, i32 10000],     align 4
@.str = private unnamed_addr constant [4 x i8] c"%f\0A\00", align 1

; Function Attrs: uwtable
define void @_Z7processPiS_(i32* %a, i32* %b) #0 {
  %1 = alloca i32*, align 8
  %2 = alloca i32*, align 8
  %barData = alloca [20000 x i32], align 16
  %begin = alloca i64, align 8
  %i = alloca i32, align 4
  %j = alloca i32, align 4
  %end = alloca i64, align 8
  %elapsed_secs = alloca double, align 8
  store i32* %a, i32** %1, align 8
  store i32* %b, i32** %2, align 8
  %3 = call i64 @clock() #3
  store i64 %3, i64* %begin, align 8
  store i32 0, i32* %i, align 4
  br label %4

; <label>:4                                       ; preds = %34, %0
  %5 = load i32* %i, align 4
  %6 = load i32* getelementptr inbounds ([2 x i32]*             @_ZZ7processPiS_E3dim, i32 0, i64 1), align 4
  %7 = icmp slt i32 %5, %6
  br i1 %7, label %8, label %37

; <label>:8                                       ; preds = %4
  store i32 0, i32* %j, align 4
  br label %9

; <label>:9                                       ; preds = %30, %8
  %10 = load i32* %j, align 4
  %11 = load i32* %i, align 4
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %13, label %33

; <label>:13                                      ; preds = %9
  %14 = load i32* %i, align 4
  %15 = sext i32 %14 to i64
  %16 = load i32** %1, align 8
  %17 = getelementptr inbounds i32* %16, i64 %15
  %18 = load i32* %17, align 4
  %19 = load i32* %j, align 4
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [20000 x i32]* %barData, i32 0, i64 %20
  store i32 %18, i32* %21, align 4
  %22 = load i32* %i, align 4
  %23 = sext i32 %22 to i64
  %24 = load i32** %2, align 8
  %25 = getelementptr inbounds i32* %24, i64 %23
  %26 = load i32* %25, align 4
  %27 = load i32* %j, align 4
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [20000 x i32]* %barData, i32 0, i64 %28
  store i32 %26, i32* %29, align 4
  br label %30

; <label>:30                                      ; preds = %13
  %31 = load i32* %j, align 4
  %32 = add nsw i32 %31, 1
  store i32 %32, i32* %j, align 4
  br label %9

; <label>:33                                      ; preds = %9
  br label %34

; <label>:34                                      ; preds = %33
  %35 = load i32* %i, align 4
  %36 = add nsw i32 %35, 1
  store i32 %36, i32* %i, align 4
  br label %4

; <label>:37                                      ; preds = %4
  %38 = call i64 @clock() #3
  store i64 %38, i64* %end, align 8
  %39 = load i64* %end, align 8
  %40 = load i64* %begin, align 8
  %41 = sub nsw i64 %39, %40
  %42 = sitofp i64 %41 to double
  %43 = fdiv double %42, 1.000000e+06
  store double %43, double* %elapsed_secs, align 8
  %44 = load double* %elapsed_secs, align 8
  %45 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x     i8]* @.str, i32 0, i32 0), double %44)
  ret void
}

; Function Attrs: nounwind
declare i64 @clock() #1

declare i32 @printf(i8*, ...) #2

; Function Attrs: uwtable
define i32 @main() #0 {
  %1 = alloca i32, align 4
  %a = alloca [10000 x i32], align 16
  %b = alloca [10000 x i32], align 16
  store i32 0, i32* %1
  %2 = getelementptr inbounds [10000 x i32]* %a, i32 0, i32 0
  %3 = getelementptr inbounds [10000 x i32]* %b, i32 0, i32 0
  call void @_Z7processPiS_(i32* %2, i32* %3)
  ret i32 0
}

attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-    pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-    math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8"     "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind "less-precise-fpmad"="false" "no-frame-    pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-    math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8"     "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-    elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-    nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-    math"="false" "use-soft-float"="false" }
attributes #3 = { nounwind }

!llvm.ident = !{!0}

!0 = !{!"clang version 3.6.2 (tags/RELEASE_362/final)"}

Notice that Z7processPiS is very long.
Here is with optimization -O3 (which is generally safe in C++ nowadays):
; ModuleID = 'test.cpp'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = private unnamed_addr constant [4 x i8] c"%f\0A\00", align 1

; Function Attrs: nounwind uwtable
define void @_Z7processPiS_(i32* nocapture readnone %a, i32* nocapture readnone %b) #0 {
  %1 = tail call i64 @clock() #2
  %2 = tail call i64 @clock() #2
  %3 = sub nsw i64 %2, %1
  %4 = sitofp i64 %3 to double
  %5 = fdiv double %4, 1.000000e+06
  %6 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x     i8]* @.str, i64 0, i64 0), double %5)
  ret void
}

; Function Attrs: nounwind
declare i64 @clock() #1

; Function Attrs: nounwind
declare i32 @printf(i8* nocapture readonly, ...) #1

; Function Attrs: nounwind uwtable
define i32 @main() #0 {
  %1 = tail call i64 @clock() #2
  %2 = tail call i64 @clock() #2
  %3 = sub nsw i64 %2, %1
  %4 = sitofp i64 %3 to double
  %5 = fdiv double %4, 1.000000e+06
  %6 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x     i8]* @.str, i64 0, i64 0), double %5) #2
  ret i32 0
}

attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-    pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false"     "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-    float"="false" }
attributes #1 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-    elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-            protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false"         }
attributes #2 = { nounwind }

!llvm.ident = !{!0}

!0 = !{!"clang version 3.6.2 (tags/RELEASE_362/final)"}

P.S.: It would be more idiomatic to write:
#include <iostream>
#include <vector>
#include <ctime>

using std::vector;

void process(vector<int> a, vector<int> b) {
    const pair<int,int> dim = {1, 10000};
    vector<int> barData(20000,0);
    clock_t begin = clock();
    for (int i = 0; i < dim.second; i++) {
        for (int j = 0; j < i; j++) {
            barData[j] = a[i];
            barData[j] = b[i];
        }
    }
    clock_t end = clock();
    std::cout << double(end-begin)/CLOCKS_PER_SEC << '\n';
}

int main() {
    vector<int> a(10000, 0), b(10000,0);
    process(a,b);
    return 0;
}


text:
Q: Why is tput failing silently on TERM=vt100 I'm using zsh with iTerm as my terminal emulator on macOS and my environment has TERM=xterm-256color by default.
If I run tput setaf 3 it exits with code 0.
If I set TERM=vt100 and run tput setaf 3 it exits with code 1 (indicating failure).
Why is this the case?

A: vt100 has no setaf capabilities which tput notices and fails on. The definitions can be found in the terminfo(5) database:
% TERM=xterm-256color infocmp | grep setaf
        setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
% TERM=vt100 infocmp | grep setaf
%

A vt100 is rather old and the manual mentions nothing about supporting such fancy things as colors (apparently there were different colors for the floor mats you could purchase with a vt100...).

A: VT100s never did color (see ncurses FAQ).  So the terminal description lacks the feature, and as documented, tput returns an error.
When the vt100 was introduced in 1976, color was a costly feature, not used on commodity terminals.  Color was standardized a few years later (at least, ECMA-48 edition 2 in 1979 provides this information; edition 1 is unavailable for inspection).


text:
Q: Translating titles with ctex As best as I can understand, there are two ways to load the ctex package: as a document class (i.e. \documentclass{ctexbook} or as a package (i.e. \usepackage{ctex}). As I am using another document class, I have selected the later. This means, however, that the document uses English for titles throughout the document (e.g. table of contents, glossary).
When I try to rename the titles of parts of the documents, using \CTEXoptions, this always fails. E.g.:
\documentclass{book}
\usepackage{ctex}
\usepackage{xeCJK}
\usepackage{fontspec}
\CTEXoptions[contentsname={目录名}]
\begin{document}
    \tableofcontents
    \chapter{This is a chapter title}
\end{document}

This fails to compile:
! Package xkeyval Error: `contentsname' undefined in families `CTEX'.

See the xkeyval package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.6 \CTEXoptions[contentsname={目录名}]

*

*How can I properly set the names of these items in my document?

contentsname 目录名
listfigurename 表格目录
listtablename 插图目录
figurename 图
tablename 表
abstractname 摘要
indexname 索引
bibname 参考文献

A: Load the ctexcap package instead of ctex. This will automatically redefine the strings you mentioned in your question. The command \CTEXoptions[contentsname={目录名}] will also then work.
P/S: Surely 目录名 is wrong?

A: This is a long comment of LianTze Lim's answer.

*

*Load ctexcap package for other document classes. But you should only load ctexcap for those document classes based on standard article, report and book. For example, you can use ctexcap together with extarticle and ltxdoc, but you should NOT use ctexcap with beamer, scrartcl or moderncv. Actally ctexcap is rarely used.
(EDIT: Well, it doesn't matter)

*You don't need to use xeCJK and fontspec explictly when you use ctex bundle.

*目录名 should be 目录.

*You are welcome to ask this kind of questions in CTeX forum.


text:
Q: Can't change to Nvidia drivers Ubuntu18.04 In the few days since this LTS release I've clean installed 3 times! The first time I thought I'd messed up the install when my screen kept frezing. The mouse cursor would still move but not work on anything. No key combinations would work either. Nvidia driver choice would always revert to nouveau.
The second time I tried the ppa of experimental nvidia drivers. Then aborted their installs with errors.
Now I'm on this 3rd install. It freezes when I'm in a browser or not. Seems to be random. And still when I try to change to nvidia drivers it just reverts to the default - nouveau
I never had any problems with 16.04 LTS but I'd like to be able to use this new version, it looks good, when it doesn't freeze on me!
I have Nvidia geforce GTX 550ti
Edit-Update- I was still having freezing with Xorg Nouveau but I tried changing to Nvidia driver again.This time, after clicking apply changes I left the window open and came back in 15 min. The change to Nvidia worked and seems to have stayed.


text:
Q: How do I pull a specific variable from the SqlDataReader? I'm working on a currency conversion project, now I've built a little script to pull the conversion rates and descriptions out of my database, but I can't seem to find a way to pull the variable (Rate) out of the string the datareader has created.
Here is the code snippet:
            if (reader.HasRows)
                //The reader will only read the rows if the ISO code matches the options avalible within the DB
            {
                Console.WriteLine("Result Found!");
                while (reader.Read())
                {
                    Console.WriteLine("Rate: {0}\t Conversion Rate: {1}",
                                      reader[0], reader[1]);
                }
                reader.Close();
            }

Now I want the Rate variable which is a decimal without having to convert it or shove it in an adapter (I'm new at C#).
tl;dr
I want the output from "Rate: {0}" alone so I can use it to convert the currency's.
Any ideas?

A: The DataReader doesn't create a string.
You can call reader.GetDecimal(0).

A: have you tried
reader.ReadField<type>("fieldname") ?

EDIT:   Wow, I can't believe I forgot that this was not part of SqlDataReader :p, I was just looking at my implementation... code for this:
Extension:
public static T ReadField<T>(this IDataReader reader, String fieldname)
{
    return DB.ReaderField<T>(reader, fieldname);
}

DB.ReaderField:
public static T ReaderField<T>(IDataReader reader, String fieldname)
{
    try
    {
        int idx = reader.GetOrdinal(fieldname);
        if (reader.IsDBNull(idx))
        {
            return (T)default(T);
        }
        else
        {
            object o = reader.GetValue(idx);

            try
            {
                return (T)Convert.ChangeType(o, typeof(T));
            }
            catch
            {
                return (T)default(T);
            }
        }
    }
    catch { }

    return (T)default(T);
}

Sorry about the confusion :)


text:
Q: Displaying SubReport Data into a Microsoft Report Viewer Control with ASP.NET VB I've got the main report displaying just fine. Can't get the subreport to display data. Parameters are setup and linked appropriately, but still nothing. Am I missing something obvious? Is there a bug I'm not aware of? Anyone else fighting with this? I'm using Visual Web Developer Express 2008 on a SQL Express 2005 database.

A: Have you handled the SubreportProcessing event?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf Me.SubreportProcessingEventHandler
End Sub

Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As Microsoft.Reporting.WebForms.SubreportProcessingEventArgs)
    'TODO
End Sub

Here's a link to the MSDN page on this: click here


text:
Q: Unity 2022.2.0 'Removing null node error' in animator I am using Unity 2022.2.0b3 for my project and when I use the animator tab 3 errors appear.

Removing null node
UnityEditor.Graphs.Graph:OnEnable ()
Edge.toNode is null
UnityEditor.Graphs.Graph:OnEnable ()
Edge.fromNode is null
UnityEditor.Graphs.Graph:OnEnable ()

The error only appears if the animator tab is open when I run the scene. But it doesn't show up in different versions(like 2021).
So is this a error specific to the beta version(2022) or am I just doing something wrong?
Please ask for more information if needed. Really frustrated right now.

A: ... Report this to Unity? It's a beta, you shouldn't be using it for your main project.


text:
Q: SQL pivot table without using pivot function I need to convert a table from a standard table into a more summarized version. The rows should be based whether its the year 2013 or 2014. I was considering using a pivot but I don't believe its necessary. The code below fails because of the group by function of a column Ive just created is there a way to get around this?
CODE
CREATE VIEW -- select * from
    [03_rdm].[AR_LedgerByInvoice]
as
select [EY_Business_Unit]
        ,(Case when [AR_Fiscal Year] = 2014 then 'AR_Outstanding_Amount (CY)' else 'AR_Outstanding_Amount (PY)' end) [Aging_Bucket]
        , [AR_1-30 Days Past Due]
        , [AR_31-60 Days Past Due]
        , [AR_61-90 Days Past Due]
FROM [02_cdm].[0040_AR_InvoiceSummary_2013_2014]
GROUP BY [Aging_Bucket]

The end result should be:
DESIRED OUTPUT
Business Unit   Aged Bucket                [AR_1-30 Days]   [AR_31-60 Days] [AR_61-90 Days] Total
100 `           AR_Outstanding_Amount (CY)  x                xx             xxx             xxxx
100             AR_Outstanding_Amount (PY)  x                xx             xxx             xxxx

A: You can't group by an alias created on the same 'level' but you should be able to group by the same expression, but maybe you just want to group by year? (if so maybe GROUP BY [AR_Fiscal Year] is what you really want):
CREATE VIEW -- select * from
    [03_rdm].[AR_LedgerByInvoice]
as
select [EY_Business_Unit]
        ,(Case when [AR_Fiscal Year] = 2014 then 'AR_Outstanding_Amount (CY)' else 'AR_Outstanding_Amount (PY)' end) [Aging_Bucket]
        , [AR_1-30 Days Past Due]
        , [AR_31-60 Days Past Due]
        , [AR_61-90 Days Past Due]
FROM [02_cdm].[0040_AR_InvoiceSummary_2013_2014]
GROUP BY
  [EY_Business_Unit],
  CASE WHEN [AR_Fiscal Year] = 2014 THEN 'AR_Outstanding_Amount (CY)' ELSE 'AR_Outstanding_Amount (PY)' END

As you didn't provide any sample data or table I couldn't test it, but it should work.
Or maybe you want to aggregate the rows:
select [EY_Business_Unit]
        ,(Case when [AR_Fiscal Year] = 2014 then 'AR_Outstanding_Amount (CY)' else 'AR_Outstanding_Amount (PY)' end) [Aging_Bucket]
        , SUM([AR_1-30 Days Past Due])
        , SUM([AR_31-60 Days Past Due])
        , SUM([AR_61-90 Days Past Due])
FROM [0040_AR_InvoiceSummary_2013_2014]
GROUP BY
[EY_Business_Unit]
        ,(Case when [AR_Fiscal Year] = 2014 then 'AR_Outstanding_Amount (CY)' else 'AR_Outstanding_Amount (PY)' end)
order by [EY_Business_Unit];


text:
Q: Pygame window freezes and stop responding, how could I fix this? I am creating a game but I am having a problem with my button class for my gui. There are no compile errors and no runtime errors either. The only problem is that on run it immediately freezes the pygame window. I don't know how to solve this.
I've tried fiddling around with the callback function (which I removed entirely) and with the update and draw loop as well but nothing seems to work.
Python 3.7.0 and Pygame 1.9.4
Button Class:
import sys
import time
import pygame
pygame.init()

class button:
    def __init__(self, txt, location, bg=(255,255,255),fg=(0,0,0),size=(80,30),font_name="Times New Roman",font_size=16):
        #bg is the colour of the button
        #fg is the colour of the text
        #location refers to the center points of the button
        self.colour = bg
        self.bg = bg
        self.fg = fg
        self.size = size
        self.font = pygame.font.SysFont(font_name,font_size)
        self.txt = txt
        self.txt_surf = self.font.render(self.txt, 1, self.fg)
        self.txt_rect = self.txt_surf.get_rect(center=[s//2 for s in self.size])
        self.surface = pygame.surface.Surface(size)
        self.rect = self.surface.get_rect(center=location)
    def mouseover(self):
        self.bg = self.colour
        pos = pygame.mouse.get_pos()
        if self.rect.collidepoint(pos):
            self.bg = (200,200,200)
    def draw(self, screen):
        self.mouseover()
        self.surface.fill(self.bg)
        self.surface.blit(self.txt_surf, self.txt_rect)
        screen.blit(self.surface, self.rect)

Actual update/draw loop
import gui
import pygame
import sys
import time
import win32api
pygame.init()

screen = pygame.display.set_mode((400,400))
button1 = gui.button("No", (200,200))
intro = True
while intro:
    screen.fill((255,255,255))
    button1.draw(screen)
    if win32api.GetKeyState(0x01) == -127 or win32api.GetKeyState(0x01) == -128:
        if button1.rect.collidepoint(pygame.mouse.get_pos()):
            intro = False
            pygame.quit()
            sys.exit()
    pygame.display.flip()
    pygame.time.wait(20)

I really just want the window to stop freezing up on run and to actually have a button press work. What it should do is immediately quit the application when you press the button in the middle. Not actually do that though.

A: You have to let pygame process the events in the event queue by calling pygame.event.get (or pygame.event.pump, but you should stick to use get).
Otherwise, the queue will fill up and new events will be dropped. This includes internal events that tell your OS to draw the window etc, so your window will freeze.
Also, there's no reason to use win32api to get the state of the keyboard (you can use pygame.key.get_pressed instead), but that's another topic.


text:
Q: Wrong date extraction from Spreadsheet I want to extract a date from a spreadsheet that is in a "DD dd/mm/yyyy hh:mm:ss" format and put it in another spreadsheet and afterwards create an event in calendar, the problem is that when it is extracted it gets a different time zone than the one from the original spreadsheet, and it changes with different documents. The Utilities.formatDate() command doesn't work for me because it appears in the correct time zone.
Cell value : mon. 02/04/2018 12:00:00
Original Spreadsheet time zone : GMT -800
New Spreadsheet time zone : GMT -800 (also)
function Event(){
  var firstdoc =SpreadsheetApp.openById("ID"); // ouvre le fichier manifest list
  var firstdocsheet = firstdoc.getSheetByName("sheet");
  var date1= new Date(firstdocsheet.getRange(4,10).getValue());
  Logger.log(date1);
  date1 = Utilities.formatDate(date1, "GMT-800", "dd-MM-yyyy HH:mm:ss");
  Logger.log(date1);
}

This is what I get:
Logger.log([Mon Apr 02 21:00:00 GMT+02:00 2018)
Logger.log([02-04-2018 11:00:00)
I know that the code works but I don't get why it takes the wrong date since the beggining, any help please ?

A: Verify your code with the example below:
function test() {
  var date = new Date('03/08/2018 09:51:00');
  Logger.log(date)
  Logger.log(Utilities.formatDate(date, "GMT-08:00", "dd-MM-yyyy HH:mm:ss"));
}

Log output:
[18-03-08 12:31:31:518 CET] Thu Mar 08 09:51:00 GMT+01:00 2018
[18-03-08 12:31:31:520 CET] 08-03-2018 00:51:00

The mechanism you're using seems to be right, so the problem is either in your cell value or the timezone as pointed out in the comment.


text:
Q: Jquery mobile forms and validation using Sqllite I am new to Jquery mobile and I wish to create a form which has Username and password in first HTML file and I need to store these datas in sqlite and retrieve an compare datas and if I enter the different login details ie..(Username and password) it should prompt an error message.
After completing the login I have to register the details and after the registration is completed,its gets stored in sqlite database and if we want to edit these details the edited details gets stored again in the database.
May I know the concept,methods and the reference so it will be helpful for me


text:
Q: How to find a curve which satisfies some properties?
Let $C$ be a curve in $\mathbb R^2$ passing through $(3,5)$ and $L(x,y)$ denote the segment of the tangent line to $C$ at $(x,y)$ lying in the first quadrant. Assuming that each point $(x,y)$ of $C$ in the first quadrant is the midpoint of $L(x,y)$, find the curve.

First I found the equation of the line whose line segment in first quadrant is $L(3,5)$, which is $5x+3y=30 \ [\text{ It is easy to find as (3,5) will be mid-point of the line}].$
From here how can we find the equation of the curve?
Any help is appreciated. Thnak you.

A: Let the curve be parametrized by $c(t) =\big(x(t), y(t)\big)$, where $c(0) = (3,5)$.
The tanget $T_t$ at $c(t)$ is given by the parametrization
\begin{align}
T_t(s)
&=
c(t) + s\cdot \big(x'(t), y'(t)\big)
\\&=
\Big(x(t) + s\cdot x'(t)\,, \,\,\,y(t) + s\cdot y'(t)\Big)
.\end{align}
Notice that near $t=0$, the curve lies on the first quadrant.
Near $t=0$, we may hence not have $x'=0$ or $y'=0$, for then the midpoint condition would be impossible to satisfy.
Then, for $t$ near $0$, $T_t$ crosses the $y$-axis when
$$s_{y, t} =  \frac{-y(t)}{y'(t)},$$
and $T_t$ crosses the $x$-axis when
$$s_{x, t} =  \frac{-x(t)}{x'(t)}.$$
The midpoint between them is $T_t\left(\frac12(s_{y,t} + s_{x,t})\right)$, and we have
\begin{align}
s_{y,t} + s_{x,t}
&=
\frac{-y(t)x'(t) -x(t)y'(t)}{x'(t)y'(t)}
\\
\\&=
-\,\frac{\frac{d}{dt}\big[x(t)y(t)\big]}{x'(t)y'(t)}.
\end{align}
For $t$ near $0$, we need to have
$$T_t\left(\frac12(s_{y,t} + s_{x,t})\right) = c(t),$$
which simplifies to
$$(s_{y,t} + s_{x,t}) \cdot \Big(x'(t), y'(t)\Big) = 0.$$
Since neither $x'$ nor $y'$ may be $0$, it follows that for $t$ near $0$ we must have
$$s_{y,t} + s_{x,t} = 0 \iff \frac{d}{dt}\big[x(t)y(t)\big] = 0
\iff x(t)y(t) \,\text{ is constant}$$
Substituting $t=0$ we get $x(0)y(0) = 15$, so the curve looks like
$$y = \frac{15}x,$$
at least in its domain of definition in the first quadrant.

A: The segment L, by definition, must cut the axes at points $(2x, 0)$ and $(0,2y)$ and the tangent at $(x, y)$ is given by the differential equation $\dfrac{dy}{dx}= \dfrac{ 2y}{-2x}$ whose solution is $y=\dfrac cx$. The constant $c$ is clearly $ 15$ so the curve $C$ has equation
$$xy=15$$  which is an equilateral hyperbola, symmetric with respect to the diagonal $y = x$ in which it is easy to verify that the tangential segment $L$ corresponding to the arbitrary point $(x, y)$ of the curve $C$ has extremes $(2x, 0)$ and $(0,2y)$.   This curve, in turn, it is well defined on the third quadrant.


text:
Q: Checar se campo preenchido automaticamente está "True" jQuery

Tenho o seguinte campos
<input type="text" value="" name="campo" id="campo">
<input type="text" value="" name="campoRecebeDados" id="campoRecebeDados">

E o seguinte jQuery:
$(document).ready(function(){

    function setar_valor(){
        var campo = $("#campo").val();
        $("#campoRecebeDados").val(campo);
    }

    $(document).on("keyup", "#campo", setar_valor);

});

No momento estou usando keyup, que seria no caso se o campo for preenchido, ele copia o valor para o campoRecebeDados, mas como eu sei (via código) que o campoRecebeDados foi preenchido?
Pensei em fazer:
if($("#campoRecebeDados")==true){
    alert('Preenchido')
}

Porém, se eu fizer desta forma, ele nunca vai ser true, porque o preenchimento value="" do campo sempre será o estágio inicial, não o que foi setado. (isso se vermos no código fonte);
Neste caso eu já preenchi um campo anterior, que preencheu este, mas como podem ver o value="" permanece inalterado.

A: Aí você teria que alterar o atributo value, que é uma propriedade do input:
$("#campoRecebeDados").attr("value", campo);

O .val() não altera essa propriedade, ele apenas pega ou altera o que tem dentro do campo, e isso já é suficiente para saber se o campo foi ou não preenchido.
E para verificar se o input possui alguma coisa, bastaria:
if($("#campoRecebeDados").val()){
    // possui algum valor
}

No caso de inputs, se o value inicial for vazio, não precisa nem colocar value="", porque o value já vem vazio por padrão.
Exemplo baseado no seu código:

$(document).ready(function(){

    function setar_valor(){
        var campo = $("#campo").val();
        $("#campoRecebeDados").val(campo);

      if($("#campoRecebeDados").val()){
         console.log("tem valor");
      }else{
         console.log("não tem valor");
      }
    }

    $(document).on("keyup", "#campo", setar_valor);

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="campo" id="campo">
<input type="text" name="campoRecebeDados" id="campoRecebeDados">

A: Tente
if( $("#campoRecebeDados").val().length > 0 ){}

Ou
if( $("#campoRecebeDados").val() != "" ){}