text:
Q: Remove Wubi boot menu entry I had a Windows laptop and I installed Ubuntu 17.10 with wubi. Soon after, I needed to clean up Windows and I restored it via its own restore function, which deletes all data and preferences and reverts Windows to factory version. I didn't uninstall Wubi before doing that.
When booting, my computer didn't show me the option to boot into Ubuntu unless I manually entered the boot menu. Now, if I enter the boot menu, I still see the Ubuntu option from before the restore, but if I choose it doesn't find Ubuntu.
I needed Ubuntu again so I reinstalled it again via Wubi, (Wubi didn't offer me an option to uninstall the previous version) and now in the boot menu I have two "Ubuntu" entries.
How do I remove the old one? The old install of wubi is not there any more so I suppose it's just a matter of editing the options of the boot menu.

A: I found a solution to the problem:
From this question on Super User, I used EasyUEFI to delete the menu entry that was not needed. This solved the issue.


text:
Q: 'Gen' as a synonym for Attorney? The Words With Friends dictionary tells me that 'Gen' means attorney,
Is this a general term for lawyers?
Does it have any special connotations?
Is it office slang?
How is it pronounced; like gin?

A: No, "Gen" meaning lawyer is unknown to most dictionaries.  (However they have other definitions for "gen" so it is allowed to be played.)
"gen" can mean "information".  The OED says it originated as R.A.F. slang.
Other dictionaries have also "gen" used as slang for "generation".

redpajama_set_name: RedPajamaStackExchange


text:
Q: Ayuda Base de Datos SQL de Hana Buen día,
Agradecería su ayuda si fuera posible, Tengo la siguiente consulta
SELECT T1."Segment_0"||'-'||T1."Segment_1"||'-'||T1."Segment_2" as "Cuenta",
T1."AcctName",
sum   (T0."Debit"-T0."Credit")as "Saldo_SOL",

(
SELECT  SUM(T0."VALOR") AS preSUPUESTO FROM (
SELECT "U_EXC_CTACONT", '1' AS "MES" ,"U_EXC_ENERO" AS "VALOR" , "U_EXC_CCOSTO" AS "COSTO"FROM "@EXC_PRESUPUESTO1"    WHERE  "Code"=  YEAR('2020')
UNION ALL
SELECT "U_EXC_CTACONT", '2' AS "MES" ,"U_EXC_FEBRERO" AS "VALOR" , "U_EXC_CCOSTO" AS "COSTO"FROM "@EXC_PRESUPUESTO1"   WHERE  "Code"=  YEAR('2020')
UNION ALL
SELECT "U_EXC_CTACONT", '3' AS "MES" ,"U_EXC_MARZO" AS "VALOR", "U_EXC_CCOSTO" AS "COSTO" FROM "@EXC_PRESUPUESTO1"  WHERE  "Code"=  YEAR('2020')
) AS T0

WHERE T0."MES" >= MONTH('20200101') AND T0."MES"<= MONTH('20200131')
AND  "U_EXC_CTACONT"= T1."Segment_0"||'-'||T1."Segment_1"||'-'||T1."Segment_2"
GROUP BY T0."U_EXC_CTACONT"
) AS PRESUPUESTO

FROM JDT1 T0
INNER JOIN OACT T1 ON T0."Account" = T1."AcctCode"

WHERE T0."RefDate" BETWEEN '20200101' AND '20200131'
AND T0."ProfitCode" = '10501'

AND SUBSTRING (T1."FormatCode",12,4)!='9410'
group by T1."Segment_0"||'-'||T1."Segment_1"||'-'||T1."Segment_2", T1."AcctName"
order by 1

Obtengo el siguiente resultado del mes de Enero

Estoy usando 3 tablas
OACT  -
JDT1 -
EXC_PRESUPUESTO1
Columna Saldo_SOL = Consulta Principal
Columna PRESUPUESTO= Subconsulta
El inconveniente que tengo es que en la Columna de la subconsulta  presupuesto no me aparecen todos los registros ya que la columna Saldo_Sol no tiene valores para el numero de cuenta que si tiene el presupuesto.
Solo me esta priorizando los valores del campo Saldo_SOL dejándome sin los valores que tiene la columna Presupuesto
ambas tablas están relacionadas con el código de la columna Cuenta
Como puedo hacer para que me muestre todos los registros de la subconsulta PRESUPUESTO que tienen datos y en la Columna Saldo_Sol me aparezca Cero
Ejemplo
Digamos que me faltan Estas cuentas pero no aparecen por que no tienen datos en Saldo_SOL y Si en Presupuesto.

Agradezco de antemano su ayuda.

A: Creo que deberías usar un LEFT JOIN.
Ejemplo:
LEFT JOIN OACT T1 ON T0."Account" = T1."AcctCode"


text:
Q: Add html tag and style on CKEditor Textarea I'm using django ckeditor, is it possible to add html and css on textarea? Something like this:

A: You could use a custom CKEDITOR.stylesSet in your project, defining tags and their attributes in a js file:
// file living, e.g in static/js/ckeditor-styles.js
CKEDITOR.stylesSet.add('mystyles', [

  { name: 'Párrafo sin margen', element: 'p', attributes: { 'class': 'p-nomargin' } },
  { name: 'Enlace opinión', element: 'p', attributes: {'class': 'opinion__link'}},
  { name: 'Enlace opinión2', element: 'p', attributes: {'class': 'opinion__link--linea'}},
])

Next, you need to add this file to the stylesSet section of the CKEDITOR_CONFIGS dictionary, in the settings.py file. Remember that you need a contentCss in order to properly preview the styles in the editor widget, and the 'Styles' widget in the toolbar. This is an example of my ckeditor configuration:

CKEDITOR_CONFIGS = {
    'default': {
        # 'toolbar': 'full',
        'toolbar': 'Custom',
        'toolbar_Custom': [
            ['Styles', 'Format', 'Bold', 'Italic', 'Underline', 'Strike'],
            ['Undo', 'Redo'],
            ['Link', 'Unlink', 'Anchor', 'Image', 'image2', 'addFile', 'Iframe',
             'Table', 'HorizontalRule'],
            ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-',
             'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock',
             '-', 'Blockquote', 'CreateDiv', 'ShowBlocks'],
            ['RemoveFormat', 'SpecialChar', 'TextColor', 'BGColor',
             '-', 'PasteCode', 'Source', 'Maximize']
        ],
        'stylesSet': 'mystyles:%sjs/ckeditor-styles.js' % STATIC_URL,
        'width': 1000,
        'bodyClass': 'article__body detail',
        'contentsCss': ['%scss/ckeditor-css.css' % STATIC_URL],
        'allowedContent': False,
        'extraPlugins': 'image2,pastecode',
        # 'enterMode': 1  # CKEDITOR.ENTER_P(1), CKEDITOR.ENTER_BR(2), CKEDITOR.ENTER_DIV(3)
    },
}

And this the result:


text:
Q: Entropy of generalized distributions? What's the entropy of the following generalized probability distributions?
$P_1(x) = \delta(x)$
$P_2(x,y) = \delta(x+y)$, for $0\le x\le 1$, and $P_2(x,y)=0$ otherwise.
Integrals of the type $-\int \delta(x) \ln\delta(x) \mathrm{d}x$ seem to diverge to $-\infty$ (see here). But entropy is supposed to be positive. What's going on here? How can I compute the entropy of these distributions? Is there a way to define entropy for these distributions?

A: Typical Shannon entropy, on discrete set of probabilities, needs to be positive, as it is average of non-negative numbers, i.e.
$$\sum_i p_i \left(\tfrac{1}{p_i}\right).$$
Differential entropy need not to be positive. It is
$$\int p(x) \log\left(\tfrac{1}{p(x)}\right) dx,$$
which does not need to be positive. $p(x)$ is probability density, so it can be greater than one, making $\log(\tfrac{1}{p(x)})$ negative. In fact differential entropy can be viewed as Shannon entropy, where we do limit for infinitesimally small boxes and subtract $\log(1/\epsilon)$ (i.e. box size), otherwise the limit diverges:
$$
\lim_{\epsilon\to\infty} \sum_i p_{[i\epsilon, (i+1)\epsilon]}
\log\left(\tfrac{1}{p_{[i\epsilon, (i+1)\epsilon]}}\right)
$$
$$
\approx
\lim_{\epsilon\to\infty}
\sum_{i} p(i \epsilon)\epsilon
\log\left(\tfrac{1}{p(i \epsilon)\epsilon}\right)
$$
$$
=
\lim_{\epsilon\to\infty}
\left(\sum_{i} p(i \epsilon)\epsilon
\log\left(\tfrac{1}{p(i \epsilon)}\right)
+ \log(1/\epsilon) \right)
$$
$$
=
\int_x
p(x)
\log\left(\tfrac{1}{p(x)}\right) dx
+ \lim_{\epsilon\to\infty}\log(1/\epsilon)
$$
For Dirac delta differential entropy is $-\infty$, so you are right.


text:
Q: Limits of entire functions Given an entire function $f \left(x \right)$, which entire function $g \left(x \right)$ is asymptotic to $f \left(x \right)$ as $x \rightarrow \infty$ and asymptotic to $1$ as $x \rightarrow 0$?
When I say asymptotic, I mean that the limit of their quotient is equal to $1$.
We assume that $x$ stays always positive.

A: I guess it depends on exactly what you mean by asymptotic, but how about
$$g(x) = f(x)-f(0)+1\:?$$
(I.e. change the $x^0$ coefficient in the Maclaurin series of $f$ to $1$.)


text:
Q: Replace image with other image I'm new in android, so I still learning simple things. :)
I have images (*.jpg) in directory named "drawable-xhdpi" (only there). I can see the R.java file contain these images and set them a corresponding hex value.
I add my image view to the XML file:
<ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/a1" />

So, After setting this, I can see it in the begining of the emulator.
Now, I want to change it to be "a2.jpg" in code. I have the string path of an image file described above (for example: "a2"). therefore, I used:
ImageView (ImageView) findViewById(R.id.imageView1);
int resId = getResources().getIdentifier("a2", "drawable", getPackageName());
image.setImageResource(resId);

But it's fail. the image isn't replaced by the other image. and it doesn't matter if I wrote the above lines in the OnCreate method of the activity, or in some method which respond to android:OnClick.
I looked the previous answer in the forum, but still can't find - what have I missed?
Thanks for your help.


text:
Q: Select statement, table sample, equal distribution Let's assume there is a SQL Server 2008 table like below, that holds 10 million rows.
One of the fields is Id, since it's identity it is from 1 to 10 million.
CREATE TABLE dbo.Stats
(
   id      INT IDENTITY(1,1) PRIMARY KEY,
   field1  INT,
   field2  INT,
   ...
)

Is there an efficient way by doing one select statement to get a subset of this data that satisfies the following requirements:

*

*contains a limited number of rows in the result set, i.e. 100, 200, etc.

*provides equal distribution of a certain column, not random, i.e. of column id

So, in our example, if we return 100 rows, the result set would look like this:
Row 1 - 100 000
Row 2 - 200 000
Row 3 - 300 000
...
Row 100 - 10 000 000

I want to avoid using cursor and storing this in a separate table.

A: Not sure how efficient it's going to be, but thie following query will return every 100000th row (relative to ordering established by id):
SELECT *
FROM (
    SELECT *, ROW_NUMBER() OVER (ORDER BY id) RN
    FROM Stats
) T
WHERE RN % 100000 = 0
ORDER BY id

Since it does not rely on actual id values, this will work even if you have "holes" in the sequence of id values.

A: Something like this?
SELECT id FROM dbo..Stats WHERE id % 100000 = 0

it should work, since you are saying that id goes from 1 to 10 000 000. If number of rows is not known, but number of resulting rows is what you know, then just calculate that 100000 number like (if you would like 100 resulting rows):
SELECT id FROM Stats WHERE (id % (SELECT COUNT(id) FROM Stats) / 100) = 0


text:
Q: Photo Gallery page loads extremely slow my photo gallery page takes way to long to load. Are there any simplier ways? I tried making the images all small to load quicker, but it is still very slow and will at times freeze.
It is about 60 photos.
CSS:
#center img
        {
        opacity:0.5;
        -webkit-transition: opacity 1s linear;
        }

#center img:hover
        {
        opacity:1.0;
        -webkit-transition: opacity 1s linear;
        }

#center {
            float: left;
            margin: 10px 0 10px 20px;
            min-width: 200px; width: 494px; border-radius:8px;
        }
#center  a img {
    border: 2px solid black;
    height: 100px;
    margin-top: 4px;
    vertical-align: top;
    width: 145px;
}

HTML:
<!DOCTYPE html>

<title>Predict the Result</title>
   <meta charset="utf-8">
   <link rel="stylesheet" href="april.css" />

Copyright "Younani" Michael Younani 2012

A: You appear to be showing the full-sized image for the gallery, and resizing it with html. This is not best practice, as it requires the user to download all images at full resolution. 60 of them is just too many, and is probably over 10mb in downloads, at a guess.
Also, using width and height to resize images is not good for performance.
The answer is thumbnails.
You must make a smaller copy of every image, and use this in the link of your slideshow, instead of just showing a squashed version of the full-size image.
You can also use some form of lazy loading, where an image is only shown when it is needed.
It looks like you're doing this by hand, so you might find generating a web album in Picasa to be a quick and easy to to make thumbnails.
I hope this helps.


text:
Q: Wordpress editor: lock editing part of page My client wants to edit pages content in Wordpress. I had to disable visual editor because it ruins custom html. The problem is my client isn't familiar with HTML.
What I want is to lock part of source code in WP editor for ex. in line

Lorem ipsum

I want to allow him to modify only "Lorem ipsum" part.
How can I do that?

A: well you can provide a textarea for him to enter text and then replace html inside element with class whatever, so basically you control regions of html where modifications can be made instead of whole page, of-course you need to write some code to do so.
I would simply mark the editable regions with some kinda class, and then on page load add some script which will pick all regions with that clas and show a small editable button there, on click of those button a shim with text area would pop up where user can add his text/html and on done, the markup would be injected inside the element. Later on save, the whole page would can be saved, little tricky but can work :)


text:
Q: How to fetch data from SQL Server using VB.Net DateTimePicker I am having a challenge with my project.
I need to retrieve sales transactions between set dates and time. e.g (From 2:00 Pm on 1/3/2021 To 8:00 Am 2/3/2021).
This is a VB.net 2015 with SQl Server 2012.
The dates are provided by the Datetime Picker tool, and the associated SQL column type is "Datetime" (2021-03-02 16:27:33.233).
Here is what i have tried:
Dim tbls As New DataTable()
' cmd = New SqlCommand("Select * from RECEIPTS  WHERE Time BETWEEN @dafrom AND @dato ORDER BY 'Receipt_No'", con)
cmd = New SqlCommand("Select * from RECEIPTS WHERE Date Between @Stim And @Etim ORDER BY 'Receipt_No'", con)

cmd.Parameters.Add("@Stim", SqlDbType.DateTime).Value = Datefrom.Value
cmd.Parameters.Add("@Etim", SqlDbType.DateTime).Value = DateTo.Value

Dim adapter As New SqlDataAdapter(cmd)
adapter.Fill(tbls)

I enabled the time part from the DateTimePicker to allow me set a time, But my query only returns rows based on the Date part without the time.

A: At a complete guess, but I am guessing that what you are saying is that data for the last date is missing. For example, if you select 2021-01-01 and 2021-01-31 for your input parameters, a row with a value of 2021-01-31T17:00:00 is not being returned.
The reason for that is quite simple, because 2021-01-31T17:00:00 is not BETWEEN the values 2021-01-01 and 2021-01-31; as 2021-01-31 is effectively 2021-01-31T00:00:00.
When dealing with date and time values, you are better off using date explicit date boundaries with >= and <. This means your query should probably be the following:
cmd = New SqlCommand("SELECT {Explicitly define your columns} FROM dbo.RECEIPTS WHERE [Date] >= @Stim AND [Date] < DATEADD(DAY,1,@Etim) ORDER BY Receipt_No;", con)

I have also changed ORDER BY 'Receipt_No' as it made no sense; it might as well have read ORDER BY 'What ever you like SQL Server. Any arbitrary value will do.'. Column names don't go in single quotes ('); single quotes are for literal strings. The delimit identifier for objects in T-SQL is brackets ([]), however, it also supports ANSI-SQL's double quotes (").

A:
because i only need the time part of the control to filter my transaction table.

In order to extract time from DateTime, you can use
yourDateTime.ToString("HH:mm:ss")

Or
yourDateTime.ToShortTimeString()

For example,
Dim d = New DateTime(2021, 3, 2, 16, 27, 33)
Dim time = d.ToString("HH:mm:ss")  ' 16:27:33
Dim tm = d.ToShortTimeString()     ' 4:27 PM

A: Thanks, Evryone, I have Finally found a solution to my question.
I realised the datetimepicker was sending both Date and Time, Also I use datetime type in SQL Db, So i just Make use of 2 Datattime picker (i.e Date from adn Date To) and i change the Format property to custom. and i Set it to (MM/dd/yyyy hh:mm:ss tt) and my problem was solved.


text:
Q: Log4Net stops logging following db backup On some nights our site stops logging at the time the db backup happens - in the last week, we've had 5 days with no issues and 2 days where we had to recycle the IIS app pool to get logging going again.  We are logging at DEBUG level.  The last item before it stops is a DEBUG-level log.
Our theory is that it only breaks when a request happens at the time of the db backup.
Any ideas as to the potential cause, or a reliable solution?

A: Log4net stops logging to the database if there is a connection problem. You can set the ReConnectOnError flag on your appender (make sure that you use a very short connection timeout or else your application may hang).


text:
Q: typescript type for object with unknown keys, but only numeric values? I have an object that I get from an external source at runtime. It has arbitrary string string valued keys, but only numric values. It could look like:
{foo:1, bar:3}

but it might as well look like
{asdf: 1}

I want the typescript compiler to know that for all present keys, the value is numeric. I tried things like type numObj = {string: number} and type numObj = {[string]: number} but neither works.
What is the suiting type declaration?

A: As given by jonrsharpe in his comment typescript type for object with unknown keys, but only numeric values?:

{ [key: string]: number }? Read the docs on indexable types:
  www.typescriptlang.org/docs/handbook/interfaces.html


text:
Q: Is there any Android notifications setContentTitle and setContextText magic values? I'm currently working on a library with android support.
I'm being asked to notify user on foreground service start.
The notification must contain "ApplicationName" as title, and "ApplicationName is running" as text. The notification icon has to be the same as the launcher one.
The target API level is 26.
The notification did not work because the previous developper forgot to open the notification chanel. This is now fixed, we have the notification that pops correctly. And the label are matching expectation.
But now i'm questioning why the notification contains the expected values. I could not find any reference in the javadoc.
The following code will display the notification as expectecd the application's name as title and the text "ApplicationName is running" :
@Override
public void onCreate() {
    NotificationChannel channel = new NotificationChannel("APPLICATION_CHANNEL", "MyService", NotificationManager.IMPORTANCE_LOW);
    channel.setDescription(notificationChannelText);
    //block below useful for head up notification
    channel.setSound(null, null);
    channel.setShowBadge(false);
    channel.enableLights(false);
    channel.enableVibration(false);

    NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.createNotificationChannel(channel);
}
@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    foregroundNotification();
    return Service.START_STICKY;
}
/**
 * In order to start foreground service we and generate a service running notification.
 */
private void foregroundNotification() {
    Context context = getApplicationContext();
    Intent notificationIntent = new Intent(context, getClass());
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    Notification notification = new Notification.Builder(context, "APPLICATION_CHANNEL")
            .setContentTitle("Title")
            .setContentText("Subject")
            .setContentIntent(pendingIntent)
            .build();
    startForeground(42666, notification);
}

Why doesn't it just display a notification with "Title" as the title and "Subject" as content ?
Are there any constants or magic values that we have to know ?
Where can we find any documentation or definition about it ?
Edit 2020/04/01 : Added code representing notification channel creation

A: I found your problem. This is result of your code:

and after add small icon:
.setSmallIcon(R.mipmap.ic_launcher)

It works fine


text:
Q: Can't create resource in Cloudformation as name is already taken I'm trying to set up a tech stack through cloudformation. I've had to deploy it many times as it's difficult to piece together, and am currently stuck on one thing. I have the following resource defined which I constantly need to rename, as when I delete my stack then go to recreate it, I receive an error stating that the resource already exists by that name. This is especially confusing as I can't find the resource being listed anywhere in my AWS console ( I'm in the correct region ). Please see below, any advice would be appreciated.
Thanks,
Erik
  DBSecurityGroupTwentyFour:
Type: AWS::EC2::SecurityGroup
Properties:
  GroupName: DBSecurityGroupTwentyFour
  GroupDescription: Security group for NGINX container
  SecurityGroupIngress:
    - IpProtocol: tcp
      FromPort: 3306
      ToPort: 3306
      CidrIp: 0.0.0.0/0

A: In these case I usually add the stack name in the field to preserve the uniqueness.
Example:
  DBSecurityGroupTwentyFour:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupName: !Sub ${AWS::StackName}DBSecurityGroupTwentyFour
      GroupDescription: !Sub ${AWS::StackName} - Security group for NGINX container
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: 3306
          ToPort: 3306
          CidrIp: 0.0.0.0/0

A: You can also just skip GroupName: DBSecurityGroupTwentyFour:
DBSecurityGroupTwentyFour:
  Type: AWS::EC2::SecurityGroup
  Properties:
    GroupDescription: Security group for NGINX container
    SecurityGroupIngress:
      - IpProtocol: tcp
        FromPort: 3306
        ToPort: 3306
        CidrIp: 0.0.0.0/0

This way CFN will auto-generate a name for the SG, and you don't have to worry about naming it.


text:
Q: Обновление данных в новости (activerecord) Имеется метод, который выводит одну новость:
    public function actionOne()
{
    $id_article = $_GET['id'];
    $onenews = NewsModel::getOne($id_article);
    $view = new View();
    $view->listonenews = $onenews;
    $view->display('adminnews/one.php');

// Здесь происходит обновление записей, данные приходят из формы

    $onenews->title = $_POST['title'];
    $onenews->date = $_POST['date'];
    $onenews->text = $_POST['text'];
    $onenews->updateNews();
}

Проблема состоит в том, что форму обрабатывает эта же страница, а следовательно, на экран выводятся предупреждения, поскольку данные из формы еще не пришли:

Notice: Undefined index: title

и так со всеми полями, которые я собираются обновить.
Подскажите пожалуйста, как можно исправить этот момент.

A: Грамотно разделить обработку и рендер формы на разные action в одном вы будете рендерить форму как есть, в другом обрабатывать форму. И стоит использовать методы работы с пост на подобие getPost(),getParam()  и т.д. и т.п. используемого фреймворка, или же написать свой метод
public function getPost($key) {
    if(isset($_POST[$key])) {
        return $_POST[$key];
    } else {
        return null;
    }
}

и обработка формы будет выглядить примерно так
public function actionOneSave() {
       $onenews->title = $this->getPost('title');
       $onenews->date = $this->getPost('date');
       $onenews->text = $this->getPost('text');
       $onenews->updateNews();
}


text:
Q: Android Studio - Install failed. Installation failed Rerun I am unable to run my android project on any android device.
I am getting error on android studio. My project is building and compiling without any error.
Attaching screenshot

A: Wiping emulator may help, but what if I'm using physical, configured for use device? This bug is weird and a bit random... for me restarting IDE and device helped, also used Android Studio -> Files -> Invalidate Caches / Restart and manual killing/restarting daemon with adb kill-server and adb start-server commands
also: note that some devices have additional toggles to turn on for developing purposes, e.g. Xiaomi have separated option in dev prefs for allowing installing apks through USB, USB debugging turned on isn't sufficient

A:
Blockquote

In my device don't  have efficient space .After remove some apps this error  solved.

A: Sometimes, the actual error message shows up in IDE (internal) Fatal Errors, accessible at the bottom right of the Android Studio IDE (should be a red circle with an exclamation mark within).
When it happened for me, I found out through Fatal Errors that my target device was out of space.

A: *

*Close emulator.

*Wipe data in AVD Manager for a particular emulator.

A: I have faced this issue on the Android Emulator (last available version, HAXM 7.5.1) installing a project with API 28 under AS 3.4.1 (a simple run, not a debug!). The solution was to set check to
File -> Settings -> Debugger -> Allow unsigned requests checkbox.
UPDATE 28/07/2019
The reason was an insufficient internal memory of API 28 Emulator in my case. The error have disappeared after adding extra space.

A: I was getting the same error without any other build/compilation error after editing my AndroidManifest.xml and accidentally leaving a meta-data tag without a corresponding android:value or android:resource attribute. Check your manifest for similar errors
Wrong:
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>

Right
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter"/>

A: If you are using physical device, go to settings/developer options in your device and turn on "Install via USB" option. This will allow installation via USB.


text:
Q: ssl_error_rx_record_too_long I've googled this error but came up with no solution, this happened when I installed oracle database 11g, I tried to reach https://localhost:1158/em and this error pops up in firefox
Secure Connection Failed

An error occurred during a connection to localhost:1158.

SSL received a record that exceeded the maximum permissible length.

(Error code: ssl_error_rx_record_too_long)

    *   The page you are trying to view can not be shown because the authenticity of the received data could not be verified.

    *   Please contact the web site owners to inform them of this problem. Alternatively, use the command found in the help menu to report this broken site.

Anyone had similar problem before, I'd be thrilled if someone could help. thank you

A: Are you sure that the dbconsole was secured and is actually an SSL service? Try to connect to http://localhost:1158/em and see what happens...


text:
Q: return Int from a generic mathematics type in swift How to require a generic type to be usable in mathematical operations is mentioned here
Which led me to this protocol
protocol MathematicsProtocol : Equatable
{
    init(_ value: Int)
    init(_ value: Float)
    init(_ value: Double)

    func + (lhs: Self, rhs: Self) -> Self
    func - (lhs: Self, rhs: Self) -> Self
    func * (lhs: Self, rhs: Self) -> Self
    func / (lhs: Self, rhs: Self) -> Self
}
extension Int:    MathematicsProtocol {}
extension Float:  MathematicsProtocol {}
extension Double: MathematicsProtocol {}

used in this snippet
struct MyRange<DataType : MathematicsProtocol>
{
    let start : DataType
    let end   : DataType
    let step  : DataType

    subscript(index: Int) -> DataType
    {
        get {
            assert(index < self.count)
            return start + DataType(index) * step
        }
    }

    var count : Int {
        return Int((end-start)/step) //not working
//      return 4
    }
}

However the conversion of DataType to Int in the count function doesn't work.
Is there a way to fix this?
Edit:
This works, but it's an ugly hack using a string as a temporary value.
func convert<DataType : MathematicsProtocol>(value : DataType) -> Int
{
    let intermediate = "\(value)" as NSString
    return intermediate.integerValue
}

A: You have to define how a MathematicsProtocol is converted to an Int, e.g.
by adding a intValue property to the protocol:
protocol MathematicsProtocol {
    // ...
    var intValue : Int { get }
}
extension Int:    MathematicsProtocol {
    var intValue : Int  { return self }
}
extension Float:  MathematicsProtocol {
    var intValue : Int { return Int(self) }
}
extension Double: MathematicsProtocol {
    var intValue : Int { return Int(self) }
}

Then you can use it as
var count : Int {
    return ((end-start)/step).intValue
}


text:
Q: Use same id for any element in two different views of a controller i am just curious that can we use same id of any element say div in two different views of the same controller (in any framework).
Note _ It's working ,when i'm assigning dynamic value to div . can any one explain , why it's working because as far i know it'd not work . I'm using Ruby on Rails
Review: I'm not asking for using duplicate id on the one view of a controller , I'm asking for having two different pages but same controller and the same js file

A: It's not impossible, even it doesn't raise errors or anything it is still wrong to use same ID for different elements. ID should be unique but you have to make sure that stays that way. RoR has nothing to do it.
If you need an identifier to use in some JS code, I would suggest create an id like "my-model-#{id}"(although not CSS friendly) where only the id is dynamically changed. Or use some data attribute on the element like data-my-unique-id="#{id}"
For me, I would stay with a data attribute, ID it's reachable on the CSS and that's why it should have a descriptive name and stay like that, avoiding dynamically values.

A: It works because each view is essentially a different html document. ID of an html element should be unique in a document. But If you need to use same ID for multiple elements across different views, better approach would be to use classes.


text:
Q: Find and print lines that have column value repeated n times I have a file:
scaffold_0      11498
scaffold_0      11501
scaffold_0      11728   "RHOH"
scaffold_0      12144   "RHOH"
scaffold_0      20708   "RHOH"
scaffold_0      23579   "RHOH"
scaffold_0      130818
scaffold_0      200485  "NSUN7"
scaffold_0      209928  "NSUN7"
scaffold_0      212965  "NSUN7"
scaffold_0      214055  "APBB2"
scaffold_0      223404
scaffold_0      223686  "APBB2"
scaffold_0      227687  "APBB2"
scaffold_0      306105  "APBB2"
scaffold_0      307000  "APBB2"
scaffold_0      391742
scaffold_0      399332  "UCHL1"
scaffold_0      406726  "UCHL1"
scaffold_0      482215
scaffold_0      484921
scaffold_0      538855  "LIMCH1"
scaffold_0      539051  "LIMCH1"
scaffold_0      539819
scaffold_0      543347  "LIMCH1"
scaffold_0      568182  "LIMCH1"
scaffold_0      570321
scaffold_0      570325
scaffold_0      577502  "LIMCH1"
scaffold_0      578933  "LIMCH1"
scaffold_0      621330  "PHOX2B"
scaffold_0      623303  "PHOX2B"
scaffold_0      640271
scaffold_0      667510  "gene3"
scaffold_0      679096
scaffold_0      698659  "TMEM33"
scaffold_0      700427  "TMEM33"

and I want to print the lines for which the items in the 3rd column are repeated 3 or more times. So that these lines are deleted:
scaffold_0      399332  "UCHL1"
scaffold_0      406726  "UCHL1"
scaffold_0      621330  "PHOX2B"
scaffold_0      623303  "PHOX2B"
scaffold_0      667510  "gene3"
scaffold_0      698659  "TMEM33"
scaffold_0      700427  "TMEM33"

I would be happy to have the order of the file kept and the lines for which the 3rd column is empty stay.
 I tried:
sort -k3 file.txt | awk 'a[$3]++{ if(a[$3]>=2){ print b }; print $0}; {b=$0}'

A: This awk reads and hashes the whole file into memory
$ awk '{
    a[NR]=$0              # hash to a using record number as the key for order
    c[$3]++               # $3 counter
}
END {                     # after file records have been hashed
    for(i=1;i<=NR;i++) {  # iterate in order
        split(a[i],b)     # get the 3rd column
        if(c[b[3]]>=3)    # output if count is right
            print a[i]
    }
}' file

Output sample:
...
scaffold_0      306105  "APBB2"
scaffold_0      307000  "APBB2"
scaffold_0      391742
scaffold_0      482215
scaffold_0      484921
scaffold_0      538855  "LIMCH1"
scaffold_0      539051  "LIMCH1"
...

A: $ awk 'NR==FNR{c[$3]++;next} c[$3]>2' file file
scaffold_0      11498
scaffold_0      11501
scaffold_0      11728   "RHOH"
scaffold_0      12144   "RHOH"
scaffold_0      20708   "RHOH"
scaffold_0      23579   "RHOH"
scaffold_0      130818
scaffold_0      200485  "NSUN7"
scaffold_0      209928  "NSUN7"
scaffold_0      212965  "NSUN7"
scaffold_0      214055  "APBB2"
scaffold_0      223404
scaffold_0      223686  "APBB2"
scaffold_0      227687  "APBB2"
scaffold_0      306105  "APBB2"
scaffold_0      307000  "APBB2"
scaffold_0      391742
scaffold_0      482215
scaffold_0      484921
scaffold_0      538855  "LIMCH1"
scaffold_0      539051  "LIMCH1"
scaffold_0      539819
scaffold_0      543347  "LIMCH1"
scaffold_0      568182  "LIMCH1"
scaffold_0      570321
scaffold_0      570325
scaffold_0      577502  "LIMCH1"
scaffold_0      578933  "LIMCH1"
scaffold_0      640271
scaffold_0      679096

.
$ awk 'NR==FNR{if ($3!="") c[$3]++;next} c[$3]>2' file file
scaffold_0      11728   "RHOH"
scaffold_0      12144   "RHOH"
scaffold_0      20708   "RHOH"
scaffold_0      23579   "RHOH"
scaffold_0      200485  "NSUN7"
scaffold_0      209928  "NSUN7"
scaffold_0      212965  "NSUN7"
scaffold_0      214055  "APBB2"
scaffold_0      223686  "APBB2"
scaffold_0      227687  "APBB2"
scaffold_0      306105  "APBB2"
scaffold_0      307000  "APBB2"
scaffold_0      538855  "LIMCH1"
scaffold_0      539051  "LIMCH1"
scaffold_0      543347  "LIMCH1"
scaffold_0      568182  "LIMCH1"
scaffold_0      577502  "LIMCH1"
scaffold_0      578933  "LIMCH1"


text:
Q: Boost MPL Sequence and defines: How to turn MPL Sequence into define string? I understand we can print elements into define one by one knowing total count (pseudocode):
    // For the sake of simplicity, I assume the Sequence passed is a boost::mpl::vector
        #define seq_to_array_str \
        < typename boost::mpl::at<Sequence, 0>::type \
        , typename boost::mpl::at<Sequence, 1>::type \
        , typename boost::mpl::at<Sequence, 2>::type \
        ...
        , typename boost::mpl::at<Sequence, N>::type
        >

But I wonder how to automate such operation for all elements of boost::mpl Sequence? (I wonder about Vector but I hepe there can be one general answer for any mpl sequence type)


text:
Q: Template style is not setting some preferences I have a style template (below) that does not update some my custom control properties.
...
    <Style x:Name="KeyboardButton" TargetType="Controls:KeyboardButton">
...
        <Setter Property="ArrowDirection" Value="Right" />
        <Setter Property="ArrowBeginColor" Value="Red" />

        <Setter Property="Template">
...

ArrowBeginColor id DependencyProperty of Color (not brush) type.
When I do not use a setter, ArrowBeginColor is default color Black, from DependencyProperty (new PropertyMetadata(Colors.Black));)
But when I use a setter in template system can't get color. Blender runing out witn error, VS seting color to #00000000.
What do I wrong? Why ArrowBeginColor do not set color for my custom control propertly?
Other DP is OK, problem with DP Color type only.
Silverlight 4, VS 2010.

A: What's your reason for using a Color type instead of Brush? Brush is far better in terms of support with both the VS designer and Blend


text:
Q: Regularization: Evaluating the one-loop $\phi^4$ integral to order $\lambda^2$ I'm currently on the chapter of regularization on Zee's QFT book. For the $\phi^4$ theory, an amplitude for a single loop correction to order $\lambda^2$ is given by a diagram

Following the Feynman rules, we obtain the amplitude
$$
\mathcal{M}=\frac{i^2}{2}(-i\lambda)^2\int\frac{d^4k}{(2\pi)^4}\frac{1}{k^2-m^2+i\epsilon}\frac{1}{(K-k)^2-m^2+i\epsilon}
$$
where $K=k_1+k_2$. Assuming that $m<<k$ and having the cut off $\Lambda$, he said that this is equal to
$$
\mathcal{M}=iC\lambda^2log\bigg(\frac{\Lambda^2}{K^2}\bigg)
$$
Where $C$ is just some constant after evaluation. I was trying to evaluate this integral to obtain the same answer as he got, but I am getting nowhere close. I don't even understand what the bounds are in the 4 integrals if we replace them by $\Lambda$. Are all the bounds $\Lambda$?
How did he get that answer?

A: For the regulation of the amplitude $M = \frac{i^2}{2}(-i\lambda)^2 I$ with
$$I:=\int \frac{d^4k}{(2\pi)^4} \frac{1}{k^2-m^2}\frac{1}{(k-K)^2-m^2}$$
the following the strategy is applied (according to R.Feynman). With $A=(k-K)^2-m^2$ and $B=k^2-m^2$
$$I = \int \frac{d^4k}{(2\pi)^4} \frac{1}{A}\frac{1}{B}=\int_0^1 dx\int \frac{d^4k}{(2\pi)^4}\frac{1}{[xA + (1-x) B]^2}$$
Expanding the denominator we get:
$$I=\int_0^1 dx\int \frac{d^4k}{(2\pi)^4}\frac{1}{[k^2 - 2xK\cdot k + xK^2 -m^2]^2}$$
Next step is a substitution $l =k-xK$: ($l$ is a 4-vector with the components $(l^0,l^1,l^2,l^3)$):
$$I=\int_0^1 dx\int \frac{d^4l}{(2\pi)^4}\frac{1}{[l^2+x(1-x)K^2 -m^2]^2}$$
followed by a Wick rotation:  $l^0_E = -il^0$ and $\vec{l_E} = \vec{l}$
$$I = i\int_0^1 dx\int \frac{d^4l_E}{(2\pi)^4}\frac{1}{[l_E^2-x(1-x)K^2 +m^2]^2}= i\int_0^1 dx\int \frac{d^4l_E}{(2\pi)^4}\frac{1}{[l_E^2+\Delta]^2}$$
with $\Delta = m^2-x(1-x)K^2$  Apparently Zee applied Pauli-Villars regularisation which consists of replacing
$$ \frac{1}{(l_E^2 +\Delta)^2} \longrightarrow \frac{1}{(l_E^2 +\Delta)^2}-\frac{1}{(l_E^2 +\Lambda^2)^2}$$
Applying it on our integral $I$ it becomes $I_\Lambda$:
$$I_\Lambda=i\int_0^1 dx\int \frac{d^4l_E}{(2\pi)^4}(\frac{1}{[l_E^2+\Delta]^2}-\frac{1}{[l_E^2+\Lambda^2]^2}) = i\int_0^1 dx\int d\Omega_4 \int_0^{\infty} \frac{dl_E }{(2\pi)^4} \left( \frac{l_E^3}{[l_E^2+\Delta]^2} -  \frac{l_E^3}{[l_E^2+\Lambda^2]^2}\right)$$
A final substitution $z= l_E^2$ with  $dz = 2l_E dl_E $ yields ($\int d\Omega_4 = 2\pi^2$):
$$I_\Lambda=i\int_0^1 dx\int_0^{\infty}\frac{dz}{(4\pi)^2} \left( \frac{z}{[z+\Delta]^2} -  \frac{z}{[z+\Lambda^2]^2}\right)=\frac{i}{(4\pi)^2}\int_0^1 dx\,\, \log(\frac{\Lambda^2}{\Delta}) $$
Therefore we get for the regularized amplitude $M_\Lambda$:
$$ M_\Lambda = \frac{i^2}{2}(-i\lambda)^2 I_\Lambda =\frac{i\lambda^2}{32\pi^2} \int_0^1 dx\,\, \log\left(\frac{\Lambda^2}{m^2-x(1-x)K^2}\right)$$
which corresponds to Zee's formula (14) on page 152. In the computation the terms $+i\epsilon$ were omitted for simplicity.

A: If you do not need to know the constant $C$ then all you have to do is observe that the integral is Log divergent at large momentum, so it must contain a $\ln \Lambda^2$, but the argument of the log has to be dimensionless and the only dimensionful quantity that the integral dependens on is $K^2$ so it contains a $\ln (K^2/\Lambda^2)$. To get the factor of $i$ I assume that a Wick rotation is being made so that the $dk_0$ is being rotated to $i dk_0$.
If you need the actual number $C$ use the Feynman parameter method. If $m=0$ it is much easier to work  in Euclidan signature and in configuation space.


text:
Q: Como executar uma função após success do ajax? No meu projeto, no success do ajax, estou fazendo um autocomplete, ai preciso executar uma função após selecionar uma opção, ou seja, após o success. Seria possível/Como eu faria isso?

A: Após o success: você tem o o complete: porém ele é disparado tanto no caso de sucesso quanto no caso de erro, por isso você precisa valisar o xhr.status para verificar se a requisição foi concluída com sucesso. Aqui no snnipet ela sempre retorna erro, mas é possível demonstrar a ordem dos eventos.

$(document).ready(function() {
  $.ajax({
    url: "#",
    error: function() {
      console.log("Falhou!");
    },
    success: function(data, xhr, textStatus) {
      console.log("Sucesso!");
    },
    complete: function(xhr, textStatus) {
      console.log("Completo -> " + xhr.status + " - " + textStatus);
    }
  });

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>


text:
Q: Disable certain part of fragment for scrolling even though it's inside a nested scrollview Currently I am finishing the last details of my project and I am trying to keep a certain part inside a nested scrollview to stay on top of the screen and let only the recyclerview scroll.
This is the code I have right now:
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    android:id="@+id/marktplaats_refresh"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/imageView14"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:scaleType="centerCrop"
                android:tint="#9F000000"
                app:layout_constraintCircleRadius="10dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="1.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/offer_bg"/>

            <Button
                android:id="@+id/verkoopEenProduct"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="10dp"
                android:background="@null"
                android:text="Verkoop een product"
                android:textColor="@color/white"
                android:textSize="12sp"
                android:textStyle="bold"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent"/>

            <EditText
                android:id="@+id/button5"
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="10dp"
                android:background="@drawable/light_contact_buttons"
                android:hint="Zoek in marktplaats"
                android:textAlignment="center"
                android:gravity="center_vertical"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView33"/>

            <TextView
                android:id="@+id/textView32"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:layout_marginEnd="10dp"
                android:text="Marktplaats"
                android:textColor="@color/white"
                android:textSize="18sp"
                android:textStyle="bold"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/verkoopEenProduct"/>

            <TextView
                android:id="@+id/textView33"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:text="Hier vind u alles wat u nodig\nhebt voor uw praktijk"
                android:textColor="@color/white"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView32"/>

            <TextView
                android:id="@+id/textView34"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:text="Alle producten"
                android:textSize="18sp"
                android:textStyle="bold"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/imageView14"/>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/marktplaats_recyclerview"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView34"/>

            <Button
                android:id="@+id/button11"
                android:translationX="-20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@null"
                android:rotation="180"
                android:text="➜"
                android:textColor="@color/white"
                android:textSize="36sp"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"/>
        </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

And this is my kotlin

class MarktplaatsOverview : ApplicationFragment(){
    var products: Array<MarketModel> = arrayOf()

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        super.onCreateView(inflater, container, savedInstanceState)
        return inflater.inflate(R.layout.fragment_marktplaats, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        marktplaats_refresh.setOnRefreshListener {
            refreshData()
            marktplaats_refresh.isRefreshing = false
        }

        button11.setOnClickListener {
            navController.navigate(R.id.action_marktplaatsOverview_to_more)
        }
        button5.requestFocus()

        refreshData()

        verkoopEenProduct.setOnClickListener {
            navController.navigate(R.id.action_marktplaatsOverview_to_marktplaatsDetail)
        }
    }

    private fun refreshData() {
        if (DataStorage.market.isNotEmpty()) {
            setupRecyclerView()
        } else {
            SharedInstance.api.getAllMarketItems {
                if (isAdded) {
                    setupRecyclerView()
                }
            }
        }
    }

    private fun setupRecyclerView(){
        SharedInstance.api.getAllMarketItems {
            products = DataStorage.market
            val xLayoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true)
            xLayoutManager.stackFromEnd = true
            marktplaats_recyclerview.layoutManager = xLayoutManager
            marktplaats_recyclerview.adapter = MarktplaatsAdapter(products)
        }
    }
}

Does anyone have a solution for this awkward problem? I've been trying to do some restructuring of the swiperefreshlayout, scrollviews and constraints but no succes so far.
I also can't find anything on the internet where someone wants the same as me...

A: As per your question description, I am assuming that you face an issue that recycler view scroll or take focus automatically while you open screen and you need to stick layout at the top so pass this field on your parent layout.
android:descendantFocusability="blocksDescendants"

or replace your SwipeRefreshLayout
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    android:id="@+id/marktplaats_refresh"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:descendantFocusability="blocksDescendants"
    android:layout_height="match_parent">

I hope it helps you.


text:
Q: How does Google Calendar update the content of an email AFTER it is sent? Google calendar invite emails will update after they are sent if the original event has been changed... how does Google achieve this? Is there a general technique for anyone to do this? Or is this only possible because Google owns both gMail/gCalendar and the two systems are integrated behind the scenes outside of SMTP?
My first guess was that they used an iframe or an image that was loaded when the email was opened, but inspecting the source of the gMail page doesn't show any signs of that.
Here's a screenshot of the updated text:

And here's the HTML for that section of the page when reading the email within gMail:

A: Note :
Inspecting Source wil give you nothing other than the markup of the content you see in the page after all dynamic operations including ajax.
To check the actual source, you want to visit view-source:url.
Now the question
That information is updated automatically at Run time via a JavaScript code.
In the image, you checked on Inspect element, which show the code of live view and so, you saw the updated content.
It is done by JavaScript DOM and text manipulation.
To verify this,

*

*Click on the address bar.

*add view-source: before the url. So, it will look like view-source:https://url

*Then press ctrl+f or the corresponding key to find.

*Search for the <div id=":8hg" which will show 0 results.

The view-source is load the source of the file without any ajax or JavaScript manipulation.
The div is not present in the source. So, we can understand that it is done dynamically.
When checking in detail,
in the source, we can see a link https://www.google.com/calendar/event?action\u003dVIEW\u0026eid\u003db..... which is stored in an array.
From this link, the content is taken.

(I blacked out some text for privacy).
Based on the return of the url, the content on mail is upated.
To verify this,
In the mail, you can see This invitation is out of date
But in the view-source: page, search for This invitation is out of date and it will return 0 results.
So, it is sure that the Calendar details are taken via an API call by Gmail to the G Calendar API.

A: I wonder if on sending the email they create an image at some url and then if it changes they just remove it, then in the email they have something like

Although im not sure if they can't use the onerror attribute (b/c email + js = bad idea). the only other way is just to use alt attribute and use some css trickery but I don't see how that could result in the inspected code.


text:
Q: What is the point of OOP visibility in PHP when Closures and Reflections are available? Consider this code here:
final class TinkerWithMe {
    protected $key1 = 19;
    private $key2 = 88;
}

$class = new TinkerWithMe();

$getKeys = function() {
    return array($this->key1, $this->key2);
};

$oldKeys = $getKeys->call($class);

$newKey1 = 96;
$newKey2 = 42;

$setKeys = function() use ($newKey1, $newKey2) {
    $this->key1 = $newKey1;
    $this->key2 = $newKey2;
};

$setKeys->call($class);

Why bother with OOP visibility when you can get around it so easily with Closures or Reflections?
Is there a way of blocking this kind of thing that I am missing?

A: Great question!  I would like to add few more points
The purpose of specifying visibility in OOP languages is:

*

*To show what the properties and  methods are meant to do. This is to bring clarity among developers as to how to access/modify the property and methods, to decide whether to extend the class or not.

*The properties that are set inside its respective class is validated and set to correct values and it is safe to be used inside the Class without checking the property type.

*It is not a foolproof way to secure the data from modification.

The Purpose of Closures is to throw a piece of function into a variable or another function to perform some activity once in a while. Instead of dedicating a separate section code in global scope for performing an action once in a while and not look at it later you can use closures.
Reflections are meant to introspect objects to know its properties, methods, class etc. It is useful to identify dependencies.
Larvel uses reflection to perform dependency injection of objects.
Yes as you said you can use Closures and Reflection to work around visibility but it should be viewed as a language feature rather than a design flaw as no language can secure data 100%

A: Visibility modifiers aren't iron clad protection or ensure any sort of security or anything of that sort. They're markers for how a piece of code is intended to be used.
When writing a piece of code like a class, other pieces of code are going to couple with it; meaning you will write other code that calls methods of that class or accesses properties of that class. In order to minimise coupling to the absolute necessary, you will want to keep the public interface of the class as small as possible. When you designate something as public, you're marking it "for general use". That public piece should then be rather stable and not change, or you risk breaking a lot of coupled code if you do change it.
Marking something as protected or private marks these parts as not for general consumption; it clarifies that these implementation details might change in the future or are not supposed to be used by other code "not in the know". This allows you to easier refactor those parts later as necessary and having a better idea of what other parts might break as a result. It also helps to ensure the internal state of the class is consistent when external code won't directly modify internal values without completely understanding how it should do so.
PHP will help you honour those markers in the general case by throwing errors when naïvely trying to access protected or private properties "from the outside"; that prevents most accidental usage and unwanted coupling. PHP is not going to bend over backwards to ensure those properties stay inaccessible under all possible circumstances. If you're really bent on shooting your own foot, so be it. Perhaps you need to do so for testing purposes; it would be counter productive to absolutely prevent you from doing so.
In the mantra of Python:

We're all consenting adults here.


text:
Q: Exporting and importing a database I have setup an Oracle 11g Database and have a question about exporting and importing a database.
I am using Enterprise Manager and have browsed to the following: Data Movement->Export to Export Files. Down the bottom of the screen, I need to supply Host Credentials. When trying to use the username SYS, I see that the error message says to logout and login using a different role.
What role should I use? Should I create a specific role for this task, and if so, what priviledges should the role have?

A: The link below is from oracledistilled.com and goes through Enterprise Manager >> Data Movement.
Clone a Database to Another Host using Enterprise Manager 11gR1 Grid Control
It is very well explained with good screen shots and walks through Cloning i.e. another function under 'Data Movement' >> 'Export Export to File'.
Under host credentials the normal user is the O/S Oracle user, Alex Poole mentioned in a comment:

Host credentials are for an operating system account (e.g. Oracle). SYS is a database account and has to be connected AS SYSDBA (not as 'normal' in the drop-down role when you log in to EM).


text:
Q: Using CSS to show/hide content. How do I make hide the default I am trying to hide some content on a webpage until a user clicks on the [...]. So far Google has gotten me the following

some text I want to show

[...]
[...]

content I want to hide

CSS
.show {display: none; }
.hide:focus + .show {display: inline; }
.hide:focus { display: none; }
.hide:focus ~ #list { display:none; }
@media print { .hide, .show { display: none; } }

It works, but I would like hidden to be the default, and I cannot seem to figure out how to accomplish that.
As always, any help is appreciated.

A: Just change css like following will work for you.
First hide list. And on focus display.
.show {display: none; }
#list { display:none; }
.hide:focus + .show {display: inline; }
.hide:focus { display: none; }
.hide:focus ~ #list { display:block; }

Fiddle


text:
Q: retrieving latest post from Tumblr via jquery I'm trying to integrate a Tumblr blog into a website. Specifically I want to display the latest text post.
I have taken a look of Tumblr API and everything looks quite easy but I cannot make it work.
According to the documentation for Tumblr API v2  (http://www.tumblr.com/docs/en/api/v2)
this is the call I need:
http://api.tumblr.com/v2/blog/blog.tumblr.com/posts/text?api_key=KEY&limit=1
and if I put it in my browser I get what I want.
However if I try to retrieve the post'title to it using jquery 1.7.1 as specified below
$.getJSON('http://api.tumblr.com/v2/blog/blog.tumblr.com/posts/text?api_key=<KEY>&limit=1', function(data) {
  console.log("data.posts[0].title");
});

I get an empty response.
Am I missing something?
Thanks for your help.
SIG

A: You have to use JSONP as of the Same-Origin-Policy
How to do this you can read in the documentation in the Response Format section.

A: The solution given by Andreas is worked for me. I changed the code with $.ajax and data type to JSONP. Now I am able to get the data from tumblr.
$.ajax({
    type: "GET",
    url: "http://api.tumblr.com/v2/blog/blog.tumblr.com/posts/text?api_key=<KEY>&limit=1",
    dataType: "JSONP",
    success: SuccessCallbackFunction,
    error: ErrorCallbackFunction,
});


text:
Q: wait for async function ends I've my own function A, and a third party async function B that upload a file, now I would like to call function B during the execution of A, and then wait that B function ends.
I can check if the function is completed by a flag var F, the problem is that if I use the below code the browser go in an endless loop(maybe because it is busy in the loop and cannot update F).
function A(){
    // ...
    B();
    while(F);
    // ...
}

function B(){
    // ...
}

I cannot split the function A in 2 sub-functions
Sorry for my very poor english

A: JavaScript runs always in one thread. It means, that you cant do a busy wait, or you will block the entire script. You should use some async programming. Like providing a callback to your B function or letting your B func return a promise.
The callback approach will look like this:
B(function(err, result) {
    // some code after B completes
});

Function B must call the callback after completion.
When using promises, your code will be like:
B().then(function(result) {
        // result handling
    },
    function(err) {
        // error handling
    });

Promises are very handy, but require to use some third party library, as they are not a part of JS. In fact, using a promises may differ, depending on library (i.e. promises in jquery and q)


text:
Q: What's the Green's function of the photon's equation of motion? The Green's function of the Klein-Gordon equation:
$$\phi_s(x_\mu-y_\mu) =  \int \frac{d^4k}{(2\pi)^4} \;  \frac{e^{-i k^\mu (x_\mu -y_\mu)}}{-k_\mu k^\mu + m^2}$$
is the solution to the equation
$$ \left(\partial_\mu   \partial ^{\mu} + m^2\right) \phi_s = \delta(x_\mu-y_\mu) \, .$$
What's the corresponding equation and solution for a massless gauge field $A_\mu$? The free equation of motion reads
$$\partial_\sigma ( \partial^\sigma A^\rho -  \partial^\rho  A^\sigma) =0  \, $$
but I'm unsure what we write here on the right-hand side to define the Green's function since there is a free index $\rho$ in the equation of motion. Moreover, although I checked several textbooks, I wasn't able to find the expression for the Green's function for photons.

A: In momentum space the equation of motion for photon is:
$$(-p^2g_{\mu\nu}+p_\mu p_\nu)A_\mu= J_\nu$$
where $J_\nu$ is the source term. Now the term in the parentheses is not invertible since the determinant is zero (no mass term). This is also a signature of Gauge freedom of the photon fields. To remedy this, a gauge term is added to the original Lagrangian.
$$\mathcal{L}= -\frac{1}{4} F_{\mu\nu}^2-\frac{1}{2\xi}(\partial_\mu A_\mu)^2 - J_\mu A_\mu.$$
Here $\xi$ is the gauge field which satisfies the equation of motions $\partial_\mu A_\mu=0$ (Lorenz gauge). With this Lagrangian, the equation of motion becomes
$$\left[-p^2g_{\mu\nu}+\left(1-\frac{1}{\xi}\right)p_\mu p_\nu\right]A_\mu= J_\nu.$$
Now, one can check that the propagator is given by the following expression
$$\Pi_{\mu\nu}=-\frac{g_{\mu\nu}-(1-\xi)p_\mu p_\nu/p^2}{p^2}.$$
To check that this is indeed the propagator, it should satisfy the equation $\left[-p^2g_{\mu\nu}+\left(1-\frac{1}{\xi}\right)p_\mu p_\nu\right]\Pi_{\nu\beta} = g_{\mu\beta}$.
So, the expression for propagator or Green's function is dependent on the gauge choice as it should be but all the physical observables should be independent of the gauge field $\xi$. Some most used choices of gauge fields in Quantum Electrodynamics are:

*

*Feynman gauge: $\xi=1\implies \Pi_{\mu\nu}=-\frac{g_{\mu\nu}}{p^2+i\epsilon}$.

*Lorenz gauge: $\xi=0 \implies \Pi_{\mu\nu}=-\frac{g_{\mu\nu}-p_\mu p_\nu/p^2}{p^2+i\epsilon}$
The $i\epsilon$ part is added to choose the causal Green's function and in the final expression of an observable $\epsilon\rightarrow 0$ limit is taken.
To read more about photon propagators you can have a look at any QED book. The discussion of the propagator should be independent of whether this is a classical or quantum field theory.


text:
Q: Vector of pointers Efficient/Correct Iteration What is the correct way to iterate over a vector of pointers?
This prints "29" ten times, the desired output is "7, 8, 10, 15, 22, 50, 29"
Thanks a bunch!
Edit: Thanks for pointing out the initial errors. For some reason this example works even with multithreading but my code in my program doesn't. If you post an answer I'll accept it.
#include <future>
#include <vector>
#include <iostream>

int ints[] = { 1, 7, 8, 4, 5, 10, 15, 22, 50, 29 };
std::vector<int*> intptrs;
void iterate();

int main()
{
    for (int i : ints)
    {
        intptrs.push_back(&i);
    }
    std::vector<std::future<void>> futures;

    futures.push_back(std::async(iterate));
    futures.push_back(std::async(iterate));

    for (auto &f : futures)
    {
        f.get();
    }
    system("pause");
}

void iterate()
{
    for(std::vector<int*>::iterator it = intptrs.begin(); it != intptrs.end(); ++it;)
    {
        if (**it > 5)
        {
            std::cout << **it << std::endl;
            //Do stuff
        }
        else
        {
            delete (*it);
            it = intptrs.erase(it);
        }
    }
}

A: An error is that
for (int i : ints)
{
    intptrs.push_back(&i);
}

should be
for (int &i : ints)
{
    intptrs.push_back(&i);
}

The reason? In the former, i is a local variable (which gets a copy of each array element in turn), so &i gives you a pointer to the local variable. You get a vector full of copies of the same pointer... and that pointer becomes invalid as soon as the loop ends. In the latter, you actually get references to the elements of the array.

A: The traditional idiom for iterating over a vector and removing some elements looks like this:
for(auto i = somevec.begin(); i != somevec.end();) {
    if (some condition) {
        i = somevec.erase(i);
    }
    else {++i;}
}

Notice that the ++i isn't in the for loop header, it's in the body of the loop, and only happens if we don't erase. The iterator returned when you erase something from a vector is the iterator you would have gotten if you ++i'd instead, so you'll end up skipping elements and incrementing somevec.end() if you write the code the way you wrote it initially.
(The reason your code is printing '29' is because you are invoking undefined behavior by dereferencing a pointer to a auto that has since been destroyed. In your implementation, it turns out that it's still got the last value it held.)


text:
Q: Understanding std::copy After reading this code to teach how a simple vector of doubles is built:
class vector
{
    int sz;
    double* elem;

public:
    vector(int s)
        :sz{s}, elem{new double[sz]}
    {
        for (int i = 0; i < sz; ++i)elem[i] = 0.0;
    }
    vector(initializer_list<double>lst)
        :sz{ int(lst.size()) }, elem{ new double[sz] }
    {
        copy(lst.begin(), lst.end(), elem);
    }
    vector(const vector&);
    ~vector(){ delete[] elem; }
    double get(int n) const { return elem[n]; }
    void set(int n, double v) { elem[n] = v; }
};

The copy constructor is defined as:
vector::vector(const vector& arg)
    :sz{ arg.sz }, elem{new double[arg.sz]}
{
    copy(arg.elem, arg.elem + sz, elem);
}

Shouldn't the range arg.elem, arg.elem + sz be actually
arg.elem, arg.elem + sz - 1

?

A: In C++ various functions accept a beginning iterator or pointer, and an end iterator or pointer. The beginning iterator is included in whatever operation it is, be it copy or sort or whatever, but the end iterator or pointer is not included. Usually the operation is start iterator to (end iterator - 1). From the docs for std::copy:

Input iterators to the initial and final positions in a sequence to be
  copied. The range used is [first,last), which contains all the
  elements between first and last, including the element pointed by
  first but not the element pointed by last.

That's why in the containers the end() iterator doesn't point to the last element. std::vector::end() is an iterator to one past the last member for example.

A: std::copy is implemented as something like:
template<class InputIt, class OutputIt>
OutputIt copy(InputIt first, InputIt last,
              OutputIt d_first)
{
    while (first != last) {
        *d_first++ = *first++;
    }
    return d_first;
}

the element pointed to by last is not copied. If it was then the following code:
std::vector<int> in;
std::vector<int> out;
std::copy(in.begin(), in.end(), std::back_inserter(out.begin()))

wouldn't work. You'd have to do something like this which wouldn't work in the case of an empty vector:
std::vector<int> in;
std::vector<int> out;
std::copy(in.begin(), in.end() - 1, std::back_inserter(out.begin()))


text:
Q: Failed insert into database I've a problem with this code. I've this html form
<form method="post" action="invio_db1.php">
    Nome <input type="text" name="nome">

    Cognome <input name="cognome" type="text">

    <input value="Invia" type="submit">
    <input value="Reset" type="reset">
</form>

and this php code
<?php
    $host = "127.0.0.1";
    $nick = "root";
    $pw = "";
    $db_name = "associazydbe";

    $db = mysqli_connect($host, $nick, $pw) or die ("Errore nella connessione");
    mysqli_select_db($db, $db_name) or die (mysqli_error());

    if(!empty($_POST["nome"]))
        $nome = $_POST["nome"];
    else
        $nome = null;

    if(!empty($_POST['cognome']))
        $cognome = $_POST['cognome'];
    else
        $cognome = null;

    $query = "INSERT INTO persons_comeunprodigio (nome, cognome)
                  VALUES ('$nome', '$cognome')";

    mysqli_query($db, $query) or die(mysqli_error());
?>

I think it hasn't error but, after the running, in the database, all fields are null!
I can't find and fix the problem.
Thanks in advance.

A: Probably you should add condition to your PHP script and insert data into database only when you send the form.
Instead of:
   if(!empty($_POST["nome"]))
        $nome = $_POST["nome"];
    else
        $nome = null;

    if(!empty($_POST['cognome']))
        $cognome = $_POST['cognome'];
    else
        $cognome = null;

    $query = "INSERT INTO persons_comeunprodigio (nome, cognome)
                  VALUES ('$nome', '$cognome')";

    mysqli_query($db, $query) or die(mysqli_error());

you should have:
if (isset($_POST['nome'])) {

   if(!empty($_POST["nome"]))
        $nome = $_POST["nome"];
    else
        $nome = null;

    if(!empty($_POST['cognome']))
        $cognome = $_POST['cognome'];
    else
        $cognome = null;

    $query = "INSERT INTO persons_comeunprodigio (nome, cognome)
                  VALUES ('$nome', '$cognome')";

    mysqli_query($db, $query) or die(mysqli_error());
}

Now you need to fill in form and press submit button to insert data to database.
However you should use at least mysqli_real_escape_string but better choice would be prepared statements. At the moment your code is vulnerable to SQL Injection.


text:
Q: Local Sip profile and peer profile have the same domain, yet the call can still be made I'd just starting to get my feet wet with Sip, playing around with the SipDemo included as an SDK sample.
My app would only make outgoing calls to Twilio, and ideally there would be no "Sip Provider", my app just connects straight to Twilio. I wasn't sure if this would work, but it does and I am able to complete the call and talk to myself.
Register to my sip domain created on Twillio with the required credentials for access:
    public void onRegister(View view)
    {
        String username = "myusername";
        String domain = "mytestsip.sip.twilio.com";
        String password = "mypassword";

        SipProfile.Builder builder = null;
        try {
           builder = new SipProfile.Builder(username, domain);
            builder.setPassword(password);
            me = builder.build();
        } catch (ParseException e) {
        // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
            manager.open(me);
        } catch (SipException e) {
        // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

Initiate the call, using the Twilio Sip domain and bogus credentials:
    public void initiateCall() {
        try {
            SipAudioCall.Listener listener = new SipAudioCall.Listener() {
                @Override
                public void onCallEstablished(SipAudioCall call) {
                    call.startAudio();
                    call.setSpeakerMode(true);
                    call.toggleMute();
                    //updateStatus(call);
                }

                @Override
                public void onCallEnded(SipAudioCall call) {
                    //updateStatus("Ready.");
                }
            };
            SipProfile.Builder builder2 = new SipProfile.Builder("blah", "mytestsip.sip.twilio.com");
            builder2.setPassword("mehpass");
            SipProfile other = builder2.build();
            call = manager.makeAudioCall(me, other, listener, 30);
        }
        catch (Exception e) {
           ...
        }
    }

How does this work? Every example of a Sip client mentions needing a Sip Provider for the local profile. How am I able to use the same domain for the local and peer profiles? My goal is to learn how Sip works, so I am looking for a detailed high level explanation of what is happening here.
Note, I'm using a Sip client and not the Android Twilio SDK for a reason, so you don't need to mention that it's available.


text:
Q: Android json objects to array list in Parcelable class I don't know of the title is very accurate, but let me explain what I want.
I am having this long JSONObject (sadly it's not an array and I can't loop through it) with many other JSONObjects inside of it with similar elements (id, name, icon), and when I read through an element it writes its value in a separate class with implemented Parcelable.
Here is what my Parcelable class look like before I explain further:
public class ItemsInfo implements Parcelable {

    public int itemId;
    public String itemName, itemIcon;

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(itemName);
        dest.writeString(itemIcon);
        dest.writeInt(itemId);
    }

    public static final Parcelable.Creator<ItemsInfo > CREATOR = new Parcelable.Creator<ItemsInfo >() {

        @Override
        public ItemsInfo createFromParcel(Parcel source) {
            ItemsInfo ei = new ItemsInfo();
            ei.itemName = source.readString();
            ei.itemIcon = source.readString();
            ei.itemId = source.readInt();
            return ei;
        }

        @Override
        public ItemsInfo [] newArray(int size) {
            return new ItemsInfo [size];
        }
    };
}

what I want is everytime it reads through a JSONObject with the similar elements, to write them with an ArrayList in the String itemName, so later I can access a given item by only a index or something, and not to have to make separate strings and integers for every different item, like itemName1, itemName2, itemName3..... Is it possible?

A: You can use droidQuery to simplify JSON parsing. To convert your JSONObject to a Key-Value mapping, you can use this:
List<String> items = new ArrayList<String>();//this will contain your JSONObject strings
Map<String, ?> data = null;
try {
    JSONObject json;//this references your JSONObject
    data = $.map(json);

} catch (Throwable t) {
    Log.e("JSON", "Malformed JSON Object");
}

Then, to loop through each element, just do this:
if (data != null) {
    for (Map.Entry<String, ?> entry : data.entrySet()) {
        items.add(entry.value().toString());
    }
}

Now your List items is populated with the String representation of your JSONObejcts. Later, if you want to parse this JSON, just do:
int index = 2;//the index of the JSONObject you want
try {
    Map<String, ?> data = $.map(new JSONObject(items.get(2)));
    //now iterate the map
} catch (Throwable t) {
    t.printStackTrace();//something wrong with your JSON string
}


text:
Q: Onclick respeitar campo required Criei uma animação que aparece na tela e bloqueia os campos digitados pelo usuário enquanto a requisição é processada, diretamente no submit, conforme abaixo:
onclick="javascript:document.getElementById('blanket').style.display = 'block';document.getElementById('aguarde').style.display = 'block'; block();"

Aparecendo a imagem abaixo:

Acontece que se o usuário não preencher alguma informação, o formulário não é enviado e aparece o aviso devido ao required, mas a animação é executada de qualquer forma, e para voltar a página somente atualizando a mesma.
Existe alguma forma do onClick aguardar a validação dos campos required antes de executar essa animação?

A: Nesse caso o onclick será executado de qualquer forma. Para que essa validação de bloqueio seja ativada somente se os critérios forem preenchidos, coloque dentro o evento onsubmit e tire do onclick. Pode ser algo como:
document.getElementById('meu_form').addEventListener("submit", function(){
    document.getElementById('blanket').style.display = 'block';
    document.getElementById('aguarde').style.display = 'block';
    block();
});


text:
Q: React-Router-4 routing from another component Is it possible to route a component from another component?
So normally it would be done like below
<NavLink to="/link">link</NavLink>
<NavLink to="/anotherLink">link </NavLink>
<Switch>
    <Route exact path="/link" component={linkComponent}/>
    <Route path="/anotherLink" component={anotherLinkComponent}/>
</Switch>

but is it possible to have NavLink in one component which is loaded in the main component then route from the main component? So have NavLink in one component and have Route in the main component.
The Nav component
export default class Nav extends Component {
    render() {
        return (

                        <NavLink to="/" className="nav-title">
                            First Page
                        </NavLink>

                        <NavLink to="second-page" className="nav-title">
                            Second Page
                        </NavLink>

                        <NavLink to="third-page" className="nav-title">
                            Third Page
                        </NavLink>

        )
    }
}

The App component
import Nav from 'whateverthepath';

export default class App extends Component {

    render() {
        return (

                <Switch>
                    <Route exact path="/" component={Firstpage}/>
                    <Route path="/secondpage" component={Secondpage}/>

                </Switch>

        )
    }
}

All the appropriate React imports are done

A: That's definitely possible and your example should even work as is. The biggest thing you'll need to make sure of is that your <Route>s were rendered as some point. The reason your example works is because you're rendering  in the same render() method as your <Switch> statement. If you were to instead just render  without ever rendering the switch statement, then the NavLinks would take you somewhere that React Router hasn't been informed about. That's typically why your <Route>s are almost always in your most parent component, to make sure they're rendered.


text:
Q: AutoComplete for string parameter I have set up a testproject using NUnit and Selenium Webdriver of which you can find a shortened version below.
class ByHolder
{
    public readonly string name, path;
    public readonly Func<string, By> call;

    public ByHolder(string name, string path, Func<string, By> call)
    {
        this.name = name;
        this.path = path;
        this.call = call;
    }
}

class Page
{
    private readonly List<ByHolder> LocatorList = new List<ByHolder>();

    public Page()
    {
        SetUpList();
    }

    private void SetUpList()
    {
        AddLocator("Button0", "//button0", By.XPath);
        AddLocator("Button1", "button1", By.Id);
        ...

    }

    public By Get(string locatorName)
    {
        var holder = LocatorList.FirstOrDefault(p => p.name.Equals(locatorName));

        return holder?.call(holder.path);
    }

    public void AddLocator(string name, string path, Func<string, By> call)
    {
        LocatorList.Add(new ByHolder(name, path,call ));
    }

}

class PersonelDriver : IWebDriver
{
    IWebDriver driver = new FirefoxDriver();
    Page page = new Page();

    public void Click(string locatorName)
    {
        driver.FindElement(page.Get(locatorName)).Click();
    }

    ...
}

[TestFixture]
class PageTest
{
    private readonly PersonelDriver d = new PersonelDriver();

    [Test]
    public void ClickTest0()
    {
        d.Click("Button0");
    }
    [Test]
    public void ClickTest1()
    {
        d.Click("Button1");
    }

    ...
}

As you can hopefully see I tried implementing a shortened method with a minimum of variables to make longer testcases easier to read mainly for outsiders but also for me, for example.
d.Click("that");
d.EnterText("thisLocator","text");
d.WaitFor("somethingElse");
d.Click("this");

(After using Selenium for some time I find that things can become chaotic quite fast when repeatedly using the driver.FindElement... in the tests themselves.)
Even tough I'm happy with the shortened versions and readability, there is of course no autocomplete or check since i'm handling strings and not IWebElement objects or By references that have been named or put in a specific getter.
What I used to do was the following, but it just felt wrong:
class Locators
{
    public By GetButton()
    {
        return By.Id("button");
    }

    ...
}

I was wondering if there is a way to implement an autocomplete or some other check for the string values when adding for example d.Click("stringvalue");
Thank you in advance.


text:
Q: Using node app inside an express js server I have an Express js server endpoint with the following directory structure:

*

*app.js

*node_modules

*package-lock.json

*package.json

*mrz-detection

The mrz-detection directory, contains a node app which I would normally call from the command line like this node run/getMrz.js --file passport.jpg
My app.js looks like this
const { getMrz } = require('./mrz-detection');
const fs = require('fs');
const app = express()
const port = 3000
const bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '10mb', extended: true}));
var passportsArr = [];

app.post('/', function(req, res) {
    var passport = req.body;
    let buff = new Buffer(passport.data, 'base64');
    fs.writeFileSync('passport.png', buff);
    // send passport photo to mrz-detection app here
})

app.listen(port, () => console.log(`Mrz detection app listening at http://localhost:${port}`))

I need to call the mrz-detection app from my post route in the app.js
How would I do that?

A: There are two ways I can think of to do this:

*

*Call the other program command-line-style as explained by a commentor

*Refactor your code so that you can simply import a function from your other file and use it. I would recommend this more because it allows for complex parameters to potentially be passed without having to serialize and deserialize them in the command line.

A: You could you start the app as a child process:
https://nodejs.org/api/child_process.html
There are a few different 'child_process' functions for spawning child processes
execFile
spawn
fork
With fork, sending messages between parent and child works automatically
const fork = require('child_process').fork;
const child = fork('/path/to/app.js', ['optional', 'arguments']);

// message from child
child.on('message', (msg) => {
    console.log('message from child ' + msg);
}

// send message to child
child.send({hi:'hi from parent'});


text:
Q: Double quotes within string like triple double quote in Python Within Python I can use:
test = """My "cute" string"""

Where the double quotes get escaped. Is there a way that I can emulate this within Java without using escape slashes?

A: I don't see a reason not to escape ", but.. you can do:
System.out.println((char)34+"Some Text"+(char)34); //See ASCII table for more information

Output >> "Some Text"

A: If you don't need an escape, you should use string concatenation such as:
test = '"' + "My " + '"' + "cute" + '"' + " string" + '"';

Or using StringBuffer to append " character if you want.
Another way to do that is using String.format:
test = String.format("%1$sMy %1$scute%1$s string%1$s", '"');

Which replaces %1$s by your give "quote" later.

A: You have to use \u0022.
String str= "\u0022 MyString \u0022";

But this is quite similar to escaping " by \

A: No, there is no sensible way of doing that in Java. Judging from the other answers, I'd say that escaping the quotes is the path of least pain.
It is possible in Groovy (which also runs on the Java VM), though, using either single quotes:
`'some "String"'`

or the so-called here documents:
""" Everything here can be "quoted"
/"""

But Java has no such mechanism.

A: Beginning with Java 13, Java now supports triple-quotes! See JEP 355 for details.


text:
Q: xargs cat with conditional statement I am dealing with the unix xargs cat, i am not really into unix and at the moment i have a cat command like this:
    ls *ex_vs*ex.txt | xargs cat > ex.txt

    ls *en_vs*en.txt | xargs cat > en.txt

What i want to do now is make a statement that has this meaning:
    ls *ex_vs*en.txt **OR** *en_vs*ex.txt | xargs cat > en_ex.txt

so my question is basically how to put a conditional statement (or) for catting files together.
Any suggestion will be very much appreciated.
Best
Alfredo

A: ls can take multiples arguments :
$ ls --help
Usage: ls [OPTION]... [FILE]...

So you can add both file selectors after the ls :
ls *ex_vs*en.txt *en_vs*ex.txt | xargs cat > en_ex.txt

You can also use :
 cat *ex_vs*en.txt *en_vs*ex.txt > en_ex.txt


text:
Q: Firebase storage is locked my Firebase storage is locked.
"Unable to upload files because the project limit has been exceeded"
here where the limit has been exceeded:

does it unlock itself or do I have to do something?


text:
Q: Proof of Muirhead's inequality I have seen Muirhead's inequality being stated and used in many, many places, but I haven't ever seen a proof. Does someone have a reference or simple proof for this result?

A: For non-negative integer powers we can use an induction and we can get a sum of squares.
For non-negative real powers we can use doubly stochastic matrices. See about this:
A.W.Marshal, I.Olkin "Inequalities: Theory of Majorization and Its Applicaitions",
Mathematics in science and engineering, Volume 143, 1979.


text:
Q: Can't download image from eucalyptus cloud I'm newbie in using eucalyptus. I need to download modify a prepackaged image. I use command
euca-download-bundle

to download it. It has a required parameter - bucket.
I want to download this image.
mi-E07C107C
image-store-1297468153/image.manifest.xml
eki-F6BE10FF
eri-0B3C116B
but I always get error -

Unable to get bucket

Here are the commands I tried:
euca-download-bundle -b image-store-1297468153
euca$ euca-download-bundle -b /var/lib/eucalyptus/bukkits/image-store-1297468153

A: you may not be able to download the bundle if you are not the same user who uploaded it. For example, if admin uploaded that bundle, but the user aleksey is the one trying to download it, that would be the error you get.


text:
Q: Copy Observable Collection to another using reflection I'm attempting to create a method which will allow me to copy observable collection to another using reflection. The observable collection would be part of the DTO which i am copying, and hence i need to uniquely identify whether its an Observable Collection /List.
Thank you..
Rithesh

A: Copying collection to list can be done with Enumerable.ToList extension method.
If you want to detect type via reflection - Type.IsGenericType and Type.GetGenericTypeDefinition will let you detect if type of given object is ObservableCollection<T>. Than Type.GetGenericArguments will give the exact type. At that point you should be able to create your own collection of element of that type and copy elements from original collection into new one.


text:
Q: Android browser doesn't use the Cell-ID to geolocate with HTML5 API (only GPS) I'm doing a Wep App using the HTML5 Geolocation API.
I'm using the typical W3C code given here http://dev.w3.org/geo/api/spec-source.html with the getCurrentPosition method.
On the Android browser it only works if GPS is enabled and gets the position.
If it doesn't (indoors for example), the API returns the timeout error. Idem in a webview (with the correct permissions). It means that it does not use the other sources of geolocation.
On the contrary on Windows Mobile or with Opera on the Android device if the GPS can't reach the position it returns the Cell-ID source position (Relay Antenna based source).
How can I make it works with the Android browser ?
Thanks for your help.
Android version I'm using : 2.2.1.

A: Actually it was coming from the permissions. Even if it specified in the Application manifest you have to allow the location using Cell-ID on the mobile : go to the mobile Parameters/ Location and security then check "Use wireless networks" (it includes the ID Cell). Unfortunately by doing this you allow Google to collect your location data.
It's strange that it was working anyway on Opera browser.


text:
Q: Catch multiple xhr responses on multiple page.click (without page reload or change)         page.on('response', response => {
           // allow only XHR
           if ('xhr' !== response.request().resourceType()){

               return ;
           }

           console.log(response.url());
        });

    await page.click('span#first');
    await page.click('span#second');
    await page.click('span#third');

As result of the example above, just ajax requests corresponding to the span#first are caught by page.on . The span#second and span#third are not caught. Usage of page.waitForNavigation seems have no effect.


text:
Q: ScrollView not Scrolling - Android I am unable to scroll my scrollview. It has a textView, an imageview and few linear layouts inside of it. When I replace the imageview and linear layouts with textview it is working. Here is my code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true"
        android:orientation="vertical"
        android:scrollbars="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Drop Text Down"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="555dp"
            android:src="@drawable/ic_launcher" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/ln"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:background="#000000"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/TextView06"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/TextView05"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/TextView04"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/TextView03"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/TextView02"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/TextView01"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" />
            </LinearLayout>

        </LinearLayout>
    </LinearLayout>
</ScrollView>

</LinearLayout>

A: Your ScrollView child needs to have its height as wrap_content :
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:animateLayoutChanges="true"
    android:orientation="vertical"
    android:scrollbars="vertical" >

    ...
    ...
</LinearLayout>
</ScrollView>

A: I was able to solve it by adding (android:windowSoftInputMode="adjustResize|stateHidden") in the activity manifest, like below
<activity
            android:name=".ui.main.MainActivity"
            android:label="@string/app_name"
            android:windowSoftInputMode="adjustResize|stateHidden"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar">
        </activity>

A: Maybe i'm too late for this, but the only method that helped me fix the scrollview not scrolling after hours of searching and trial and error method is, setting scrollview's height to 0dp.
Here's an example xml code for reference.
<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

*

*The top constraint layout having "match_parent" will fit the screen.

*The Scroll View inside having "0dp" adjusts the height to the content inside and creates a scrollable view when the content goes beyond the top/ parent constraint layout.

*The inner most constraint layout (child of scroll view) will contain the views and actual contents.

A: Put an empty view with fixed height
<View
                android:layout_width="match_parent"
                android:layout_height="50dp" />

as your last item in the linear layout which is a child of scroll view..
This is just a trick, I don't know the logic. Maybe, in the presence of bottom navigation bar, the scrollview behaves like that. So if we add another view with height that matches the bottom navigation bar's height(40-50) it performs well.

A: You should set the height of LinearLayout (child of Scrollview) to wrap_content.
When the child is taller than the ScrollView, then android:fillViewport="true"  attribute has no effect.

A: The child view of a ScrollView should be set to wrap_content. If you set it to match_parent, it will fill the area of the ScrollView and never scroll, because it won't be larger than the ScrollView.
Try changing the child LinearLayout layout_height to either wrap_content or a specific size (in dp) instead of match_parent.

A: If you set the height of the Linear layout inside the scrollview to match_parent, there is nothing to scroll if the height is the same as the scrollview.
You have to set it to wrap-content. This way the height of the LinearLayout will be greater than the scrollview, and you will then be able to scroll.
Corect Code
<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:animateLayoutChanges="true"
        android:orientation="vertical"
        android:scrollbars="vertical" >

Aditional Note:
You also cannot use weight and weightsum inside a scrollview. Doing so will make the scrollview unscrollable.

A: use Table Layout instead of linear layout something like this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:fadeScrollbars="false" android:padding="6dip">
<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1"
    >
   //your stuff
</TableLayout>
</ScrollView>

A: <ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >

Remove android:fillViewport="true" from above element