Choosing a flute for an adult beginner: Open or closed holes?

Question: By looking to various flutes online, I saw that there are two types of flutes:

Open Holes Flutes
Closed Holes Flutes

As an adult beginner, what should be taken into consideration before deciding  which category of flute to buy from?
I can understand that for children, it might be easier to buy a flute with closed holes, because their fingers might not be big enough to cover the holes, but this is not the case here.
Comment: Related: [Beginning to learn the transverse C-flute : with offset-G key or inline-G key?](http://music.stackexchange.com/questions/344/beginning-to-learn-the-transverse-c-flute-with-offset-g-key-or-inline-g-key) + [Choosing the appropriate flute for my preschooler](http://music.stackexchange.com/questions/4712/choosing-the-appropriate-flute-for-my-preschooler)
Answer: When we bought the first flute for our daughter, her teacher recommended open keys and the difference was even hearable for us as uninformed listeners, even if their main purpose is microtonal adjustments in pitch by partial covering. There are two further reasons, which I consider as striking:

You are enforced, to set your fingers carefully and correct from the beginning (otherwise the hole will not be closed properly and intonation will clearly indicate this). Closed keys allow a more sloppy approach.
There are sets of small plugs available (and sometimes even supplied with the flute), which convert open keys into closed ones. (According to my knowledge, their use is only reasonable for children.) The other direction is much more difficult and means exchanging the keys.
Comment: @Shevliaskovic: no, even smallish adult hands will be larger than that of our daughter with 12 years.
Comment: As an adult with full grown fingers, I won't have any trouble covering the holes, right?
Comment: There is nothing wrong with not placing your fingers carefully if you decide that you do not intend to ever go for an open keyed flute! Actually, having the freedom to press the key more "sloppily" may help you develop more agile technique without unnecessary tension. There are so many reasons why a beginner becomes tense even with a closed hole flute! Open keys are really necessary only for contemporary music that cannot be played on a closed keyed flute. In fact, some professional flutists use closed keys.
Answer: Having only experience with open holes, I can't comment on closed. But it seems that the latter are geared towards child beginners. I have pretty small hands (well, not that pretty...) and covering holes has never been a problem. As a fully grown adult, you might as well start as you mean to go on - get an open hole one, and just take care. You'll soon get the message if you're not closing properly. If you're like me, you'll have more trouble with the embouchure than fingering! Good luck. It's one of the more difficult instruments to learn, I think. Carl's price quote seems quite steep. There are lots of pre-owned ones up for grabs, and not a lot to go wrong, unless they've been dropped - but that's the same for most musical instruments.
Comment: If you buy a used instrument directly from an owner, as opposed to a shop, be sure to have it checked out professionally before purchasing it.  Repairing bent or misaligned or frozen components can be expensive.
Answer: A quick look at a couple retail online shops indicates you'll pay (for Yamaha, a good line of starter flutes) around $900 -$1000 for a closed-hole, and maybe $500 more for an open-hole flute.  If the money doesn't bother you, then go with open-hole for the reasons given in other answers and comments.  If you're not sure you are going to play the flute "forever," then you may want to go cheap.
Comment: I'm with you there, Carl. The relative cost is a consideration, no doubt. +1. This little space is for comments, like 'I downvoted because...'.
Answer: I would go with the closed hole flute for two particular reasons. First of all, it is cheaper than the open hole flute. This is easier for you if you decide that you would not like to keep the instrument. Secondly, open hole flutes require a more precise hand position than the closed hole, making it more difficult fingering wise no matter the hand size.
However, the open holed flutes do allow a much more mature tone. And if you feel your fingering is not precise, there are plugs you can buy to close up the holes until your positioning has improved. If you are dedicated to playing the flute then the open hole is a better choice. Most beginners will get a closed hole because they are not sure they will continue playing the instrument.
The basic answer for you can be determined by which of these qualities is more important to you. I hope you enjoy playing the flute as much as I do!
Answer: With a French Horn, a beginners starts on a Single horn and progresses to a Double horn.
The single is cheaper and simpler. A general rule for beginners - especially children - who may very well decide the flute is not for them and take up some other instrument, is to start cheap and simple. As Dr Klee says "most professionals use an open hole Flute". There is your answer. You start simple and progress to the more complex, more expensive instrument with the bigger range and tone as the learner becomes more proficient and can attempt more complex pieces.
Answer: A few more things I want to add are:

With open holes, a flutist can produce a wider range of special effects, which is common in modern music. Like, he can cover only part of the hole and alter the pitch this way.
Closed holes flutes have a bit brighter sound and you can move your fingers around a bit without losing the note, whereas in the closed holes the tone is darker.


How to find the function parameters with some constraint?

Question: In the context of neural networks, I am using a function to increase the difference between "good" accuracies and "bad" accuracies, i.e, for example all accuracies below 0.8 are considered bad and all accuracies above, good.
The function looks as follow:
$$
new\_x(x) = \frac{1}{1+e^{-Ax +B}}
$$
Where $x$ is the accuracy, here is the graph, with A=1 and B=0
My question is the following: how do I find the values of A and B such the function returns high values (close to 1) after $x=0.8$  and very low before $x=0.8$ (close to $0$) ?
I have tried to find it out manually, but I would like to automate the process. I guess the solution involves constraints solving, that is why I tagged it this ways (but feel free to suggest another tag).
Thanks a lot!
Comment: First of all you need $\frac{B}{A}=0.8$ for the curve to change its concavity at $x=0.8$. Then for immediate change in values from $0$ to $1$ at $x=0.8$, you should take large values for $A$ and $B$, the larger, the better. For instance, you can take $A=10000, B=8000$
Comment: Thanks a lot! this is very usefull, if you post the answer I will validate it.
Comment: Would it be possible to also give the theory behind your solution ? (or at least a piece of it)
Comment: I've written the answer consisting the theory. You can check why I suggested those values in the comment by looking at the first derivative and the point of inflection.
Answer: Let $f(x)= \frac{1}{1+e^{-Ax +B}}$. It can be easily noticed that the range of $f$ is $(0,1)$ and for $A>0$, $f$ is strictly increasing and for $A<0, f$ is strictly decreasing.
Now, you want $f(x)$ close to $0$ when $x<0.8$ and $f(x)$ close to $1$ when $x>0.8$. That means three things: first, $A$ should be positive. Second, slope of the $f(x)$ curve should be very large at $x=0.8$. Third, the point where the graph changes its concavity from concave upwards to concave downwards should be $0.8$
You need to find $\{A>0,B\}$ such that $f'(x)_{\text{ at }x=0.8}$ is large and $f''(x)_{\text{at }x=0.8}=0$


About LinearLayoutManager.scrollToPositionWithOffset(int,int)

Question: When I invoke the function moveScrollViews(float) in the FragmentThree.enter(), the application will crash and the logcat has no exception.  But I found that the memory allocated to the application increased from 46MB to 95MB.  If I don't invoke the function, everything is okay. The five RecyclerViews is in a fragment, and the fragment is a part of a ViewPager.  My English is poor, but I'm studying it hard. Hope you understand my question.  Thanks.
This is my Fragment
public class FragmentThree extends BaseFragment{
private View root;
private RecyclerView recycler1;
private RecyclerView recycler2;
private RecyclerView recycler3;
private RecyclerView recycler4;
private RecyclerView recycler5;

private int scrollOffsetX;
private Point sharedElemScrollPoint;
private int finishHeight;
private int finishWidth;

public static FragmentThree newInstance(int position){
    FragmentThree scene = new FragmentThree();

    Bundle args = new Bundle();
    args.putInt(KEY_POSITION, position);
    scene.setArguments(args);

    return scene;
}
@Override
public int getLayoutId() {
    return R.layout.fragment_three;
}

@Override
public void init(View view) {
    root=view.findViewById(R.id.root);
    setRootPositionTag(root);
    if(root==view){
        Log.e("SAME","SAME");
    }

    recycler1=(RecyclerView) view.findViewById(R.id.recycler_1);
    recycler2=(RecyclerView) view.findViewById(R.id.recycler_2);
    recycler3=(RecyclerView) view.findViewById(R.id.recycler_3);
    recycler4=(RecyclerView) view.findViewById(R.id.recycler_4);
    recycler5=(RecyclerView) view.findViewById(R.id.recycler_5);
    setRecyclerView(recycler1,getResources().obtainTypedArray(R.array.images_1));
    setRecyclerView(recycler2,getResources().obtainTypedArray(R.array.images_2));
    setRecyclerView(recycler3,getResources().obtainTypedArray(R.array.images_3));
    setRecyclerView(recycler4,getResources().obtainTypedArray(R.array.images_4));
    setRecyclerView(recycler5,getResources().obtainTypedArray(R.array.images_5));
}

private void setRecyclerView(RecyclerView recyclerView, TypedArray drawables) {
    LinearLayoutManager layoutManager =
            new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);

    recyclerView.setLayoutManager(layoutManager);
    ImageAdapter adapter = new ImageAdapter(drawables);
    recyclerView.setAdapter(adapter);
}

@Override
public void enter(@Nullable ImageView shareElem, float position) {

    if(sharedElemScrollPoint==null){
        setTransition(shareElem);
    }
    root.setAlpha(1-position);
    shareElem.setX(sharedElemScrollPoint.x*(1-position));
    shareElem.setY(-getResources().getDimension(R.dimen.tutorial_shared_element_translate_y)
            + (sharedElemScrollPoint.y * (1 - position)));
    scaleShareImg(shareElem,position);
    setRoundImg(shareElem,position);
    moveScrollViews(position);
}

private void setTransition(ImageView shareElem){
    ImageView finishView=(ImageView)recycler2.getLayoutManager().findViewByPosition(0);
    finishView.setVisibility(View.INVISIBLE);

    finishWidth=finishView.getWidth();
    finishHeight=finishView.getHeight();

    Point finishLocation= ViewHelper.getViewLocation(finishView);
    // find the point of the screen(middle - half image) and for final point to be centered
    int screenCenterX = ViewHelper.getDisplaySize(getActivity()).x / 2;
    int finishWidth = finishView.getWidth() / 2;
    int finishX = screenCenterX - finishWidth;

    scrollOffsetX=finishX - finishLocation.x;

    Point sharedPoint=ViewHelper.getViewLocation(shareElem);
    sharedElemScrollPoint=new Point();
    sharedElemScrollPoint.x=finishX - sharedPoint.x;
    sharedElemScrollPoint.y=finishLocation.y - sharedPoint.y;
}

private void scaleShareImg(ImageView sharedElement,float position){
    float scaleX = 1 - ((float) finishWidth / sharedElement.getWidth());
    float scaleY = 1 - ((float) finishHeight / sharedElement.getHeight());

    // scale around the center
    sharedElement.setPivotX(1.0f);
    sharedElement.setPivotY(1.0f);

    // scale the shared image to the finish views size
    sharedElement.setScaleX((1 - (scaleX * (1 - position))));
    sharedElement.setScaleY((1 - (scaleY * (1 - position))));
}

@Override
public void center(@Nullable ImageView shareElem, float position) {
    root.setAlpha(1f);
    shareElem.setX(sharedElemScrollPoint.x);
    shareElem.setY(-getResources().getDimension(R.dimen.tutorial_shared_element_translate_y)
            + sharedElemScrollPoint.y);
    scaleShareImg(shareElem,0);
    setRoundImg(shareElem, 0);
    //moveScrollViews(0);
}

@Override
public void exit(@Nullable ImageView shareElem, float position) {
}

@Override
public void notInScene() {
    //moveScrollViews(1.0f);
    root.setAlpha(0f);
}

private void moveScrollViews(float position){
    int scroll = (int) (scrollOffsetX * (1 - position) + 200);
    scrollRecyclerViewTo(recycler1,-scroll);
    scrollRecyclerViewTo(recycler2,scroll);
    scrollRecyclerViewTo(recycler3,-scroll);
    scrollRecyclerViewTo(recycler4,scroll);
    scrollRecyclerViewTo(recycler5,-scroll);

}
private void scrollRecyclerViewTo(RecyclerView recycler,int offset){
    LinearLayoutManager linearLayoutManager=(LinearLayoutManager) recycler.getLayoutManager();
    linearLayoutManager.scrollToPositionWithOffset(2,offset);
    Log.e("Scroo","Scroll"+offset);

}
}

This is my ViewPager.PageTransformer
public class IntroTransformer implements ViewPager.PageTransformer{
private List<TransformerListener> listeners=new ArrayList<>();
private ImageView shareElem=null;
@Override
public void transformPage(View page, float position) {
    page.setTranslationX(page.getWidth() * -position);

    int tag=(int)page.getTag();
    if(tag==0 && shareElem==null) {
        shareElem = (ImageView) page.findViewWithTag("shared_element");
    }
    makeCallback(listeners.get(tag),position);
}

private void makeCallback(TransformerListener listener,float position){
    if(enter(position)){
        listener.enter(shareElem,position);
    }else if(exit(position)){
        listener.exit(shareElem,position);
    }else if(center(position)){
        listener.center(shareElem,position);
    }else if(notInScene(position)){
        listener.notInScene();
    }
}
public void addPageTransformerListener(TransformerListener listener){
    listeners.add(listener);
}

public boolean enter(float position){return position>0f && position<1f;}
public boolean exit(float position){return position>-1f && position<0f;}
public boolean center(float position){return position==0f;}
public boolean notInScene(float position){return position<=-1f || position>=1f;}
}

Here is my logcat.
    11-16 13:48:30.019 17293-17293/? I/art: Late-enabling -Xcheck:jni
    11-16 13:48:30.035 17293-17299/? E/art: Failed sending reply to debugger: Broken pipe
    11-16 13:48:30.035 17293-17299/? I/art: Debugger is no longer active
    11-16 13:48:30.072 17293-17293/? W/System: ClassLoader referenced unknown path: /data/app/com.jsnu.newpractice-2/lib/arm64
    11-16 13:48:30.074 17293-17293/? I/InstantRun: Instant Run Runtime started. Android package is com.jsnu.newpractice, real application class is com.jsnu.newpractice.MyApplication.
    11-16 13:48:30.241 17293-17293/? W/System: ClassLoader referenced unknown path: /data/app/com.jsnu.newpractice-2/lib/arm64
    11-16 13:48:30.337 17293-17293/? I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl
    11-16 13:48:30.380 17293-17293/? W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
    11-16 13:48:30.597 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.597 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=750, h=750, format=0x1, usage=0x2000003
    11-16 13:48:30.598 17293-17293/? I/gralloc: Alloc handle(0x7f85ca8b00): interfmt=0x1, stride=768, size=2310144
    11-16 13:48:30.608 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=2250, h=2250, format=0x1, usage=0x2000003
    11-16 13:48:30.615 17293-17293/? I/gralloc: Alloc handle(0x7f8c3a8800): interfmt=0x1, stride=2304, size=20754432
    11-16 13:48:30.650 17293-17293/? I/gralloc: Free handle(0x7f8c3a8800)
    11-16 13:48:30.650 17293-17293/? I/gralloc: Free handle(0x7f85ca8b00)
    11-16 13:48:30.657 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.657 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=750, h=750, format=0x1, usage=0x2000003
    11-16 13:48:30.658 17293-17293/? I/gralloc: Alloc handle(0x7f8c38af00): interfmt=0x1, stride=768, size=2310144
    11-16 13:48:30.668 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=2250, h=2250, format=0x1, usage=0x2000003
    11-16 13:48:30.674 17293-17293/? I/gralloc: Alloc handle(0x7f7367e000): interfmt=0x1, stride=2304, size=20754432
    11-16 13:48:30.709 17293-17293/? I/gralloc: Free handle(0x7f7367e000)
    11-16 13:48:30.709 17293-17293/? I/gralloc: Free handle(0x7f8c38af00)
    11-16 13:48:30.846 17293-17316/? I/OpenGLRenderer: Initialized EGL, version 1.4
    11-16 13:48:30.866 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.866 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:30.867 17293-17293/? I/gralloc: Alloc handle(0x7f735fe400): interfmt=0x1, stride=384, size=339968
    11-16 13:48:30.870 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:30.871 17293-17293/? I/gralloc: Alloc handle(0x7f735fe600): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:30.878 17293-17293/? I/gralloc: Free handle(0x7f735fe600)
    11-16 13:48:30.878 17293-17293/? I/gralloc: Free handle(0x7f735fe400)
    11-16 13:48:30.880 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.880 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:30.880 17293-17293/? I/gralloc: Alloc handle(0x7f735fe500): interfmt=0x1, stride=384, size=339968
    11-16 13:48:30.883 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:30.885 17293-17293/? I/gralloc: Alloc handle(0x7f735fe700): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:30.892 17293-17293/? I/gralloc: Free handle(0x7f735fe700)
    11-16 13:48:30.892 17293-17293/? I/gralloc: Free handle(0x7f735fe500)
    11-16 13:48:30.894 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.894 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:30.894 17293-17293/? I/gralloc: Alloc handle(0x7f735fe600): interfmt=0x1, stride=384, size=339968
    11-16 13:48:30.896 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:30.898 17293-17293/? I/gralloc: Alloc handle(0x7f735fe800): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:30.905 17293-17293/? I/gralloc: Free handle(0x7f735fe800)
    11-16 13:48:30.905 17293-17293/? I/gralloc: Free handle(0x7f735fe600)
    11-16 13:48:30.907 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.907 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:30.907 17293-17293/? I/gralloc: Alloc handle(0x7f735fe800): interfmt=0x1, stride=384, size=339968
    11-16 13:48:30.910 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:30.911 17293-17293/? I/gralloc: Alloc handle(0x7f735fea00): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:30.918 17293-17293/? I/gralloc: Free handle(0x7f735fea00)
    11-16 13:48:30.918 17293-17293/? I/gralloc: Free handle(0x7f735fe800)
    11-16 13:48:30.920 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.921 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:30.921 17293-17293/? I/gralloc: Alloc handle(0x7f735fea00): interfmt=0x1, stride=384, size=339968
    11-16 13:48:30.923 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:30.925 17293-17293/? I/gralloc: Alloc handle(0x7f735fec00): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:30.932 17293-17293/? I/gralloc: Free handle(0x7f735fec00)
    11-16 13:48:30.932 17293-17293/? I/gralloc: Free handle(0x7f735fea00)
    11-16 13:48:30.934 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.934 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:30.934 17293-17293/? I/gralloc: Alloc handle(0x7f735fec00): interfmt=0x1, stride=384, size=339968
    11-16 13:48:30.937 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:30.938 17293-17293/? I/gralloc: Alloc handle(0x7f735fee00): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:30.945 17293-17293/? I/gralloc: Free handle(0x7f735fee00)
    11-16 13:48:30.945 17293-17293/? I/gralloc: Free handle(0x7f735fec00)
    11-16 13:48:30.949 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.949 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:30.949 17293-17293/? I/gralloc: Alloc handle(0x7f85dff000): interfmt=0x1, stride=384, size=339968
    11-16 13:48:30.952 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:30.953 17293-17293/? I/gralloc: Alloc handle(0x7f85dff200): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:30.959 17293-17293/? I/gralloc: Free handle(0x7f85dff200)
    11-16 13:48:30.960 17293-17293/? I/gralloc: Free handle(0x7f85dff000)
    11-16 13:48:30.962 17293-17293/? I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:30.962 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:30.963 17293-17293/? I/gralloc: Alloc handle(0x7f85dff200): interfmt=0x1, stride=384, size=339968
    11-16 13:48:30.965 17293-17293/? I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:30.966 17293-17293/? I/gralloc: Alloc handle(0x7f85dff400): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:30.973 17293-17293/? I/gralloc: Free handle(0x7f85dff400)
    11-16 13:48:30.973 17293-17293/? I/gralloc: Free handle(0x7f85dff200)
    11-16 13:48:30.979 17293-17293/? W/View: requestLayout() improperly called by android.support.v7.widget.AppCompatImageView{e9167dc V.ED..... ......ID 0,0-708,708 #7f0c005a app:id/sharedImage} during layout: running second layout pass
    11-16 13:48:35.626 17293-17293/com.jsnu.newpractice I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:35.626 17293-17293/com.jsnu.newpractice I/gralloc: Alloc         req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:35.626 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f7164da00): interfmt=0x1, stride=384, size=339968
    11-16 13:48:35.629 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:35.630 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f7164dc00): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:35.640 17293-17293/com.jsnu.newpractice I/gralloc: Free         handle(0x7f7164dc00)
    11-16 13:48:35.640 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f7164da00)
    11-16 13:48:35.652 17293-17293/com.jsnu.newpractice I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:35.652 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=750, h=750, format=0x1, usage=0x2000003
    11-16 13:48:35.653 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f7164dc00): interfmt=0x1, stride=768, size=2310144
    11-16 13:48:35.667 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=2250, h=2250, format=0x1, usage=0x2000003
    11-16 13:48:35.675 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f7164de00): interfmt=0x1, stride=2304, size=20754432
    11-16 13:48:35.721 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f7164de00)
    11-16 13:48:35.721 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f7164dc00)
    11-16 13:48:35.723 17293-17293/com.jsnu.newpractice I/BitmapFactory:         set decoder allocator to gralloc
    11-16 13:48:35.723 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:35.724 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f7164dd00): interfmt=0x1, stride=384, size=339968
    11-16 13:48:35.726 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:35.727 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f7164df00): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:35.734 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f7164df00)
    11-16 13:48:35.734 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f7164dd00)
    11-16 13:48:35.737 17293-17293/com.jsnu.newpractice I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:35.737 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:35.737 17293-17293/com.jsnu.newpractice I/gralloc: Alloc         handle(0x7f7164df00): interfmt=0x1, stride=384, size=339968
    11-16 13:48:35.744 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:35.745 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f709a4100): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:35.752 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f709a4100)
    11-16 13:48:35.753 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f7164df00)
    11-16 13:48:35.754 17293-17293/com.jsnu.newpractice I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:35.754 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:35.755 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f709a4000): interfmt=0x1, stride=384, size=339968
    11-16 13:48:35.758 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:35.759 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f709a4200): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:35.766 17293-17293/com.jsnu.newpractice I/gralloc: Free         handle(0x7f709a4200)
    11-16 13:48:35.766 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f709a4000)
    11-16 13:48:35.768 17293-17293/com.jsnu.newpractice I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:35.769 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:35.769 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f709a4100): interfmt=0x1, stride=384, size=339968
    11-16 13:48:35.771 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:35.772 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f709a4300): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:35.778 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f709a4300)
    11-16 13:48:35.779 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f709a4100)
    11-16 13:48:35.783 17293-17293/com.jsnu.newpractice I/BitmapFactory: set decoder allocator to gralloc
    11-16 13:48:35.783 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=330, h=220, format=0x1, usage=0x2000003
    11-16 13:48:35.783 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f709a4400): interfmt=0x1, stride=384, size=339968
    11-16 13:48:35.785 17293-17293/com.jsnu.newpractice I/gralloc: Alloc req: dev=0x7f8c1cb880, w=990, h=660, format=0x1, usage=0x2000003
    11-16 13:48:35.786 17293-17293/com.jsnu.newpractice I/gralloc: Alloc handle(0x7f709a4600): interfmt=0x1, stride=1024, size=2703360
    11-16 13:48:35.793 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f709a4600)
    11-16 13:48:35.793 17293-17293/com.jsnu.newpractice I/gralloc: Free handle(0x7f709a4400)
    11-16 13:48:35.801 17293-17303/com.jsnu.newpractice I/art: GC statistics: 19 time(s), freed 22206(22MB) objects, paused 6.407ms total 151.611ms

Comment: Please post logcat.
Comment: I post my logcat.Could you look at it
Comment: the problem is the manipulation of the images that require a lot of memory (see enter function). Why are you applying animation manually and without using android's transitions?
Answer: Try to add
android:largeHeap="true"

into your Manifest application tag
Comment: This will just increase your memory space at runtime
Comment: Your error might be occur due to sudden large increase in memory
Comment: Bue why the demo has no problem like this?
Comment: May be because you demo does not have this issue and use device to test with large memory available
Comment: But I use my device to test mine and the demo.


403 forbidden on Apache after trying to install nginx reverse proxy

Question: My setup:
Digital Ocean droplet running Debian 8
2 websites with each their domain running on Apache2
Tried installing nginx and configure it as a reverse proxy following these instructions:
https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-web-server-and-reverse-proxy-for-apache-on-one-ubuntu-14-04-droplet
It instantly broke my sites, giving Forbidden 403 error when trying to access them.
I spent so many hours trying to make it work and now decided to leave it and just use Apache2 like i did before.
But now the sites are still showing Forbidden 403 even after nginx is stopped.
Briefly installed lighttpd + lighttpd php5-cgi and then i could access the sites, however, it was showing just 1 site on both domains.
I have chown -R www-data:www-data /var/www
Also did a chmod -R 755 /var/www
Please, if anyone could provide some input, I would be so happy. I am going crazy trying to fix this mess. :(
Apache ports.conf:
Listen 80

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

Sample from Apache error log:
[Thu Mar 03 13:56:36.965194 2016] [authz_core:error] [pid 31517] [client 18.104.22.168:55470] AH01630: client denied by server configuration: /var/www/html/xmlrpc.php
[Thu Mar 03 13:56:43.316074 2016] [authz_core:error] [pid 31518] [client 126.96.36.199:52484] AH01630: client denied by server configuration: /var/www/html/xmlrpc.php
[Thu Mar 03 13:56:47.635774 2016] [authz_core:error] [pid 31496] [client 22.214.171.124:53967] AH01630: client denied by server configuration: /var/www/html/xmlrpc.php
[Thu Mar 03 13:57:00.853631 2016] [authz_core:error] [pid 31670] [client 188.8.131.52:50494] AH01630: client denied by server configuration: /var/www/html/xmlrpc.php
[Thu Mar 03 13:57:08.455024 2016] [authz_core:error] [pid 31668] [client 126.96.36.199:45464] AH01630: client denied by server configuration: /var/www/html/xmlrpc.php
[Thu Mar 03 13:57:21.641599 2016] [authz_core:error] [pid 31517] [client 188.8.131.52:38106] AH01630: client denied by server configuration: /var/www/html/xmlrpc.php
[Thu Mar 03 13:57:28.132631 2016] [authz_core:error] [pid 31518] [client 188.8.131.52:48468] AH01630: client denied by server configuration: /var/www/html/xmlrpc.php

apache2.conf:
Mutex file:${APACHE_LOCK_DIR} default

PidFile ${APACHE_PID_FILE}

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 100

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

Include ports.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/site1>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<Directory /var/www/site2>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

<Directory /srv/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

AccessFileName .htaccess

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

site1.conf:
<VirtualHost *:80>
    ServerName www.site1.com
    ServerAlias site1.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/site1

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/site1/>
        Options FollowSymlinks
        AllowOverride none
        Require all granted
    </Directory>

        <IfModule mod_fastcgi.c>
                AddHandler php5-fcgi .php
                Action php5-fcgi /php5-fcgi
                Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
                FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /tmp/php5-fpm.sock -pass-header Authorization
        </IfModule>

</VirtualHost>

SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|ico|png)$ \ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

site2.conf:
<VirtualHost *:80>
    ServerName www.site2.com
    ServerAlias site2.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/site2

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/site2/>
        Options FollowSymlinks
        AllowOverride none
        Require all granted
    </Directory>

        <IfModule mod_fastcgi.c>
                AddHandler php5-fcgi .php
                Action php5-fcgi /php5-fcgi
                Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
                FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /tmp/php5-fpm.sock -pass-header Authorization
        </IfModule>

</VirtualHost>

SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|ico|png)$ \ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Answer: Too long for a comment but probably not a complete answer:
It is odd that you get errors on the file-system path /var/www/html/ which is outside of the DocumentRoot paths /var/www/site1 and /var/www/site2.
That implies that there may be another configuration file in play. You may want to check what these Include directives are loading:
 IncludeOptional mods-enabled/*.load
 IncludeOptional mods-enabled/*.conf

and if there are any .htaccess files to want to source content from /var/www/html.
In the error message below:
[Thu Mar 03 13:57:28.132631 2016] [authz_core:error] [pid 31518] [client 188.8.131.52:48468] AH01630: client denied by server configuration: /var/www/html/xmlrpc.php

you see that it gets generated by the module: authz_core which indicates that it has to do with the access controls that are governed by that module; the manual lists quite a few.
It is this server configuration that denies access by the way:
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

a sensible default access policy which denies access unless specifically allowed, but you don't allow anything for the path /var/www/html ; you have only specifically allow access to:  /usr/share /var/www/site1 /var/www/site2 & /srv.

EDIT  Hmmm /var/www/html  may be the compile time default DocumentRoot.
And from your hapache2.conf it seems that an IncludeOptional sites-enabled/*.conf or similar is missing.
That would explain why you get directed to /var/www/html and fail
Comment: So i disabled 000-default.conf and enabled site1.conf and site2.conf. Now I am getting forbidden 403 message again:

Forbidden

You don't have permission to access /php5-fcgi/index.php on this server.

So it seems to be an issue with php?
Comment: The thing is that /var/www/html is not in use at all. I always had my sites in /var/www/siteX
Comment: see my edit for a thought
Comment: we have progress! Now I am seeing this message on both site1.com and site2.com:

http://imgur.com/TVbnPbd
Answer: Thanks to @HBruijn for the input. Means a lot!
Now my sites are somewhat running again. One is showing 500 Internal error, but the other is good. :) That I can manage!
I changed /etc/apache2/mods-available/fastcgi.conf to the following which solved the issues:
<IfModule mod_fastcgi.c>
  AddHandler php5-fcgi .php
  Action php5-fcgi /php5-fcgi
  Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi_example.com
  FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi_example.com -socket /var/run/php5-fpm_example.com.sock -pass-header Authorization
  <Directory /usr/lib/cgi-bin>
      Require all granted
  </Directory>
</IfModule>


Searching worksheets to return True or False based on value

Question: I have 2 excel worksheets. The first worksheet has 1 column representing route numbers and 4 columns representing values at 4 stops (see below)

The second worksheet has columns representing route numbers, latitude, longitude and stop numbers (see below).

I want to use the route numbers and stop numbers in the second worksheet to search the matching cell in the first worksheet and return a TRUE or FALSE as to whether the value is 0.
The result using my two examples would look as shown below.

What function would I need to perform this search and return?
Comment: Are the column headers in the first worksheet text values as *Stop1, Stop2, etc.* or are they numbers formatted as `"Stop"0`?
Comment: http://www.excel-easy.com/examples/two-way-lookup.html
Answer: Assuming your first sheet is Sheet1, you could use the following formula:
<code>=vlookup($a2,sheet1!$A$2:$E$6,match("Stop"&$d2,sheet1!$a$1:$e$1,0),0)=0
</code>
The match will retrieve the column corresponding to your Stop, and the vlookup will match the row corresponding to your route.
Comment: Thank you for the answer, it wasn't working as stated. I changed it to `=vlookup($a2,sheet1!$A$2:$E$6,match("Stop"&$d2,sheet1!$a$1:$e$1,0),0)=0` and it is working perfectly.
Comment: Correct, first row was #2. I adjusted.


Hide/Unhide DIV with JQuery

Question: I'm pulling the variables from a database and the values could either be Manual or Automatic. Users can also use a dropdown to change the values.
If the value is already Manual I need it to unhide a DIV or if it was Automatic and the user switches to Manual I need to unhide a DIV.
What I have currently only unhides if it was Automatic and user selects Manual.
Here is a JSFiddle: http://jsfiddle.net/DTcHh/5031/
Any help would be appreciated.
Thanks!
HTML:
<form class="form-horizontal" method="post">

    Method:

        <select id="method" name="method" class="form-control">
            <option value="Automatic">Automatic</option>
            <option value="Manual">Manual</option>
        </select>

            Manual

            Activity Complete:

                <select id="activitycomplete" name="activitycomplete" class="form-control">
                    <option value="False">False</option>
                    <option value="True">True</option>
                </select>

    <button type="submit" class="btn btn-success">Update</button>
    <button type="button" data-dismiss="modal" class="btn btn-default">Back</button>

</form>

JQuery:
$(document).ready(function () {
    $('#method').change(function () {
        $('#manual').toggle(500);
    });
//$("#method").val('Manual');
});

Answer: There's no logic in the code which actually checks the value.  Basically, this rule isn't implemented:

If the value is already Manual I need it to unhide a DIV or if it was Automatic and the user switches to Manual I need to unhide a DIV.

The code is assuming that the initial value is always "Automatic" and that there will always ever be a one-way-or-the-other switch between the two values.  This assumption is incorrect.
Instead of assuming the value and just toggling, explicitly show/hide based on the inspected value:
$('#method').change(function () {
    if ($(this).val() == 'Manual') {
        $('#manual').show(500);
    } else {
        $('#manual').hide(500);
    }
});

Which you can extract into a function so it can be invoked manually as well:
var toggleDiv = function () {
    if ($('#method').val() == 'Manual') {
        $('#manual').show(500);
    } else {
        $('#manual').hide(500);
    }
}
$('#method').change(toggleDiv);

Then you can invoke it when the page first loads as well:
$("#method").val('Manual');
toggleDiv();

Example here.
Answer: You'll want to check the value of the dropdox and on page load if it is manual run the toggle function:
$(document).ready(function () {
    $('#method').change(function () {
        $('#manual').toggle(500);
    });
    var valueOfDropDown = $('#method').val();
    if(valueOfDropDown === "Manual"){
        $('#manual').toggle(500);
    }
});

This will obviously show the box on once the dom is ready.

Hide/Unhide DIV with JQuery


Non isomorphism graph

Question: Im confused what is non isomorphism graph

cant post image so i upload it on tinypic
Particulary with this example

It is said, that this c4 graph on left side is non isomorphism graph.
But this is my try to make it isomorphic, like u might see it on picture
I have idea of non isomorphism graph, with contradiction, that u can for every graph, "squeeze" it, move little left-little right branches and vertices, mark vertices with different numbers, make bijection which shows that u can translate base graph to that derived , the end?
Can u give me some examples with non isomorph. graphs, and explanation that contradict mine?
*all down votes are not welcome, leave comment for discussion if u want to down vote
Comment: English as a second language is OK - just do the best you can.  Text message abbreviations are not. Specific examples will really help.
Comment: The two graphs in your picture are isomorphic. How you draw them is irrelevant. If you want more help you should post more examples of pairs of graphs that you think are or are not isomorphic. You can draw those pictures as text and format them so that they appear verbatim. And please write in complete sentences with complete words. No text message abbreviations.
Comment: Thanks, i ll try to find more examples. English is not my native, but i will try to think twice next time about words
Comment: Also part of question is can u give me some examples of non isomorphic graphs so u can contradict my theory
Comment: I also add that it's perfectly acceptable practice to post in your native language and request a translation by other users.
Comment: Instead of "u", use "you". Using "u" as you would in a text message is not welcome.  Asking questions, without showing your own work, or otherwise failing to include context, are not welcome.  Asking and answering is a "two-way street". You can expect downvotes, and/or votes to close when you fail to honor the expectations of this site.  Whether you welcome such votes or not is irrelevant.  If you do not want downvotes, then *listen and respond to suggestions*, take the site tour, review the site's "help section" (e.g. how to ask a good question), and be respectful of others.
Comment: I'm open for suggestion, and discussion, i think "u" "you" abbrevations , play little role here. I included my try?
Answer: Formally, (simple) graphs are an ordered pair $(V,E)$ where $V$ is a set (the vertex set) and $E$ has a set of $2$-subsets of $V$.
So, a $4$-cycle graph really is a pair $(V,E)$ with:

Vertex set: $V=\{1,2,3,4\}$,
Edge set: $E=\{\{1,2\},\{2,3\},\{3,4\},\{1,4\}\}$.

There is no drawing here.
We often draw graphs to make them easier to visualize (and because graph drawings are interesting in their own right).  I might draw the graph like this:

Someone else might draw it like this:

These are two different drawings of the same graph.  I.e., the graphs are equal.  (Despite being drawn differently.)

Graph isomorphism is instead about relabelling.  In this setting, we don't care about the drawing.=
Typically, we have two graphs $(V_1,E_1)$ and $(V_2,E_2)$ and want to relabel the vertices in $V_1$ so that the edge set $E_1$ maps to $E_2$. If it's possible, then they're isomorphic (otherwise they're not).
For example:

These two graphs are

not equal, e.g., only one of the graphs has the edge $\{1,4\}$, so they have different edge sets, but they are
isomorphic, if we swap the vertex labels $3$ and $4$, we go from the left graph to the right graph.

So...

I have idea of non isomorphism graph, with contradiction, that u can for every graph, "squeeze" it, move little left-little right branches and vertices, mark vertices with different numbers, make bijection which shows that u can translate base graph to that derived , the end?

The part "mark vertices with different numbers" is what isomorphism is about.  If they're isomorphic, you can:

Relabel the vertices of one to make it equal to the other.

After which we can

Redraw two equal graphs however we like (or even create a video showing how one maps to the other).  But this is about visualization, i.e., making it easier to see and understand.
Comment: Ahh, yeah, @user439345  You can vote up any answer to a question you ask.  You can also accept one answer per question.  So, please do upvote helpful answers, and accept an answer to each question as being the most helpful to you.  To do otherwise (to not vote, or accept) "is not welcome."
Comment: Can't vote, tried. I will wait little time maybe something come better, but this is satisfying and best for know...

Non isomorphism graph


MPI: how to distinguish send and recv in MPI_Wait

Question: Let's say I use PMPI to write a wrapper for MPI_Wait, which waits for an MPI send or receive to complete.
/* ================== C Wrappers for MPI_Wait ================== */
_EXTERN_C_ int PMPI_Wait(MPI_Request *request, MPI_Status *status);
_EXTERN_C_ int MPI_Wait(MPI_Request *request, MPI_Status *status) {
    int _wrap_py_return_val = 0;

  _wrap_py_return_val = PMPI_Wait(request, status);
    return _wrap_py_return_val;
}

The wrapper is generated by this.
What I would like to do is:
/* ================== C Wrappers for MPI_Wait ================== */
_EXTERN_C_ int PMPI_Wait(MPI_Request *request, MPI_Status *status);
_EXTERN_C_ int MPI_Wait(MPI_Request *request, MPI_Status *status) {
    int _wrap_py_return_val = 0;

  if(is a send request)
    printf("send\n");
  else // is a recv request
    printf("recv\n");

  _wrap_py_return_val = PMPI_Wait(request, status);
    return _wrap_py_return_val;
}

How to distinguish send and recv in Open MPI? Let's say I use Open MPI 3.0.0.
Comment: I browsed through http://www.vi-hps.org/upload/packages/scorep/scorep-3.1.tar.gz in `src/adapters/mpi/SCOREP_Mpi_P2p.c` and `scorep_mpi_request.*`. They register requests manually during send and receive. I.e. for each send/recv, register the request and retrieve its source during wait. (look for e.g. `SCOREP_MPI_REQUEST_TYPE_RECV` in the linked tarball). Score-P is MPI-implementation agnostic
Comment: `MPI_Request` is an opaque handler, so you cannot distinguish send and receive (nor collectives, ...) at this level. If you target a specific version of OpenMPI, then you can use the internal `ompi_request_t` type. Note your extension should be written and built all together with Open MPI.
Comment: @GillesGouaillardet Which element of ompi_request_t contains info for distinguishing send and recv? I looked into the definition, but couldn't find the element. ompi_request_type_t? It's not for send and recv. Maybe you could post code example as an answer?
Comment: I missed some steps. If this is a `MPI_REQUEST_PML`, then cast the request into a `mca_pml_base_request_t` and check `req_type`
Comment: @GillesGouaillardet What is PML short for?
Comment: P2P Management Layer
Comment: scorep approach looks implementation agnostic, but that has a (runtime + memory) cost
Answer: I think since MPI_Request is opaque (I think in several release it is just an int) your only chance is to monitor yourself the created MPI_Request.
Here is a proposition (it is C++ oriented, because that's the way I like it) :
#include <mpi.h>
#include <iostream>
#include <map>
//To do opaque ordering
struct RequestConverter
{
      char data[sizeof(MPI_Request)];
      RequestConverter(MPI_Request * mpi_request)
      {
            memcpy(data, mpi_request, sizeof(MPI_Request));
      }
      RequestConverter()
      { }
      RequestConverter(const RequestConverter & req)
      {
            memcpy(data, req.data, sizeof(MPI_Request));
      }
      RequestConverter & operator=(const RequestConverter & req)
      {
            memcpy(data, req.data, sizeof(MPI_Request));
            return *this;
      }
      bool operator<(const RequestConverter & request) const
      {
            for(size_t i=0; i<sizeof(MPI_Request); i++)
            {
                  if(data[i]!=request.data[i])
                  {
                        return data[i]<request.data[i];
                  }
            }
            return false;
      }
};
//To store the created MPI_Request
std::map<RequestConverter, std::string> request_holder;

extern "C"
{

int MPI_Isend(
  void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request
)
{
      int ier = PMPI_Isend(buf, count, datatype, dest, tag, comm, request);
      request_holder[RequestConverter(request)]="sending";
      return ier;
}

int MPI_Irecv(
  void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request
)
{
      int ier = PMPI_Irecv(buf, count, datatype, dest, tag, comm, request);
      request_holder[RequestConverter(request)]="receiving";
      return ier;
}

int MPI_Wait(
  MPI_Request *request,
  MPI_Status * status
)
{
      int myid;
      MPI_Comm_rank(MPI_COMM_WORLD, &myid);
      std::cout << "waiting("<<myid<<")-> "<<request_holder[RequestConverter(request)]<<std::endl;
      request_holder.erase(RequestConverter(request));

      return PMPI_Wait(request, status);
}

}

RequestConverter is just a way of doing oblivious ordering to use a std::map
MPI_Isend stores the request in the global map, so does MPI_Irecv and MPI_Wait looks for the request and deletes it from the std::map.
Simple test gives :
int main(int argv, char ** args)
{
       int myid, numprocs;
      MPI_Init(&argv, &args);
      MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
      MPI_Comm_rank(MPI_COMM_WORLD, &myid);

      int i=123456789;
      MPI_Request request;
      MPI_Status status;
      if(myid==0)
      {
            MPI_Isend(&i, 1, MPI_INT, 1, 44444, MPI_COMM_WORLD, &request);
            MPI_Wait(&request, &status);
            std::cout << myid <<' '<<i << std::endl;
      }
      else if(myid==1)
      {
            MPI_Irecv(&i, 1, MPI_INT, 0, 44444, MPI_COMM_WORLD, &request);
            MPI_Wait(&request, &status);
            std::cout << myid <<' '<<i << std::endl;
      }
      int * sb = new int[numprocs];
      for(size_t i=0; i<numprocs; i++){sb[i]=(myid+1)*(i+1);}
      int * rb = new int[numprocs];
      MPI_Alltoall(sb, 1, MPI_INT, rb, 1, MPI_INT, MPI_COMM_WORLD  );
      MPI_Finalize();
}

output :
waiting(0)-> sending
0 123456789
waiting(1)-> receiving
1 123456789

However I just added a test with MPI_Alltoall to see if only the PMPI functions were called and it is the case. So no miracle there.


Limit of the ratio of the logarithms of two functions versus the limit of the ratio of the functions

Question: I am interested in proving or finding a counter example for the following statement
$$
\lim_{n \to \infty}{\frac{\ln{f(n)}}{\ln{g(n)}}} = \infty \implies \lim_{n \to \infty}{\frac{f(n)}{g(n)}} = \infty
$$
It seems to make a lot of sense, but it isn't very clear how to prove this statement.
If it isn't true, what if both $f(n)$ and $g(n)$ are monotonically increasing?
I've tried looking at the contrapositive, as well as Taylor series expansions, but I'm not able to come to a complete conclusion.
I would also imagine that this holds for any monotonic function, not just the logarithm (if it holds at all).
Comment: If $f(n)=2$ and $g(n)=1+\frac{1}{n}$, you have a counter example.
Answer: I already gave a counter example in the comments for the general case.
let's suppose that f and g are monotonically increasing and >1. Then their limits is $+\infty$.(otherwise, the limit of $\frac{ln(f(n))}{ln(g(n))}$ would not be $+\infty$)
Let's define h such as : $f(n)=h(n)g(n)$
Then : $\frac{ln(f(n))}{ln(g(n))}=\frac{ln(h(n)g(n))}{ln(g(n))}=1+\frac{ln(h(n)}{ln(g(n))}$. So you know that the limit of $\frac{ln(h(n)}{ln(g(n))}$ is $+\infty$.
Since the limit of $ln(g(n))$ is $+\infty$, the limit of $ln(h(n))$ is also $+\infty$.
Hence, by definition of $h$,  the limit of $\frac{f(n)}{g(n)}$ is also $+\infty$.
Is it ok for you?
Comment: Very simple and beautiful answer. +1
Comment: I think it is not necessary that $\log(g(n))$ also tends to $\infty$. It may tend to a finite limit. But your conclusion and proof holds in exactly the same manner.
Comment: Very good, thank you.


Integrating a link to my database within the Win 8 App Search Contract

Question: In my Win 8 app, based on a blank template, I have successfully added search contract and it seems to work despite the fact that I have not linked it to any data yet, so, for now, when I search any term in my app it simply takes me to the searchResults page with the message "No Results Found" this is what I was expecting initially.
Now what I wish to do is link my database into the searchResults.js file so that I can query my database. Now outside of the search contract I have tested and connected my Db and it works; I did this using WinJS.xhr, to connect to my web-service which in turn queries my database and returns a JSON object.
In my test I only hardcoded the url, however I now need to do two things. Move the test WinJS.xr data for connecting my DB into the search contract code, and second - change the hardcoded url to a dynamic url that accepts the users search term.
From what I understand of Win 8 search so far the actual data querying part of the search contract is as follows:
// This function populates a WinJS.Binding.List with search results for the provided query.
    _searchData: function (queryText) {
        var originalResults;
        // TODO: Perform the appropriate search on your data.
        if (window.Data) {
            originalResults = Data.items.createFiltered(function (item) {
                return (item.termName.indexOf(queryText) >= 0 || item.termID.indexOf(queryText) >= 0 || item.definition.indexOf(queryText) >= 0);
            });
        } else {`enter code here`
            originalResults = new WinJS.Binding.List();
        }
        return originalResults;
    }
});

The code that I need to transfer into this section is as below; now I have to admit I do not currently understand the code block above and have not found a good resource for breaking it down line by line. If someone can help though it will be truly awesome! My code below, I basically want to integrate it and then make searchString be equal to the users search term.
   var testTerm = document.getElementById("definition");
    var testDef = document.getElementById("description");

    var searchString = 2;
    var searchFormat = 'JSON';

    var searchurl = 'http://www.xxx.com/web-service.php?termID=' + searchString +'&format='+searchFormat;

    WinJS.xhr({url: searchurl})
      .done(function fulfilled(result)

      {
          //Show Terms
          var searchTerm = JSON.parse(result.responseText);

          // var terms is the key of the object (terms) on each iteration of the loop the var terms is assigned the name of the  object key
          // and the if stament is evaluated

          for (terms in searchTerm) {

              //terms will find key "terms"
              var termName = searchTerm.terms[0].term.termName;
              var termdefinition = searchTerm.terms[0].term.definition;

              //WinJS.Binding.processAll(termDef, termdefinition);
              testTerm.innerText = termName;
              testDef.innerText = termdefinition;
          }
    },
              function error(result) {
                  testDef.innerHTML = "Got Error: " + result.statusText;
              },
              function progress(result) {
                  testDef.innerText = "Ready state is " + result.readyState;
              });

Answer: I will try to provide some explanation for the snippet that you didn't quite understand. I believe the code you had above is coming from the default code added by Visual Studio. Please see explanation as comments in line.
/**
 * This function populates a WinJS.Binding.List with search results
 * for the provided query by applying the a filter on the data source
 * @param {String} queryText - the search query acquired from the Search Charm
 * @return {WinJS.Binding.List} the filtered result of your search query.
 */
_searchData: function (queryText) {
    var originalResults;
    // window.Data is the data source of the List View
    // window.Data is an object defined in YourProject/js/data.js
    // at line 16 WinJS.Namespace.define("Data" ...
    // Data.items is a array that's being grouped by functions in data.js
    if (window.Data) {
        // apply a filter to filter the data source
        // if you have your own search algorithm,
        // you should replace below code with your code
        originalResults = Data.items.createFiltered(function (item) {
            return (item.termName.indexOf(queryText) >= 0 ||
                    item.termID.indexOf(queryText) >= 0 ||
                    item.definition.indexOf(queryText) >= 0);
            });
    } else {
        // if there is no data source, then we return an empty WinJS.Binding.List
        // such that the view can be populated with 0 result
        originalResults = new WinJS.Binding.List();
    }
    return originalResults;
}

Since you are thinking about doing the search on your own web service, then you can always make your _searchData function async and make your view waiting on the search result being returned from your web service.
_searchData: function(queryText) {
    var dfd = new $.Deferred();
    // make a xhr call to your service with queryText
    WinJS.xhr({
        url: your_service_url,
        data: queryText.toLowerCase()
      }).done(function (response) {
           var result = parseResultArrayFromResponse(response);
           var resultBindingList = WinJS.Binding.List(result);
           dfd.resolve(result)
      }).fail(function (response) {
          var error = parseErrorFromResponse(response);
          var emptyResult = WinJS.Binding.List();
          dfd.reject(emptyResult, error);
      });
    return dfd.promise();
}
...
// whoever calls searchData would need to asynchronously deal with the service response.

_searchData(queryText).done(function (resultBindingList) {
    //TODO: Display the result with resultBindingList by binding the data to view
}).fail(function (resultBindingList, error) {
    //TODO: proper error handling
});


É possível converter um número de 16 bits para um único byte?

Question: Este código:
Int16 numero = 2017;
byte m = (byte) numero;

m será 225. De forma inversa, como obtenho 2017 a partir de m  novamente?
Comment: 16 bits são 2 bytes. Não tem como converter sem jogar informação fora.
Comment: Um bom exemplo de como armazenar números em menos bits do que a potência de 2 equivalente são os floats (também chamados de [Minifloats](https://en.wikipedia.org/wiki/Minifloat) nesse caso). Isso é algo feito no dia a dia em inúmeras situações onde não se necessita exatidão - obviamente alguma perda vai ter em parte dos valores. Uma pesquisa rápida por `8 bit float` é um bom ponto de partida. E tem aplicações reais interessantes, não é só "teoria computacional" não: https://www.johndcook.com/blog/2018/04/15/eight-bit-floating-point/
Answer: Parece que está te faltando a base conceitual sobre como valores são codificados em binário.
Se cada dígito binário só pode ser zero ou um, um dígito binário só permite codificar dois valores. Da mesma maneira, dois dígitos permitem codificar até 4 valores:
00 - 0
01 - 1
10 - 2
11 - 3

A regra geral é que a quantidade de valores que um número binário de determinado comprimento n é capaz de codificar é x = 2n. Portanto, em 8 bits (1 byte) você consegue codificar 256 valores distintos. No caso de inteiros, pode ser de -128 a 127 de 0 a 255, ou outra alguma outra divisão mais exótica. Mas de qualquer maneira, não cabem mais que 256 valores em 1 byte.
Assim, se você tem um valor que precisa de mais de 1 byte para ser armazenado, não tem como fazê-lo caber em 1 byte sem perder informação. No seu exemplo de 2017, por exemplo, a conversão dá 255 porque é o maior inteiro que cabe em 1 byte. Qualquer valor maior que 255 dá esse mesmo resultado ao ser convertido para byte, e assim não tem como desfazer a operação, já que inúmeros valores (infinitos, na verdade) dão esse mesmo resultado.
Answer: Não tem espaço
Você está querendo pegar algo de 1Kg e guardar em um recipiente de 500g, vai jogar fora 500g, aí você quer ter o 1Kg de volta. Só existe uma possibilidade, guardar os 500g em outro lugar. Mas pra que fazer isso? Não tem sentido. Se precisa manter a informação completa, use ela completa.
Em um tipo byte cabem 8 bits, como o bit só tem 2 estados, 2 elevado a 8 temos uma combinação de 256 números diferentes, então em um byte não podemos representar um número maior que 255, já que começa do 0.
Um short possui 2 bytes (16 bits), podendo representar 65536 números diferentes. Mas tem uma coisa diferente do byte, ele é sinalizado, ou seja existe um bit indicando se é negativo, então o maior número possível positivo é 32783.
Então não tem quantidade de bits suficiente em um byte para representar 2017 que precisaria um mínimo de 11 bits, mas como não dá para reservar memória com um byte quebrado, 16 bits é adotado.
Na verdade mesmo o uso de um short talvez deva ser evitado. Em alguns casos onde o ganho de memória ocorrerá de fato, e poucos casos ocorre e é necessário, em geral é pior tentar usar um tipo menor do que o mais adequado para o processador, então deixe um int (Int32), a não ser que tenha certeza que terá ganho.
Solução alternativa
Agora, se precisar realmente reduzir o tamanho, o que eu duvido que seja tão necessário assim, é possível adotar algum critério conforme o que for usar. Você pode jogar fora uma informação que sabe que pode ser recuperada depois por convenção. Isto dá certo em alguns casos.
Por exemplo, está usando 2017, acredito que isso seja um ano completo com século, mas talvez não precise do século, então subtraia 2000 e guarde só o ano que cabe um um byte. Se tiver anos de antes de 2000, pode subtrair 1900, claro que o que estiver acima de 100 você sabe que é século 21, o que está abaixo é século 20.
De forma simplificada seria algo assim:
using System;
using System.Diagnostics.Contracts;

public class Program {
    public static void Main() {
        short numero = 2017;
        var m = new ShortYear(numero);
        Console.WriteLine(m);
    }
}
//provavelmente teria implemnetações de operadores, outros métodos e das interfaces
//IFormattable, IConvertible, IComparable<ShortYear>, IEquatable<ShortYear> e outras
public struct ShortYear {
    public byte Year;
    public const short Century = 1900;
    public ShortYear(short value) {
        Contract.Ensures(value >= Century && value < Century + 256);
        Year = (byte)(value - Century);
    }
    public ShortYear(int value) {
        Contract.Ensures(value >= Century && value < Century + 256);
        Year = (byte)(value - Century);
    }
    public static implicit operator short(ShortYear value) => (short)(value.Year + Century);
    public static implicit operator int(ShortYear value) => value.Year + Century;
    public override int GetHashCode() => Year.GetHashCode();
    public override String ToString() => (Year + Century).ToString();
}

Veja funcionando no ideone. E no .NET Fiddle. Também coloquei no GitHub para referência futura.
Eu ainda acho muita gambiarra pra provavelmente pouco ganho. Você teria que ficar controlando isso em toda aplicação. Ou poderia criar um tipo de um byte que abstraia tudo isto, o que ainda provavelmente será muito esforço para pouco ganho, como não há contexto não dá para afirmar.
Seria possível usar alguma outra forma como um tipo de ponto flutuante binário com 1 byte, fora do padrão IEEE 754, mas ele poderia representar menos inteiros ainda, e decimais que não servem para nada neste caso, poderia ser em casos extremamentes restritos com outra exigência onde não precisa de exatidão decimal, pode ter pouca precisão, e bem poucos inteiros.
Answer: Como um byte é composto geralmente* de oito bits, o maior valor que você pode representar em geral é 255 mesmo.
Explicação: números inteiros são representados em geral como somas de potências de 2. Cada bit com valor zero representa zero mesmo, e cada bit com valor 1 representa o valor 2n, onde n é a posição (geralmente da direita para a esquerda) do bit zero-indexada.
Seguem alguns valores para exemplo:
0000 0001 = 1
0000 0010 = 2
0000 0100 = 4
0000 0101 = 5
0001 0000 = 32
0010 0001 = 33

Etc., etc., até o maior valor que é 255 quando a disposição dos bits é a seguinte:
1111 1111 = 255

Pois 255 = 27 + 26 + 25 + 24 + 23 + 22 + 21 + 20.
Então, para representarmos quaisquer valores maiores que isso, precisamos de mais bits. Por esse motivo os tipos numéricos da maioria das linguagens tem tamanhos variando de dezesseis a sessenta e quatro bits.
Infelizmente, exatamente por esse motivo, não é possível extrair um valor inteiro maior do que 255 a partir de apenas oito bits.
Talvez fosse possível com números de ponto flutuante, mas em geral o menor tipo de ponto flutuante, o float, costuma ocupar ao menos quatro bytes em memória. Além disso, você ainda correria o risco de não obter o resultado desejado devido a problemas de precisão, caso deseje implementar ponto flutuante de um byte na marra.
Portanto:

Se você quer utilizar o tipo byte por motivos de compactação, é melhor rever suas estratégias;
Se você precisa utilizar o tipo byte por quaisquer outros motivos (i.e.: tarefa de casa), você vai precisar de mais bytes.

*Eu não estou fazendo piadinhas de mal-gosto aqui, bytes de tamanhos diferentes existem apesar de serem quase tão raros quanto mundiais do Palmeiras.
Answer: Um valor de 16 bits é melhor representado como um short invés de int para usar BitConvert.GetBytes(short).
Por isso, como alternativa:
byte lowByte = (byte) (numero & 0xff);
byte highByte = (byte) ((numero >> 8) & 0xff);

Answer: Impossível colocar 16 bits em 1 byte. O que você pode fazer é colocar em um array de bytes com BitConverter e depois fazer o processo ao contrário.
    Int16 numero = 2017;
    var StrToByte = BitConverter.GetBytes(numero);
    byte[] temp = new byte[4];
    StrToByte.CopyTo(temp, 0);
    StrToByte = temp;
    var i = BitConverter.ToInt32(StrToByte, 0);
    Console.WriteLine(i);


change the list option based on the selection type

Question: In a form, user have an option to choose the submission type. Based on the selected submission type, user should get an option to choose sub-type. Please let me know how this is done in Drupal 7. Please suggest a module.

If user select e-book, sub-type should change to case:1 (see image)
If user select e-project, sub-type should change to case:2
If user select e-lab manual, sub-type should change to case:3
Answer: Seems like you are looking for Conditional Fields module...

Conditional Fields allows you to manage sets of dependencies between
  fields. When a field is "dependent", it will only be available for
  editing and displayed if the state of the "dependee" field matches the
  right condition. When editing a node (or any other entity type that
  supports fields, like users and categories), the dependent fields are
  dynamically modified with the States API. You can, for example, define
  a custom "Article teaser" field that is shown only if a "Has teaser"
  checkbox is checked.

See below image displayed in project page which suits your requirement.. Hope above module solves your problem..
Answer: If this is taxonomy term based, try using Simple hierarchial select. Details from project page:

Simple hierarchical select defines a new form widget for taxonomy fields to select a term by "browsing" through the vocabularies hierarchy.
  The widget is available in node forms and as Views exposed filter.
This module has been inspired by Hierarchical select but is much simpler.

It provides a field widget that can force deepest level selection, so your nested terms are fully utilized.


Add field to vocabulary itself

Question: I have a situation where I would like to add a field to a vocabulary itself.  In other words, I need an editable field on the form that normally appears at /admin/structure/taxonomy/my_vocabulary/edit and not a field that appears each term in the vocabulary.  Unfortunately, the description column in {taxonomy_vocabulary} is too limited for what I need.
What is the best way to go about this?  If possible I would like to avoid making a custom module with a custom table, form-alters for the vocabulary edit page, etc.
Thanks.
Answer: So the basic problem is that a vocabulary is not fieldable. In theory this is easy to fix, but I don't know if they lack this functionality because it would cause technical difficulties, or to avoid confusion users.
To make a vocabulary fieldable, implement hook_entity_info_alter:
function hook_entity_info_alter(&$entity_info) {
  $entity_info['taxonomy_vocabulary']['fieldable'] = TRUE;
}

Comment: +1 That's a great answer...looking at the controller classes ([`TaxonomyVocabularyController`](http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module/class/TaxonomyVocabularyController/7) and [`TaxonomyTermController`](http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module/class/TaxonomyTermController/7)) there's not much difference so nothing to suggest fields wouldn't work out of the box.
Comment: If I go with this, I assume I would have to wire up everything to add fields via the UI myself?
Comment: I'm not sure I understand that question. Obviously you need to "add the field yourself", but it wouldn't need to happen through the UI. You could add field programmatically.
Comment: @Letharion, thanks.  I'm just trying to make things as simple as possible for an odd request that came in on a project.
Answer: You can use the Fieldable vocabularies module.

This module exposes the Vocabulary to the field system. It defines a single bundle and a single view mode.

Add field to vocabulary itself


Como fazer buscas usando jquery por atributo TITLE?

Question: Espero que esta mensagem os encontre bem.
Possuo o um código jquery que realiza buscas em tabela em tempo real. Este código faz buscas nesta tabela pelos valores das células, mas preciso que ele busque ao mesmo tempo por valores e valores do atributo title.
Exemplo se eu possuir o nome de uma empresa na tabela, ele encontrará esta empresa, todavia, se eu possuir a logo da empresa o nome dela estará no atributo TITLE e não como valor da célula.
Preciso que este código busque por ambos, tanto as empresas que só possuem o nome registrado e também as que possuem logo na tabela, mas que o nome está no TITLE.
Já antecipando os meus agradecimentos, segue o código abaixo.
Forte abraço a todos!

Answer: <!DOCTYPE html>

This is a paragraph.

This is a paragraph.

This is a paragraph.

This is a paragraph.

This is a paragraph.

This selector selects all elements with a title attribute value equal to 'Tomorrow', or starting with 'Tomorrow' followed by a hyphen.

Neste trecho é que tá o "segredo" da coisa
$(document).ready(function(){  $("p[title|='Tomorrow']").css("background-color", "yellow");});

Ai eu consigo procurar a tag p e com um nome title específico e adicionar o background amarelo no elemento cujo o title é "Tomorrow", acho que é isso que quer.
Edit 1: você pode substituir também, e outro exemplo disto é este abaixo
<!DOCTYPE html>

    <title>Esconder titulos</title>

    <input type="text" name="texto" id="texto">
    <button id="btn">Aplicar Titulo</button>

Script.js:
document.addEventListener('DOMContentLoaded',function() {
document.querySelector('#btn').addEventListener('click', function() {
    let text = document.querySelector('#texto').value;
    document.title = text;
});
});


Server to server file transfer port?

Question: I use a bash script(https://github.com/johnnywoof/FTP-Bash-Backup) to Backup my Debian  www directory to a ftp server. everything went well but transfer blocked by firewall. The script using separate port every time so i can't unblock by Firewall. is there any way to specify a port ?
The Bash script
# FTP server settings
USERNAME=""
PASSWORD=""
SERVER=""
PORT=21

BACKUPDIR="/"

ndays=7

LOCAL_DIRECTORY="/home"

TEMP_BACKUP_STORE="/tmp"

ENCRYPT_BACKUP=false

AES_PASSWORD_FILE=""

timestamp=$(date --iso)

backup_remote_file_name="$timestamp.tar.gz"
backup_file="$TEMP_BACKUP_STORE/$backup_remote_file_name"

MM=`date --date="$ndays days ago" +%b`
DD=`date --date="$ndays days ago" +%d`

echo "Removing files older than $MM $DD"

listing=`ftp -i -n $SERVER $PORT <<EOMYF
user $USERNAME $PASSWORD
binary
cd $BACKUPDIR
ls
quit
EOMYF`

lista=( $listing )

for ((FNO=0; FNO<${#lista[@]}; FNO+=9));do
    # month (element 5), day (element 6) and filename (element 8)
    #echo Date ${lista[`expr $FNO+5`]} ${lista[`expr $FNO+6`]}          File: ${lista[`expr $FNO+8`]}

    if [ ${lista[`expr $FNO+5`]}=$MM ];
    then
        if [[ ${lista[`expr $FNO+6`]} -lt $DD ]];
        then
            echo "Removing ${lista[`expr $FNO+8`]}"
            ftp -i -n $SERVER $PORT <<EOMYF2
            user $USERNAME $PASSWORD
            binary
            cd $BACKUPDIR
            delete ${lista[`expr $FNO+8`]}
            quit
            EOMYF2
        fi
    fi
done

echo "Creating backup..."

tar -czf $backup_file $LOCAL_DIRECTORY

if [ "$ENCRYPT_BACKUP" == "true" ]
then
    echo "Encrypting backup using OpenSSL..."
    output_encrypted_file="$backup_file.enc"
    openssl enc -aes-256-cbc -salt -in $backup_file -out $output_encrypted_file -pass file:$AES_PASSWORD_FILE
    rm $backup_file
    backup_file=$output_encrypted_file
fi

echo "Uploading backup $backup_file ..."

ftp -n -i $SERVER $PORT <<EOF
user $USERNAME $PASSWORD
cd $BACKUPDIR
put $backup_file $backup_remote_file_name
quit
EOF

echo "Deleting temporary files..."
rm $backup_file
echo "Backup complete."

Comment: The script should always connect to the same port - port 21. Are you saying your local (client) firewall is blocking outbound (client) traffic directed at port 21 on the server?
Comment: no its using random port, 21 port is unblocked
Comment: Btw.: Please take a look: http://www.shellcheck.net/
Answer: Switch to passive mode:
Insert passive in a new line after user command.

See: Active FTP vs. Passive FTP, a Definitive Explanation

Server to server file transfer port?


Why do we always have to use complete induction when dealing with a sequence defined recursively?

Question: I heard I should for simplicity use complete induction (strong induction) always rather than memorize when to use weak induction versus complete induction. Is there a reason that I should always use strong induction when dealing with recursive sequences? I'm not looking for an explanation on strong vs weak induction because I heard I'm always correct if I use strong induction.
Comment: [both induction are equivalent](https://math.stackexchange.com/questions/1978715/why-induction-is-defined-as-an-implication-instead-of-an-if-and-only-if-statem) yes. Sometimes you can use only weak for recursions too. I think it depends on the kind of recursion.
Answer: Where did you "hear that"?
I think that simplicity suggests that you use the simplest tool that does the job. So when ordinary vanilla induction works it's the tool of choice. Save strong induction for the problems where it's necessary. That depends on the problem, not on something you memorize.


How to create /etc/subuid and /etc/subgid

Question: My Manjaro installation did not configure /etc/subuid and /etc/subgid files which are required for rootless containers such as Docker to work.
For e.g. cat /etc/subuid returns a file not found error.
I discovered this problem as soon as I installed Docker Desktop and it was taking forever to start.
I followed some advice from this page but to no avail because my system did not have the requisite files.
Eventually, I figured out how to create and configure the subuid and subgid files. I have provided the solution below.
Answer: To create /etc/subuid and /etc/subgid files, use
touch /etc/subuid
touch /etc/subgid

To configure the files, I used a wrote a Python program as described here:
f = open("/etc/subuid", "w")
for uid in range(1000, 65536):
    f.write("%d:%d:65536\n" %(uid,uid*65536))
f.close()

f = open("/etc/subgid", "w")
for uid in range(1000, 65536):
    f.write("%d:%d:65536\n" %(uid,uid*65536))
f.close()

You can verify the existence and contents of these files with cat /etc/subuid
Docker works perfectly now!


Does MySQL provide native support for enabling a resilient data storage?

Question: My client strongly desires for a highly availability access to data stored in their MySQL database. They want to be confident that a reliable solution exists to avert downtime due  to a database server failure.
In the scope of MySQL database, how may I provide a resilient data storage solution to my clients?
There should be a means to ensure our app stays up and is not starved of data necessity for its operation when DB server goes down. I googled and found this:
http://galeracluster.com/documentation-webpages/configuration.html
But I think there should be an easier way to switch between different DB servers, am I right?
In any case my question is: what is the practices to handle such situations when DB server goes offline?
Comment: its called replication
Comment: One major reason why cloud services are popular
Answer: You are looking for a database cluster (probably with multi-master replication)
https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-replication-multi-master.html
This topic is WAY too deep for an SO post, but this is the direction you should be heading.
Answer: The solution to the challenge you described is Database Replication.

Replication in computing involves sharing information so as to ensure consistency between redundant resources, such as software or hardware components, to improve reliability, fault-tolerance, or accessibility.
Database replication can be used on many database management systems (DBMS), usually with a master-slave relationship between the original and the copies. The master logs the updates, which then ripple through to the slaves. Each slave outputs a message stating that it has received the update successfully, thus allowing the sending of subsequent updates.

MySQL supports DB replication when you configure it. So, you do not have to implement the actual replication process.
See the official MySQL documentation on ⇢ MySQL database replication.


Central Limit Theorem for uncorrelated RV (counter example)

Question: In Varadhan's probability book it is stated that there exists sequences of identically distributed uncorrelated (finite variance?) RV's such that the central limit theorem does not hold.   The book doesn't cite an example though.   I was wondering if such an example is easy to construct.
Answer: Consider the random variables $X_n=Y_n\cdot Z$ where the sequence of random variables $(Y_n)_n$ is i.i.d. square integrable and centered, and where the random variable $Z$ is square integrable and independent of $(Y_n)_n$.
Then the sequence of random variables $(X_n)_n$ is square integrable, centered and uncorrelated.
The central limit theorem applied to the sequence $(Y_n)_n$ shows that the random variables $\frac1{\sqrt{n}}(X_1+\cdots +X_n)$ converge in distribution to $YZ$, where  the random variable $Y$ is standard normal and independent of $Z$.
When the random variable $Z$ is not almost surely constant, there is no reason to expect the random variable $YZ$ to be normal. For example, if $Z$ is a Bernoulli random variable with $P(Z = 0) = P(Z = 1) = \frac{1}{2}$, then $YZ$ is non-normal, specifically a mixture of a normal distribution and a point mass at zero. Thus, convergence in distribution holds, but not necessarily to a normal distribution.
Comment: @MichaelHardy This is quite complete as it stands, thank you. If you have trouble finding an example, be reassured that nearly everything works (say, Z asymmetric Bernoulli). O wait! This was already clear from the answer, right?
Comment: If only math.stackexchange would have a *like* button, I would have liked the latter comment. Things being what they are, I could only rank it up.
Comment: This would be more complete if an instance were exhibited of distributions of $Y_n$ and of $Z$ for which one would prove that $YZ$ is not normally distributed. ${}\qquad{}$


Bridging two VLANs together

Question: I have a connection to a network service provider with two VLANs on it.
One VLAN has the internet.  The service provider has defined a default router and assigned me a subnet of IPs attached to that router for me to use.
The other VLAN is a connection to two remote sites.
(It is set up this way for historical reasons.)
What I really want to do is use the IPs assigned to me on the second VLAN.
So.  Is there any reason why I can't:

untag a port on the internet VLAN
untag a port on the remote-site VLAN
turn spanning tree off on those two ports
connect them together with a crossover cable

...besides the fact that it just looks wrong?
Second part of the question.
Assuming I have a Dell PowerConnect 6224, is there a way to do this "correctly" within the switch without the wrong-looking cable?
Comment: I have the single port that goes to the upstream provider tagged on both VLANs.  If the two VLANs are bridged together, arps from VLAN 2 should be passed to VLAN 1, where the router will respond to them.  Basically I want to use all of the IPs assignment from VLAN1 on devices that are only on VLAN2 (at remote sites).
Comment: Where's your router that's going to route this Internet subnet going to sit, on one of the VLAN2 access ports?
Comment: Am I right in thinking that you want to be able to assign addresses that currently only work for physical ports tagged for VLAN1 on ports that are currently tagged only for VLAN2? Do you need any of these ports to work for both VLANs (trunked)? Also how does your suggested approach handle routing for the internet IP's when they are on your remote-site VLAN?
Comment: I shouldn't need a router.  I want all traffic on VLAN 1 to also be on VLAN 2.
Comment: Well then, yes, you could use some sort of bridge, but that's still slightly more complex than patching two VLAN interfaces together. If it happens to be a "Layer 3 Switch" (the marketing name for a router with lots of ports), you could do it in the same device.
Comment: Also keep in mind that if you just bridge the two networks, the devices on them would need to be in the same subnet, obviously.
Answer: ...and the answers, are:
1) Because it IS wrong.  If you create an ethernet loop across VLANs as described, even if you have spanning tree turned off on the ports in question (or even the entire switch) -- if you have spanning tree ANYWHERE ELSE in your network, those packets will loop and flood all ports on the switch.
2) Call the service provider and ask that a /30 be set up between you and them; then have them route the /26 to you via your end of the /30, which you've assigned to one interface on your 6224.  Then put the /26 on VLAN2 through another interface.  Enable routing, and you are done.
Comment: ..score me minus several million for having to learn this the hard way.
Answer: Yes, the thing that does what you want is called a "router".
Comment: Ah yes, I have one built in to said Dell 6224.  How do I configure it (or an abstract router) to do this?
Comment: Well pretty much all of my router experience has been with *nix-based ones... in which case you'd enable IP forwarding and then add appropriate firewall rules for the correct interfaces.
Comment: yeah, it's the whole "defining appropriate interfaces" bit I had a problem with.

Bridging two VLANs together


How to create multiple empty classes in a single declaration?

Question: As we can create multiple variables in a single line, such as:
x, y, z = 1, 2, 3
print(x)

and the output would be 1,
I wonder if there is something similar to create multiple empty classes, so something like this, which I know is wrong, but just to let you have an idea of what I mean:
class X, Y, Z:
    pass

Thank you very much!
Comment: I don't think this is meaningful as class is an abstract thing. Three identical abstract things can be abstacted as one thing.
Answer: No, there is no special syntax to use a class definition this way. You could use the type constructor, something like:
>>> A, B, C = type('A', (object,), {}), type('B', (object,), {}), type('C', (object,), {})
>>> A, B, C
(<class '__main__.A'>, <class '__main__.B'>, <class '__main__.C'>)
>>>
>>> A()
<__main__.A object at 0x10354d780>
>>> B()
<__main__.B object at 0x1038b1ef0>
>>> C()
<__main__.C object at 0x10354d780>

But I think that's hardly elegant, and it's unlikely you'll be able to keep the single line to a sane length. Just stick to the full class definitions.


Wildfly Undertow File Mimetypes

Question: I want Undertow to serve static files like .jpg, .png, .js, .css, .txt etc...
I edited the undertow subsystem in standalone.xml:
<subsystem xmlns="urn:jboss:domain:undertow:4.0">
        <buffer-cache name="default"/>
        <server name="default-server">
            <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
            <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
            <host name="default-host" alias="localhost">
                <location name="/images" handler="sh-resources"/>
                <filter-ref name="server-header"/>
                <filter-ref name="x-powered-by-header"/>
                <filter-ref name="content-png" predicate="path-suffix['.png']"/>
                <http-invoker security-realm="ApplicationRealm"/>
            </host>
        </server>
        <servlet-container name="default">
            <jsp-config/>
            <websockets/>
        </servlet-container>
        <handlers>
            <file name="sh-resources" path="/resource" directory-listing="true"/>
        </handlers>
        <filters>
            <response-header name="server-header" header-name="Server" header-value="WildFly/11"/>
            <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
            <response-header name="content-png" header-name="Content-Type" header-value="image/png"/>
        </filters>
    </subsystem>

I hav some files in my "/resource" folder "1.jpg", "2.png", "js.js", "c.css" in:
http://localhost:8080/resource/1.jpg  --> shows nothing in browser
http://localhost:8080/resource/2.png  --> shows nothing in browser
http://localhost:8080/resource/js.js  --> shows nothing in browser
http://localhost:8080/resource/c.css  --> shows file content in browser
http://localhost:8080/resource/test.html  --> shows file content in browser
Why cant I see the images but can see the css & html content ? I think its because of incorrect mimetype setting ?
PS:
I tried serving the static files via a Servlet and setting the correct Mimetypes -> everything works perfectly in browser (chrome) I can see the images and .js content (and all other file endings).
My Servlet Code (app is running at "/" of server):
@WebFilter("/*")  //get all requests
public class MasterFilter implements javax.servlet.Filter {
        //...
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest req = (HttpServletRequest) request;
    String path = req.getRequestURI();

    if (path.startsWith("/resource")) {
        String mimetype = "text/html;charset=UTF-8";

        mimetype = path.contains(".png") ? "image/png" : mimetype;
        mimetype = path.contains(".jpg") || path.contains(".jpeg") ? "image/jpeg" : mimetype;
        mimetype = path.contains(".js") ? "text/javascript" : mimetype;
        mimetype = path.contains(".css") ? "text/css" : mimetype;
        response.setContentType(mimetype);
        chain.doFilter(request, response); // Goes to static resource in local folder "webapp/resource/"

    }
}

Any suggestions ?
Thanks in advance.
EDIT:
The above solution with the Servlet Filter works fine. But thanks to @JGlass's answer I also found another solution. (keep in mind that I absolutely need my Servlet Filter):

"MasterFilter" class forwards to "ServeResource" servlet:
@WebFilter("/*")
public class MasterFilter implements javax.servlet.Filter {
/*...*/
public void doFilter(..){
/*...*/
   if (path.startsWith("/resource")) {//forward to "ServeResource" servlet
   }
}
}

2."ServeResource" servlet serves static file:
@WebServlet("/resource/*")
public class ServeResource extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
 * @see HttpServlet#HttpServlet()
 */
public ServeResource() {
    super();
}

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
   response)
 */
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

  ServletContext cntx= req.getServletContext();
  String fileUri = req.getRequestURI();
  System.out.println("fileUri: "+fileUri);
  // Get the absolute path of the image (or any file)
  String filename = cntx.getRealPath(fileUri);
  System.out.println("file realPath: "+filename);
  // retrieve mimeType dynamically
  String mime = cntx.getMimeType(filename);
  System.out.println("mime type: "+mime);
  if (mime == null) {
    resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    return;
  }

  resp.setContentType(mime);
  File file = new File(filename);
  resp.setContentLength((int)file.length());

  FileInputStream in = new FileInputStream(file);
  OutputStream out = resp.getOutputStream();

  // Copy the contents of the file to the output stream
   byte[] buf = new byte[1024];
   int count = 0;
   while ((count = in.read(buf)) >= 0) {
     out.write(buf, 0, count);
  }
    out.close();
    in.close();
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doGet(request, response);
}

}

3.web.xml contains extension mappings:
    <mime-mapping>
    <extension>html</extension>
    <mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>txt</extension>
    <mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>js</extension>
    <mime-type>text/javascript</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>jpg</extension>
    <mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>jpeg</extension>
    <mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>png</extension>
    <mime-type>image/png</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>css</extension>
    <mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>zip</extension>
    <mime-type>application/zip</mime-type>
</mime-mapping>

Comment: *"I think its because of incorrect mimetype setting ?"* In other words, you haven't even checked the actual response headers..?? Why not?
Comment: Any reason you're using the servlet filter to handle the mime types instead of just allowing the final servlet in the chain handle them in which case you don't need a servlet filter?  My answer below is sort of two fold - I'd imagine you'd need the mime type mappings in the web.xml for static pages then the SO link for having a servlet handle mime types
Comment: @JGlass I need the servlet filter for my routing setup. If I get a request for "/resource" -> serve static file -> else forward request to some other servlets
Comment: Oh, I understand now.  Did you try BalusC's comment, you know how to do that in FF or IE correct?  And stupid questions, but try sys out'ing path to make sure it contains what you expect it to contains - you dont have an else.. so *possibly* the IF statements not even getting hit  Another thought, if it's a static resource... well I dunno, but maybe try adding the web.xml entries, see if they help?
Comment: And as per this [Javax servlet filterchain setting contenttype as text plain in firefox](https://stackoverflow.com/questions/28610752/javax-servlet-filterchain-setting-contenttype-as-text-plain-in-firefox) i'd try the mime types in the web.xml as it was the correct answer
Answer: You can put your mime-types mapping in your web.xml.  Here's an example:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="WebApp_ID" version="3.1">
    <display-name>TestDynamicWAR</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>testServlet</servlet-name>
        <servlet-class>com.mycompany.test.TestServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>testServlet</servlet-name>
        <url-pattern>/test</url-pattern>
    </servlet-mapping>

    <mime-mapping>
        <extension>html</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>txt</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>jpg</extension>
        <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>png</extension>
        <mime-type>image/png</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>js</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>css</extension>
        <mime-type>text/css</mime-type>
    </mime-mapping>

</web-app>

Note: you likely don't need the css and js as they're already working.  html and txt mime types are just an example as well

And I dont believe you need to deal with the servlet filter if you just want to handle the mime-types.  This SO post has the servlet dealing with the mime types Output an image file from a servlet
Comment: I will accept this as an answer, because it helped me find the solution.
Comment: Did that work?  I hope it did!  Seemed like it might help based on the last comment and link I had found.  Glad to help you out!
Comment: look at my updated post. Your answer helped to find another solution,but the first solution (with servlet filter ans chain.doFilter() had the same result)
 :)
Comment: Ahh, I see, its a mix of both!  Nice, good job!  Glad we got it going!  Cya!

Wildfly Undertow File Mimetypes


SSRS: Am I hallucinating?

Question: The solution at
SSRS - How to build a simple multi-column report?
says there is a layout tab under the report properties. Ive googled the subject to death and the same menu is referred to in multiple places. I can't find a Layout Tab or a Columns property anywhere. Have I gone round the bend?
Answer: Regarding the Columns property, you've clicked on the Body of the report which brings up the body properties.  To view the Columns property, click outside the Body of the report on the yellowish area.  The Columns property will be under the "Page" group.
Alternatively, you can open the Properties pane and select Report from the dropdown list at the top of the pane to view all report properties.
Comment: Thanks Alison. You are a ninja. =)
Answer: I believe that the Layout tab was removed in VS2008 (or "bids" based on VS2008). In the previous version there were three tabs - Data, Layout and Preview.
In the 2008 version, the functionality that was available in the Data tab moved to the report data pane and Layout was renamed (and redesigned) to Design.
Still a lot of articles, posts etc. out there that refers to the Layout-tab though.
Anyway... Most properties must be available elsewhere, such as the Report properties pane etc.

SSRS: Am I hallucinating?