text:
Q: Get ld to pick the correct library I'm trying to compile a program prog and link it against OpenSSL's 1.0.2 beta, built from source and installed in /usr/local/ssl-1.0.2. On an older system using 0.9.8, this works without too much trouble. On a more recent system with 1.0.1 installed, this requires a bit more work. I'm wondering why.
1) On Ubuntu 10.04, with OpenSSL 0.9.8:
Here are the steps I follow to compile and link against 1.0.2.
$ ./config shared --openssldir=/usr/local/ssl-1.0.2 && make && make install
$ ldconfig
$ ldconfig -p | grep libcrypto

=> Only 0.9.8 files show up, so I add the path to the 1.0.2 files...
$ ldconfig /usr/local/ssl-1.0.2/lib
$ ldconfig -p | grep libcrypto

=>
 libcrypto.so.1.0.0 (libc6) => /usr/local/ssl-1.0.2/lib/libcrypto.so.1.0.0
 libcrypto.so.0.9.8 (libc6, hwcap: 0x0008000000008000) => /lib/i686/cmov/libcrypto.so.0.9.8
 libcrypto.so.0.9.8 (libc6, hwcap: 0x0004000000000000) => /lib/i586/libcrypto.so.0.9.8
 libcrypto.so.0.9.8 (libc6, hwcap: 0x0002000000000000) => /lib/i486/libcrypto.so.0.9.8
 libcrypto.so.0.9.8 (libc6) => /lib/libcrypto.so.0.9.8
 libcrypto.so.0.9.8 (libc6) => /usr/lib/libcrypto.so.0.9.8
 libcrypto.so (libc6) => /usr/local/ssl-1.0.2/lib/libcrypto.so

And so I can compile prog...
$ gcc -o prog ... -L/usr/local/ssl-1.0.2/lib -lcrypto
$ ldd prog

=>
    libcrypto.so.1.0.0 => /usr/local/ssl-1.0.2/lib/libcrypto.so.1.0.0 (0x0083b000)

... and it is correctly linked against 1.0.2.
2) On Debian Wheezy, with OpenSSL 1.0.1:
Same steps, different result.
$ ./config shared --openssldir=/usr/local/ssl-1.0.2 && make && make install
$ ldconfig
$ ldconfig -p | grep libcrypto

=>
 libcrypto.so.1.0.0 (libc6, hwcap: 0x0008000000008000) => /usr/lib/i386-linux-gnu/i686/cmov/libcrypto.so.1.0.0
 libcrypto.so.1.0.0 (libc6, hwcap: 0x0004000000000000) => /usr/lib/i386-linux-gnu/i586/libcrypto.so.1.0.0
 libcrypto.so.1.0.0 (libc6) => /usr/lib/i386-linux-gnu/libcrypto.so.1.0.0

Likewise, I add the path to 1.0.2...
$ ldconfig /usr/local/ssl-1.0.2/lib
$ ldconfig -p | grep libcrypto

=>
 libcrypto.so.1.0.0 (libc6, hwcap: 0x0008000000008000) => /usr/lib/i386-linux-gnu/i686/cmov/libcrypto.so.1.0.0
 libcrypto.so.1.0.0 (libc6, hwcap: 0x0004000000000000) => /usr/lib/i386-linux-gnu/i586/libcrypto.so.1.0.0
 libcrypto.so.1.0.0 (libc6) => /usr/local/ssl-1.0.2/lib/libcrypto.so.1.0.0
 libcrypto.so.1.0.0 (libc6) => /usr/lib/i386-linux-gnu/libcrypto.so.1.0.0
 libcrypto.so (libc6) => /usr/local/ssl-1.0.2/lib/libcrypto.so

Then I try to compile...
$ gcc -o prog ... -L/usr/local/ssl-1.0.2/lib -lcrypto
$ ldd prog

=>
    libcrypto.so.1.0.0 => /usr/lib/i386-linux-gnu/i686/cmov/libcrypto.so.1.0.0 (0xb7591000)

But here it is not linked against 1.0.2. The compile-time library path is correct (specified with -L, gcc would fail otherwise since some functions used in prog are specific to 1.0.2), but not the run-time one.
3) How to get it working on Wheezy
With or without running ldconfig /usr/local/ssl-1.0.2/lib:
$ gcc -o prog ... -Wl,--rpath=/usr/local/ssl-1.0.2/lib -L/usr/local/ssl-1.0.2/lib -lcrypto
$ ldd prog

=>
    libcrypto.so.1.0.0 => /usr/local/ssl-1.0.2/lib/libcrypto.so.1.0.0 (0xb7592000)

Alternatively, run export LD_LIBRARY_PATH=/usr/local/ssl-1.0.2/lib before running gcc.
What I'd like to know
Using LD_DEBUG=libs ./prog as suggested by mr.spuratic, I found that the paths were looked up in /etc/ld.so.cache. I opened that file and found that the order in which .so are looked up corresponds to the output of ldconfig -p.
So the actual question is:

*

*Why does the 1.0.2 file gets on top of ldconfig's list in 1) but not in 2) ?  Pure randomness? Confusion due to 1.0.1 and 1.0.2 files having the same suffix? ("1.0.0")

Or, said differently,

*

*Why are the flags added in 3) not necessary in 1) ?

A: There are three things you need to take care of when compiling/linking against a non-default package:

*

*headers  (usually CFLAGS)

*compile-time library path (usually LDFLAGS)

*run-time library path (rpath via LDFLAGS, LD_RUN_PATH, LD_LIBRARY_PATH or ld.so.conf)

You haven't said what prog is, so I can't how well-behaved its configuration might be (or if it uses autoconf?), I've seen many that only perform the first two steps reliably.
During the link stage the library path order is relevant, assuming you're using the GNU toolchain (gcc & binutils) you can probably see what's going on by setting CFLAGS before configure (or possible in the Makefile directly):
export CFLAGS="-Wl,-t"

This passes the -t trace option to the linker. You may need to add V=1 or VERBOSE=1 to the make command if you only get terse "CC" and "LD" lines output during the make.)
At run time you can see what ld.so tries by carefully setting LD_DEBUG, e.g.
LD_DEBUG=libs ./myprog

(or try values of files or symbols for more detail)
To specify all three parameters correctly at build time you should be able to do:

*

*export CFLAGS="-I/usr/local/ssl-1.0.2/include"

*export LDFLAGS="-L/usr/local/ssl-1.0.2/lib -R/usr/local/ssl-1.0.2/lib"
then reconfigure/recompile.
You're using --openssldir rather than the more conventional --prefix (I recommend the latter and also using just make install_sw if you don't need the 1000 or so man pages & symlinks a default install gives you). This may be part of the problem. For some reason the .so libraries that you show are known to ld.so do not have a version suffix (e.g. .so.1.0.2), a proper "make install" should have set that up for you (via the link-shared target in the main Makefile).
The -R option instructs the linker to embed an RPATH in the executable output for the specific OpenSSL library so that it does not need to rely on the default that the runtime linker (ld.so) would normally provide. You can modify existing binaries with chrpath instead.
This is more or less equivalent to exporting LD_LIBRARY_PATH=/usr/local/ssl-1.0.2/lib. You can read more about RPATH and the related RUNPATH here: http://blog.tremily.us/posts/rpath/
As a last resort you could possibly build OpenSSL without "shared" or with "noshared", this will give you static libraries which won't have this problem (but may well have other problems, e.g. for use within ELF .so, causing PIC/PIE problems)

Based on the updated details, I believe the problem is that 1.0.1 and 1.0.2beta both set the .so version suffix (SONAME) to 1.0.0. On the first system with only 0.9.8 this causes no problems; on the second with 1.0.1 and 1.0.2 both versioned as 1.0.0, it's "first match wins" based on the ld.so.{conf,d} ordering. Remember, ld the compile time linker is a different program to ld.so the run-time linker, and can have different behaviour (usually resulting in symbol errors or worse, as you have seen).
$ cd /usr/local/src/openssl/openssl/1.0.2beta1
$ readelf -a libssl.so | grep SONAME
0x0000000e (SONAME)                     Library soname: [libssl.so.1.0.0]

$ cat verchk.c
int main(int argc, char *argv[]) {
    printf("build: %s\n",OPENSSL_VERSION_TEXT);
    printf("run  : %s\n",SSLeay_version(SSLEAY_VERSION));
    return 0;
}

$ gcc -Wall  -I/usr/local/src/openssl/openssl-1.0.2-beta1/include \
    -Wl,-rpath /usr/local/src/openssl/openssl-1.0.2-beta1/ \
    -o verchk /usr/local/src/openssl/openssl-1.0.2-beta1/libcrypto.so verchk.c

$ ./verchk
build: OpenSSL 1.0.2-beta1 24 Feb 2014
run  : OpenSSL 1.0.2-beta1 24 Feb 2014

$ grep SHLIB_M...R= Makefile
SHLIB_MAJOR=1
SHLIB_MINOR=0.0

Update
OpenSSL-1.1 has made some API level changes, the above code will fail to compile with v1.1 headers and older libraries (undefined reference to `OpenSSL_version').
SSLeay_version() is now deprecated and (depending on OPENSSL_API_COMPAT) may be #define-d to the proper API function OpenSSL_version().

A: Is the path of the new lib in one of the files within /etc/ld.so.conf.d? Next run:-
#ldconfig -v

to rebuild the cache.  If you're quick, you should see the new lib in the long list it prints out (or pipe it to grep or less)
Maybe the path was already in the first server, but not on the second?


text:
Q: Passing Roles from ASP.NET Web API to ASP.NET CORE MVC to allow Authorize Attribute in Controllers I think this is the first time to ask a question here, but wanted to try. Hope I got this right. I have searched all over web but nothing seems to come up for this scenario.
On a Test Project, I was going to have a ASP.NET Web API that will be exposed to the web. It will have authentication and authorization. The roles will be managed thru the Web API. I will have a ASP.NET CORE MVC app as one of the clients accessing the Web API.
What I would like to do is pass the users roles (in a Claim?) from the Web API into the Web Site and have the roles be used in the Controllers Authorize as well as in the views (menu filter and button disable functionality). Of course the issue is the separation of the Website from the Web API.
I have seen tutorials where the role is passed to a Angular/React/Vue site but I am trying to see about this in a Asp.net Core website.
I think I want to pass the claim(with the Roles) to the Website and have it use it as if the website was accessing the DB directly.
Just trying to figure out how this would be done.
Any direction would be appreciated.
Thanks

redpajama_set_name: RedPajamaStackExchange


text:
Q: Apache Airflow Processing file in the order of receipt I have multiple source sending incremental data and there are no metadata columns at record level. How can I ensure that Airflow is processing data in the order of receipt. I may end-up processing the file in out-of-sync order.
Does airflow have inbuilt methods/way to handle the files in the order of receival. ?
Airflow version used :2.4.3

A: You can use boto to retrieve the last modified timestamp from files in your S3 bucket within a PythonOperator.
This question has an answer that shows how to pull the last modified timestamp. Then you can sort the keys by the timestamp, process the files in that order and move the files to an achieve folder or bucket so only new files are processed with every DAG run.
As a general note if you have any control over your sources I would prefer trying to add a timestamp at the record level, this seems like an easier option.


text:
Q: application.js can't find the file I'm including I installed textAngular with Bower. But I'm having a hard time getting it to work. Anyone tried to add it with Rails and Bower?
$ rake bower:install && find . -name "*textAngular*" -print
./lib/assets/bower_components/textAngular
./lib/assets/bower_components/textAngular/dist/textAngular-sanitize.min.js
./lib/assets/bower_components/textAngular/dist/textAngular.min.js
./lib/assets/bower_components/textAngular/src/textAngular-sanitize.js
./lib/assets/bower_components/textAngular/src/textAngular.js
./lib/assets/bower_components/textAngular/src/textAngularSetup.js

Adding textAngular to application.js works. But adding textAngular-sanitize failes. A bit weird as I can see the source file next to textAngular.
// [snipp...]
//= require textAngular           => No complaining here.
//= require textAngular-sanitize  => couldn't find file 'textAngular-sanitize'
//= require_tree .

And added to app.js
angular
  .module('app', ['ngRoute', 'restangular', 'textAngular'])
  .config(['$routeProvider', 'RestangularProvider', function($routeProvider, RestangularProvider) {

A: The important line is
./lib/assets/bower_components/textAngular/dist/textAngular-sanitize.min.js

Your require should look like:
//= require textAngular/dist/textAngular-sanitize


text:
Q: Regex match first word same as last word Here's the regex:
"'(\d{4})-(.*)-(\d{4})'i"

I want to match the first part of number (\d{4}) which must same as last part
Like this:

*

*1111-abcdefg-2222 = invalid

*1111-x-1111 = valid

*0000-rwrgreheherhe-0000 = valid

*1234-abcd-5678 -  invalid

how can I achieve this?
UPDATE
I use the following script to check the output
$i = '1111-abcd-1111';
preg_match("'(\d{4})-(.*)-(\1)'i",$i,$m);
echo print_r($m,true);

but return empty array?

A: Use a backreference:
'/(\d{4})-(.*)-\1/i'

\1 equals to what you captured in the first capture group.

A: Use \1 as a backreference to your first capture group:
'~(\d{4})-(.*)-\1~'

See it here in action: http://codepad.viper-7.com/2Jw0dL

A: You need to use back-reference:
"'(\d{4})-(.*)-\1'i"

A: preg_match("'(\d{4})-(.*)-(\g1)'i",$i,$m);

add the \g1 to the back reference:
http://php.net/manual/en/regexp.reference.back-references.php

As of PHP 5.2.2, the \g escape sequence can be used for absolute and relative referencing of subpatterns. This escape sequence must be followed by an unsigned number or a negative number, optionally enclosed in braces. The sequences \1, \g1 and \g{1} are synonymous with one another. The use of this pattern with an unsigned number can help remove the ambiguity inherent when using digits following a backslash. The sequence helps to distinguish back references from octal characters and also makes it easier to have a back reference followed by a literal number, e.g. \g{2}1.


text:
Q: Adding order number to woocommerce admin email header in  tags Trying to add order number to a woocommerce admin new order email header. Thought to be easy, but when adding following code
<?php if ( ! $sent_to_admin ) : ?>

<?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?>

<?php else : ?>

<a class="link" href="<?php echo esc_url( admin_url( 'post.php?post=' . $order->get_id() . '&action=edit' ) ); ?>"><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?> (<?php printf( '<time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ); ?>)

<?php endif; ?>

to email-header.php in h1 tags, I'm getting "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data" during checkout.
Is there some sort of conflict maybe? Or some code I'm missing?
Thanks in advance!

A: The email header ( not(!) the subject ) can be modified using the WooCommerce settings.
Go to WooCommerce -> Settings -> Email (tab)
From there click on the "New Order" email to modify it. Where it says "email heading" you can use
{order_number}

to output the order number in the heading.


text:
Q: How can I step into a method decorated with DebuggerStepThroughAttribute? I'd like to avoid the debugger breaking into a series of validation helper methods that may lead to an exception, If an exception is thrown I'd like for it to appear at the point of invocation, not inside these helper methods. So I put the DebuggerStepThroughAttribute on the helper methods. However, as the validation methods may have bugs, I'd still like to be able to debug the validating method. If I place a breakpoint inside one of these validation method, the debugger still will skip right over it.
How can I get it so that with an exception is thrown the method is skipped, but if I place a breakpoint in the method, then I should be able to step into it, or is this not possible?

A: Putting DebuggerStepThroughAttribute on a method prevents you from stepping into it using the debugger. Contrary to what you say in your question, you can still place breakpoints inside the method and they will be hit. The MSDN docs for the attribute state this as well.
This is the closest you are likely to get to what you want (eg. step through the method normally, but place a breakpoint on its first line when you want to debug it).


text:
Q: jQuery change event firing on select when arrows pressed I've seen in numerous places that jQuery's change event on a select will only fire on blur or mouse-click, yet when I try it out, the event also fires on every arrow key press. I'm trying to get the change event to not fire when arrows are used to select an option. For example:
<select size="4" id="more" name="more" required="required">
    <option value="0">No</option>
    <option value="1">Yes</option>
    <option value="2">Maybe</option>
    <option value="3">No clue</option>
</select>

$('#more').on('change', function(event){
    alert('hi');
});

This fiddle demonstrates the event firing when:
http://jsfiddle.net/McWatt/x5cTr/7/
According to the jQuery change() page, if I tab to the select, then use the arrows to select an option, the change event should not fire until the select loses focus (at least that is how I am reading it). In reality, I am seeing the change event fire with every arrow key press.
http://api.jquery.com/change/

For select boxes, checkboxes, and radio buttons, the event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus.

Has this behavior changed, or am I not understanding the functionality?
Update: I was misreading the jQuery docs, although they could be clearer. I've accepted the answer that led me to that realization. For the actual solution to my problem, I bound a keydown event to the select that set a data attribute to false if the arrows were used. Then in the change binding, I set a condition to only execute code on change if the data attribute was true. This isn't the best solution as it effectively killed the change callback code if an arrow was used, but since there is an alternate way to trigger the functionality (via a button), I could live with this functionality.
Update2:
Here is a working fiddle: http://jsfiddle.net/McWatt/BR8QQ/
// prevent change event being fired on arrow keys
$('#more').data('activation', 'activated').bind({
    keydown: function(event) {
        if(event.which === 38 || event.which === 40){
            $(this).data('activation', 'paused');
        }
    },
    click: function(event) {
        if($(this).data('activation') === 'paused'){
            $(this).data('activation', 'activated');
            $(this).trigger('change');
        }
    },
    change: function(event) {
        if($(this).data('activation') === 'activated'){
            var time = new Date();
            $('#changed').text(event.type + ": " + time.getTime());
        }
    }
});

A: Looks like it's inaccurate. As far as I can tell it's no different to the vanilla change event.
Basically, whenever a text-based input loses focus after its value is changed, it fires the event. Whenever a checkbox is clicked (or toggled with the spacebar when focussed) it fires the event. Whenever a radio button is selected (by clicking, spacebar, arrows keys...) it fires the event. Whenever a select box is changed (by selecting, arrow keys...) it fires the event too.
jQuery is no different to vanilla JS in this aspect.

A: Maybe you could add a click check in there too
$('#more').change(function(event){
    $(this).click(function(event){
    var time = new Date();
    $('#changed').text(event.type + ": " + time.getTime());
    });
 });

http://jsfiddle.net/x5cTr/13/


text:
Q: wget always giving ERROR 404: Not Found wget http://www.icerts.com/images/logo.jpg --header "Referer: www.icerts.com"
--2018-03-16 16:41:28--  http://www.icerts.com/images/logo.jpg
Resolving www.icerts.com (www.icerts.com)... 192.243.111.11
Connecting to www.icerts.com (www.icerts.com)|192.243.111.11|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.icerts.com/images/logo.jpg [following]
--2018-03-16 16:41:30--  https://www.icerts.com/images/logo.jpg
Connecting to www.icerts.com (www.icerts.com)|192.243.111.11|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-03-16 16:41:32 ERROR 404: Not Found.

Also not able to install any software using sudo apt-get install, it is always showing same ERROR 404: Not Found


text:
Q: Best software for showing SQL Server Database Structure I have a MSSQL2005 DB with about 140 tables.  I want to create either an accessible diagram or a printable API type document with the table structure.  Is there a program that offers this kind of db visualization?
I find the diagramming built into SQL Server to be very clunky and very inaccessible for my DB size.

A: Take a look at SQL Doc.

A: I always used Visio for this type of thing.

A: I like Toad Data Modeler for this.  It reverse-engineers Microsoft SQL Server databases (and other brands of databases too), but more than that, you can start making your modeling changes inside the tool and it'll generate change scripts.
If you use somebody else's tool, make sure that you can round trip changes - meaning, if you put all the time and effort into getting your documentation right, and then you change the database inside SQL, can you re-import your changes from the database without overwriting your work in the documentation tool?  Most of 'em don't do that, but Toad Data Modeler does.
(Disclaimer - I work for Quest.  I used this program before Quest bought it, though, and always loved it.)
http://www.quest.com/toad-data-modeler/


text:
Q: Passing variables in a URL of a php page to JavaScript and to another PHP Based on the code in this link http://webaudiodemos.appspot.com/AudioRecorder/index.html, I am making changes to send the recorded audio file to server by passing a sessionId via URL. The php page is http://xxxxx/abc.php?sessionId=Sam.  PHP versions: PHP 5.4 PHP 5.5.22. I am using the 2nd method from this link:How to pass variables and data from PHP to JavaScript?.  The abc.php page has reference to a few JS codes as with the index.html from the link above. abc.php page process the URL values correctly with the following code:
  <div id="bottom">
        <?php
            $faid = $_GET["sessionId"];
            echo htmlspecialchars($faid);     // tested working
        ?>
  </div>

On the recorder.js  JavaScript,I have a function that tries to pass the URL values to another PHP while uploading the audio file to server - The fname is not being passed on ... it seems .. can the xhr.send(blob) will still send the fname?
  Recorder.setupDownload = function(blob){
    var div = document.getElementById("bottom");
    var fname = div.textContent;

  var xhr = new XMLHttpRequest();
  xhr.open('POST', "./uploads.php?" + fname, true);
  xhr.onload = function(e) {};
  // Listen to the upload progress.
  var progressBar = document.querySelector('progress');
  xhr.upload.onprogress = function(e) {
    if (e.lengthComputable) {
      progressBar.value = (e.loaded / e.total) * 100;
      progressBar.textContent = progressBar.value; // Fallback for unsupported browsers.
    }
  };

  xhr.send(blob);

The uploads.php in the server has the following script to receive the value and to create an audio file - but it is not creating the audio file - however, if I fix the file name (eg: "filename123") it writes the audio file - so the issue is in passing the variable name - I am a newbie and I wonder what am I missing?:
    <?php
        ini_set("display_errors", true);
        error_reporting(E_ALL);

    if(isset($_GET['fileId']) && !empty($_GET['fileId'])){
     $id = $_GET["fileId"];
    }
        $fp = fopen( $id, 'wb' );   // writes the audio file
        fwrite( $fp, $GLOBALS['HTTP_RAW_POST_DATA'] );
        fclose( $fp );
    ?>

Update: It is working!

A: You didn't give your value a name, so you're passing a value that will appear as  DIFFERENT key in every page.
e.g. each of your users will have something like
http://example.com?foo
http://example.com?bar

leading to $_GET['foo'] and $_GET['bar'] in PHP. But since foo/bar are some randomish value representing your session ID, you have no idea what that value will be. So... give it a name:
http://example.com?key=foo

Now you just do $key = $_GET['key'] and can always access your session value, no matter what value it really as - it'll always be assigned to the key.


text:
Q: SSL error Omnipay Guzzle CI - verify that the CA cert is OK I'm using Omnipay (latest version) to perform some online payments.
I'm using SSL via Cloudflares fleixble SSL so there is no actual SSL certificate installed on the domain / server. It was all working perfectly fine until yesterday and I started getting the following error:
Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 60:
 SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed [url]
https://api.sandbox.ewaypayments.com/CreateAccessCode.json' in /home/verecsta/vendor/guzzle
/http/Guzzle/Http/Curl/CurlMulti.php:359 Stack trace: #0 /home/verecsta/vendor/guzzle/http/Guzzle
/Http/Curl/CurlMulti.php(292): Guzzle\Http\Curl\CurlMulti->isCurlException(Object(Guzzle
\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array) #1
/home/verecsta/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php(257): Guzzle\Http
\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest),
Object(Guzzle\Http\Curl\CurlHandle), Array) #2 /home/verecsta/vendor/guzzle/http/Guzzle/Http/Curl
/CurlMulti.php(240): Guzzle\Http\Curl\CurlMulti->processMessages() #3 /home/verecsta/vendor
/guzzle/http/Guzzle/Http/Curl/CurlMulti.php(224): Guzzle\Http\Curl\CurlM in /home/verecsta/vendor
/guzzle/http/Guzzle/Http/Curl/CurlMulti.php on line 359

If I set $certificateAuthority = false; on Guzzle it works again. But this is not ideal.
I can't figure out why it has stopped working all of a sudden ? Could something of expired on my server? I have been googling the issue and come across this a few times:
"Basically it means your server doesn't have the up to date Certificate Authority bundles installed"
What does this mean exactly? Do I have to install an SSL certificate for this domain? Or is there something else that needs to be update on the server? (as it was working fine up until yesterday using clouldflares SSL so guessing something else needs to be updated?)
Also I thought Guzzle used it's own certificates $opts[CURLOPT_CAINFO] = __DIR__ . '/Resources/cacert.pem'; so again not sure why I'm getting this error.

A: This issue happened to me the other day. This was because of CentOS having an old certificate authority bundle.
Assuming you are running of CentOS try running the following commands through ssh.
First back up your certificate incase it breaks.
    # cp /etc/pki/tls/certs/ca-bundle.crt /root/backup/

Then just download the new certificate bundle.
    # curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt

Once updated this should then fix your issue.

A:
Also any idea why it would all of a sudden stop working? As it was running fine before

It looks like they got a new certificate recently. Take a look at notBefore date below.
(And don't worry about the error:num=20:unable to get local issuer certificate. I did not use -CAfile option).
$ openssl s_client -connect api.sandbox.ewaypayments.com:443 | openssl x509 -text -noout
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify error:num=20:unable to get local issuer certificate
verify return:0
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 1363420 (0x14cddc)
    Signature Algorithm: sha1WithRSAEncryption
        Issuer: C=US, O=GeoTrust, Inc., CN=RapidSSL CA
        Validity
            Not Before: Aug 24 05:15:18 2014 GMT
            Not After : Nov 26 05:47:38 2015 GMT
        Subject: serialNumber=heE9O2tltnG/R8itCXJOsm8M-n1x0sDe, OU=GT69801168, OU=See www.rapidssl.com/resources/cps (c)14, OU=Domain Control Validated - RapidSSL(R), CN=api.sandbox.ewaypayments.com
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:91:d0:2d:bb:c6:dc:94:e3:79:d1:6e:e2:cb:88:
                    9d:69:7a:24:34:8c:1a:91:94:22:3a:fd:0f:db:ef:
                    9f:54:63:20:1d:d1:3d:ef:35:4b:d6:83:82:bc:5c:
                    88:8c:c3:38:4d:e7:3a:38:ca:40:74:8c:96:a6:2b:
                    d3:62:fd:5f:1b:e0:24:76:db:79:dc:98:a2:a4:bd:
                    67:6d:1a:72:47:70:4c:cb:a1:d9:0d:4b:a2:63:b8:
                    76:dc:ed:1e:12:25:75:41:7b:7c:10:86:d7:95:25:
                    c5:e9:2b:4b:9e:f4:5f:a1:26:80:da:0d:87:9e:09:
                    4e:82:d3:52:60:ac:d4:63:4f:a6:eb:5e:f8:be:6e:
                    1d:b5:e8:c6:ac:2b:a2:2d:0e:5a:fa:31:a9:79:03:
                    c6:40:2e:d9:1d:86:cb:79:5b:99:dd:32:78:ef:ee:
                    89:95:84:ed:9b:0b:93:a4:61:dc:0b:65:5a:73:b4:
                    ca:5a:a7:f5:d0:8d:e0:4f:a9:ea:31:a2:26:b2:02:
                    40:72:73:27:e7:36:e5:61:e1:91:db:0c:dc:20:ad:
                    18:f4:67:f1:34:db:c2:3b:95:6d:35:2e:19:18:9e:
                    3f:fe:77:b0:1c:ac:a3:29:ad:36:74:12:ae:d5:51:
                    b8:ba:cf:38:6d:1f:8f:34:de:ba:c5:2b:f6:36:b2:
                    76:a1
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Authority Key Identifier:
                keyid:6B:69:3D:6A:18:42:4A:DD:8F:02:65:39:FD:35:24:86:78:91:16:30

            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment
            X509v3 Extended Key Usage:
                TLS Web Server Authentication, TLS Web Client Authentication
            X509v3 Subject Alternative Name:
                DNS:api.sandbox.ewaypayments.com
            X509v3 CRL Distribution Points:

                Full Name:
                  URI:http://rapidssl-crl.geotrust.com/crls/rapidssl.crl

            X509v3 Subject Key Identifier:
                AD:B5:7E:1D:48:7A:43:43:C8:BC:52:12:CF:08:A6:A0:4B:02:34:6E
            X509v3 Basic Constraints: critical
                CA:FALSE
            Authority Information Access:
                OCSP - URI:http://rapidssl-ocsp.geotrust.com
                CA Issuers - URI:http://rapidssl-aia.geotrust.com/rapidssl.crt

            X509v3 Certificate Policies:
                Policy: 2.16.840.1.113733.1.7.54
                  CPS: http://www.geotrust.com/resources/cps

    Signature Algorithm: sha1WithRSAEncryption
         73:f3:78:15:9b:e0:91:dd:b9:80:4c:95:f8:d2:2a:75:82:f5:
         7b:86:19:a9:c4:86:26:c1:e2:59:49:7d:dc:27:d7:d6:32:52:
         9c:c8:0a:c0:88:3d:9b:40:51:ed:3e:a5:77:c6:de:7d:a6:2d:
         b4:68:b8:bc:bc:14:3b:1e:1c:3f:df:1d:84:86:bf:55:75:13:
         af:52:ef:c9:03:db:c7:13:1c:51:aa:b1:f1:e3:7e:8a:39:ae:
         c6:3f:69:8a:59:43:9e:60:68:21:25:7b:5d:4b:0a:f9:87:e9:
         07:bb:63:c8:ac:d8:e8:95:e5:5c:ec:39:e6:bc:90:c0:0f:08:
         d9:d9:93:f6:f1:2d:f3:d0:16:a3:64:cc:96:54:d3:71:7e:33:
         06:b2:73:cd:b5:00:a6:e0:f8:cb:9b:5c:65:b6:f2:be:7f:46:
         d2:eb:ab:3a:58:52:fa:70:6e:ad:5e:e2:bc:2a:79:d4:37:b5:
         d1:93:ec:89:5a:51:ac:15:45:32:95:97:ec:5c:71:33:b6:01:
         f5:6b:54:06:ee:0e:d9:68:d2:1d:18:fa:a1:ac:26:18:45:47:
         14:54:2d:10:9b:73:1a:9c:81:95:4e:a8:ed:89:9c:45:c2:8c:
         b0:81:83:7b:9c:2e:79:de:2c:dd:f0:ac:b8:33:ab:b8:fc:ab:
         a6:88:e7:f7

A: Equifax certifies api.sandbox.ewaypayments.com. You know that because Equifax is the Issuer at level two (see the 2 i: below):
$ openssl s_client -connect api.sandbox.ewaypayments.com:443
CONNECTED(00000003)
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/serialNumber=heE9O2tltnG/R8itCXJOsm8M-n1x0sDe/OU=GT69801168/
     OU=See www.rapidssl.com/.../CN=api.sandbox.ewaypayments.com
   i:/C=US/O=GeoTrust, Inc./CN=RapidSSL CA
 1 s:/C=US/O=GeoTrust, Inc./CN=RapidSSL CA
   i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
 2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
   i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
---
...

Go to GeoTrust Root Certificates, and download Root 1 - Equifax Secure Certificate Authority. Its default filename is Equifax_Secure_Certificate_Authority.pem.
Now, run s_client again. But this time, use the -CAfile option. Notice you finish with Verify return code: 0 (ok).
$ openssl s_client -connect api.sandbox.ewaypayments.com:443 -CAfile Equifax_Secure_Certificate_Authority.pem
CONNECTED(00000003)
depth=3 C = US, O = Equifax, OU = Equifax Secure Certificate Authority
verify return:1
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify return:1
depth=1 C = US, O = "GeoTrust, Inc.", CN = RapidSSL CA
verify return:1
depth=0 serialNumber = heE9O2tltnG/R8itCXJOsm8M-n1x0sDe, OU = GT69801168, OU = See www.rapidssl.com/resources/cps (c)14, OU = Domain Control Validated - RapidSSL(R), CN = api.sandbox.ewaypayments.com
verify return:1
---
...

So your job is to plug Equifax Secure Certificate Authority into Guzzle or Curl. Instead of the cacerts.pem file, you only need to use Equifax_Secure_Certificate_Authority.pem since that's the CA that certifies the site.
So I suppose you code would look similar to:
$opts[CURLOPT_CAINFO] = __DIR__ . '/Resources/Equifax_Secure_Certificate_Authority.pem';

If desired, you can cat the Equifax cert into the cacert.pem, but I would not recommend it:
$ cat Equifax_Secure_Certificate_Authority.pem >> Resources/cacert.pem

$ openssl s_client -connect api.sandbox.ewaypayments.com:443 -CAfile Equifax_Secure_Certificate_Authority.pem
CONNECTED(00000003)
depth=3 C = US, O = Equifax, OU = Equifax Secure Certificate Authority
verify return:1
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify return:1
depth=1 C = US, O = "GeoTrust, Inc.", CN = RapidSSL CA
verify return:1
depth=0 serialNumber = heE9O2tltnG/R8itCXJOsm8M-n1x0sDe, OU = GT69801168, OU = See www.rapidssl.com/resources/cps (c)14, OU = Domain Control Validated - RapidSSL(R), CN = api.sandbox.ewaypayments.com
verify return:1
---
Certificate chain
 0 s:/serialNumber=heE9O2tltnG/R8itCXJOsm8M-n1x0sDe/OU=GT69801168/OU=See www.rapidssl.com/resources/cps (c)14/OU=Domain Control Validated - RapidSSL(R)/CN=api.sandbox.ewaypayments.com
   i:/C=US/O=GeoTrust, Inc./CN=RapidSSL CA
 1 s:/C=US/O=GeoTrust, Inc./CN=RapidSSL CA
   i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
 2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
   i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIFPjCCBCagAwIBAgIDFM3cMA0GCSqGSIb3DQEBBQUAMDwxCzAJBgNVBAYTAlVT
MRcwFQYDVQQKEw5HZW9UcnVzdCwgSW5jLjEUMBIGA1UEAxMLUmFwaWRTU0wgQ0Ew
HhcNMTQwODI0MDUxNTE4WhcNMTUxMTI2MDU0NzM4WjCByzEpMCcGA1UEBRMgaGVF
OU8ydGx0bkcvUjhpdENYSk9zbThNLW4xeDBzRGUxEzARBgNVBAsTCkdUNjk4MDEx
NjgxMTAvBgNVBAsTKFNlZSB3d3cucmFwaWRzc2wuY29tL3Jlc291cmNlcy9jcHMg
KGMpMTQxLzAtBgNVBAsTJkRvbWFpbiBDb250cm9sIFZhbGlkYXRlZCAtIFJhcGlk
U1NMKFIpMSUwIwYDVQQDExxhcGkuc2FuZGJveC5ld2F5cGF5bWVudHMuY29tMIIB
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkdAtu8bclON50W7iy4idaXok
NIwakZQiOv0P2++fVGMgHdE97zVL1oOCvFyIjMM4Tec6OMpAdIyWpivTYv1fG+Ak
dtt53JiipL1nbRpyR3BMy6HZDUuiY7h23O0eEiV1QXt8EIbXlSXF6StLnvRfoSaA
2g2HnglOgtNSYKzUY0+m6174vm4dtejGrCuiLQ5a+jGpeQPGQC7ZHYbLeVuZ3TJ4
7+6JlYTtmwuTpGHcC2Vac7TKWqf10I3gT6nqMaImsgJAcnMn5zblYeGR2wzcIK0Y
9GfxNNvCO5VtNS4ZGJ4//newHKyjKa02dBKu1VG4us84bR+PNN66xSv2NrJ2oQID
AQABo4IBtzCCAbMwHwYDVR0jBBgwFoAUa2k9ahhCSt2PAmU5/TUkhniRFjAwDgYD
VR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAnBgNV
HREEIDAeghxhcGkuc2FuZGJveC5ld2F5cGF5bWVudHMuY29tMEMGA1UdHwQ8MDow
OKA2oDSGMmh0dHA6Ly9yYXBpZHNzbC1jcmwuZ2VvdHJ1c3QuY29tL2NybHMvcmFw
aWRzc2wuY3JsMB0GA1UdDgQWBBSttX4dSHpDQ8i8UhLPCKagSwI0bjAMBgNVHRMB
Af8EAjAAMHgGCCsGAQUFBwEBBGwwajAtBggrBgEFBQcwAYYhaHR0cDovL3JhcGlk
c3NsLW9jc3AuZ2VvdHJ1c3QuY29tMDkGCCsGAQUFBzAChi1odHRwOi8vcmFwaWRz
c2wtYWlhLmdlb3RydXN0LmNvbS9yYXBpZHNzbC5jcnQwTAYDVR0gBEUwQzBBBgpg
hkgBhvhFAQc2MDMwMQYIKwYBBQUHAgEWJWh0dHA6Ly93d3cuZ2VvdHJ1c3QuY29t
L3Jlc291cmNlcy9jcHMwDQYJKoZIhvcNAQEFBQADggEBAHPzeBWb4JHduYBMlfjS
KnWC9XuGGanEhibB4llJfdwn19YyUpzICsCIPZtAUe0+pXfG3n2mLbRouLy8FDse
HD/fHYSGv1V1E69S78kD28cTHFGqsfHjfoo5rsY/aYpZQ55gaCEle11LCvmH6Qe7
Y8is2OiV5VzsOea8kMAPCNnZk/bxLfPQFqNkzJZU03F+Mwayc821AKbg+MubXGW2
8r5/RtLrqzpYUvpwbq1e4rwqedQ3tdGT7IlaUawVRTKVl+xccTO2AfVrVAbuDtlo
0h0Y+qGsJhhFRxRULRCbcxqcgZVOqO2JnEXCjLCBg3ucLnneLN3wrLgzq7j8q6aI
5/c=
-----END CERTIFICATE-----
subject=/serialNumber=heE9O2tltnG/R8itCXJOsm8M-n1x0sDe/OU=GT69801168/OU=See www.rapidssl.com/resources/cps (c)14/OU=Domain Control Validated - RapidSSL(R)/CN=api.sandbox.ewaypayments.com
issuer=/C=US/O=GeoTrust, Inc./CN=RapidSSL CA
---
No client certificate CA names sent
---
SSL handshake has read 4207 bytes and written 506 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : DHE-RSA-AES256-SHA
    Session-ID: DD7775A6CE6031234C07C11FD8EB297BD3936C4B5C630217EA7658D86A89A89D
    Session-ID-ctx:
    Master-Key: 28FE5406F41EAC68000D949D101EE3FED1753AFBB77E2853314D8436CA22D80FBA656976DF17E9C3A0DB3E9CEE4365B1
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 300 (seconds)
    TLS session ticket:
    0000 - 6d 7c 92 08 26 2d 51 a7-93 e5 d9 f3 ca 35 e9 c3   m|..&-Q......5..
    0010 - ad 36 7b 52 bd 24 fc 06-f5 66 0f 15 f4 6c 90 a8   .6{R.$...f...l..
    0020 - 86 07 5b 90 b4 eb bd c7-63 73 0a 71 6c b7 17 eb   ..[.....cs.ql...
    0030 - 5a c5 21 5d 88 5e ff 74-76 55 0a fc 3d 5a 9e a6   Z.!].^.tvU..=Z..
    0040 - 20 70 b6 c9 f6 61 d6 87-f2 58 14 c4 ef 1a 52 9b    p...a...X....R.
    0050 - cc 11 0c c3 52 7c 8a 72-cf 6c 2e fb 26 ad 38 97   ....R|.r.l..&.8.
    0060 - 67 54 f3 70 b1 49 36 e9-34 c1 fb 51 5a 1c ee 7f   gT.p.I6.4..QZ...
    0070 - 22 61 73 dc 75 0e f1 ff-33 47 7a 1e 6a 92 8b b6   "as.u...3Gz.j...
    0080 - 20 4e 0a a8 bd 3a 53 04-56 af de 7d 65 a8 09 db    N...:S.V..}e...
    0090 - 7d 2d 9e 91 df cd f2 6b-f9 ba 57 ff 37 8c 09 0b   }-.....k..W.7...

    Start Time: 1409189687
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---


text:
Q: Excel - calculate backwards from cell based on changing its value Markup calculator
What formula do I require in the 'client charge' cell in order for that to calculate based on the percentage I put in the 'markup' cell?

A: If the markup cell is calculated based on the client charge, you can't change client charge based on markup because that would be a circular reference.
Your options are to use the built in Excel Solver function, or create a new cell which calculates the recommended client charge.


text:
Q: Are there any mac epub readers that support vertical scrolling? I find it much easier scrolling down on to the next page, rather than going left to right. Does anyone know if there are any epub readers that suppor this?

A: There's at least Bookle. It still seems sort of unfinished though and the last update was about a year ago.

A: Calibre's own viewer can do it.

A: I was looking for an answer to this myself. For the record, I found Murasaki.


text:
Q: Games explorer group order is reversed I've formatted my PC to do a clean install of Windows 7 Ultimate SP1 x64. I was adding the Spanish language pack and then removing the English one.
After removing the English LP, something weird happened to Games Explorer, the groups "Games" and "Game Provider" swapped position. Usually "Game Provider" is above "Games", when the position changed, "Games" went above "Game Provider". Check out the screenshot.

I want to make "Games" be below "Game Provider" (like default).

A: I've found the answer by myself just before submitting the question, but I want to answer this anyway for the people with the same issue.
The order of these groups are set in this submenu.
Right click the Games Explorer's blank space.

Go to Group by and then change from "Ascending" to "Descending" keeping "Type" as group method.


text:
Q: how to save a pdf with action script from a browser? I have a problem with my script, I create a pdf file with data and script inside and I show this pdf in a browser.
The user can put more data y has a button that calls a script action for to save, in this part my script does not work.
This is the code in the web page:
<script language="JavaScript">
        function doSubmit() {
            pdfObject = document.getElementById("PDFObj");
            try{ pdfObject.postMessage(["submitForm", "submitForm"]);  }
            catch (e)
            { alert( "Error: \n name = " + e.name + "\n message = " + e.message ); }
       }
</script>
<p align="center">
<object id="PDFObj" align="center" data="../pdf/form.pdf" type="application/pdf" width="500" height="200"></object>
</p>

This is my script:
<action type="javascript"><![CDATA[
            var mydoc = app.activeDocument;

            function myOnMessage(aMessage){

                if (aMessage[0] == 'submitForm'){

                    try {
                    var myPath = "/d/temp/" + "file" + ".pdf";
                    this.saveAs(myPath);
                    app.alert("the records was successful" );
                    }catch (e)
                    { app.alert("Error:" + e.Message);}

                }
            }

            var msgHandlerObject = new Object();
            msgHandlerObject.onMessage = myOnMessage;
            msgHandlerObject.onError = myOnError;
            msgHandlerObject.onDisclose = myOnDisclose;
            function myOnDisclose(cURL,cDocumentURL){
            return true;    }
            function myOnError(error, aMessage){
            app.alert(error);
            }
            this.hostContainer.messageHandler = msgHandlerObject;
            ]]>
         </action>

Please, I need to know why does not work my script and a possible solution.


text:
Q: Form layout is not visible in visual C# for Smart Device->Windows CE 5.0->Device Application project I am developing an application for windows CE 6.0.
When i start a windows CE 5.0 device application project, IDE shows me the form in the solution explorer but there is no form layout in the designer. Instead, it appears as a control similar to openFileDialog control.
alt text http://img7.imageshack.us/img7/7130/formdesignererrorpictur.jpg
The same problems does not occur if i try it on a windows application project.
Did i miss installing any required API libraries?

A: I form layout is degraded because of conflicting APIs.
Because multiple versions of the same library can be the cause of such a problem.
I had installed .net compact framework 1, 2 , 3 and 3.5 SP1.
I uninstalled all and then when Visual Studio asked to install .net compact framework 2.
I got the appropriate layout back.


text:
Q: Vue event handler on dynamically inserted string does not work This is my code:
<template>

 <button v-on:click="replace">Click Me to replace div contents</button>

</template>

Here if I click on Click Me to replace div contents the content is replaced but the event handler clickMe does not fire. This data would come from server and I need to compile this string and use it from within the Vue's context so Vue can handle events etc.
How can I have the dynamic string downloaded from server work? I am using Vue 2.

A: Other solution using Vue components (codepen):

 <button v-on:click="replace">Click Me to replace div contents</button>
  <component :is="currentView"></component>

A: Since v-html isn't compiled you will have to create a mini component like this to get around the issue:

new Vue({
  el: '#app',
  data () {
    return {
      data: ``
    }
  },

  computed: {
    compiledData () {
      return {
       template: `<p>${this.data}</p>`
      }
    }
  },

  methods: {
    replace () {
       this.data = `Now click on me <a href='#' @click.prevent='alert("yo")'> here </a>`
    }
  }
})

  <component :is="compiledData" ></component>
  <button v-on:click="replace">Click Me to replace div contents</button>

The above code compiles the string content and thus you can run/execute the function as intended

A: v-html is not compiled as a Vue template. From the docs:

Note that the contents are inserted as plain HTML - they will not be compiled as Vue templates. If you find yourself trying to compose templates using v-html, try to rethink the solution by using components instead.

see: https://v2.vuejs.org/v2/api/#v-html

A: You can not render VueJS code from a html string.
You can solve this issue by using v-if

I will be replaced once you click on button

Why does click me not work? It is loaded from server via ajax Click Me

<button @click="replace">Click Me to replace div contents</button>


text:
Q: Error Showing on file upload in codeigniter <?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Upload extends CI_Controller
 {
    public function __construct()
     {
        parent::__construct();

            $this->load->library('session');
            $this->load->helper('form');
            $this->load->helper('url');
            $this->load->library('upload');
            $this->load->helper(array('form', 'url'));
            $this->load->database();
            $this->load->library('form_validation');
    }

    public function index()
    {
        $this->load->view('index');
    }

    public function files()
    {
        $this->load->model('file_model','b');
        $this->load->view('files');
    }

    public function upload_file()
    {
        $status = "";
        $msg = "";
        $filename = 'product_pic';

        if(empty($_POST['title']))
        {
            $status = "error";
            $title = "Please Enter Title";
        }

        if($status != "error")
        {
            $config['upload_path'] = 'img/';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size'] = 1024 * 8;
            $config['encrypt_name'] = true;
            $this->upload->initialize($config);
            if(!$this->upload->do_upload->('$filename'))
            {
                $status = 'error';
                $msg = $this->upload->display_errors('','');
            }
            else
            {
                $this->load->model('file_model');
                $data =$this->upload->data();
                $file_id =$this->file_model->insert_file($data['file_name'],$_POST['title']);
                if($file_id)
                {
                    redirect('upload/index');
                }
                else
                {
                    unlink($data['full_path']);
                    $status = "error";
                    $msg    = "Please try again";
                }

            }
            @unlink($_FILES[$filename]);
        }
            echo json_encode(array('status'=>$status,'msg'=>$msg));
    }
}

?>

this is my controller file
on uploading image it showing error as follows

A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Upload::$do_upload
Filename: controllers/upload.php
Line Number: 48
Backtrace:
File: D:\xampp\htdocs\picture\application\controllers\upload.php Line:
  48 Function: _error_handler
File: D:\xampp\htdocs\picture\index.php Line: 315 Function:
  require_once
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: controllers/upload.php
Line Number: 48
Backtrace:
File: D:\xampp\htdocs\picture\application\controllers\upload.php Line:
  48 Function: _error_handler
File: D:\xampp\htdocs\picture\index.php Line: 315 Function:
  require_once

A: Try this
if(!$this->upload->do_upload($filename))

Instead of
if(!$this->upload->do_upload->('$filename')) // you had extra ->

Filename should be
controllers/Upload.php

Not
controllers/upload.php

http://www.codeigniter.com/user_guide/general/styleguide.html#file-naming
You do not need to close the controller with ?> also
If non of that works try renaming controller to a different name because there is a class upload all ready.


text:
Q: How to give grained IAM control for AWS Aurora? I want to give a least privilege IAM policy to control creation and deletion of AWS Aurora instances. Rights for DB Instances working fine, but DB Cluster objects can not be deleted:
User xxxxxxx is not authorized to perform: rds:DeleteDBCluster

Here is what rights I want:
{
  "Sid": "313",
  "Effect": "Allow",
  "Action": [
    "rds:ModifyDBCluster",
    "rds:DeleteDBCluster"
  ],
  "Resource": "arn:aws:rds:eu-west-1:123456789101:cluster:*",
  "Condition": {
    "StringEquals": {
      "rds:cluster-tag/author": "qa"
    }
  }
}

But as far as I tested only this works:
{
  "Sid": "313",
  "Effect": "Allow",
  "Action": [
    "rds:ModifyDBCluster",
    "rds:DeleteDBCluster"
  ],
  "Resource": "*"
}


text:
Q: Adsense code not showing My adsense code won't show. Code is in there, and is in there for weeks...Still not showing..
http://www.ecompanies.nl/pilot/diensten/seo/breda.html
I think it should be jQuery or Google Maps javascript interfering or something.
Don't see any javascript errors..
Any help is highly appreciated!

A: For anyone encountering the same problem...It looks like an Adsense problem. Seems like the ads only show up after Google Adsense bot spidered the page. On new pages on my sites, it takes 1 or 2 days for the ads to show up. Very strange..


text:
Q: EF Core one-to-many mapping to tables with no keys I'm trying to map tables from an old IBM Db2 database to entities using EntityFramework Core 2.2 but these tables don't have any keys at all (yes I was shocked too) and I'm not sure if I'm even allowed add them to this ancient beast that has been running since the stone age.
So far I've gotten things to work by reverse engineering the relationships and finding potential keys to use so that EF can happily track these entities, but I'm facing an issue with a one-to-many mapping.
I want to make a one-to-many mapping from the Invoice table to the SellerAccountDetails table. My configuration:
Invoice entity:
public class FinvoiceConfiguration : IEntityTypeConfiguration<Finvoice>
{
    public void Configure(EntityTypeBuilder<Finvoice> builder)
    {
        // PK for Invoice
        builder.HasKey(f => new { f.FinvoiceBatchNumber, f.FinvoiceBatchRowNumber });

        // One-to-many to SellerAccountDetails table
        builder.HasMany(f => f.SellersAccountDetails)
            .WithOne(s => s.Invoice)
            .HasForeignKey(s => new
            {
                s.FinvoiceBatchNumber,
                s.FinvoiceBatchRowNumber,
                s.SellerAccountPartyIdentifier
            })
            .HasPrincipalKey(f => new
            {
                f.FinvoiceBatchNumber,
                f.FinvoiceBatchRowNumber,
                f.SellerPartyIdentifier
            });
    }
}

SellerAccountDetails entity:
public class SellerAccountDetailsConfiguration : IEntityTypeConfiguration<SellerAccountDetails>
{
    public void Configure(EntityTypeBuilder<SellerAccountDetails> builder)
    {
        // PK for SellerAccountDetails
        builder.HasKey(s => new
        {
            s.FinvoiceBatchNumber,
            s.FinvoiceBatchRowNumber,
            s.SellerAccountPartyIdentifier,
            s.SellerAccountID // <-- Needed for uniqueness of this entity
        });

        // Many-to-one to Invoice table
        builder.HasOne(s => s.Invoice)
            .WithMany(i => i.SellersAccountDetails)
            .HasForeignKey(s => new
            {
                s.FinvoiceBatchNumber,
                s.FinvoiceBatchRowNumber,
                s.SellerAccountPartyIdentifier
            })
            .HasPrincipalKey(f => new
            {
                f.FinvoiceBatchNumber,
                f.FinvoiceBatchRowNumber,
                f.SellerPartyIdentifier
            });
    }
}

Now this works when I make a query and then call ToList(), in my test code I'm supposed to get 3 SellerAccountDetails entities for one Finvoice, but if I don't materialize the IQueryable, I get 6 SellerAccountDetails for one Finvoice, and if I enumerate again, they increase to 9, and so on...
Shouldn't EF know from the configured primary key on SellerAccountDetails what makes this entity unique?
I added the HasPrincipalKey because the property SellerPartyIdentifier (from Finvoice) corresponds to the property SellerAccountPartyIdentifier on the accounts table, but it's not a primary key. If I remove it and keep just the 2 foreign keys, the result is the same.
How do I make this work? I might be missing something obvious here, but I don't see it.
Here's my example query:
var invoices = _dbContext.Invoices.Include(i => i.SellersAccountDetails).ThenInclude(s => s.Invoice).
                Where(i => i.FinvoiceBatchNumber == 13491).OrderBy(i => i.FinvoiceBatchRowNumber).Take(1);//.ToList();

Thank you!

A: Solved! The problem was that the entity properties' getters were trimming the field:
private string _sellerAccountID;

[Column("FV77A", TypeName = "char(35)")]
[Required, DefaultValue("")]
[MinLength(0), MaxLength(35)]
public string SellerAccountID
{
    get { return _sellerAccountID.Trim(); } // <-- Trim() is the culprit
    set { _sellerAccountID = value; }
}

For some reason this was confusing the EF tracker, because if I also disable tracking by using AsNoTracking (or setting it globally by doing optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); then it would also work correctly.
I removed the trim (and the private fields), and did the trimming using AutoMapper on the DTO level like so:
CreateMap<string, string>().ConvertUsing((s, d) => s.Trim());
Now I always get 3 results as I should no matter how many times I enumerate the IQueryable.

A: You cannot use "Include" linq without key/relationship in Db2.
You have to use below
var invoices = (from a in _dbContext.Invoices.Where(x => x.FinvoiceBatchNumber == 13491)
                from b in _dbContext.SellersAccountDetails.Where(x => x.InvoiceId = a.Id).DefaultOrEmpty()
                select a, b).Take(1);


text:
Q: Command "grep | cut" in shell programming I have a problem with the grep command.
I have a file, called dictionary.txt, containing 2 columns of words, like
abc def
apple orange
hour minute

In my Bash script, having entered the word in the left column as an argument, I have to output the corresponding word on the right using the grep command.
A requirement is to use a loop.
I created this script:
#!/bin/bash

parola=$1

for traduzione in $( sort dictionary.txt )
do
     if [ $parola == $traduzione ]
     then
     grep $traduzione | cut -f 2 dictionary.txt
     fi
done

This does not work as described above.

A: I'd suggest to replace the whole for loop with
awk -v word="$parola" '$1 == word{print $2;exit}' dictionary.txt

where

*

*-v word="$parola" passes the parola variable to the awk script

*$1 == word checks if the Column 1 value equals the parola

*{print $2;exit} - prints the Column2 value and exits (remove exit if you need all matches on the further lines).

With dictionary.txt as
abc def
apple orange
hour minute

and script.sh as
#!/bin/bash
parola=$1
awk -v word="$parola" '$1 == word{print $2; exit}' dictionary.txt

the bash script.sh apple returns orange.
If you need a for loop you can use

#!/bin/bash
parola=$1

while IFS= read -a line; do
  read -r left right <<< "$line"
  if [ "$left" == "$parola" ]; then
     echo "$right";
  fi
done < dictionary.txt

That is:

*

*Read dictionary.txt line by line assigning the current line value to the line variable

*Read the values on a line into left and right variables

*If left is equal to right, print right.

A: Why are you using a for-loop?
grep -w "word1" dictionary.txt

This shows you the line where you can find that word, so the for-loop is not even needed. For your information, -w means "only take whole words".


text:
Q: How to deal with seldom used big database and postgresql? I loaded in PostgreSQL (9.3) OpenStreetMap data for whole europe (400gb). Then I installed a geocoding api (nominatim) that queries the database with gis queries.
My problem is :

This database is queried a few times a day, but because postgres loads
  the data in its buffer on demand, my first query on a particular gps
  point is always slow, and I do only one query per GPS point, so it's
  always slow (like 60sec slow against 100ms when the data is buffered)

.
What could I do here ?

*

*I'm using a A6 Azure instance (4 Cores, 28 GB memory, HDD).

*Server is Ubuntu 14.04.4 LTS

*Swapping is enabled

*There is index on the geometry columns queried.

*The shared buffer is 10GB

*work mem is 256MB

*maintenance work mem is 4GB

A: depending on your usage, you could try to partition the data to reduce the scanned data (at 400gb even your indexes are large and heavy to read...)
I think it's your best option as working with 400gb tables is heavy even on a very optimized queries...
You could also pre-warm the cache with the index data , by issuing some of your queries on frequent gps points or by using something like pg_prewarm


text:
Q: How to check if the recieved audio src url is working or not? I have to play song as per user input . My backend is in python which fetches from some api and provides the song source to play to the frontend (reactjs). Some of the links are broken and cannot play. So I need to identify which are broken so that it wud not cause bad UX.
I have tried these workarounds-

*

*fetch request to the obtained link and if it returns status other than 200
This did not work and provided CORS Not Allowed warning in console and also the request just passed to catch and I was unable to check status in then.

*using play() promise
var context = new AudioContext();
var source = context.createBufferSource();
var audioFile = new Audio();
audioFile.src= audio['audiosrc'];
var playPromise = audioFile.play()
console.log(playPromise);
playPromise.then(() => {console.log('ok')})
.catch((err) => {console.log('err')
console.log(err);
fetch('https://app.boorish86.hasura-app.io/stream', {
  method: 'POST',
  body: JSON.stringify({
    src: audio['audiosrc']
  }),
  headers: {
    "Content-type": "application/json; charset=UTF-8"
  }
})
.then(response => response.arrayBuffer())
.then(response => {console.log(response)
    context.decodeAudioData(response, function(decodedData) {
    source.buffer = decodedData;
    source.connect(context.destination);
    source.start(0) });
})
.catch(err => console.log(err))
})

None of these workarounds help me since I have to pass src to some other react custom play component.Nd this is not happenning on pasing source downt to a child component.
Also checking from oncanplaythrough, canplay , onloadeddata is not working for me . It gives same output for broken as well as non broken links


text:
Q: detecting deserialized json object mismatch I am parsing a json reply, this reply can be different depending on if the call succeeded or not.
I created a function to check if the deserialization was sucessful, (return true + data or false + no-data)
static private bool TryParse<T>(string json, out T result)
{
    try
    {
        result = Deserialize.FromJson<T>(json);
        return true;
    }
    catch
    {
        result = default;
        return false;
    }
}

.
public class Success_type
{
    [JsonProperty("success")]
    public string Success { get; set; }
}
public class Failure_type
{
    [JsonProperty("status")]
    public bool Status { get; set; }
    [JsonProperty("reason")]
    public string Reason { get; set; }
}

public static class Deserialize
{
   public static T FromJson<T>(string json) => (T)JsonConvert.DeserializeObject<T>(json, QuickType.Converter.Settings);
}

Example:
if (TryParse(json, out Success_type expected_success))
{
    //do sosmething with expected_success
}

if (TryParse(json, out Failure_type expected_failure))
{
    //do sosmething with expected_failure
}

i was expecting an exception to be thrown in DeserializeObject.FromJson<T>(json) because json is not of type T. however, it succeeds, TryParse() returns true and just contains null items. why is that / how to i catch a mismatch?


text:
Q: Javascript date object based on what I am using the date object below to obtain the current time from the user:
    var currentdate = new Date();
    return (currentdate.getDate() + "/"
            + (currentdate.getMonth()+1)  + "/"
            + currentdate.getFullYear() + " @ "
            + currentdate.getHours() + ":"
            + currentdate.getMinutes() + ":"
            + currentdate.getSeconds());

My question is where does currentdate obtain the time from? Does it grab the time from a central server? Would any user from anywhere around the globe execute the codes above at the same time will obtain the same value?
Or this is per user based, meaning if two users from different time zones execute the codes at the same time, they will obtain the time based on their time zone, hence the codes return different values?

A: In the code you provided, the first line is:
var currentdate = new Date();

The constructor of the Date object is called without any parameters, and thus is initialized with a timestamp having the same value as Date.now().  That value is a Unix timestamp, containing milliseconds since 1970-01-01 00:00:00.000 UTC (not accounting for leap seconds).  It is strictly UTC based. The sytem time zone is not involved in the construction, and the Date object does not store the system time zone.
Only the system clock is involved.  Every computer system has an internal clock that can return the current UTC time.  This clock is most often synchronized with clocks of other computers via NTP, PPTP, or similar mechanisms.  It is computer dependent though.
 For example, when configured for "set time automatically", Windows computers will obtain their time either from a public NTP server on the Internet, or from a domain controller on a local network, depending on the network configuration.  However, a standalone computer that is not configured to set time automatically, could have a very different clock value.
Thus, two given computers calling new Date() (or Date.now()) will likely retrieve similar values if their clocks are synchronized correctly, but are not guaranteed to.  There is no network call involved, only a call to the local system clock.
In the rest of your code, you call the functions getMonth, getFullYear, getHours, getMinutes, and getSeconds.   Each of these function calls will independently use the Date object's UTC-based timestamp and the time zone configured on the computer where the code is being executed.  If the code is executed in a web browser, then it's the user's computer's time zone that is applied.  If the code is executed on the server, then it's the server's time zone that is applied.
Again, the important thing to remember is that Date object only track a single numeric value - the milliseconds since the Unix epoch (not accounting for leap seconds).  You can see this value directly by calling d.getTime() or d.valueOf() on the Date object (named d here), or by coercing the value to a Number as in +d.  The time zone is not part of the object's state, and it does not make network calls on its own.

A: This is based on the Unix timestamp and will be based on the users' computers time if requested client-side, or the servers timestamp if requested server-side.
For further reading see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now

A: First of all its a very good question. Lot of developers use date but never bother to go as to how it works exactly.
Yes, it's machine based on which the JavaScript engine is running, so yes it depends upon timezone too.
See : https://javascript.info/date

A: According to mdn, the exact date/hour is based on your computer. More details:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours

A: Javascript runs on a web browser so it will take the time form the user's machine. So if your users sit in different time zone then they will see different time.

A: Javascript Date is executed on the client side ! So yes each user would see his machine time and his specific Timezone.
Even when the user has a wrong time in his machine, he would see it wrong.
The exception returns Server time when you are using Node.js for example. In that case, local time would be the server time.
Again on servers, usually time and Timezones follow the OS time setting.
If you expect them all to see the same time, Like displaying : "Time in London 10:13pm"
You need to store your server time in a javascript variable using your server' programming language.


text:
Q: Lower bounds for integer factorization Suppose we know that $n=p_a p_b$ where $a<b$ and $n$ are known integers and $p_a$ is the $a$-th prime. ( For example $n = p_{102} \cdot p_{2034}$). Then the time $t(n)$ to factor $n$ is greater then or equal to $T(a)$ = the time to find the $a$-th prime (Edit by comment from Erick Wong:) given $n = p_a \cdot p_b ,a,b$ in the decimal system. So what is the time to find the $a$-th prime number given $n = p_a p_b,a,b$ in the decimal system? This question is related to the number system http://oeis.org/A054841 where in the given representation of  a number one "knows" its prime factors.

A: One way to compute $p_a$ given $n$,$a$,$b$ is to factor $n$.  If $a$ and $b$ are extremely close together (like $b=a+1$) then the fastest method may well be a simple Fermat factorization.  If $a$ and $b$ are roughly of the same size, then this would fall under a general-purpose algorithm like Number Field Sieve, which takes
$O(\exp((\log n)^{1/3 + \epsilon}))$ time.
However, if $b$ is substantially larger than $a$ (say, on the order of $a^2$, perhaps) then $n$ will also be substantially longer than $a$, and it may be more efficient to use something like Lenstra ECM factorization which is faster for small $a$.
At some point (when $b$ is much larger than $a$, maybe exponentially larger) there would be a crossover where it makes sense to ignore $n$ and just focus on computing the $a$th prime.  Computing the $a$th prime function is essentially the same as computing $\pi(x)$, the prime-counting function: given either function, you can use binary search to compute the other, so that the running times are at most a $O(\log a)$ factor apart.
Algorithms for computing the prime-counting function $\pi(x)$ are pretty well-studied.  In practice this is done by modern forms of the Meissel-Lehmer algorithm which runs in time $O(x^{2/3 + \epsilon})$, which is faster than computing all primes up to $x$ at least for larger $x$, but notably slower than factoring methods for numbers of similar size.  See Deleglise and Rivat's paper for more details.
In theory it is possible to compute $\pi(x)$ using high-precision complex arithmetic in time $O(x^{1/2 + \epsilon})$, but this may not be very practical.  You might find some informative discussion of this method in William Galway's thesis.


text:
Q: How can I enable mods in Cities Skylines? I am hoping not to sound too much of a nitwit, but I am completely not understanding how mods are supposed to work on Cities Skylines (or Steam at all for that matter). I find confusing information: some sites telling me to download files (which ones?) some hinting towards subscribing to be enough (I guess...)
To be a little more specific, all I want is to be able to use the right mouse button to pan in the game. That's it. I found this mod that supposedly does that, but there is nothing I can download, so I subscribed, and started the game. Nothing. Nowhere anything about mods at all in the game.
Another option would be this mod, which seems to be a little more recent, but same problems apply here.
In short, how do I install mods (or manage them) in Cities: Skylines?

A: Windows OS
To install mods in the Cities Skylines usually, I will do this.
In the browser

*

*Log in to Steam and navigate to the mod, e.g.
https://steamcommunity.com/sharedfiles/filedetails/?id=1406625743

*Subscribe to the mod

*Once that is done, the Steam client automatically download the subscribed mod in the game computer/laptop

On the computer (I am using Windows 10, should work for Windows 8.1 too)

*Open Cities Skylines - Play

*On the screen, you will find Content Manager. Select it.

*In the Content Manager screen you will find the MODS on the left side. Select it.

*On the right side, you need to enable the mod you want to be available in the game. Refer this image link for the screens.

*To uninstall a mod, you can unsubscribe it either from the Steam Workshop page (where you previously subscribed) or from the MODS section of the Content Manager screen by clicking x button on the right side.

Note
Due to some reason, if you couldn't find your subscribed mod in the MODS section of the content manager, sign out the Steam client on your machine and sign in again.


text:
Q: i have 10 files with CSV and TSV. I want to get the output what is CSV and TSV data using MapReduce in Apache Hadoop one file is containing data like this
robert 10,20,30
john 10,30,20

Another file containing data like
surya 10|20|30
sumanth 30|40|10

like this 10 files i want to get the output data what is coma separated and pipe separated using Map Reduce

A: Here's the code to replace comma delimiter with pipe and combine all the lists for the same surname into one
package my.reader;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

import java.io.IOException;

public class ReadRows {
    public static class Map extends Mapper<LongWritable, Text, Text, Text> {
        public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
            String[] res = value.toString().split("\t");
            if (res[1].contains(",")) {
                res[1] = res[1].replace(',','|');
            }
            context.write(new Text(res[0]), new Text(res[1]));
        }
    }

    public static class Reduce extends Reducer<Text,Text,Text,Text> {
        public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException{
            String res = "";
            for(Text val : values) {
                res += "|" + val.toString();
            }
            context.write(key, new Text(res.substring(1)));
        }
    }

    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        if (args.length != 2) {
            System.err.println("Usage: my.reader.ReadRows <in> <out>");
            System.exit(2);
        }

        Job job = new Job(conf, "ReadRows");
        job.setJarByClass(ReadRows.class);
        job.setMapperClass(Map.class);
        job.setReducerClass(Reduce.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);
        job.setInputFormatClass(TextInputFormat.class);
        job.setOutputFormatClass(TextOutputFormat.class);

        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}

And here's the code just to parse them and calculate max:
public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
    public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] res = value.toString().split("\t");
        String[] sal;
        if (res[1].contains(",")) {
            sal = res[1].split(",");
        } else {
            sal = res[1].split("\\|");
        }
        Integer maxSal = 0;
        for ( String s : sal ) {
            maxSal = max(Integer.valueOf(s), maxSal);
        }
        context.write(new Text(res[0]), new IntWritable(maxSal));
    }
}

public static class Reduce extends Reducer<Text,IntWritable,Text,IntWritable> {
    public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException{
        Integer maxSal = 0;
        for(IntWritable val : values) {
            maxSal = max(val.get(), maxSal);
        }
        context.write(key, new IntWritable(maxSal));
    }
}


text:
Q: how to specify java runtime range with build granularity in jnlp Because of a serious bug in Java 8 Update 40 which was fixed in Java 8 Update 40 build 27, I would like to specify that build as minimum in my JNLP. However this does not seem to work:
<resources>
  <java version="1.8.0_40-b27+"/>

Strangely, it doesn't work even if I specify exactly the build, which is currently installed on my machine, Java Web Start tells the me it's not, in my case I did:
<resources>
  <java version="1.8.0_40-b27"/>

Is it possible to somehow specify the Java runtime version in this granularity, after all?
Update: At least I can specify a range with update granularity (but not build granularity), if a certain href is provided:
<resources>
  <java version="1.8.0_40+" href="http://java.sun.com/products/autodl/j2se"/>


text:
Q: test whether symbol is an operator Given a symbol, how do you know if it's an operator?
> expr <- quote(a[b + 1] * c)
> expr[[1]]
`*`

match doesn't work
> expr[[1]] %in% c(quote(`+`), quote(`*`))
Error in match(x, table, nomatch = 0L) :
  'match' requires vector arguments

it's possible using ==
> expr[[1]] == quote(`+`)
[1] FALSE
> expr[[1]] == quote(`*`)
[1] TRUE

but I wonder if there's an easier way that doesn't involve dozens of =='s.


text:
Q: Assembly*Attributes missing in Release builds on Xamarin.Android Every component of my app-suite specifies the following in AssemblyInfo.cs to identify itself:
..
[assembly: AssemblyVersion("MM.nnn.*")]
[assembly: AssemblyTitle( "Component Title" )]
#if DEBUG
[assembly: AssemblyDescription( "<Component>.Debug" )]
[assembly: AssemblyConfiguration( "Debug" )]
#else
[assembly: AssemblyDescription( "<Component>.Release" )]
[assembly: AssemblyConfiguration( "Release" )]
#endif

Every component's start-up usually involves the following sequence:
Assembly        asm =   Assembly.GetExecutingAssembly( );
FileVersionInfo fvi =   FileVersionInfo.GetVersionInfo( asm.Location );

Utils.sModInfo =    string.Format( Utils.scFmtModId, fvi.FileDescription, fvi.Comments,
                        fvi.FileVersion, Utils.GetBuildFromVersion( fvi.FileVersion ) );

For completeness:
/// <summary>Returns build-date/time, extracted from the version string
    (use on 'MM.nnn.*'-versioned assemblies)</summary>
public static DateTime  GetBuildFromVersion( string sVersion )
{
    DateTime    dB =    new DateTime( 2000, 1, 1 );
    string[]    sa =    sVersion.Split( '.' );

    if(  sa.Length == 4  )
    {
        dB =    dB.AddDays(    Convert.ToInt32( sa[ 2 ] ) );
        dB =    dB.AddSeconds( Convert.ToInt32( sa[ 3 ] ) << 1 );
    }
    return  dB;
}

Now, Xamarin.Android project shares a lot of library code, and i would like to use same approaches for similar conceptual tasks.  Therefore, i created AssemblyInfo.cs, and filled it accordingly..
Everything works great in Debug builds:  attributes are retrieved and displayed properly.
The very first Release build crashed, unable to get asm.Location - as i later figured out.
So i put #if DEBUG .. #endif around that code and went on..

Today i realized FileVersionInfo is not really necessary, and changed Android start-up to:
string  sVersion =  asm.GetName( ).Version.ToString( ),
        sFileDsc =  string.Empty,
        sComment =  string.Empty;

foreach(  Attribute attr in asm.GetCustomAttributes( true )  )
{
    if(  attr.GetType( ) == typeof(AssemblyTitleAttribute)  )
        sFileDsc =      ((AssemblyTitleAttribute)attr).Title;
    else
    if(  attr.GetType( ) == typeof(AssemblyDescriptionAttribute)  )
        sComment =      ((AssemblyDescriptionAttribute)attr).Description;
}

Utils.sModInfo =    string.Format( Utils.scFmtModId, sFileDsc, sComment,
                        sVersion, Utils.GetBuildFromVersion( sVersion ) );

This worked perfectly in Debug build..  And only gave me a version# in Release one!
Exposing proper (similar and comparable to all other components) version# is great, i'll take that.
But what happens to the rest of Assembly*Attributes in Release builds?


text:
Q: The remote server returned an error (400) Bad Request using webrequest When I execute HttpWebRequest.GetResponse on URL, GetResponse returns "The remote server returned an error:  (400) Bad Request." instead of response.
The strange thing is that when I run this url at the browser I get the right response.
doesn't webrequest need to return the same values as the browser?
the following code return bad request
 // Create a request for the URL.
            WebRequest request = WebRequest.Create(
              "http://someUrl/api/v5/basicAuth");

            // Get the response.
            WebResponse response = request.GetResponse();
            // Display the status.
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);
            // Get the stream containing content returned by the server.
            Stream dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();
            // Display the content.
            Console.WriteLine(responseFromServer);
            // Clean up the streams and the response.
            reader.Close();
            response.Close();

also tried  using  WebClient with same results.
any idea how to get the proper response same as the browser?

A: The title says you're getting a 400 bad request, but in your question you say 404 Not Found.  Those are very different. For a 404, I'd be troubleshooting the URL itself and how the request is being routed, DNS, etc.  if it's a 400, then I would use something like Fiddler to capture how my request looks when using a browser, then see what the request looks like when coming from the program and see what's different/missing.  It could be that some HTTP headers are needed, such as the content-type, or handling of cookies, etc etc.  But something like Fiddler could at least get you started.


text:
Q: Is it possible to deserialise either Json.Number or Json.String to a string without using a custom Converter? I am writing a service to consume JSON that I have no control over. One property in this JSON can either be a number or a string, so input can either look like:
{"event_type":"status","value":"ok"}

or
{"event_type":"status","value":-253}

I have a record type in my code which I want to deserialise into:
public record StatusMessage(
    [property: JsonPropertyName("event_type")] string EventType,
    [property: JsonPropertyName("value")] string StatusValue)

As expected this works fine when I attempt the deserialise the Json.String variant but the Json.Number variant blows up with System.InvalidOperationException: Cannot get the value of a token type 'Number' as a string..
I am aware that I can write a custom JsonConverter for StatusMessage but am wondering if there's any other way?


text:
Q: Pyspark > Dataframe with multiple array columns into multiple rows with one value each We have a pyspark dataframe with several columns containing arrays with multiple values. Our goal is to have each of this values of these columns in several rows, keeping the initial different columns.
So, starting with something like this:
data = [
    ("A", ["a", "c"], ["1", "5"]),
    ("B", ["a", "b"], None),
    ("C", [], ["1"]),
]

Whats:
+---+------+------+
|id |list_a|list_b|
+---+------+------+
|A  |[a, c]|[1, 5]|
|B  |[a, b]|null  |
|C  |[]    |[1]   |
+---+------+------+

We would like to end up having:
+---+----+----+
|id |col |col |
+---+----+----+
|A  |a   |null|
|A  |c   |null|
|A  |null|1   |
|A  |null|5   |
|B  |a   |null|
|B  |b   |null|
|C  |null|1   |
+---+----+----+

We are thinking about several approaches:

*

*prefixing each value with a column indicator, merge all the arrays into a single one, explode it and reorganize the different values into different columns

*split the dataframe into several, each one with one of these array columns, explode the array column and then, concatenating the dataframes

But all of them smell like dirty, complex, error prone and inefficient workarounds.
Does anyone have an idea about how to solve this in an elegant manner?

A: In case both columns list_a and list_b could be empty, I would add a 4th case in the dataset
data = [
    ("A", ["a", "c"], ["1", "5"]),
    ("B", ["a", "b"], None),
    ("C", [], ["1"]),
    ("D", None, None),
]
df = spark.createDataFrame(data,["id","list_a","list_b"])

I would then split the original df in 3 (both nulls, list_a exploded and list_b exploded) and the execute a unionByName
dfnulls = df.filter(col("list_a").isNull() & col("list_b").isNull())\
    .withColumn("list_a", lit(None))\
    .withColumn("list_b", lit(None))

df1 = df\
    .withColumn("list_a", explode_outer(col("list_a")))\
    .withColumn("list_b", lit(None))\
    .filter(~col("list_a").isNull())

df2 = df\
    .withColumn("list_b", explode_outer(col("list_b")))\
    .withColumn("list_a", lit(None))\
    .filter(~col("list_b").isNull())

merged_df = df1.unionByName(df2).unionByName(dfnulls)

merged_df.show()

+---+------+------+
| id|list_a|list_b|
+---+------+------+
|  A|     a|  null|
|  A|     c|  null|
|  B|     a|  null|
|  B|     b|  null|
|  A|  null|     1|
|  A|  null|     5|
|  C|  null|     1|
|  D|  null|  null|
+---+------+------+

A: Try this dynamic solution.
Input:
data = [
    ("A", ["a", "c"], ["1", "5"]),
    ("B", ["a", "b"], None),
    ("C", [], ["1"]),
]
df=spark.createDataFrame(data,["id","list_a","list_b"])
df.show(truncate=False)
+---+------+------+
|id |list_a|list_b|
+---+------+------+
|A  |[a, c]|[1, 5]|
|B  |[a, b]|null  |
|C  |[]    |[1]   |
+---+------+------+

Lets create an array of Dataframes for each of the array columns in df.
Initialize first with empty Dataframe and then override it in the for loop.
For each column, explode it and for all other columns, change the datatype to string with NULL.
from pyspark.sql.types import *
array_cols=df.columns[1:]  #just ignoring the ID column
c=0
dfarr=[spark.createDataFrame([],schema=StructType()) for i in array_cols ]
for i in array_cols:
    dfarr[c]=df.withColumn(i,explode(col(i)))
    for j in array_cols:
        if(i!=j):
            dfarr[c]=dfarr[c].withColumn(j,expr(" cast(null as string) "))
    c=c+1

Now, dfarr is an array of dataframes with the schema like
dfarr[0].printSchema()
root
 |-- id: string (nullable = true)
 |-- list_a: string (nullable = true)
 |-- list_b: string (nullable = true)

dfarr[1].show(truncate=False)
+---+------+------+
|id |list_a|list_b|
+---+------+------+
|A  |null  |1     |
|A  |null  |5     |
|C  |null  |1     |
+---+------+------+

The datatypes in dfarr is all similar now, so just do a union of all them. For this we need the reduce function from functools
from functools import reduce
from pyspark.sql import DataFrame

def unionAll(*dfs):
    return reduce(DataFrame.unionByName, dfs)

Applying to our dfarr
combo=unionAll(*dfarr)

combo.show(truncate=False)
+---+------+------+
|id |list_a|list_b|
+---+------+------+
|A  |a     |null  |
|A  |c     |null  |
|B  |a     |null  |
|B  |b     |null  |
|A  |null  |1     |
|A  |null  |5     |
|C  |null  |1     |
+---+------+------+

A: The following approach might help you and it's based on Scala
Basically exploding the respective list columns individually and joining the datasets based on the dummy column to get the desired result.
import org.apache.spark.sql.functions.{explode_outer, col, lit, concat}

val df1 = inputDF
  .withColumn("list_a", explode_outer(col("list_a")))
  .withColumn("random_join_col", concat(col("id"), lit("1")))
  .drop("list_b")

val df2 = inputDF
  .withColumn("list_b", explode_outer(col("list_b")))
  .withColumn("random_join_col", concat(col("id"), lit("2")))
  .drop("list_a")

val finalDF = df1.join(df2, Seq("id", "random_join_col"), "full_outer").drop("random_join_col")

// Drop rows, if it got null value on both the list columns
finalDF.na.drop(how = "all", Seq("list_a","list_b")).orderBy("id").show(false)


text:
Q: Is there any way to integrate Express route with Azure function or service fabric using private IP Address? I have one cloud service which communicates with Express route with private IP address. I want to migrate this to an Azure Function or Service Fabric but due to private IP address I am unable to migrate cloud service. Is there any way to integrate Azure Function or Service Fabric with cloud service using private IP address (I cant use public address because of security reasons)?

A: Yes, you can run Azure Functions inside a virtual network. See here for the different options: https://learn.microsoft.com/en-us/azure/azure-functions/functions-networking-options

Also Service Fabric can be deployed inside a private VNET: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-patterns-networking


text:
Q: Xdebug connection breaks instantly in PhpStorm Xdebug stopped working in PhpStorm. The connection is lost in less than a second. I connect to Xdebug via SSH. I have attached a video with the bug. I will be grateful for any help.

*

*PHP 7.3.33

*Xdebug 3.1.5

*PhpStorm 2022.2.3

*Mac OS

bug video (google disk)

A: General approach in troubleshooting here:

*

*Enable Xdebug log (most likely will need to restart your web server/php-fpm) and try to debug again. Then check the log to see if it was a clean exit or it just died/process terminated. Maybe Xdebug is crashing.

*You may also enable extra logging on PhpStorm end to see their side of things. Then you can check the idea.log via PhpStorm | Help | Show Log in XXX
P.S. Just in case: see if disabling Settings (Preferences on macOS) | PHP | Debug | Enable '__toString' object view option will make any difference. PhpStorm 2022.2 has implemented this functionality but it looks like not all corner cases may be covered yet.

Since disabling the Enable '__toString' object view option helped, then please check out the 2022.3 EAP version -- EAP builds have a few tickets fixed in this area.
Since it works OK for you in 2022.3 EAP build then it could be one of these tickets (cannot say which one without knowing the code / seeing the logs etc.):

*

*WI-68096 -- '__toString' in Debugger triggers custom error handler

*WI-68622 -- Enable '__toString() object view': code that reads from stream ends early under debugger


text:
Q: Disable Model Validation [Required] in ASP.NET Web API So basically I have two classes which are Model and DTO, Model will be used to handle the APIs while the DTO will be handling the database (Firestore).
I have a Company model, in this model, the CompanyName is required when I'm doing CreateCompany POST request.
public class Company
{
    public string CompanyId { get; set; }

    [Required]
    public string CompanyName { get; set; }
}

This is the Employee model, which I used to create employee's details, and Company model will be used in this class.
public class Employee
{
    public string EmployeeId { get; set; }

    public bool? IsFirstLogin { get; set; }

    [Required]
    public string Name { get; set; }

    [Required]
    [EmailAddress]
    public string PaypalEmail { get; set; }

    [Required]
    [Phone]
    public string PhoneNumber { get; set; }

    public Company company { get; set; }
}

Now the problem is when I made a CreateEmployee POST request, I will only need the Employee.company.CompanyId to be filled in, but because in the Company model, the Company.CompanyName has set to [Required] earlier, and it made a must to fill in the Employee.company.CompanyName as well.
So I was thinking if there is any way I can disable the Model Validation during making a CreateEmployee POST request. Or maybe I should only enable the Model Validation during CreateCompany POST request?

A: You can create custom validation attribute validating CompanyName based on whether Company is inner property or top level model
[AttributeUsage(AttributeTargets.Class)]
public class RequiredCompanyNameAttribute: RequiredAttribute
{
    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        //validate if top level model
        if (validationContext.ObjectType == typeof(Company))
            return base.IsValid(value, validationContext);

        //no validation inside Employee
        return ValidationResult.Success;
    }

    public override bool IsValid(object value)
    {
        Company company = (Company)value;
        //validate CompanyName with RequiredAttribute
        return base.IsValid(company.CompanyName);
    }
}

And usage
[RequiredCompanyName]
public class Company
{
    public string CompanyId { get; set; }

    public string CompanyName { get; set; }
}

But the easiest would be intoducing different models for this purpose
public class Company
{
    public string CompanyId { get; set; }

    [Required]
    public string CompanyName { get; set; }
}

public class EmployeeCompany
{
    [Required]
    public string CompanyId { get; set; }

    public string CompanyName { get; set; }
}

public class Employee
{
    //..

    public EmployeeCompany Company { get; set; }
}

A: Remove the offending property from the ModelState
ModelState.Remove( "Company.CompanyName" );


text:
Q: pip DO NOT MATCH THE HASHES no known caching Any package I try to install using python 2/3 will fail on hash comparison eg
/opt/homebrew/opt/python@3.10/bin/python3  -m pip install --upgrade pip
Requirement already satisfied: pip in /opt/homebrew/lib/python3.10/site-packages (22.0.2)
Collecting pip
  Downloading pip-22.0.4-py3-none-any.whl
     \ 523.2 kB 7.1 MB/s 0:00:00
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE.

same python different package
Installing with pip..
Collecting pynvim
  Downloading pynvim-0.4.3.tar.gz
     / 523 kB 5.2 MB/s
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE.

have tried:

*

*rm -rf ~/.cache/pip/

*brew uninstall python // and reinstall

*.. --no-cache-dir ..

*manually downloading a .whl file (failing: ERROR: Wheel 'pip' located at {location}/pip-22.0.4-py3-none-any.whl is invalid.

*not seeing any local cache that pip could use

worth noting, I started with SSL cert issues from files.pythonhosted - it seems they don't have a valid cert on files domain, so I've added this pip.conf which brought me to the subsequent hashes error:
cat ~/.config/pip/pip.conf
[global]
trusted-host = pypi.python.org
           pypi.org
           files.pythonhosted.org

tried easy_install.py - failing on same SSL cert issues
tried get-pip.py - failing on hashes issues on both python2 and python 3 eg
/usr/bin/python get-pip2.py
DEPRECATION: Python 2.7 ...
Defaulting to user installation because normal site-packages is not writeable
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl
     / 523 kB 4.3 MB/s
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE.

I'm out of ideas and cannot find anything relevant online, anyone have any suggestions?
Thanks!

A: Turns out that my Internet provider was blocking files.pythonhosted due to the insecure self signed ssl certificate.
The hash was the same for every pip package - the reason was I was getting a my provider was redirecting me "blocking content" html error page, which in turn caused pips hash validation security check to fail.


text:
Q: Type casting operator is not being called I was trying to do some example code for type conversions between objects, just following what is showed here.
This is the parent class
// ParentClass.h
class ParentClass {
public:
    ParentClass();
    virtual ~ParentClass();
};

It´s just some concept proof, the only thing it does is print something
#include <iostream>
#include "ParentClass.h"
ParentClass::ParentClass()
{
    std::cout << "Parent\tDefault constructor\n";
}
ParentClass::~ParentClass()
{
    std::cout << "Parent\tDestructor\n";
}

And then, the derived class
// ChildClass.h
#include "ParentClass.h"

class ChildClass: public ParentClass {
public:
    ChildClass();
    // conversion constructor
    ChildClass( const ParentClass& p );
    // conversion from assignment
    ChildClass& operator= ( const ParentClass & p );
    // type-cast operator
    operator ParentClass();
    // destructor
    virtual ~ChildClass();
};

And then, the code, is also rather stupid
// ChildClass.cpp

#include <iostream>
#include "ChildClass.h"

ChildClass::ChildClass()
{
    std::cout << "Child\tDefault constructor\n";
}
ChildClass::~ChildClass()
{
    std::cout << "Child\tDestructor\n";
}
// conversion constructor
ChildClass::ChildClass( const ParentClass& p )
{
    std::cout << "Child\tConversion constructor\n";
}
// assignment operator
ChildClass& ChildClass::operator= ( const ParentClass & p )
{
    std::cout << "Child\toperator= conversion\n";
    return *this;
}
// type-cast operator
ChildClass::operator ParentClass()
{
    std::cout << "Child\toperatorParentClass()\n";
    return ParentClass();
}

Then, I do some conversions in my main function
    std::cout << "calls Parent default constructor\n";
    ParentClass foo;
    std::cout << "calls Parent to child constructor\n";
    ChildClass bar = foo;
    std::cout << "calls assignment operator from child\n";
    bar = foo;
    std::cout << "calls Child type-cast operator\n";
    foo = bar;
    std::cout << "Exit\n";

But when I run this the code is not entering the type cast operator from the derived class, it just prints this:
calls Parent default constructor
Parent  Default constructor
calls Parent to child constructor
Parent  Default constructor
Child   Conversion constructor
calls assignment operator from child
Child   operator= conversion
calls Child type-cast operator
Exit
Child   Destructor
Parent  Destructor
Parent  Destructor

I am at a loss about this, as I tried the code in the link above and it worked just like it should.

A: Derived-to-base conversion never invokes a conversion function. [class.conv.fct]/p1:

A conversion function is never used to convert a (possibly
  cv-qualified) object to the (possibly cv-qualified) same object type
  (or a reference to it), to a (possibly cv-qualified) base class of
  that type (or a reference to it), or to (possibly cv-qualified)
  void.

In your foo = bar;, the bar binds directly to the const ParentClass& parameter of the implicitly-declared copy assignment operator of ParentClass.


text:
Q: Unable to resolve clj-http I want to use clj-http, so I created a project with lein with these dependencies in project.clj:
(defproject app "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:main app.core
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
          :url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
            [clj-http "2.0.0"]])

src/app/core.clj:
(ns app.core
  (:require [clj-http.client :as client]))

(println client)

(defn -main
  [& args])

when I use lein clean && lein deps && lein run, I get an error message:
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: client in this context, compiling:(app/core.clj:4:1)
    at clojure.lang.Compiler.analyze(Compiler.java:6543)
    at clojure.lang.Compiler.analyze(Compiler.java:6485)
    at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3791)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6725)
    at clojure.lang.Compiler.analyze(Compiler.java:6524)
    at clojure.lang.Compiler.analyze(Compiler.java:6485)

lein version output:
Leiningen 2.5.3 on Java 1.8.0_45 Java HotSpot(TM) 64-Bit Server VM
Did I make something wrong? I followed exactly the clj-http documentation.
Thank you.

A: Requiring [clj-http.client :as client] lets you refer to Vars defined in that namespace using client as a prefix. For example, you could say
(client/get "http://example.com/")

and get back a response.
This usage, however, is unrelated to using the symbol client to refer to a Var or a local, and so this isn't going to work:
(println client)

client is just a namespace alias registered in the current namespace, and those can't be evaluated.


text:
Q: how to add log.path and data.path to elastic.yaml for kuberenetes to deploy with operator **
good day!
i try to deploy elastic with operator in Kubernetes with this code
**
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: elastic-cluster
  namespace: elastic-system
spec:
  version: 7.16.3
  nodeSets:
  - name: data
    count: 1
    config:
      node.master: false
      node.data: true
      node.ingest: false
      xpack.ml.enabled: false
      node.store.allow_mmap: false
    podTemplate:
      spec:
       containers:
          - name: elasticsearch
            env:
            #  - name: ES_JAVA_OPTS
            #    value: -Xms1g -Xmx1g
              - name: READINESS_PROBE_TIMEOUT
                value: "30"
            #resources:
            #  requests:
            #    memory: 1Gi
            #    cpu: 1
            #  limits:
            #    memory: 1Gi
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 2G

**
but i dont know where in this file to mount the log.path and data.path and how to do it
any help?
**
*
italic
*


text:
Q: Passing a table name as a parameter to multiple SELECTs I have an SQL query that summarises columns of a table table_name (BigQuery Console) along the lines:
SELECT
(SELECT COUNT(*) FROM `table_name` WHERE A_col = 'Hello') /
(SELECT COUNT(*) FROM `table_name`) * 100 AS A_something,

(SELECT COUNT(*) FROM `table_name` WHERE B_col IS NULL) /
(SELECT COUNT(*) FROM `table_name`) * 100 AS B_something

How is it possible to have only a single place to specify table_name in the SQL query, so inside all the per-column SELECT's it's a parameter? For example:
(SELECT COUNT(*) FROM m WHERE B_col IS NULL) /
(SELECT COUNT(*) FROM m) * 100 AS B_something

A: I would just use conditional aggregation:
select avg(case when a_col = 'Hello' then 100.0 else 0 end) as a_something,
       avg(case when b_col is null then 100.0 else 0 end) as b_something
from m

If you want to use this expression multiple times, use a CTE:
with params as (
      select avg(case when a_col = 'Hello' then 100.0 else 0 end) as a_something,
             avg(case when b_col is null then 100.0 else 0 end) as b_something
      from m
     )
select . . .
from params cross join
     . . .

A: You can use a CTE (Common Table Expression). You don't mention what database you are using. As an example, the following query will work in PostgreSQL:
with
m as (
  select * from table_name
)
select
  (select count(*) from m where a_col = 'Hello') /
  (select count(*) from m) * 100 as a_something,
  (select count(*) from m where b_col = 'Hello') /
  (select count(*) from m) * 100 as b_something

A: For BigQuery Standard SQL
SELECT
  100 * COUNTIF(A_col = 'Hello') /  COUNT(*) AS A_something,
  100 * COUNTIF(B_col IS NULL) / COUNT(*)  AS B_something
FROM `table_name`