text:
Q: Where can I find a list of common phrases? I'm not so good at english, and I would ask if someone knows a website that lists the most used english ways to say, like for example, "eat the bullet" or "with a grain of salt".
I've done some research about it, but the only thing I got is Urban Dictionary, but unfortunately it's not easy to find the phrases; it would be great to have a vocabulary of "ready phrases" (for poor-english people like me:-)

A: There is a good website devoted to phrases in British and American English here.
That said, I would recommend avoiding "ready made phrases".  In the vocabulary of language learners, they tend to sound forced, and worse, unintentionally comical.
It is important to be able to understand the idioms used by native speakers, but I would generally discourage their use until your language skills have improved to the point where they occur organically.
Best of luck!

A: Well what you're looking for are called idioms or colloquialisms. Searching with those terms might help. That said here are a couple lists of examples to help you out:
http://en.wikipedia.org/wiki/List_of_English-language_idioms
http://www.idiomsite.com/
http://www.learn-english-today.com/idioms/idioms_alphalistsA-Z.htm
Heck, http://lmgtfy.com/?q=english+idioms+list+for+learning+the+language


text:
Q: Edit role error 'Wrong tab configuration' I'm not very familiar with magento code,
Recently when I try to add/edit the user role I got following error, can anybody help me how to solve this issue.
Wrong tab configuration.

#0 /var/www/html/app/code/core/Mage/Adminhtml/Block/Permissions/Editroles.php(42): Mage_Adminhtml_Block_Widget_Tabs->addTab('account', false)
#1 /var/www/html/app/code/core/Mage/Core/Block/Abstract.php(293): Mage_Adminhtml_Block_Permissions_Editroles->_prepareLayout()
#2 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#3 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('adminhtml/permi...', 'adminhtml.permi...')
#4 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('adminhtml/permi...', 'adminhtml.permi...')
#5 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#6 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#7 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#8 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#9 /var/www/html/app/code/core/Mage/Adminhtml/Controller/Action.php(275): Mage_Core_Controller_Varien_Action->loadLayout(NULL, true, true)
#10 /var/www/html/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php(44): Mage_Adminhtml_Controller_Action->loadLayout()
#11 /var/www/html/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php(105): Mage_Adminhtml_Permissions_RoleController->_initAction()
#12 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Permissions_RoleController->editRoleAction()
#13 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('editrole')
#14 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#15 /var/www/html/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#16 /var/www/html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#17 /var/www/html/index.php(83): Mage::run('', 'store')
#18 {main}

A: you are getting the error here:
https://github.com/bragento/magento-core/blob/1264aee821b451b3c88e55659cd1ee79d3b324af/app/code/core/Mage/Adminhtml/Block/Permissions/Editroles.php#L42
For some reason, the
$this->getLayout()->createBlock('adminhtml/permissions_tab_rolesedit','adminhtml.permissions.tab.rolesedit')

returns false in your shop.
Looking at here:
https://github.com/bragento/magento-core/blob/1264aee821b451b3c88e55659cd1ee79d3b324af/app/code/core/Mage/Core/Model/Layout.php#L437
we see that this happens, when an expetion is raised during the _getBlockInstance Call
Since this Exception should get Logged, you should take a look at the last message in your var/log/exception.log
Then looking at here:
https://github.com/bragento/magento-core/blob/1264aee821b451b3c88e55659cd1ee79d3b324af/app/code/core/Mage/Core/Model/Layout.php#L484
might give you the answer

A: I had had this same error, but I fix it recreating my file adminhtml.xml, you can use this below like a sample and changing the necessary tags, that are line 11, 12 and 14 to your custom module name.
<?xml version="1.0"?>
<config>
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <YOURVENDOR_YOURMODULE>
                                        <title>YOURMODULE</title>
                                        <sort_order>1000</sort_order>
                                    </YOURVENDOR_YOURMODULE>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</config>

redpajama_set_name: RedPajamaStackExchange


text:
Q: Hover-State at bottom of element I am currently developing a styleguide and the hover-state of my navigation is giving me some headache, but I am pretty sure, that it could be solved very easily, so I just want to ask, if someone has an idea.
My html looks like this:

Design

Components

Motionguide

and my css looks like this:
.components__navigation {
    display: flex;
    height: 75px;
    align-items: center;
    padding-left: 50px;
    border-bottom: 4px solid #f5f5f5;
}

.components__navigation img {
    width: 250px;
    height: 40px;
    margin-right: 100px;
}

.components__navListTop {
    font-size: 14px;
    display: flex;
    list-style: none;
    padding: 0;
}

.components__navListTop a {
    color: #333;
    text-decoration: none;
    margin-right: 50px;
}

.components__navItem a {
    text-decoration: none;
    background-image: linear-gradient(#ffda00,#ffda00),linear-gradient(#fff,#fff);
    background-size: 0 3px,auto;
    background-repeat: no-repeat;
    background-position: bottom;
    transition: background .2s linear;
}

.components__navItem a:hover {
    background-size: 100% 3px,auto;
}

#active a {
    background-image: linear-gradient(#ffda00,#ffda00),linear-gradient(#fff,#fff);
    background-size: 100% 3px,auto;
    background-repeat: no-repeat;
    background-position: bottom;
}

Here is a pen to make it more visual:
https://codepen.io/dbljn/pen/abbMdVE
The current hover-state is right under the font of the tabs, but I want the hover-state to be where the gray border is. Like so:

Do you have an idea? And thanks a lot!!

A: It is always a good practice to write similar styling rules when the elements are overlapping on each other.
for example, we could use the same background-image property with nav html element instead of border property
.components__navigation {
    display: flex;
    align-items: center;
    padding-left: 50px;
    background-image: linear-gradient(transparent 90%, #f5f5f5 0);
}

remove the margin from ul element and background-image from below selectors so that the nav element will spread on li element and will be dynamic
.components__navListTop {
    font-size: 14px;
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
}

.components__navListTop a {
    color: #333;
    text-decoration: none;
}

finally give the li element its background-image and other CSS rules,
.components__navItem {
    padding: 20px 0;
    margin-right: 50px;
    background-image: linear-gradient(transparent 90%,#ffda00 0);
    background-size: 0;
    background-repeat: no-repeat;
    background-position: bottom;
    transition: background .2s linear;
}

Since you want the animation while hovering on li element, the :hover pseudo attribute should be present on this li element, also it's good to use classes instead of id
.components__navItem:hover, .active {
    background-size: 100%;
}

Finally putting it all together,

body, html {
    margin: 0;
}

.components__navigation {
    display: flex;
    align-items: center;
    padding-left: 50px;
    background-image: linear-gradient(transparent 90%, #f5f5f5 0);
}

.components__navigation img {
    width: 250px;
    height: 40px;
    margin-right: 100px;
}

.components__navListTop {
    font-size: 14px;
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
}

.components__navListTop a {
    color: #333;
    text-decoration: none;
}

.components__navItem {
    padding: 20px 0;
    margin-right: 50px;
    background-image: linear-gradient(transparent 90%,#ffda00 0);
    background-size: 0;
    background-repeat: no-repeat;
    background-position: bottom;
    transition: background .2s linear;
}

.components__navItem:hover, .active {
    background-size: 100%;
}

Design

Components

Motionguide

A: Try replacing .components__navItem a with:
.components__navItem a {
    text-decoration: none;
    background-image: linear-gradient(#ffda00,#ffda00);
    background-size: 0 3px,auto;
    background-repeat: no-repeat;
    background-position: bottom;
    transition: background .2s linear;
    padding-bottom: 33px;
}

This is assuming a fixed font size though.


text:
Q: Python pygame mixer music detect if ended I'm making a simple music player with a pygame mixer, and I have to know if the music ended. Is there any easy way?
Something like this:
if pygame.mixer.music.is_ended: #like this!
    pass

A: If you just want to confirm the music and yu can just simply perform a test in the terminal
if pygame.mixer.music.is_ended: #like this!
    print('yes')

** you can further add a second program ,if you want to do something else you can also do the same.......**
Here is a example if you want to continue music till the end of the program
mixer.music.load('background.wav')
mixer.music.play(-1)

Here -1 will repeat the song again and again


text:
Q: iOS swipe back gesture with Custom page route i am trying to use Android Page Transition on iOS. i set fullscreenDialog to true this works well but the Swipe back gesture on iOS is disabled. How can i enable it back still using the Android Page Transition.
Navigator.push(
                              context,
                              MaterialPageRoute(
                                builder: (context) => Chat(
                                  peerid: peerid,
                                  userid: widget.matchesId,
                                ),
                                fullscreenDialog: true
                              ),
                            );

Also i have try to use this plugin still yet getting the-same result. The swipe back gesture on iOS still disabled...


text:
Q: How to deploy NodeJS App to Heroku? I am creating a chat app with NodeJS, and I want to deploy to Heroku. However,  I get an error: An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. by using the Github deployment. Does anyone know what is going on?

Here is some code to see what I have done.

    {
  "name": "chat",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./lib/index.js",
    "test": "jasmine"
  },
  "dependencies": {
    "express": "~4.13.1",
    "firebase": "^3.9.0",
    "request-promise": "^2.0.1",
    "socket.io": "^1.4.5"
  },
  "devDependencies": {
    "jasmine-sinon": "^0.4.0",
    "jscs": "^2.11.0",
    "proxyquire": "^1.7.4",
    "rewire": "^2.5.1",
    "sinon": "^1.17.3"
  }
}

index.js (Server)

    var express = require('express');
var app = express();
var path = require('path');
var http = require('http').Server(app);
var io = require('socket.io')(http);

var routes = require('./routes');
var chats = require('./chat');

app.use(express.static(path.join(__dirname, '../public')));

routes.load(app);
chats.load(io);

var port = process.env.PORT || 3000;
app.listen(port);
console.log('Server is listening at port:' + port);

A: I got the app working in a Heroku. The issue in your code is that you're not setting the correct port for heroku to work. In the code you provided you're setting the correct port by doing
var port = process.env.PORT || 3000;

However, in your GitHub project you're hardcoding the port to 3000
http.listen(3000, function () {
  console.log('listening on *:3000');
});

Instead what you want to do is allow Heroku to define the port or default to 3000 for development like so..
var process = require('process');

var port = process.env.PORT || 3000;
http.listen(port, function() {
  console.log("Server is listening on port: " + port);
});

Once you have that, deploy to Heroku and you should see your app running.


text:
Q: Does module names reside in a separate "name space", or could they collide with e.g. variable names? I guess/hope that module names will not collide with e.g. names of variables. Could someone confirm this, and perhaps reference a suitable section in the (upcoming) standard?
File: a_module.cc
export module a_module;
export int add(int a, int b) { return a + b; }

// Question-1: Is using 'a_module' below as variable name allowed, or does
// the 'export module a_module' above prevent us from using that name?
int a_module = 11;

File: main.cc
import a_module;

// Question-2: Is using 'a_module' below as variable name fine, or does the
// 'import a_module' above prevent us from using that name?
int a_module = 42;

int main() { return add(1, 2); }

A: It's hard to cite a negative, but yes - module names cannot collide with non-module names.
We have lots and lots of kinds of name lookup in C++, but none of them consider module names. Like the statement f(x); can find many kinds of things named f and x and those ()s could even mean different things, but it can never find either a module named f or x. Having modules named one or the other or both does not change any of the lookup.
Likewise, in the preamble, all module-related statements (import, export, module declarations or partition declarations) only consider module names. If you have something like:
import M1;
import M2;

And M1 happens to export some name M2, that won't break the subsequent import of M2. We're only looking for, specifically, modules named M2.
You don't have to worry about collisions between these two things.


text:
Q: How I get a list of the online users in Yii2? How do I get the list of the online users in yii2? I want to see who is onlone and who signed out.

A: I was the same problem recently and I finished saving a timestamp to any login and logout action of each user in a table, because I didn't find any "native" solution.
You could solve your problem with a couple of lines as a first approach.
Depending on of your auth system maybe there are some better solution.


text:
Q: BouncyCastle undefined length ASN1 I try to get a X509Certificate2 from a BountyCastle X509Certificate and a PKCS12. I use the following code:
 certificate = new X509Certificate2(rawData, password, storageFlags);

I generate the rawData, like the following:
using (MemoryStream pfxData = new MemoryStream())
{
   X509CertificateEntry[] chain = new X509CertificateEntry[1];

   chain[0] = new X509CertificateEntry(x509);
   pkcsStore.SetKeyEntry(applicationName, new AsymmetricKeyEntry(subjectKeyPair.Private), chain);
   pkcsStore.Save(pfxData, passcode.ToCharArray(), random);
   var rawData = pfx.ToArray();
}

The problem is, that I get the following exception:

After some days of researching, I figured out, that the problem is based on the Mono implementation of ASN1. This implementation doesn't allow "Undefined length encoding". If I use the code on Windows it works great.
My question
Is there any way, to convert the pfxData stream to a valid ASN1 structure?
I have tried it with the following code:
Asn1InputStream asn1InputStream = new Asn1InputStream(pfxData);
var asn1Object = asn1InputStream.ReadObject();

MemoryStream memoryStream = new MemoryStream();
new Asn1OutputStream((Stream)memoryStream).WriteObject(asn1Object);
var asn1ByteArray = memoryStream.ToArray();

certificate = new X509Certificate2(asn1ByteArray);

But with this code, I get the following exception:

"Index was out of range. Must be non-negative and less than the size of the collection.\nParameter name: startIndex"

I use Xamarin PCL with .NET Standard 1.3 and I can only use the "Portable.BouncyCastle" Nuget package.
UPDATE Exception Stack Trace (Converting BER to DER):
05-28 15:19:54.895 D/Mono    ( 3808): Assembly Ref addref Mono.Security[0x9b4fe080] -> System[0xac8de400]: 17
05-28 15:19:54.957 I/mono-stdout( 3808): System.AggregateException: One or more errors occurred. ---> System.Security.Cryptography.CryptographicException: Unable to decode certificate. ---> System.Security.Cryptography.CryptographicException: Input data cannot be coded as a valid certificate. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
System.AggregateException: One or more errors occurred. ---> System.Security.Cryptography.CryptographicException: Unable to decode certificate. ---> System.Security.Cryptography.CryptographicException: Input data cannot be coded as a valid certificate. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex
  at System.String.IndexOf (System.String value, System.Int32 startIndex, System.Int32 count, System.StringComparison comparisonType) [0x0002a] in <d18287e1d683419a8ec3216fd78947b9>:0
  at System.String.IndexOf (System.String value, System.Int32 startIndex, System.StringComparison comparisonType) [0x00009] in <d18287e1d683419a8ec3216fd78947b9>:0
  at System.String.IndexOf (System.String value, System.Int32 startIndex) [0x00000] in <d18287e1d683419a8ec3216fd78947b9>:0
  at Mono.Security.X509.X509Certificate.PEM (System.String type, System.Byte[] data) [0x00030] in <2940be14d5a1446694e2193e9029b558>:0
  at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x00014] in <2940be14d5a1446694e2193e9029b558>:0
   --- End of inner exception stack trace ---
  at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x0002f] in <2940be14d5a1446694e2193e9029b558>:0
05-28 15:19:54.958 I/mono-stdout( 3808): Parameter name: startIndex
  at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x0000b] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
   --- End of inner exception stack trace ---
  at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00031] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at System.Security.Cryptography.X509Certificates.X509Helper2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags, System.Boolean disableProvider) [0x00020] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at System.Security.Cryptography.X509Certificates.X509Certificate2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00000] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor (System.Byte[] rawData) [0x00011] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
05-28 15:19:54.958 I/mono-stdout( 3808):   at System.String.IndexOf (System.String value, System.Int32 startIndex, System.Int32 count, System.StringComparison comparisonType) [0x0002a] in <d18287e1d683419a8ec3216fd78947b9>:0
  at APP.Models.Services.ACommunicationService.CreateCertificate (System.String storeType, System.String storePath, System.String password, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] domainNames, System.UInt16 keySize, System.DateTime startTime, System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits, System.Boolean isCA, System.Security.Cryptography.X509Certificates.X509Certificate2 issuerCAKeyCert) [0x003b5] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:517
05-28 15:19:54.958 I/mono-stdout( 3808):   at System.String.IndexOf (System.String value, System.Int32 startIndex, System.StringComparison comparisonType) [0x00009] in <d18287e1d683419a8ec3216fd78947b9>:0
  at APP.Models.Services.ACommunicationService.CreateCertificate (System.String storeType, System.String storePath, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] serverDomainNames, System.UInt16 keySize, System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits) [0x00001] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:318
  at APP.Models.Services.ACommunicationService+<ACommunicationServiceAsync>d__18.MoveNext () [0x00972] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:214
   --- End of inner exception stack trace ---
05-28 15:19:54.959 I/mono-stdout( 3808):   at System.String.IndexOf (System.String value, System.Int32 startIndex) [0x00000] in <d18287e1d683419a8ec3216fd78947b9>:0
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <d18287e1d683419a8ec3216fd78947b9>:0
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <d18287e1d683419a8ec3216fd78947b9>:0
  at System.Threading.Tasks.Task.Wait () [0x00000] in <d18287e1d683419a8ec3216fd78947b9>:0
  at APP.Models.Services.ACommunicationService..ctor (PCLStorage.IFolder rootFolder) [0x00010] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:46
05-28 15:19:54.959 I/mono-stdout( 3808):   at Mono.Security.X509.X509Certificate.PEM (System.String type, System.Byte[] data) [0x00030] in <2940be14d5a1446694e2193e9029b558>:0
05-28 15:19:54.959 I/mono-stdout( 3808):   at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x00014] in <2940be14d5a1446694e2193e9029b558>:0
05-28 15:19:54.959 I/mono-stdout( 3808):    --- End of inner exception stack trace ---
05-28 15:19:54.959 I/mono-stdout( 3808):   at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x0002f] in <2940be14d5a1446694e2193e9029b558>:0
05-28 15:19:54.959 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x0000b] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
---> (Inner Exception #0) System.Security.Cryptography.CryptographicException: Unable to decode certificate. ---> System.Security.Cryptography.CryptographicException: Input data cannot be coded as a valid certificate. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
05-28 15:19:54.961 I/mono-stdout( 3808):    --- End of inner exception stack trace ---
05-28 15:19:54.961 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00031] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
05-28 15:19:54.961 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Helper2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags, System.Boolean disableProvider) [0x00020] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
05-28 15:19:54.962 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Certificate2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00000] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
05-28 15:19:54.962 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor (System.Byte[] rawData) [0x00011] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
Parameter name: startIndex
05-28 15:19:54.963 I/mono-stdout( 3808):   at APP.Models.Services.ACommunicationService.CreateCertificate (System.String storeType, System.String storePath, System.String password, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] domainNames, System.UInt16 keySize, System.DateTime startTime, System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits, System.Boolean isCA, System.Security.Cryptography.X509Certificates.X509Certificate2 issuerCAKeyCert) [0x003b5] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:517
05-28 15:19:54.963 I/mono-stdout( 3808):   at APP.Models.Services.ACommunicationService.CreateCertificate (System.String storeType, System.String storePath, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] serverDomainNames, System.UInt16 keySize, System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits) [0x00001] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:318
05-28 15:19:54.964 I/mono-stdout( 3808):   at APP.Models.Services.ACommunicationService+<ACommunicationServiceAsync>d__18.MoveNext () [0x00972] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:214
05-28 15:19:54.964 I/mono-stdout( 3808):    --- End of inner exception stack trace ---
05-28 15:19:54.965 I/mono-stdout( 3808):   at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <d18287e1d683419a8ec3216fd78947b9>:0
05-28 15:19:54.965 I/mono-stdout( 3808):   at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <d18287e1d683419a8ec3216fd78947b9>:0
05-28 15:19:54.965 I/mono-stdout( 3808):   at System.Threading.Tasks.Task.Wait () [0x00000] in <d18287e1d683419a8ec3216fd78947b9>:0
  at System.String.IndexOf (System.String value, System.Int32 startIndex, System.Int32 count, System.StringComparison comparisonType) [0x0002a] in <d18287e1d683419a8ec3216fd78947b9>:0
05-28 15:19:54.965 I/mono-stdout( 3808):   at APP.Models.Services.ACommunicationService..ctor (PCLStorage.IFolder rootFolder) [0x00010] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:46
05-28 15:19:54.966 I/mono-stdout( 3808): ---> (Inner Exception #0) System.Security.Cryptography.CryptographicException: Unable to decode certificate. ---> System.Security.Cryptography.CryptographicException: Input data cannot be coded as a valid certificate. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
05-28 15:19:54.966 I/mono-stdout( 3808): Parameter name: startIndex
05-28 15:19:54.967 I/mono-stdout( 3808):   at System.String.IndexOf (System.String value, System.Int32 startIndex, System.Int32 count, System.StringComparison comparisonType) [0x0002a] in <d18287e1d683419a8ec3216fd78947b9>:0
  at System.String.IndexOf (System.String value, System.Int32 startIndex, System.StringComparison comparisonType) [0x00009] in <d18287e1d683419a8ec3216fd78947b9>:0
  at System.String.IndexOf (System.String value, System.Int32 startIndex) [0x00000] in <d18287e1d683419a8ec3216fd78947b9>:0
  at Mono.Security.X509.X509Certificate.PEM (System.String type, System.Byte[] data) [0x00030] in <2940be14d5a1446694e2193e9029b558>:0
  at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x00014] in <2940be14d5a1446694e2193e9029b558>:0
   --- End of inner exception stack trace ---
  at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x0002f] in <2940be14d5a1446694e2193e9029b558>:0
  at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x0000b] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
   --- End of inner exception stack trace ---
  at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certif
icates.X509KeyStorageFlags keyStorageFlags) [0x00031] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at System.Security.Cryptography.X509Certificates.X509Helper2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags, System.Boolean disableProvider) [0x00020] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at System.Security.Cryptography.X509Certificates.X509Certificate2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00000] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor (System.Byte[] rawData) [0x00011] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at APP.Models.Services.ACommunicationService.CreateCertificate (System.String storeType, System.String storePath, System.String password, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] domainNames, System.UInt16 keySize, System.DateTime startTime,
System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits, System.Boolean isCA, System.Security.Cryptography.X509Certificates.X509Certificate2 issuerCAKeyCert) [0x003b5] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:517
  at APP.Models.Services.ACommunicationService.CreateCertificate (System.String storeType, System.String storePath, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] serverDomainNames, System.UInt16 keySize, System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits) [0x00001] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:318
  at APP.Models.Services.ACommunicationService+<ACommunicationServiceAsync>d__18.MoveNext () [0x00972] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:214 <---
05-28 15:19:54.968 I/mono-stdout( 3808):   at System.String.IndexOf (System.String value, System.Int32 startIndex, System.StringComparison comparisonType) [0x00009] in <d18287e1d683419a8ec3216fd78947b9>:0
05-28 15:19:54.969 I/mono-stdout( 3808):   at System.String.IndexOf (System.String value, System.Int32 startIndex) [0x00000] in <d18287e1d683419a8ec3216fd78947b9>:0
05-28 15:19:54.969 I/mono-stdout( 3808):   at Mono.Security.X509.X509Certificate.PEM (System.String type, System.Byte[] data) [0x00030] in <2940be14d5a1446694e2193e9029b558>:0
05-28 15:19:54.969 I/mono-stdout( 3808):   at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x00014] in <2940be14d5a1446694e2193e9029b558>:0
05-28 15:19:54.969 I/mono-stdout( 3808):    --- End of inner exception stack trace ---
05-28 15:19:54.969 I/mono-stdout( 3808):   at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x0002f] in <2940be14d5a1446694e2193e9029b558>:0
05-28 15:19:54.969 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x0000b] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
05-28 15:19:54.969 I/mono-stdout( 3808):    --- End of inner exception stack trace ---
05-28 15:19:54.969 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00031] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
05-28 15:19:54.970 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Helper2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags, System.Boolean disableProvider) [0x00020] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
05-28 15:19:54.970 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Certificate2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00000] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
05-28 15:19:54.970 I/mono-stdout( 3808):   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor (System.Byte[] rawData) [0x00011] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
05-28 15:19:54.970 I/mono-stdout( 3808):   at APP.Models.Services.ACommunicationService.CreateCertificate (System.String storeType, System.String storePath, System.String password, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] domainNames, System.UInt16 keySize, System.DateTime startTime, System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits, System.Boolean isCA, System.Security.Cryptography.X509Certificates.X509Certificate2 issuerCAKeyCert) [0x003b5] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:517
05-28 15:19:54.971 I/mono-stdout( 3808):   at APP.Models.Services.ACommunicationService.CreateCertificate (System.String storeType, System.String storePath, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] serverDomainNames, System.UInt16 keySize, System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits) [0x00001] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:318
05-28 15:19:54.971 I/mono-stdout( 3808):   at APP.Models.Services.ACommunicationService+<ACommunicationServiceAsync>d__18.MoveNext () [0x00972] in C:\projects\APP - Kopie\APP_XamarinApplication\APP\APP\APP\Models\Services\ACommunicationService.cs:214 <---

EDIT: I have posted the same question in BouncyCastle GitHub: BouncyCastle GitHub
EDIT 2: I have tested to save the PKCS and create a X509Certificate2 with string constructor, like the following:
var pkcsPath = pkcsStorePath + "/pkcs.p12";
File.WriteAllBytes(pkcsPath, pfxData.ToArray());

// Exception is thrown on this line (Undefined length):
certificate = new X509Certificate2(pkcsPath, string.Empty);

Edit 3: I have found the method var util = Pkcs12Utilities.ConvertToDefiniteLength(pfxData.ToArray(), certPassword.ToCharArray()); in the BouncyCastle library and if I use this method right before the File.WriteAllBytes(pkcsPath, util); line, the exception "Undefined length encoding." is gone. But now, I get the following exception:
06-01 21:05:54.903 I/mono-stdout(31001): System.Security.Cryptography.CryptographicException: Input data cannot be coded as a valid certificate. ---> System.Security.Cryptography.CryptographicException: Input data cannot be coded as a valid certificate.
System.Security.Cryptography.CryptographicException: Input data cannot be coded as a valid certificate. ---> System.Security.Cryptography.CryptographicException: Input data cannot be coded as a valid certificate.
  at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data) [0x0003b] in <2940be14d5a1446694e2193e9029b558>:0
   --- End of inner exception stack trace ---
  at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data) [0x00322] in <2940be14d5a1446694e2193e9029b558>:0
  at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x00030] in <2940be14d5a1446694e2193e9029b558>:0
06-01 21:05:54.905 I/mono-stdout(31001):   at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data) [0x0003b] in <2940be14d5a1446694e2193e9029b558>:0
  at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00041] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at System.Security.Cryptography.X509Certificates.X509Helper2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags, System.Boolean disableProvider) [0x00020] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at System.Security.Cryptography.X509Certificates.X509Certificate2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00000] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor (System.Byte[] rawData, System.String password) [0x00011] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
  at Pkcs12TestProject.MyClass.CreateCertific
ate (System.String storeType, System.String storePath, System.String password, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] domainNames, System.UInt16 keySize, System.DateTime startTime, System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits, System.Boolean isCA, System.Security.Cryptography.X509Certificates.X509Certificate2 issuerCAKeyCert, System.String pkcsStorePath) [0x00377] in C:\OneDrive\VS\Pkcs12TestProject\Pkcs12TestProject\Pkcs12TestProject\MyClass.cs:223
06-01 21:05:54.906 I/mono-stdout(31001):    --- End of inner exception stack trace ---
06-01 21:05:54.906 I/mono-stdout(31001):   at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data) [0x00322] in <2940be14d5a1446694e2193e9029b558>:0
06-01 21:05:54.906 I/mono-stdout(31001):   at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data) [0x00030] in <2940be14d5a1446694e2193e9029b558>:0
06-01 21:05:54.906 I/mono-stdout(31001):   at System.Security.Cryptography.X509Certificates.X509Certificate2ImplMono.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00041] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
06-01 21:05:54.906 I/mono-stdout(31001):   at System.Security.Cryptography.X509Certificates.X509Helper2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags, System.Boolean disableProvider) [0x00020] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
06-01 21:05:54.906 I/mono-stdout(31001):   at System.Security.Cryptography.X509Certificates.X509Certificate2.Import (System.Byte[] rawData, System.String password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) [0x00000] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
06-01 21:05:54.907 I/mono-stdout(31001):   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor (System.Byte[] rawData, System.String password) [0x00011] in <1a27f8ea09e3480db932cbde0eaedfb2>:0
06-01 21:05:54.907 I/mono-stdout(31001):   at Pkcs12TestProject.MyClass.CreateCertificate (System.String storeType, System.String storePath, System.String password, System.String applicationUri, System.String applicationName, System.String subjectName, System.Collections.Generic.IList`1[T] domainNames, System.UInt16 keySize, System.DateTime startTime, System.UInt16 lifetimeInMonths, System.UInt16 hashSizeInBits, System.Boolean isCA, System.Security.Cryptography.X509Certificates.X509Certificate2 issuerCAKeyCert, System.String pkcsStorePath) [0x00377] in C:\OneDrive\VS\Pkcs12TestProject\Pkcs12TestProject\Pkcs12TestProject\MyClass.cs:223

Edit 4: If I use the X509 certificate from BountyCastle as rawdata in the X509Certificate2 method, it works great! But it is without the private key..

A: I found some bugreports on your problem with possible workarounds outlined. I don't have an appropriate environment to test this myself - sorry. But from the history it looks like it hasn't really been resolved:

*

*Bugreport:

This explicitly states problems with BouncyCastle just like you experience. Sebastian Pouliot posts a sample code in comment3 that he thinks can be used (or parts of it) to work around the problem using mono.security.dll. I don't know if your usecase allows to use it. It is shipped with MonoDroid.
He goes into details in this comment and has the example code linked on github: https://github.com/mono/mono/blob/master/mcs/tools/security/makecert.cs

*There is also someone else who posted a problem with this. BouncyCastle is not explicitly mentioned: http://lists.ximian.com/pipermail/mono-bugs/2010-October/104908.html
His workaround at the end of post:
[Once you have the correct PKCS#12] Quote:

Write the byte[] PKCS#12 into a temporary file and load it with string
  constructor.

Update on source provided in comments
Hope my system worked correctly as it took hours to get it running. But then I got the following working.

The solution is to change the StoreBuilder to UseDEREncoding to true

Small bugfix up front
Finding: You put in a string.empty as password but protected the cert with a password. I think this is not correct. If I put in the password I get the first error again CryptographicException Certificate cannot be coded to valid certificate.
So first I changed this:
certificate = new X509Certificate2(pkcsPath, string.Empty);

to
certificate = new X509Certificate2(pkcsPath, certPassword);

Fix
And now I don't know if this is what you want but after changing it I didn't get an exception but a certificate object.
The complete changes of the "using memory stream" block finally looked like this:
using (MemoryStream pfxData = new MemoryStream())
{
    // **Change 1**: The DER Encoding is enabled on the
    // store builder
    Pkcs12StoreBuilder builder = new Pkcs12StoreBuilder();
    builder.SetUseDerEncoding(true);
    Pkcs12Store pkcsStore = builder.Build();
    // change - end

    X509CertificateEntry[] chain = new X509CertificateEntry[1];
    string certPassword = Guid.NewGuid().ToString();
    chain[0] = new X509CertificateEntry(x509);
    pkcsStore.SetKeyEntry(applicationName, new AsymmetricKeyEntry(subjectKeyPair.Private), chain);
    pkcsStore.Save(pfxData, certPassword.ToCharArray(), random);

    var pkcsPath = pkcsStorePath + "/pkcs.p12";

    File.WriteAllBytes(pkcsPath, pfxData.ToArray());

    // **Change 2**: Use certificate password
    certificate = new X509Certificate2(pkcsPath, certPassword);
    // **Change 3**: Possible to use array instead of filename
    // works as well. Just uncomment
    //certificate = new X509Certificate2(pfxData.ToArray(), certPassword);

}

A: Part of the problem seems to be that Mono's X509Certificate2 byte[] constructors don't behave the same as .NET Framework's X509Certificate2 byte[] constructors.
Browsing through the mono source it looks like X509Certificate2(byte[]) will try to load as a X.509 (individual) certificate, then as a PFX with a null (vs empty) password.
What has me the most confused about your callstack, and I was hoping to reproduce, is that it tried a PEM decode... which should only happen when the first byte isn't 0x30 (per the source), but 0x30 should be the first byte of the PFX as well.  (Then there's their mishandling of not finding -----BEGIN CERTIFICATE----- resulting in the ArgumentOutOfRangeException which sent me down a bad path. Oh, well.)
The .NET Framework implementation of new X509Certificate2(byte[]) is more flexible:

*

*X.509 DER

*X.509 PEM

*PFX null password

*PFX empty password

*PKCS#7 SignedCms signer certificate

*AuthentiCode signer certificate

(So Mono only tries half the things .NET Framework / .NET Core does)
Based on comments it seems like you are using a PFX with an empty password, so changing your post-DER normalization call from
new X509Certificate2(asn1ByteArray)

to
new X509Certificate2(asn1ByteArray, string.Empty)

should solve this particular aspect of the problem.


text:
Q: Creatives LinkedIn API - Projection parameters not supported with new versioned API `Hi All,
After LinkedIn API versioning, it seems that below projection parameter is not supported with creatives API call now :

*

*com.linkedin.ads.SponsoredVideoCreativeVariables

*com.linkedin.ads.SponsoredUpdateCarouselCreativeVariables

*com.linkedin.ads.SpotlightCreativeVariablesV2

*com.linkedin.ads.SponsoredUpdateCreativeVariables

*com.linkedin.ads.JobsCreativeVariablesV2

*com.linkedin.ads.SponsoredInMailCreativeVariables

Due to this, we are not able to fetch response similar to Old API call with new API now. This seems to be big impact to us.
For example , We are not receiving any of fields like 'showMemberProfilePhoto', 'forumName' for SpotlightCreativeVariablesV2 with new API which we used to get previously like mentioned below.
We have 2 headers in request as mentioned in LinkedIn API migration document.

*

*X-Restli-Protocol-Version : 2.0.0

*LinkedIn-Version : 202210

Old API call : https://api.linkedin.com/v2/adCreativesV2?ids=List({$creative_id})&projection=(results(*(variables(*,data(*,com.linkedin.ads.SpotlightCreativeVariablesV2(*,share~(*)))))))
Old API Response :
{
    "results": {
        "46524875": {
            "variables": {
                "clickUri": "$clickUri",
                "data": {
                    "com.linkedin.ads.SpotlightCreativeVariablesV2": {
                        "showMemberProfilePhoto": true,
                        "forumName": "$forumName",
                        "description": "$description",
                        "logo": "$logo",
                        "headline": "$headline",
                        "callToAction": "$callToAction"
                    }
                }
            }
        }
    }
}

New API Call : https://api.linkedin.com/rest/creatives?ids=List(urn%3Ali%3AsponsoredCreative%3A{$creative_id})
New API Response :
{
    "results": {
        "urn:li:sponsoredCreative:$creative_id": {
            "servingHoldReasons": ["$servingHoldReasons"],
            "lastModifiedAt": 12345678000,
            "lastModifiedBy": "",
            "content": {
                "reference": "urn:li:ugcPost:$ugc_post"
            },
            "createdAt": 1234562340000,
            "isTest": false,
            "createdBy": "$createdBy",
            "review": {
                "status": "APPROVED"
            },
            "isServing": false,
            "campaign": "urn:li:sponsoredCampaign:$campaign_id",
            "id": "urn:li:sponsoredCreative:$creative_id",
            "intendedStatus": "ACTIVE",
            "account": "urn:li:sponsoredAccount:$account_id"
        }
    },
    "statuses": {
        "urn:li:sponsoredCreative:creative_id": 200
    },
    "errors": {}
}

Is there any way to get all those fields we used to get in old API call with new API as we need these fields for processing.
`


text:
Q: Crystal Reports ONLY print date code and serial numbers IF NOT blank Hello StackOverflow community and experts.
I am new with Crystal Reports and I am trying to figure out how to ONLY print date code and serial numbers IF NOT blank. I have searched online for code examples and see what others have asked and what answers were returned.
Although, I have not found what I am looking for, I have found many suggestions for using the surpress in the solution.
Also, I have noticed a lot of online code examples that begin with a question mark. What does the question mark indicate?

A: As per my understanding below is the code:
Serial Number:
if(ISNULL(rmadtl.ShortChar01))
then
//your code
else
rmadtl.ShortChar01

Date:
if(ISNULL(rmadtl.ShortChar03))
then
//your code
else
rmadtl.ShortChar03

In both the cases checking the null condition and if it is write required code you need else pring the serial number and date
Let me know if this not your requirement.

A: The syntax that Crystal Reports needed to work properly was:
IF ({rmadtl.ShortChar01}) = ""
OR
(ISNULL ({rmadtl.Shortchar01}))
THEN
TRUE


text:
Q: show message on console on selecting check box menu item When the user ticks the check box menu item, I want to show some message to the user on console. How can I do that? For now when the user checks the checkbox message is displayed only on the frame. How can I display some message on the console too?
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
import javax.swing.BorderFactory;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;

public class CheckBoxMenu extends JFrame {

    private JLabel statusbar;

    public CheckBoxMenu() {

        initUI();
    }

    private void initUI() {

        createMenuBar();

        statusbar = new JLabel("On Progress...");
        statusbar.setBorder(BorderFactory.createEtchedBorder());
        add(statusbar, BorderLayout.SOUTH);

        setTitle("JCheckBoxMenuItem");
        setSize(360, 250);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    private void createMenuBar() {

        JMenuBar menubar = new JMenuBar();
        JMenu fileMenu = new JMenu("File");

        JMenu viewMenu = new JMenu("View");
        JCheckBoxMenuItem sbarMi = new JCheckBoxMenuItem("Show Statusbar");

        sbarMi.setSelected(true);

        sbarMi.addItemListener((ItemEvent e) -> {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                statusbar.setVisible(true);
            } else {
                statusbar.setVisible(false);
            }
        });

        viewMenu.add(sbarMi);

        menubar.add(fileMenu);
        menubar.add(viewMenu);

        setJMenuBar(menubar);
    }

    public static void main(String[] args) {

        EventQueue.invokeLater(() -> {
            CheckBoxMenu ex = new CheckBoxMenu();
            ex.setVisible(true);
        });
    }
}

A: You could just use a System.out.println call in your listener, or use a logger.
sbarMi.addItemListener((ItemEvent e) -> {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        statusbar.setVisible(true);
        // Using System.out
        System.out.println("On Progress...");
        // Or using a logger (defined somewhere else, using Logger.getLogger or a logging framework.)
        logger.info("On Progress.");
    } else {
        statusbar.setVisible(false);
    }
});


text:
Q: how can i get multiple values to display from a mapped api which has multiple images within the already looped array? im trying to loop through an API with images, which I will change to fruits to make it easier to read
let arr = [
  {src: "mango, banana"},
  {src: "melon"},
  {src: "apple"},
  {src: "pear"},
]

notice how "apple, banana" are together
if I map them arr.map(e => e.src) it comes out like
[ 'mango, banana', 'melon', 'apple', 'pear' ]

when I try to do a arr.map(e => e.src.split(',')) then it gets separated but I cant still use it like this
[ [ 'mango', ' banana' ], [ 'melon' ], [ 'apple' ], [ 'pear' ] ]

how can I access or separate the first array to be single, I need it to render images for a react app, but some fields have multiple images like that which breaks the code.
the outcome that I want is to have them all separated into single string
[ 'mango', 'banana', 'melon', 'apple', 'pear']

i tried something like this
let pushed = arr.map(e => e.src)
console.log(pushed[0]);
// output: mango, banana

and I get to select those and I could split them and work with those, but that's too hard coded, I need it to be dynamic as I am getting over 4000 pictures and I cant be checking every single field to see which one I have to change

A: You can use .reduce function to have result you would like to have.
arr.reduce((prev, current)=> [...prev, ...current.src.split(',')], []);

A: You're close to a right solution. If you pass a .flat after the .map function, it'll flatten your array to one level like such
arr.map(val=> val.src.split(",")).flat()


text:
Q: How to solve error with syncing PostgreSQL with Vercel I have a database using PostgreSQL but the published site is Vercel and when deploying for production is gives the error below. The error doesn't happen for Heroku
django.db.utils.OperationalError: FATAL:  no pg_hba.conf entry for host "123.456.789.102", user "example_user", database "example_db", SSL off
How do I solve this error, thank you. I have checked Google results aren't really helpful

A: I found the answer out. It was just not to use Heroku but instead I used a service called ElephantSQL and used the details and it worked perfectly well

A: You can't not authenticate as HBA stands for host-based authentication.
That's because your host is "123.456.789.102"..
Seems like you need to fix .env
DATABASE_NAME=db_name
DATABASE_HOST=DATABASE_URL obtained from heroku
DATABASE_USER=db_user that usually default to postgres
DATABASE_PASSWORD=your_password
DATABASE_PORT=5432

And when locally you are fine, change Vercel Environment variables according to them as well as 'vercelignoring' your .env file.
Vercel is serverless, it is immutable (nothing meant to change after deployment), so it has limited support for databases. The solution is, as in case of OP, using external database hosting. ElephantSQL is fine, but somewhat expensive after some time, while AWS RDS free tier offers 20GB of storage.
I've personally deployed Laravel app to Vercel using vercel-php & linked to AWS RDS PostgreSQL. Officially it seems like neither Laravel nor AWS RDS are supported.


text:
Q: Fax barcode recognition software to integrate in a c# application My application is preparing a cover-sheet for submitting documents by fax. I identify the batch by printing a Code39 on it.
The incoming faxes are received as tif files and my small c# service is polling for new faxes and calling a decoding function.
Currently I use a Win32 dll to recognize the barcode (QSbar39) and I am facing some problems with it - timeouts, hangs, errors etc. which are painful to handle.
I'd prefer the have some free .Net component or an open source class to integrate.
Whould you take a different approach? What tool do you use?
Many thanks for your answers!

A: BarBara is an open source barcode recognition library.  It certainly isn't perfect, but I have gotten it to work (if I remember it needed some twiddling to get it to compile in VS2008) pretty well.

A: I've used this java libarary with good results, and have gotten it to compile in .Net with minimal effort.  It's been around for a while and works pretty well.  It had some minor issues with EAN codes, but that has probably been resolved now.
http://barbecue.sourceforge.net/

A: I'm not sure there is anything available free or open source, but VintaSoftBarcode.NET Library is pretty cheap and did the job for me on a recent project.


text:
Q: Chatter feed says Chatter isn't enabled or the user doesn't have Chatter access Hi I have to enable chatter to post comments for knowledge articles. So I enabled chatter, enable feed tracking for knowledge object. We have two record types so for both respective page layouts I added "Post" action. I need to enable this to support users - i.e. for Support Analyst, Support Manager and VP of Support profiles. In lightning record page, I have added the chatter component. for published and archived articles its working. Only for draft articles, post action is visible not the feed and it below it says "Chatter isn't enabled or the user doesn't have Chatter access.". For one draft article I can see both and for one I can see feed but no post. I am totally confused here. please help me out. Any help would be appreciated. Thanks

added chatter feed and post separately to test where it has issue


text:
Q: How to save Date and Time to Firebase using datepicker in android Im having trouble passing the date and time to my firebase, can anyone please help me.
This is the code that i have made
 final Calendar calendar = Calendar.getInstance();
            int day = calendar.get(Calendar.DAY_OF_MONTH);
            int month = calendar.get(Calendar.MONTH);
            int year = calendar.get(Calendar.YEAR);

            // Date picker Dialog
            picker = new DatePickerDialog(Reservation.this, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                    dateTime.setText(dayOfMonth+"/"+(month + 1)+"/"+ year);
                }
            }, year, month, day);
            picker.show();

This is the other one
Map<String, Object> reservation = new HashMap<>();
            reservation.put("Car Number", resVehicleNumber.getText().toString().trim());
            reservation.put("Full Name", resFullName.getText().toString().trim());
            reservation.put("Date and Time",dateTime.getText().toString());

            db.collection("Reservation").add(reservation).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
                @Override
                public void onSuccess(DocumentReference documentReference) {
                    resFullName.setText("");
                    resVehicleNumber.setText("");
                    dateTime.setText("");
                    Toast.makeText(Reservation.this, "Reservation Successful", Toast.LENGTH_SHORT).show();
                    startActivity(new Intent(Reservation.this, HomePageActivity.class));
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Toast.makeText(Reservation.this, "Failed to Reserve!", Toast.LENGTH_SHORT).show();


text:
Q: Which is best coding technique to count record in php and mysql first method
$sql_m = mysql_query("select count(t_id) as ad from t_master where product_id='$pro_id' AND order_id='$or_id'");
$st_id_m = mysql_fetch_assoc($sql_m);
$st_id_m = $st_id_m['ad'];

second method
$sql_m = mysql_query("select * from t_master where product_id='$pro_id' AND order_id='$or_id'");
$st_id_m = mysql_num_rows($sql_m);

which is the best method for given better performance in large database and get number of record.


text:
Q: Never reach smooth, constant 60 fps in 3D applications regardless of graphics settings I have a Radeon R9 290 (though this also happened on my previous card, a 6850) and it seems that only a select few games run at a constant, smooth 60fps. This has no relation to graphics settings as it still does this on minimum settings. I can watch a 60fps YouTube video of the same game and notice the smoothness, in comparison to a lot of small stutters on my computer.
Specs:

*

*AMD Phenom II X4 955 (3.2GHz quadcore)

*8GB DDR3 1333MHz RAM

*Radeon R9 290

*Windows 10 Pro x64 (this also happened on windows 7.)

It's not that the game completely stutters and pauses, more like it fluctuates around 55-60, thus removing the sense of smoothness you would see from a constant framerate. This happens with vsync on and off.
I have two monitors, which I suspect might be the culprit.
Any ideas for how to fix this? I know I can run these games just fine, especially considering most of what I'm trying to play is 4+ years old.


text:
Q: Atom simple console.log? I tried everything and amazingly I couldn't find a way to do such a simple thing- show inside Atom the logs of my program.
console.log(" just a simple log")

*

*if you go to view->developer->toggle developer tools a Chrome like console will be open, but log will not be displayed, and its not a good UI.

*Tried to install any kind of package output-panel, console, console-log none of them will show my logs.
If I open the index.html in Chrome I see all my logs as expected.
Why I can't see a simple log ?

A: The console you see is atom's console. Atom is written in JavaScript itself, with the console you can debug the editor, plugins etc. You won't see the log you've written, because no one executes your code. If you open the script as part of a webpage in Chrome, Chrome executes the script.
You could use the script plugin to run the file directly from within atom.

A: I had the same problem and I figured it out myself.
You really don't need an Atom JS console to see the results of your console.log commands as long as your program runs in a browser's window. You only need the console window that is already embeded in your browser. Here is how to do it:

*

*Open the web server page (fake or real) in your browser that shows the results of your program.

*In the web server page press Ctrl + Shift + J to toggle the developer tools (DevTools) window.

*Press the "Console" tab.

*Press the three vertical dots to the right of the DevTools window and then press the 3rd button with the caption "Dock to bottom", or leave it as it is if you prefer.

Now each time your javascript code executes a console.log command the result will be displayed in the console window.

A: I know i'm late, but Install "Script" by atom in the package installer and it supports almost all languages so just press cmd+I for Mac and ctrl+I for Windows.
Edit: This is only for running script inside of the Atom-editor, if you have linked it to a web then this is unnecessary.


text:
Q: How to automatically translate between traditional and simplified Chinese characters with Unicode? Is there a way to translate programmatically from traditional to simplified Chinese characters? If so, how do you do it, does unicode offer a way? If not, why doesn't there exist a database with the mapping, is it not one-to-one? I know you can find a mirror image glyph from another glyph in Unicode, but can you find the simplified glyph from a traditional one?

A: It is indeed not one to one. My favorite example to explain this quickly is this:
Take the character for face, 面. So far so good, it's the same in Traditional and Simplified Chinese. However, 面 is also the simplified version of 麵, noodle (where the 面 part on the right is the phonetic part). So if you have 面, you have no way of knowing which is which.


text:
Q: MySQL: Get a return result from an INSERT SELECT I have query that INSERTS both explicit values and SELECTd content. I'm also doing basic incrementing.
INSERT INTO `table` (`myID`, `myVal1`, `myVal2`) SELECT `myID` + 1, 'explValHere', 'otherValThere')
FROM `table` ORDER BY `myID` DESC LIMIT 0,1

I am doing this as the table has multiple id's and incrementing within a specific column. So I can't, as you would first say, use auto incrementing and insert_id.
The problem of course is the insert doesn't return the select, but can it? Is there a way of running this insert query and returning any of the result?

A: Since your query has a LIMIT 1 you could store the "result" in a session/user-defined variable. Still two queries but reentrant; each connection is its own session.
<?php
$pdo = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'localonly', 'localonly');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
setup($pdo);

$query = "
    INSERT INTO tbl1 (myID, myVal1, myVal2)
    SELECT @foo:=myID+1, 'val1', 'val2' FROM tbl2 WHERE x=0 LIMIT 1
";
$pdo->exec($query);
foreach( $pdo->query('SELECT @foo as foo') as $row ) {
    echo $row['foo'];
}

function setup($pdo) {
    $pdo->exec('CREATE TEMPORARY TABLE tbl1 (myID int, myVal1 varchar(16), myVal2 varchar(16))');
    $pdo->exec('CREATE TEMPORARY TABLE tbl2 (myID int, x int)');
    $pdo->exec('INSERT INTO tbl2 (myID, x) VALUES (1,1),(2,1),(3,0),(4,0),(5,1)');
}

the "first" record in tbl2 having x=0 is (myID=3,x=0) and the script prints 4.
Other than that and stored procedures et al there's (to my knowledge) nothing like SQLServer's OUTPUT or postgresql's RETURNING clause for MySQL.

A: You can (in a transaction) first read the values and afterwards do your insert statement.

A: try like this after your normal insert
INSERT INTO `table` (`myID`, `myVal1`, `myVal2`) values ('xxx','xxxx','xxxx');

then execute the queryget last inser id using
$id=mysql_insert_id();

then update the inserted row as below
mysql_query("update table set myid=$id where id=$id");


text:
Q: How to convert \x1 \x2 \x3 ... characters to normal characters without erasing? What are those \x1 ..\x2 ..\x3 characters and how to convert these to normal characters?

A: They are characters with the ordinal values 1, 2, and 3. They are called control characters and are not printable, which is why the debugger is showing you their escaped representation.
You can look the control characters up in an ASCII table.


text:
Q: How to set secured URL patterns for different file extensions e.g., .xhtml, .jpg, .docx How can I set secured URL patterns in AuthorizeExchangeSpec.pathMatchers(String[])?
I tried setting the pattern but this didn't work.
AuthorizeExchangeSpec.pathMatchers(["/cfs/**/*.xhtml", "/cfs/**/*.docx"]).authenticated()

The pattern should intercept these URLs:

*

*http://www.somedomain.com/cfs/1231asdasd/stage/abc.xhtml

*http://www.somedomain.com/cfs/1231asdasd/stage/basket/abc.docx

A: Finally, I was able to solve this issue by writing a custom matcher with AntPathMatcher.
AuthorizeExchangeSpec has a matchers method in which we can provide our own matcher which extends ServerWebExchangeMatcher
AuthorizeExchangeSpec.matchers(ServerWebExchangeMatcher... matchers)

And my matcher class is written as below
public class CustomMatcherServerWebExchangeMatcher implements ServerWebExchangeMatcher {

private PathMatcher matcher = new AntPathMatcher();

@Override
public Mono<MatchResult> matches(ServerWebExchange exchange) {
    ServerHttpRequest request = exchange.getRequest();
    if (this.method != null && !this.method.equals(request.getMethod())) {
        return MatchResult.notMatch();
    }
    String path = request.getPath().pathWithinApplication().value();
    boolean match = matcher.match(pattern, path);

    if (!match) {
        return MatchResult.notMatch();
    }

    Map<String, String> pathVariables = matcher.extractUriTemplateVariables(pattern, path);
    Map<String, Object> variables = new HashMap<>(pathVariables);
    return MatchResult.match(variables);
}}

And here org.springframework.util.AntPathMatcher is the class which does all the magic of matching for any file extensions as per this documentation
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/util/AntPathMatcher.html


text:
Q: Reflect User Preferences in Design Time When User changes form size and this is saved in Preferences, can the new size be applied in design time when the form is opened in Visual Studio?

A:
can the new size be applied in design time when the form is opened in Visual Studio?

No, not in any reasonable sort of way.
The Designer loads the design-time layout strictly from the *.Designer.cs or *.xaml file (for Winforms and WPF, respectively). While you can save and load the run-time size of the window (e.g. to the Settings object, the registry, a special file of your own construction, etc.), the initialization you put in the user code-behind (i.e. the regular *.cs file that goes with the form) will be ignored by the Designer.
You would have to modify the appropriate *.Designer.cs or *.xaml file itself. Not impossible, but IMHO impractical.
For what it's worth, I don't believe that it's a good idea to try to do this anyway. The window should be defined exclusively by changes made in the Designer itself. It's fine for the window's size to be retained from one instance of running the program itself to another, but for changes to the window's size in an instance of running the program to then be copied back to the design-time size of the window would mean that every time you tested the program, you ran the risk of deviating from the actual intended design of the window. Users resize windows for all sorts of reasons, and often these reasons don't apply at design time nor should be captured at design time to be reused the next time the program is run.


text:
Q: Restore deleted Mac App Store on 10.8.2 I accidentally deleted system apps like the App Store.app and the Calendar.app.
How can I restore these? I've tried the combo update like suggested for 10.6.6 systems, but that unfortunately doesn't seem to work on 10.8.

A: Boot to recovery HD and reinstall Mountain Lion if you don't have those backed up to your Time Machine (or equivalent) backup.


text:
Q: Find value of $x$ which satisfies the equation $\log_9 x=(\log_3 x)^2 ,x>1$ So far I got this $(\log_3 x)/2=(\log_3 x)(\log_3 x)$. Then I am stuck. Any idea or nice elaboration on this problem will be kindly appreciated.

A: Well $$\log_ax=\frac{\log_b x}{\log_b a}.$$
Then $$\log_9x=\frac{\log_3 x}{\log_3 9}=\frac{\log_3 x}{2}.$$
Then by placing ${\log_3 x}=t$ you get the equation
$$\frac{t}{2}=t^2.$$
From here either $t=0$ and $x=1$ or $t=\frac{1}{2}$ and then $x=\sqrt{3}$.

A: Note that:
$$0=\log_9(x)-\left(\log_3(x)\right)^2 = \frac{\log(x)}{\log(9)}-\left(\frac{\log(x)}{\log(3)}\right)^2 = \log(x)\left(\frac{1}{\log(9)}-\frac{\log(x)}{\log(3)^2}\right). $$
Since $x>1$, $\log(x)>0$ and, hence, the second term needs to be 0:
$$\frac{1}{\log(9)}-\frac{\log(x)}{\log(3)^2} =0. $$
Try to follow from there.

A: Well I would like to show one more way to do this :
We know that,
$$\log_{a^b}c^d=\frac{d}{b}\log_{a}c$$ Using that here $\frac{1}{2}\log_3{x}=(\log_3{x})^2$. Then it is just a quadratic equation with $\log_3{x}=t$


text:
Q: css grids change layout depending on page so i have my main page that have a menu , sidebar and main window. I have a redirect to another page. On this page i would like the sidebar to go away.
Is this possible using CSS grids without having 2 CSS files?
so for example this would be the grids for index.html
grid-container {
  display: grid;
  grid-template-areas:
  'menu menu menu menu'
  'mainWindow mainWindow mainWindow chat'
  'footer footer footer footer';
  grid-gap: 0.6em;
  column-gap: 1.2em;
}

on redirect to myOtherPage.html
.grid-container {
  display: grid;
  grid-template-areas:
  'menu menu menu menu '
  'mainWindow mainWindow mainWindow mainWindow '
  'footer footer footer footer';
   grid-gap: 0.6em;
   column-gap: 1.2em;
}

A: You could structure your CSS as such. The first block has the styles all .grid-containers share. The next is unique to whatever other-page should be.
.grid-container {
  display: grid;
  grid-template-areas:
  'menu menu menu menu'
  'mainWindow mainWindow mainWindow chat'
  'footer footer footer footer';
  grid-gap: 0.6em;
  column-gap: 1.2em;
}

.grid-container.other-page {
  grid-template-areas:
  'menu menu menu menu '
  'mainWindow mainWindow mainWindow mainWindow '
  'footer footer footer footer';
}

index

...

other page

...


text:
Q: sql query/entity framework query not returning distinct values on two tables I have a query I am running on two Tables (Table Customer and Table Vendor). On Table Customer I may have multiple rows of similar records. I am joining the two tables using the parameters below, however I noticed instances of Table Vendor Id duplicates in the query result. I am guessing this is because I have multiple similar records on Table Customer. Please can someone assist me with the right query to use to get distinct ID values on the join? Note that I am using this on entity framework core for a project. See query used on entity framework converted to sql below
SQL

select distinct * from Vendor e inner join Customer d on e.account = d.Cod_account
where (e.ActionStatus = 'Pending' and d.ActionStatus = 'Pending') and (d.Amt = e.Amount)
and (e.UploadTime = '05:00pm') and (e.Uploaddate = d.Calldate) order by d.Amt desc

ENTITY FRAMEWORK

await (from  e in _dbc.Vendor join d in _dbc.Customer on e.account equals d.Cod_account
where (e.ActionStatus == "Pending" && d.ActionStatus == "Pending") && (d.Amt == e.Amount)
&& (e.UploadTime == uploadtime) && (e.Uploaddate == d.Calldate)
orderby d.Amt descending
      select new CustomerVend
       {
          Customer = d,
          Vendor = e
       }).Take(2000).Distinct().ToListAsync();

A: I've corrected your LINQ query. Distinct should be placed before Take.
var query =
   from e in _dbc.Vendor
   join d in _dbc.Customer on e.account equals d.Cod_account
   where e.ActionStatus == "Pending"
      && d.ActionStatus == "Pending"
      && d.Amt == e.Amount
      && e.UploadTime == uploadtime
      && e.Uploaddate == d.Calldate
   orderby d.Amt descending
   select new CustomerVend
   {
      Customer = d,
      Vendor = e
   }

var result = await query.Distinct().Take(2000).ToListAsync();


text:
Q: Write the content of a text file line by line with Svelte i wrote this code in svelte that open a txt file, and write it in a html paragraph. This is the code:
<input type='file' multiple bind:files'>

{#if files}

Files selected:

{#each Array.from(files) as file}

 IThe imported file is: {file.name}

{#await file.text() then text}

{text}

{/await}
{/each}
{/if}

and the example file is like this:
beans
spam
donut

but it gives me this:
beans spam donut

how can I create a new line (paragraph or
) for each line in the text?

A: How about this? Simply split on the newline and create a new p tag.

<input type='file' multiple bind:files />

{#if files}

Files selected:

{#each Array.from(files) as file}

 IThe imported file is: {file.name}

{#await file.text() then text}
{#each text.split('\n') as line }

{line}

{/each}
{/await}
{/each}
{/if}


text:
Q: Is It Important To Specify Data Types For Speedy NumPy computations? I have a python script that I have coded almost entirely in NumPy for a numerical simulation and prior to running my script I have not specified the datatype for any of the variables. I tried to figure out a way to speed up my code and eventually stumbled upon Numba where the importance of datatypes becomes a lot more transparent. As someone new to programming and scientific computing, the idea of specifying datatypes prior to the computation was not something I really thought much about because even when I don't specify the types, NumPy is able to execute just fine.
So what I am wondering is if it's actually more efficient to be specifying datatypes explicitly in the initial construction of my NumPy arrays, and if so, why is that the case? If not, why? If possible, it would be nice for the answer to generalize outside of the specific case of NumPy if at all possible.

A: By default, NumPy selects the appropriate data type according to the function used. For example, if you call numpy.array((1, 2, 3)) the resulting array will have integer type, but if you call numpy.array((1.0, 2.0, 3.0)) the resulting array will have float type. Therefore, most of the time it doesn't matter whether you specify explicitly the dtype of the array. In some very specific cases, you might be able to use a data type with less bytes to speed up computations a bit, but in my experience the speedup is negligible and the resolution loss is not:
arr = numpy.array((1.0, 2.0, 3.0), numpy.float32)

Calculations on this array (as opposed to the default numpy.float64) will be a bit faster, assuming no type casting will be necessary.


text:
Q: Java 8 ifPresent vs ternary operator What do you think is better (with arguments, of course):
Optional.ofNullable( userName )
      .ifPresent( nonNullUserName  -> header.setUser( createUser( nonNullUserName ) ) );

or
header.setUser( userName == null ? createUser( userName ) : null );

The method createUser creates xml element and the intent of the whole peace of code is to set it in a SOAP request depending on presence of userName.
The benefits of the first approach I see is the absence of useless operations, the code does one thing and no more. But the second approach lets you save one more line of code thus appearing to be more laconic.
UPDATE: I guess I missed a thing I actually implied and it caused certain misunderstanding. It would be better to provide cleaner examples with explanations if you have some.

A: They are different things, one is an Object, another is an operator. you shouldn't comparing between them. the first approach can be simplified to this, which will be more readable & descriablable:
Optional.ofNullable(userName).map(this::createUser).ifPresent(header::setUser);

IF you really want to comparing between them, the only one different is you have been mentioned above. and if you process condition or result more complex in an operator that will result to the expression is too complex to read.

A: Optional was designed to be used as a return type for methods that can't always return a value, like for example getFirstElementOfAList(), which can't return anything else if the list is empty: returning null would be less clear than returning an empty Optional, and could mean that the first element is null, and not that there is no first element.
The designers don't intend Optional to be used as a convenience construct to chain methods. See the presentation by Stuart Marks (who works on the JDK), and especially what he says at the 28th minute:

It's generally a bad idea to create an Optional for the specific purpose of chaining methods [...]

You're of course free to disrespect the intended design and the best practices, but your colleagues might also be free to hate you for that :-)
Note that the two snippets you posted don't do the same thing. The first one does nothing if the user name is null, whereas the second one sets the user to null (which might in turn throw an exception or overwrite the previous value)
I would just use (assuming what you want is the first version):
if (userName != null) {
    header.setUser(createUser(userName));
}

which is extremely clear, doesn't abuse Optional, and doesn't create an Optional instance just to chain methods.


text:
Q: Update existing records by data in different table I have the following schema in my database:
CREATE TABLE survey_results (
    id integer NOT NULL,
    raw jsonb DEFAULT '{}'::jsonb,
    created_at timestamp without time zone,
    updated_at timestamp without time zone
);

CREATE TABLE slide_results (
    id integer NOT NULL,
    survey_result_id integer NOT NULL,
    slide_id integer NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone
);

INSERT INTO survey_results (id, raw, created_at, updated_at)
    VALUES (1, '[{"id": "1", "finished_at": 1517421628092}, {"id": "2", "finished_at": 1517421894736}]', now(), now());

INSERT INTO slide_results (id, survey_result_id, slide_id, created_at, updated_at)
    VALUES (1, 1, 1, now(), now());

INSERT INTO slide_results (id, survey_result_id, slide_id, created_at, updated_at)
    VALUES (2, 1, 2, now(), now());

The problem is inside slide_results table. created_at column in this table contains invalid data. I want to update all slide_results created_at to be the same as the value of raw->finished_at.
Any idea of doing that operation like this in PostgreSQL?
Here is link to sqlfiddle:
http://sqlfiddle.com/#!17/c47fc

A: I believe this does what you want:
update slide_results
    set created_at = timestamp 'epoch' + (raw#>>'{1,"finished_at"}')::bigint * interval '1 millisecond'
    from survey_results sr
    where slide_results.survey_result_id = sr.id;


text:
Q: how to setactive/Destroy video background and video source artoolkit in unity When i'm want destroy or setactive gameobject video background and video source from code Artoolkit Controll didn't Destroy or dispose;
public GameObject Artoolkit;
Void Update()
{
if(GetKeyDown(Key.A))
{
Destroy(Artoolkit);
//or Artoolkit.SetActive(false);
}
}

This My Image, can't destroy video background and video source artoolkit in unity

A: The video source and video background GameObjects are created by ARToolKit for Unity on start, and are destroyed when it stops. The correct way to remove them from the scene is to call ARController.StopAR().
If you make the ARController inactive and then destroy the objects yourself, you will likely receive invalid object reference errors when you make the ARController active again, since it holds references to these objects which it expects to be valid.


text:
Q: Better Templating for Grails For all the things I love about Grails I do have one small issue and this isn't really even a Grails specific problem.  GSP changes require redeployments of the entire web application.  I'm not talking about adding new dynamic data or major changes.  These generally requires server side changes as well anyway.
But I'm talking about smaller changes like flipping the position of a couple of elements or modifying some simple static text on the page.  So my question is, what are some patterns used or plugins, etc that allow minor changes to GSP's without redeploying the entire application?  How can I make Grails template/GSP's more like templates and less requiring compiling?
I'm also possibly looking for something more designer friendly.

A: grails.gsp.view.dir, I think.
A trick to remember: add trailing slash and remember that grails-app/views will be added to it.

A: There is a Grails Plugin for using FreeMarker templates as views (I have not used this plugin myself).  It is not listed as SpringSource supported, but I think the author is one the core grails devs and the plugin is based on a relatively new version of FreeMarker.


text:
Q: SUGRA & consistent field theories Why must a consistent theory with a rarita schwinger field (i.e. massless gravitino in the spectrum) be supersymmetric? I was reviewing the GSO projection, Spin Structure, etc. & wasn't able to make out the argument. Is this an actual theorem (like Weinberg-Witten for composite gravitons for instance) or is it just a belief?

A: Not sure what you mean by "belief". Composite spin 3/2 fields are permeating our world, viz the Δ(1232) baryon.
Fundamental  Rarita-Schwinger (R-S) fields propagate acausally, as proven in a historic paper by
Velo  & Zwanzinger, Phys Rev 188 2218  (1969) available online.
One of the earliest triumphs of supergravity was Das & Freedman,  Nucl Phys B114 (1976) 271-296 demonstrating that local supersymmetry invariance saves the day by ensuring causality.
The propagator grows like $s\sqrt s$ at high energies,  by Mandelstam,
but unphysical scattering exchanges thereof are prevented by its coupling to the conserved supercurrent, of which it is the gauge field. The same supercurrent is not simultaneously Poincare & local susy invariant, evading the W-W theorem analogously to vector gauge fields. But I assume you are not focussed on loopholes to the exclusions of the W-W theorem; physics theorems normally rely on facts on the ground to ensure they are carefully conditioned to prevent deductions of the nonexistence of fish.


text:
Q: Asp.net linkbuttons not firing their click events on disabling javascript? I am facing a peculiar problem in asp.net. I have a link button with following specifications.
Linkbutton-
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" OnClientClick="control_visible('Calendar1', 'Calendar2', 'visible')" ClientIDMode="Static">

OnClientClick() js function-
function control_visible(control1id,control2id, control1visibility)     //toggles visibility b/w two controls with opp visibility
{
    document.getElementById(control1id).style.visibility = control1visibility;

    if (control1visibility == "visible")
    {
        document.getElementById(control2id).style.visibility = "collapse";
    }
    else
    {
        document.getElementById(control2id).style.visibility = "visible";
    }

    return false;
}

The code inside linkbutton is irrevelant in regard of the problem i am facing.
What seems logical is when you disable the js on your browser, then your code behind should execute normally.But in above case as i disable the js, my linkbutton stops interacting with the server & don't execute its code & i am not even using "return" keyword in OnClientClick function call of linkbutton, which could possibly prevent the code from running, if it provides a "false" in the onclientclick function call when the js is disabled.
I don't understand...is this for a fact that upon calling a js function with js disabled, even the code-behind fails to execute or i am possibly missing something??
Thanks, i hope i made it clear

A: Use button if you want to execute events with js disabled
<asp:Button runat="server" />

LinkButton(s) got translated into something like
<a href="javascript:something_like_invoke_postback()" onclick="your_on_client_click" />

so once you disable javascript, they're dead. OnClientClick handler is irelevant for this problem (it won't fire event if it is empty with js disabled).


text:
Q: Runaway argument? with \newcommand[2] I have a date (in the format YYYY.MM.DD) and a time (format HH:MM).
From these, I want to compute a kind of  TimeStamp/Total of minutes.
\documentclass{article}

\makeatletter

% Timestamp
\newcommand{\timeStamp}[2]{%{#1-Date (YYYY.MM.DD)}{#2-Time (HH:MM)}
    \expandafter\timeStamp@t#1 #2\@nil%
}%
\def\timeStamp@t#1.#2.#3 #4:#5\@nil{%
    \the\numexpr#5+#4*60+(#3-1)*60*24+(#2-1)*60*24*31+(#1-2017)*60*24*31*365\relax%
}%

\makeatother

\begin{document}
\def\tOne{03:00}%
\def\dOne{2017.08.01}%
\timeStamp{\dOne}{\tOne}\\%
\end{document}

The compiler says: "Runaway argument?"

This is probably due to a problem with the extension of the second argument, because this call (\timeStamp{\dOne}{03:00}) is Ok.
What am I doing wrong?

A: \expandafter only expands one token after the token that follows (unless there are arguments).  In your case this is just #1.  One way to get your result, is to collect #1 #2 expanded in a macro before insertion:

\documentclass{article}

\makeatletter

% Timestamp
\newcommand{\timeStamp}[2]{%{#1-Date (YYYY.MM.DD)}{#2-Time (HH:MM)}
  \edef\mytmp{#1 #2}\expandafter\timeStamp@t\mytmp\@nil%
}%
\def\timeStamp@t#1.#2.#3 #4:#5\@nil{%
    \the\numexpr#5+#4*60+(#3-1)*60*24+(#2-1)*60*24*31+(#1-2017)*60*24*31*365\relax%
}%

\makeatother

\begin{document}
\tracingmacros=2\tracingcommands=2
\def\tOne{03:00}%
\def\dOne{2017.08.01}%
\timeStamp{\dOne}{\tOne}
\end{document}

This approach should generalise well to more than two arguments.

A: One can do some juggling with \expandafter, but a direct approach may be better:
\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\cs_new:Nn \joseph_time_stamp:nn
 {
  \__joseph_time_stamp:w #1.#2\q_stop
 }
\cs_generate_variant:Nn \joseph_time_stamp:nn { ff }
% a devious trick for the colon
\use:x
 {
  \cs_new:Npn
   \exp_not:N \__joseph_time_stamp:w
   ##1.##2.##3.##4\token_to_str:N :##5
   \exp_not:N \q_stop
 }
 {
  \int_eval:n
   {
    #5+#4*60+(#3-1)*60*24+(#2-1)*60*24*31+(#1-2017)*60*24*31*365
   }
 }
\NewExpandableDocumentCommand{\timeStamp}{mm}
 {
  \joseph_time_stamp:ff { #1 } { #2 }
 }
\ExplSyntaxOff

\begin{document}

\def\tOne{03:00}
\def\dOne{2017.08.01}

\timeStamp{\dOne}{\tOne}

\timeStamp{2017.1.1}{0:0} % should print 0

\end{document}

If the time specification didn't include the colon, it would be easier; the problem is that : is special in the scope of \ExplSyntaxOn, so the direct
\cs_new:Npn \__joseph_time_stamp:w #1.#2.#3.#4:#5\q_stop
 {
  \int_eval:n
   {
    #5+#4*60+(#3-1)*60*24+(#2-1)*60*24*31+(#1-2017)*60*24*31*365
   }
 }

would not work and an indirect method is needed in order to "stringify" the colon.

An expandable solution with \expandafter and argument juggling (OS for "old style"):
\makeatletter
\newcommand{\timeStampOS}[2]{%
  \expandafter\timeStampOS@a\expandafter{#2}{#1}%
}
\newcommand{\timeStampOS@a}[2]{%
  \expandafter\timeStampOS@b\expandafter{#2}{#1}%
}
\newcommand{\timeStampOS@b}[2]{\timeStampOS@c #1 #2\@nil}
\def\timeStampOS@c #1.#2.#3 #4:#5\@nil{%
  \the\numexpr
    #5+#4*60+(#3-1)*60*24+(#2-1)*60*24*31+(#1-2017)*60*24*31*365
  \relax
}
\makeatother

A: expand #1 and #2
% Timestamp
\newcommand\timeStamp[2]{%
    \expandafter\timeStamp@t#2 #1\@nil}%
\def\timeStamp@t#1:#2 #3\@nil{\expandafter\timeStamp@@t#3 #1:#2\@nil}%
\def\timeStamp@@t#1.#2.#3 #4:#5\@nil{%
  \the\numexpr#5+#4*60+(#3-1)*60*24+(#2-1)*60*24*31+(#1-2017)*60*24*31*365\relax%
}%

A: It is clearer to:

*

*devote macros to sub-computations, possibly reusable elsewhere,

*indicate in the macro name the expansion type it does on its arguments.
Like this: (O meaning "expands once the argument"; often one would prefer "F" for f-type expansion which expands repeatedly the first token, as this allows nesting. Else one would need e.g. T for "expands twice the argument", because  with \def\foo{\the\numexpr...}, one needs two expansions for fully expanding).

\documentclass{article}

\newcommand{\TimeStampOO}[2]
   {\the\numexpr\expandafter\DateToMinutes\expandafter{#1}+
                \expandafter\TimeToMinutes\expandafter{#2}\relax}

\makeatletter
\newcommand{\DateToMinutes}[1]{\the\numexpr\Date@ToMinutes#1\relax}
\def\Date@ToMinutes#1.#2.#3\relax
   {(#3-1)*60*24+(#2-1)*60*24*31+(#1-2017)*60*24*31*365\relax}
\newcommand{\TimeToMinutes}[1]{\the\numexpr\Time@ToMinutes#1\relax}
\def\Time@ToMinutes#1:#2\relax
   {#2+#1*60\relax}
\makeatother

\begin{document}
\def\tOne{03:00}%
\def\dOne{2017.08.01}%
\TimeStampOO{\dOne}{\tOne}%
\end{document}

This is expandable.


text:
Q: react constants import using props drill vs context vs imports I have inherited some code that uses props drilling to pass down a large list of constants (translations) to various sub components. These translations map a symbol to a local language text and there is also a function to do the mapping called translate. ie {translate(SYM_NO)} would return "NON" if the local language was French.
I thought Props drilling was a bit messy and decided to use the new Context in React 16.3.1. This worked OK for JSX, but was a bit tricky when I needed to get translate into JS eg a MS Fabric UI DetailsList callback so that the callback could translate various column data (returned by an API call). Below is a technique for adding a parameter (from Context) to the callback which can then be used in the callback implementation:
onRenderItemColumn={(item, index, column) => this._renderItemColumn(item, index, column, translate)}

After getting this to work, I discovered that it was actually unececessary, as I could just import translation in any (most) of my components and easily use translate anywhere in my JSX or JS :-
import translate from "../../../config/translate";

So I am now wondering about the performance/memory implications of importing translate in nearly all of my components. Is there a penalty for every import or is it just the first import that counts and the rest have no impact?
Should I continue with many imports or revert to (trickier) Context or perhaps some other method. (Props drilling is not an option I think)
Peter (React newb)

A: Assuming your using a standard Webpack based React stack the overhead with regards to performance should be minimal since they all are references the same module which is only evaluated once. Maintenance wise, in my experience, it will soon become a burden. Especially when you take into account that imports are relative to the file you import in. "is this file four levels deep or six". Making moving files a pain. And adding aliases for some modules so you can import them with an absolute path increases the complexity for new developers.
Context would not be the best approach I think since you need to add consumers to all parts that need translations.
What I would advise you to look into is if higher order components click for you. That has the benefits of not cluttering your components render logic with consumers and can be added as extra functionality to all components who need translations in a pretty transparent way. In pseudo code: export default withTranslations(Component);
You would still need to import the withTranslation where you would import your config/translations module but implementation wise it would make more sense to me.
Also there are some NPM modules for i18n in React and all the ones I've used also use the higher order component approach, which makes me believe that it can also work for you.


text:
Q: Can we capture the web service call out request and web service call out response times? Can we capture the web service call out request and web service call out response times.I am able to see these times in debug logs.But i am unable to capture these time.Could you please help on this.
Please find below screen shot.
User-added image
Need to capture the call out request and call out response time in diffrent stings.
Could you please help on this.

A: You can put simple System.Now() before and after the call-out statement.
Example
    public sendSMS()
    {
        DateTime t = System.Now();
        // Do Webservice Callout
        // .... callout statement
        DateTime t2 = System.Now();
        // perform operation according to two datetime received.
    }


text:
Q: Writing regular expression to check mandatory as well as optional strings in a given input I have the following string pattern
aB_12345_topicName_A15.jpg

where topicName is mandatory part and it can be any string and remaining all optional.

Example valid inputs are:
aB_SportsTopic.png
12345_topicName.jpg
Environment.jpg
topicName_A15.jpg
topicName_2B5.jpg
aB_12345_topicName.jpg

How to write a regular expression in java to validate user input accordingly?
I have written like this so far
^[a-z A-Z]_?\_[a-z A-Z]*_\[[0-9]*\][a-z A-Z]*_[a-z A-Z 0-9]*_[a-z A-Z 0-9]{3}\.[a-z A-Z]*

How to write regular expression for it in java?
Thanks in advance.

A: Here is the regExp you search:
^[a-zA-Z0-9_]*topicName[a-zA-Z0-9_]*$

Edited. You can do it also if topicName is any String. Just concatenate the first part, the topicName and the last part of regExp.
public String myRegExp(String topicName) {
    return "^[a-zA-Z0-9_]*" + topicName + "[a-zA-Z0-9_]*$";
}

and call it as you like most, for example:
String regExp1 = myRegExp("pippo");
String regExp2 = myRegExp("topicName");
String regExp3 = myRegExp("otherTopic");

A: If you want topicName to be in place there is regular expression:
    ^[A-Za-z0-9_]*[A-Za-z0-9]+[A-Za-z0-9_]*(.[a-z]*)$

If you need something else check this link. You can write regExp and check it there.


text:
Q: File transfer over HTTP As far as I know it is possible to transfer binary files over HTTP protocol. But HTTP is a text-based protocol, the typical HTTP response frame looks as follows:
HTTP/1.1 200 OK
Date: Wed, 23 May 2012 22:38:34 GMT
Content-Length: 438
Content-Type: text/html; charset=UTF-8

Here goes content

If so, how should binary file be encoded in this frame? What is the Content-Type? Is the content encoded with base64 - same as attachments in POP3 protocol? Or it is raw data (is it possible not to cause problems if so?)

A: The header fields are text based, but the actual payload is binary. You can transfer whatever you want.
And no, it doesn't have anything to do with the Content-Type. That is just a label so that the recipient knows how to process the data; it does not affect the format in the protocol itself.

A: Binary files are usually transferred with the Application/octet-stream mimetype (unless they match another more specific mimetype of course). For transmission you use the raw data - no base64 needed.


text:
Q: VBA Word: remove editing restriction at opening and restrict again when closing Is it possible to set a macro that would trigger each time I open a word document and check if it has an editing restriction. If so, try password from a list of passwords (hardcoded). In case one password is successfull, keep it in memory, remove restriction, and re-apply the restriction when I close the document.
In this way, if I always use the same password for the documents I use and restrict, I could open them on my computer as if there was no restriction, but the restriction would still apply to other users.
Note: the macro in Private Sub Document_Open() would need to trigger on all documents I open from my computer only. Documents must be .docx and not .docm.
Thank you.

A: Note 1: You will need to put this into a .dotm file and ultimately save as a global template on your PC (google).
Note 2: This will fail if you open more than 1 doc because only 1 password is stored - you could write the password as a document property (which you would retrieve & delete before saving and relocking).
Depending on whether or not you are happy to add code to the Normal.dotm template (personally I'm not) will influence how you do this.
If NOT using Normal.dotm then you will need to setup a global template AND trigger the code by creating your own application events as described here: https://wordmvp.com/FAQs/MacrosVBA/PseudoAutoMacros.htm
If using Normal.dotm then in ThisDocument add:
Private Sub Document_Open()
    MsgBox ActiveDocument.Name
    Dim oDoc As Object
    Set oDoc = ActiveDocument
    unlocker oDoc
End Sub

And (for testing) in a regular module add the following (you'll likely want to split this into separate units of code later):
Sub unlocker(ByVal docToUnlock As Document)
    If Not docToUnlock.Type = wdTypeDocument Then
        ' this is a template, don't try anything
        MsgBox "Not a doc"
        GoTo endOfSub
        Else
        MsgBox "Is a doc"
    End If

    Dim passWords() As String
    passWords = Split("pw1,pw2,pw3", ",")

    Dim iLoop As Long
    iLoop = LBound(passWords)

    On Error GoTo err_Test:

    Do While Not ActiveDocument.ProtectionType = wdNoProtection
        If iLoop > UBound(passWords) Then Exit Do

        oldpassword = passWords(iLoop)

        ActiveDocument.Unprotect oldpassword
        iLoop = iLoop + 1
    Loop

    If Not ActiveDocument.ProtectionType = wdNoProtection Then
        ' unable to unlock document, quit
        oldpassword = vbNullString
        MsgBox "Failed to Unlock"
        GoTo endOfSub
    Else
        MsgBox "Unlocked"
    End If

    ' Do Stuff

    If Not oldpassword = vbNullString Then
        ActiveDocument.Protect wdAllowOnlyReading, Password:=oldpassword
    End If

endOfSub:
    Exit Sub

err_Test:
    If Err.Number = 5485 Then
        ' ignore error due to wrong password
        Err.Clear
        Resume Next
    Else
        ' handle unexpected error
    End If

End Sub