Cannot play sound in expo project using expo-av

Question: <code>import {Audio} from 'expo-av';

  useEffect(() =>
    const enableAudio = async () => {
    await Audio.setAudioModeAsync({
      playsInSilentModeIOS: true,
      staysActiveInBackground: false,
      // interruptionModeAndroid: INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
      shouldDuckAndroid: false,
    });
  };
    enableAudio();
    playSound();
  }, []);

  const enableAudio = async () => {
    await Audio.setAudioModeAsync({
      playsInSilentModeIOS: true,
      staysActiveInBackground: false,
      // interruptionModeAndroid: INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
      shouldDuckAndroid: false,
    });
  };

  const playSound = () => {
    try {
      const { sound: s } = await Audio.Sound.createAsync(
        require('../../assets/sounds/strongClick.wav'),
      );
      setSound(s);
      await s.playAsync();
    } catch (err) {
      console.log(err);
    }
  };
</code>
No sound.
What am i doing wrong?
Answer: My bad.  I didn't have the volume up on the simulator.  For those having the same problem, just click the left side button on the simulator near the top and drag up.


Flashbuilder 4.6 PopupManager.removePopUp

Question: The PopupManager.removePopUp leaves the blurlayer on screen when using the modal option. I have anything tried but i can't find the solution to solve this problem.
Comment: Does PopupManager.visible = false work?
Comment: No that property is unknown by the PopupManager Class.
Comment: It seems to be a problem of the Flash Player 11.5.502.110?
Answer: I was having the same problem.
For me, what worked was to call the PopUpManager.removePopUp() method after finishing calling all the commands in the close handler callback function.
Previously, I called the PopUpManager.removePopUp(this) method within the custom window that I had previously added to the PopUpManager, but in the following line, I was calling another method (that wasn't even in the same customWindow class, but in another one). So I removed the PopUpManager.removePopUp(this) line from the customWindow, and put it at the very end of the last method in the other class.
This eliminated the problem


FAST ESP 5.3 SP4 - Turkish tr-tr fails

Question: Im using dotnet search api for FAST ESP 5.3. Everything works fine except for culture tr-tr i.e cultureid=1055.
Getting exception as "Error parsing information" on executing the below line
<code> qr = view.Search(query);
</code>
Can anybody please throw some light on this issue?
What & where to check whether my installed FAST ESP has turkish(tr-tr) support?
Your help is highly appreciated.
Thanks,
Arun
Answer: Finally resolved the issue as below through MS support:
<code>CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
qr = view.Search(query);
Thread.CurrentThread.CurrentCulture = originalCulture;
</code>

FAST ESP 5.3 SP4 - Turkish tr-tr fails


Integer Optimization

Question: I have an integer optimization problem that I've been pondering for the last several days. Here's an abbreviated version:
I have several wav song files with variable sizes (601201 kilobytes for example) and I want to know how to optimally arrange them into several CDs (with a given capacity in kilobytes).  The objective is to minimize the number of CDs and at the same time maximize the free space on the last CD.  Minimizing the number of CDs is not a problem.  I'm really concerned about the second part.
This kind of question seems like it would have relevance in many different areas and as such, I feel that I should be able to find information about it.  However, I don't know what exactly to search for.  Has anyone ever heard of this type of problem and if so, can you point me in the right research direction?
Thanks
Comment: How did you solve the first part ?
Comment: Try "worst fit" instead of "best fit".
Comment: I didn't actually solve the first part.  It just so happens that for the specific case I'm interested in, if you add all the tracks up and divide by the capacity of 1 CD, you get 18.1 and just through trial and error, I've found a solution that only takes 19 CDs.
Answer: Since you have found that you only need 19 CDs, I would suggest the following model:
$max \  C_{19}-\sum_{i=1}^n c_{i}\cdot y_{i19}$
The objective function calculate the remaining space on CD 19. It has to be maximized.

The sum of seizes of the songs on $CD_j$ cannot be greater than the capacity of $CD_j$:

$\sum_{i=1}^n c_{i}\cdot y_{ij} \leq C_{j} \quad \forall \ j \in 1,2,..,19$

Song i can only be on one CD

$\sum_{j=1}^{19} y_{ij}=1\ \forall \ i \in 1,2,...,n$
i: Index for song i
j: Index for CD j
$c_{i}$: Size of song i
$y_{ij}=\begin{cases} 1, \ \text{if song i is on CD j } \\ 0, \text{else} \end{cases}$
$C_j$: capacity of CD j
Comment: I like it!  I'll get back to you once I'm able to implement it.
Comment: @G-Cam I´m interested to know, if it works.
Comment: It worked by the way.  Thanks again!
Comment: Nice to hear. It is also nice, that you have given a feedback.

Integer Optimization


how to add and remove same item in ListView in android?

Question: I have 3 string text 'A' , 'B' , 'C' and it is added in ListView . And one TexView as Title .
1 . When i click on List-view Item 'A' this item will be display in TexView and Item 'A' remove from ListView.Only 'B','C' remianing in List.
2 . When i click on List-view Item 'B' this item will be display in TexView and same Item 'B' remove from ListView and 'A','C' will be showing in ListView.
3 . When i click on List-view Item 'C' this item will be display in TexView and same Item 'C' remove from ListView and 'A','B' will be showing in ListView.

It means first i have 3 item in my ListView after adding in textView as title only 2 item will be display every time in ListView. How to work with this logic.Can someone help me .
Here is my code.
String[] values = new String[] { "A", "B", "C"};

arr = new ArrayList<String>(Arrays.asList(values));
                filterPost_adapter = new ArrayAdapter<String>(getApplicationContext(),R.layout.filter_popup_list_item , R.id.text_filter_title, arr);
                filter_list.setAdapter(filterPost_adapter);

filter_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id)
                    {
                        String selectedFromList =(filter_list.getItemAtPosition(position).toString());
                        Log.e("selectedFromList ", " = " + selectedFromList);
                        removeItemFromList(position);

                        if(selectedFromList.equals("A"))
                        {
                            textSearch.setText("A");
                            populate_MyAllPostList();

                        }
                        if(selectedFromList.equals("B"))
                        {
                            textSearch.setText("B");
                            populateList();

                        }
                        if(selectedFromList.equals("B"))
                        {
                            textSearch.setText("B");
                            populate_StarPost();

                        }
                    }
                });

 protected void removeItemFromList(int position) {
        final int deletePosition = position;
        arr.remove(deletePosition);
        filterPost_adapter.notifyDataSetChanged();
        filterPost_adapter.notifyDataSetInvalidated();}

Answer: in on item click write below code:
     @Override
       public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
    if(filterPost_adapter.getCount()==3){
          String data = filterPost_adapter.getItem(position);
            textVeiw.setText(data);
         filterPost_adapter.remove(data);
    }else{
        String temp = textView.getText().toString();
        String data = filterPost_adapter.getItem(position);
        textVeiw.setText(data);
        filterPost_adapter.remove(data);
       filterPost_adapter.add(temp);
    }
 }

Answer: You only removed the item from your Activity ArrayList I supose
to update the Listview you have to call a method from the adapter and update it's arraylist before calling notifyDataSetChanged()
Exemple :
In your activity
-> here remove the item from the activity arraylist and then
filterPost_adapter.updatelist(arrayListWithRemovedItem);

In your adapter :
public void updateList(ArrayList list)
{
    mLocalArrayList = list;
    this.notifyDataSetChanged();
}

Comment: Item remove properly.But before removing item i want to add TextView String in list-view which is displaying listview item in  TextView  before removing second item from listview.
Comment: If you also want to update some of the list cells (you are not very clear on this) you should do a if() test in getView() depending on what is the condition  and change the cell's views when they are created/recycled
Comment: I think you are not understand my question.
Comment: Sorry for my bad English, I'm not influent in English. So that's why writes  above 3 points in my post 1 ,2  ,3 for clearer.


How to append CSS from a variable in CSS or HTML file? Angular 4+

Question: Is that possible to append CSS from a variable. for example
var myHtml = "
My example html
";

// in html i can do this

But what if I have CSS stored in variable. like below:-
var myCss = ".exampleClass {margin: 0;width: 100%;}";

How can I add this css variable in my CSS file OR in HTML as a working css?
I'm using Angular 4+ but even JavaScript solution also appreciated.
Answer: You can simply insert a new


Feisty network mount refuses to umount

Question: I have a particular network share that's giving me grief. Basically, we had two NAS devices which had to be moved to another building. I updated /etc/fstab to the new IP addresses and tried to remount them. One of the NAS devices went through the process just fine. The other one, however, is being rude.
I tried the suggestions in this thread, but they didn't work:
When I type umount -f /mnt/gsrnas2, it says Device is busy
If I try to cd /mnt/gsrnas2 and then ls, the terminal locks up and I can't break out with Ctrl+C
When I try fuser -mk /mnt/gsrnas2 or lsof | grep /mnt/gsrnas2, the terminal freezes with those commands as well.
All of the other NFS mounts on the server are behaving just fine, and I can umount and mount them without any problems.
I'm sure that no one is actively using this mount point, because it points to an unoccupied IP address.
Answer: First use the lsof -P | grep filename command to see which processes have a file handle for files on your device. You can use kill or something similar to try and terminate them gracefully.
If nothing respond to the polite requests, then its not going to clean up gracefully, so you can make some progress with the lazy and force option like so;
umount -l -f /mnt/gsrnas2

Comment: That got it. AND I was able to immediately remount. Bonus! Thanks for your help!

Feisty network mount refuses to umount


avoid DOM manipulation using jQuery in ng-repeat

Question: I am new to angular and working on a simple CRUD application. I understand that I must avoid DOM manipulation using jQuery if I can.
I am displaying data on the page after I get data from server using ng-repeat.
My problem is that I want to remove the row from the DOM when I delete the row data from the server. I have accomplished this using jQuery for now.
I have this code:
View

Add Project

Project Search: <input type="text" ng-model="search.projectName" id="search.projectName" />

        Project ID
        Project Name
        WBS
        Action

        {{project.id}}
        {{project.projectName}}
        {{project.WBS}}

            Delete
            Edit

Controller
enterprise.controller('projectController', ['$scope','$route','$modal','projectService',function($scope,$route,$modal,projectService) {
$scope.projects = projectService.getAllProjects();
$scope.deleteProject=function(projectID){
    projectService.deleteProject(projectID).$promise.then(function(){
        $('#' + projectID).remove();
    },function(){
        console.log('Delete failed');
    });
};}]);

I understand that I must not use $('#' + projectID).remove(); and make use of directives for this kind of stuff. In case of non ng-repeat scenarios this could have been pretty easy. How should this be approached.
Answer: Pretty simply actually, splice out the index you want gone by passing $index to your delete function:
ng-click="deleteProject(project.id, $index)"

$scope.deleteProject=function(projectID, index){
    projectService.deleteProject(projectID).$promise.then(function(){
        $scope.projects.splice(index, 1);
    },function(){
        console.log('Delete failed');
    });
};


Postfix seems to send spam

Question: I recently discovered this in my postfix-log:
<code>Aug  4 11:09:12 mail postfix/smtpd[71597]: connect from unknown[220.127.116.11]
Aug  4 11:09:14 mail postfix/smtpd[71597]: Anonymous TLS connection established from unknown[18.104.22.168]: TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)
Aug  4 11:09:17 mail postfix/smtpd[71597]: 1AE3B7EC3D: client=unknown[188.8.131.52], sasl_method=PLAIN, email@example.com
Aug  4 11:09:30 mail postfix/cleanup[71606]: 1AE3B7EC3D: message-id=<email@example.com>
Aug  4 11:09:30 mail opendkim[24666]: 1AE3B7EC3D: DKIM-Signature field added (s=mail, d=MYDOMAINCOM2012)
Aug  4 11:09:30 mail postfix/qmgr[27543]: 1AE3B7EC3D: from=<firstname.lastname@example.com>, size=2149, nrcpt=20 (queue active)
Aug  4 11:09:31 mail postfix/smtpd[71611]: connect from MAIL.example.com[172.16.0.3]
Aug  4 11:09:31 mail postfix/smtpd[71611]: 14C4C7EC57: client=MAIL.example.com[172.16.0.3]
Aug  4 11:09:31 mail postfix/cleanup[71606]: 14C4C7EC57: message-id=<firstname.lastname@example.com>
Aug  4 11:09:31 mail postfix/smtpd[71611]: disconnect from MAIL.example.com[172.16.0.3]
Aug  4 11:09:31 mail postfix/qmgr[27543]: 14C4C7EC57: from=<firstname.lastname@example.com>, size=2891, nrcpt=20 (queue active)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/lmtp[71609]: 1AE3B7EC3D: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=15, delays=14/0.06/0.03/0.47, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as 14C4C7EC57)
Aug  4 11:09:31 mail postfix/qmgr[27543]: 1AE3B7EC3D: removed
Aug  4 11:09:31 mail postfix/smtpd[71597]: 968227EC58: client=unknown[188.8.131.52], sasl_method=PLAIN, email@example.com
Aug  4 11:09:31 mail postfix/smtp[71612]: 14C4C7EC57: to=<email@example.com>, relay=mx.bluebottle.com[184.108.40.206]:25, delay=0.61, delays=0.05/0.02/0.22/0.32, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 37DBE9EC4)
Aug  4 11:09:32 mail postfix/smtp[71618]: 14C4C7EC57: to=<firstname.lastname@example.com>, relay=vfxplc.com.inbound10.mxlogic.net[22.214.171.124]:25, delay=1.6, delays=0.05/0.05/0.6/0.85, dsn=5.0.0, status=bounced (host vfxplc.com.inbound10.mxlogic.net[18.104.22.168] said: 554 Denied [CS] [b6d90c55.0.552923.00-2289.1107665.p02c11m005.mxlogic.net] (Mode: normal) (in reply to end of DATA command))
Aug  4 11:09:32 mail postfix/smtp[71616]: 14C4C7EC57: to=<firstname.lastname@example.com>, relay=mx4.hotmail.com[18.104.22.168]:25, delay=1.6, delays=0.05/0.04/0.49/1, dsn=2.0.0, status=sent (250  <firstname.lastname@example.com> Queued mail for delivery)
Aug  4 11:09:32 mail postfix/smtp[71614]: 14C4C7EC57: to=<firstname.lastname@example.com>, relay=equitydirect.co.ke.inbound10.mxlogicmx.net[220.127.116.11]:25, delay=1.6, delays=0.05/0.03/0.9/0.66, dsn=5.0.0, status=bounced (host equitydirect.co.ke.inbound10.mxlogicmx.net[126.96.36.199] said: 554 Denied [CS] [b6d90c55.0.778752.00-2304.1523550.s12p02m085.mxlogic.net] (Mode: normal) (in reply to end of DATA command))
Aug  4 11:09:32 mail postfix/smtp[71620]: 14C4C7EC57: to=<email@example.com>, relay=mx-eu.mail.am0.yahoodns.net[22.214.171.124]:25, delay=1.8, delays=0.05/0.07/0.08/1.6, dsn=2.0.0, status=sent (250 ok dirdel 4/2)
Aug  4 11:09:32 mail postfix/smtp[71620]: 14C4C7EC57: to=<email@example.com>, relay=mx-eu.mail.am0.yahoodns.net[220.127.116.11]:25, delay=1.8, delays=0.05/0.07/0.08/1.6, dsn=2.0.0, status=sent (250 ok dirdel 4/2)
Aug  4 11:09:32 mail postfix/smtp[71620]: 14C4C7EC57: to=<email@example.com>, relay=mx-eu.mail.am0.yahoodns.net[220.127.116.11]:25, delay=1.8, delays=0.05/0.07/0.08/1.6, dsn=2.0.0, status=sent (250 ok dirdel 4/2)
Aug  4 11:09:32 mail postfix/smtp[71620]: 14C4C7EC57: to=<email@example.com>, relay=mx-eu.mail.am0.yahoodns.net[188.8.131.52]:25, delay=1.8, delays=0.05/0.07/0.08/1.6, dsn=2.0.0, status=sent (250 ok dirdel 4/2)
Aug  4 11:09:32 mail postfix/smtp[71620]: 14C4C7EC57: to=<email@example.com>, relay=mx-eu.mail.am0.yahoodns.net[22.214.171.124]:25, delay=1.8, delays=0.05/0.07/0.08/1.6, dsn=2.0.0, status=sent (250 ok dirdel 4/2)
Aug  4 11:09:32 mail postfix/smtp[71620]: 14C4C7EC57: to=<email@example.com>, relay=mx-eu.mail.am0.yahoodns.net[22.214.171.124]:25, delay=1.8, delays=0.05/0.07/0.08/1.6, dsn=2.0.0, status=sent (250 ok dirdel 4/2)
Aug  4 11:09:33 mail postfix/smtp[71613]: 14C4C7EC57: to=<email@example.com>, relay=mx.bt.lon5.cpcloud.co.uk[22.214.171.124]:25, delay=2.5, delays=0.05/0.02/0.08/2.4, dsn=2.0.0, status=sent (250 <55BF549902860DA2> Mail accepted)
Aug  4 11:09:35 mail postfix/smtp[71615]: 14C4C7EC57: to=<firstname.lastname@example.com>, relay=mx1.safaricombusiness.co.ke[188.8.131.52]:25, delay=4.2, delays=0.05/0.03/2.6/1.5, dsn=2.0.0, status=sent (250 ok:  Message 1038363882 accepted)
Aug  4 11:09:35 mail postfix/smtp[71615]: 14C4C7EC57: to=<firstname.lastname@example.com>, relay=mx1.safaricombusiness.co.ke[22.214.171.124]:25, delay=4.2, delays=0.05/0.03/2.6/1.5, dsn=2.0.0, status=sent (250 ok:  Message 1038363882 accepted)
Aug  4 11:09:35 mail postfix/smtp[71615]: 14C4C7EC57: to=<email@example.com>, relay=mx1.safaricombusiness.co.ke[188.8.131.52]:25, delay=4.2, delays=0.05/0.03/2.6/1.5, dsn=2.0.0, status=sent (250 ok:  Message 1038363882 accepted)
Aug  4 11:09:36 mail postfix/smtp[71621]: 14C4C7EC57: to=<email@example.com>, relay=mta5.am0.yahoodns.net[184.108.40.206]:25, delay=5.7, delays=0.05/0.07/0.41/5.2, dsn=2.0.0, status=sent (250 ok dirdel 4/0)
Aug  4 11:09:36 mail postfix/smtp[71621]: 14C4C7EC57: to=<firstname.lastname@example.com>, relay=mta5.am0.yahoodns.net[184.108.40.206]:25, delay=5.7, delays=0.05/0.07/0.41/5.2, dsn=2.0.0, status=sent (250 ok dirdel 4/0)
Aug  4 11:09:36 mail postfix/smtp[71621]: 14C4C7EC57: to=<firstname.lastname@example.com>, relay=mta5.am0.yahoodns.net[18.104.22.168]:25, delay=5.7, delays=0.05/0.07/0.41/5.2, dsn=2.0.0, status=sent (250 ok dirdel 4/0)
Aug  4 11:09:36 mail postfix/smtp[71621]: 14C4C7EC57: to=<email@example.com>, relay=mta5.am0.yahoodns.net[126.96.36.199]:25, delay=5.7, delays=0.05/0.07/0.41/5.2, dsn=2.0.0, status=sent (250 ok dirdel 4/0)
Aug  4 11:09:43 mail postfix/cleanup[71606]: 968227EC58: message-id=<email@example.com>
Aug  4 11:09:43 mail opendkim[24666]: 968227EC58: DKIM-Signature field added (s=mail, d=MYDOMAINCOM2012)
Aug  4 11:09:43 mail postfix/qmgr[27543]: 968227EC58: from=<firstname.lastname@example.com>, size=2204, nrcpt=20 (queue active)
Aug  4 11:09:43 mail postfix/smtpd[71611]: connect from MAIL.example.com[172.16.0.3]
Aug  4 11:09:43 mail postfix/smtpd[71611]: B0D2D7EC70: client=MAIL.example.com[172.16.0.3]
Aug  4 11:09:43 mail postfix/cleanup[71606]: B0D2D7EC70: message-id=<firstname.lastname@example.com>
Aug  4 11:09:43 mail postfix/smtpd[71611]: disconnect from MAIL.example.com[172.16.0.3]
Aug  4 11:09:43 mail postfix/qmgr[27543]: B0D2D7EC70: from=<email@example.com>, size=2946, nrcpt=20 (queue active)
Aug  4 11:09:43 mail amavis[24687]: (24687-07) Passed CLEAN {RelayedOpenRelay}, [18.104.22.168]:4678 [184.108.40.206] <email@example.com> -> <firstname.lastname@example.com>,<email@example.com>,<firstname.lastname@example.com>,<email@example.com>,<firstname.lastname@example.com>,<firstname.lastname@example.com>,<email@example.com>,<firstname.lastname@example.com>,<firstname.lastname@example.com>,<firstname.lastname@example.com>,<firstname.lastname@example.com>,<email@example.com>,<firstname.lastname@example.com>,<firstname.lastname@example.com>,<firstname.lastname@example.com>,<email@example.com>,<firstname.lastname@example.com>,<firstname.lastname@example.com>,<firstname.lastname@example.com>,<email@example.com>, Queue-ID: 968227EC58, Message-ID: <firstname.lastname@example.com>, mail_id: JR1l308kvN-H, Hits: -, size: 2531, queued_as: B0D2D7EC70, 378 ms
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<firstname.lastname@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
Aug  4 11:09:43 mail postfix/lmtp[71609]: 968227EC58: to=<email@example.com>, relay=172.16.0.3[172.16.0.3]:10024, delay=13, delays=12/0/0.01/0.38, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[172.16.0.3]:10025): 250 2.0.0 Ok: queued as B0D2D7EC70)
</code>
172.16.0.3 is the internal IP of my mailserver-jail.
I have a little trouble interpreting this log. Does it mean that someone is using my username (email@example.com) to send spam? If so, then how is it possible and how do I fix it?
This is my Postfix main.cf:
<code>### GENERAL
smtpd_banner = $myhostname ESMTP $mail_name
biff = no
append_dot_mydomain = no
daemon_directory = /usr/local/libexec/postfix
command_directory = /usr/local/sbin
myhostname = MAIL.example.com
myorigin = example.com
mydestination = 172.16.0.3
#relayhost =
mynetworks = 172.16.0.0/12 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
alias_database = hash:/etc/aliases
alias_maps = $alias_database
message_size_limit = 50000000
smtpd_helo_required = yes

### VIRTUAL
virtual_mailbox_domains = pgsql:/usr/local/etc/postfix/postgres-virtual-mailbox-domains.cf
virtual_mailbox_base = /var/vmail
virtual_mailbox_maps = pgsql:/usr/local/etc/postfix/postgres-virtual-mailbox-maps.cf
virtual_alias_maps = pgsql:/usr/local/etc/postfix/postgres-virtual-alias-maps.cf
virtual_minimum_uid = 150
virtual_uid_maps = static:150
virtual_gid_maps = static:6
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1

### SASL Authentication
smtpd_sasl_auth_enable = yes
smtpd_sasl_exceptions_networks = $mynetworks
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

smtpd_tls_cert_file = /usr/local/etc/ssl/MAIL.example.com/private.crt
smtpd_tls_key_file = /usr/local/etc/ssl/MAIL.example.com/private.key
smtpd_tls_CAfile = /usr/local/etc/ssl/MAIL.example.com/cacert.pem
smtpd_tls_security_level = may
smtpd_tls_received_header = no
smtpd_tls_loglevel = 1
smtpd_use_tls = yes
smtpd_tls_auth_only = yes
tls_random_source = dev:/dev/urandom

debug_peer_level                = 2
debugger_command                =
show_user_unknown_table_name    = no

### LIMITATIONS
smtpd_client_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_rbl_client ix.dnsbl.manitu.net,
    reject_rbl_client dnsbl.sorbs.net,
    reject_rbl_client sbl-xbl.spamhaus.org,
    reject_rbl_client zen.spamhaus.org,
    reject_rbl_client blackholes.easynet.nl,
    reject_rbl_client dialup.blacklist.jippg.org,
    reject_rbl_client cbl.abuseat.org,
    reject_rbl_client bl.spamcop.net,
    reject_rbl_client sbl.spamhaus.org,
    reject_rbl_client t1.dnsbl.net.au,
    reject_rhsbl_client block.rhs.mailpolice.com,
    reject_rhsbl_client dynamic.rhs.mailpolice.com,
    reject_rhsbl_client rhsbl.sorbs.net,
    reject_rhsbl_client bogusmx.rfc-ignorant.org

smtpd_sender_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unknown_sender_domain,
    reject_sender_login_mismatch,
    reject_rhsbl_sender rhsbl.sorbs.net,
    reject_rhsbl_sender rddb.dnsbl.net.au,
    reject_rhsbl_sender endn.dnsbl.net.au,
    reject_rhsbl_sender rhsbl.sorbs.net,
    reject_rhsbl_sender block.rhs.mailpolice.com,
    reject_rhsbl_sender dynamic.rhs.mailpolice.com

smtpd_recipient_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_unauth_destination,
  reject_unknown_recipient_domain,
  reject_rbl_client ix.dnsbl.manitu.net,
  reject_rbl_client dnsbl.sorbs.net,
  reject_rbl_client bl.spamcop.net,
  reject_rbl_client zen.spamhaus.org,
  reject_rbl_client dnsbl-1.uceprotect.net

readme_directory = /usr/local/share/doc/postfix
sample_directory = /usr/local/etc/postfix
sendmail_path = /usr/local/sbin/sendmail
html_directory = /usr/local/share/doc/postfix
setgid_group = maildrop
manpage_directory = /usr/local/man
newaliases_path = /usr/local/bin/newaliases
mailq_path = /usr/local/bin/mailq
queue_directory = /var/spool/postfix
mail_owner = postfix
data_directory = /var/db/postfix
disable_vrfy_command = yes
smtpd_delay_reject = yes
content_filter = amavisfeed:[172.16.0.3]:10024
#receive_override_options = no_address_mappings
smtpd_milters = inet:172.16.0.3:54321
non_smtpd_milters = inet:172.16.0.3:54321
milter_default_action = accept
inet_protocols = ipv4
</code>
172.16.0.3:54321 is OpenDKIM.
And this is my master.cf:
<code> smtp      inet  n       -       n       -       -       smtpd
 pickup    unix  n       -       n       60      1       pickup
 cleanup   unix  n       -       n       -       0       cleanup
 qmgr      unix  n       -       n       300     1       qmgr
 tlsmgr    unix  -       -       n       1000?   1       tlsmgr
 rewrite   unix  -       -       n       -       -       trivial-rewrite
 bounce    unix  -       -       n       -       0       bounce
 defer     unix  -       -       n       -       0       bounce
 trace     unix  -       -       n       -       0       bounce
 verify    unix  -       -       n       -       1       verify
 flush     unix  n       -       n       1000?   0       flush
 proxymap  unix  -       -       n       -       -       proxymap
 proxywrite unix -       -       n       -       1       proxymap
 smtp      unix  -       -       n       -       -       smtp
 relay     unix  -       -       n       -       -       smtp
 showq     unix  n       -       n       -       -       showq
 error     unix  -       -       n       -       -       error
 retry     unix  -       -       n       -       -       error
 discard   unix  -       -       n       -       -       discard
 local     unix  -       n       n       -       -       local
 virtual   unix  -       n       n       -       -       virtual
 lmtp      unix  -       -       n       -       -       lmtp
 anvil     unix  -       -       n       -       1       anvil
 scache    unix  -       -       n       -       1       scache
 dovecot    unix  -       n       n       -       -       pipe
    flags=DRhu user=vmail:mail argv=/usr/local/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}
 amavisfeed unix  -       -       n       -       2       lmtp
    -o lmtp_data_done_timeout=1200
    -o lmtp_send_xforward_command=yes
172.16.0.3:10025 inet n - n - - smtpd
   -o content_filter=
   -o smtpd_delay_reject=no
   -o smtpd_client_restrictions=permit_mynetworks,reject
   -o smtpd_helo_restrictions=
   -o smtpd_sender_restrictions=
   -o smtpd_recipient_restrictions=permit_mynetworks,reject
   -o smtpd_data_restrictions=reject_unauth_pipelining
   -o smtpd_end_of_data_restrictions=
   -o smtpd_restriction_classes=
   -o mynetworks=172.16.0.0/12
   -o smtpd_error_sleep_time=0
   -o smtpd_soft_error_limit=1001
   -o smtpd_hard_error_limit=1000
   -o smtpd_client_connection_count_limit=0
   -o smtpd_client_connection_rate_limit=0
   -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters,no_address_mappings
   -o local_header_rewrite_clients=
   -o smtpd_milters=
   -o local_recipient_maps=
   -o relay_recipient_maps=
</code>
Comment: Open relay tests do not detect this because it is not an open relay. It is a password protected relay. The password has been compromised but the relay can still only be used by those who have it, not by everyone.
Comment: Seems like external relay is happening. Include following value in main.conf & try. smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination Restart postfix . Refer http://serverfault.com/questions/665258/postfix-how-to-prevent-external-clients-from-using-my-server-as-a-relay
Comment: @StackPlayer: I included it in main.conf. Is it normal, that open relay tests don't detect this kind of relay?
Answer:
Does it mean that someone is using my username (firstname.lastname@example.com) to send spam?

YES
This log line was the proof of it.
<code>Aug  4 11:09:17 mail postfix/smtpd[71597]: 1AE3B7EC3D: client=unknown[184.108.40.206], sasl_method=PLAIN, firstname.lastname@example.com
</code>
As you have <code>permit_sasl_authenticated</code> in <code>main.cf</code>, then you authorize anyone who knows your credential to send email via your server.

If so, then how is it possible?

There many ways to make your credential leaked.

Keylogger planted in your computer
Worm sends sensitive information (including your credential)
Weak password was retrieved via brute-force or guessing
Phising email
And many others...

and how do I fix it?

First disable the account, either change its status in postgre database or change the password into random one. Identify how your credential was leaked and fix that hole too.
Additional notes:
Your postfix configuration was fine. Although it's little bit overlapping each other as you repeat some of the restriction in each stage. You should also verify that each rhsbl/rbl provider was still active maintaining the blacklist to avoid false-positives.
Answer: The log shows that someone has obtained the password for the mail account email@example.com and is using it to send SPAM through the server.

The entry at time 11:09:17 shows a successful SASL authentication
from IP address 220.127.116.11 with username email@example.com.
The entry at 11:09:30 shows reception and queuing of a message with sender address email@example.com with twenty declared recipients over that connection.
The entries timestamped 11:09:31 show these twenty copies being first forwarded internally within Postfix and then sent out to the recipients.

The most frequent cause for that kind of incident is a user falling for a phishing mail telling him or her to enter his or her mail address and password on some credentials harvesting web form.
To fix:

Change that account's password immediately.
Choose a (more) sensible password, specifically one not used anywhere else.
Be (more) careful not to reveal that password to anybody, specifically do not enter it on any website.

Postfix seems to send spam


Showing one set is a subset of another

Question: Let's say you have sets $A,\, B,$ and $C.$
How would you show that $[(A-B) - C]\subseteq (A-C)$ using a venn diagram or logical translations?
How can this even be done when you don't know the members of $A,\, B,$ or $C$?
Comment: @Bob: but the two sets are not equal (not equivalent). What IS TRUE is that $\,(A - B) - C\,$ is a *subset of* $\,A - C,\,$ which simply means that all of $\,(A-B) - C\,$ is "contained within" $A - C$. By definition of "subset", that means every element of $\,(A - B) - C\,$ is necessarily also an element of $\,A - C\,$ but not necessarily the other way around. Two sets $X, Y$ are equal if and only if $X\subseteq Y$ AND $Y\subseteq X$. Here we have only one containment.
Comment: Look at [this](https://www.google.com/#q=site:http%3A%2F%2Fmath.stackexchange.com+%22element+chasing%22) for some examples. I also recommend you look at the book [How to Prove It: A Structured Approach](http://www.amazon.com/How-Prove-Structured-Daniel-Velleman/dp/0521675995), by [D.J. Velleman](http://www.cs.amherst.edu/~djv/).
Comment: If $x \in [(A-B)-C]$ that means $x$ is in $A$, but in neither $B$ nor $C$. How would you characterize an element of $(A-C)$ similarily?
Comment: @Arthur x is in A, but not in C. How can I combine the two to conclude they're subsets of each other?
Comment: @Bob They aren't subsets of each other.
Comment: By the way, if two sets _are_ subsets of each other, then they are equal.
Comment: I'm trying to show that [(A-B)-C] is a subset of (A-C) using a logical equivalence. I'm not sure how to do that.
Answer: You'd need to use logical translations, implicitly (no need for logic symbols though - words work fine), in the sense that you need to use the definition of set-minus where $\;x \in X - Y\;$ means that $\;x \in X\;$ AND $\,x \notin Y.$
Showing that set-membership in $\,X\,$ implies set-membership in $\,Y,\,$ proves that $\,X\subseteq Y$. Logically, this is establishing that $\,x \in [(A - B) - C] \implies x \in (A - C).$
In this case, start by assuming $\,x \in (A - B) - C,\,$ and then unpack what this means using the definition of set-minus. Using this you can argue that it must follow that $\,x \in A-C.\,$ This is equivalent to proving that $\,(A-B) -C \subseteq A - C$.
Comment: See the edited answer, Bob.
Comment: @Bob What my answer is saying is that we can express $[(A - B) - C] \subseteq (A - C)$ as the logically equivalent statement $\,x \in [(A-B)-C] \rightarrow x \in (A-C).\,$ So to prove $\,[(A - B) - C] \subseteq (A - C),\,$ we need to prove $\,x \in [(A-B)-C] \rightarrow x \in (A-C).\,$ To prove this, we start by assuming $\,x \in [(A - B) - C]$, and show that this implies $(\rightarrow)\,$ that $\,x \in (A-C).\,$ That's a very straightforward task, but once you've done that, you've proven the equivalent statement $\,[(A - B) - C] \subseteq [A - C]$.
Comment: Ah, so this would 'show' that they are subsets of each other?
Comment: I suppose I am confusing the word 'show' with 'prove'.
Comment: @Bob To clarify, this only proves that $(A-B)-C\subseteq A-C$. It doesn't prove that they are subsets of each other, it just proves one is a subset of the other.
Comment: Is it possible to write out an equivalence to x ∈ (A-B) - C ---> x ∈ (A-C)?

It doesn't make any sense that you can just write that out, without proving (A-B) - C is a subset of A-C
Comment: Thanks a lot! I've figured it out with your help.
Comment: You're welcome, @Bob! I knew you could do it!
Answer: Let $x\in(A-B)-C$. By the definition of set difference we know that $x\in A-B$ and $x\notin C$. Since $x\in A-B$ we know that $x\in A$ and $x\notin B$. Thus we have $x\in A$ and $x\notin C$ which implies that $x\in A-C$ and we can conclude that $(A-B)-C\subseteq A-C$.
Comment: How do we know this about $x$?  What is $x$?
Comment: amWhy posted the first step for Bob by letting x be an element of (A-B)-C. I was just letting Bob know what needs to follow by using the definition of set difference.
Comment: Oh, I see.  But I think if you're going to post this as an answer rather than a comment on amWhy's answer, then it should be self-contained.
Comment: I understand. Is my edit acceptable?
Comment: Yep, looks good now.
Comment: I'm new to this site. I'm learning slowly. Any tips are greatly appreciated. Thank you! :)

Showing one set is a subset of another


Combobox with fixed text

Question: I am trying to set a fixed text inside a combobox, but a cannot "overwrite" the default behaviour that it always set the text to the SelectedItem.ToString(). Is there a way to do this?
My current combobox looks like this:
<ComboBox x:Name="ddlSection"
                Text="Hello World!"
                ItemsSource="{Binding Sections}"
                SelectedItem="{Binding SelectedSection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
</ComboBox>

In this combobox there should always be the text "Hello World!" be displayed no matter what item is selected, the only way I can achieve this right now is using the SelectedItemChanged and reset the Text Property manually.
Comment: How user will see, that he had selected another item?
Comment: Text shall always stay Hello World but user may select different items when popup is open? How much sense it that making to you?
Comment: I know its not the default behaviour, and that the user will not see whats currently selected but its kinda hard to explain why exactly I need it. So yes, thats exactly what I want and I am sorry it doesnt make any sense to you, but is there a way to do it.
Comment: Yes there is a way to do it. Use DataTemplates or ControlTemplates.
Comment: @devhedgehog Could you pls provide a more explained answer, and again not that you recommend the same as gleng, that items within the popup should stay as is and display "correctly" only the textbox (within a comboxbox) should display a different value ("Hello World!").
Comment: madd0 provided you a nice example. Take a look at it.
Answer: You'll need to make a custom ItemTemplate. Try this:
<ComboBox ItemsSource="{Binding Binding Sections}" SelectedItem="{Binding SelectedSection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
    <ComboBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="Hello World!"/>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

Comment: Sorry, but thats not what I like to do, since this will change the Items in the list, the list shall display the correct values but only the Text should be different (fixed).
Comment: This doesn't change the items in the list. It changes the way they are displayed.
Comment: Yeah thats what I meant, and its not what I desire the items should display as is, but the text within the textbox part should always contain the same text no matter what item is selected.
Answer: You have to change the template of your ComboBox. You can create a copy by right clicking then selecting Edit Template > Edit a Copy...
In the original template you will find a ContentPresenter whose content is bound to the selected element:
<ContentPresenter x:Name="contentPresenter"
    ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
    ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
    Content="{TemplateBinding SelectionBoxItem}"
    ... />

You can either replace this ContentPresenter with whatever you want to display, or simply replace the value of the Content property with your own binding or hard-coded value (e.g. "Hello world")

Combobox with fixed text


Existence of certain homomorphism on cochaincomplexes

Question: I found the following problem online. I'm not sure if this is easy or not as I'm not sure how one defines the class of an element in $H^p$.
Let $C=\bigoplus_{p\in\mathbb Z}C^p$, $C^\prime$ ja $C^{\prime\prime}$ be cochaincomplexes and let
$$0\to C^\prime\overset u\to C\overset v\to C^{\prime\prime}\to 0$$
be the exact sequence on complexes.
How can I show that there are well defined homomorphisms
$$\ldots \to H^p(C^\prime  )\overset{u_*}\to H^p(C)\overset{v_*}\to H^p(C^{\prime\prime})\overset\delta\to H^{p+1}(C^\prime)\to\ldots$$
satisfying: $u_*(\overline{z^\prime})=\overline{u(z^\prime)}$ as $z^\prime\in Z^p(C^\prime)$ $(\overline{z^\prime}\in H^p(C^\prime)$ is the class of $z^\prime)$, $v_*(\overline{z})=\overline{v(z)}$ as $z\in Z^p(C)$, and $\delta (\overline{z^{\prime\prime}})=\overline{z^\prime}$, as
$z^{\prime\prime}\in Z^p(C^{\prime\prime})$, $z^\prime\in Z^{p+1}(C^\prime)$ and for some $x\in C^p$ satisfies $v(x)=z^{\prime\prime}$, $dx=u(z^\prime)$.

How can I show the existence of homomorphisms?
How can I show that the pair of homomorphisms $(u_*,v_*)$ is exact?
How can I show that the pair $(v_*,\delta)$ is exact?
Comment: Any book on homological algebra treats this. For example, Bourbaki's. Jacobson's BAII has a treatment, too.
Answer: Well, this is a classical result of homological algebra, the cohomology LES. You get your sequence by applying the Snake lemma to the commutative diagram with exact rows having as columns exact sequences of the form $0\rightarrow H^n(C)\rightarrow C^n/B^n(C)\rightarrow Z^n(C)[1]\rightarrow H^n(C)[1]\rightarrow 0$ (note that $H^n(C)$ is the kernel of the middle map, which is induced by $d$, and $H^n(C)[1]$ the cokernel), and the rows are induced by the short exact sequence $0\rightarrow C'\rightarrow C\rightarrow C''\rightarrow 0$ of complexes. Alternatively you do it by a diagram chase. But you should learn about the snake lemma, it is very useful to establish diagram lemmas, see e.g. here: https://math.stackexchange.com/questions/581698/on-a-commutative-diagram/1085070#1085070 . Details can be found in any homological algebra textbook, e.g. Weibel or Bourbaki


perl client-to-server file sending and file retrieval

Question: I'm a newbie in stackoverflow and perl IO::Socket sockets programming and I have a problem with my project. I have a TCP client and server script where the client can send file to the server. The server side creates a directory where it stores the received received files.
Is it possible for me to view and retrieve/download the files that I have sent to the server?
My professor told me that if i could add these functions he would reconsider my project.
help would be greatly appreciated. THANK YOU!
Answer: A possible approach will be to send a "string" command to the server that will trigger the server to scan the download directory for all file by using the code below
The names of the files can then be sent by the server app back through the client socket
Subsequently another string command for download can be sent to the server indicating the file path of the file your're interested in and you'll use the same process you used to send the file to the server in the first place to send it back to the client.
Comment: Sorry for my ignorance I cant seem to catch up so i have to ask another question. Would the server be the one to send the file back to the client or would the client be able to retrieve the file by itself? :(
Comment: the server will have to send it back...kind of like turning things around. You could implement it the same was the client sent the file  to the server in the first place


Install & Compile ZeroMQ/ZMQ/0MQ on Ubuntu 12.04 32bit

Question: I really want to use 0MQ for a personal project, but I am having a very tough time getting things to compile after installation
Here is what I do:

#### Install prerequisites without errors: ####
$ sudo apt-get install libtool autoconf automake uuid-dev build-essential

#### Get 0MQ: ####
$ cd ~/Downloads
$ wget http://download.zeromq.org/zeromq-3.2.1-rc2.tar.gz
$ tar -xvzf zeromq-3.2.1-rc2.tar.gz

#### Install 0MQ without errors: ####
$ cd zeromq-3.2.1
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig

#### Get the imatix zguide: ####
$ cd ~/Downloads
$ wget https://github.com/imatix/zguide/tarball/master
$ tar -xvzf master

This is where I need help. Running "./build all" in the imatix "examples/C" and "examples/C++" folders just results in loads of errors. I have also tried compiling using the "./c" and "./c -p" commands in the "/examples/C/" & "/examples/C++/" directories respectively. I don't get errors, but they generate ".o" and ".opp" files. Are these executables? After compiling I have tried "chmod +x" and "chown 777" to no avail. Here is what I do:

#### Generates hwclient.o ####
$ cd imatix-zguide-a690f10/
$ cd examples/C/
$ ./c hwclient.c
Compiling hwclient...
$ ./hwclient.o
bash: ./hwclient.o: Permission denied

#### Generates hwclient.opp ###
$ cd ../C++/
$ ./c -p hwclient.cpp
Compiling hwclient...
$ ./hwclient.opp
bash: ./hwclient.opp: Permission denied

I have also tried compiling with g++ which just results in similar errors to running "./build all":

$ g++ hwclient.cpp -o hwclient.exe
/tmp/ccWFyLHw.o: In function `main':
hwclient.c:(.text+0x16): undefined reference to `zmq_ctx_new'
hwclient.c:(.text+0x3a): undefined reference to `zmq_socket'
hwclient.c:(.text+0x52): undefined reference to `zmq_connect'
hwclient.c:(.text+0x73): undefined reference to `zmq_msg_init_size'
hwclient.c:(.text+0x7f): undefined reference to `zmq_msg_data'
hwclient.c:(.text+0xb9): undefined reference to `zmq_msg_send'
hwclient.c:(.text+0xc5): undefined reference to `zmq_msg_close'
hwclient.c:(.text+0xd1): undefined reference to `zmq_msg_init'
hwclient.c:(.text+0xed): undefined reference to `zmq_msg_recv'
hwclient.c:(.text+0x10d): undefined reference to `zmq_msg_close'
hwclient.c:(.text+0x12e): undefined reference to `zmq_close'
hwclient.c:(.text+0x13a): undefined reference to `zmq_ctx_destroy'
collect2: ld returned 1 exit status

What is the next step/what am I missing? I have looked all over the 0MQ site & wiki but nobody else seems to have an issue. Am I making a noob mistake? Am I executing the ".o" or ".opp" files incorrectly? Are they even executables?
Please help. I really want to use 0MQ!
Comment: I would recommend reading some material on basic compiler usage and how to use libraries, aside of a packaging fault with the rc2 package that will answer the rest of the questions:  http://stackoverflow.com/questions/3364736/c-c-linking-tutorial
Answer: I found that I had to upgrade to ZeroMQ 3.2.x to get the examples to compile properly.  The current version in the CentOS/EPEL repositories is 2.1.9, which doesn't work with the examples in the zguide.  My example here was done on a CentOS 6.3 server.
<code>yum remove zeromq zeromq-devel
wget http://download.zeromq.org/zeromq-3.2.2.tar.gz
tar zxvf zeromq-3.2.2.tar.gz && cd zeromq-3.2.2
./configure
make && make install
cd ~/zguide/examples/C
gcc -o hwclient hwclient.c -lzmq
</code>
Answer: After talking on a few IRC channels I have figured it out.

#### Build a single file with: ####
./c -p filename.cpp
g++ -o filename filename.opp -lzmq

#### Build all in folder ####
CCLIBS='-lzmq' ./build all
Comment: Thanks.  I edited the 'c' file and placed the CCLIBS='-lzmq' in it. Now I can simply do: "./build hwclient" and it builds successfully.


How to find the perimeter of a rectangle and an scalene triangle?

Question: The problem is as follows:

The alternatives given in my book are as follows:
$\begin{array}{ll}
1.&\textrm{21 cm}\\
2.&\textrm{39 cm}\\
3.&\textrm{28 cm}\\
4.&\textrm{27 cm}\\
\end{array}$
I've attempted to follow a similar strategy of assigning values to the edges of the figures mentioned.
This was done as follows:
Since it was mentioned that the figure is a square then this means that the edges measure 6 cm.
Assuming that the inner sides of the scalene triangle are $a,\,b,\,c,\,d$ and $6$ (this starting from the left in clockwise direction).
This leads to:
$a+b+c+d+6=15$
The upper segment which has been cut by the triangle I'm assigning those as:
$e,\,f,\,g$. (These starting from the left to the right).
Thus $e+f+g=6$
Up here the perimeter of the orange shaded region would be.
$3\times 6 + a+b+c+d = P$
Thus $a+b+c+d=9$
Therefore:
$P=18+9=27\,cm$
Therefore this should be the perimeter. But does it exist a better way than doing this?. Can it be obtained in a faster way?.
Answer: You can simplify the calculations, at least, by thinking of it this way:
The perimeter of the orange shape consists of three sides of the square, along with two of the sides of the triangle. In particular, it consists of
$$(\text{perimeter of triangle})+(\text{perimeter of square})-2\times (\text{side of square}).$$
So, the answer is
$$15+24-2\cdot\frac{24}{4}=27\text{ cm}.$$
Answer: Note that the orange region's border contains three sides of the square (three quarters of the square's perimeter), plus the entire triangle's border, except for the bottom side of the square. Thus the answer is $\frac3424+15-\frac1424=\frac1224+15=12+15=27$.


Ordenação dos dados com prioridade de valor utilizando LINQ

Question: Possuo uma tabela de "status" com os seguintes valores:
ID 1 = Ativo
ID 2 = Novo
ID 3 = Excluido

Como faria para retornar uma lista de objetos (que possuem o objeto status) priorizando, vindo por primeiro, os que possuem Status 2 (Novo) utilizando LINQ?
Gostaria de saber se tem uma solução melhor do que fazer com duas (2) Lista.
Answer: Seria algo assim:
var lista = contexto.Entidade
                    .Where(/* Sua condição aqui */)
                    .OrderBy(e => e.Status == 2)
                    .ThenBy(e => e.Status)
                    .ToList();

Answer: var lista = contexto.Entidade.Where(/*Alguma condição*/)
                             .OrderBy(e => e.Status.Id == 2) //Ordenar primeiramente pelo status com id = 2
                             .ThenBy(e => e.Status.Id) //Depois ordenar pelo id dos status em ordem crescente
                             .ToList(); //Converter para List


Concatenar um link dentro de um atributo href com uma variável?

Question: Queria saber como eu faço para concatenar um link dentro de um atributo href com uma variável?
Observação tem que ser algo 'inline'.
Eu uso uma plataforma que não me deixa usar scripts dentro da página por isso o motivo do inline.
Exemplo:
var teste = [x];
vai

A saída deveria ser:
http://websro.correios.com.br/sro_bin/txect01$.QueryList?P_LINGUA=001&P_COD_UNI=[x]

Meu código está errado na organização dos elementos ou aspas no lugar errado então desconsidere essa parte. Preciso de uma sugestão de como eu montaria isso.
Answer: Defina uma variável global e use o operador + para concatenar:

vai

Demonstração
A concatenação irá ocorrer no momento do clique.
Comment: Consegue colocar um exemplo no JSFiddle?
Comment: Sim, editei a resposta com o link
Comment: Sua resposta foi a que mais se aproximou, então eu considerarei ela como certa. Obrigado @bfavaretto
Answer: Você pode criar um input hidden e setar um value algo como:
<input type="hidden" name="teste" id="name" value="qualquer-valor"/>

Ai você pega o value e concatena no seu link algo como:
onclick="window.open('http://websro.correios.com.br/sro_bin/txect01$.QueryList?P_LINGUA=001&P_COD_UNI=' + document.getElementById('teste').value)"

Answer: Você pode usar o "eval", mas seu uso não é recomendado por questões de segurança.
Assim:
<!doctype html>

    <meta charset="UTF-8">
    <title>Document</title>

    vai

Cuidado com o uso do eval. Como disse, ele traz falhas de segurança mas, como você disse que o código tem que ser inline, isso resolve.
Comment: Não precisa usar eval para fazer uma simples concatenação!
Comment: não pensei nesse método mas parece ser interessante essa informação vai direto par um email, sera que pode ter eventuais problemas?
Comment: @bfavaretto hahaha, você tem toda razão, viajei na maionese! =D


Uncaught type error when I am using npm install popmotion(it is used for animation )

Question: No error was there when I used external js file link of popmotion provided by them but when I tried using parcel error occurred . After installing parcel I did npm install popmotion then I created localhost link but it didn't worked. There was an error in console log.
Error was:
Uncaught TypeError: (0 , _popmotion.styler) is not a function
    at Object.parcelRequire.animation.js.popmotion (animation.js:5)
    at newRequire (animation.7bfd2d21.js:47)
    at animation.7bfd2d21.js:81
    at animation.7bfd2d21.js:120

The js code is
import {styler, spring, listen, pointer, value } from "popmotion";

const ball = document.querySelector('.box');
const divStyler = styler(ball);
const ballXY = value({ x: 0, y: 0 }, divStyler.set);

listen(ball, 'mousedown touchstart')
  .start((e) => {
    e.preventDefault();
    pointer(ballXY.get()).start(ballXY);
  });

listen(document, 'mouseup touchend')
  .start(() => {
    spring({
      from: ballXY.get(),
      velocity: ballXY.getVelocity(),
      to: { x: 0, y: 0 },
      stiffness: 200,
      // mass: 1,
      // damping: 10
    }).start(ballXY);
  });

and the html code is:
</!DOCTYPE html>

    <title>Animation</title>
    <link rel="stylesheet" type="text/css" href="./animation.css">

Animation

Also when I just used external link for popmotion it worked fine. Below is working code.
The js code is:
const { styler, spring, listen, pointer, value } = window.popmotion;

const ball = document.querySelector('.box');
const divStyler = styler(ball);
const ballXY = value({ x: 0, y: 0 }, divStyler.set);

listen(ball, 'mousedown touchstart')
  .start((e) => {
    e.preventDefault();
    pointer(ballXY.get()).start(ballXY);
  });

listen(document, 'mouseup touchend')
  .start(() => {
    spring({
      from: ballXY.get(),
      velocity: ballXY.getVelocity(),
      to: { x: 0, y: 0 },
      stiffness: 200,
      // mass: 1,
      // damping: 10
    }).start(ballXY);
  });

and the html code is:
<!DOCTYPE html>

  <title>Animation</title>
  <link href="./animation.css" rel="stylesheet" type="text/css" />

Animation

popmotion site: https://popmotion.io/pure/
Note:This is my first Question and I am not sure if I have to provide any additional information. Please do let me know if you need additional info. Thanks.

A Noob
Answer: You use popmotion version 8 style. You can uninstall the current popmotion package and its dependencies (particularly styler) and then install poption v8. You can try popmotion v8.1.24


Discriminant, logistic approach to attrition analytics

Question: I have a few variables for each employee like tenure, age, marital status, certification, working away from home, #of OThours in an year, last promotion, performance rating, etc...
I have these variables and few more for employees who had left and employees who are working. If you see my variables, few are continuous and others are categorical, is it possible to run a discriminant analysis on this and identify which variables are discriminating better between a person leaving/not leaving the company and to forecast for existing employees or should I only use logistic regression since DA may not support discrete variables in the equation, or do we have any other method to achieve my goal?
Comment: What is "attrition analytics"?  Did you mean to say "attrition analysis"?
Answer: You can choose the suitable technique after checking the following assumptions with your data
<code>Assumptions ------------- Discriminant Analysis ---- Logistic Regression

Multivariate Normality ->   Yes                       No
Homoscedasticity       ->   Yes                       No
Non-Multicolinearity   ->   Yes                       Yes
Absence of Outliers    ->   Yes                       Yes
Large Sample Size*     ->    No                       Yes

(Predictor Variables
can be Categorical,
Continuous or Discrete) ->   Yes                       Yes

*Based on ten (10) independent variables, Discriminant analysis would need minimum of 50 cases and Logistic regression would need minimum of 250 cases.
</code>
Well, I have applied Logistic regression for my organization data to predict the attrition. I see very similar situation you have. You could also refer this document. Hope this helps !
Comment: Sample size needs are the same for logistic regression and DA.


InnoDB table optimization w/o locking table

Question: I've noticed a significant amount of performance gain if I repack a table (ALTER TABLE foo ENGINE = INNODB) after some period of time, or after heavy volume of INSERT/UPDATE/DELETEs.  I don't know if this is because indicies etc are rebuilt, or compacting the table space, or something else?
It strikes me that doing something like ALTER TABLE foo ENGINE = INNODB should be a part of routine table maintenance, however using OPTIMIZE or ALTER locks the table which is unacceptable, is there is a good way to do with with one database server (meaning no failing over to another instance) w/o locking the entire table?
Update: Using Percona 5.5.17-55
Update: SHOW VARIABLES LIKE 'innodb%';
+----------------------------------------+------------------------+
| Variable_name                          | Value                  |
+----------------------------------------+------------------------+
| innodb_adaptive_checkpoint             | estimate               |
| innodb_adaptive_flushing               | OFF                    |
| innodb_adaptive_hash_index             | ON                     |
| innodb_additional_mem_pool_size        | 8388608                |
| innodb_auto_lru_dump                   | 120                    |
| innodb_autoextend_increment            | 8                      |
| innodb_autoinc_lock_mode               | 1                      |
| innodb_buffer_pool_shm_checksum        | ON                     |
| innodb_buffer_pool_shm_key             | 0                      |
| innodb_buffer_pool_size                | 30064771072            |
| innodb_change_buffering                | inserts                |
| innodb_checkpoint_age_target           | 0                      |
| innodb_checksums                       | ON                     |
| innodb_commit_concurrency              | 0                      |
| innodb_concurrency_tickets             | 500                    |
| innodb_data_file_path                  | ibdata1:10M:autoextend |
| innodb_data_home_dir                   |                        |
| innodb_dict_size_limit                 | 0                      |
| innodb_doublewrite                     | ON                     |
| innodb_doublewrite_file                |                        |
| innodb_enable_unsafe_group_commit      | 0                      |
| innodb_expand_import                   | 0                      |
| innodb_extra_rsegments                 | 0                      |
| innodb_extra_undoslots                 | OFF                    |
| innodb_fast_checksum                   | OFF                    |
| innodb_fast_recovery                   | OFF                    |
| innodb_fast_shutdown                   | 1                      |
| innodb_file_format                     | Antelope               |
| innodb_file_format_check               | Barracuda              |
| innodb_file_per_table                  | ON                     |
| innodb_flush_log_at_trx_commit         | 0                      |
| innodb_flush_log_at_trx_commit_session | 3                      |
| innodb_flush_method                    | O_DIRECT               |
| innodb_flush_neighbor_pages            | 1                      |
| innodb_force_recovery                  | 0                      |
| innodb_ibuf_accel_rate                 | 100                    |
| innodb_ibuf_active_contract            | 1                      |
| innodb_ibuf_max_size                   | 15032369152            |
| innodb_io_capacity                     | 200                    |
| innodb_lazy_drop_table                 | 0                      |
| innodb_lock_wait_timeout               | 50                     |
| innodb_locks_unsafe_for_binlog         | OFF                    |
| innodb_log_block_size                  | 512                    |
| innodb_log_buffer_size                 | 67108864               |
| innodb_log_file_size                   | 402653184              |
| innodb_log_files_in_group              | 2                      |
| innodb_log_group_home_dir              | ./                     |
| innodb_max_dirty_pages_pct             | 75                     |
| innodb_max_purge_lag                   | 0                      |
| innodb_mirrored_log_groups             | 1                      |
| innodb_old_blocks_pct                  | 37                     |
| innodb_old_blocks_time                 | 0                      |
| innodb_open_files                      | 300                    |
| innodb_overwrite_relay_log_info        | OFF                    |
| innodb_page_size                       | 16384                  |
| innodb_pass_corrupt_table              | 0                      |
| innodb_read_ahead                      | linear                 |
| innodb_read_ahead_threshold            | 56                     |
| innodb_read_io_threads                 | 4                      |
| innodb_recovery_stats                  | OFF                    |
| innodb_replication_delay               | 0                      |
| innodb_rollback_on_timeout             | OFF                    |
| innodb_show_locks_held                 | 10                     |
| innodb_show_verbose_locks              | 0                      |
| innodb_spin_wait_delay                 | 6                      |
| innodb_stats_auto_update               | 1                      |
| innodb_stats_method                    | nulls_equal            |
| innodb_stats_on_metadata               | ON                     |
| innodb_stats_sample_pages              | 8                      |
| innodb_stats_update_need_lock          | 1                      |
| innodb_strict_mode                     | OFF                    |
| innodb_support_xa                      | ON                     |
| innodb_sync_spin_loops                 | 30                     |
| innodb_table_locks                     | ON                     |
| innodb_thread_concurrency              | 8                      |
| innodb_thread_concurrency_timer_based  | OFF                    |
| innodb_thread_sleep_delay              | 10000                  |
| innodb_use_purge_thread                | 1                      |
| innodb_use_sys_malloc                  | ON                     |
| innodb_use_sys_stats_table             | OFF                    |
| innodb_version                         | 1.0.16-12.8            |
| innodb_write_io_threads                | 4                      |
+----------------------------------------+------------------------+

Comment: What version of MySQL are you using ???
Comment: Updated question to include MySQL version
Comment: Please add this to your question: `SHOW VARIABLES LIKE 'innodb%';`
Answer: You cannot ALTER or OPTIMIZE a table without locking it. However, with the pt-online-schema-change tool from Percona Toolkit (disclaimer: my employer), you can do that, and it works quite well. To OPTIMIZE the table, simply use something like this:
pt-online-schema-change <options> --alter='ENGINE=InnoDB'

http://www.percona.com/doc/percona-toolkit/2.1/pt-online-schema-change.html
Comment: I updated the question for clarity.  I will look into pt-online-schema-change, thanks.
Comment: Reading the documentation, I will not use this tool in my InnoDB tables (all with foreign keys). Check http://www.percona.com/doc/percona-toolkit/2.1/pt-online-schema-change.html#cmdoption-pt-online-schema-change--alter-foreign-keys-method
Comment: @JoseNobile I use --alter-foreign-keys=drop_swap for big data with alot of columns where the "rebuild_constraints" method will fail. It works.
Comment: @Baron I run command 'pt-online-schema-change D=XXX,t=YYY,h=localhost,u=root --alter="ENGINE=InnoDB" --alter-foreign-keys-method="auto" --ask-pass --execute' but got the error '`XXX`.`YYY` was not altered.
2018-08-17T17:23:22 Error copying rows from `XXX`.`YYY` to `XXX`.`_YYY_new`: Redundant argument in printf at /usr/bin/pt-online-schema-change line 3595.'
Comment: @Baron  Can I use pt-online-schema-change through Java application?
Answer: From MySQL 5.6.17, MySQL supports online optimize of InnoDB tables by default.
Answer: Basically, you are doing an OPTIMIZE on the table. For InnoDB tables, OPTIMIZE is mapped to ALTER TABLE. Quoting from the Mysql manual :

For InnoDB tables, OPTIMIZE TABLE is mapped to ALTER TABLE, which rebuilds the table to update index statistics and free unused space in the clustered index.

When deleting 1/2 a table, an OPTIMIZE after is a really good idea.
I would make a suggestion for improving performance. Seeing that you support in your configuration the new file format BARRACUDA you should use it. Enabling it is really easy, just add in your my.cnf :
innodb_file_format=Barracuda

Restart the server and then alter your table to use the new available ROW_FORMAT = COMPRESSED :
ALTER TABLE x ROW_FORMAT=COMPRESSED;

From personal experience, when using the compressed row format, table size has reduced to half and it a significant positive impact on performance as well.
For more details try going throug :
http://dev.mysql.com/doc/refman/5.5/en/innodb-compression-usage.html
http://www.mysqlperformanceblog.com/2008/04/23/testing-innodb-barracuda-format-with-compression/
Comment: Are there downsides to using the new file format or row compression?
Comment: There should be a minor increase in CPU usage, but all the tests I've seen indicate that there is no downside. The old format "Antelope" is kept as default mainly for compatibility with older MySQL versions. The new Barracuda file format will most likely become the default in the next major MySQL release.
Comment: In my experience enabling compressed row format only makes sense if your average row length is big enough (use `SHOW TABLE STATUS LIKE 'table_name'` to check) and you have at least one text field with a long content.


Is there a way to document what the value of `this` is in JSDoc?

Question: Is there a way to document what the value of this will (or must) be in the body of a function?
An example of such a function might be an event handler that is attached to a DOM node. I might define the handling function elsewhere and I want to be able to document that this will be the target node.
@param doesn't seem to cut it.
Answer: Yeah... and seconds after posting the question, I thought: maybe it's just @this and lo! and behold: http://usejsdoc.org/tags-this.html


What is the correct way to pass values from PHP code to javascript in Drupal 8?

Question: I'm not talking about the library. That part is covered fairly extensive. What I want to do is generate the javascript based on PHP. But I can't, for example, do this:
$o = '';

$form['mainText'] = array (
        '#type' => 'markup',
        '#markup' => $o,
    );

return $form;

How am I supposed to do this correctly?
And if you are wondering, the reason I am doing this is because I want to generate javascript that is to be used to plot points on a graph.
Comment: My interpretation of your question is "How do I provide data/settings to my JavaScript graph plotting library?" because the code in the question is outputting a simple array/object.
Comment: You can do this by writing PHP code, attaching it to the page/node/field etc hook as a drupalSetting and read it in to the JS code. Although if you are writing JS to plot points on a graph, either in real time or not, this approach (code in OP) simply won't work.
Comment: fill drupalSettings under #attached in render array with php and process it with javascript.
Answer: There are a number of ways you could do this. I will you tell you one.
Create a controller class that has a method that is responsible for printing an array of numbers. Hit that endpoint via a javascript get request and do something with the returned data.
So you would create a routing file:
your_module.routing.yml
your_module.create_numbers:
 path: '/your_module/{numbers}'
 defaults:
   _controller: '\your_module\Controller\YourCustomControllerClass::createNumberArray'
 requirements:
   _permission: 'access content'

YourCustomControllerClass.php
<?php

namespace 'your_module\Controller';

class YourCustomControllerClass extends ControllerBase {

 /**
 * Return a JSON response based on the number param
 * @param $number integer The number passed into the route.
 * @returns JsonResponse
 */
 public function createNumberArray($number) {
   $numbers = [];
   for ($i = 0 ; $i < $number; $i++) {
     $numbers[] = $i;
   }
   return new JsonResponse($numbers);
 }

}

Now you can hit your route from Javascript. The cool thing about this is that your route can create dynamic arrays. If you notice in the routing file the numbers is in {}. That means it is dynamic and is passed in as an argument to the createNumbersArray method. It can then use it to create an array of any length.
your_module_graph.js
var numbers = 10;

// Note numbers can be set to whatever you want.
var jqxhr = $.get( "/your_module/" + numbers, function(data) {
  // data will be a JSON object containing an array of numbers.
  var parsedJson = JSON.parse(data);
  // Now do what you want with parsedJson. Build your graphs etc.
});

I haven't tested that but have done similar things a lot lately and I'm quite confident that if not that exact code, the approach in general will suit your needs. As mentioned earlier there is no one way to do this but with Symfony now a core part of Drupal 8 it really is built for doing stuff like this. That is, taking HTTP requests and returning data.
Hope that helps.
Comment: This is more correct, but my lazy ass went for "allowed_tags" as seen here: http://drupal.stackexchange.com/questions/184963/pass-raw-html-to-markup
Answer: You should place the data into any one of php variables and then you could easily pass the php variables to javascript file if you follow this link
After the you can access the data in your javascript library.


Gerar todas combinações dada uma lista em python

Question: Já procurei bastante e não encontrei em nenhum lugar o que quero exatamente. O que eu quero é, dada uma lista de caracteres, gerar todas as combinações possíveis de tamanho x até tamanho y.
Exemplo:
dado 0,1,2 e pedir combinações de tamanho de 1 a 2
gerar:
(00)
(11)
(22)
(01)
(10)
(02)
(20)
(12)
(21)
Queria gerar, por exemplo, todas as combinações de 8 a 20 caracteres dada uma lista de 70 caracteres (sei que seria extremamente grande).
O código que eu fiz:
from itertools import permutations

caracteres = [0, 1, 2]
for subset in permutations(caracteres, 2):
    print(subset)

gera apenas:
(01)
(02)
(10)
(12)
(20)
(21)
Answer: Para gerares todas as combinações de 8 chars de uma lista de 70 elementos vai ser extremamente custoso, 708 (576,480,100,000,000) combinações... Boa sorte :P
Para gerar todas as combinações possíveis, incluindo caracteres repetidos, usa product:
from itertools import product

caracteres = [0, 1, 2]
permsList = []
genComb = product(caracteres, repeat=2) # aqui e onde tens de especificar o numero de chars que cada combinacao tenha
for subset in genComb:
    print(subset) # tuple retornado com uma combinacao por loop
    permsList.append(subset)
print(permsList) # [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]

Nem precisas do ciclo for (a não ser que precises de fazer mais alguma operação no loop) basta transformares o generator retornado numa lista/set/tuple para armazenares os resultados, sendo só preciso isto:
from itertools import product

caracteres = [0, 1, 2]
permsList = list(product(caracteres, repeat=2))
print(permsList) # [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]

Podes também remover os tuples e ficares com uma lista de strings, para isso, visto que temos inteiros e não strings temos de os tranformar em string:
from itertools import product

caracteres = [0, 1, 2]
permsList = [''.join(str(i) for i in x) for x in product(caracteres, repeat=2)]
print(permsList) # ['00', '01', '02', '10', '11', '12', '20', '21', '22']

Se tiveres strings em vez de inteiros nos tuples podes só:
permsList = [''.join(x) for x in product(caracteres, repeat=2)]

Comment: obrigado Miguel
Comment: de nada @JúlioCésar, ainda bem que resolveu


Feature dimension of RGB color histogram?

Question: I am unsure about this but I want to compute features around interest points computed by surf using RGB color Histogram. I guess the final feature will be 256 dimensional long. However, I am unsure if this is correct.
Answer: The dimension of the RGB color histogram is determined by how many bins you use for each channel. The dimension will be 24 (8+8+8) if you use 8 bins for each of them.
Comment: @user1965914 RGB color histogram is OK here because the dimension will be same no matter how large the image is as long as they use same bins.
Comment: Actually I am confused like the image of the model only contains the cup while the image for detection contains other cluster of colors. Wont the 2 histogram won't match. Sorry I am just confused.
Comment: @user1965914 They will not match in this case because the larger image contains other content. You can try search with relative similar sizes.
Comment: Like sliding windows like search would be good enough.. Also if I compute histogram of each interest points which u answered will be 24 dimensional vector for each interest point right. just confirming
Comment: @user1965914 It will be 24 but most of them will be 0. I don't recommend you to compute RGB histogram for each point. Histogram is a statistic value (i.e. for pixels not a single pixel).
Comment: Do you have any suggestion for which type of descriptor would be better together with SURF.
Comment: @user1965914 I am not quite familiar with SURF. Maybe you can ask another SO question to find it out. :)
Comment: oh thanks I just noticed them. I have one more question if you can help me out in. At the moment I am using SURF features and RGB color histogram for feature computation. For example for detection of a cup on the table. Do you think the use of histogram feature is good enough here? I mean when i compute the features of the cup model which is 40 x 40 pixel image and I perform detection on 640 x 480 image which will contain a lot more colours. Is it good idea to use RGB histogram descriptor as well here.


How to decide `end of transmission` symbol for arithmetic coding?

Question: In Mackay's Information Theory book (p. 111), he's said that

Let the source alphabet be $\mathcal{A}_X = \{a_1, . . . , a_I\}$, and
  let the $I$th symbol $a_I$ have the special meaning 'end of transmission'.

which seems quite arbitrary to me. More importantly, there might involve a risk of corrupting decoding process, since $a_I$ cannot be translated (it's replaced with end of transmission symbol).
To specify my idea, suppose, we have $\mathcal{A}_x=\{a,b,c\}$ and probabilities $p (a) = 0 . 25 , p (b) = 0 . 25 , p (c) = 0 . 5$. If we want to encode a string $abc$, how to decide the end of transmission symbol and its probability? Are we randomly set some probability $p(d)$ as end of transimisson and  then rescale $p(a), p(b), p(c)$ according to that probability?
Edited
To be clear, the scope of question is artihmatric coding.
Answer: Ideally, you will choose a probability for EOT dependant on how long your message typically is, as though it were part of every message in your corpus. Thus in your probability selecting corpus "abc" is really "abc." And "qrxjundieko" is really "qrxjundieko." And so forth.
Note that my use of a period there implies that there are no other periods in the entire corpus. Really you use a special symbol that's guaranteed not to be there.
Comment: Thanks for the answer. I think the algorithm of Huffman coding is different from arithmetic coding, and the scope of this question is arithmetic coding.
Comment: Aha, one moment, the answer is slightly different there.
Comment: You've mentioned that prob of EOT depends on the length of message, could you clarify it a little bit of how to set this prob of EOT? Does that mean differnt choice of $p(EOT)$ would result to different codewords?
Comment: It can, yes. Choosing the probability correctly means that a random real number gives a message that has a character density *and length* similar to a typical message in the corpus.
Answer:
More importantly, there might involve a risk of corrupting decoding process, since $a_I$ cannot be translated

No, the symbol $a_I$ means exclusively EOT (end of trasmission). If you want to trasmit three symbols $\mathcal{A}_x=\{a,b,c\}$ (which might appear anywhere in the stream) then you need to augment that with the extra EOT symbol.
Bear in mind that the EOT symbol is only one way, another possibility is to prepend the coded sequence with the sequence length.
Comment: Would EOT and length prepend methods generate the same result?
Comment: @Logan Surely not, but they will both be asymptotically negligible


Differentiation and integration

Question: Which came first : Differentiation or Integration? If one of them was developed to solve certain types of problems, was the other developed for backward compatibility, or was it an independent development and later discovered that they were inverses?
Also, how were they discovered to be linked?
It was just something that I was thinking, and I would like to clarify it.
(I see that this is related : History of differential and integral calculus, but no answer is present)
Comment: Answering questions like this comes down to what you mean exactly by differentiation and integration. As stated in the question you linked (and elsewhere) the ancient Greeks and Romans used techniques like the method of exhaustion. Is this a proto-integration technique? Is it a proto-limits technique? If you are meaning our modern form linked to functions then you'll get a different date/answer.
Comment: Not an answer, but I do know that they developed more or less independently of each other. For a long time, the connection between the two was not obvious, whereas today they are always taught as being intimately related by the fundamental theorem. Integration developed (at least in part) with the very geometric goal of finding areas under curves.
Comment: Check out the website below. It seems like the short answer is that integration came first (in the form of areas under curves) and differentiation later (in the form of tangent lines to curves).

https://www.math.ucdavis.edu/~temple/MAT16A/ArticlesOnCalculus16A/WikopediaHisoryOfCalculus.pdf
Answer: In a nutshell, the calculus was "discovered" or "invented" during 17th century independently by Leibniz and Newton who merged brilliantly various techniques developed since ancient Greece to solve geometrical problems.
Following the development of algebra during the Reanaissance and the pubblication of Descartes' Geometry in 1637, those methods were improved and new ones were discovered:

drawing the normal to a curve: Descartes, Hudde
finding tangents: Roberval, Fermat
finding maxima and minima of curves: Fermat
the method of indivisibles: Cvalieri
arithmetical methods of integration: Wallis.

See:

Ivor Grattan-Guinness and H.J.M. Bos (editors), From the Calculus to Set Theory, 1630-1910: An Introductory History (1980), Ch.1 Techniques of the calculus, 1630-1660, by Kirsti Moller Pedersen, page 10-on.

The "official" birth of the calculus must be dated with Newton (De analysi of 1669) and Leibniz (various Ms. of 1675) independent developments:

Leibniz's differential and integral calculus and Newton's fluxional calculus,
  though different in many aspects, each involve a clear recognition of what we now call the inverse relationship between differentiation and integration. Moreover, both men worked out a system of notations, symbols and rules through which their methods could be applied in the form of algorithms performed on formulae, rather than in the form of geometrical arguments presented in prose with reference to figures.

See into: Ivor Grattan-Guinness, cit., Ch.2 Newton, Leibniz and the Leibnizian Tradition, by H.J.M. Bos, page 49-on
Answer: This is similar to the chicken-and-the-egg question though relation is not as obvious in the case of integration-and-differentiation. Namely, both types of problems were already studied by Archimedes (areas of figures and volumes of solids), Apollonius (tangents to curves), and others thousands of years ago.  However the inverse relationship between the integration and differentiation was not understood until Barrow (some say even earlier by James Gregory), Newton, and Leibniz.

Differentiation and integration


Using an expression pedal with a PC?

Question: Currently I'm using my guitar through a Ubisoft Rocksmith adapter, and I'm thinking of buying an expression pedal with a 6.3 mm jack output, but I don't know how could I connect it to my PC so I could use it in i.e. Amplitube.
Is the only solution to this is buying a relatively big and expensive USB interface?
I want to use only this pedal. Is there a single adapter on the market?
What other solutions are there?
Comment: This isn't a site for product recommendations. Even if it were, I don't know of much in the way of midi controllers for less than €50. You might look at a music instrument retailer web site and see what they have.
Comment: You need something that turns analog expression pedal voltages into a digital signal that a computer can interpret. One of the most popular and easiest ways to do that is to get some kind of MIDI controller that has an expression pedal input.
Comment: @ToddWilcox could you recommend one which just has that one input?
Comment: I've found this https://beatbars.com/en/home.html , but it's a bit expensive for me.
Answer: USB instrument interfaces don't have to be large and expensive, there are small and inexpensive versions available.
If you want to use a standard effects pedal like a WAH then a simple USB interface will work.
The Behringer interface line starts at around $30 USD. You would send the guitar into the expression pedal, then into the interface.
If you want to control the software to use built-in expression, then you need to use a MIDI controller. There are a few different configurations available, but the most direct for what you describe would be an "Expression pedal to MIDI adapter" which starts around 50 Euro.
I have seen stand-alone MIDI expression pedals on the market before, but I believe the price range starts around $150 USD and goes up from there.

Using an expression pedal with a PC?


Is it possible to add animation to my onboarding screen?

Question: I already have this onboarding page made up but I wanted to add some more interactivity to it and it consists of 4 pages and with each swipe I want to have a small animation to the logos.
This what my onboarding looks like
As you can see with the sample image, there's this image of a chatbot what I want to have for this is to animate the robot with the speech bubble popping up or something.
Answer: Already did this one and I just put in a gif using this
this


how to validate minimum age in webform

Question: I've got a question about webform and webform validation.
I'm in D6.19 with webform 6.x-3.4 and webform validation 6.x-1.3
I'm adding a date field to capture age, and I need to validate that the age of the user is at least 13 years from current date.
Does anyone know how I can do this?
Thanks
Stephanie
Comment: What are you trying to accomplish here? If you use form validation, then the webform cannot be submitted until the field value is correct (in this case now - 13 years). If you are trying to block access to users under 13, then a different approach is required, say webform rules, or using a date field on user registration (again using rules). Please give us more details on your intent.
Comment: Hi, thanks for the reply - I absolutely intend to prohibit users younger than 13 from submitting the form. I'll check out Webform Rules. Thanks!
Comment: Then you definitely do not want field validation. That would keep presenting the form to the user until they entered a value which passed the validation. You need to let them submit it with the entered date, then slap their wrists for doing so :-)
Answer: You can do it using the hook_webform_submission_presave() exposed by the Webform api in a custom module.
Another alternative is to make use of this sandbox project

This module provides a way to calculate values for Webform components
  and/or to add custom validation code without the need for creating
  custom modules that implement hooks. It offers a PHP-like macro
  scripting language to use instead.
Differs from Webform PHP in that there is no eval() evil and macro
  code has no direct access to Drupal environment or functions, i.e.
  macro code is contextually jailed.
Differs also from Webform Calculator in that it permits logic-driven
  calculations and also integrates with the Webform Validation module.

how to validate minimum age in webform


Pushout not a homotopy invariant

Question: The pushout in the category of topological spaces is not a homotopy invariant. Can somebody give me an explicit example for this fact?
Answer: The pushout of $I \leftarrow 2 \rightarrow I$ where $I = [0, 1], 2 = \{ 0, 1 \}$, and both maps are the inclusion of the endpoints into the interval is $S^1$. This pushout diagram is homotopy equivalent to $1 \leftarrow 2 \rightarrow 1$ (where $1$ is a one-point space) whose pushout is $2$, which is not homotopy equivalent to $S^1$.
Comment: Indeed, a very similar example works: there's a cospan $1 \rightarrow I \leftarrow 1$ whose pullback is empty, but contracting $I$ to a point first makes the pullback $1$ instead.
Comment: There's no particular reason for it to be.

Pushout not a homotopy invariant


Date Display: How to hide part of repeat rule?

Question: When displaying recurring event dates for end users I would like to hide a part of the repeat rule (the until date has no meaning for end users):
Current display:

Repeats every week every Thursday until Mon Dec 31 2012

Expected display:

Repeats every week every Thursday

How to do this ?
Answer: The recurrence description is defined in date_repeat_rrule_description() in date_repeat.module.
At this time, there is no way for themes to change it. See this issue: http://drupal.org/node/342665
EDIT
Actually, you may override theme_date_repeat_field(), which calls date_repeat_rrule_description(). You could call your own version of that function to customize the display.
This would leave the contrib modules untouched, but you would be duplicating some effort and have more code to maintain.


Robust Variance Estimation in Bayesian Meta-analysis

Question: BACKGROUND
I am conducting a meta-analysis using the brms in R with structure akin to the following (leaving out priors, etc. for simplicity):
brm(yi|se(sei) ~ 1 + (1 | eid), data = dat)

Here yi is the effect, sei is the standard error of that effect and eid is a unique identifier for each experiment. My understanding is that inclusion of a random effect by experiment (eid) addresses concerns related to dependencies in my data (e.g., if one experiment reports two effects from the same sample they would share the same eid). I have published several papers using this approach (sometimes with additional random effects, moderators, etc.) in the past without issue. I have just received a review stating that the use of a multilevel Bayesian model is insufficient to account for such dependencies, and I must instead apply some form of robust variance estimator (of the sort recommended by Hedges, Tipton, & Johnson, 2010). However, I am unable to find anything in the Bayesian meta-analytic literature discussing this issue. The reviewer has recommended abandoning my Bayesian approach so that I can use the robust function from the metafor package instead. I am not keen to do that (as much as I love the metafor package).
QUESTION
I was hoping someone could point me towards an article or two that either (a) discusses robust variance estimation in the context of Bayesian meta-analysis, or, (b) explains why robust variance estimation is unnecessary in the context of Bayesian meta-analysis.
Answer: The reviewer is correct in the sense that this model does not properly account for correlated sampling errors (when multiple effects are computed based on the same sample of subjects, then the sampling errors of the estimates are typically correlated). By adding random effects to your model, you are modeling potential correlation/dependencies in the underlying true effects, but not the sampling errors. Just like you are specifying the standard errors of the estimates (sei), one would have to specify the covariances of the estimates (i.e., an entire variance-covariance matrix of the sampling errors) to properly account for the latter. This is an example where this is done:
https://www.metafor-project.org/doku.php/analyses:berkey1998
In practice, constructing this var-cov matrix ($V$) is difficult. One can construct an approximate var-cov matrix based on a 'guestimate' of the correlation among the sampling errors and then treat this as the 'working model'. Even if the $V$ matrix is somewhat misspecified, the estimates of the fixed effects should be approximately unbiased. But the standard errors might be off. Hence, for inferences, we can use cluster robust standard errors.
This aside, just adding a random effect at the study level implicitly assumes that the true effects within studies are homogeneous. That is not an assumption I would recommend to make a priori.
Here is an example illustrating the different approaches (note: esid is an 'effect size id', not the study id).
library(metafor)
library(brms)
library(clubSandwich)

dat <- dat.assink2016
dat$sei <- sqrt(dat$vi)
head(dat, 10)

#    study esid id      yi     vi pubstatus year deltype        sei
# 1      1    1  1  0.9066 0.0740         1  4.5 general 0.27202941
# 2      1    2  2  0.4295 0.0398         1  4.5 general 0.19949937
# 3      1    3  3  0.2679 0.0481         1  4.5 general 0.21931712
# 4      1    4  4  0.2078 0.0239         1  4.5 general 0.15459625
# 5      1    5  5  0.0526 0.0331         1  4.5 general 0.18193405
# 6      1    6  6 -0.0507 0.0886         1  4.5 general 0.29765752
# 7      2    1  7  0.5117 0.0115         1  1.5 general 0.10723805
# 8      2    2  8  0.4738 0.0076         1  1.5 general 0.08717798
# 9      2    3  9  0.3544 0.0065         1  1.5 general 0.08062258
# 10     3    1 10  2.2844 0.3325         1 -8.5 general 0.57662813

# fit multilevel model (assuming no covariance among the sampling errors)
res1 <- rma.mv(yi, vi, random = ~ 1 | study/esid, data=dat)
res1

# analogous brm() model
res2 <- brm(yi|se(sei) ~ 1 + (1 | study/esid), data = dat)
summary(res2, priors=TRUE)

# construct approx V matrix assuming r=0.6 for the sampling errors
V <- impute_covariance_matrix(dat$vi, cluster=dat$study, r=0.6)

# fit multilevel model with the approximate V matrix
res3 <- rma.mv(yi, V, random = ~ 1 | study/esid, data=dat)
res3

# use cluster robust inference methods
robust(res3, cluster=dat$study)

# or use coef_test() from clubSandwich
coef_test(res3, vcov="CR2", cluster=dat$study)

You will find that the results in res1 and res2 are quite similar.$^1$ The results in res3 differ more by having specified the approximate $V$ matrix. Using cluster robust methods barely changes the results in this case, but could do so more in other cases.
Some relevant papers on the use of robust variance estimation (also known as the 'sandwich method') in the context of Bayesian analyses are https://doi.org/10.1214/10-AOAS362 and https://doi.org/10.3982/ECTA9097 but these are not focused on meta-analysis and I am not aware of any papers that do so.
If you want to stick with brms, then I would recommend to at least specify the random effects as above. There is some evidence that ignoring the sampling error covariances can also work (the study-level variance component then gets inflated to compensate for essentially assuming that the covariances are equal to zero, which we also see happening in this example). See https://doi.org/10.3758/s13428-012-0261-6 and https://doi.org/10.3758/s13428-014-0527-2 and https://doi.org/10.1080/13645579.2016.1252189 (none of these discuss Bayesian approaches though).
$^1$ The mean of the posterior for the study-level standard deviation is a tad higher in res2 than the REML estimate in res1, presumably because with 17 studies, the prior (a half student-t with df=3 and scale parameter 2.5) pulls the mean of the posterior up a bit.
Comment: Wolfgang to the rescue, as usual. Thanks!
Answer: Please check this article by brms' author: https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0173660, where they say: "...outcomes reported by the same study were explicitly modeled as correlated. In the absence of any reported correlations in the primary studies, correlations were set to r = 0.7. To investigate the influence of this decision on the obtained results, a sensitivity analysis was conducted where correlations were varied between r = 0.1 and r = 0.9."
Fortunately, they used brms to run the meta-analysis and the code is available here: https://osf.io/gs6hk/