Kubernetes - How to debug Failed Scheduling "0 nodes are available"

Question: I often find myself trying to spin up a new pod, only to get an error saying that no node is available. Something like:
0/9 nodes are available: 1 node(s) had no available volume zone, 8 node(s) didn't match node selector.
I'm always at a loss when I get those messages. How am I supposed to debug that?
Comment: please provide Taints information from your nodes kubectl describe your node  and provide your pod/deployment yaml. You are looking for [Taints and Tolerations](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/)
Comment: Hi Hanx. I'm not looking for a solution specific to this instance of my problem. Indeed, this very problem is solved. I'm looking for general advice concerning node allocation and that debugging.
Answer: At the beginning my advice is to take a look at Kubernetes Scheduler Component:

Component on the master that watches newly created pods that have no node assigned, and selects a node for them to run on.[-]
  Factors taken into account for scheduling decisions include individual and collective resource requirements, hardware/software/policy constraints, affinity and anti-affinity specifications, data locality, inter-workload interference and deadlines.
A scheduler watches for newly created Pods that have no Node assigned. For every Pod that the scheduler discovers, the scheduler becomes responsible for finding the best Node for that Pod to run on
  For every newly created pods or other unscheduled pods, kube-scheduler selects a optimal node for them to run on. However, every container in pods has different requirements for resources and every pod also has different requirements. Therefore, existing nodes need to be filtered according to the specific scheduling requirements.

As per documentation:

In a cluster, Nodes that meet the scheduling requirements for a Pod are called feasible nodes. If none of the nodes are suitable, the pod remains unscheduled until the scheduler is able to place it.

kube-scheduler selects a node for the pod in a 2-step operation. Standard kube-scheduler based on Default policies:

Filtering
Scoring

Looking into those two policies you can find more information where the decisions were made. For example:
for scoring at the stage CalculateAntiAffinityPriorityMap This policy helps implement pod anti-affinity.

Below you can find quick review based on Influencing Kubernetes Scheduler Decisions

Node name: by adding a node's hostname to the .spec.nodeName parameter of the Pod definition, you force this Pod to run on that specific node. Any selection algorithm used by the scheduler is ignored. This method is the least recommended.
Node selector: by placing meaningful labels on your nodes, a Pod can use the nodeSelector parameter to specify one or more key-value label maps that must exist on the target node to get selected for running that Pod. This approach is more recommended because it adds a lot of flexibility and establishes a loosely-coupled node-pod relationship.
Node affinity: this method adds even more flexibility when choosing which node should be considered for scheduling a particular Pod. Using Node Affinity, a Pod may strictly require to be scheduled on nodes with specific labels. It may also express some degree of preference towards particular nodes by influencing the scheduler to give them more weight.
Pod affinity and anti-affinity: when Pod coexistence (or non-coexistence) with other Pods on the same node is essential, you can use this method. Pod affinity allows a Pod to require that it gets deployed on nodes that have Pods with specific labels running. Similarly, a Pod may force the scheduler not to place it on nodes having Pods with particular labels.
Taints and tolerations: in this method, instead of deciding which nodes the Pod gets scheduled to, you decide which nodes should not accept any Pods at all or only selected Pods. By tainting a node, you're instructing the scheduler not to consider this node for any Pod placement except if the Pod tolerates the taint. The toleration consists of a key, value, and the effect of the taint. Using an operator, you can decide whether the entire taint must match the toleration for a successful Pod placement or only a subset of the data must match.

As per k8s documentaions:
1. NodeName is the simplest form of node selection constraint, but due to its limitations it is typically not used.
Some of the limitations of using nodeName to select nodes are:

If the named node does not exist, the pod will not be run, and in some cases may be automatically deleted.
If the named node does not have the resources to accommodate the pod, the pod will fail and its reason will indicate why, e.g. OutOfmemory or OutOfcpu.
Node names in cloud environments are not always predictable or stable.

2. The affinity/anti-affinity feature, greatly expands the types of constraints you can express. The key enhancements are:
- the language is more expressive (not just "AND of exact match")
- you can indicate that the rule is "soft"/"preference" rather than a hard requirement, so if the scheduler can't satisfy it, the pod will still be scheduled
- you can constrain against labels on other pods running on the node (or other topological domain), rather than against labels on the node itself, which allows rules about which pods can and cannot be co-located
The affinity feature consists of two types of affinity, node affinity and inter-pod affinity/anti-affinity. Node affinity is like the existing nodeSelector (but with the first two benefits listed above),

There are currently two types of pod affinity and anti-affinity, called requiredDuringSchedulingIgnoredDuringExecution and preferredDuringSchedulingIgnoredDuringExecution which denote "hard" vs. "soft" requirements.

Hope this help.
Additional resources:

Affinity and anti-affinity
scheduler Performance Tuning
Making Sense of Taints and Tolerations in Kubernetes
Kubernetes Taints and Tolerations PreferNoSchedule
Comment: Ooh apologies, I never saw your answer for some reason... Thanks, that's a really nice one!


Toggle button font color and drawableft selector

Question: Xamarin, android.
I made a selector which changes background colors:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_checked="false">
    <shape>
      <solid
          android:color="#aaaaac"/>

      <corners
          android:radius="6dp" />
      <padding
          android:left="5dp"
          android:top="5dp"
          android:right="5dp"
          android:bottom="5dp" />
    </shape>
    <drawable
      drawableLeft="@drawable/male"/>
  </item>
  <item android:state_checked="true">
    <shape>

      <solid
          android:color="#357fca" />

      <corners
          android:radius="6dp" />
      <padding
          android:left="5dp"
          android:top="5dp"
          android:right="5dp"
          android:bottom="5dp" />
    </shape>
    <drawable
          drawableLeft="@drawable/male_pushed"/>
  </item>
</selector>

Besides that, I also want to change drawableft and text colors as follows.
If - android:state_checked="false"
then
android:textColor="#000000" and  android:drawableLeft="@drawable/male"
if - android:state_checked="true"
then android:textColor="#ffffff" and
android:drawableLeft="@drawable/male_pushed"

How to do this?
Answer: You can't set multiple properties like drawableLeft, textColor etc using Single selector. You should create selector for each attributes.
Create

drawable_left_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="false" android:drawable="@drawable/male"/>
    <item android:state_checked="true" android:drawable="@drawable/male_pushed"/>
</selector>

text_color_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="false" android:color="#000000"/>
    <item android:state_checked="true" android:color="#ffffff"/>
</selector>

toggle_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="false">
        <shape>
            <solid android:color="#aaaaac"/>
            <corners android:radius="6dp" />
            <padding
                android:left="5dp"
                android:top="5dp"
                android:right="5dp"
                android:bottom="5dp" />
       </shape>
    </item>
    <item android:state_checked="true">
        <shape>

            <solid android:color="#357fca" />
            <corners android:radius="6dp" />
            <padding
                android:left="5dp"
                android:top="5dp"
                android:right="5dp"
                android:bottom="5dp" />
        </shape>
    </item>
</selector>

Set ToggleButton
<ToggleButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/toggle_selector"
    android:drawableLeft="@drawable/drawable_left_selector"
    android:textColor="@drawable/text_color_selector" />


fechar alertdialog aberto com inflate

Question: Tenho um projeto com uma caixa de dialogo aberta com um inflate dando a opção do usuário digitar um texto para assim mudar o valor de uma String.
Estou tendo problemas para fechar essa caixa e voltar ao layout anterior.
<code>public class Calendario extends Activity {
    AlertDialog.Builder alert = new AlertDialog.Builder(Calendario.this);
    String Txt = "Digite sua mensagem";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate( savedInstanceState );
    setContentView( R.layout.calendario );

Txtmessage = (TextView)  findViewById( R.id.EdtMensagemCalendar );
Txtmessage.setText( Txt );

Txtmessage.setOnClickListener( new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            View v1 = getLayoutInflater().inflate(R.layout.edit, null);
            alert.setView(v1);
            alert.create();
            Edt = (EditText)  findViewById( R.id.EdtM );
            alert.show();

        }

    } );
</code>
o projeto carrega o layout edit dentro da caixa de dialogo corretamente, mas preciso que depois que o usuário digite a mensagem pedida que a caixa de dialogo feche voltando ao layout anterior e fornecendo novo valor ao EditText.
Comment: Obrigado.  Eu usei um inflate porque queria que a caixa de diálogo tivesse um editText, resolvi o problema usando um positivebutton "ok", era o que precisava para fachar o inflate e obter o valor editText.  Não sei por mais não estava conseguindo usar o dismiss, dava erro. Obrigado
Comment: No Edt você precisa colocar -> EditText Edt = (EditText)  v1.findViewById( R.id.EdtM );
pois o edt esta na view inflada v1, caso contrario vai dar nullpointer
Answer: Você pode fazer o seguinte:
Abrir a caixa de diálogo, e ao clicar no botão OK da caixa do diálogo pegar o texto introduzido, colocá-lo na tal String e fechar a caixa.
Crie um Listener para a caixa de diálogo e sete ela para o botão "OK".
Esse Listener pode fazer isso:
<code>        String str = Edt.getText().toString(); //Pegar a String da caixa de diálogo
        alert.dismiss //fechar a caixa de diálogo
</code>

fechar alertdialog aberto com inflate


Get all Related Products which are not available in Related Product Table?

Question: Let's say i have Product and RelatedProduct tables,
Product
------
ID
Name

RelatedProduct
--------------
ID
ProductID
RelatedProductID
RelatedProductName

Now I a @ProductID parameter. I need to get all products which are not already added in RelatedProduct table. So, if I have
Product
-----------
ID     Name
 1      A1
 2      A2
 3      A3
 4      A4

RelatedProduct
-----------------------------------------
ID     Name   ProductID    RelatedProductID
 1      B1       2             1
 2      B2       4             3
 3      B3       2             4

If @ProductID =1, then I need Product's 2,3,4. If @ProductID = 2, then I need Product's 3. If @ProductID = 4, then I need Product's 1,2.
Comment: how are the tables related with each other?
Comment: @JW, simply RelatedProduct.ProductID and RelatedProduct.RelatedProductID always belong to Product.ID
Answer: select *
from    Product
where   id not in
  (select RelatedProductID
   from   RelatedProduct
   where  productID = @productID)

NOTE: if product 1 is related to product 2, is product 2 then also related to product 1? Your examples explicitly say no, but often this kind of relationship is bi-directional.
Comment: I am testing thanks, but I think you are missing union select @productID


Thead absolute com scrum lateral

Question: Olá, estou com um problema em uma tabela que é muito extensa na horizontal e vertical. Preciso que os títulos acompanhem os dados até o final na rolagem vertical e horizontal e também preciso que os títulos acompanhem os dados na rolagem fora da div da tabela.
Encontrei algo parecido aqui no fórum, porém não permite a rolagem fora da Div da tabela. segue o link: http://jsfiddle.net/mathijsflietstra/X2Kmd/1/
Quem puder ajudar agradeço muito..
Comment: Não entendi essa parte "preciso que os títulos acompanhem os dados na rolagem fora da div da tabela." e qual o problema do exemplo do link, por que ele não te atende?
Comment: Obrigado pela resposta. Tentarei ser mais claro. No exemplo que mandei, o thead da table fica parado junto com o view port e o que se move na rolagem horizontal e vertical  é o tbody.  Eu preciso que haja uma rolagem fora do tbody.
Comment: Olha esse exemplo usando Bootstrap veja se é isso que precisa https://pt.stackoverflow.com/questions/329027/thead-com-topo-fixo-table/329048#329048 aqui tem outro modelo https://pt.stackoverflow.com/questions/44546/fixar-primeira-linha-tabela/329101#329101
Comment: É quase isso mais. Eu preciso que a barra de rolagem da direita também se movimente e que o thead continue acompanhando os dados.
Comment: Vc tem algum exemplo de alguma tabela que funcione do jeito que vc quer? Tem algum link de exemplo
Comment: Gostaria muito mais anda não consegui encontrar.
Comment: O mais próximo que encontrei foi este plugin : https://tympanus.net/Tutorials/StickyTableHeaders/
Answer: Resolvi o meu problema utilizando este pluguin jquery: https://www.jqueryscript.net/table/Freeze-Table-Thead-At-Top-jQuery.html

Thead absolute com scrum lateral


How to stop the loop when "Q" or "q" is entered

Question: The code seems to continue running even after inputting Q or q. I know we need to break it from the loop but when I keep it inside the main function the output seems to be both
"Thank you for using the program!"
"Invalid Input, Please Enter 1-2-Q for the desired action to be performed"
when I enter Q
def main():
    count = True
    while count == True:
        print("1 - Chemical formula for the Ionic Compound")
        print("2 - Chemical Name for the Ionic Compound")
        print("Q - EXIT")
        print("-----------------------------------------------")
        action = input("What action would you like to execute? ")
        menu(action)

def menu(action):
    if action == "1":
        print()
        e1 = input("Enter chemical symbol for first element: ")
        c1 = int(input("Enter the first element charge: "))
        e2 = input("Enter chemical symbol for second element: ")
        c2 = int(input("Enter the second element charge: "))
        print()
        print(chemistry.ionicCompound(e1, c1, e2, c2))
    elif action == "2":
        print()
        e1 = input("Enter chemical symbol for first element: ")
        e2 = input("Enter chemical symbol for second element: ")
        print(chemistry.ionicName(e1, e2))
    elif action == "Q" or action == "q":
        print()
        print("Thank you for using the program!")
    else:
        print()
        print("Invalid Input, Please Enter 1-2-Q for the desired action to be performed")
        print()
    print("----------------------------------------------------------------------------------")
main()

Comment: But you never break the loop.
Comment: You need to do something to stop the loop if your input is `q`. How can you stop the loop? By using `break` or by falsifying the loop condition. `count== True` (side note: you don't need to do `count == True`, just `count` will suffice if `count` is a boolean). What can you do from inside the `menu` function that will give some information about whether the loop needs to be broken to a caller outside the function?
Answer: Try this:
RUNNING = True

def main():
    count = True
    while count == True and RUNNING:
        print("1 - Chemical formula for the Ionic Compound")
        print("2 - Chemical Name for the Ionic Compound")
        print("Q - EXIT")
        print("-----------------------------------------------")
        action = input("What action would you like to execute? ")
        menu(action)

def menu(action):
    global RUNNING
    if action == "1":
        print()
        e1 = input("Enter chemical symbol for first element: ")
        c1 = int(input("Enter the first element charge: "))
        e2 = input("Enter chemical symbol for second element: ")
        c2 = int(input("Enter the second element charge: "))
        print()
        print(chemistry.ionicCompound(e1, c1, e2, c2))
    elif action == "2":
        print()
        e1 = input("Enter chemical symbol for first element: ")
        e2 = input("Enter chemical symbol for second element: ")
        print(chemistry.ionicName(e1, e2))
    elif action == "Q" or action == "q":
        print()
        print("Thank you for using the program!")
        RUNNING = False
    else:
        print()
        print("Invalid Input, Please Enter 1-2-Q for the desired action to be performed")
        print()
    print("----------------------------------------------------------------------------------")
main()


Question about a particular property of sheaves

Question: Let $F$ be a Hausdorff topological field. Let us require all algebras to be associative commutative unital, and algebra morphisms to be unital.
Let us say a sheaf $\mathcal{O}$ of $F$-algebras on a topological space $X$ has property $\mathcal{P}$
if:
for every open $U\subset X$ and $x \in U$ and $f \in \mathcal{O}(U)$,
there exists a unique $\lambda \in F$
satisfying the property that $f-\lambda$ is non-invertible when restricted to any open neighborhood of $x$ (contained in $U$).

Could anyone help me verify if the following proof is correct?
Claim: the sheaf of continuous $F$-valued functions on $X$ has property $\mathcal{P}$.
Proof: Given $U,f,x$ as above;
Existence: let $\lambda = f(x)$; then $f-\lambda$, restricted to any open neighborhood of $x$, has a zero at $x$ and therefore cannot be invertible.
Uniqueness: suppose $\alpha \in F$ is such that $f-\alpha$ is non-invertible in any neighborhood of $x$; it follows that $f-\alpha$ has a zero in any neighborhood of $x$; thus $x$ is a limit point of $f^{-1}(\{\alpha\})$, but the latter is closed since $f$ is continuous and $F$ is Hausdorff, hence $x \in f^{-1}(\{\alpha\})$, hence $\alpha = f(x)$.

Edit: generalized from $\mathbb{R}$ to any Hausdorff topological field $F$.
Edit: as pointed out below, more generally $F$ need only be $T_1$ (which is weaker than Hausdorff), i.e. all its points are closed.
Answer: Your proof looks correct - in fact, we only need the field's topology to be $T_1$.
Existence proceeds exactly as you described. For uniqueness, consider some $\beta \neq f(x)$. Then let $V = f^{-1}(F \setminus \{\beta\})$, which is open since $F$ is $T_1$ and $f$ is continuous. Then $f - \beta$ is nonzero everywhere on $V$, hence invertible there. And $x \in V$.


Is Drupal secure?

Question: I want to respond to this:

"Drupal is listed as limited use, not generally available because of the licensing and security issues related to various modules that people want to use."

I have two questions:

Is Drupal less secure than other web solutions?
Can contributed modules (i.e. modules that are accepted into the Drupal community) make Drupal less secure?
Comment: 1.. No.  2.. Yes.
Answer: I'll start with your second question, "do contributed modules make Drupal less secure?"
In general, yes, because contributed modules expand the attack surface of your site. When a module provides user interaction features it's another point an attacker could probe for exploits on your site. Additionally that module becomes another dependency in your system and that affects site maintenance and agility.
Now, not all contributed modules are the same, they don't all provide user-facing functionality, but the point is that most every additional module has to be balanced with the possible risks that come along, including possible vulnerabilities.
Also, Gareth Parker correctly highlights that contributed modules undergo far less peer-review and testing than Drupal core, so there could be greater likelihood of security risks in the code. Again, it depends on the modules.
As for your first and main question, "is Drupal secure?". As one of the authors of the Drupal Security Report which attempts to answer this question by analyzing Drupal's published Security Advisories as well as describing how Drupal addresses the OWASP Top 10, I would say "yes" :) Full disclosure, I'm also a member of the Drupal security team.
However, there will be vulnerabilities found in Drupal in the future, it's not secure in that it's immune to risk. It's secure in that it's been both professionally reviewed by security firms and peer-reviewed by thousands of contributors during its development. Additionally, core APIs are strong, providing security mitigation techniques and tools, and many of the default configurations are secure.
Answer: Drupal Core itself is fairly secure as long as you keep it up to date. There's no way to say that it's perfect, but I wouldn't worry about security
Drupal Modules on the other hand are written by average people who simply want a piece of functionality, create it and then share it. Some projects have many people working on it, some have only one. These modules aren't checked by any kind of Drupal Team for security problems, so it's mainly on the people who make and contribute to them to make sure that it's all secure
Knowing that, it's easy to determine that some modules would be secure, some wouldn't, and it really varies from module to module. So in a long, roundabout way, yes, the modules can make drupal less secure
Comment: For new project contributions to drupal.org there is a small amount of security review that happens. The project application process (documented at https://drupal.org/node/1011698) contains some automated security analysis tools. Additionally manual peer review often happens as part of the application process.
Comment: I stand corrected
Answer: In my opinion drupal is secure in the general sense but like any other system there are, sometimes, security issues. However, Drupal has a large community and is opensource so the code is examined over and over by a large number of developers. When security issues are found, they're reported and made public so you can take precautionary measures until a patch is available.
You can check the following security advisory to get an idea how often security issues surface. I advise you to bookmark this page.
Comment: A minor correction, security issues are not made public when found. Issues are only public when there's an accompanying Security Advisory and new release of the software. Security issues should be communicated privately to the Drupal security team. This process is documented here https://drupal.org/security-team

Is Drupal secure?


ffmpeg to ffserver works, but cannot view

Question: I have a generic windows webcam that I am trying to broadcast
ffmpeg -f vfwcap -I 0 -vcodedc libx264 -tune zerolatency-b 900k -f mpegts udp://domain.com:8090

which appears error free.
I can see plenty of traffic using tcpdump on port 8090
ffserver is configure on a FreeBSD server with no firewall configured
# cat /usr/local/etc/ffserver.conf| egrep -v "(^#.*|^$)"
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000
CustomLog -
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 200K
ACL allow 184.108.40.206
</Feed>
<Stream test1.mpg>
Feed feed1.ffm
Format mpeg
AudioBitRate 32
AudioChannels 1
AudioSampleRate 44100
VideoBitRate 64
VideoBufferSize 40
VideoFrameRate 3
VideoSize 160x128
VideoGopSize 12
ACL ALLOW all
</Stream>
<Stream test.asf>
Feed feed1.ffm
Format asf
VideoFrameRate 15
VideoSize 352x240
VideoBitRate 256
VideoBufferSize 40
VideoGopSize 30
AudioBitRate 64
StartSendOnKey
</Stream>
<Stream test1-rtsp.mpg>
Format rtp
File "/tmp/feed1.ffm"
</Stream>
<Stream stat.html>
Format status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255 22.214.171.124 0.0.0.0
</Stream>
<Redirect index.html>
URL http://www.ffmpeg.org/
</Redirect>

The port is live
# netstat -an|grep 8090
tcp4       0      0 *.8090                 *.*                    LISTEN

But when I try to connect via VLC to the ffserver
rtsp://persiaspalace.us:8090/feed1.ffm

connection fails.
There are no networking issues
How do I configure a webcam broadcast from ffmpeg to ffserver for viewing via VLC (or similar)?
Answer: You need to connect to the stream, not the feed.  The feed is the incoming video.  The stream is the outgoing video.
rtsp://persiaspalace.us:8090/feed1.ffm
needs to be
rtsp://persiaspalace.us:8090/test1.mpg
or
rtsp://persiaspalace.us:8090/test.asf
or
rtsp://persiaspalace.us:8090/test1-rtsp.mpg
Answer: I believe your ports are mixed up. FFserver is using port 8090 for HTTP, RTSP. Set RTSPPort in your FFserver config file and then make sure you're hitting the stream and not the feed (as QA Collective pointed out). Something like:
...
HTTPPort 8090
RTSPPort 5554
...

Make sure the port is available, and then try:
ffplay -loglevel debug "rtsp://persiaspalace.us:5554/test1.mpg"


How to copy a file with filename "+" and rename it?

Question: I have a file named  +13x18_DSC_0800.JPG  on a linux server (Please don't ask me how it got there as I have no idea how it got there). I wish to rename it to 13x18_DSC_0800.JPG. However I have not been able to. When I try to copy it I get ;
# cp \+13x18_DSC_0800.JPG asd.JPG
  cp: cannot stat `+13x18_DSC_0800.JPG': No such file or directory

Here is some more inforamtion ;
#ll
 -rwxrwxrwx  1 ftpuser renko 2798985 2011-10-14 01:12  +13x18_DSC_0800.JPG*

I really don't know what is wrong other than that the plus sign is killing some script.
Some more information ;
#uname -a
Linux server-1 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

Any help would be awesome...
Answer: Often this means there are some non-printing characters in the filename, which you can't see because they're non-printing.
Try ls -la > /tmp/foo then vi -b /tmp/foo to look at all the text.
If that's the case, the easiest way is to handle it via glob, try echo *13x18_DSC_0800* to verify that the glob matches that file (and only that file), then you can do mv *13x18_DSC_0800* newname.jpeg to rename it.
Comment: Or `ls -la | cat -vT`
Comment: @MadHatter I got a "-rwxrwxrwx  1 ftpuser renko 2798985 2011-10-14 01:12  +13x18_DSC_0800.JPG
-rwxrwxrwx  1 ftpuser renko 2567144 2011-10-14 01:12  +13x18_DSC_0848.JPG
"
Comment: @MadHatter Although I haven't been able to resolve this issue without using the joker card i.e. "*". Here is the solution I have been able to find ;

      #cp *DSC_0800* 13x18_DSC_0800.JPG
      #rm *+*

This seems to do the trick... I still wonder why I couldn't do it without using the * ....
Since you reminded me of the * you get the bonus!
Answer: Use
cp "+13x18_DSC_0800.JPG" 13x18_DSC_0800.JPG

Comment: Sorry but no cigar you get a : "cp: cannot stat `+13x18_DSC_0800.JPG': No such file or directory" error
Answer: stupid and simple solution if you want to get rid of just one file - use midnight commander :D
but + sign at the beginning shouldn't be a problem at all ...
    $ touch +13x18_DSC_0800.JPG
    $ mv +13x18_DSC_0800.JPG test.jpg
    $ rm test.jpg

works for me ...
Comment: touch does create an empty file with that name if it does not exist. i was presenting this as an example of it working.
Comment: [edited] actually it did not work... the test.jpg turned out to be a 0 byte file...
Answer: For me
    cp +13x18_DSC_0800.JPG 13x18_DSC_0800.JPG

worked like charm, without any escaping.
Answer: The accepted answer uses globbing and so requires checking only one file matches. If we prepend a path the reference is unique.
touch +plus.file
touch -minus.file
mv ./+plus.file plus.file
mv ./-minus.file minus.file


Falha ao intalar a gem mysql no Linux Manjaro

Question: Faz um tempinho que comecei a brincar com Ruby on Rails no Ubuntu e criei alguns projetinhos.
Atualmente instalei a distro Manjaro e fiz a instalação do ruby e do rails e quero executar o meu projeto criado no Ubuntu, porém estou enfrentando um problema com a gem mysql2.
Ao tentar startar a aplicação "rails s" é apresentado o seguinte erro:

Could not find proper version of railties (4.2.1) in any of the
  sources Run bundle install to install missing gems.

Ao executar o comando bundle install ocorre o seguinte erro:
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
 ERROR: Failed to build gem native extension.
    current directory: /home/wagner/.rvm/gems/ruby-2.3.1/gems/mysql2-0.3.18>>/ext/mysql2
/home/wagner/.rvm/rubies/ruby-2.3.1/bin/ruby -r >./siteconf20160831-4570-57p5rs.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You >may
need configuration options.
Provided configuration options:
 --with-opt-dir
 --without-opt-dir
 --with-opt-include
 --without-opt-include=${opt-dir}/include
 --with-opt-lib
 --without-opt-lib=${opt-dir}/lib
 --with-make-prog
 --without-make-prog
 --srcdir=.
 --curdir
 --ruby=/home/wagner/.rvm/rubies/ruby-2.3.1/bin/$(RUBY_BASE_NAME)
 --with-mysql-dir
 --without-mysql-dir
 --with-mysql-include
 --without-mysql-include=${mysql-dir}/include
 --with-mysql-lib
 --without-mysql-lib=${mysql-dir}/lib
 --with-mysql-config
 --without-mysql-config
 --with-mysql-dir
 --without-mysql-dir
 --with-mysql-include
 --without-mysql-include=${mysql-dir}/include
 --with-mysql-lib
 --without-mysql-lib=${mysql-dir}/lib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-mlib
 --without-mlib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-zlib
 --without-zlib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-socketlib
 --without-socketlib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-nsllib
 --without-nsllib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-mygcclib
 --without-mygcclib
 --with-mysqlclientlib
 --without-mysqlclientlib
To see why this extension failed to compile, please check the mkmf.log >which can be found here:
  /home/wagner/.rvm/gems/ruby-2.3.1/extensions/x86_64-linux/2.3.0>/mysql2-0.3.18/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/wagner/.rvm/gems/ruby-2.3.1/gems/mysql2-0.3.18 for inspection.
Results logged to /home/wagner/.rvm/gems/ruby-2.3.1/extensions/x86_64->linux/2.3.0/mysql2-0.3.18/gem_make.out

No meu gemfile a gem está configurada da seguinte maneira gem 'mysql2', '~> 0.3.18'
Alguém tem ideia do que pode estar errado ?
Muito obrigado pela atenção.
Answer: Olá você precisa instalar as bibliotecas nativas de compilação do MySQL
sudo apt-get install libmysqlclient-dev

Caso você não tenha instalado, instale também o build-essential
sudo apt-get install build-essential

E ai sim, instale a gem do MySQL
gem install mysql2

Comment: Olá, o Manjaro não possui o comando apt-get. No fim de semana quando estiver em casa irei procurar o comando equivalente para o Manjaro .
Obrigado pela dica.
Comment: Nem tive tempo de ver no fim de semana.
Hoje eu procurei e não encontrei os comandos equivalentes para o Manjaro, porém ao pesquisar por mysql no gerenciador de pacotes pacman eu encontrei o pacote libmariadbclient e o instalei. Após isto executei o bundle install e funcionou.
 Obrigado pela ajuda.
Comment: @WagnerRodrigues deu certo?
Comment: A resposta não responde a pergunta.
Answer: No Manjaro e em qualquer outra distribuição baseada em ArchLinux, conforme o comentário do @WagnerRodrigues, é preciso instalar o pacote libmariadbclient com o comando:
pacman -S libmariadbclient

Feito isso, retorne à instalação normal da gem mysql2 e vai funcionar.


Redes Neurais com o pacote "AMORE" - R

Question: Caros colegas,
Eu estou tentando usar o pacote AMORE do R para rodar uma Rede Neural com novas funções de ativação, porém não consegui entender muito bem o manual e consequentemente não consegui implementar a nova função. Enfim, a função que eu quero implementar é a seguinte:
Ordonez
ord <- function(x){
   1-((1+0.5*exp(x))^(-1/0.5))#activation function Aranda-Ordonez
}

DERIVATIVE Ordonez
dord <- function(x){
   ((1+0.5*exp(x))^(-(1+0.5)/0.5))*exp(x)# derivative activation functionao Aranda-Ordonez
}

e a função do R que eu quero usar é esta, a qual eu quero apenas modificar a função do último neurônio output.layer="custom":
select.activation.function(activation.function)

library(AMORE)

P <- matrix(sample(seq(-1,1,length=1000), 1000, replace=FALSE), ncol=1)

target <- P^2

net <- newff(n.neurons=c(1,3,2,1), learning.rate.global=1e-2, momentum.global=0.5,
error.criterium="LMS", Stao=NA, hidden.layer="tansig",
output.layer="custom", method="ADAPTgdwm")
result <- train(net, P, target, error.criterium="LMS", report=TRUE, show.step=100, n.shows=5 )

y <- sim(result$net, P)

Caso alguém já tenha usado ou tenha alguma dica a me dar, fico grato pela ajuda.
Atenciosamente,
Elisalvo
Comment: Vim nessa pergunta só pela carência... :/
Answer: Consegui implementar redes neurais com o pacote neuralnet seguindo esse tutorial: https://www.youtube.com/watch?v=LTg-qP9iGFY&index=3&t=899s&list=PLVbc4TTBBn6nuF3BTQms_y1j7wIV2inkL
Esse pacote me pareceu simples de implementar.
Também tentei o pacote RNNS mas sem sucesso.
Segue também uma lista de tutoriais: https://www.youtube.com/playlist?list=PLVbc4TTBBn6nuF3BTQms_y1j7wIV2inkL
Caso adote o pacote neuralnet e tiver alguma dúvida, poderei te ajudar mais.
O pacote AMORE nunca utilizei.

Redes Neurais com o pacote "AMORE" - R


Is there any continuous surjective map from $\mathbb{R}^3$ to $\mathbb{R}^3$ s.t. for every $x$ in $\mathbb{R}^3$ $f(x) \cdot x= 0$?

Question: Is there any continuous surjective map from $\mathbb{R}^3$ to $\mathbb{R}^3$ such that for every $x$ in $\mathbb{R}^3$,  $f(x)  \cdot x=0$?
What about i replace $\mathbb{R}^3$ to $\mathbb{R}^4$ ?
Comment: It's easy to do in $\mathbf{R}^4$  You can do it with a linear transformation.  Think of a block matrix with two $90^{\circ}$ rotation matrices on the diagonal.  This generalizes to any even number of dimensions.  I suspect you can't do it in an odd number of dimensions, but I can't see why.
Comment: Does $f(x).x$ indicate the dot product?  If so, it would be better to write it as $f(x)\cdot x$ I think.
Comment: @GEdgar I'm trying to deduce it from the [hairy ball theorem](https://en.wikipedia.org/wiki/Hairy_ball_theorem), but I'm hung up on "non-vanishing."  If we could say that there is some sphere $S$ centered at the origin such that $f$ does not vanish on $S$ we'd be done, but why must this be true?
Comment: I would already be interested if you could cook up such a function whose image contains an open set (however small).
Comment: With $f(x,y,z) = (y, -x, 0) + z (0, -z, y) = (y, -x-z^2, yz)$ the image is $\{ (a,b,c) \mid a\ne 0 \vee c=0 \}$ which is dense...
Comment: Hmm... on the other hand, the hairy ball theorem would imply $f(0) = 0$, otherwise $\lVert f(x) \rVert \ne 0$ on a neighborhood of 0 and therefore $f / \lVert f \rVert$ would form a nonvanishing tangent vector field on a sphere of small enough radius.
Comment: yes. i meant dot product
Comment: That there is no **linear** map like that in odd dimensions seems clear.  But non-linear?  Why not?
Comment: @saulspatz The linked wikipedia page sketches the argument.
Comment: @B.Mehta The argument given there doesn't address my difficulty, because it proves that you can't assign a nonzero orthogonal vector.  However, the OP's asks for a surjective function, so the zero vector must be allowed.
Comment: I think the answer is yes.  We can almost get there with $f(x)=x \times \hat z$.  It is continuous and satisfies $f(x)\cdot x=0$.  It is not surjective because nothing has an image that is along the $z$ axis.  I think if we replace $\hat z$ with a unit vector whose direction depends continuously on $|x|$ we can get there, but I don't have the details.
Comment: @RossMillikan: I think it's an exaggeration to say that $f(x)=x\times e_3$ comes close. Its image is only $\mathbb R^2$, which is a far cry from being surjective.
Comment: @MikeMiller: Fix some nonzero vector $a$ and let $f(x)$ be $\|x\|$ times the orthogonal projection of $a$ onto the orthogonal complement of $x$.  If I'm not mistaken, the image will contain the entire half-space whose inner product with $a$ is positive.
Comment: It is clear, that there can not be a map $f: \mathbb{R}^3 \rightarrow \mathbb{R}^3$ f injective, so that $f(x) \cdot x=0$, but surjective? The question is only slightly variated, but it seems difficult.
Comment: @EricWofsey I think if one enumerates a countable dense set of $\Bbb R^3$, and runs a variant on this near the $n$-sphere for each $n$ (damped by some bump function), this should get you surjectivity.
Comment: @MartinErhardt The comments above show why you need $f(x)$ to be zero on every 2-sphere centered at the origin.
Answer: For  $\mathbb{R}^3$ the answer is "yes".
Let us say that a continuous map $f : M \to \mathbb{R}^3$ defined on a subset $M \subset \mathbb{R}^3$ is admissible if $f(x) \cdot x = 0$ for all $x \in M$.
Define the spheric shell  $S^2(r_1,r_2) = \lbrace p \in \mathbb{R}^3 \mid r_1 \le \lVert p \rVert \le r_2 \rbrace$ and $S^2(r) = S^2(r,r)$ = sphere with radius $r$. Note that $S^2(0,r)$ = closed ball with center $0$ and radius $r$.
The reason for the affirmative answer is that we can find a cover $P_i$, $i \in \mathbb{N}$, of $\mathbb{R}^3$ such that each $P_i$ is contained in the image of an admissible map defined on a suitable spheric shell $S_i$.
If we have admissible $f_i : S^2(r_i) \to  \mathbb{R}^3$, then
$$L(f_1,f_2) : S^2(r_1,r_2) \to \mathbb{R}^3, L(f_1,f_2)(p) = \frac{r_2 - \lVert p \rVert}{r_2 - r_1}f_1(r_1 \frac{p}{\lVert p \rVert}) + \frac{\lVert p \rVert - r_1}{r_2 - r_1}f_2(r_2 \frac{p}{\lVert p \rVert})$$
is easily seen to be admissible. In other words, each admissible map defined on the boundary of $S^2(r_1,r_2)$ has an admissible extension to $S^2(r_1,r_2)$.
Let $H_z^{\pm} = \lbrace (x,y,z) \mid sign(z) = \pm 1 \rbrace$ the open halfspaces above and below the $x$-$y$-plane. $H_x^{\pm}, H_y^{\pm}$ are defined similarly.
Now let $S$ denote $S^2$ with north and south pole $(0,0,\pm 1)$ removed. Define a function $\varphi : S \to S^2$ as follows: For each $x \in S$ let $G_x$ be the great circle through $x$ and north and south pole. Let $\varphi(x)$ be the unit tangent vector at the manifold $G_x$ in the point $x$ going in downward direction. $\varphi$ is admissible, but cannot be extended to $S^2$. Define $\phi_z^- : S^2 \to  \mathbb{R}^3$, $\phi_1(0,0,\pm 1) = 0$, $\phi_z^-(x,y,z) = (1-z^2)\varphi(x,y,z)$ for $z \in (-1,1)$. Then $\phi_z^-$ is  admissible. For each $p = (x,y,z) \in S^2$ with $z < 0$ the line through $p$ and $0$ contains a non-zero point of $K_z^- = \phi_z^-(S^2)$.
Define $K_z^-(n) = \lbrace t p \mid p \in K_z^-, t \in [n-1,n] \rbrace$ for $n \in \mathbb{N}$. Then $\bigcup_{n=1}^\infty K_z^-(n) = H_z^- \cup \lbrace 0 \rbrace$.
Similarly we obtain an admissible $\phi_z^+$ and sets $K_z^+(n) \subset H_z^+ \cup \lbrace 0 \rbrace$ with analogous properties. Do the same to obtain the obvious $\phi_x^\pm, \phi_y^\pm$ and  $K_x^\pm(n), K_y^\pm(n)$.
On $S^2(12(n-1),12(n-1)+1)$ define $\phi_z^-(n)(p) = (\lVert p \rVert - 11(n-1)) \phi_z^-(\frac{p}{\lVert p \rVert})$. This is an admissible map such that $K_z^-(n) \subset \phi_z^-(n)(S^2(12(n-1),12(n-1)+1))$. Note that for $n = 1$ we obtain $S^2(12(n-1),12(n-1)+1) = S^2(0,1)$ = closed ball with center $0$ and radius $1$.
On the spheric shells $S^2(12(n-1) + 2,12(n-1)+ 3)$ define $\phi_z^+(n)$ similarly based on $\phi_z^+$. Do the same on $S^2(12(n-1) + 4,12(n-1)+ 5)$ based on $\phi_x^-$, on $S^2(12(n-1) + 6,12(n-1)+ 7)$ based on $\phi_x^+$, on $S^2(12(n-1) + 8,12(n-1)+ 9)$ based on $\phi_y^-$, on $S^2(12(n-1) + 10,12(n-1) + 11)$ based on $\phi_y^+$.
This gives an admissible map $f: \bigcup_{k=1}^\infty S^2(2k-2,2k-1) \to \mathbb{R}^3$ which is surjective by construction.
On the intermediate spheric shells $S^2(2k-1,2k)$, $k \in \mathbb{N}$, use admissible extensions to get an admissible surjective map $F : \mathbb{R}^3 \to \mathbb{R}^3$.
Comment: underrated answer