How to expand a CMD shell variable twice (recursively)

Thinking in terms of a less tortuous solution, this, too, produces the CCC you desire. setlocal enabledelayedexpansion set AAA=BBB set BBB=CCC for /F %%a in (‘echo %AAA%’) do echo !%%a! edit: to dissect this answer: setlocal enabledelayedexpansion – this will allow for any environment variable setting during your bat to be used as modified during … Read more

Powershell: What’s the difference between Alias and Function?

An alias in PowerShell allows you to define an alternative name for another command. Unlike in POSIX-compatible shells such as bash, you cannot include pass-through arguments in its definition – you need a function for that. The typical use case is to define a short alternative name for convenience of interactive invocation; for instance, PowerShell … Read more

is it possible to call a sql script from a stored procedure in another sql script?

There is a set of commands that are builtin to the mysql client. They’re documented under “mysql Commands.” These include DELIMITER, SOURCE, HELP, CONNECT, USE, QUIT, etc. The \. (or SOURCE) command is one of these builtins. You can’t execute these builtin commands programmatically, nor from within a stored procedure. It’d be like trying to … Read more

Loading script tags via AJAX

If you use jQuery’s .html method it parses out the script tag and evals it: $(“div”).html(‘<script type=”text/javascript”>alert(“This should work”)</script>’); If jQuery isn’t an option you could write this yourself using either (1) a regular expression, or (2) parse out the DOM tree and find script tags. (#2 is how jQuery does it)

Can PHP asynchronously use sockets?

Yup, that’s what socket_set_nonblock() is for. Your socket interaction code will need to be written differently, taking into account the special meanings that error codes 11, EWOULDBLOCK, and 115, EINPROGRESS, assume. Here’s some somewhat-fictionalized sample code from a PHP sync socket polling loop, as requested: $buf=””; $done = false; do { $chunk = socket_read($sock, 4096); … Read more