## An algorithm which efficiently generates random samples without replacement, from a large range [0-N], N ~ 10^12?

I want an algorithm which generates random integers, without replacement, from a large range [0-N], N~10^12.

However, the whole range should not be stored in memory. The memory footprint should be O(1) relative to N. The algorithm can (probably must) retain state after every sample request.

The randomness should be “strong” in the cryptographic sense.

## Is this correct : whether or not a type 3 grammar generates $\Sigma^*$ is not c.e

An example from Sipser’s book, Introduction to the Theory of Computation, shows that it is not decidable for a $$TM$$ to recognize whether a $$CFG$$ (or a type 2 grammar) generates $$\Sigma^*$$, where $$\Sigma$$ is the alphabet. Call this language $$CFG_{all}$$

But the above language is also not computably enumerable. There can be a reduction from $$CFG_{all}$$ to $$\bar{A_{TM}}$$, where $$\bar{A_{TM}}$$ is the language s.t. the input $$TM$$ does not accept any input. $$\bar{A_{TM}}$$ is not computably enumerable.

But could we say that whether or not a type 3 grammar generates $$\Sigma^*$$ is also not c.e. ? (since type 3 grammars are a subset of context-free grammars). While it is true that a finite automaton can recognize $$\Sigma^*$$, this language is different right from whether a type 3 grammar generates $$\Sigma^*$$?

Just to clarify the source of my confusion, in summary, it is decidable for a $$TM$$ to decide whether a pushdown automaton recognizes $$\Sigma^*$$ or accepts any input, but it is not decidable or even computably enumerable for a $$TM$$ to recognize that a CFG generates $$\Sigma^*$$. Similarly, it is decidable for a $$TM$$ to check if a finite automaton accepts $$\Sigma^*$$, but it may not be decidable for a $$TM$$ to check if a type 3 grammar generates $$\Sigma^*$$. It’s somehow the difference between recognizing and generating.

## Is it unsecured to use TOTP codes on the device that generates them?

Let’s say I have a TOTP generator app (like Google Authenticator) installed on my smartphone. I use it for 2FA for service X. How bad is it if I log in to X’s website/dedicated app on the same smartphone? Would I gain anything by using an airgapped phone dedicated for TOTP?

## Deciding whether CFG generates the empty word

Give an algorithm to decide the following problem: given a CFG $$G$$, does $$G\Rightarrow^\star \epsilon$$? That is, given a grammar can it generate the empty word? How can I make sure my algorithm is decidable?

## get_template_directory_uri() generates wrong path

I’ve uploaded a wordpress site but it’s missing javascript and css. The links on the head still have the local path (src='https://localhost...') and not the new ones. So I guess it has to do with get_template_direcory_uri() that I use in fucntions.php to apply my javascript/jquery,bootstrap,css etc.

How yo fix that?

define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] ); define( 'WP_HOME', 'http://' .$  _SERVER['HTTP_HOST'] ); 

and

define( 'WP_HOME', 'https://...' ); define( 'WP_SITEURL', 'https://...' ); 

but they didn’t help…

## Proving the decidability of whether a CFG generates a particular string or not

Let $$G$$ be a context-free grammar and $$w$$ be a string of length $$|w| = n$$.

Consider the language $$A_{CFG}$$ = { <$$G$$, $$w$$> | $$G$$ is CFG that generates $$w$$ }, where <$$G$$, $$w$$> is a string encoding of $$G$$ and $$w$$.

Now we have to show that $$A_{CFG}$$ is decidable, or in other words, there exists an algorithm that determines whether $$w$$ is generated by $$G$$ or not.

Now, the proof given in my book converts $$G$$ into an equivalent CFG $$G’$$ in Chomsky Normal Form and one-by-one checks all derivations in $$G’$$ that take $$2n – 1$$ steps, since a grammar in CNF takes exactly $$2n – 1$$ steps to generate a string of length $$n$$.

Now, I have an alternate algorithm in mind. I want you guys to tell me if there is something wrong with it or not because this one seems to be much simpler than the one given in my book.

So, since every CFG has a pushdown automaton which recognizes the same language, we convert the CFG into an equivalent PDA. Now we simulate the PDA on our Turing machine on the string $$w$$. This process must end in a finite number of steps since our string is finite in length.

Is this an alternate algorithm that illustrates the decidability of $$A_{CFG}$$ or is there something wrong with it?

## For my role playing game, I’m looking for something that generates future/sci fi tech ideas?

Does anybody know of a blog or site that generates ideas every week or so of future tech/ sci fi tech. I’m trying to find ideas.

## Magento 2 generates thousands of temp table queries on product update

I have a Magento 2.2.5 store with ~20k products and ~250 categories arranged in a tree of maximum 2 sub categories.

One of the top categories has 5k products and when I try to remove a product from the category, or remove the category for a specific product the server takes more than 2 minutes and times out.

After reading the general_log, I saw thousands of queries like this:

SELECT e.* FROM tmp_select_e5e424ef98e4a8a4026e18df9d8088e0 AS e WHERE (hash_key = '1_44083') 

peaking the database server to 100%:

I think this has something to do with url_rewrites, but I can’t seem to understand how is this a problem with only 5k products.

Are there any configurations I can set maybe loosing functionalities, to be able to do something as simple as removing a product from a category?

Thanks a lot.

## drush uli generates correct link but results in ‘Access Denied’

I have set up a Drush alias for my website (hosted on a shared hosting), the alias works correctly, because commands like drush status, drush cc all, etc. work. The problem comes with drush uli. It generates the one-time login link, the domain is correct, everything looks all right, but when entered into a browser, it results in standard Drupal

page.

Part of setting up the alias and some interesting issues around path-alias-es, relations to database settings, it’s usage and relevancy the aliases is originally discussed in Drush issues page on GitHub.

Technical information:

• This is a clean Drupal 7 installation, without contrib modules.
• I can log in using password (even using password set via drush upwd using the same alias).
• I have checked all possible sources (like truncating sessions table, etc.) discussed in similar but yet different issue on StackExchange.
• I have tried different browsers and cleared browser caches and cookies as suggested in various similar discussions on Drupal.org, all without luck.

Drush alias:

\$  aliases['myalias'] = array(   'uri' => 'mysite.com',   'root' => '/home/mysite.com/web',   'path-aliases' => array(     '%drush' => '/home/.composer/vendor/drush/drush',    ),   '%files' => '/home/mysite.com/web/sites/mysite.com/files', );  

The alias works correctly for other commands like clearing caches and drush status confirms that Drupal is bootstrapped correctly.

## A basis is a subset of the topology it generates

I know this question is very basic but I just wanted to be sure. I’m reading through Munkres’ Toplogy book, and he mentions that given a topology $$\tau$$ generated by some basis $$\mathcal{B}$$, each basis element is an element of the toplogy $$\tau$$. I just wanted to make sure I could prove this.

I need to show that given some $$B \in \mathcal{B}$$ and some $$x \in B$$, there exists some $$B’ \in \mathcal{B}$$ such that $$x \in B’ \subset B$$.

I want to use the definition of a basis: given any $$x \in B_1 \cap B_2$$ where $$B_1,B_2 \in \mathcal{B}$$, there exists some $$B_3 \subset B_1 \cap B_2$$ such that $$x \in B_3$$. In this case, I set $$B_1=B_2=B$$, and $$B’=B_3$$. But I’m not sure if this is legal, because the $$B_1,B_2$$ in this definition may have to be distinct. Munkres’ definition used the word “two”, but not distinct, which is where I’m unclear.

I’m also not sure if I’m allowed to set $$B’=B$$, or if I need to find some $$B’$$ strictly contained in $$B$$.

Thanks!