text:
Q: How does onboard Wi-Fi get presented to the OS? Desktop Motherboard I'm looking at motherboards and I'm debating on spending more for one with built-in Wi-Fi. I was wondering how this is presented to the OS. I'd like to use PCI pass-through, so I'm wondering if it uses PCI somehow or some other technology like USB.
The specific motherboard I'm looking at is the MSI z370 gaming carbon AC
https://www.msi.com/Motherboard/Z370-GAMING-PRO-CARBON-AC/Specification
I can't even find that it says it has Wi-Fi or Bluetooth but I Googled and that's what the AC stands for and apparently it's Intel based... Not a very specific spec sheet in my opinion. Id love to know what exact Wi-Fi card is used.
Update: seems I missed the details tab.... I now see the type of card. But I still want to confirm that it's presented as a PCI device.

A: As Micheal Frank mentioned in his answer, the motherboard in question comes with a Intel® Dual Band Wireless-AC 8265 card, and Intel's ARK website states: "System Interface Type: PCIe, USB".
This means that the card needs both PCIe and USB to work, not either-or. Typically in these kinds of combo Wifi + Bluetooth cards, whether made by Intel, Atheros (now Qualcomm) or Broadcom, whether in MiniPCIe or m.2 form factor, the PCIe lanes connect the WiFi part, and the USB lanes connect the Bluetooth part.
For example, the following is a screenshot taken from Device Manager on a Windows 10 laptop, where menu "View -> Device by connection" is selected:

Similarly, on a Linux computer, the WiFi card will show up in lspci, and the Bluetooth card will show up in lsusb.
The MiniPCIe and m.2 connection specifications both include PCIe lanes and USB lanes, and for a combo WiFi + Bluetooth card to work properly, both protocols are required. The PCIe adapter provided with the motherboard routes PCIe lanes on the m.2 connector to the PCIe slot, and the USB lanes to the USB connector, where it must be plugged in to the motherboard's internal USB headers using the provided cable. If the cable is not connected, WiFi may work, but Bluetooth will not work. (Certain models of laptops may have either only PCIe lanes or only USB lanes connected on their MiniPCIe / m.2 slots, and if a combo card is plugged in to those slots, only one function will work.)
Since the OP would like to use PCI passthrough to present the wireless card to a virtual machine, both the PCIe device and the USB device must be passed through if WiFi and Bluetooth are both desired in the virtual machine. (Even then it may not work properly, because PCI passthrough is black magic, and many devices don't like it. I have attempted to pass through a simple PCIe WiFi card before, and never got it to work; your mileage may vary.)

A: The details page you linked has this information on it:

Intel® Dual Band Wireless-AC 8265 card

*

*Supports Wi-Fi 802.11 a/b/g/n/ac, dual band (2.4GHz, 5GHz) up to 867 Mbps speed.

*Supports Dual Mode Bluetooth® 2.1, 2.1+EDR, 3.0, 4.0, BLE, 4.2

Following that, you can find on Intel Ark that this wireless card could be either PCIe or USB.
Finally, looking at the box art:

There's a PCIe card!
However... and this is where the plot thickens... The product manual reveals the following information:

A USB Cable?!
But then further along it also mentions the following:

Intel® Dual Band Wireless-AC 8265 card
  * The Wireless card is pre-install in the M2_3 (M.2 Key E)
  slot.

There's also this diagram:

All in all, it's quite unclear how exactly this wireless card actually connects to the motherboard, so basically... I dunno?


text:
Q: Silverlight 4: how to show ToolTip on keyboard focus (revised) My original question:
Is there an easy way for a ToolTip to be shown when an item gets keyboard focus, not just mouse over? We have a list of items with tooltips that users will probably tab through, and the desired behavior is for a tooltip to be shown then too.
Added example XAML. A HyperlinkButton with the Tooltip set is what needs the keyboard focus as well.
    <DataTemplate x:Key="OfferingItemDT">
        <HyperlinkButton Command="{Binding Path=NavigateToLinkCommand}" ToolTipService.ToolTip="{Binding Tooltip}">
             <Grid x:Name="gOfferingButtonRoot" Width="275" MaxHeight="78" Margin="5,3">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="40"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <Image x:Name="imgServiceOfferingIcon"
                Grid.RowSpan="2"
                VerticalAlignment="Top"
                Source="{Binding Path=Image, Converter={StaticResource ByteArrayToImageConverter}}"
                Stretch="UniformToFill"
                Margin="2,10,0,0"
                MaxHeight="32" MaxWidth="32"
                />
                <TextBlock x:Name="txbOfferingTitle"
                    Grid.Column="1"
                    Grid.Row="0"
                    Text="{Binding Title}"
                    TextWrapping="Wrap"
                    Style="{StaticResource OfferingTileTitleText}"/>
                <TextBlock x:Name="txbOfferingDesc"
                Grid.Column="1"
                Grid.Row="1"
                Style="{StaticResource OfferingTileBodyText}"
                Text="{Binding BriefDescription}" />

             </Grid>
        </HyperlinkButton>
    </DataTemplate>

Updated:
Based on info in WPF: Show and persist ToolTip for a Textbox based on the cursor as well as Anthony's comments, I tried this code in the GotFocus eventhandler:
        private void showTooltip(object sender, RoutedEventArgs e)
    {
        HyperlinkButton hb = new HyperlinkButton();
        ToolTip ttip = new ToolTip();

        hb = sender as HyperlinkButton;

        ttip = ToolTipService.GetToolTip(hb) as ToolTip;
        ttip.IsOpen = true;

    }

This seems like it would work, but ttip is always null. Help?

A: "Easy" is subjective term.  Yes its easy.  On the same UI element on which you attach the ToolTip you can hook the GotFocus and LostFocus event handler the will use ToolTipService.GetToolTip to acquire the tooltip and the set IsOpen to true and false respectively.

A: The missing part is to define the tooltip in XAML so that we can access the Tooltip element.
<HyperlinkButton MouseLeftButtonUp="showTooltip">
  <ToolTipService.ToolTip>
    <ToolTip>
      <TextBlock Text="My tooltip text"/>
    </ToolTip>
  </ToolTipService.ToolTip>
  <!-- ... -->
</HyperlinkButton>

Code behind
private void showTooltip(object sender, RoutedEventArgs e)
{
  FrameworkElement frameworkElement = (FrameworkElement)sender;
  ToolTip tooltip = ToolTipService.GetToolTip(frameworkElement) as ToolTip;
  if (tooltip != null)
  {
    tooltip.IsOpen = true;
    frameworkElement.MouseLeave += new MouseEventHandler(frameworkElement_MouseLeave);
  }
}

static void frameworkElement_MouseLeave(object sender, MouseEventArgs e)
{
  FrameworkElement frameworkElement = (FrameworkElement)sender;
  frameworkElement.MouseLeave -= new MouseEventHandler(frameworkElement_MouseLeave);

  ToolTip tooltip = ToolTipService.GetToolTip(frameworkElement) as ToolTip;
  if (tooltip != null)
  {
    tooltip.IsOpen = false;
  }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Sorting user defined structure in C++ I have a data structure of the following form:
struct E{
 unsigned k;
 unsigned c;
 unsigned v[100];
};

main()
{
 vector<E*> vecE;
 E e1;
 e1.k=10; e1.c=20; e1.v[0]=30; e1.v[1]=31;
 vecE.push_back(&e1);
 E e2;
 e2.k=101; e2.c=28; e2.v[0]=82; e2.v[1]=32;
 vecE.push_back(&e2);
 //sort vecE by E.k of the structure
}

I have a large vecE containing thousands of objects of type E. I need to sort vecE again and again. What is the fastest way by which I can sort vecE in-memory -- here vecE is sorted on E.k. One of the ways by which one can do the same is by building priority queue. But priority will be rather expensive due to insertions. Is there some other fast way by which I can sort vecE on "k".
Also after sorting and outputting the results to the user I want to delete the vecE entirely..but I can not do so as it consists of pointers to E. How can I destroy vecE completely, so that even values pointed to by E are deleted.
The gcc version that I am using is: gcc (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4

A: Given that E is quite a big structure, you should have a vector<E*>, so that swapping elements is as fast as swapping a single integer. Then you can use either sort or stable_sort from the standard header <algorithm> (see http://www.cplusplus.com/reference/algorithm/).
vector<E*> vecE;
sort(vecE.begin(),vecE.end(),compE);

with:
bool compE(E* first,E* second)
{
    return (first->k < second->k);
}

At the end delete the elements this way:
for(auto e: vecE)
{
    delete e;
}

You don't need to delete the vector itself, because it has automatic storage duration, and it will be destroyed at scope exit.

A: class cmp{  // Function object to pass to std::sort algorithm
public:
    bool operator()(const E &a, const E &b)
    {
        return a.k > b.k;
    }
};
int main()
{
    vector<E> a(10);
    cmp comparator;
    sort(begin(a), end(a), comparator);
    return 0;
}


text:
Q: problem with varying css height I have got a div [projItemsContent] that varies in height based on the contents,the problem i have got is that there are two other divs [projItemsLeft,projItemsRigh] that i want to have the same height as projItemsContent div. Any suggestions please?
div.projItems{width:360px;min-height:200px;_height:200px;background:#000}

div.projItemsLeft{float:left;width:30px;background:#990}
div.projItemsRight{float:left;width:30px;background:#900}
div.projItemsContent{float:left;width:300px;background:#ccc}

        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet nunc eu ligula tincidunt faucibus.
        Curabitur eget magna neque, sed porta sem. Fusce eu lorem at orci dapibus faucibus ut eu mi. In eget ligula risus.
        Sed id lectus lorem. Integer elit dui, bibendum vitae dictum a, mollis sodales diam. Morbi vehicula lobortis semper.
        Suspendisse potenti. Proin eu convallis lectus. Praesent ut sem at enim condimentum dictum vitae id elit.
        Phasellus id dolor ante, hendrerit tempus lorem. Proin nisi nibh, convallis et sollicitudin in, interdum vitae nibh.
        Fusce ullamcorper dictum nunc, eget bibendum ipsum viverra quis. Aliquam vitae leo non metus ultricies tempus in id libero.
        Vivamus mauris tortor, convallis ut luctus at, elementum sed velit. Cras cursus tempus erat adipiscing lacinia.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam diam risus, sollicitudin sed venenatis a, molestie in turpis.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet nunc eu ligula tincidunt faucibus.
        Curabitur eget magna neque, sed porta sem. Fusce eu lorem at orci dapibus faucibus ut eu mi. In eget ligula risus.
        Sed id lectus lorem. Integer elit dui, bibendum vitae dictum a, mollis sodales diam. Morbi vehicula lobortis semper.
        Suspendisse potenti. Proin eu convallis lectus. Praesent ut sem at enim condimentum dictum vitae id elit.
        Phasellus id dolor ante, hendrerit tempus lorem. Proin nisi nibh, convallis et sollicitudin in, interdum vitae nibh.
        Fusce ullamcorper dictum nunc, eget bibendum ipsum viverra quis. Aliquam vitae leo non metus ultricies tempus in id libero.
        Vivamus mauris tortor, convallis ut luctus at, elementum sed velit. Cras cursus tempus erat adipiscing lacinia.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam diam risus, sollicitudin sed venenatis a, molestie in turpis.

A: Encapsulate the divs:
div.projItems{width:360px;min-height:200px;_height:200px;background:#000}

div.projItemsLeft{float:left;width:360px;background:#990}
div.projItemsRight{float:right;width:330px;background:#900}
div.projItemsContent{float:left;width:300px;background:#ccc}

        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet nunc eu ligula tincidunt faucibus.
        Curabitur eget magna neque, sed porta sem. Fusce eu lorem at orci dapibus faucibus ut eu mi. In eget ligula risus.
        Sed id lectus lorem. Integer elit dui, bibendum vitae dictum a, mollis sodales diam. Morbi vehicula lobortis semper.
        Suspendisse potenti. Proin eu convallis lectus. Praesent ut sem at enim condimentum dictum vitae id elit.
        Phasellus id dolor ante, hendrerit tempus lorem. Proin nisi nibh, convallis et sollicitudin in, interdum vitae nibh.
        Fusce ullamcorper dictum nunc, eget bibendum ipsum viverra quis. Aliquam vitae leo non metus ultricies tempus in id libero.
        Vivamus mauris tortor, convallis ut luctus at, elementum sed velit. Cras cursus tempus erat adipiscing lacinia.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam diam risus, sollicitudin sed venenatis a, molestie in turpis.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet nunc eu ligula tincidunt faucibus.
        Curabitur eget magna neque, sed porta sem. Fusce eu lorem at orci dapibus faucibus ut eu mi. In eget ligula risus.
        Sed id lectus lorem. Integer elit dui, bibendum vitae dictum a, mollis sodales diam. Morbi vehicula lobortis semper.
        Suspendisse potenti. Proin eu convallis lectus. Praesent ut sem at enim condimentum dictum vitae id elit.
        Phasellus id dolor ante, hendrerit tempus lorem. Proin nisi nibh, convallis et sollicitudin in, interdum vitae nibh.
        Fusce ullamcorper dictum nunc, eget bibendum ipsum viverra quis. Aliquam vitae leo non metus ultricies tempus in id libero.
        Vivamus mauris tortor, convallis ut luctus at, elementum sed velit. Cras cursus tempus erat adipiscing lacinia.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam diam risus, sollicitudin sed venenatis a, molestie in turpis.

    Right column content

    Left column content

A: Google turned up this: http://matthewjamestaylor.com/blog/perfect-3-column.htm
I once used this as a guide: http://bluerobot.com/web/layouts/layout3.html
And this too is a good resource: http://www.thenoodleincident.com/tutorials/box_lesson/boxes.html


text:
Q: Playing sound with AudioClip in Java - JackRouter error? I'm relatively new to Java, though now I'm delving a little bit further in here.
I'm creating a program that displays a button of a chicken, and upon clicking this button, an audioclip of the chicken clucking is played. Simple, it seems, yet I really can't get audio to work at all.
I'm using AudioClip to try to accomplish this. The book that I've been using to teach myself, [i]Introduction to Java Programming[/i] (eighth edition) by Y. Daniel Liang, tells me that I can use AudioClip despite in a non-Applet program despite its location.
I'm having trouble getting this to work, though, so here's what I have so far. I'll give you my code and then give you the error I'm receiving.
I'm temporarily on a Mac, by the way, and haven't had a chance to try it on Windows. Don't know why that would affect anything, but there you go.
//this is the class that plays the sound. The main class follows.

import javax.swing.JApplet;
import java.applet.*;
import java.net.URL;

public class ChickenSound extends JApplet
{
private AudioClip chSound; //creates AudioClip

public ChickenSound()
{
    URL url = getClass().getResource("resources/chicken-sound.wav"); //creates a url that is the path of the soundfile
    chSound = this.newAudioClip(url); //sets AudioClip equal to the url
    chSound.play(); //plays AudioClip
}
}

//main class
// some of these imports are unnecessary but I will clean them up later
import java.applet.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.*;

import java.net.URL;
import javax.swing.*;

public class ChickenButton extends JFrame
{
private ImageIcon chBtnIcon = new ImageIcon("resources/chicken-side.png");
private JButton chBtn = new JButton(chBtnIcon);
private JPanel panel = new JPanel(new GridBagLayout());

public ChickenButton() //main window
{
    GridBagConstraints c = new GridBagConstraints();

    chBtn.setBorder(BorderFactory.createEmptyBorder());
    chBtn.setContentAreaFilled(false);
    Font bigFont = new Font("Times New Roman", Font.BOLD, 25);
    JLabel chLbl = new JLabel("Click the Chick'n");
    chLbl.setFont(bigFont);

    c.gridheight = 1;
    c.gridx= 0;
    c.gridy = 0;
    c.weighty = 2;
    panel.add(chLbl,c);
    c.gridheight=2;
    c.gridx= 0;
    c.gridy = 1;
    c.weighty = 2;
    panel.add(chBtn, c);
    add(panel);

    chBtn.addActionListener(new ChLstnr()); //creates click listener for button
}

public static void main(String[] args)
{
    ChickenButton window = new ChickenButton();
    window.setLocationRelativeTo(null);
    window.setTitle("Chick'n Button");
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.setSize(300, 400);
    window.setVisible(true); //creates window

}

class ChLstnr implements ActionListener
{
    public void actionPerformed(ActionEvent e)
    {
        System.out.println("Cluck cluck cluck"); //for button functionality testing purposes (and it works)
        ChickenSound chSnd = new ChickenSound(); //this is supposed to play the sound. This doesn't work.
    }
}

}

The errors I receive are...
2012-07-06 15:44:33.365 java[41264:ff03] Error loading /Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter:  dlopen(/Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter, 262): no suitable image found.  Did find:/Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter: no matching architecture in universal wrapper

2012-07-06 15:44:33.367 java[41264:ff03] Cannot find function pointer New_JackRouterPlugIn for factory 7CB18864-927D-48B5-904C-CCFBCFBC7ADD in CFBundle/CFPlugIn 0x102191490 </Library/Audio/Plug-Ins/HAL/JackRouter.plugin> (bundle, not loaded)

I really have no idea what this means. Obviously it has something to do with an audio plug-in that can't be loaded, but I don't really know. From what it seems this may be more of an error with my computer than something I'm messing up with Java, but I've found no solution so far. I've tried this with two IDEs, Eclipse and Netbeans, and they both produce the same errors. Does anyone have an idea what's up with this?
Any help is greatly appreciated.
Thanks.
Edit:
It just works now. Somehow.


text:
Q: Find String Start and End position multiple times Would like to find the Start and End position of passwords multiple times in a given string.
I have 2 arrays
one for possible password tags combination
another for tags splitter
need to use the below 2 arrays to locate the possible password string combination and the corresponding splitter after it.
String[] tags = {password, pwd, passcode};
String[] splitter = {:,#,=};

Need to find the start and end position of password in below string
Example 1:
Input:
password: test123 and pwd = 123&test

Output:
test123 = 10,17
123&test = 27,36

Example 2:
Input:
passcode: test123 and passcode: 123&test

Output:
test123 = 10,17
123&test = 32,40

A: To extract the passwords you could use a regular expression and the Pattern and Matcher classes.
here an example
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Pwd {

    private Pwd() {
        super();
    }

    public static String maskPwd(String input) {

        String regex = "(?:password|pwd|passcode) ?[:#=] ?([a-zA-Z0-9&]+)\s?";
        Pattern pwdPattern = Pattern.compile(regex);
        Matcher pwdMatcher = pwdPattern.matcher(input);

        StringBuilder maskedInput = new StringBuilder();
        boolean isFollowingPwd = false;
        int previousEnd = -1;
        while (pwdMatcher.find()) {

            if (isFollowingPwd) {
                int start = pwdMatcher.start(1);
                int end = pwdMatcher.end(1);

                maskedInput.append(input.substring(previousEnd, start));
                appendMaskSign(start, end, maskedInput);

                previousEnd = end;
            } else {
                int start = pwdMatcher.start(1);
                int end = pwdMatcher.end(1);

                maskedInput.append(input.substring(0, start));
                appendMaskSign(start, end, maskedInput);

                isFollowingPwd = true;
                previousEnd = end;
            }
        }
        maskedInput.append(input.substring(previousEnd, input.length()));

        return maskedInput.toString();
    }

    private static void appendMaskSign(int start, int end, StringBuilder maskedInput) {
        int signCounter = end - start;
        for (int i = 0; i < signCounter; i++) {
            maskedInput.append("*");
        }
    }
}

and some Junit5 tests, which passed
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

class PwdTest {

    @Test
    void mask() {
        String actual = Pwd.maskPwd("password: test123 and pwd = 123&test");

        String expected = "password: ******* and pwd = ********";

        assertEquals(expected, actual);
    }

    @Test
    void mask2() {
        String actual = Pwd.maskPwd("passcode: test123 and passcode: 123&test");

        String expected = "passcode: ******* and passcode: ********";

        assertEquals(expected, actual);
    }

    @Test
    void mask3() {
        String actual = Pwd.maskPwd("password: test123 and passcode= 123&test and pwd# 987&test");

        String expected = "password: ******* and passcode= ******** and pwd# ********";

        assertEquals(expected, actual);
    }
}

The code will also work with more than 2 passwords (look at mask3()).

A: Split string by and
        String[] inputStrArr = input.split("and");

find the splitter to be use
        for(String str : inputStrArr) {
            String passStrSplt = "";
            if(str.indexOf(":") > 0) {
                passStrSplt = ":";
            } else if(str.indexOf("#") > 0) {
                passStrSplt = "#";
            } else if(str.indexOf("=") > 0) {
                passStrSplt = "=";
            }
    // get the password from each string
           String passStr = str.substring(0,str.indexOf(passStrSplt));
           String passVal = str.substring(str.indexOf(passStrSplt)+1,str.length());
           System.out.println("passVal:"+passVal);
    // find begin and end index
           int beginIndex = input.indexOf(passVal);
           int  endIndex = beginIndex+passVal.length();
           System.out.println("begin:"+beginIndex+" end:"+endIndex);

Output
    passVal: test123
    begin:9 end:18

    passVal: 123&test
    begin:27 end:36

verify if string with begin and endIndex matches expected password
    String extractedPass = input.substring(beginIndex, endIndex);
    System.out.println("extractedPass "+extractedPass);

Output ExtractedPass
    extractedPass  test123

    extractedPass  123&test


text:
Q: Unexpected token } in JSON at position 378 Trying to figure out why the top .json file returns an error while the bottom works fine. (sorry if format is terrible, first post here) working code is from GitHub so i don't have very much knowledge of the 'inner workings'(mac OS). TIA
{
  "regions": [
    "cville",
    "tech",
    "downtown",
    "outskirts",
    "allregions"

  ],

  "region_subregions": {
    "cville": ["tech", "downtown"],
     "allregions": ["cville", "tech", "downtown", "northcv",  "southcv", "westcv", "canecreek"]

  },
  "region_neighborhoods": {
    "southcv": ["parkview", "sink", "fairground"],

  }
}

{
  "regions": [
    "sf",
    "eastsf",
    "centralsf",
    "westsf",
    "southsf",
    "peninsula",
    "sanjose",
    "marin",
    "eastbay",
    "sacramento",
    "allregions"
  ],
  "region_subregions": {
    "sf": ["eastsf", "centralsf", "westsf"],
    "allregions": ["eastsf", "centralsf", "westsf", "southsf", "peninsula", "sanjose", "marin", "eastbay", "sacramento"]
  },
  "region_neighborhoods": {
    "eastsf": ["embarcadero-p39-northbeach", "missionbay-dogpatch", "soma-ferry_bldg", "fidi-union_sq", "tenderloin-civic_center", "nob-russian_hill"],
    "centralsf": ["haight-castro", "mission-dolores", "fillmore-hayes_valley"],
    "westsf": ["presidio-marina", "richmond-gg_park", "sunset-", "lakeview-lake_merced"],
    "southsf": ["glen_park-twin_peaks", "ingleside-", "excelsior-portola", "outer_mission-cow_palace", "bayview-", "south_city-brisbane", "daly_city-pacifica"],
    "peninsula": ["half_moon_bay-coast", "san_bruno-burlingame", "san_mateo-foster_city", "belmont-sc-rws", "redwood_city-palo_alto", "mt-view_sunnyvale"],
    "sanjose": ["san-jose"],
    "marin": ["marin-"],
    "eastbay": ["oakland-", "berkeley-", "east-bay"],
    "sacramento": ["sacramento-"]
  }
}

A: It's due to the trailing comma on this line
 "southcv": ["parkview", "sink", "fairground"],


text:
Q: Uniqueness proof for a certain functional equation Consider the following functional equation:
\begin{equation}f(x)=kf(mx)\end{equation}
where $x \in [0,1]$; $k>0$; $0<m<1$; and $f(1)=1$.
It has at least one solution: $f(x)=x^l$, where $l=log_m({1/k})$.
Assume further that $f$ is smooth on $(0,1)$. Is $f$ unique? If not, does adding monotonicity restriction on $f$ guarantee uniqueness?

A: Let $f_0\colon [m,1]$ be any continuous (and maybe monotonic) function with $f(m)=\frac1k$, $f(1)=1$. Then we can define $f(x)=k^{-r}f_0(m^{-r}x)$ where $r=\lfloor\log_mx\rfloor $ and obtain a continuous solution on $(0,1]$ and every continuos solution on $(0,1]$ can be obtained this way.
If $k>1$, this solution extends to $[0,1]$. If $k<1$, there cannot be a continuous solution as necessarily $f({m^r})=k^{-r}\to\infty$. If $k=1$, the solution is continuous at $0$ only if it is constant.
If we require not only that $f_0$ is continuos, but is smooth and the derivatives at $m$ and $1$ "fit", we obtain a smooth solution on $(0,1]$.


text:
Q: NSMutableDictionary - entries appear to be over-written by each addition I'm fairly new to Objective-C; but have been coding for years and this one really stumps me.
I'm trying to build an iPhone app and wanted to create a "settings" screen which will use a Table format. (Xcode 5.1.1).
I want to future proof the main Settings screen and make it easy for the application coding by hiding the "hard work" in subroutines/methods.
I may be getting too clever but I've created a class for each 'setting' that contains screen prompts, default values etc and using an Enum to cross-reference it (so the compiler will highlight typos etc)
The problem I'm encountering is that when I add entries to my NSMutableDictionary and use lldb to print the values; every entry seems to have the same "key" and values. I've tried converting the eNum to an NSNumber and also as an NSString -- no difference in the result - so I'm obviously doing something else daft but just can't see it
The following code is from various .m & .h files, I've omitted boring stuff that you always "have to have" to keep it short
// basic x-ref I want to use in my code
typedef NS_OPTIONS(NSInteger, ConfigurationType)  {
    unDefined = -1,
    Server = 0,
    Id  = 1,
    Phone  = 2
};
// definition for a "single" Settings value
@interface SettingDefinition : NSObject
@end

@implementation SettingDefinition

ConfigurationType _cfgType;
NSString *_cfgName;
NSString *_screenTitle;
NSString *_value;

- (NSString *)description
{
    NSString *className = NSStringFromClass([self class]);
    return [NSString stringWithFormat:@"<%@: x%p Type=%d dbKey=%@ '%@' -> %@>", className, self, _cfgType, _cfgName, _screenTitle, _value];
}
- (id)initType:(ConfigurationType)cfgOption
      withDbKey: (NSString*)dbKey
      asOptionTitle:(NSString*)cfgTitle
      withValue:(NSString*)itmValue
{
    self = [super init];

    if (self) {
        _screenTitle = cfgTitle;
        _cfgName = dbKey;
        _cfgType = cfgOption;
        _value = itmValue;
    }
    return self;
}
@end

@interface Configuration : NSObject
@end
@implementation Configuration {
   NSMutableDictionary *Settings;  // List of Setting structures
};

- (id)init {
    self = [super init];

    if (self) {
        Settings = [[NSMutableDictionary alloc]init];

        [self add:Server withDbKey:@"Server" asOptionTitle:@"Server"];
        [self add:Id     withDbKey:@"Id"     asOptionTitle:@"Your ID"];
        [self add:Phone  withDbKey:@"Phone"  asOptionTitle:@"Phone No."];
    }
    return self;
}
- (void)    add:(ConfigurationType)cfgOption
      withDbKey:(NSString*)dbKey
  asOptionTitle:(NSString*)cfgTitle
{
     NSString * itmValue = [self configurationValue: cfgOption cfgName:dbKey];
     SettingDefinition *x = [[SettingDefinition alloc]
                               initType:  cfgOption
                               withDbKey:   dbKey
                               asOptionTitle:  cfgTitle
                               withValue: itmValue];
     [Settings setObject:x forKey:[self asKey:cfgOption]];
}

- (NSString *) asKey:(ConfigurationType) settingType {
    NSString *rc = [NSString stringWithFormat:@"%d", settingType];
    return rc;
}
- (NSString *) configurationValue:(ConfigurationType) settingType {
    // returns a suitable value from my system setup
    // which is initially a null value until the user sets everything up
}

the debug window shows the following when I break after the final call to [self add: ...]
    (lldb) po Settings
    {
       0 = "<SettingDefinition: x0x8e7c280 Type=2 dbKey=Phone 'Phone No.' -> (null)>";
       1 = "<SettingDefinition: x0x8c703a0 Type=2 dbKey=Phone 'Phone No.' -> (null)>";
       2 = "<SettingDefinition: x0x8e7c310 Type=2 dbKey=Phone 'Phone No.' -> (null)>";
    }

The (null) is obviously due to no data in 'value' yet; but why do they all show as 'Phone'; if I break after the second call to [self add:..] they all show as 'Id'

UPDATE:
DOH! obviously they're globals (I've been using another IDE where everything is local until exposed) .. If I enclose them in braces in the implementation as the documentation states then the exhibited problem vanishes. I have properties to access the variables but as the setter does more than just set the memory, I thought I'd need my "own" variables to hold the data.. said it was something daft .. thank you!


text:
Q: How to change the Button text using JS? I have this button in my WordPress site that says ENROLL THIS COURSE. I want it to show ADD TO CARD. Can anyone provide me with custom JavaScript. Can anyone help me please?
ENROLL THIS COURSE


text:
Q: What are some good resources for learning threaded programming? With the rise of multicore CPUs on the desktop, multithreading skills will become a valuable asset for programmers. Can you recommend some good resources (books, tutorials, websites, etc.) for a programmer who is looking to learn about threaded programming?

A: I've honestly never read it myself, but Concurrent Programming in Java is a book I've heard recommended by several people.

A: http://www.yoda.arachsys.com/csharp/threads/

A: I write about multithreading and concurrency in C++ on my blog. I'm also writing a book on concurrency in C++: C++ Concurrency in Action.

A: I've read (most of) Java Concurrency in Practice by Brian Goetz, which is very good.
There is obviously a Java-based theme running through the book (using Java specific implementations of threads, locks etc.), but pretty much all of the principles can be applied to other languages.
The author's home page contains a list of articles he has written, some of which include threading related stuff. Maybe start there and if you like his style, buy the book.

A: For a great guide and reference for concurrency programming in C# (or .NET in general) I'd recommend the MSDN What Every Dev Must Know About Multithreaded Apps article by Vance Morrison on MSDN. It contains a great deal of best-practice information and caveats about multithread development

A: I maintain a linkblog for concurrency articles, blogs, and projects at:
http://concurrency.tumblr.com
I usually post a link or two per day on a variety of topics (threads, actors, locking, parallel programming) in a variety of environments (Erlang, Java, Scala, .NET, C++, Ruby, Python, etc).

A: It's Delphi specific, but no reason why the concept wouldn't apply to any other language!
Multi Threading Tutorial

A: Take a look at Herb Sutter's "The Free Lunch Is Over" and then his series of articles on Effective Concurrency.

A: Joseph Albahari wrote a good overview of Threading in C# here:
http://www.albahari.com/threading/

A: http://www.cilk.com/multicore-e-book/
That's a nice general overview of the sitution, if you're looking for tuorials and books it might be best to specify a language as a starting point so you can mess around with some code.

A: The Erlang programming language provides an easy-to-use style of concurrent programming.  You may never actually use Erlang, but the concepts are transportable to other languages.  You might want to read the book Programming Erlang: Software for a Concurrent World .
Fans of functional programming claim that there is no need to learn anything new.  Just use a pure functional language, and the compiler or interpreter will automatically parallelize everything.  So you might want to learn Haskell, OCaml, or another functional language.

A: I don't know what exactly you are looking for, but if you are doing WindowsForms development the following blog post is worth every minute reading:
WinForms UI Thread Invokes: An In-Depth Review of Invoke/BeginInvoke/InvokeRequred

A: I think Boost.Threads is a great C++ concurrency library to learn, especially if you just want to get started in writing multithreaded applications.  The code is very succinct and easy to understand, plus the next C++ standard will likely include a threading library based on Boost.Threads  (tutorial: http://www.ddj.com/cpp/184401518)

A: If you want to have a go at doing a highly parallel version of a simple task, or see real solutions, you could do worse than look at the wide finder project.  Basically it's about how to do parallel regex matching of log files efficiently, but trying to add as little code as possible.
Participants have submitted solutions in many different languages and the performance results are posted.  The original project has now finished and there is now wide finder 2 taking the work on.
CodingHorror has a good introduction to wide finder.

A: For a rich, thorough treatment of the subject, with a good balance between computer science and practice, I recommend The Art of Multiprocessor Programming. A lot of examples are in object-oriented code, i.e. Java, with other languages scattered throughout. It just depends on the topic being covered. What I really love about this book is that it discusses how common algorithms should be implemented in a concurrent design. Of course, there's so much more!
For general concepts and a treatment of pthreads, I really like Programming with POSIX Threads. Being the library and API that it is, it's in C.
For Windows and C# developers, check out Joe Duffy's blog. Joe works on parallel libraries, infrastructure, and programming models in Microsoft's Developer Division. He has a book coming in Nov. 2008 titled Concurrent Programming on Windows (Amazon link).
Also, don't miss the Godfather's blog: Herb Sutter's Sutter's Mill. He has links to all his articles in Dr. Dobb's Journal and more. Click his Concurrency category.

A: CPU manufacturers websites have some interesting content:
http://developer.amd.com/documentation/articles/Pages/default.aspx#parallel
http://software.intel.com/en-us/multi-core
Also Intel's opensource threading library has some good references:
http://www.threadingbuildingblocks.org/

A: If you work with C#, the book "C# 2008 and 2005 threaded programming", by Gaston C. Hillar - Packt Publishing - http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book ,  will help you.
Highly recommended for C# programmers, because you can download the code with funny examples that exploit your multicore computer.
The book is a nice guide with a lot of code to practice. It tells stories while it explains the most difficult concepts.


text:
Q: Power set elements of a certain length Given an array of elements in PHP, I wish to create a new two-dimensional array containing only those elements of the power set that are a specific length. As an example, for the following array:
array(4) {
    0 => 'A',
    1 => 'B',
    2 => 'C',
    3 => 'D'
}

If I were to run the function fixed_length_power_set( $arr, 2 ) then I want it to return:
array(6) {
    0 => array(2) {
        0 => 'A',
        1 => 'B'
    }
    1 => array(2) {
        0 => 'A',
        1 => 'C'
    }

    2 => array(2) {
        0 => 'A',
        1 => 'D'
    }
    3 => array(2) {
        0 => 'B',
        1 => 'C'
    }
    4 => array(2) {
        0 => 'B',
        1 => 'D'
    }
    5 => array(2) {
        0 => 'C',
        1 => 'D'
    }
}

Although I can think of a few rules to generalize the process, for some reason I can not seem to turn it into code. Does anyone have suggestions?

A: Use a simple recursive algorithm: For the set of all subsets of size k from a set of size n,

*

*if n == k, return a set containing the entire set;

*if k == 1 return the set of all singletons;

*otherwise remove an element x from the set: now you need all the subsets of size k-1 of the remaining set (i.e. those subsets which include x), as well as all the subsets of size k of the remaining set (those which don't include x).
In PHP pseudo-code:
function subsets_n($arr, $k)
{
  if (count($arr) < $k) return array();
  if (count($arr) == $k) return array(0 => $arr);

  $x = array_pop($arr);
  if (is_null($x)) return array();

  return array_merge(subsets_n($arr, $k),
                     merge_into_each($x, subsets_n($arr, $k-1)) );
}

Here merge_into_each() adds x to each array in the collection:
function merge_into_each($x, $arr)
{
  foreach ($arr as &$a) array_push($a, $x);
  return $arr;
}

A: I am not a PHP expert, so I will answer with pseudocode instead. Since you seem to be asking about arrays and subsequences (even though you use the English words "sets" and "subsets"), I'll do that. I'll use the notation arr[m:n] to mean the construction of a brand new array of length n - m + 1 that copies the elements m, m+1, ..., n from arr.
fun subsequences(arr, len) {
    answer = new empty array

    // base case 1: we haven't got a enough members in the
    // array to make a subsequence that long, so there are
    // no subsequences of that length
    if(arr.length < len) return answer

    // base case 2: we're only looking for trivial subsequences
    if(len <= 0) {
        trivial = new empty array
        prepend trivial to answer
        return answer
    }

    // choose the first element in the subsequence nondeterministically
    for each i from 0 to arr.length - 1 {
        // since we know the sequence starts with arr[i], the
        // remainder of the sequence must come from the elements
        // after index i
        subanswer = subsequences(arr[i+1:arr.length], len-1)
        for each subsequence in subanswer, prepend arr[i] to subsequence
        answer = concat(subanswer, answer)
    }
}


text:
Q: Bredon homology defined using singular chains Is it possible to replace cellular chains in the construction of Bredon homology/cohomology with cingular chains? (Possible it should be, but in that case will the Bredon homology groups be the same?)
I have strong feeling that it should be possible, but I am not sure.

A: I'll answer this question just for future references. Since (after fixing a coefficient system) the ordinary cohomology theory is unique, on G-CW-complexes cohomology defined by cellular chains will be the same as defined by singular chains. And since compactly generated G-spaces have weak homotopy type of a G-CW-complex, it is possible to use singular chains in the definition.


text:
Q: Javascript global value remained NULL after attempting to change it via function I am trying to change the global variable in javascript after it picks up changes in a drop down list.
Below is the HTML:
<select class='dropdown' id='selection' onChange='checkyo()'>
 <option value="is_revenue">Revenue</option>
 <option value="is_costofrevenue">Cost of Revenue</option>
</select>

Below is the javascript:
var isSelected = {}; //global variable

checkyo = function() {
  chosen = document.getElementById("selection").value;
  isSelected = chosen;
};

alert(isSelected);  //check the updated value

I am expecting the value of isSelected to be either is_revenue or is_costofrevenue depending on the drop down list selected by the user but then my alert is showing an empty array.

A: Your alert is issued before anything changes the select box's value. Move the alert into the onchange handler (checkyo). Also ensure that your code runs after the element exists (the simplest way is to put the script tag at the end of the page, just before the closing </body> tag).
Example: Live Copy
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Example</title>
</head>
<body>
<select class='dropdown' id='selection' onChange='checkyo()'>
 <option value="is_revenue">Revenue</option>
 <option value="is_costofrevenue">Cost of Revenue</option>
</select>
  <script>
    var isSelected = {}; //global variable

    checkyo = function() {
      chosen = document.getElementById("selection").value;
      isSelected = chosen;

      alert(isSelected);  //check the updated value
    };

  </script>
</body>
</html>

A: The onchange event only fires when the dropdown box element is changed.  The alert is currently outside of that handler.  Move the alert inside of the checkyo() function.
Here is the fiddle.
HTML
<select class='dropdown' id='selection' onChange='checkyo()'>
 <option value="is_revenue">Revenue</option>
 <option value="is_costofrevenue">Cost of Revenue</option>
</select>

JS
var isSelected = {}; //global variable

checkyo = function() {
  chosen = document.getElementById("selection").value;
  isSelected = chosen;
  alert(isSelected);  //check the updated value
};


text:
Q: What's the pattern evaluation on Jenkinsfile when-branch setting? I am trying to detect the branch pattern on a when statement inside a stage.
Like this:
stage('deploy to staging') {
agent label:'some-node'
when { branch "feature/*" }
steps {
    sh './deploy_pr.sh'
}

}
What if I want a more complicated pattern?
I am trying to detect something like feature/0.10.25 and the following pattern doesn't work:
when { branch 'feature/[0-9]+.[0-9]+.[0-9]+' }

Doesn't work . And it's a correct regexp, according to https://regexr.com/

A: Ok ! So, through the error stack trace I found out that on the when-branch option, Jenkins compares with Ant style patterns:
https://ant.apache.org/manual/dirtasks.html
That means it doesn't expect regexp, but simpler stuff like:
        */staging/*

I solved this by using the when-expression option instead, like this:
        when {
            expression { BRANCH_NAME ==~ /feature\/[0-9]+\.[0-9]+\.[0-9]+/ }
        }

That uses groovy expressions as described here:
https://www.regular-expressions.info/groovy.html
Especially, look for the explanation of the ==~ operator, that was helpful.
For the regular expression itself, you can test yours here:
https://regexr.com/


text:
Q: C# XslCompiledTransform - output in form of POCO instead of Html I am trying to read a xml file and insert its contents in a database.
I ran into XSLT transformation and it is really fast and good. The following code works fine and the data is seen in the result.html
var settings = new XsltSettings(true, true);
var xslt = new XslCompiledTransform();
xslt.Load("filename.xsl", settings, new XmlUrlResolver());
xslt.Transform("xmlfileName.xml", "result.html");

However I wanted to take the data from XML and insert it into a database.
Is it possible through XSLT transformation? Like rather than the output as HTML, is there a way to get this data in any other format, so that I can then pick it up and insert it into a database.
I know this can be done by xml deserialization, however I am wondering if this can be done through XSLT too. It will be really fast and cool!

A: The main output format for XSLT 1 is XML so instead of HTML you can certainly create XML output (with the data you want). How to insert XML into a database is another topic.
XSLT 1 can also create plain text output so for some restricted uses where you have an existing API that expect CSV or a similar format you can of course also have the XSLT create that text format.
Using XSLT 3 as supported for the .NET framework by the .NET version of Saxon 9.9 or 9.8 can also create JSON as XdmMap or XdmArray and then convert it a .NET Dictionary for instance, see e.g. http://saxonica.com/html/documentation9.9/dotnetdoc/Saxon/Api/XdmMap.html and http://saxonica.com/html/documentation9.9/dotnetdoc/Saxon/Api/XdmMap.html#AsDictionary()


text:
Q: error installing xapian core gem Building native extensions.  This could take a while...
ERROR:  Error installing xapian-core:
ERROR: Failed to build gem native extension.

rake1.8 RUBYARCHDIR=/usr/lib/ruby/gems/1.8/gems/xapian-core-1.2.7.1/lib RUBYLIBDIR=/usr/lib/ruby/gems/1.8/gems/xapian-core-1.2.7.1/lib
sh: rake1.8: not found

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/xapian-core-1.2.7.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/xapian-core-1.2.7.1/ext/gem_make.out
Here is the gem makeout file:
rake1.8 RUBYARCHDIR=/usr/lib/ruby/gems/1.8/gems/xapian-core-1.2.7.1/lib RUBYLIBDIR=/usr/lib/ruby/gems/1.8/gems/xapian-core-1.2.7.1/lib
sh: rake1.8: not found


text:
Q: Why is the distance between two points in a 2d plane not differentiable when the distance is 0? I've been told that if we have two moving points in a 2d plane, their movement described by:
$$x_{1}(t) = v_{x1}\times t + x_{1_{0}}, 0 <= t < t_{end}$$
$$y_{1}(t) = v_{y1}\times t + y_{1_{0}}, 0 <= t < t_{end}$$
and analogously for $y_{2}(t)$ and $x_{2}(t)$, then, if we write the distance between them as:
$$D(t) = \sqrt{(v_{x1}\times t + x_{1_{0}}-v_{x_{2}} \times t-x_{2_{0}})^2+(v_{y_{1}}\times t + y_{1_{0}}-v_{y_{2}} \times t-y_{2_{0}})^2}$$,
then D(t) is not differentiable when the distance is zero. Why is this?

A: The distance (in $1$ dimension) behaves like $\sqrt{x^2}=|x|$ and it is well-known, that the function $f:\mathbf R \to \mathbf R$, $x\mapsto |x|$ is not differentiable in $0$. Just calculate $f_+'(0)$ and $f_-'(0)$.


text:
Q: How disable copy and paste windows server 2008 I need create Group policy to use disable copy and paste  windows server 2008 please

A: Unfortunately, this is not possible.  While it is possible to disable copy/paste in certain applications like Internet Explorer, there are workarounds.  System wide, it simply impossible.


text:
Q: Shifting \newtheorem Is there a way to shift a theorem from amsthm ? I mean instead of having :
theorem 1.1 (title): BLABLABLA
You would have theorem 1.1 a little bit on the left and blablabla in the same place. Similarly, it would be something like this : (but without tcolorbox, here I don't need the rest of the functionnalities, the style of amsthm is sufficient)

I want that my definition ( which is for now classic ) has the same behavior as the green and orange box. The dimension is not a problem (I'll set the value of shifting )

A: You can try something like this.  The main point is that the last argument to \newtheoremstyle allows you to put arbitrary code to format the heading.  You can make the heading stay within the margins by adjusting \leftskip at the same time you set the body font, i.e. in the third argument to \newtheoremstyle.

\documentclass{article}

\usepackage{amsthm}
\usepackage{lipsum} % for dummy text

\newtheoremstyle{side}{}{}{\advance\leftskip3cm\relax\itshape}{}
{\bfseries}{}{0pt}{%
\makebox[0pt][r]{%
  \smash{\parbox[t]{2.5cm}{\raggedright\thmname{#1}%
  \thmnumber{\space #2}\thmnote{\newline (#3)}}}%
  \hspace{.5cm}}}

\theoremstyle{side}
\newtheorem{theorem}{Theorem}[section]

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\begin{document}

\lipsum[1]

\begin{theorem}
  \lipsum[1]
\end{theorem}

\begin{theorem}[Euclid]
  \lipsum[2]
\end{theorem}

\begin{theorem}[Very long name]
  \lipsum[3]
\end{theorem}

\begin{definition}
  \lipsum[1]
\end{definition}

\end{document}


text:
Q: Arbitrary VLAN interface name Is there a way to name a VLAN interface arbitrarily like eth72 or ext19 instead of the four standard nameing schemes eth0.72, vlan19 (and the padded variations)?
Don't have no clue. Perhaps udev?

A: OMG - it's that easy:
Rename vlan 42 on eth0 to ext2:
ip link set dev eth0.42 name ext2

A: I didn't have luck with "ip link set dev bond0.10 name ext0". If the interface is up, it gets a BUSY error. If the interface is down, it gets a NOT FOUND error.
What I did have luck with is this: in my base interface definition for bond0,
post-up ip link add name ext0 link bond0 type vlan id 10
pre-down ip link delete dev ext0 type vlan

and
auto ext0
iface ext0 inet static
    address ...

Now I find that "ifup bond0" not only creates the VLAN as seen in /proc/net/vlan/config and creates the ext0 device, but it even ifup's the ext0 device. bond0.10 never comes into existence.

A: In OpenBSD (and presumably other BSDs) you can set a description of an interface with ifconfig using the aptly named description argument, see ifconfig(8). This is very handy for distinguishing between a bunch of interfaces. But that doesn't help you.
Unfortunately there's no great way to do this in Linux.
In Linux, interfaces are named dynamically with each interface being assigned the first available name. This means that if you pull a NIC and then add another one (say to replace it or upgrade it) there is no guarantee that its interface will remain the same.
Try a program like ifrename which will allow you to manually specify the interface names. It looks primarily designed to assure that NIC0 is always associated with eth0 but I believe you can use it assign names like external and dmz to interfaces instead of eth0 and so on. Udev will also allow you to change interface names using the network.rules file (see here for an examples).
You should be careful to document this as it is not typically done but unlike @MichealHampton I don't see any particular problem with it. I personally make great use of the description field for interfaces in my BSD installs.

A: In debian you use /etc/network/interfaces to configure your network interfaces.
Be aware that you should install the vlan package:
apt-get install vlan

From man 5 interfaces:

To  ease  the configuration of VLAN interfaces, interfaces having .  (full stop character) in the name are configured as 802.1q tagged virtual LAN interface.
For example, interface eth0.1 is a virtual interface having eth0 as physical link, with VLAN ID 1.

For more information check man 5 vlan-interfaces. Basically, you can give your vlan interface any name, and use vlan-raw-device to associate the vlan with your NIC. For instance, vlan10 on eth0 would be:
iface vlan10 inet static
    vlan-raw-device eth0
    address 192.168.10.1
    netmask 255.255.255.0

On non-debian distros, you can do this same thing with iproute2 as follows:
ip link add link enp3s0f1 name vlan10 type vlan id 10
ip addr add 192.168.10.1/24 dev vlan10

A: So this works well.
in /etc/network/interfaces:
auto lxdHost
iface lxdHost static
   pre-up ip link add link eth0 name lxdHost type vlan id 102
   address 192.1.1.1/25
   ...

then ifup lxdHost
pre-up and post-down and the others in intefaces man are the magic hooks to do things your own way.

A: Not sure if this also applies to Debian, but in Ubuntu (and Red Hat), this is easily done by editing /etc/udev/rules.d/persistent-net.rules (or similar; I'm not in a position to check)
Renaming interfaces has some useful advantages:

*

*assigns known semantics to an interface (eg. 'management0', 'front0', 'back0')

*having a predictable name makes it easier for configuration management scripts etc to work well (esp. Firewall rules)

You do need to make sure that your team knows to expect this. That's not a problem, it's generally very welcome, particularly when you have many interfaces in a system (eth8 is not unreasonable in an host with redundant bonded links to SAN storage)
Having discussed this recently, if you wanted to rename based on VLAN ID, I would suggest that you consider the following:

*

*VLAN IDs are not all that memorable and easily mistyped and looked over.

*a host generally has no simple way to determine which VLAN (if any) it is on, or it if is the native VLAN, and an access or trunk port (doing this manually from the host is sometimes doable if you tcpdump for CDP messages or know what traffic maps to which VLAN). Thus, the configuration is one based on belief, which can easily become invalid.

A: Using nmcli on RedHat/CentOS/SL 7 you have system-supported persistent arbitrary namig for VLAN interfaces, just:
$ nmcli con add type vlan ifname outside dev eno1 id 10


text:
Q: Spread operator in array syntax Vs. Array New to React.
I was trying to update the boolean value 'done' whenever the user clicks on it.
For some reasons, this code doesn't work
var updateTodo = todos;
updateTodo[Number(id)].done = !updateTodo[Number(id)].done;
setTodos(updateTodo);

but this does
var updateTodo = [...todos];
updateTodo[Number(id)].done = !updateTodo[Number(id)].done;
setTodos(updateTodo);

As far as I think todos and [...todos] both return the same values i.e. todos array, then why won't the first code snippet work?
Here is working App.tsx for reference, not working snippet present in the function handleDone.
import React from "react";

type item = {
  itemId: number;
  todo: string;
  done: boolean;
};

var id = 0;

const App: React.FC = () => {
  const [newTodo, setNewTodo] = React.useState<string>("");
  const [todos, setTodos] = React.useState<item[]>([]);

  const handleChange = (event: any) => {
    const { value } = event.target;
    setNewTodo(value);
  };

  const handleSubmit = (event: any) => {
    setTodos([...todos, { itemId: id, todo: newTodo, done: false }]);
    id++;
    setNewTodo("");
    event.preventDefault();
  };

  const handleDone = (item: any) => {
    // Not Working
    var updateTodo = todos;
    updateTodo[Number(id)].done = !updateTodo[Number(id)].done;
    setTodos(updateTodo);

    // Working Code
    // var updateTodo = [...todos];
    // updateTodo[Number(id)].done = !updateTodo[Number(id)].done;
    // setTodos(updateTodo);
  };

  return (
    <>
      <form>
        <input onChange={handleChange} value={newTodo} type="text" name="todo" placeholder="Enter Todo" />
        <button onClick={handleSubmit}>Add</button>
      </form>

        {todos.map((item, index) => {
          return item.done ? (
            <li id={`${item.itemId}`} onClick={handleDone} style={{ textDecoration: "line-through" }}>
              {item.todo}

          ) : (
            <li id={`${item.itemId}`} onClick={handleDone} style={{ textDecoration: "none" }}>
              {item.todo}

          );
        })}

    </>
  );
};

export default App;


text:
Q: Apache Tomcat server on linux I have installed java and tomcat appache  server on linux.
When i am going to start tomcat using ./startup.sh command on linux server,
it gives output as
Using CATALINA_BASE:   /usr/src/apache-tomcat-5.5.28
Using CATALINA_HOME:   /usr/src/apache-tomcat-5.5.28
Using CATALINA_TMPDIR: /usr/src/apache-tomcat-5.5.28/temp
Using JRE_HOME:        /usr/src/jdk1.6.0_16
Using CLASSPATH:       /usr/src/apache-tomcat-5.5.28/bin/bootstrap.jar

but server is not started.
after that when i am firing javac command ,it generates following error
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

i am not getting the right reason for that.
I am new with linux.
Please help me.
Thanks in advance

A: Could not reserve enough space for object heap.
Looks like there is not enough memory given for the initialisation.
Check the given memory...and reconfigure your memory size for the JVM.


text:
Q: Can't fire up Package Manager with ctrl+shift+p in Sublime Text 3 After installing gnome-session-flashback when I hit ctrl+shift+p, nothing is happening. How to solve it?
PS I have checked Keyboard Shortcuts, but there is nothing about ctrl+shift+p

A: Install XFCE instead of using GNOME Flashback.
GNOME defines global keyboard shortcuts, which may override per-program ones. Try changing/disabling them so that GNOME no longer attempts to "take over" those key combinations:

To change a keyboard shortcut:

*

*Select Edit ▸ Preferences ▸ Shortcuts.

*Select the shortcut that you wish to edit by clicking on it.

*Once the shortcut is selected, click on the shortcut key combination to edit it.

*Press your desired shortcut key combination as you would enter it to use it. The keys that you can use include Alt, Alt Gr, Ctrl, Shift
  number and letter keys.

Mnemonic key combinations, such as Alt+F will not work.

*Once you have entered your new shortcut, it will automatically be saved and you should see it in the list next to the corresponding
  action.

Alternatively, you could try changing the settings using dconf-editor as suggested by this blog post:

I really love Gnome 3 and its Shell, but I almost went nuts on this.
  It really took me a while to finally figure this out. To make a really
  short blog post even shorter:
Use dconf-editor (from package dconf-tools) and go to
  org.gnome.desktop.wm.keybindings. There you have it.
Why would I want to change keyboard shortcuts? Some of them (namely
  Alt+F1, Alt+F7 and Alt+F8) clash with IntelliJ IDEA's shortcuts.
  That's why! :-)


text:
Q: Conectar señales usando GObjectIntrospection Estoy siguiendo este tutorial sobre python + GObjectIntrospection. El código es muy simple:
import gi
gi.require_version( 'Gtk', '3.0' )
from gi.repository import Gtk

class Handler:
 def onButtonPressed( self, button ):
  print( 'Boton pulsado ... ' )

 def onDestroy( self, *args ):
  Gtk.main_quit( )

builder = Gtk.Builder( )
builder.add_from_file( '.archivo.glade' )

builder.connect_signals( Handler( ) )
window = builder.get_object( 'MainWindow' )
window.show_all( )

Gtk.main( )

Al ejecutarlo con python3 main.py, aparenta ejecutarse bien, pero al cerrar la ventana (pulsando en el icono de su barra de título), dicha ventana efectivamente se cierra, pero el programa no finaliza. Da la sensación de que no se llama a la función Gtk.main_quit( ).
En el depurador, colocando un punto de interrupción en la línea
Gtk.main_quit( )

observo que nunca se entra en ese punto. La ejecución no llega ahí. Da la sensación de que onDestroy no es la señal a la que conectarse.
Por supuesto, he intentado cambiarlo a 'destroy', 'on_destroy', 'Destroy', y alguna mas, pero ninguna ha funcionado.

A: Asegurate de declarar las señales en Glade. El mismo tutorial muestra que el archivo .glade se debe cambiar para definir las señales onDestroy y onButtonPressed:
...
    <signal name="destroy" handler="onDestroy" swapped="no"/>
...
        <signal name="pressed" handler="onButtonPressed" swapped="no"/>
...

En este diff se pueden observar en detalle las diferencias entre los dos ejemplos de archivo .glade del tutorial.


text:
Q: Reading "raw" Unicode-strings in Python I am quite new to Python so my question might be silly, but even though reading through a lot of threads I didn't find an answer to my question.
I have a mixed source document which contains html, xml, latex and other textformats and which I try to get into a latex-only format.
Therefore, I have used python to recognise the different commands as regular expresssions and replace them with the adequate latex command. Everything has worked out fine so far.
Now I am left with some "raw-type" Unicode signs, such as the greek letters. Unfortunaltly is just about to much to do it by hand. Therefore, I am looking for a way to do this the smart way too. Is there a way for Python to recognise / read them? And how do I tell python to recognise / read e.g. Pi written as a Greek letter?
A minimal example of the code I use is:
fh = open('SOURCE_DOCUMENT','r')
stuff = fh.read()
fh.close()

new_stuff = re.sub('READ','REPLACE',stuff)
fh = open('LATEX_DOCUMENT','w')
fh.write(new_stuff)
fh.close()

I am not sure whether it is an important information or not, but I am using Python 2.6 running on windows.
I would be really glad, if someone might be able to give me hint, at least where to find the according information or how this might work. Or whether I am completely wrong, and Python can't do this job ...
Many thanks in advance.
Cheers,
Britta

A: You talk of ``raw'' Unicode strings. What does that mean? Unicode itself is not an encoding, but there are different encodings to store Unicode characters (read this post by Joel).
The open function in Python 3.0 takes an optional encoding argument that lets you specify the encoding, e.g. UTF-8 (a very common way to encode Unicode). In Python 2.x, have a look at the codecs module, which also provides an open function that allows specifying the encoding of the file.
Edit: alternatively, why not just let those poor characters be, and specify the encoding of your LaTeX file at the top:
\usepackage[utf8]{inputenc}

(I never tried this, but I figure it should work. You may need to replace utf8 by utf8x, though)

A: Please, first, read this:
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
Then, come back and ask questions.

A: You need to determine the "encoding" of the input document. Unicode can encode millions of characters but files can only story 8-bit values (0-255). So the Unicode text must be encoded in some way.
If the document is XML, it should be in the first line (encoding="..."; "utf-8" is the default if there is no "encoding" field). For HTML, look for "charset".
If all else fails, open the document in an editor where you can set the encoding (jEdit, for example). Try them until the text looks right. Then use this value as the encoding parameter for codecs.open() in Python.


text:
Q: Failed prop type: Material-UI: Either children, image, src or component prop must be specified. at CardMedia I'm trying to use CardMedia component from Material-ui and and was getting this error 'Failed prop type: Material-UI: Either children, image, src or component prop must be specified.
at CardMedia' tried many solution like adding component='img' it removed the error but the image wasn't displayed (removes the error but breaks it).
it works fine with out it tho but i want to know why i kept getting the error
"@material-ui/core": "4.12.3",
"@material-ui/icons": "^4.11.2",
"react": "^17.0.2",

<CardMedia
  className={media}
  image={post.selectedFile}
  title={post.title}
  // component="image"
  // component="img"
/>

A: After some Debugging found out that the CardMedia component is a Div and my styles were implied on a div and specifying it as an image component using the line component="img", it broke my css, and the image was just 'Hiding lol' it was there all along.


text:
Q: Bootstrap cards not showing like in examples Why do my Bootstrap cards look weird? In the examples they look like cards with a border and white padding but mine look like text only without the padding and the white background.
For example:

I don't know if the code will help you but here it is:

.container {
  left: 0;
  right: 0;
  bottom: -340px;
  text-align: middle;
  position: absolute;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

This is Card #1

Some quick example text to build on the card title and make up the bulk of the card's content.

          Learn More

A: Copying card css from the boostrap4 version into your bootstrap3 solution worked for me. Nice if you are stuck on bootstrap3.
Just drop the following in your CSS anywhere.
.card {
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.25rem;
}

.card-block {
    -webkit-box-flex: 1;
    -webkit-flex: 1 1 auto;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    padding: 1.25rem;
}

.card-title {
    margin-bottom: 0.75rem;
}

.card-subtitle {
    margin-top: -0.375rem;
    margin-bottom: 0;
}

.card-text:last-child {
    margin-bottom: 0;
}

.card-link:hover {
    text-decoration: none;
}

.card-link + .card-link {
    margin-left: 1.25rem;
}

.card > .list-group:first-child .list-group-item:first-child {
    border-top-right-radius: 0.25rem;
    border-top-left-radius: 0.25rem;
}

.card > .list-group:last-child .list-group-item:last-child {
    border-bottom-right-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
}

.card-header {
    padding: 0.75rem 1.25rem;
    margin-bottom: 0;
    background-color: #f7f7f9;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.card-header:first-child {
    border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0;
}

.card-footer {
    padding: 0.75rem 1.25rem;
    background-color: #f7f7f9;
    border-top: 1px solid rgba(0, 0, 0, 0.125);
}

.card-footer:last-child {
    border-radius: 0 0 calc(0.25rem - 1px) calc(0.25rem - 1px);
}

.card-header-tabs {
    margin-right: -0.625rem;
    margin-bottom: -0.75rem;
    margin-left: -0.625rem;
    border-bottom: 0;
}

.card-header-pills {
    margin-right: -0.625rem;
    margin-left: -0.625rem;
}

.card-primary {
    background-color: #0275d8;
    border-color: #0275d8;
}

.card-primary .card-header,
.card-primary .card-footer {
    background-color: transparent;
}

.card-success {
    background-color: #5cb85c;
    border-color: #5cb85c;
}

.card-success .card-header,
.card-success .card-footer {
    background-color: transparent;
}

.card-info {
    background-color: #5bc0de;
    border-color: #5bc0de;
}

.card-info .card-header,
.card-info .card-footer {
    background-color: transparent;
}

.card-warning {
    background-color: #f0ad4e;
    border-color: #f0ad4e;
}

.card-warning .card-header,
.card-warning .card-footer {
    background-color: transparent;
}

.card-danger {
    background-color: #d9534f;
    border-color: #d9534f;
}

.card-danger .card-header,
.card-danger .card-footer {
    background-color: transparent;
}

.card-outline-primary {
    background-color: transparent;
    border-color: #0275d8;
}

.card-outline-secondary {
    background-color: transparent;
    border-color: #ccc;
}

.card-outline-info {
    background-color: transparent;
    border-color: #5bc0de;
}

.card-outline-success {
    background-color: transparent;
    border-color: #5cb85c;
}

.card-outline-warning {
    background-color: transparent;
    border-color: #f0ad4e;
}

.card-outline-danger {
    background-color: transparent;
    border-color: #d9534f;
}

.card-inverse {
    color: rgba(255, 255, 255, 0.65);
}

.card-inverse .card-header,
.card-inverse .card-footer {
    background-color: transparent;
    border-color: rgba(255, 255, 255, 0.2);
}

.card-inverse .card-header,
.card-inverse .card-footer,
.card-inverse .card-title,
.card-inverse .card-blockquote {
    color: #fff;
}

.card-inverse .card-link,
.card-inverse .card-text,
.card-inverse .card-subtitle,
.card-inverse .card-blockquote .blockquote-footer {
    color: rgba(255, 255, 255, 0.65);
}

.card-inverse .card-link:focus, .card-inverse .card-link:hover {
    color: #fff;
}

.card-blockquote {
    padding: 0;
    margin-bottom: 0;
    border-left: 0;
}

.card-img {
    border-radius: calc(0.25rem - 1px);
}

.card-img-overlay {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 1.25rem;
}

.card-img-top {
    border-top-right-radius: calc(0.25rem - 1px);
    border-top-left-radius: calc(0.25rem - 1px);
}

.card-img-bottom {
    border-bottom-right-radius: calc(0.25rem - 1px);
    border-bottom-left-radius: calc(0.25rem - 1px);
}

@media (min-width: 576px) {
    .card-deck {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-flex-flow: row wrap;
        -ms-flex-flow: row wrap;
        flex-flow: row wrap;
    }
    .card-deck .card {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-flex: 1;
        -webkit-flex: 1 0 0%;
        -ms-flex: 1 0 0%;
        flex: 1 0 0%;
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    .card-deck .card:not(:first-child) {
        margin-left: 15px;
    }
    .card-deck .card:not(:last-child) {
        margin-right: 15px;
    }
}

@media (min-width: 576px) {
    .card-group {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-flex-flow: row wrap;
        -ms-flex-flow: row wrap;
        flex-flow: row wrap;
    }
    .card-group .card {
        -webkit-box-flex: 1;
        -webkit-flex: 1 0 0%;
        -ms-flex: 1 0 0%;
        flex: 1 0 0%;
    }
    .card-group .card + .card {
        margin-left: 0;
        border-left: 0;
    }
    .card-group .card:first-child {
        border-bottom-right-radius: 0;
        border-top-right-radius: 0;
    }
    .card-group .card:first-child .card-img-top {
        border-top-right-radius: 0;
    }
    .card-group .card:first-child .card-img-bottom {
        border-bottom-right-radius: 0;
    }
    .card-group .card:last-child {
        border-bottom-left-radius: 0;
        border-top-left-radius: 0;
    }
    .card-group .card:last-child .card-img-top {
        border-top-left-radius: 0;
    }
    .card-group .card:last-child .card-img-bottom {
        border-bottom-left-radius: 0;
    }
    .card-group .card:not(:first-child):not(:last-child) {
        border-radius: 0;
    }
    .card-group .card:not(:first-child):not(:last-child) .card-img-top,
    .card-group .card:not(:first-child):not(:last-child) .card-img-bottom {
        border-radius: 0;
    }
}

@media (min-width: 576px) {
    .card-columns {
        -webkit-column-count: 3;
        -moz-column-count: 3;
        column-count: 3;
        -webkit-column-gap: 1.25rem;
        -moz-column-gap: 1.25rem;
        column-gap: 1.25rem;
    }
    .card-columns .card {
        display: inline-block;
        width: 100%;
        margin-bottom: 0.75rem;
    }
}

Source: https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L4055

A: It shows up fine by me. You have to make sure that you are linking the version 4 style sheet.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">

A: The Bootstrap 4 card feature has undergone additional changes from the earlier v4-alpha version(s) to the v4-beta version. However, the examples on the Bootstrap web site still use the older class name. The cards still render, but the padding is lost if the older class name is used.
Current (September 2017) example using the card-body class (CSS):

Card title

Some quick example text to build on the card title and make up the bulk of the card's content.

    Go somewhere

Here is a similar answer to a related question.

A: This might be old, but are you using a customized bootstrap file by any chance? I recently was trying to work with cards using our customized file, and the same thing was happening to me. Then I realized that there are no card classes in the bootstrap file, nor is there any mention of Cards on the customize page.
http://getbootstrap.com/customize/
Seems strange to me, I even had a coworker verify it though. Hope this helps.

A: If you have installed bootstrap via a package manager, such as NPM:
For some package managers, the default installed version is bootstrap@4.0.0-beta.2 which doesn't appear to have this feature.
This could be misleading as the correct version is described on Bootstrap's Getting started > Download section, found here
To resolve, ensure you are referencing the latest package version bootstrap@4.0.0-alpha.6


text:
Q: Is there an open source implementation of Mathematica-the-language? I've seen questions before such as "What is the best open-source equivalent for Mathematica?", but that specific question (and that line of inquiry in general) cares more about the computer algebra system and less about the core language and its unique and powerful features.
My interest in Mathematica come from a slightly different angle--namely, I find a tremendous amount of value in the power and flexibility of the language that Mathematica implements (I think of it as a slightly less scary looking syntax for Lisp with some very novel additions such as the powerful pattern matching system).
Are there any projects that have made a concerted effort to build a Mathematica-the-language work-alike instead of focusing on the Computer Algebra System?
Mathics is the closest project I've found so far (since it does, in fact, try to stay faithful to Mathematica syntax where it can), but even it pitches itself as a computer algebra system. And it was written in Python, which isn't bad by itself, but it sets itself up to not be as fast as Mathematica for computationally intensive tasks.
It seems to me that Wolfram Research would actually benefit tremendously from having an even bigger programmer community around Mathematica as a language and developer platform, because more packages would be produced to solve more off-the-shelf programming problems (just like almost any other programming language).
An open (or at least freely available) implementation of the core programming language wouldn't even dilute their secret sauce which I would say primarily lies in Mathematica's base of mathematical rules and algorithms, in the scientific computing tools that they've bundled into one enormous and broad package, and into the insanely well-integrated notebook experience that they should have no trouble keeping ahead of any kind of open source project.

A: I've been collecting these links for a while, so this question is a good excuse for a link dump. I'm not sure which project is the "best", but I think that mathics and symja are two of the more active and developed projects.
Lisp:
MockMMA is probably the first implementation of the Mathematica language. It was written by Richard Fateman who had a bit of a scuffle with Wolfram Research over the code.
Python:
Mathics (which you mentioned in the question) is primarily a syntax layer ontop of sympy and sage, not an independent implementation of the Mathematica language.
Pythonica is an abandoned python implementation of Mathematica.
Java:
symja is a pure Java library for symbolic mathematics that uses Mathematica notation and supports Rubi Integration rules.
omath is an project that is still under development that will have a Mathematica like syntax, but does not aim to blindly copy Mathematica.
Go:
expreduce an experimental computer algebra system written in Go.

The omath page also has some interesting links to papers describing some of the Mathematica language's algorithms:
Matching in flat theories by Temur Kutsia.
A detailed description of Mathematica's flat pattern matching. (But quite technical!) (original link)
Mathematica as a Rewrite Language by Bruno Buchberger.
On the implementation of a rule-based programming system and some of its applications by Mircea Marin and Temur Kutsia.
These people obviously understand Mathematica's pattern matching enumeration system forwards and backwards.
Discussions about whether computer languages can be copyrighted, 1, 2, 3.

A: Yes.
According to Mathematica's creator, Stephen Wolfram, Mathematica is just an implementation of a language that as of 2013 has been named Wolfram
Two other implementations have been developed by a Kernel Developer at Wolfram Research (poeschko.com).
One is called Mathador, which is implemented in C++ and is no longer maintained, but the source may be of interest to you.
The other is called Mathics and is currently (as of 2022) being maintained.  It is implemented in Python, uses the SymPy package to perform symbolic computations, and has a web browser interface.  You can check it out online at mathics.org.

A: Expreduce
Expreduce is a new MIT-licensed project that has a fairly complete implementation of the language semantics. Further, it has a nice collection of definitions that provide CAS functionality, along with documentation to match. There is also a large testing suite for verification. It aims to have a small core with most of the functionality implemented in the language itself using the rewrite rule paradigm. The kernel is written in Go. Here are some examples of what can be computed:
In[1]:= D[Cos[Log[Sin[x]]+x]+x,x]

Out[1]= (1 + (-1 * (1 + Cot[x]) * Sin[(x + Log[Sin[x]])]))

In[2]:= Integrate[5*E^(3*x),{x,2,a}] // Expand

Out[2]= ((-5/3 * E^6) + (5/3 * E^(3 * a)))

The CAS functionality uses a collection of rewrite rules. For example, the product rule for derivatives is implemented using only one line:
D[a_*b_,x_] := D[a,x]*b + a*D[b,x]

The implementation is currently lacking in visualizations and the functionality of Solve among other things. Right now it is just a terminal, but perhaps there will be a Jupyter notebook interface for it in the future. It has virtually no dependencies. Since it does not call out to another open source CAS, there are many operations that it cannot do. Fortunately, the rule paradigm allows for fast development of new features. It could also benefit by getting the Risch algorithm for integration. Right now the integrations are mostly solved using heuristics.
mmaclone
There is also an interesting Haskell implementation of the pattern matching engine by Yonghao Jin at https://github.com/jyh1/mmaclone.


text:
Q: How to speed up the execution of inserting values in postgresql data_input=open(ratingsfilepath,'r')
for row in data_input:
   cur_load.execute("INSERT INTO "+ratingstablename+" VALUES (%s, %s, %s)", (row.split('::')[0],row.split('::')[1],row.split('::')[2]))

I have 10 million records in .dat file I am loading them into table using python script. But it takes nearly 1 hour to load them. Is there anything to reduce the time

A: Inserting 10 million records will anyway take a very long time, but you can still speed it up by using your python script to convert your data file into CSV format that corresponds to your table structure. Then you can use the COPY FROM sql command to load it into the table in one go.
Using copy is considerably faster than 10 million inserts.


text:
Q: is this possible to do with iBatis + spring usual idiom of using ibatis with spring support is following.  Or this is how I'm doing it. please let me know if it can be done a better way?
beans xml:
<bean id="DataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/some/som1/my/mydb"/>
</bean>
<bean id="SqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="classpath:sql-map-config-oracle.xml"/>
  <property name="dataSource" ref="DataSource"/>
</bean>
 <bean id="myDAO" class="com.reports.MyUserAccessDAO">
    <property name="sqlMapClient" ref="SqlMapClient"/>
    <property name="dataSource" ref="DataSource"/>
 </bean>

interface:
public interface MyUserAccessIface {
    public SomeBean getUserReports (String org);
}

DAO:
public class MyUserAccessDAO extends SqlMapClientDaoSupport implements MyUserAccessDAO {
    public SomeBean getUserReports (String org)
    {
      SomeBean bean = new SomeBean();
      //code for parameters goes here
      getSqlMapClientTemplate().queryForList("namesp.userreport", parm);
      //fetch the result from parm and put them in SomeBean
      return bean
    }
}

calling the DAO:
MyUserAccessIface iBatisDAO =
(MyUserAccessIface) ApplicationInitializer.getApplicationContext().getBean("myDAO");

even though this works fine I dont understand the need for an interface.
Questions

*

*Can the interface be taken out of the
picture and still have this working?

*can the design/settings be changed so
the call to the DAO is simply (even if that requires a base abstract class)
MyUserAccessDAO mydao = new MyUserAccessDAO();
mydao.getUserReports("blah");
I've asked question along these lines couple days back but after struggling for 2 days and finding more things out I asked this question again now.  If possible please provide code snippets of what you'd change/add.
Unit testing with this design does not work because everything is residing inside the container.  If I get that working, then I will be adding that to the question as well (for information purpose).
Also, I think for someone trying to make spring + ibatis work...this would end up being a good place to start.
Edit:
Like I mentioned above that I would like to call my DAO like this (or i'm fine with passing something along as constructor parameter):
MyUserAccessDAO mydao = new MyUserAccessDAO(); mydao.getUserReports("blah");

To achieve above I would have following line in my DAO
setSqlMapClient((SqlMapClient)ApplicationInitializer.getApplicationContext().getBean("SqlMapClient"));

Still need to know what all to overwrite to be able to write test case for this.  Test case wont be able to access anything inside the container so it will depend on Driver Datasource...
Since I am going against the best practice here...i dont mind changing my DAO exclusively just for the test case...

A:
Can the interface be taken out of the picture and still have this working?

Don't take the interface out.  It's there for a good reason (e.g., proxy generation for transactions, AOP, mocks for testing in services, etc.)
Why do you want to take it out?  What angst is it causing for you?

Can the design/settings be changed so the call to the DAO is simply (even if that requires a base abstract class)

Why are you calling "new"?  If you're using Spring, you should be injecting this using the App Context.  If you call "new", it's not under Spring's control.  That should be the whole point.

A: The interface is there to decouple you from depending directly on the implementation, which is, in general, good practice. It should all work fine without the interface, but it is better to depend on abstractions rather than implementations.
As for testing, well by using the interface, it becomes much easier to test the code using the DAO as you can just create a "mock" implementation of this that just returns dummy data and "inject" this manually in your unit test - your client code can't tell the difference between this and the real DAO as all it knows about is the interface.

A: I can think of 1 major principle taking out the interface would break... 'object orientation' and most importantly, the inability to change method signatures without disrupting clients calling your code.  That alone would stop me on my tracks.  GOOD QUESTION THOUGH!!  During many engagements, I am usually asked this question.  Or simply people want to program to abstract classes. =)


text:
Q: jQuery Datatable, saving state of the table like pagination, search etc So I am using this attribute "bStateSave": true to save the state of jQuery Datatable but for some reason it doesn't work for me. It doesn't save search results and pagination etc when I do the page refresh. Is there some other parameter that needs to go in hand with this one. I am mainly going by the information on this page
http://datatables.net/examples/basic_init/state_save.html
The code is too freaking huge to be posted and I am not sure what snipped should I used to post. Thanks in advance for your help.

A: First off, you want to make sure you have a cookie, hop into chrome once you loaded your page, click on "settings," then "show advanced settings," under the privacy section click on content settings.
Below is a code example from that site, that works fine in my web app and also make sure you have the most recent version of the plugin.
$('#MyExampleGrv').dataTable({
    "bStateSave": true,
    "fnStateSave": function (oSettings, oData) {
        localStorage.setItem('DataTables_' + window.location.pathname, JSON.stringify(oData));
    },
    "fnStateLoad": function (oSettings) {
        var data = localStorage.getItem('DataTables_' + window.location.pathname);
        return JSON.parse(data);
    }
});

What this code does, is makes a local storage instead of the cookie, and uses a page specific versus just using a generic identifier called Datatables, this way if you have a table on another page, there will be no conflicts. What this code will not do, this code will not save the pagination state if you are using ASP.NET controls and a gridview, if you use the generic CRUD operations built into ASP.NET such as EDIT/DELETE/UPDATE, and your edit item is on pagination page 3, it will default to page 1 after postback and even partial postback via AJAX.

A: I know that this answer is not about this old version of datatables, but I believe it will help newcomers.
Datatables API changed a lot from 2011 to now.
To save the state of a datatable, you use either HTML5 LocalStorage or DB(ajax callbacks).
To enable state saving using localStorage, you do the following call:
$(document).ready(function() {
$('#datatable').DataTable({
  stateSave: true,
 });
} );

If you want to use sessionStorage instead of localStorage:
$(document).ready(function() {
$('#datatable').DataTable({
  stateSave: true,
  stateDuration:-1 //force the use of Session Storage
 });
} );

If you want to use a database to avoid storing them in the browser, then you have to use callback functions  defined in the options stateSaveCallback and stateLoadCallback.
Here is a tutorial with examples and source code that shows you how to implement all the methods above: Datatables state save client and server-side

A: Do you see the cookie when inspecting in your browser?  I am using Chrome and the developer tools to see the current cookies for the link you sent.  I see a cookie called "datatables.net" stored on my machine.  Do you see this cookie when trying your custom DataTables code?


text:
Q: ExceptionNotifier constant uninitialized Rails 3 I've read over many questions on this site as well as the GitHub documentation for ExceptionNotifier and its implementation in Rails 3, and I can't figure out why it won't work for me on my production server. On my local machine (a Mac), it works perfectly in the production environment. But after I deploy with capistrano and run the app using unicorn on a Linux box, my unicorn log complains about an uninitialized constant ExceptionNotifier in my environments/production.rb file, even though my local machine seems to think it's fine. I've tried with both implementations:
gem 'exception_notification', :require => 'exception_notifier' and
gem 'exception_notification_rails3', :require => 'exception_notifier'. Both are throwing this error. Here's my production.rb
Rl4::Application.configure do
  # code omitted
  # Enable ExceptionNotifier, having it ignore its default exceptions
  config.middleware.use ExceptionNotifier,
    sender_address: 'reports@ctatechs.com',
    exception_recipients: 'brice@ctatechs.com',
    ignore_exceptions: ExceptionNotifier.default_ignore_exceptions
end

Here's my Gemfile
source 'https://rubygems.org'
# lots omitted
gem 'exception_notification_rails3', :require => 'exception_notifier'
# lots more omitted

And here's my application_controller.rb, which implements the gem:
class ApplicationController < ActionController::Base
  protect_from_forgery

  # By default, only production ENV considers requests not local
  unless Rails.application.config.consider_all_requests_local
    rescue_from Exception, :with => :server_error
    rescue_from ActionController::UnknownAction, :with => :not_found
    rescue_from ActionController::UnknownController, :with => :not_found
    rescue_from ActionView::MissingTemplate, :with => :not_found
  end

  private
    def server_error(exception)
      ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
      respond_to do |format|
        format.html { render template: '/500.html', layout: 'application/layout', status: 500 }
        format.all { render nothing: true, status: 500 }
      end
    end

    def not_found(exception)
      ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
      respond_to do |format|
        format.html { render template: '/404.html', layout: 'application/layout', status: 404 }
        format.all { render nothing: true, status: 404 }
      end
    end
end

Again, the implementation isn't my problem at the moment. Somehow, the gem isn't installing correctly or it's not being initialized properly. I did run a sudo gem install on the Linux box for both versions of the gem, as well as 'exception_notifier'. No dice. Thoughts?
Additional info
I just tried to reinstall the gem as a plug-in, and got the same errors after changing the production.rb file to use config.middleware.use ::ExceptionNotifier instead. However, those modifications still worked on my local machine. Maybe I'm missing another piece of software on the Linux box? Nothing seems to be mentioned on the documentation...
Request for gem version
I'm using exception_notification, v. 3.0.1
Request for full stacktrace
I, [2013-04-24T17:34:44.113788 #16877]  INFO -- : Refreshing Gem list
E, [2013-04-24T17:34:46.562588 #16877] ERROR -- : uninitialized constant ExceptionNotifier (NameError)
/home/deployer/rl4/releases/20130424201053/config/environments/production.rb:80:in `block in <top (required)>'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:24:in `class_eval'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:24:in `configure'
/home/deployer/rl4/releases/20130424201053/config/environments/production.rb:1:in `<top (required)>'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:571:in `block in <class:Engine>'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/deployer/rl4/releases/20130424201053/config/environment.rb:5:in `<top (required)>'
config.ru:4:in `require'
config.ru:4:in `block in <main>'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `eval'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `block in builder'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `call'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `build_app!'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:595:in `init_worker_process'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:615:in `worker_loop'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:511:in `maintain_worker_count'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:277:in `join'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/bin/unicorn:19:in `load'
/home/deployer/rl4/shared/bundle/ruby/1.9.1/bin/unicorn:19:in `<main>'

A: Here is how you can solve it.
Considring you already have SMTP setting in your development and production.rb
Gemfile
gem 'exception_notification' ,'3.0.0', :require => 'exception_notifier'

application.rb
config.middleware.use ExceptionNotifier,
  :email_prefix => "[ERROR]",
  :sender_address => %{"Exception Notifier" <XYZ@gmail.com>},
  :exception_recipients => %w{ABC@gmail.com}

application_controller.rb
#render 500 error
def render_error(exception)
  ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
  respond_to do |f|
    ...
  end
end

For me it works both in development and production(Heroku).
Hope it will help you as well.
Cheers:)

A: It shames me to say that my fix for this problem was so trivial.
$ cap unicorn:stop
$ cap unicorn:start

My restart task in my deployment process was never actually stopping the instance of the server, so the new libraries weren't being loaded, and thus, the exceptions.
Ladies and gents, don't forget to try turning it off and back on again. Ever. Thanks to everyone who helped me through this problem.


text:
Q: Creating a function from a 2D array in MATLAB (For use in ode45) I am a first time MATLAB user. I have a 2d array of t vs f in MATLAB. This 2d array correponds to a function, say f(t). I am using ode45 to solve a set of differential equations and f(t) is one of the coefficients i.e. I have a set of equations of the form x'(t)=f(t)x(t) or variations thereof. How do I proceed?
I need a way to convert my array of t vs f into a function that can be used in the ode45 method. Presumably, the conversion will do some linear interpolation and give me the equation of the best fit curve.
Or if there is another approach, I'm all ears!
Thank you!

A: This is a simple example with passing function as a parameter to right hand side of the ODE. Create files in the same directory and run main
main.m
t = 0:0.2:10; f = sin(t);
fun = @(xc) interp1(t, f, xc);

x0=0.5
% solve diff(x, t)=sin(t)
% pass function as parameter
[tsol, xsol] = ode45(@(t, x) diff_rhs(t, x, fun),[0.0 8.0], 0.5);

% we solve equation dx/dt = sin(x), x(0)=x0
% exact solution is x(t) = - cos(t) + x(0) + 1
plot(tsol, xsol, 'x');
hold on
plot(tsol, -cos(tsol) + x0 + 1, '-');
legend('numerical', 'exact');

diff_rhs.m
function dx = diff_rhs(t, x, fun)
  dx = fun(t);
end

References in the documentation: interp1 and anonymous Functions.


text:
Q: c# winforms property attributes and binding In order to get a more presentable list of properties to the end-user, I've added quite a lot of property attributes DisplayName and Browsable(false).
Now, it appears the program crashes when trying to bind to the original property name (I didn't update all bindings). Follwoing error occurs:
System.ArgumentException: Cannot bind to the property or column MyPropertyName on the DataSource.
Parameter name: dataMember
   at System.Windows.Forms.BindToObject.CheckBinding()
   at System.Windows.Forms.BindToObject.SetBindingManagerBase(BindingManagerBase lManager)
   at System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase)
   at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding)
   at System.Windows.Forms.BindingsCollection.Add(Binding binding)
   at System.Windows.Forms.BindingContext.UpdateBinding(BindingContext newBindingContext, Binding binding)
   at System.Windows.Forms.Control.UpdateBindings()

Is this a known behaviour, or am I looking at the wrong problem's origin?

A: Thanks to Ivan pointing me to the right direction.
Indeed Browsable(false) removes the property from BindingSource as explained in this thread.
As I use DevExpress' property grid, it is sufficient to use an empty DisplayName to remove it from the list of showing properties in their components... So I simply added a EmptyDisplayName attribute which returns null as the DisplayName.
Note that I didn't check if this works for other property lists.