text:
Q: Validação de formulário com DataAnnotations em MVC Estou tentando fazer a validação de formulários com uso do DataAnnotation, tentei direto na model ou na minha viewmodel e nenhuma delas funciona.
View Model:
public class CieloViewModelTransacaoPartial
{
    [Required(ErrorMessage = "Token é obrigatório")]
    public string Token { get; internal set; }

    [Required(ErrorMessage = "IDC é obrigatório")]
    [Display(Name = "IDC")]
    public int ClienteId { get; set; }

    [Required(ErrorMessage = "Valor a ser cobrado é obrigatório")]
    [Range(1, 50000)]
    public decimal Valor { get; set; }

    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
    [Required(ErrorMessage = "Data de Refêrencia é obrigatórico")]
    [Display(Name = "Data de Refêrencia")]
    [DataType(DataType.Date)]
    public DateTime DataRef { get; set; }

    public int Tipo { get; set; } //1 config, 2mensal, 3 outros, 4 diff. mensal
}

View Resumida:
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

                @Html.LabelFor(model => model.Token, htmlAttributes: new { @class = "control-label col-md-2" })

                    @Html.EditorFor(model => model.Token, new { htmlAttributes = new { @class = "form-control" } })

                    @Html.ValidationMessageFor(model => model.Token, "", new { @class = "text-danger" })

                @Html.LabelFor(model => model.ClienteId, htmlAttributes: new { @class = "control-label col-md-2" })

                    @Html.EditorFor(model => model.ClienteId, new { htmlAttributes = new { @class = "form-control form-peq" } })

                    @Html.ValidationMessageFor(model => model.ClienteId, "", new { @class = "text-danger" })
                    Carregar cliente

                <input type="submit" value="Cadastrar" class="btn btn-danger " />

}

sendo que minha _Layout já chama os javascript abaixo:

Porém ele está postando sem validar.
Não da nenhum erro no console ou qualquer erro.
Quero validar no browser com o DataAnnotation, o que falta?
update:
Código da _Layout

    @{ Html.RenderPartial("_Header", RenderSection("topright", false)); }
    @{ Html.RenderPartial("_Aside"); }

        @{ Html.Partial("_Ribbon"); }
        @RenderBody()

    @if (Request.IsAuthenticated)
    {
        Html.RenderPartial("_Footer");
    }

    @{ Html.RenderPartial("_Scripts"); }
     @RenderSection("pagespecific", false)

e a page _Scripts.cshtml

@Scripts.Render("~/scripts/smartadmin")

@if (@Model is HelperResult)
{
    @Model
}

A: O erro era a falta de 2 key no web.config
  <appSettings>
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>

Conforme descrito em detalhes http://www.macoratti.net/12/07/mvc_valid1.htm


text:
Q: Identify the original printer I am enumerating printers connected in the PC. I done it using C# System.Printing namespace.
It works well. But mostly it shows software printers like Microsoft XPS Document writer,Microsoft Fax etc. I would like to know is it possible to remove these ssoftware printers from enumeration. The code I have done is show below :
PrintQueue printQueue = null;

LocalPrintServer localPrintServer = new LocalPrintServer();

// Retrieving collection of local printer on user machine
PrintQueueCollection localPrinterCollection =
    localPrintServer.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local,
                                            EnumeratedPrintQueueTypes.Connections });

System.Collections.IEnumerator localPrinterEnumerator =
    localPrinterCollection.GetEnumerator();

while (localPrinterEnumerator.MoveNext())
{
    // Get PrintQueue from first available printer
    printQueue = (PrintQueue)localPrinterEnumerator.Current;

    if (!printQueue.IsOffline)
    {
        MessageBox.Show(printQueue.FullName.ToString());
        string s = "Printer found " + printQueue.FullName.ToString();
        listBox1.Items.Add(s);
    }
    else
    {
        // No printer exist, return null PrintTicket
        // return null;
    }
}

A: The only way I found is to compare the name of desired printer with the one we are getting.

A: Few observations:

*

*In the Properties window the Device Settings Page is available ONLY for the Real Printers and NOT for the Virtual Printers. And most of these values are available in printQueue.UserPrintTicket property

*printQueue.QueuePort.Name contains an IP address appended with or without the port name. ex: "20.120.12.22_1" or "20.120.12.22" for Real Printers

A: You can use the Print Spooler API to manage printers and printjobs. Specially the EnumPrinters function might be useful for you. You can grab the c# wrapper from Pinvoke.net

A: The key to distinguishing a real printer from a virtual printer is the port the printer is using.  Real printers use hardware ports such as LPT1: or USB ports.  Virtual printers use software-driven ports.
The complication will be network printers.  It won't be easy determining if a network printer is using a hardware port.
I know this isn't a great answer but you've posed a very difficult question.  I hope it gets your started in the right direction.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to Send Base64 Encoded Image From Rails App and Display Image I'm trying to display images hosted in the public directory of my rails app on a different website.  I basically don't want a user to be able to type the src of the image tag into a browser and access the uri for my app where the image can be found.
After doing some digging, I determined that the way to achieve this may be to send the image as base64 encoded data, and then rebuild the image from that data on the website receiving the ajax response.  Please let me know if I am mistaken.
I've successfully sent the base64 data from my rails app to my website through ajax, but I'm having difficulty building an image from the data.
This is my rails code:
def send_image(blank=nil)
  require 'base64'
  @image= "#{Rails.root}/public/test.jpg"
  @imageEncoded = Base64.encode64(@image)

send_data @imageEncoded, :type => 'text/plain', disposition: "inline", :x_sendfile=> true

end

This is the ajax response:
    L2FwcC9wdWJsaWMvcHVwcHkuanBn

This is the code to build the image from the ajax response:
    $("#picture").attr("src","data:image/jpg;base64," + data);

I think I may be misunderstanding how this all works.  When I get back the endcoded data and insert it into the src, an image is not displayed.  It just shows a broken image icon.
If I send just the image file by itself (without encoding the data), the picture shows up in the ajax response when I look in the Network tab of the developer tools, but I cannot use that data to build an image.  The data response looks like this:
    ���� :ExifMM*  � s � � � ( 1 � 2 ҇i � -��' -��' Adobe Photoshop CS5 Macintosh2015:05:20 15:25:20 � 0221� ��� �� � n v ( ~ �H H ����Adobe_CM �� Adobed� ���        �� x� " �� �� ? 3 ! 1 AQa "q�2 ���B#$ R�b34r��C %�S���cs5 ���&D�TdE£t6 �U�e���u��F'���������������Vfv��������7GWgw�������� 5 !1 AQaq" 2�� ��B#�R��3$b�r��CS cs4�% ��� &5��D�T� dEU6te����u��F���������������Vfv��������'7GWgw������� ?�T�I%)$�IJI$�R�I$���I%)$�IJI$�R�I$���I%)$�IO���T�I%)$�IJI #&� .�dž�J��ɶ��0?ю Ys� o.̘�J~ �z�Ugk �Ø� iU~u�: ��* >� � hL�^� HЎ$*Y9��;��ѵ ��_7I���� �� [� � � � � HI ��K�D�� c ӈ�uQ� � a��;C���;\�} s V%e��)��lm���K r_�-�\��i�IT�/�sa�A�Q�z��1*�r�@ wk�H ��!�� ~��� �O�DN ���7 I$�B�I$�����T�I%) /)��op�th�(� ���2KX k=�?�Qg�����@Ɇ s��԰ �� k��* u�%���\�W��Oc��� ϱ�Ǭ�y��=�� i?�z1�� A�+�<��Vvo� Q��Z� / �c� �����Of�+�5�hy2����; � ���:Ů=c���W]m kˁ��m{v��Ќx�t�e d[���7# ��6ڈp�S � � �Nr�!� N��X8�{�w=�p ��#��+��u�>Ө�S���� ��n����i� � �� B�C�5�'� y ��t�t��� kH �.�^�'� ���/ � ������X���-��-�i>+3�P�.nѸ q� � ��T*$�uu��{���;Lhc�7} ��ަ����X���㸏 �n�_K�ߣi�q �

Can someone let me know where I might be going wrong here?  Do I have to send the image, and then base64 encode it and add it to the src of the image tag?  Am I failing to understand how encoding works?

RESPONSE TO COMMENTS
So the code that I would have to write looks like this?
var request = new XMLHttpRequest();
request.responseType = "blob";
request.open("GET", railsAppEndpoint);

*This is where I'm unclear as to how to proceed based on your comment.  I've never used fetch before.  I looked up some documentation on fetch and it looks as though the first argument that you are supposed to pass into fetch is a url.  Are you saying that I have to open up an XMLHttpRequest, and then also use fetch?  Or is fetch supposed to replace the XMLHttpRequest.
I'm just guessing at the correct syntax here:
fetch()
 .then(
     response => response.blob()
  )

*Something seems missing here.
**At this point I don't get how to obtain the Blob url.  I know how to set the src of an image, but I need to complete the other steps first.


text:
Q: Crypto, hashes and password questions, total noob? I've read several stackoverflow posts about this topic, particularly this one:
Secure hash and salt for PHP passwords
but I still have a few questions, I need some clarification, please let me know if the following statements are true and explain your comments:

*

*If someone has access to your database/data, then they would still have to figure out your hashing algorithm and your data would still be somewhat secure, depending on your algorithm? All they would have is the hash and the salt.

*If someone has access to your database/data and your source code, then it seems like no matter what your do, your hashing algorithm can be reversed engineered, the only thing you would have on your side would be how complex and time consuming your algorithm is?

*It seems like the weakest link is: how secure your own systems are and who has access to it?

Lasse V. Karlsen ... brings up a good point, if your data is compromised then game over ... my follow up question is: what types of attacks are these hashes trying to protect against? I've read about rainbow table and dictionary attacks (brute force), but how are these attacks administered?

A: The security of cryptographic algorithms is always in their secret input. Reasonable cryptanalysis is based on an assumption that any attacker knows what algorithm you use. Good cryptographic hashes are non-invertible and collision resistant. This means that there's still a lot of work to do going from a hash to the value that generated it, regardless of whether you know the algorithm applied.

*

*If you used a secure hash, access to the hash, salt, and algorithm will still leave a lot of work for a would-be attacker.

*Yes, a secure hash puts a very hard to invert algorithm on your side. Note that this inversion is not 'reverse-engineering'

*The weak link is probably the processes and procedures that get those password hashes into the database. There are all sorts of ways to screw up and store sensitive data in the clear.

As I noted in a comment, there are attacks that these measures defend against. First, knowing the password may lead to authorization to do things beyond what the contents of the database suggest. Second, those passwords may be used elsewhere, and you expose your users to risk by revealing their passwords as a result of a break-in. Third, with hashing, an insider can't exploit read-only access to the database (subject to less auditing, etc.) to impersonate a user.
Dictionaries and rainbow tables are techniques for accelerating hash inversion.

A: You question is about using passwords as an authentication mechanism and how to securely store these passwords in a database using a hash. As you probably already know the goal is to be able to verify passwords without storing these passwords i clear text in the database. In this context let me try to answer each of your questions:

If someone has access to your database/data, then they would still have to figure out your hashing algorithm and your data would still be somewhat secure, depending on your algorithm? All they would have is the hash and the salt.

The basic idea of hashing passwords is that the attacker has knowledge of the hashing algorithm and has access to both the hash and the salt. By selecting a cryptographic strong hash function and a suitable salt value that is different for each password the computational effort required to guess the password is so high that the cost exceeds the possible gain the attacker can get from guessing the password. So to answer your question, hiding the hash function does not improve the security.

If someone has access to your database/data and your source code, then it seems like no matter what your do, your hashing algorithm can be reversed engineered, the only thing you would have on your side would be how complex and time consuming your algorithm is?

You should always use a well-known (and suitably strong) hashing algorithm, and reverse engineering this algorithm is not meaningful as there is nothing hidden in your code. If you didn't mean reverse engineer but actually reverse then, yes, the passwords are protected by the complexity of reversing the hash function (or guessing a password that matches a hash value). Good hash functions makes this very hard.

It seems like the weakest link is: how secure your own systems are and who has access to it?

In general this is true, but when it comes to securing passwords by storing them as hashes you should still assume that the attacker has full access to the hashes and design your system accordingly by choosing an appropriate hash function and using salts.

What types of attacks are these hashes trying to protect against? I've read about rainbow table and dictionary attacks (brute force), but how are these attacks administered?

The basic attack that password hashing protects against is when the attacker gets access to your database. The clear text password cannot be read from the database and the password is protected.
A more sophisticated attacker can generate a list of possible passwords and compute the hash using the same algorithm as you. He can then compare the computed hash to the stored hash and if he finds a match he has a valid password. This is a brute force attack and it is generally assumed that the attacker has "offline" access to your database. By requiring the users to use long and complex passwords the effort required to "brute force" a password is significantly increased.
When the attacker wants to attack not one password, but all the passwords in the database a large table of passwords and hash value pairs can be precomputed and further improved by using what is called hash chains. Rainbow tables is an application of this idea and can be used to brute force many passwords simultaneously without increasing the effort significantly. However, if a unique salt is used to compute the hash for each password a precomputed table becomes useless as it is different for each salt and cannot be reused.
To sum it up: Security by obscurity is not a good strategy for protecting sensitive information and modern cryptography allows you to secure information without having to resort to obscurity.

A:
what types of attacks are these hashes trying to protect against?

That type when someone gets your password from poorly secured site, reverses it, and then tries to access your bank/PayPal/etc. account. It happens all the time, and many people are still using same (and often weak) passwords everywhere.
As a side note, from what I've read, key derivation functions (PBKDF2/scrypt/bcrypt) are considered better/more secure (#1, #2) than plain salted SHA-1/SHA-2 hashes by crypto people.

A: If you have just a hash, no salt, then once they know your data (and algorithm) they can get your password via a rainbow table lookup. If you have a hash and a salt, they can get your password by burning a lot of CPU cycles and building a rainbow table.
If your salt is the same for all your data, they only need to burn a lot of CPU cycles once to build the table and then they have all the passwords. If your salt is not always the same, they need to burn through the CPU cycles to make a unique rainbow table for each record.
If the salt is long enough, the CPU cycles they need become very cost-prohibitive.
If you know your data security is breached, of course, you need to reset all the passwords immediately anyway, because as far as you know the attacker is willing to spend that time.

A:
If someone has access to your database/data, then they would still
  have to figure out your hashing
  algorithm and your data would still be
  somewhat secure, depending on your
  algorithm? All they would have is the
  hash and the salt.

This might be all a really dedicated opponent would need.  Much of this answer depends on how valuable the data is, which would tell you how motivated the opponent is.  Credit card numbers are going to be extremely valuable, and criminal attackers seem to have plenty of time and accomplices to do their dirty work.  Some bad guys have been known to farm out key decryption tasks to botnets!

If someone has access to your database/data and your source code,
  then it seems like no matter what your
  do, your hashing algorithm can be
  reversed engineered, the only thing
  you would have on your side would be
  how complex and time consuming your
  algorithm is?

If they have access to your source and all the data, the question is going to be "how did you load your key into the memory of the server in the first place?"  If it's embedded in the data or in the program code, it's game over and you've lost.  If it was hand-keyed by an operator at the machine's boot time, it should be as secure as your trust in your operator.  If it is stored in an HSM*, it should still be secure.
And if they have root-level authority access to your running machine, then they can probably trigger and recover a memory dump that will reveal the secret key.

It seems like the weakest link is: how
  secure your own systems are and who
  has access to it?

This is true.  But there are alternatives that help improve security.
For bank-like protection, the kind that passes security and industry audits, it's recommended that you use a *Hardware Security Module (HSM) to perform key storage and encryption/decryption functions.  The commercial strength HSMs we're looking at cost 10s of thousands of dollars or more each, depending on capacity.  But I have seen hardware encryption cards that plug into a PCI slot that cost substantially less.
The idea behind an HSM is that the encryption happens on a secure, hardened platform that nobody has access to without the secret keys.  Most of them have cabinets with intrusion detection switches, trip wires, epoxied chips, and memory that will self-destruct if tampered with.  Not even the legitimate owner or the factory should be able to recover the database key from an HSM without the set of authorized crypto keys (usually carried on smart cards.)
For a very small installation, an HSM can be as simple as a smart card. Smart cards aren't high performance encryption devices, though, so you can't pump more than about one decryption transaction per second through them.  Systems using smart cards usually just store the root key, then decrypt the working database key on the smart card and send it back to the database accessing system.  These will still yield the working database key if the attacker can access running memory, or if the attacker can sniff the USB traffic to and from the smart card.
And I have no experience getting TPM chips to work (yet), but theoretically they can be used to securely store keys on a machine.  Again, it is still no defense against an attacker taking a memory dump while the key is loaded in memory, but they would prevent a stolen hard drive containing code and data from revealing its secrets.

A: A hash cannot be reversed. Conceptually, think of a hash as taking the value to be hashed as the seed to a random number generator, then taking the 500th number that it generates. This is a repeatable process, but it is not a reversible process.
If you store a hashed password in your database, when your user logs in, you take his password from the input to the login page, you apply the same hash to it, and then you compare the result of that operation to what you have stored in the database. If they match, the user typed the right password. (Or, in theory, they could have typed something that happens to hash to the same value, but in practice, you can completely ignore this.)
The purpose of the salt is so that even if users have the same password, you can't tell, and also lots of other things which are equivalent to this idea. If the user's password is "secret", and the salt is "abc", then instead of making a hash of "secret", you hash "secretabc" and store the results of that in your database. You also store the salt, but this is perfectly safe to store -- you can't figure out any information about the password from it.
The only reason to safeguard the hashed passwords and salt is that if an attacker has a copy of it, he can test passwords offline on his own machine, rather than repeatedly trying to log in to your server, which you would probably lock him out after three attempts or something like that. Even if you don't lock him out, it's much faster to test locally than to wait for the network round-trip.

A: ( OP )

brings up a good point, if your data
  is compromised then game over ... my
  follow up question is: what types of
  attacks are these hashes trying to
  protect against? I've read about
  rainbow table and dictionary attacks
  (brute force), but how are these
  attacks administered

( discussion )
It's not a game, except to the attacker. Research these terms:

*

*Sarbanes-Oxley

*Gramm-Leach-Bliley Act (GLBA)

*HIPAA

*Digital Millenium Copyright Act (DMCA)

*PATRIOT Act

Then tell us ( as thought provocation for you ) how do we protect against whom? For one thing, it is the efforts of innocents vis-a-vis intruders - and for another it is data-recovery if part of the system fails.
It is an interesting experiment that the original intent of tcp/ip  and so on is advertised as being a weapon of war, survivability under attacks. Okay, so passwords are hashed - no one can recover them ...
Which, duh, includes the owner-operator of the system.
So you build a robust record locking tool that implements key controls, then political pressures force the use of brand-x tools.
You can read Federal Information Security Management Act (FISMA) and by the time you have read it some governmental entity somewhere will have had an entire disk either stolen or compromised.
How would you protect that disk if it was your personal identity information on that disk.
I can tell you from the caliber of Martin Liversage and jadeters they will be paying attention.

A: When hashing a password, it is one way.  So it is very difficult to get the password even if you have the salt, source and alot of cpu cyles to burn.

A: Here are my thoughts to your points:

*

*If people have access to your database you have bigger security concerns than your hash algorithm and salt phrase.  Hashes are somewhat secure, however there are problems such as hash collisions and hash lookups.

*Hashes are one-way, so unless they can guess the input there is no way to reverse out the original text even with the algorithm and salt; hence the name one-way hash.

*Security is about obscurity and layers of defense.  If you layer your defenses and make determining what those defenses are you stand a much better chance of staving off an attack than if you relied on a single approach to security such as password hashing and running OS/network hardware updates.  Throw in some curveballs like obsfucation of the web server platform and clear boundaries between the prod web and database environments.  Layers and hiding implementation details buy you valuable time.


text:
Q: Chrome displaying incorrect SVG natural size I have a strange issue whereby periodically my SVGs are rendering really small in Google Chrome (Version 65), but only on Windows 10. Here's a screenshot of the image beside the word sum:

And what it really should look like:

When I hover over the tiny image in dev tools, this is what I see:

Which, obviously is not 3x6 pixels! In addition to this, the issue only seems to present itself when the image is embedded inside specific  elements. I have rendered the SVG to PNG and this works fine, the size is reported as expected. I am confident there is no CSS in play here, as this works fine in the same version of Google Chrome on Mac & Chromebook.
Replacing the  with an <object> works as expected, but I would consider this the nuclear option - I don't want to go down this route for one specific edge-case.
Here's the code for the image:

.my-class
max-height: 30px;
max-width: none;
margin: 0;

sum.svg
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="3.355ex" height="6.176ex" style="vertical-align: -3.005ex;" viewBox="0 -1365.4 1444.5 2659.1" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg">
<defs>
<path stroke-width="1" id="E1-MJSZ2-2211" d="M60 948Q63 950 665 950H1267L1325 815Q1384 677 1388 669H1348L1341 683Q1320 724 1285 761Q1235 809 1174 838T1033 881T882 898T699 902H574H543H251L259 891Q722 258 724 252Q725 250 724 246Q721 243 460 -56L196 -356Q196 -357 407 -357Q459 -357 548 -357T676 -358Q812 -358 896 -353T1063 -332T1204 -283T1307 -196Q1328 -170 1348 -124H1388Q1388 -125 1381 -145T1356 -210T1325 -294L1267 -449L666 -450Q64 -450 61 -448Q55 -446 55 -439Q55 -437 57 -433L590 177Q590 178 557 222T452 366T322 544L56 909L55 924Q55 945 60 948Z"></path>
<path stroke-width="1" id="E1-MJMATHI-6E" d="M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z"></path>
<path stroke-width="1" id="E1-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"></path>
</defs>
<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">
 <use xlink:href="#E1-MJSZ2-2211" x="0" y="0"></use>
<g transform="translate(234,-1051)">
 <use transform="scale(0.707)" xlink:href="#E1-MJMATHI-6E" x="0" y="0"></use>
 <use transform="scale(0.707)" xlink:href="#E1-MJMAIN-3D" x="600" y="0"></use>
</g>
</g>
</svg>

And for completeness sake, this is the  element in which I'm seeing the issue:


text:
Q: Calculate the volume swept out when the top half of the elliptical region bounded by... Problem
Work the problem by substituting a=4 and b=3, then solve usin direct integration.
Not sure where to get started here. Some guidance would be appreciated. Pretty sure this just requires creating the equation and just straight solving but I can't seem to figure it out.

A: Hint: Use the distance from the x-axis of the ellipse as the radius of a circle.


text:
Q: React: getting TypeError when trying to return JSON response from fetch API call I have Node server and REST API, which returns contact info in JSON format, and now I'm trying to display that information to user when user clicks certain menu button. My server works just fine but when trying to display the data I'm getting error message:
TypeError: Cannot read property 'state' of undefined

Here is my React code:
import './App.css';
import MenuItems from './components/Navbar/MenuItems';
import ReactDOM from 'react-dom'
import React, { useState } from 'react'

function App() {

  const [selectedItem, setSelectedItem, contacts] = useState();
  getContactInfo();
  return (

My website

        {MenuItems.MenuItems.map((item, index) => (

 setSelectedItem(item.title)}
          style={{cursor: "pointer"}}>{item.title}

        ))}
        {selectedItem && (

{selectedItem}

        )}
        {selectedItem == 'Contact_us' &&

          {this.state.contacts.map(contacts =>

 {contacts.phone}
)}

        }

  );
}
function getContactInfo() {
    fetch('http://127.0.0.1:5000/listUsers')
    .then(res => res.json())
    .then(contacts => this.setState({contacts}))
    .catch(console.log)
}

export default App;

Basically I'm trying fetch the information from server before user clicks menu button and display it after menu button has been clicked. I'm doing this to avoid "undefined" exceptions but it doesn't seem to help. Any advise is highly appreciated.

A: UseState has the syntax:
const [state, setState] = useState(initialState);

(https://reactjs.org/docs/hooks-state.html)
You need a seperate state for your contacts:
const [contacts, setContacts] = useState({})

Then use setContact in your getContactInfo() function to set the contacts state:
function getContactInfo() {
    fetch('http://127.0.0.1:5000/listUsers')
    .then(res => res.json())
    .then(contacts => setContacts(contacts))
    .catch(console.log)
}

Also, the getContactInfo() function needs to be inside your App, it's currently out of scope.


text: Q: Have a self extract archive extract to specific folder How can I create a self extracting archive that will extract the contents into a specific folder? Any program or method is acceptable on windows.


text:
Q: Docker is unable to delete a directory when building images The issue is similar to Docker is unable to delete a file when building images
However, the route cause isn't the same, because d_type is enabled in my case.
Here is the Dockerfile
FROM arm64v8/ubuntu:latest

RUN export DEBIAN_FRONTEND='noninteractive' && \
    rm -rf /var/lib/apt/lists/* /tmp/* /usr/share/doc

When trying to build the image
docker build -t arm64v8-ubuntu-test .

I get the following error
Sending build context to Docker daemon  3.584kB
Step 1/2 : FROM arm64v8/ubuntu:latest
 ---> 499b06aa549b
Step 2/2 : RUN export DEBIAN_FRONTEND='noninteractive' &&     rm -rf /var/lib/apt/lists/* /tmp/* /usr/share/doc
 ---> Running in 5ff328ef5a57
rm: cannot remove '/usr/share/doc/sed': Directory not empty
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty
rm: cannot remove '/usr/share/doc/mawk': Directory not empty
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty
rm: cannot remove '/usr/share/doc/apt': Directory not empty
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty
rm: cannot remove '/usr/share/doc/passwd': Directory not empty
rm: cannot remove '/usr/share/doc/mount': Directory not empty
rm: cannot remove '/usr/share/doc/procps': Directory not empty
The command '/bin/sh -c export DEBIAN_FRONTEND='noninteractive' &&     rm -rf /var/lib/apt/lists/* /tmp/* /usr/share/doc' returned a non-zero code: 1

My docker info is
$ docker info
Containers: 7
 Running: 1
 Paused: 0
 Stopped: 6
Images: 95
Server Version: 17.10.0-ce
Storage Driver: overlay
 Backing Filesystem: extfs
 Supports d_type: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
 NodeID: mjm8vu1ixmw1ls25dk7gomiva
 Is Manager: true
 ClusterID: lnspgxtrca8d4lm3kfv7zbz77
 Managers: 3
 Nodes: 3
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 10.0.4.71
 Manager Addresses:
  10.0.4.71:2377
  10.0.4.72:2377
  10.0.4.73:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 0351df1c5a66838d0c392b4ac4cf9450de844e2d
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.14.79-27-ARCH
Operating System: Arch Linux ARM
OSType: linux
Architecture: aarch64
CPUs: 4
Total Memory: 1.928GiB
Name: alarm-docker-manager-host
ID: Y5ZZ:5G3O:KIE2:MSQX:7MBB:XWOZ:CYLL:2SSY:GTMB:YCBG:4TTT:EJVN
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Manually running the container and trying to execute the command has the same result, for example
$ docker run --rm -it arm64v8/ubuntu:latest bash
root@87a3ea8fecdd:~# rm -rf /var/lib/apt/lists/* /tmp/* /usr/share/doc
rm: cannot remove '/usr/share/doc/sed': Directory not empty
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty
rm: cannot remove '/usr/share/doc/mawk': Directory not empty
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty
rm: cannot remove '/usr/share/doc/apt': Directory not empty
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty
rm: cannot remove '/usr/share/doc/passwd': Directory not empty
rm: cannot remove '/usr/share/doc/mount': Directory not empty
rm: cannot remove '/usr/share/doc/procps': Directory not empty

Also, the permissions seem fine, the directory is there, and is not being used by another process
root@87a3ea8fecdd:/# ls -lah /
total 68K
drwxr-xr-x   1 root root 4.0K Oct 19 06:43 .
drwxr-xr-x   1 root root 4.0K Oct 19 06:43 ..
-rwxr-xr-x   1 root root    0 Oct 19 06:43 .dockerenv
drwxr-xr-x   2 root root 4.0K Oct 19 05:39 bin
drwxr-xr-x   2 root root 4.0K Apr 12  2016 boot
drwxr-xr-x   5 root root  360 Oct 19 06:44 dev
drwxr-xr-x   1 root root 4.0K Oct 19 06:43 etc
drwxr-xr-x   2 root root 4.0K Apr 12  2016 home
drwxr-xr-x   8 root root 4.0K Oct 19 05:39 lib
drwxr-xr-x   2 root root 4.0K Oct  6 01:43 media
drwxr-xr-x   2 root root 4.0K Oct  6 01:43 mnt
drwxr-xr-x   2 root root 4.0K Oct  6 01:43 opt
dr-xr-xr-x 143 root root    0 Oct 19 06:43 proc
drwx------   2 root root 4.0K Oct 19 05:39 root
drwxr-xr-x   5 root root 4.0K Oct  6 01:44 run
drwxr-xr-x   2 root root 4.0K Oct 19 05:39 sbin
drwxr-xr-x   2 root root 4.0K Oct  6 01:43 srv
dr-xr-xr-x  12 root root    0 Oct 19 06:43 sys
drwxrwxrwt   2 root root 4.0K Oct  6 01:44 tmp
drwxr-xr-x  10 root root 4.0K Oct 19 05:39 usr
drwxr-xr-x  11 root root 4.0K Oct 19 05:39 var

root@87a3ea8fecdd:/# ls -lah /var/lib/apt
total 24K
drwxr-xr-x  6 root root 4.0K Oct 19 05:39 .
drwxr-xr-x 11 root root 4.0K Oct 19 05:39 ..
-rw-r--r--  5 root root    0 Oct  6 01:44 extended_states
drwxr-xr-x  2 root root 4.0K Oct 19 05:39 keyrings
drwxr-xr-x  2 root root 4.0K Oct 11 14:01 lists
drwxr-xr-x  3 root root 4.0K Oct 19 05:39 mirrors
drwxr-xr-x  2 root root 4.0K Apr 14  2016 periodic

root@87a3ea8fecdd:/# ls -lah /usr/share
total 160K
drwxr-xr-x 40 root root 4.0K Oct 19 05:39 .
drwxr-xr-x 10 root root 4.0K Oct 19 05:39 ..
drwxr-xr-x  2 root root 4.0K Oct 19 05:39 adduser
drwxr-xr-x  3 root root 4.0K Oct 19 05:39 apport
drwxr-xr-x  2 root root 4.0K Oct 19 05:39 base-files
drwxr-xr-x  2 root root 4.0K Oct 19 05:39 base-passwd
drwxr-xr-x  3 root root 4.0K Oct 19 05:39 bash-completion
drwxr-xr-x  6 root root 4.0K Oct 19 05:39 bug
drwxr-xr-x  2 root root 4.0K Oct 19 05:39 common-licenses
drwxr-xr-x  4 root root 4.0K Oct 19 05:39 dbus-1
drwxr-xr-x  2 root root 4.0K Oct 19 05:39 debconf
drwxr-xr-x  2 root root 4.0K Oct 19 05:39 debianutils
drwxr-xr-x  2 root root 4.0K Apr 12  2016 dict
drwxr-xr-x 94 root root 4.0K Oct 19 05:39 doc
...

root@df3ef4561fc3:/# lsof /usr/share/doc
root@df3ef4561fc3:/# rm -rf /usr/share/doc
rm: cannot remove '/usr/share/doc/sed': Directory not empty
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty
rm: cannot remove '/usr/share/doc/mawk': Directory not empty
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty
rm: cannot remove '/usr/share/doc/apt': Directory not empty
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty
rm: cannot remove '/usr/share/doc/passwd': Directory not empty
rm: cannot remove '/usr/share/doc/mount': Directory not empty
rm: cannot remove '/usr/share/doc/procps': Directory not empty

Rmdir doesn't work either
root@df3ef4561fc3:/# rmdir /usr/share/doc
rmdir: failed to remove '/usr/share/doc': Directory not empty
root@df3ef4561fc3:/# lsof /usr/share/doc

Same for directly running the rm command
$ docker run --rm -it arm64v8/ubuntu:latest rm -rf /usr/share/doc
rm: cannot remove '/usr/share/doc/sed': Directory not empty
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty
rm: cannot remove '/usr/share/doc/mawk': Directory not empty
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty
rm: cannot remove '/usr/share/doc/apt': Directory not empty
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty
rm: cannot remove '/usr/share/doc/passwd': Directory not empty
rm: cannot remove '/usr/share/doc/mount': Directory not empty
rm: cannot remove '/usr/share/doc/procps': Directory not empty

And with sudo
$ sudo docker run --rm -it arm64v8/ubuntu:latest rm -rf /usr/share/doc
rm: cannot remove '/usr/share/doc/sed': Directory not empty
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty
rm: cannot remove '/usr/share/doc/mawk': Directory not empty
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty
rm: cannot remove '/usr/share/doc/apt': Directory not empty
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty
rm: cannot remove '/usr/share/doc/passwd': Directory not empty
rm: cannot remove '/usr/share/doc/mount': Directory not empty
rm: cannot remove '/usr/share/doc/procps': Directory not empty

This is not listed as a known issue in Docker Issues. How do I debug the issue further?

A: After reporting it as an issue at Docker overlay storage driver unable to delete directories from underlying image layer #35257, I got to the bottom of it, thanks to thaJeztah.
As documented at https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/, the overlay storage driver requires kernel version 3.18 or newer.
My system uses the image ArchLinuxARM-odroid-c2-latest.tar.gz which has an older kernel version 3.14.
The problem occurs because the ALARM docker package is configured with the overlay driver by default, which will only work on newer kernel versions (e.g. RPi image or mainline kernel for ODROID-C2).
Therefore, the solution is to either

*

*Upgrade the kernel version. The last time I checked, mainline kernel support for ODROID-C2 had issues, so the next option might be preferable.

*Or configure docker to use the AUFS storage driver instead of the overlay driver.


text:
Q: Need to refresh three times to get all the values with hooks Hello I am trying to get all the date between each start date and end date and then put these dates inside my react-native-calendar component. Everything work but actually I need to CTRL + S three time my project to have the values inside my calendar, do you have any idea how to have it directly ?
Here is my code :
const myConstrucion = async () => {
    let user_id = await AsyncStorage.getItem('user_id');
    const _id = user_id;

    try {
        let res = await axios.get(`https://myseenapp.herokuapp.com/constructionSite/${_id}`);
        let data = res.data;
        setConstruction(data);
        let st = data
        .map(e => e.startDate.split("-").reverse().join("-"))
        .forEach((day) => { setStartDate(day)})
        let et = data
        .map(e => e.endDate.split("-").reverse().join("-"))
        .forEach((day) => { setEndDate(day)})
        let now = moment(startD);
        let end = moment(endD);
            while (now <= end){
                dateArray.push(now.format("YYYY-MM-DD"));
                now.add(1, 'days');
                dateArray.forEach((day) => {
                    newDaysObject[day] = {
                        textColor: "white",
                        color: 'gold',
                        selected: true,
                    }
                    return dateArray;
                })
            }
    }
    catch (err) {
        console.log(err)
    }
};

I have also my useEffect :
useEffect(() => {
    myConstrucion()
}, [])

A: I can't test at the moment.
By the way using [] in userEffect is bad practice.
This way you are telling useEffect to not whatch for any dependency, just run the first time. In that array one should put the variable to check for change, try
useEffect(() => {
  myConstrucion()
}, [_id])


text:
Q: API to Triggered Send is "OK" but email fails in AMPscript -- can we use API to pull the error record? we've set up triggered sends, and it works just fine... however, on occasion the BuildRowSetfromString fails because the delimiter is missing (for example, there are 3 products in the email, but only 2 values in one of the fields).
This causes our Triggered Send to error and pause the Triggers... which is expected.
However, is it possible to use the API to get the status and error of the post that failed?
As you can probably guess, I am not an API writer/expert!

A: There are different steps to email sends. However, in your case when an API request is made, the validation is first made on the authentication and data attributes. Once initial validation is successful then a response will be passed back to the invoker.
On the second step, the platform (SFMC) will try to validate the email with the data and possibly AMPscript in your case. This step is independent to the first API call you make to send an email.
To confirm the delivery report of the email send, you'd need to make a second API call to SFMC which is known as Get Email Delivery Details
Process:

*

*Once the first API call is successful the response will contain a recipientSendId.

HTTP/1.1 202 Accepted
    {
       "requestId": "e2ddb203-ea53-4843-b2d4-9f8c0c862913",
       "responses": [   {
          "recipientSendId": "e2ddb203-ea53-4843-b2d4-9f8c0c862913",
          "hasErrors": false,
          "messages": ["Queued"]
       }]
    }

*

*You'd then use the recipientSendId to make a second API call to validate the email send delivery report.

Host: https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com
GET /messaging/v1/messageDefinitionSends/key:external_key/deliveryRecords/a7038ea5-51b7-4574-ac22-183654378dd2
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN

*

*From this, you can confirm if the email send was successful by inspecting the response of the request.

HTTP/1.1 200 OK
{
    "deliveryTime": "2014-09-18T07:38:34.943",
    "id": "bd52a488-2f5c-de11-92ee-001cc494ae9e",
    "messageId": "a7038ea5-51b7-4574-ac22-183654378dd2",
    "status": "Sent",
    "to": {
        "address": "example@example.com",
        "id": 195711367,
        "key": "example@example.com"
    }
}

Reference:

*

*Send Email

*Get Email Delivery Details


text:
Q: Cannot configure a React Pre Hook with parameters passed to "npm start" I have a brand new project created with:
$ npx create-react-app test-react-app && cd test-react-app && npm start

here the repo: https://github.com/tlg-265/test-react-app
I created a new script: /prepare-project.js with the following content:
let project = 'ferrari' // replace this value with the one passed via: $ npm start [what to put here?]

console.log(`########################`);
console.log(`###### The current project is: ${project} ######`);
console.log(`########################`);

The content of file: /package.json is:
{
  "name": "test-react-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-scripts": "3.3.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "prestart": "node prepare-project.js"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

where you can see I configured the pre hook:
"prestart": "node prepare-project.js"

My goal is to run:
$ npm start [what to put here?]

so inside the script: /prepare-project.js I can read that value.
I tried with:
$ node prepare-project.js --project=mclaren

with no luck when trying to read that value from inside the script: prepare-project.js.
Any idea on how to achieve this?
Thanks!

A: You can use yargs module to parse command line arguments and then you can use child_process to execute your command. Here is what your code should look like, you may add your own custom logic.

const yargs = require('yargs');
const { execSync } = require('child_process');

const argv = yargs
    .option('project', {
        alias: 'p',
        description: 'name of the project',
        type: 'string',
    })
    .help()
    .alias('help', 'h')
    .argv;

console.log(argv.project);
console.log(`npm start --project=${argv.project}`);
const output = execSync(`npm start --project=${argv.project}`);
console.log(output)


text:
Q: Flex can't handle EOF in Action, or how to? env

*

*OS: MacOS Monterey 12.6 with apple M1 Pro

*version: flex 2.6.4 Apple(flex-34)

Problem
%{
#include <stdio.h>
int yywrap(void) {
    return 1;
}
%}

ID  [a-z][a-zA-Z0-9]*
DIGIT [0-9]

%%

{DIGIT}+    {printf("num");}

{ID}    printf("id: %s\n", yytext);

"/*"    {
    int c;

    for ( ; ; ) {
        while ( (c = input()) != '*' && c != EOF )
            printf("%x\n", c);

        if ( c == '*' ) {
            while ( (c = input()) == '*' )
                printf("%x\n", c);
            if ( c == '/' )
                break;    /* found the end */
            }

        if ( c == EOF ) {
            printf( "EOF in comment" );
            break;
        }
    }
}
%%

int main(int argc, char **argv) {
    ++argv, --argc;
    if (argc > 0) {
        yyin = fopen(argv[0], "r");
    } else {
        yyin = stdin;
    }
    yylex();
    return 0;
}

I try this code, hope to handle EOF in Action by myself. But it fail to handle this file, like:
/* **jfiowejfiowe
 *
 *

Yes, I just want to test unclosed comment in the end of file.
lex test.lex
gcc lex.yy.c -o lextest
./lextest comment.c

and it output
20
2a
66
69
6f
77
65
6a
66
69
6f
77
65
a
20
20
0
0
0
...

with endless 0.
I also try to rewrite yywrap()
int yywrap() {
    return 0;
}

But it output like
20
2a
66
69
6f
77
65
6a
66
69
6f
77
65
a
20
20
[1]    57558 segmentation fault  ./lextest comment.c

has a segmentation fault error.
Also I try yyterminate like
#define yyterminate() return YY_NULL

int yywrap(void) {
    yyterminate();
}

still has a segmentation fault error.

A: Up to version 2.6.0, the input() function returned EOF on end of input. For reasons which are not at all clear to me, this was changed for version 2.6.1 (released in March, 2016); since then, input() returns 0 on end of input, making it pretty well impossible to distinguish between end of input and a NUL character. The Flex documentation has not been updated to reflect this change.
A very clumsy workaround is available. In yywrap, you could set a global flag (or put a flag in the yyextra data, for a reentrant scanner), and then you could check the flag after input() returns 0. This is not a fully general solution, but it should work in your case.
Alternatively, you could install an older Flex release (2.5.39 and 2.6.0 are both available at the Github release page. Or you could download the source for version 2.6.4 and patch the file flex.skl at line 1859, changing it from return 0 to return EOF.
Whatever the reason for the change, it's certainly a bug, either in the behaviour or in the documentation, and it has been reported several times: most recently, apparently, by you, and previously as issue 212 in 2017 and issues 444 and 448 in 2020. That last one contains references to bug reports in other places (debian, for example).
On the whole, I feel that the use of input() should be avoided if at all possible. It has its uses, but in most cases, you'll find it faster and more convenient to use start conditions. In the particular case of multiline comments, even that's unnecessary; they can be recognised with a pair of patterns. (One for correct comments, and another one to flag an error for unterminated comments.)
As a final note about your attempt to terminate the lexical scan from yywrap:
The only thing you can do in yywrap to terminate the scan is return 1. If you return 0, you are promising that you have reset the yyinput so as to make more input available. If you don't do that, the result is undefined (which means, bad). The yyterminate action is only valid in lexer actions; it cannot be used anywhere else. (Although it looks like a function, it's actually a macro which assumes that it is being expanded in the context of an action, and will have undefined consequences if expanded in a different scope.) So the segfaults you experienced are not surprising.


text:
Q: Zend 1.11, Decorator file location I search every where but cannot find an answer, so question is, where must be Decorator class, let's look with example:
I have application/forms/Guestbook.php
class Application_Form_Guestbook extends Zend_Form
{

    public function init()
    {

        $this->addPrefixPath('My_Decorator', '/application/forms/decorator', 'decorator');

        $this->setMethod('post');
        $this->addElement('text', 'email', array(
            'label' => 'Your email address',
            'require' => true,
            'filters' => array('StringTrim'),
            'validators' => array('EmailAddress'),
            //'prefixPath' => array('decorator' => array('My_Decorator' => 'application/forms/decorator')),
            'decorators' => array(array('SimpleInput'))));

        // Add the comment element
        $this->addElement('textarea', 'comment', array(
            'label' => 'Please Comment:',
            'required' => true,
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 20))
            )
        ));

        // Add a captcha
        $this->addElement('captcha', 'captcha', array(
            'label' => 'Please enter the 5 letters displayed below:',
            'required' => true,
            'captcha' => array(
                'captcha' => 'Figlet',
                'wordLen' => 5,
                'timeout' => 300
            )
        ));

        $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Sign Guestbook'));
        $this->addElement('hash', 'csrf', array('ignore' => true));
    }

}

and have application/forms/decorator/SimpleInput.php
class My_Decorator_SimpleInput extends Zend_Form_Decorator_Abstract
{

    protected $_format = '<label for="%s">%s !!!!!!</label><input id="%s" name="%s" type="text" value="%s"/>';

    public function render($content)
    {
        $element = $content->getElement();
        $name = htmlentities($element->getFullyQualifiedName());
        $label = htmlentities($element->getLabel());
        $id = htmlentities($element->getId());
        $value = htmlentities($element->getValue());

        $markup = sprintf($this->_format, $name, $label, $id, $name, $value);

        return $markup;
    }

}

When I try to launch page I have an error on loading of decorator:
An error occurred
Application error
Exception information:

Message: Plugin by name 'SimpleInput' was not found in the registry; used paths: My_Decorator_: /application/forms/decorator/ Zend_Form_Decorator_: Zend/Form/Decorator/
Stack trace:

#0 /home/dev/public_html/local.zend.test/library/Zend/Form/Element.php(1827): Zend_Loader_PluginLoader->load('SimpleInput')
#1 /home/dev/public_html/local.zend.test/library/Zend/Form/Element.php(2207): Zend_Form_Element->_getDecorator('SimpleInput', NULL)
#2 /home/dev/public_html/local.zend.test/library/Zend/Form/Element.php(1980): Zend_Form_Element->_loadDecorator(Array, 'SimpleInput')
#3 /home/dev/public_html/local.zend.test/library/Zend/Form/Element.php(316): Zend_Form_Element->getDecorators()
#4 /home/dev/public_html/local.zend.test/library/Zend/Form/Element.php(271): Zend_Form_Element->loadDefaultDecorators()
#5 /home/dev/public_html/local.zend.test/library/Zend/Form.php(1125): Zend_Form_Element->__construct('email', Array)
#6 /home/dev/public_html/local.zend.test/library/Zend/Form.php(1035): Zend_Form->createElement('text', 'email', Array)
#7 /home/dev/public_html/local.zend.test/application/forms/Guestbook.php(18): Zend_Form->addElement('text', 'email', Array)
#8 /home/dev/public_html/local.zend.test/library/Zend/Form.php(240): Application_Form_Guestbook->init()
#9 /home/dev/public_html/local.zend.test/application/controllers/GuestbookController.php(28): Zend_Form->__construct()
#10 /home/dev/public_html/local.zend.test/library/Zend/Controller/Action.php(516): GuestbookController->signAction()
#11 /home/dev/public_html/local.zend.test/library/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action->dispatch('signAction')
#12 /home/dev/public_html/local.zend.test/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#13 /home/dev/public_html/local.zend.test/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#14 /home/dev/public_html/local.zend.test/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#15 /home/dev/public_html/local.zend.test/public/index.php(26): Zend_Application->run()
#16 {main}

This example is from quick guide. Question is where must be location of such decorators (default location), or how can I load them and which 'path/to/decorator' I should write (from root\application\forms folder?) because documentation in Zend as usually ugly... =\

A: edit #3.
I think the problem might be that Zend does not like how you set the path. /application is a absolute path and would probably not resolve where you think.
Try:
$this->addPrefixPath('My_Decorator', APPLICATION_PATH . '/forms/decorator', 'decorator');

That way the path must be good. Its probable that Zend was looking in /public/application/etc... the way you have used it.
Hope this help!

A: Decorators are loaded using Autoloader like the other classes, so the decorator needs to be put according to the class name:
eg. class My_Decorator_Something in library/My/Decorator/Something.php
Looks like the best option in this case is to improve your decorator class naming.
However, if you need some other, custom location, you need to write and register your own autoloader.


text:
Q: How to set PATH envirnment variable through a shell script though that shell script gets terminated? I am having a shell script ./my_shellscript.sh, its contents are as follows :
source /path/to/shell_script.sh

Where shell_script.sh contains:
export PATH=/path/to/a/dir:$PATH
which command_name

when I execute the my_shellscript.sh then it shows accurate path to a command, that I executed using "which" command?
When the shell_script.sh terminates and when I again do "which command_name" from command line it doesn't shows any path as it shown when I executed the scripts.
My question is that how to set/persist that path to environment variable [PATH:$PATH]  though shell_script.sh terminates?

A: That's not how environments work, you can't change the parent environment. You can only change your environment, and (optionally) that of child processes to your process.

A: You could run your ./my_shellscript.sh with source (or .) to export it's variables to your current environment.
source my_shellscript.sh

or
. my_shellscript.sh

Other option to put the PATH variable extension into your .profile file in your home directory. (/home/your_username/.profile) That will be permanent.


text:
Q: Let $G$ be a group of order $360$ and suppose $M$ is a maximal subgroup of $G$ which is isomorphic to $A_5$. Prove that $G$ is isomorphic to $A_6$. Let $G$ be a group of order $360$ and suppose $M$ is a maximal subgroup of $G$ which is isomorphic to $A_5$. Prove that $G$ is isomorphic to $A_6$.
Help me some hints.
Thanks a lot.

A: Since $|G| = 360$ and $|M| = |A_5| = 60$, the natural action of $G$ on cosets of $M$ induces a homomorphism $\phi : G \to S_6$. We will show that $\phi$ is an embedding whose image is $A_6$.
Now, $\ker \phi$ is the intersection of all conjugates of $M$ in $G$, i.e. $\ker \phi = \bigcap_{g \in G} gMg^{-1}$. Since this is a normal subgroup of $G$ contained in $M$, and $M$ is simple, we must have $\ker \phi = \{e\}$ (since $\ker \phi \neq M$, else $M \unlhd G$ - why is this impossible?). Thus $\phi : G \to S_6$ is an embedding.
To show that $\phi(G) = A_6$, notice that $\phi(G) \subseteq S_6$ is a subgroup of index 2. Then $\phi(G) \unlhd S_6 \implies \phi(G) \cap A_6 \unlhd A_6 \implies \phi(G) = A_6$ (note $\phi(G) \cap A_6 \neq \{e\}$, since at least half of the elements in $\phi(G)$ are even permutations).
Edit: Just to be clear on why $M \unlhd G$ is impossible, notice that a normal maximal subgroup must be of prime index, as the quotient by such a subgroup cannot have nontrivial proper subgroups.


text:
Q: Large Vue component for single use in HTML I have an editor vue component <editor></editor> that I want to use on only a few sites. This component is fairly big (400kb), so I don't want to register it globally. Is there a way to do this? The site is a traditional server side app that uses normal blade.
I'm thinking about manually importing it only on the sites that use it.

A: Just add the editor component like this:
...
import EditorComponent from 'path/to/editor/'

export default {
  components: {
    'editor': EditorComponent
  }
}
...

Then you can use the <editor></editor> without troubles in your HTML.

A: Chunk your javascript with Webpack, this way you only load what you need in the front end.
Example of code splitting
Then use different new Vue functions to render only what is needed
import Editor from './Editor.vue'
import OtherVueInstance from './OtherVueInstance.vue'
window.onload = function () {
    if (pageContainsEditor) {
        new Vue({
            render: h => h(Editor)
        }).$mount('#editor');
    } else if (somethingElse) {
        new Vue({
            render: h => h(OtherVueInstance)
        }).$mount('#OtherVueInstance');
    }
}

In the blade file:

Also you can just create a whole new Vue application, with its own seperate JS and CSS. Then just load that on the pages where it is needed.

A: Just use your Editor component as async component
Instead of this:
import Editor from './editor'
export default {
  components: {
    Editor
  }
}

Do this:
export default {
  components: {
    Editor: () => import('./editor')
  }
}

Webpack will split Editor component code into separate chunk and Vue will load it on demand only when it is actually needed...


text:
Q: Find the first odd multiplicity root of a function I'm trying to find the "first" (greater than some initial $t_0$) odd root (that is, a root after which the sign of the function changes) of a function $f(t)$, if there is one, that is also less than some max bound $t_{\max}$.  I can evaluate derivatives of the function, too, but they get more much more expensive the further I go, so I don't want to derive past the first or second derivatives.  (The function is a combination of polynomials and trig functions).  The idea is that this would run as part of another algorithm, so I can't visually inspect the function to try and bracket the roots, and the method I use has to be robust.
So far I figure I can walk "downhill" (or "uphill", depending on where we start) from $t_0$ to $t_{\max}$ by using a Taylor expansion's bounds on the max error and iterating by taking the largest "safe" step size that won't cross 0.  Eventually, this should converge to the "first" zero of the function.  It's not a great algorithm numerically, but let's say I use either this or some other method to find the first root.
If the zero has multiplicity of 1, the first derivative will not be 0 and I can test for that, and then I'm done.  However, anything greater than that multiplicity-wise will generate a first derivative that is 0, so I won't be able to determine from that if the multiplicity is even or odd.
So I had the thought that if I could take some step size $h$ and evaluate the function at $f(t+h)$ I could check its sign and see if the function crossed the x axis or just bounced off of it (if the root was odd or even).  If it's an even root, I can start hillclimbing away from 0 and continue on with the algorithm.  If it's an odd root I'm done.
However for this scheme to work I need to be sure that there aren't any roots in the interval $(t, t+h]$.  So I need some way to find a safe step size $h$.  I could just use some small epsilon but I was hoping that there was a better symbolic way to approach the problem.
Or even better if there's a way to determine whether a given root is even or odd multiplicity when you have it in hand, that would be even better.
Specifically, annoying test cases I have in mind:
$f(t) = \cos(t)+1$ <-- Infinite number of even roots
$f(t) = (t-3)^3$ <-- Odd root, but first derivative is 0
$f(t) = t^2-1^{-15}$ <-- Odd root, but not necessarily detectable with machine precision.  I wouldn't mind counting these cases as even, but I want to be careful throwing epsilons all over the place.
...
Specifically, the function of interest has this form:
$f(t) = \mu^T \Pi^T \upsilon$
where:
$\mu = [\theta_1(t)](r_2-r_1)$
$\upsilon = b(t) - [\theta_0(t)]r_0 + [\theta_1(t)]r_1$
$\Pi$ is the 2x2 rotation matrix that rotates a vector by 90 degrees.
$b(t)$ is a 2 element column vector polynomial (that is, a polynomial with coefficients that are 2D vectors)
$\theta_0(t), \theta_1(t)$ are scalar polynomials
$r_0, r_1, r_2$ are constant vectors.
$[\theta(t)]$ is shorthand for the 2x2 rotation matrix by angle $\theta$.
...
So basically, is there a way to declare some neighborhood around a given root as containing no other roots?
Or alternatively, if anyone has other ideas about how to approach this problem.


text:
Q: What is the Advantage of React JS over Pure Javascript + PHP? What exactly is the purpose of React JS? I've heard a few things, like:

*

*It updates the page without refreshing.

*It is modular and can reduce redundant coding.

*It is faster than updating the DOM object with JS.

The only one I can probably agree with is the last one. I don't understand why React JS is so important for the first two. For updating the page without refreshing, can't we just use AJAX? And for redudant code, say I needed to add a navigation bar in multiple pages, can't I just put something like:

  Home Page

  About Us

And then link it wherever we need it with:
<?php include 'documentabove.php' ?>

I can build things with it, but can't wrap my head around why it seems like they made another language just for the sake of it.
Additionally, I would like to say I am sorry if this question does not belong here. I didn't feel like it belongs on stack overflow and am unsure of where to post it exactly.

A: React competes with Vanilla Javascript, not with server-side functionality¹.
Example scenario
Consider a simple interactive web application consisting of a slider. When we move the slider, we want some HTML element to move around automatically. This means that we have to find the relevant nodes in the DOM and set up an event listener and update the DOM whenever the state changes:

  Move me: <input id=slider type=range min=0 max=100>

drag the slider to move me

const slider = document.getElementById("slider");
const text = document.getElementById("text");
slider.addEventListener('input', ev => text.style.left = `${ev.target.value}vw`);

(live jsfiddle)
This works fine for this simple example, but really doesn't scale well. As multiple interactive elements are added to a page, it's difficult to keep all of the data flows clear and straightforward, without any name clashes and so on.
Reactive user interfaces
Approaches to tame the complexity of GUIs are older than the web, for example with the Model–View–Controller pattern.
What React and similar frontend frameworks like Vue do is to provide a path to tackle this complexity, hiding all the tricky bits. The general idea is that

*

*the application has some current state,

*the DOM should always be a reflection of the current state, and

*to change the DOM, you change the current state instead.

This is reactive programming, because the output (DOM) always updates itself when its inputs/dependencies (the state) are changed.
This means the programmer does not have to think about all of the DOM × DOM data flows, but can concentrate on managing the state and how to render the state in the current DOM.
A naive implementation of this approach would re-render the entire page/component whenever any part of the state changes:

  Move me: <input id=slider type=range min=0 max=100>

const app = document.getElementById("app");
const slider = document.getElementById("slider");

const renderSlidingText = (pos) => app.innerHTML = `

    drag the slider to move me

`;

slider.addEventListener('input', ev => renderSlidingText(ev.target.value));

renderSlidingText(slider.value) // render initial state

(live jsfiddle)
That works mostly fine for this small example, but replacing larger parts of the DOM would degrade performance noticeably (layouting the page is expensive for the browser). So what these frameworks do is to avoid using Element.innerHTML, instead parse the template themselves, and then compare the desired DOM with the current DOM to apply more surgical updates. For example, React would likely see here only the CSS style property needs to be updated, without having to replace the entire element.
User interface components
On top of helping with reactive programming and efficient DOM updates, these libraries also provide ways to build reusable components. For example, the following React example uses a <SlidingText> component:

const App = () => {
  const [pos, setPos] = React.useState(50);

  return (

        <input
         type="range" min="0" max="100" value={ pos }
         onInput={ (ev) => setPos(ev.target.value) }
        ></input>

        <SlidingText pos={ pos } />

  );
};

const SlidingText = ({ pos }) => (
  <div className="text" style={ {left: `${props.pos}vw` } }>
    drag the slider to move me

);

const root = ReactDOM.createRoot(document.getElementById("app"));
root.render(<App />);

(live jsfiddle)
Of course, vanilla JS also supports Web Components, but defining them is a bit more effort than a simple function.
Updating the DOM with new data
You do mention Ajax requests to load new content into the current page, but unless you directly load HTML and use the Element.innerHTML approach you're going to have to manipulate the DOM somehow. For example, assume our backend gives us a list of strings ["a", "b", "c"].
With vanilla JavaScript we'd have to resort to some serious contortions like

const list = document.getElementById("data");

const renderData = (data) => {
  list.innerHTML = ''; // delete old contents
  for (const item of data) {
    const li = document.createElement("li");
    li.innerText = item;
    list.appendChild(li);
  }
};

But with React, we can just declaratively map the data to a desired DOM:
const List = ({ data }) => (

    { data.map(item =>
{ item }
) }

);

And if we give each list item a unique key, then React's merging/reconciliation algorithm can handle subsequent updates of the input list more efficiently, without having to rewrite the entire list's DOM when elements are inserted/deleted.
Conclusion
Is all this extra effort worth it? Not for simple examples like a single slider. But React-style state management and rendering gets quite desirable for single-page applications, highly dynamic frontends, or when you want multiple instances of the same interactive component.
Of course, not every website is highly interactive. In a lot of cases, rendering templates on the backend is perfectly fine. Replacing partial content with Element.innerHTML is totally OK for a lot of use cases. For example, dynamically loading HTML fragments is quite popular and successful in the Rails community with frameworks like Turbolinks/Turbo/Hotwire. For example, the GitHub web interface uses this approach for its major navigation.
¹ though React is sometimes used for server-side rendering, a use case that competes with traditional template engines.

A: React, Vue, Angular etc provide a MVC style UI framework which HTML + JS doesn't have.
I guess the benefits are that by using the framework you get a whole load of common functionality that you would otherwise have to write from scratch. That basic binding of javascript variables to HTML elements so that when the data changes the DOM changes.
Granted if you have a very simple site you might feel that you don't need that functionality, or that its done in too complex a way, But websites these days are basically becoming desktop applications.
You might say that a static page with no javascript at all is fine for most things, But would you try to write google docs without some sort of UI framework? What about even the editable textbox on this site?
Once you've written it are you never going to reuse its basic functions in some other component or site? As you program you will build up a "framework" of code that you reuse for all your sites. React etc are the frameworks other poeple have written already.


text:
Q: Slow MySQL query. What should I index? PHPWiki has a 5 second slow query each time you save a page edit.  The query caught often in the "mysql-slow.log" is:
INSERT INTO wikiscore
SELECT w1.topage, COUNT(*)
FROM wikilinks AS w1, wikilinks AS w2
WHERE w2.topage=w1.frompage
GROUP BY w1.topage;

The current indexes are as follows:
table "wikilinks" has a primary index on "frompage" and "topage"
table "wikiscore" has a primary index on "pagename" and "score"

How could I reformulate the SELECT query to return the same results faster?   How could I change the indexes so this query would be faster? My thought is it might be OVER-indexed?
I've timed the result of the SELECT part of the query only and it takes 1-2 seconds alone.  The INSERT must take up the rest of that time.
There is a lag when saving pages that I would like to eliminate.  I do not have the option of upgrading to another wiki engine (or version of PHPwiki) due to the amount of modifications that have been done.
Any ideas?
edit---
The results of "EXPLAIN" on the SELECT part of the query were:
SIMPLE
w2
index
PRIMARY
204
31871
Using index; Using temporary; Using filesort

SIMPLE
w1
ref
PRIMARY
PRIMARY
102
phpwiki.w2.topage
14
Using index

A:
table "wikilinks" has a primary index on "frompage" and "topage"

WHERE w2.topage=w1.frompage

This condition cannot be searched over the composite index described above.
Either change order (create an index on topage, frompage) or create an additional index on topage.
P. S. The root of them problem is that the ranks of each and every page in the system are updated with every edit.
This ranking system seems a little bit weird to me: it counts link to links, not the links themselves.
If 1000 pages link to Moscow and only Moscow links to Beket pond, then the pond will get 1000 points and Moscow will get no points at all, though everyone knows of Moscow and none of the pond.
I think it's not what you meant. Most probably it should look like that:
INSERT INTO
       wikiscore
SELECT
       linked.topage, COUNT(*) AS cnt
FROM   wikilinks current, wikilinks linked
WHERE  current.frompage=@current_page
       AND linked.topage = current.topage
GROUP BY
       linked.topage
ON DUPLICATE KEY UPDATE
       score = cnt;

This will sum all links to all pages referenced from the current page, that seems to be what you want.
You will need to get rid of score in PRIMARY KEY on wikiscore in this case, but I see no point in putting it there anyway.
If you want to speed up ranking queries, you create indices like that:
ALTER TABLE wikilinks ADD CONSTRAINT pk_wikilinkes_fromto PRIMARY KEY (frompage, topage);

CREATE INDEX ix_wikilinks_topage ON wikilinks (topage);

ALTER TABLE wikiscore ADD CONSTRAINT pk_wikiscore_pagename PRIMARY KEY (pagename);

CREATE INDEX ix_wikiscore_score ON wikiscore (score);

A: It should be helpful to use the EXPLAIN statement to figure out what part of your query takes the most time. Then you can decide what measures are to be taken to optimize your query.

A: I'm having a little trouble understanding what the query does. I gather that it finds links from one page to another. so w1.topage is the links to that page, and w1.frompage is links from that page to other pages. And so the insert adds the page and the number of links to that page.
Am I on track?
Your main problem is this line:
FROM wikilinks AS w1, wikilinks AS w2

If you suppose that table has 1000 entries, the query engine has to match 1000 entries to each other entry, so it's grabbing 1000×1000 rows, (without considering the WHERE or GROUP clause). As you get more and more entries, the query time increases exponentially. (kaboom)
Also, you're only editing a single page, so you should be able to reasonably assume that links to this particular page will not change, but links from it might. So instead of writing the wikilinks table on every update, delete the links from this particular page, and then re-insert all links from this page to others.

A: Quassnoi's answer will get you some speed on the SELECT.  If the INSERT is taking another four seconds, then adding indexes isn't going to help anything.  Possibly you could cut a lot of data out of the process by adding AND COUNT(*) > 0 to your SELECT, if it's desirable to leave out pages with zero incoming link counts.
You can get at least some improvement by removing indexes from wikiscore.  Your primary key on pagename,score doesn't really make sense (you can store multiple scores from the same page, but not if they're the same score?), and should probably just be a primary key on pagename.  If there are other indexes, you might be able to get rid of them.
If wikiscore isn't freshly created when this happens, you might get some benefit out of throwing an OPTIMIZE TABLE at it.
What would be really awesome, though, is if you changed the whole theory behind this query so that, instead of rebuilding the entire wikiscore table every time a page is saved, you only update the score of the saved page and pages that it links to.

A: Here's how I modified the PHP code in PHPWiki's source
// update pagescore
//old way...
/*
mysql_query("DELETE FROM $WikiScoreStore", $dbi["dbc"]);
mysql_query("INSERT INTO $WikiScoreStore"
                 ." SELECT w1.topage, COUNT(*) FROM $WikiLinksStore AS w1, $WikiLinksStore AS w2"
                 ." WHERE w2.topage=w1.frompage GROUP BY w1.topage", $dbi["dbc"]);

*/

//delete this pagescore
mysql_query("DELETE FROM $WikiScoreStore WHERE pagename='$frompage'", $dbi["dbc"]);
//insert just this pagescore
mysql_query("INSERT INTO $WikiScoreStore"
                    ." SELECT w1.topage, COUNT(*) FROM $WikiLinksStore AS w1, $WikiLinksStore AS w2"
                ." WHERE w2.topage=w1.frompage AND w1.topage='$frompage' GROUP BY w1.topage", $dbi["dbc"]);

Since this code change and the index tweaks,  I have no slow queries.  Thank you S.O.!


text:
Q: Transforming a list of points in a "rank" of indexes Let's say that I have a list of points from a torunament
points = [0, 12, 9]

And I want to have a ranking of the players, so the expected outputs would be
[1, 2, 0]

Because the index 1 is first in the ranking, followed by index 2 and then index 0.
My idea was to use a for to iterate through all the numbers, getting the biggest value, find the index of the biggest value and then assign the value in the ranking, but it seems unnecessary long and complicated.
Any tips?

A: Use sorted:
points = [0, 12, 9]
res = sorted(range(len(points)), key=lambda x: points[x], reverse=True)
print(res)

Output
[1, 2, 0]

The idea is to sort the indexes of the list (range(3)) according to their value on the list, hence the key=lambda x: points[x]. The reverse True is because you want a descending ranking.

A: points = [0, 12, 9]
points_and_indices = [(p, i) for i, p in enumerate(points)]
points_and_indices.sort(reverse=True)
indices = [i for p, i in points_and_indices]
print(indices)

output:
[1, 2, 0]

UPDATE
You say in a comment

The first index who got that number of points is ahead

Unfortunately this  causes the above solution to be wrong for your purposes, because the indices are included in the reverse sort.
To exploit the stability of Python sorts we must either not include the indices in the reverse sort, or use a decreasing function of the points instead of the points themselves.
We can sort according to the negative points, and also condense it all into a one-liner, like this:
points = [0, 12, 9, 12]
indices = [i for _, i in sorted((-p, i) for i, p in enumerate(points))]
print(indices)

output:
[1, 3, 2, 0]

Anyway, the solution by Dani Mesejo is more pythonic, even though the use of a sort key may cause some head scratching in people coming from other programming languages.


text:
Q: How to Deploy a website to Windows Azure with Sql server Compact file in App_data in VS2012 I need a help to Deploy my Website on Windows Azure. I have a Database CodeCamper.sdf file in my App_data folder which is working good but i do not know how to deploy that application in Windows Azure and what will be my Connectionstring in that case. Currently i have no connectionstring in my web.config file. Here is my code
public CodeCamperDbContext()
        : base(nameOrConnectionString: "CodeCamper") { }

    static CodeCamperDbContext()
    {
        Database.SetInitializer<CodeCamperDbContext>(null);
    }

A: You just need to make sure that the data files have their "Copy to output directory" property set to something other than "Never".
Here's How to Deploy an Azure Website
Based on this article (below), it doesn't sound like you need to change anything in the web.config.
Using SQL Server Compact for ASP.NET Web Applications


text:
Q: Creating a table using javascript while retaining the first cell row I have a html and javascript program where in I want to upon new queue of data the table will get cleared empty while retaining the first cell row that contains the content names of the table. How can I make it possible Here is my

and here is my
<!DOCTYPE html>

Administrator Tools:

Read Database Content | Add Data | Edit Data | Delete Data

            <form>
                Show Database data by: <select id="dbselector" onchange = "dbOutputSelect();">
                                            <option value = '0'>All Data</option>
                                            <option value = '1'>By Name</option>
                                            <option value = '2'>By Address</option>
                                            <option value = '3'>Budget</option>
                                            <option value = '4'>Time to spend</option>
                                            <option value = '5'>Marker Type</option>
                                       </select>

 Content: <input type="text" size="16" id="contentholder">

                <input type="button" value="Submit" onclick="ajaxRequest();">
            </form>

Id No.	Name	Address	Information	Budget	Time to Spend	Site Type

Mysel

Myse

Mys

On my table I want to retain the original table content such as Id, name, adress information etc. in my HTML page.

A: I would recommend using thead and tbody elements in your table.
MDN link
Then you only have to add data to the tbody, and clear the data in the tbody

            Id No.
            Name
            Address
            Information
            Budget
            Time to Spend
            Site Type

A: Try something like this:
while(table.rows.length > 1){
  table.rows[1].parentElement.removeChild(table.rows[1]);
}


text:
Q: How to block access of specific client and revoke his issued tokens in admin console I implemented Authorization Server with spring boot and keycloak using the following dependencies:
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson2-provider</artifactId>
    <version>${resteasy.version}</version>
</dependency>

<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-dependencies-server-all</artifactId>
    <version>${keycloak.version}</version>
    <type>pom</type>
</dependency>

I defined a client to have client_credentials authorization flow in keycloak admin console. everything is ok and client can get his access_token and refresh_token.
Now, i want to be able to revoke this client issued tokens and also prevent his to get new token. how and where can i do that in keycloak admin console?

A: Access Tokens cannot be revoked (at least in Keycloak). They are designed to be short-lived and its very good practice to set their expiry time between 1 and 3 minutes.
The only thing you can do is:

*

*Evict all sessions of a particular user

*Disable/deny access to this particular user (so that he will not get new tokens)

*Change keys or regenerate secret credentials of a particular Client (so that it will not be possible to authenticate against nor will it issue new tokens)

*Use not-before push policy for all tokens or disable/delete the Client or application

More actions and details are available here: https://www.keycloak.org/docs/latest/server_admin/index.html#compromised-access-and-refresh-tokens
"Token lifetime" and "Revoking access" topics are partly covered here:

*

*https://www.oauth.com/oauth2-servers/access-tokens/access-token-lifetime/

*https://www.oauth.com/oauth2-servers/listing-authorizations/revoking-access/


text:
Q: Android ImageView not showing received images from socket connection I am trying to show two consecutive images in an Android app, which are received through a socket (from a C program using sendfile). The sender code seems to work ok, and I am having issues with the Android code side.
Part of the code in the Android app is the following:
public class DisplayNewActivity extends Activity {
    ...
    @Override
    public void onCreate(Bundle savedInstanceState) {
        ....
        mHandler = new Handler() {
           @Override
           public void handleMessage(Message msg) {
               Drawable d2;
               d2 = (Drawable)msg.obj;
               imageSock.setImageDrawable(d2); // to set the arrived image in the imageshow object
           }
        };
        ...
        cThread = new Thread(new ClientThread());
        rThread = new Thread(new RcvThread());
        cThread.start();
    }

    public class ClientThread implements Runnable {
        public void run() {
           // thread used for socket connection.
           ...
           rThread.start(); // once the connection has been established
           ...
        }
    }

    @SuppressLint("HandlerLeak")
    public class RcvThread implements Runnable {
         public void run() {
            while (connected) {
               try {
                  InputStream inputStream = socket.getInputStream();
                  Drawable d = Drawable.createFromStream(inputStream, null);
                  Message msg = new Message();
                  msg.obj = d;
                  mHandler.sendMessage(msg);
               } catch (Exception e) {
                  Log.e("SocketConnectionv02Activity", "C: ErrorRCVD", e);
               }
            }
         }
    }
 }

The problem I am facing is that after the first image received by the Android app is shown correctly, then the next one received (which is correctly received) is not shown and leaves the imageview object showing a white space.
Any suggestion/idea to solve this issue?.
Thanks in advance for any help you could provide.
EDIT:
public class DisplayNewActivity extends Activity {
    ...
    @Override
    public void onCreate(Bundle savedInstanceState) {
        ....
        mHandler = new Handler() {
           @Override
           public void handleMessage(Message msg) {
               Bitmap d2;
               d2 = (Bitmap)msg.obj;
               imageSock.setImageBitmap(d2); // to set the arrived image in the imageshow object
           }
        };
        ...
        cThread = new Thread(new ClientThread());
        rThread = new Thread(new RcvThread());
        cThread.start();
    }

    public class ClientThread implements Runnable {
        public void run() {
           // thread used for socket connection.
           ...
           rThread.start(); // once the connection has been established
           ...
        }
    }

    @SuppressLint("HandlerLeak")
    public class RcvThread implements Runnable {
         public void run() {
            while (connected) {
               try {
                  DataInputStream in = new DataInputStream(socket.getInputStream());
                  Bitmap d = BitmapFactory.decodeStream(in);
                  Message msg = new Message();
                  msg.obj = d;
                  mHandler.sendMessage(msg);
               } catch (Exception e) {
                  Log.e("SocketConnectionv02Activity", "C: ErrorRCVD", e);
               }
            }
         }
    }
 }

A: It sounds like the issue you are having is in decoding the data into a proper image after receiving it.
I might recommend not using Drawable.createFromStream() and instead using BitmapFactory.decodeStream() or manually downloading the data into a byte[] first and using BitmapFactory.decodeByteArray().  Sometimes the latter is useful if the former can't sufficiently keep up with the decoder as the data is received.
The method you are currently using actually ends up calling BitmapFactory.descodeResourceStream(), which is used to read image data out of the local res/ package and not so much from a remote socket.


text:
Q: Mathematica vs Wolfram Alpha integration results When I insert the following integration command in wolframalpha:
int(pi^2*0.05*Exp[-0.1]*14142135/2*x^-1*
  Exp[-x]*y*Exp[-pi*0.1*y^2/2]*
  Hypergeometric2F1[1, 2/3, 5/3, -2*y^-4*(2*10^14)^(3/4)]*
  BesselI[2, x*y*Sqrt[2*pi]],{x,0,0.25},{y,0,Infinity})

I get the following numerical result 6.68805
However, inserting the same command in Mathematica as follows:
NIntegrate[pi^2*0.05*Exp[-0.1]*14142135/2*x^-1*
  Exp[-x]*y*Exp[-pi*0.1*y^2/2]*
  Hypergeometric2F1[1,2/3,5/3,-2*y^-4*(2*10^14)^(3/4)]*
  BesselI[2,x*y*Sqrt[2*pi]],{x,0,0.25},{y,0,Infinity}]

I get the following output (no result)

Am I doing something wrong in Mathematica? Does the wolframalpha site has extended functionality compared to Mathematica (in the above concept).
Thanks in advance
PS: I suppose that wolfralpha translates int() as NIntegrate in the specific case.

A: I think the apparent answer to your problem is that you entered in Mathematica:
NIntegrate[pi^2 ... blah ]

... and in Mathematica, Pi is the exact real number $\pi$ = 3.1415 ... but pi is just a name like cat or mouse. Capital letters matter. Wolfram Alpha is more flexible about such things, perhaps because it needs to be. This explains why you would get the message about your expression not being numerical, because it contains a pi (or a cat or a dog).