text:
Q: Vertical Left Menu with User Control (Expander inside) must close others when you open one XAML I'm implementing a Vertical Left Drop Down Menu with an User Control, this has inside an Expander. The UserControl has a DependencyProperty which expect a ListView (The Items of the Menu), also has a dependency property "IsSelected" which is bind with Expander property "IsExpanded". I like implement a function when the user click in the UserControlMenu, open this (if is Closed) and close the others. I attached my classes and UserControl, but, now I'm only get when you click on the UserControlMenu, this open and in that instant close.
The UserControl XAML
<UserControl x:Class="DropDownMenuExpander.UserControlMenuItem"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
             mc:Ignorable="d" >
    <Grid>
        <md:PackIcon Kind="{Binding Path=Icon}" Width="15" Height="15" Margin="10 16"/>
        <Expander x:Name="ExpanderMenu" Header="{Binding Path=Header}" IsExpanded="{Binding Path=IsSelected}" Width="210" HorizontalAlignment="Right" Background="{x:Null}">
            <ContentControl Content="{Binding ListView}"/>
        </Expander>
    </Grid>
</UserControl>

The UserControl .cs
    public partial class UserControlMenuItem : UserControl
    {
        public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register("Header", typeof(string), typeof(UserControlMenuItem));
        public string Header
        {
            get
            {
                return (string)GetValue(HeaderProperty);
            }
            set
            {
                SetValue(HeaderProperty, value);
            }
        }

        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(UserControlMenuItem));
        public bool IsSelected
        {
            get
            {
                return (bool)GetValue(IsSelectedProperty);
            }
            set
            {
                SetValue(IsSelectedProperty, value);
            }
        }

        public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof(PackIconKind), typeof(UserControlMenuItem));
        public PackIconKind Icon
        {
            get
            {
                return (PackIconKind)GetValue(IconProperty);
            }
            set
            {
                SetValue(IconProperty, value);
            }
        }
        public static readonly DependencyProperty ListViewProperty = DependencyProperty.Register("ListView", typeof(ListView), typeof(UserControlMenuItem), new UIPropertyMetadata(null));
        public ListView ListView
        {
            get
            {
                return (ListView)GetValue(ListViewProperty);
            }
            set
            {
                SetValue(ListViewProperty, value);
            }
        }
        public UserControlMenuItem()
        {
            InitializeComponent();
            DataContext = this;
        }
    }

Calling the UserControl in the MainWindow
<StackPanel x:Name="st_menu" Margin="10" Orientation="Vertical" ScrollViewer.CanContentScroll="True">
                    <local:UserControlMenuItem  x:Name="MenuItemHome" Header="Home" Icon="Home" PreviewMouseDown="MenuItemHome_PreviewMouseDown">
                        <local:UserControlMenuItem.ListView>
                            <ListView SelectionMode="Single" Margin="0 16 0 16">
                                <ListViewItem>
                                    <TextBlock Text="Item1"/>
                                </ListViewItem>
                                <ListViewItem>
                                    <TextBlock Text="Item2"/>
                                </ListViewItem>
                                <ListViewItem>
                                    <TextBlock Text="Item3"/>
                                </ListViewItem>
                            </ListView>
                        </local:UserControlMenuItem.ListView>
                    </local:UserControlMenuItem>
                    <local:UserControlMenuItem  x:Name="MenuItem2" Header="User" Icon="User" PreviewMouseDown="MenuItemHome_PreviewMouseDown">
                        <local:UserControlMenuItem.ListView>
                            <ListView SelectionMode="Single" Margin="0 16 0 16">
                                <ListViewItem>
                                    <TextBlock Text="User1"/>
                                </ListViewItem>
                                <ListViewItem>
                                    <TextBlock Text="User2"/>
                                </ListViewItem>
                                <ListViewItem>
                                    <TextBlock Text="User3"/>
                                </ListViewItem>
                            </ListView>
                        </local:UserControlMenuItem.ListView>
                    </local:UserControlMenuItem>
                    <local:UserControlMenuItem  x:Name="MenuMes2" Header="Messages" Icon="Chat" PreviewMouseDown="MenuItemHome_PreviewMouseDown">
                        <local:UserControlMenuItem.ListView>
                            <ListView SelectionMode="Single" Margin="0 16 0 16">
                                <ListViewItem>
                                    <TextBlock Text="Message1"/>
                                </ListViewItem>
                                <ListViewItem>
                                    <TextBlock Text="Message2"/>
                                </ListViewItem>
                                <ListViewItem>
                                    <TextBlock Text="Message3"/>
                                </ListViewItem>
                            </ListView>
                        </local:UserControlMenuItem.ListView>
                    </local:UserControlMenuItem>
                </StackPanel>

MainWindow.cs
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            MenuItemHome.IsSelected = true;
        }

        private void MenuItemHome_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            foreach (var item in st_menu.Children)
            {
                if (item is UserControlMenuItem menuItem)
                {
                    if (menuItem.Equals(sender as UserControlMenuItem))
                    {
                        menuItem.IsSelected = true;
                    }
                    else
                    {
                        menuItem.IsSelected = false;
                    }
                }
            }
        }
    }

A: You should set eventArgs.Handled = true;, it will stop the event bubbling, like:
private void MenuItemHome_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
    foreach (var item in st_menu.Children)
    {
        if (item is UserControlMenuItem menuItem && sender is UserControlMenuItem senderItem)
        {
            menuItem.IsSelected = menuItem.Equals(senderItem) && !senderItem.IsSelected;
            e.Handled = true; //Tells to the visual tree that event was already handled
        }
    }
}


text:
Q: Connecting hover rules for two separate anchors? The fiddle below displays an image link and a text link for each corresponding page. Each image, when hovered over, shows the colored version by using css. The text links simply have a border on the bottom when hovered.
I need to make the image colored when the corresponding text link is hovered, and also the text link to have its border shown when the corresponding image is hovered. How can I link these together?
See this fiddle, or look at the CSS code below:
#chorus
{
    background: url('../images/work-icons/icon-chorus to size BW.jpg');
    height: 85px;
    left: 30px;
    position: fixed;
    top: 78px;
    width: 113px;
    display: block;
}

#chorus:hover
{
    background: url('../images/work-icons/chorus-icon to size.jpg');
    border-bottom: none;
}

#chorus-text-link {
    left: 180px;
    position: fixed;
    top: 111px;
}

A: By adding a parent element to your image and link, you could achieve a structure like this:

    Chorus 2014

And then simply write a hover rule for the newly created parent and its child:
span:hover #chorus
{
    background: url('http://georgewoolfe.com/new-website/images/images-3copy.jpeg');
    border-bottom: none;
}

--
To underline the link on image hover, add a rule which applies only to the 2nd child of the span (text link):
span:hover a:nth-of-type(2) {
    border-bottom: 1px solid;
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: d3plus with Svelte: Uncaught TypeError: Cannot read property 'document' of undefined The Goal
I'm trying to implement this…

<!doctype html>

<html>
  <head>
    <meta charset="utf-8">
    <script src="https://d3plus.org/js/d3.js"></script>
    <script src="https://d3plus.org/js/d3plus.js"></script>
    <style>
      html {
        height: 100%;
      }

      body {
        margin: 0;
        height: 100%;
        background: linear-gradient(to top, #ddfdff, #6DD5FA, #2980B9);
      }

      svg {
        font-family: "Helvetica", "Arial", sans-serif;
        height: 100%;
        width: 100%;
        background: transparent;
      }

      .type {
        fill: #888;
        text-anchor: middle;
      }

      .shape {
        fill: red;
        stroke: black;
      }

      .invis {
        fill: transparent;
        stroke: transparent;
      }

      .title {
        fill: #ffebeb;
      }
    </style>
  </head>
  <body>
    <svg>
      <path id="Union" fill-rule="evenodd" clip-rule="evenodd" d="M584.924 352C566.379 596.253 442.233 717.371 312.762 721.625C314.849 722.912 315.945 724.404 315.439 725.873C314.85 727.582 313.363 728.819 311.349 729.634C313.835 731.14 315.947 732.306 317.185 732.541C324.33 733.901 329.242 736.83 328.72 740.738C326.639 756.297 285.436 758.859 279.246 744.483C277.43 740.263 282.545 736.546 290.185 734.22C291.876 733.706 291.976 731.183 291.936 728.476C288.699 727.054 286.268 725.043 285.663 722.579C285.504 721.933 285.607 721.353 285.928 720.839C157.97 709.163 31.5609 584.211 2.92421 352C-23.4665 138 133.209 0 293.924 0C454.639 0 600.034 153 584.924 352Z" fill="#C80E0E"/>

      <!-- 'd3plus' uses this circle as a text mask. -->
      <!-- Honestly, I don't fully understand how this works; -->
      <!-- Changing the circle's radius yields strange effects. -->
      <circle class="shape invis" r="15px" cx="0px" cy="0px"></circle>

      <text id="circleResize" class="wrap title" x="0px" y="110px" font-size="2rem">
        Why is it so difficult to center text in a shape like this while specifying curved outer bounds?
      </text>

    </svg>

    <script>
      // Wrap text in a circle, and size the text to fit.
      d3plus.textwrap()
        .container(d3.select("#circleResize"))
        .width(620)
        .height(1000)
        .resize(true)
        .draw();
    </script>
  </body>
</html>

…in Svelte.
The Problem
I can't seem to get d3plus to work with Svelte.
First I tried using <svelte:head> to house the <script src="https://d3plus.org… lines. I don't recall what happened when I tried that, but my hunch is that <svelte:head> only works with CSS, or other files whose content doesn't need to be parsed by Svelte. ¯_(ツ)_/¯?
At any rate, my next approach is represented (in part) below. I first saved d3.js and d3plus.js in src, then, as shown, I import the symbols directly.
In this second scenario, though, I keep getting this console error:
Uncaught TypeError: Cannot read property 'document' of undefined
    at d3.js:8
    at d3.js:9553
    at createCommonjsModule (index.mjs:1328)
    at index.mjs:1328
    at main.js:8

Presumably what's happening here is that the d3 source is getting run before the app's had a chance to load, and so document remains undefined? Regardless, I'm stuck!
Here's the (broken) code, fwiw:
<script>
  import d3 from './d3.js';
  import d3plus from './d3plus.js'

  d3plus.textwrap()
    .container(d3.select("#circleResize"))
    .resize(true)
    .draw();

</script>

<style>
  svg {
    font-family: "Helvetica", "Arial", sans-serif;
    height: 100%;
    width: 100%;
    background: transparent;
  }

  .type {
    fill: #888;
    text-anchor: middle;
  }

  .shape {
    fill: red;
    stroke: black;
  }

  .invis {
    /* Fill will be transparent in final outlay */
    fill: #10ef3394;
    stroke: transparent;
    stroke-width: .1rem;
  }

  .title {
    fill: #ffebeb;
  }
</style>

<svg>
  <path id="Union" fill-rule="evenodd" clip-rule="evenodd" d="M584.924 352C566.379 596.253 442.233 717.371 312.762 721.625C314.849 722.912 315.945 724.404 315.439 725.873C314.85 727.582 313.363 728.819 311.349 729.634C313.835 731.14 315.947 732.306 317.185 732.541C324.33 733.901 329.242 736.83 328.72 740.738C326.639 756.297 285.436 758.859 279.246 744.483C277.43 740.263 282.545 736.546 290.185 734.22C291.876 733.706 291.976 731.183 291.936 728.476C288.699 727.054 286.268 725.043 285.663 722.579C285.504 721.933 285.607 721.353 285.928 720.839C157.97 709.163 31.5609 584.211 2.92421 352C-23.4665 138 133.209 0 293.924 0C454.639 0 600.034 153 584.924 352Z" fill="#C80E0E"/>

  <circle class="shape invis" r="15px" cx="0px" cy="0px"></circle>

  <text id="circleResize" class="wrap title" x="0px" y="110px" font-size="2rem">
    Why is it so difficult to center text in a shape like this while specifying curved outer bounds?
  </text>

</svg>

How can I get this working in Svelte???

A: Working code
(With  to @CD.. here on S.O., and @primos on Discord for their help!)

 The range slider and bound variables are just a bit of reactive fun to test moving the text and balloon together.

/public/index.html
<!doctype html>
<html>
<head>
  <meta charset='utf8'>
  <meta name='viewport' content='width=device-width'>

  <title>Svelte app</title>

  <link rel='icon' type='image/png' href='/favicon.png'>
  <link rel='stylesheet' href='/global.css'>
  <link rel='stylesheet' href='/bundle.css'>

  <script src="https://d3plus.org/js/d3.js"></script>     <!--  -->
  <script src="https://d3plus.org/js/d3plus.js"></script> <!--  -->

  <script defer src='/bundle.js'></script>
</head>

<body>
</body>
</html>

App.svelte
<script>
  import { onMount } from 'svelte';               //

  onMount(() => {                                 //
    d3plus.textwrap()
      .container(d3.select("#circleResize"))
      .resize(true)
      .draw();
  });

  export let name;
  let i = 0;
  const minX = 293;
  let windowWidth;
  let skyHeight;
</script>

<svelte:window bind:innerWidth={windowWidth}/>

<style>
  svg {
    font-family: "Helvetica", "Arial", sans-serif;
    height: 90%;
    width: 100%;
    background: transparent;
  }

  .type {
    fill: #888;
    text-anchor: middle;
  }

  .shape {
    fill: red;
    stroke: black;
  }

  .invis {
    fill: transparent;
    stroke: transparent;
    stroke-width: .1rem;
  }

  .title {
    fill: #ffebeb;
  }
</style>

<label>
    <input type="range" bind:value={i} max={windowWidth - (2 * minX)}>
</label>

<div>{i}</div>

<svg>
  <path id="Union" fill-rule="evenodd" clip-rule="evenodd" transform="translate({i},0)" d="M584.924 352C566.379 596.253 442.233 717.371 312.762 721.625C314.849 722.912 315.945 724.404 315.439 725.873C314.85 727.582 313.363 728.819 311.349 729.634C313.835 731.14 315.947 732.306 317.185 732.541C324.33 733.901 329.242 736.83 328.72 740.738C326.639 756.297 285.436 758.859 279.246 744.483C277.43 740.263 282.545 736.546 290.185 734.22C291.876 733.706 291.976 731.183 291.936 728.476C288.699 727.054 286.268 725.043 285.663 722.579C285.504 721.933 285.607 721.353 285.928 720.839C157.97 709.163 31.5609 584.211 2.92421 352C-23.4665 138 133.209 0 293.924 0C454.639 0 600.034 153 584.924 352Z" fill="#C80E0E"/>

  <circle class="shape invis" r="280px" cx="{minX}" cy="300px"></circle>

  <text id="circleResize" class="wrap title" x="0px" y="110px" font-size="2rem" transform="translate({i},0)">
    Why is it so difficult to center text in a shape like this while specifying curved outer bounds?
  </text>

</svg>


text:
Q: Cannot add item to inventory (Bukkit/Spigot) I have some problems with my kits plugin for Bukkit and Spigot.
When I use the command /kits only an empty inventory opens.
Here's my code:
        for (int i = 0; i<main.cfg.getConfigurationSection("kits").getKeys(false).size();i++) {
            String s = (String) main.cfg.getConfigurationSection("kits").getKeys(false).toArray()[i];
            ItemStack is = new ItemStack(Material.valueOf(main.cfg.getString("kits." + s + ".mat")));
            ItemMeta im = is.getItemMeta();
            im.setDisplayName(s);
            is.setItemMeta(im);
            cont.add(is);
        }

the item stack is valid, but when I do kits.add (is) the item doesn't get added to the inventory.

*

*I have created the inventory kits with Bukkit.createInventory(null,size,"Kits"); and it shows up correctly

*After I have added all items, I open up the inventory with ((Player)sender).openInventory(kits);
You see cont.add(is) in the code, because I've tried to make a list of ItemStack (cont) and then in another for loop add all items to the inventory, but that shouldn't make a difference.

A: I found a solution for this problem. It was because I calculated the size of the inventory depending on how many kits there are. Today I wondered why I had 3 lines in the inventory and just 1 kit. that should only make 1 line. then I set it to 54 items so 6 lines as inventory size and it worked! Solution: make sure that you're creating at least 3 lines in your inventory, then it should work.

A: The only think of is maybe "main.cfg.getConfigurationSection("kits").getKeys(false).size()" is returning 0, causing the code in the for loop to never execute. Maybe you could add "sender.sendMessage("The for loop is running");" inside the for loop just to verify that it is in fact running.

A: It isn't add, it's addItem :)
cont.addItem(is);


text:
Q: Read and store multiple NSArray can I store data for multiple NSMutableArrays in Objective C to a single plist file? If so how do I write this to the file and how do I read it? or would i need a separate file for each array I want to store?
I typically do this to read, but with only one array:
NSArray *array = [[NSArray alloc] initWithContentsOfFile:filePath];

A: You could either save an array or a dictionary that contains the two arrays that you want to save.
NSArray *bothArrays = [[NSArray alloc] initWithContentsOfFile:filePath];
NSAssert(!bothArrays || bothArrays.count == 2, @"Expecting the array to be nil or to contain 2 items");
NSArray *first  = [bothArrays firstObject];
NSArray *second = [bothArrays lastObject];


text:
Q: Assuming that A and B are non-empty, if there is an injective function F : A -> B then there must exist a surjective function g : B -> A Either give a counter-example, or a proof.
A question in my proofs review.
From what I understand we must assume each element of A is carried to a unique element of B (i.e. every value of A is associated with a unique value of B when punched into F).
We now must prove (or disprove by use of counter-example) that there always exists a surjective function G that carries B -> A.  Surjectivity (from what I understand) means that EVERY element of A (in this case) has AT LEAST one associated B value in terms of the function G.
Will anybody be kind enough to correct any misunderstandings that I may have?
Also, I can't really figure out where to begin with this question, help needed!

A: I think the key on this one is to to realize that, since $F:A \to B$ is injective, we can define an inverse function $F^{-1}$ on $F(A)$, the image of $A$ in $B$.  For every $z \in F(A)$ is the image of some $y \in A$, that is, $z = F(y)$ for $y \in A$, and since $F$ is injective there is exactly one such $y$.  We set $y = F^{-1}(z)$, on $F(A)$, for $z  \in F(A)$; we note that $F^{-1}:F(A) \to A$ is a surjection, since each $y \in A$ satisfies $y = F^{-1}(F(y))$; we define a function $V:B \to A$ by setting $V(z) = F^{-1}(z)$ for $z \in F(A)$, and $V(z) =a$ for any $a \in A$ when $z \in B - F(A)$; since $F^{-1}:F(A) \to A$ is surjective, $V: B \to A$ is a surjection from $B$ to $A$.  QED.
Hope this helps.  Cheerio,
and as always,
*Fiat Lux!!! *

A: Denoting the injection as $F$: then its inverse, $G$, is a surjection from $F(A) \rightarrow A$.
(Where $F(A) := \{F(a): a \in A\}$ is the image of $A$ after applying $F$ to it.)
Since $A$ is nonempty, we can pick $a \in A$.
Extend the domain of $G$ from $F(A)$ to $B$ (if necessary) by mapping all elements in $B-F(A)$ to $a$.
This (possibly extended) function, $g$, is a surjection $B \rightarrow A$. QED.


text:
Q: Locally shift everything by 0.5 to the left in PSTricks Is it possible in PSTricks to locally shift "everything" by 0.5 to the left? For example, in the MWE below I would like to shift the "y" to the left, so that its new coordinates are (1.5,2). Of course, in this simple example, I could just alter the coordinates directly but if you have whole bunch of objects which you want to translate this is cumbersome.
\psset{xunit=1cm,yunit=1cm}
\begin{pspicture}(0,0)(5,5)

\rput(1,1){x}
\begin{<shift to left by 0.5>}
\rput(2,2){y}
\end{<shift to left by 0.5>}
\rput(3,3){z}

\end{pspicture}

A: Insert the entire content that you want to shift to the left inside \rput(-0.5,0){...}.
Perhaps, in a more general setting, use
\rput(<h-shift>,<v-shift>){%
  % <stuff>
}

to move the content horizontally by <h-shift> and vertically by <v-shift>.


text:
Q: Update existing certain documents in MongoDB collection without remove I am new in mongoDB so I need some help with this.
I have a collection for back up. It contains documents with following data:
{
    "_id" : ObjectId("59f18942e7798954dc373b67"),
    "category" : "building",
},
{
    "_id" : ObjectId("59f18942e7798954dc373b68"),
    "category" : "building",
},
{
    "_id" : ObjectId("59f18942e7798954dc373b69"),
    "category" : "tree",
    "type" : 18,
},
{
    "_id" : ObjectId("59f18942e7798954dc373b70"),
    "category" : "book",
    "type" : 18,
}

Then, for example, some of objects were changed and became like that:
{
    "_id" : ObjectId("59f18942e7798954dc373b67"),
    "category" : "building",
    "size" : 100
},
{
    "_id" : ObjectId("59f18942e7798954dc373b68"),
    "category" : "building",
    "size" : 400
},
{
    "_id" : ObjectId("59f18942e7798954dc373b70"),
    "category" : "book",
    "type" : 18,
    "title" : "New"
}

So I need to update them in my DB. Just replace, as I understood. I've read the docs about using 'upsert' and 'multi'. But I can't implement it.
How to do that?

A: Basic syntax for updating document in mongo is
db.collection.update(query,update,options);

For your question,
1.
 db.collection.update({_id: ObjectId("59f18942e7798954dc373b67")},{$set:{size:100}});
2.
 db.collection.update({_id: ObjectId("59f18942e7798954dc373b68")},{$set:{size:400}});
3.db.collection.update({_id: ObjectId("59f18942e7798954dc373b70")},{$set:{title:"New"}});
EDIT:
You can try out this, If you want to perform Write operation in one command:
> db.characters.bulkWrite(
>       [
>          { updateOne :
>             {
>                "filter" : { _id : ObjectId("59f18942e7798954dc373b67") },
>                "update" : { $set : { size : 100 } }
>             }
>          },
>          { updateOne :
>             {
>                "filter" : { _id : ObjectId("59f18942e7798954dc373b68") },
>                "update" : { $set : { size : 400 } }
>             }
>          },
>          { updateOne :
>             {
>                "filter" : { _id : ObjectId("59f18942e7798954dc373b68") },
>                "update" : { $set: { title: "New"} }
>             }
>          },
>       ]
>);


text:
Q: Extract Bulleted Text From Powerpoint I am trying to extract bulleted text from powerpoint slides. But I couldn't find any helpful function which can provide information about if current line is in bullet list or not. I tried identifying it using indent level, but I dont find it useful either.
For example:
If slide contains text like:
Abcdefg...
. B
. C
  . D
     .E

In this, there are 5 paragraphs, if get indent level of each paragraph it will come as :
Paragraph   IndentLevel
Abcdefg...   1
B            1
C            1
D            2
E            3

Here, first 3 paragraph have same indent level, but only B and C are in bulleted list, so my program should B, c, D, E.
Here, i dont have any way to figure out if this para starts with bullet or not.
Can you please help?
Thanks,
Kailas
Edit:
Code that I am using for retrieving text
public void analyzeText( PowerPoint.Shape shape )
{
    if( shape.HasTextFrame == Office.MsoTriState.msoTrue && shape.TextFrame.HasText == Office.MsoTriState.msoTrue )
    {
        PowerPoint.TextRange textRange = shape.TextFrame.TextRange;
        string text = textRange.Text;
        MessageBox.Show(text);
        for( int i=1; i<=textRange.Paragraphs().Count; i++)
        {
            MessageBox.Show("Paragram COunt : " + textRange.Paragraphs(i).Text + " Indent " + textRange.Paragraphs(i).IndentLevel);
        }
    }
}

A: You can use this method to establish if the paragraph is bulleted or not:
blnBullet = oShp.TextFrame.TextRange.Paragraphs(x).ParagraphFormat.Bullet

A: Thanks JamieG for helping out. Your answer gave me hint. Here is how I was able to solve this problem:
 PowerPoint.BulletFormat bulletFormat = textRange.Paragraphs(x).ParagraphFormat.Bullet;

    if( bulletFormat.Type == PowerPoint.PpBulletType.ppBulletNone )
                           // Not Bulleted
    else
                        // Bulleted


text:
Q: Fast and efficient way of joining a csv file to a shapefile I'm trying to join a csv file with millions of rows to a shapefile using JoinField but it's taking forever. And when the join is completed, I get 0 in all rows of the joined field. I also tried using dictionaries with UpdateCursor but the join didn't happen. Is there a better way to do this?
The JoinField code I used is:
arcpy.MakeFeatureLayer_management("mukey.shp", "mapunit")
arcpy.CopyRows_management(kvalues_path, "kvalues")   #to give the table OIDs
arcpy.JoinField_management("mapunit", "mukey", "kvalues", "mukey", "ksat_mday")

"mukey" is the common field between the csv file and the shapefile, while "ksat_mday" is the field that I want to join to the shapefile.
The dictionary with UpdateCursor code I used was for replacing a Join connecting two Feature Classes. May be the code didn't work because I was joining a csv file to a shapefile and not two Feature Classes. The code was taken from https://community.esri.com/t5/python-blog/turbo-charging-data-manipulation-with-python/ba-p/884079.

A: Usually, such concatenating and joins are faster if you use Geopandas instead of arcpy, but since you stated that you are working with millions of rows, which implies heavy data frames you are working with here is my suggestion:

*

*Geopandas and Pandas are relatively slow libraries due to implementing one core of CPU at a time, but the best new alternative is Pollar which exactly works like Pandas data frame; however, by parallelizing the workflow over all CPU cores, you can see the results in seconds rather than days. All you need to do is:

Install Polars in an environment:
$ pip install polars

or
$ conda install polars

then using this syntax convert your tables to an excel data sheet in the ongoing environment you are working with arcpy
arcpy.conversion.TableToExcel(Input_Table, Output_Excel_File, {Use_field_alias_as_column_header}, {Use_domain_and_subtype_description})

then you can easily read the tables you have and join them by polars which exactly works like Pandas and Geopandas.
in the end, make sure to regenerate your shapefiles.
arcpy.conversion.ExcelToTable(Input_Excel_File, Output_Table, {Sheet}, {field_names_row}, {cell_range})

Please let me know if you encountered any issues regarding this solution


text:
Q: Oracle Query for Update And Return Updated Rows I'm developing an Oracle table for the purposes of distributed messages. I have a table as follows:
TABLE messages
messageid    VARCHAR(15)
pulltime     DATETIME
attempt      NUMBER(100)

When a message consumer queries for a message, I want to update the pulltime by attempt * hours and increment the attempt number:
UPDATE messages
    SET pulltime = SYSDATE + attempt / 24, attempt = attempt + 1
    WHERE pulltime < SYSDATE;

At the same time, whatever is updated, I also want to query it and return the rows to my application, to process the messages. Since there are multiple consumers, I want to be able to update the messages ready to be processed, and update their pulltime to lock other consumers from consuming the same message until the next pulltime in one operation (if the message is successfully consumed, we will remove the entry from the table with a separate command).
EDIT: The consuming application will be a Java application and I want all the columns returned (messageid, pulltime, and attempt).

A: You could do it in PL/SQL using:

*

*FOR UPDATE clause - will lock the rows from other sessions to update

*RETURNING INTO clause - will return the rows being updated

For example, using standard EMP table in SCOTT schema:
SQL> set serveroutput on
SQL> DECLARE
  2    v_empno NUMBER;
  3  BEGIN
  4    FOR i IN
  5    (SELECT * FROM emp WHERE deptno = 10 FOR UPDATE
  6    )
  7    LOOP
  8      UPDATE emp SET deptno = 99 WHERE empno = i.empno RETURNING empno INTO v_empno;
  9      DBMS_OUTPUT.PUT_LINE('updated empno is = '||v_empno);
 10    END LOOP;
 11  END;
 12  /
updated empno is = 7782
updated empno is = 7839
updated empno is = 7934

PL/SQL procedure successfully completed.


text:
Q: Función doPost para guardar valores desde URL Necesito poder obtener un valor en una URL de una implementación de google app script y se guarde en un sheets. He utilizado la función doGet y doPost pero no consigo guardar dicho texto.
mi código es
function doGet(){

 var HTMLString = ""
 + "
Hello World!
"
 + "
Welcome to the Web App";

doPost()

 HTMLOutput = HtmlService.createHtmlOutput(HTMLString);
 return HTMLOutput
}

function doPost(e){
  var o = e; // la segunda columna es el nombre de la persona

  var libro = SpreadsheetApp.getActiveSpreadsheet();
 var hoja =libro.getSheetByName("Hoja 1");
 hoja.appendRow([ "Prueba 1 columna", o, "columna3" , "columna4" ]);

}

y  la url
https://script.google.com/macros/s/AKfycbwUG76QtXcbUr568nl6QXYB96PekgQ169N8ByrwiKSJ6DvLdfRU_slWLDjtUB5aZvf78w/exec
Lo que necesito es poder guardar los datos desde la url  por ejemplo utilizando
?action=get&name=NOMBREPERSONA
quedando así:
https://script.google.com/macros/s/AKfycbwUG76QtXcbUr568nl6QXYB96PekgQ169N8ByrwiKSJ6DvLdfRU_slWLDjtUB5aZvf78w/exec?action=get&name=NOMBREPERSONA

A: En la función doGet te faltó incluir el parámetro para recibir el objeto evento. A continuación la versión modificada
function doGet(e){

 var HTMLString = ""
 + "
Hello World!
"
 + "
Welcome to the Web App";

 doPost(e)

 HTMLOutput = HtmlService.createHtmlOutput(HTMLString);
 return HTMLOutput
}

En la función doPost, si bien esta incluye el parámetro para recibir el objeto evento, el Array que pasas a appendRow no debería tener el objeto evento ya que este sólo debería tener datos de tipo number, string, boolean y/o Date. Considerando esto podrías reemplazar
hoja.appendRow([ "Prueba 1 columna", o, "columna3" , "columna4" ]);

por
hoja.appendRow([ "Prueba 1 columna", JSON.stringify(o), "columna3" , "columna4" ]);

o bien, para pasar sólo el valor de name, por
hoja.appendRow([ "Prueba 1 columna", o.parameter.name, "columna3" , "columna4" ]);


text:
Q: Accessing the label text through JavaScript Looking access the label text.
I can find the value of the input tag via:

Try this <input type="text" id="t" />
<input type="button" onclick="alert(document.getElementById('t').value)" value="Click me!"/>

But what is the method to access the label's text "Try this" ?
using .innerHTML yields nothing.  .parentNode.value yielded undefined.

A:

Try this <input type="text" id="t" />
<input type="button" onclick="alert(document.getElementById('t').parentNode.innerText)" value="Click me!"/>

A: You can search the element by their tag name using document.getElementsTagName() method. This method returns all elements with the tag

Try this <input type="text" id="t" />
<input type="button" onclick="alert(document.getElementsByTagName('label')[0].innerText)" value="Click me!"/>

A: Give your label an id, let's say lbl:
Try this <input type="text" id="t" />

Now in javascript, you can access the text using:
document.getElementById('lbl').innerText

you can also trim the result to get rid of spaces.


text:
Q: Is there any criteria for Google Play Store to update app installs count? My App crossed 100000 downloads 3 days back but on Play Store still it says 50000 downloads. How long does Google Play Store takes to display app install count ? Is there any criteria for that?

A: There is no such criteria
It takes some time to update the statistics in play store , i also faced some problem for my app.
i launched this app yesterday still there is no download updated in Google play console but it has been downloaded by 50+ people.


text:
Q: Wix XmlFile is keeping SqlDatabase from creating databases I've got a Wix project made up of several fragments.  One of those fragments has the database components, another has a component that manipulates xml files.
When I include the XmlFile element to manipulate a file, the databases defined by the SqlDatabase do not get created.  If I comment out the XmlFile, then the databases do get created.
Here are the two wix files with fragments that are being used:
Database:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">
  <Fragment>
    <DirectoryRef Id="TARGETDIR">
      <Component Id="Database1Creation" Guid="GUID_HERE">
        <sql:SqlDatabase Id="Database1"
          Server="[DATABASE_SERVER]" Database="[DATABASE_NAME]"
          CreateOnInstall="yes" ConfirmOverwrite="no"
          DropOnUninstall="yes">
        </sql:SqlDatabase>
      </Component>
    </DirectoryRef>
 </Fragment>
</Wix>

Xml Manipulation:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Fragment>

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLDIR" Name="MyDirectory">
          <Component Id="ServiceExecutables" Guid="GUID_HERE">
            <File Id="File1" Name="File1.xml" Source="Source/File1.xml" />
            <util:XmlFile Id="UpdateFile1" File="[INSTALLDIR]File1.xml" Action="setValue" ElementPath="//SomeContainer/SomeElement" Value="[SOME_VALUE]" />
          </Component>
        </Directory>
      </Directory>
    </Directory>

  </Fragment>
</Wix>

There are other things that are also installed, but they don't appear to have any influence on the issue (I've removed everything else and tested the install).
When looking at the install logs when using XmlFile and when not, they are almost exact copies of each other, except that the SqlDatabase calls would be completely missing, and the XmlFile calls would be in their place.
Is there a known bug here?  Or am I doing something I shouldn't be?  This isn't a killer for our app, since I can move the things I'm putting in the xml file into the registry, but I'd rather not do that.
I am using Wix 3.5.

A: Good news, build 1616 fixes this.  Update Wix ASAP.


text:
Q: C# reading values from datatable filled with sql select I am coding win form app, which checks on startup right of the currently logged user. I had these right saved in MS SQL server in the table. When importing data to Datatable, there is no problem. But when I want to read value, there is message "cannot find column xy".
SqlDataAdapter sdaRights = new SqlDataAdapter("SELECT * FROM rights WHERE [user]='" + System.Security.Principal.WindowsIdentity.GetCurrent().Name + "'", conn);

DataTable dtRights = new DataTable(); //this is creating a virtual table
sdaRights.Fill(dtRights);
Object cellValue = dt.Rows[0][1];
int value = Convert.ToInt32(cellValue);
MessageBox.Show(value.ToString());

I would like, that program would save the value from SQL to int.

A: You are assuming that you have rows being returned, would be my first guess. You should loop through your DataTable instead of simply trying to access element 0 in it.
DataTable dtRights = new DataTable();
sdaRights.Fill(dtRights);
foreach(DataRow row in dtRights.Rows) {
    Object cellValue = row[1];
    int value = Convert.ToInt32(cellValue);
    MessageBox.Show(value.ToString());
}

A:         using (SqlConnection con = new SqlConnection("your connection string"))
        {
            using (SqlCommand cmd = new SqlCommand("SELECT [column_you_want] FROM [rights] WHERE [user] = @user"))
            {
                cmd.Parameters.AddWithValue("@user", System.Security.Principal.WindowsIdentity.GetCurrent().Name);
                con.Open();

                int right = Convert.ToInt32(cmd.ExecuteScalar());
            }
        }


text:
Q: JXbrowser initialization fails when run in empty folder: java.nio.file.NoSuchFileException:...jxbrowser-browser.log.lck OS: macOS Sierra 10.12.3 (16D32)
jxbrowser version: 6.14.2
I set jxbrowser cache and logs directory to the single folder near the executed jar file. When it run from scratch an exception rises: java.nio.file.NoSuchFileException:...jxbrowser-browser.log.lck
If run the previous version (6.3) and after that the current one, then everything works correct.
[DEBUG] 2017-07-30 15:55:00.411 [main] ScalarSelectOperation - select from result set
Exception in Application init method
java.lang.RuntimeException: Exception in Application init method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:912)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.nio.file.NoSuchFileException: /%PATH_TO_JAR_FOLDER%/.cache/jxbrowser-browser.log.lck
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:177)
    at java.nio.channels.FileChannel.open(FileChannel.java:287)
    at java.nio.channels.FileChannel.open(FileChannel.java:335)
    at java.util.logging.FileHandler.openFiles(FileHandler.java:459)
    at java.util.logging.FileHandler.<init>(FileHandler.java:292)
    at ru.mybetter.ui.desktop.BetterClient.redirectLogMessagesToFile(BetterClient.java:174)
    at ru.mybetter.ui.desktop.BetterClient.init(BetterClient.java:106)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841)
    ... 2 more

2017-07-30 15:55:00,610 pool-2-thread-1 DEBUG Stopping LoggerContext[name=2a139a55, org.apache.logging.log4j.core.LoggerContext@f5a3839]
2017-07-30 15:55:00,611 pool-2-thread-1 DEBUG Stopping LoggerContext[name=2a139a55, org.apache.logging.log4j.core.LoggerContext@f5a3839]...

A: According to the exception stack trace the error comes from:
ru.mybetter.ui.desktop.BetterClient.redirectLogMessagesToFile(BetterClient.java:174)

I suppose you create FileHandler instance with an invalid path to the file that doesn't exist. Or, according to Javadoc of the FileHandler(String pattern) the IOException can be thrown from its constructor when there are IO problems opening the files.
Please make sure that the path to the file you pass to the FileHandler constructor is accessible from your Java program and there are no read/write permission issues with it.


text:
Q: MVC2: Need to route Urls containing # symbol I am looking for a way to correctly route urls that contain the '#' symbol. For such urls i basically want to ignore the #.
For example I want Stores/Index/#/{storeName} to route to the Index action of the Store controller passing a single parameter  (storeName).
I have tried matching the literal '#' in the string but this is not working. (The action is called but the storeName parameter is not passed)
routes.MapRoute("RemoveHash", "Store/Index/#/{storeName}",
            new {controller = "Store", action = "Index", storeName = UrlParameter.Optional});

I have also tried having 2 parameters to the action (the first being the #), thinking that I could just ignore the # if it was passed (hacky i know)... but something goes wrong with the routing in this case and neither parameter is passed to the action.
I would like to avoid using a HttpHandler for this task, if I could handle this using the MVC routing system that would be ideal.
Any suggestions?

A: What you are trying to do is impossible. Everything that follows the # (hash) sign in the URL is completely ignored when the browser sends a request to the server, so your ASP.NET MVC application could never get this value. Only client side javascript could read this value (using window.location.hash) and could pass it to the server using AJAX request and a normal URL (for example: Store/Index/{storeName}).


text:
Q: How to embed HTML url pages in adobe flex? I have a desktop adobe flex application and would like to show the content of an URL. How could a HTML page be best embedded into a desktop flex app?
I know there is some old mx:HTML location="{url}" but this seems to have many rendering and javascript issues.
I don't want to open an external browser window.

A: You can try StageWebView with argument useNative=true. Here is a wrapper component for Flex.

A: You can use stagewebview for rendering html page in flex application. Use below code to open google page.
Note: 'http' or protocol of the url should be added in the url.
        private var _stageWebView:StageWebView;
        private var _stage : Stage;

        protected function addedToStageHandler(event:Event):void
        {
            _stage = this.stage;
        }

        private function onInitStageWebView():void
        {
            _stageWebView = new StageWebView(true); //true - for system engine, false - embedded webkit
        _stageWebView.stage = _stage1;
        _stageWebView.viewPort = new Rectangle(42, 50, this.width, this.height);
        _stageWebView.addEventListener(Event.COMPLETE, completeHandler);
        _stageWebView.addEventListener(ErrorEvent.ERROR, errorHandler);
        _stageWebView.addEventListener( LocationChangeEvent.LOCATION_CHANGING, onLocationChange_Handler );
        _stageWebView.loadURL("http://www.google.com");
        }

       protected function onLocationChange_Handler( event : LocationChangeEvent ):void
       {
           trace( "Location Changed to : " : event.location );
       }


text:
Q: concatenated columns as action link I am concatenating three columns of my model and displaying them as one as action link which calls a method of controller.I write some code which is giving errors that item does not exist in current context and The best overloaded method match for System.Web.Helpers.WebGrid.Column(string, string, System.Func<dynamic,object>, string, bool) has some invalid arguments.
View :
             @using (Html.BeginForm()) {
             @Html.ValidationSummary(true)
             var grid = new WebGrid(source: Model,
                         rowsPerPage: 3);

        <div id="grid">
        @grid.GetHtml(
            columns: grid.Columns(
                   grid.Column("street", format: Html.ActionLink(item.street+ ' ' + item.city+ ' ' + item.propertyType, "showDetails" , "SearchSpace", new{ spaceId = item.spaceId})
                )
                )

                )
    </div>
}

A: Try and see if it works:
 grid.Column(header: "YourColumnName", format: (item) =>new HtmlString(
                        Html.ActionLink("linkText", "actionName","controllerName", new { id = item.yourItemId },null).ToString()))


text:
Q: How to get a JSON value from a variable suppose I have {"data": {"243232": {"id": "testid","name": "test" } }}
so when I do
var  a = data.243232.id;
 alert(a); // it gives me testid.
but when I do like
    var c = 243232;
    var d = data.c.id;
    alert(d) //it gives as undefined.

so how to get correct value when i alert d in above case thanks.

A: Use data[c].id.
In JavaScript, .prop is syntactic sugar for ["prop"]. The bracket notation allows you to use values which would be invalid when using . (such as background-image) and variables.

A: Use the other notation var a = data['243232'].id
Remember all objects in JS are really just associative arrays.
Object keys just a variable in js and thus require proper naming
the variable naming rules are.

*

*The first character must be a letter
(either uppercase or lowercase) or an
underscore (_), or a dollar sign ($).

*Subsequent characters can be letters,
numbers, underscores, or dollar signs
in JavaScript Variables.

*The JavaScript Variable name can't be
a reserved word of JavaScript, see
details of JavaScript Reserved
Characters

JSON normally uses an eval() function to turn the string into a data-structure.  This allows for incorrect keys.  If you want to reference an improper key, you need to use the associative array method.
As for you addition
var c = 243232;
var d = data[c].id;
alert(d) //it gives as undefined.

Will work


text:
Q: Cannot communicate between fragment and activity I have a dialogFragment where there's an edit text. I would like to pass the text to the parent activity, when the positive button of the dialog is clicked, but it doesn't seem to call the method of the interface implemented in the activity.
Code:
DialogFragment
 @Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    String title = getArguments().getString("title");
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
    alertDialogBuilder.setTitle(title);
    alertDialogBuilder.setView(R.layout.fragment_newfile);
    alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            listener.onFileTyped(textNewFile.getText().toString());
            Log.w("Positive","Button"); //This log is showed

        }
    });
    alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    return alertDialogBuilder.create();
}

MainActivity
 @Override
public void onFileTyped(String fileName) {
    Log.w("New File", ""); //This log is not showed
    MainFragment frag = (MainFragment) getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT);
    File newFile = new File(frag.getCurrentDir().getAbsolutePath(), "fileName");

}

Listener assignment
 @Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    if (activity instanceof onFileTypedListener) {
        listener = (onFileTypedListener) activity;
    } else {
        throw new RuntimeException(activity.toString()
                + " must implement OnFragmentInteractionListener");
    }
}

@Override
public void onDetach() {
    super.onDetach();
    listener = null;
}

A: I tried your code and it works in my case. Displays both log messages when clicked on positive button. Compare my code with yours and see if there is anything different:
Activity:
public class DialogFragmentActivity extends AppCompatActivity implements MyDialogFragment.onFileTypedListener {

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

        MyDialogFragment.newInstance("title").show(getSupportFragmentManager(),"MyDialogFragment");
    }

    @Override
    public void onFileTyped(String txt) {
    Log.w("yay", "it works");
    }
}

Fragment:
public class MyDialogFragment extends DialogFragment {

    onFileTypedListener listener;

    public interface onFileTypedListener{
        public void onFileTyped(String txt);
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        String title = getArguments().getString("title");
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
        alertDialogBuilder.setTitle(title);
        alertDialogBuilder.setView(R.layout.fragment_newfile);
        alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                listener.onFileTyped("hello");
                Log.w("Positive","Button"); //This log is showed

            }
        });
        alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        return alertDialogBuilder.create();
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof onFileTypedListener) {
            listener = (onFileTypedListener) activity;
        } else {
            throw new RuntimeException(activity.toString()
                    + " must implement OnFragmentInteractionListener");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        listener = null;
    }

    public static MyDialogFragment newInstance(String title) {

        Bundle args = new Bundle();
        args.putString("title",title);
        MyDialogFragment fragment = new MyDialogFragment();
        fragment.setArguments(args);
        return fragment;
    }
}


text:
Q: Proper ways to Put XML into HBase I am trying to put into HBase (version 1.1.X) some XML files stored locally.
My goal is to store the content of those XMLs in my HBase Table as string using MapReduce (no reduce stage) without loading them to HDFS.
Here is my pseudo-code:
fetchXMLs(path);
XML2OneLineFile();
configureHBase(); // + establishing connection
Map(input, output); //input: one XML file in one line; output : is the Put() of HBase;
closeConnection();

Is this way of tackling the problem correct, or there are better ways to do it?
ps: I do not want to parse or extract data from my XML, just store them.
Thanks in advance

A: Instead of storing XML string to Hbase, you can store them as byte[]
and you can retrieve it back as an object( of serialized type) using deserialization.
You can do that in below way using Apache commons API.
For ex :
byte[] xmlInBytes = org.apache.commons.lang.SerializationUtils.serialize(Serializable obj)

for deserializing, you can do this
static Object deserialize(byte[] objectData)

if Object may be w3c document, object should be typecasted to w3c document.
I have already tested with many type of objects not only XML.
It should work in the same way. Hope this helps.

A: Hbase is not really made for large object storing. Depending on the size of your XML, HBase might not be the solution you are looking for.
At this moment, I am working on a database consisting of multiple file types including XML. What I thought was good was to store any files under 1MB to HBase, and the rest to Hadoop, maintaining meta data either in an SQL or in HBase.
It depends a lot of what you want to achieve with this data.


text:
Q: Comparing the values of two layers In QGIS 2.18
I have two shapefile polygon layers, the actual case is quite complicated so I'm going to simplify it for the question. One is a layer of large polygons, say counties or states, and the other is a layer of smaller polygons , like individual properties or postcode districts. The polygons in the larger layer have an attribute representing a target, say the desired number of trees on each property. The smaller polygons layer has the actual number of trees each property has. I'd simply like to carry out some process which will highlight those properties/districts which are not meeting the target in their respective counties/states.
There are about 40 such targets I need to compare, so options that involve complicated transformations will not really solve the problem for me. What I need is some sort of expression I can select by which compares the value in one layer to another (I can already do this with the dbvalue() function), but only compare it to the value for the polygon it is contained by.

A: As it requires multiple steps of operations to compare the layers in desktop GIS.
The best solution I recommend for this case, import the two layers into PostGIS database and run the below SQL:
select  a.CountyName, b.PropertyID, a.TargetTrees, b.NumofTrees
from Layer1 a, Layer2 b where
ST_Contains(a.geom, b.geom) = true and b.NumOfTrees > a.TargetTrees;

Excuse me for any typo and syntax errors.


text:
Q: Where is ADF file on Tango Device? I have a Tango tablet device. So i made a ADF file using Tango Explorer.
I want to export the ADF file to PC from device.
But i cannot find the ADF file.
Please let me know where is the ADF file.
Thanks.

A: You'll first need to root your device in order to do this. The devices come in a user build and so you'll need to migrate to a user debug build. After you root your device, enter the following commands in terminal to pull your ADFs onto your PC:
adb root

adb shell

cd /data/data/com.projecttango.tango/files/Tango/ADFs

adb pull /devicedirectory/ ~/localdirectory

A: If you do not want to root your Tango, the Tango ADF Tool is a good alternative and allows you to export and then share your ADF files with other devices.

A: They have been moving the location over last two years. As of recently I found the ADF's with
adb shell ls /sdcard/Maps


text:
Q: How to NOT cascade delete in a recursive relation? I have an entity that has a ManyToMany relationship with itself:
@Entity
public class User {

    @Id
    private Long id;

    @ManyToMany
    private List<User> friends;
}

How can I delete a user without deleting all of his friends? I cannot use cascading deletes obviously. If I try to delete the user without cascading I get a this error: "Cannot delete or update a parent row: a foreign key constraint fails"

A: Actually i don't think when using cascading hibernate tries to delete the friends, it should normally just delete the link between 2 users that is stored in another table.
This is why you have a constraint violation if you do not cascade because the link (U1,U2), which have foreign key constreints on both users, still exist while you try to delete one of the 2 users.

A: Normally with ManyToMany we will map data in different tables, and the delete won't create much of a problem. I feel your case is different an you are having a self relationship. I think you need to use some other ways to perform this action.
How can I delete a user without deleting all of his friends? The below option is one of them.
Considering your special mapping, List<User> in User, you should be only updating the mapping table references, and not deleting anything from the User table. Because they may have some other User as friends and that can create problems.

A: In order to delete a user you have to remove this user from the friends lists of all other users, because in the database these references are foreign keys. This removal cannot be done automatically, i.e. with an annotation.


text:
Q: creating a username with no spaces with PHP function ..but somehow spaces are being added? I have a PHP script that generates a username based on when someone logs in via Facebook.
I am calling it like this:
$username = create_username($facebook_data['name']);

And the function is:
function create_username($username)
{
global $db;

$valid = false;
$counter = 0;
$new_username = str_replace(' ', '', $username);

while (!$valid)
{
    $counter++;
    $is_username = $db->count_rows('users', "WHERE username='" . $new_username . "'");

    if ($is_username)
    {
        $new_username = $username . $counter;
    }
    else
    {
        $valid = true;
    }
}

$new_username = strtolower($new_username);
return $new_username;

}
The problem is, if I have a user that is called "johnsmith" and someone with the name of "john smith" registers, it generates a username that is "john smith1" instead of "johnsmith1". What am I doing wrong?
I even did a
var_dump($facebook_data['name'])

and it is returned as "John Smith", with no extra spaces or anything.

A: Your are using the $username variable in your loop so you will get a username with spaces if the original username already exists.
Below I've created a $clean_username variable that can be appended to so you get username6 instead of username123456 for example:
function create_username($username)
{
   global $db;

   $valid = false;
   $counter = 0;
   $clean_username = $new_username = str_replace(' ', '', $username);

   while (!$valid)
   {
       $counter++;
       $is_username = $db->count_rows('users', "WHERE username='" . $new_username . "'");

       if ($is_username)
       {
           $new_username = $clean_username . $counter;
       }
       else
       {
           $valid = true;
       }
   }

   $new_username = strtolower($new_username);
   return $new_username;
}

A: if ($is_username)
{
    $new_username = $username . $counter;
}

correct is
if ($is_username)
{
    $new_username = $new_username . $counter;
}


text:
Q: How to get the value of recursive product using negative input? because i found it hard to get
take a look:
def mult(a, b):
    if b == 0:
        return 0
    rest = mult(a, b - 1)
    value = a + rest
    return value

prod = int(input('Enter number: '))

print('The product of', prod, 'x', prod, 'is', mult(prod,prod))

A: Just start with
def mult(a, b):
    if b<0: return -mult(a, -b)

and continue with the code you have now (assuming the latter's indented properly -- right now it's something of a mess but I'll assume that's merely a formatting issue and the code will work if properly edited:-).


text:
Q: How to disable or cancel all downloads I'm currently scraping a public webpage in the event that it goes down, and this site has some files where opening them in Chromium will usually download the file to your downloads folder automatically. For example, accessing https://www.7-zip.org/a/7z2201-x64.exe downloads a file instead of showing you the binary.
My code is really complicated, but what the main part of the code is, is this:
const page = await browser.newPage();
page.on("response", async response => {
   // saves the file to a place I want it, but doesn't cancel the chrome-based download.
   buffer = Buffer.from(new Uint8Array(await page.evaluate(function(x:string) {
            return fetch(x).then(r=>r.arrayBuffer())
            }, response.url())));
   fs.writeFileSync('path', buffer);
   return void 0;
});
await page.goto('https://www.7-zip.org/a/7z2201-x64.exe', { waitUntil: "load", timeout: 120000 });

I can't just assume the mime type either, the page could go to any URL from an html file to a zip file, so is it possible to disable downloads or rewire it to /dev/null? I've looked into response intercepting and it doesn't seem to be a thing based on this.

A: After reading a bit about /dev/null and seeing this answer, I figured out that I can do this:
const page = await browser.newPage();
await (await page.target().createCDPSession()).send("Page.setDownloadBehavior", {
   behavior: "deny",
   downloadPath: "/dev/null"
});

Setting the download path to /dev/null is redundant, but if you don't want to fully deny the download behavior for a tab but also don't want it going to your downloads folder, /dev/null will essentially delete whatever it receives on the spot.
I set the download behavior before navigating to a page, and this also focusing on behavior related to Chromium-based browsers, not just mime types.


text:
Q: Samsung S4 Video record using native camera issue I am working on an application where user can capture a video using the phone's default camera. For that I have used the following intent
startActivityForResult(new Intent(MediaStore.ACTION_VIDEO_CAPTURE).putExtra(MediaStore.EXTRA_SIZE_LIMIT, maxLimit), Constants.INTENT_ID_RECORD_VIDEO);

It works fine in Samsung galaxy nexus, Lg nexus 4, Lenovo 260 etc. Upon launching the intent, in the above devices the camera opens in video mode and user can start recording the video directly, but in Samsung S4 device the camera opens in a mode where user has to again select video mode and then start recording.
Is there a way that it can be avoided.
Can any of you please provide any work around?
Please point me to any valid official documentation if this is an issue that can not be resolved.
Thanks in advance.


text:
Q: XSLT: Взять из набора узлов каждые два Есть входной XML вида:
<items>
  <item id="1">111</item>
  <item id="2">222</item>
  <item id="3">333</item>
  <item id="4">444</item>
  <item id="5">555</item>
</items>

Нужно взять из набора каждые два узла, чтобы получить такой фрагмент HTML:

ID 1: 111

ID 2: 222

ID 3: 333

ID 4: 444

ID 5: 555

Каким образом такое сделать?

A: Попробуйте
<items>
  <item id="1">111</item>
  <item id="2">222</item>
  <item id="3">333</item>
  <item id="4">444</item>
  <item id="5">555</item>
</items>

код
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml">

  <xsl:output method="xml" indent="yes" encoding="UTF-8"/>

  <xsl:template match="/items">

       <title>Testing XML Example</title>

          <xsl:apply-templates select="item" />

  </xsl:template>

  <xsl:template match="item">

      <xsl:text>ID </xsl:text>
      <xsl:value-of select="@id" />
      <xsl:text>: </xsl:text>
      <xsl:value-of select="."/>

    <xsl:if test="position() mod 2 = 0">

    </xsl:if>

  </xsl:template>

</xsl:stylesheet>

тут код
<xsl:if test="position() mod 2 = 0">

проверяет четность и пересоздает новый

A: Я думаю, что ответ на мой вопрос поможет и вам. Как обычно все оказалось намного проще :)

A: <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes"/>

    <xsl:template match="items">

            <xsl:for-each select="item[position() mod 2 = 1]">

                        <xsl:text>ID </xsl:text>
                        <xsl:value-of select="@id"/>
                        <xsl:text>: </xsl:text>
                        <xsl:value-of select="."/>

                    <xsl:if test="self::node()[following-sibling::item]">

                            <xsl:text>ID </xsl:text>
                            <xsl:value-of select="following-sibling::item/@id"/>
                            <xsl:text>: </xsl:text>
                            <xsl:value-of select="following-sibling::item"/>

                    </xsl:if>

            </xsl:for-each>

    </xsl:template>

</xsl:stylesheet>


text:
Q: Get Maximum Value of a column if one column is not null from the same table I am working on a table which has the following Schema
I want to get data in the following manner

*

*If Parent is null then get the whole row as it is

*If Parent is not null then get the maximum version and not the row which has the same id as the parent id of the row.

Running the query I should get the following Id's
2, 3, 4, 6.
I would get Id 6 but not Id 1 because 1 is a parent of 6 and 5 and since 6 has the max version then row 6 would get selected.

A: Created my own sample data, as an image isn't usable. You'll need to adjust this for your own data. This should get you what you're after, however:
WITH CTE AS (
    SELECT *
    FROM (VALUES (1,'John.jpg',0,NULL),
                 (2,'Jane.jpg',0,NULL),
                 (3,'George.jpg',0,NULL),
                 (4,'Susan.jpg',0,NULL),
                 (5,'John2.jpg',0,1),
                 (6,'Susan2.jpg',0,4),
                 (7,'John3.jpg',1,1)) AS V (ID, [Filename], [Version], Parent)),
RNs AS(
    SELECT COALESCE(C2.ID,C1.ID) AS ID,
           COALESCE(C2.[Filename],C1.[Filename]) As [Filename],
           COALESCE(C2.[Version],C1.[Version]) AS [Version],
           COALESCE(C2.Parent,C1.Parent) AS [Parent],
           ROW_NUMBER() OVER (PARTITION BY C1.ID ORDER BY C2.[Version] DESC) AS RN
    FROM CTE C1
         LEFT JOIN CTE C2 ON C1.ID = C2.Parent
    WHERE C1.Parent IS NULL)
SELECT ID, [Filename], [Version]
FROM RNs
WHERE RN = 1;

A:     Create table #tmp (id int, [version] int, parent int)

    insert into #tmp values(1,0,null)
    insert into #tmp values(2,0,null)
    insert into #tmp values(3,0,null)
    insert into #tmp values(4,0,null)
    insert into #tmp values(5,0,1)
    insert into #tmp values(6,1,1)
    --insert into #tmp values(7,2,1)
    --insert into #tmp values(8,2,2)
    --insert into #tmp values(9,3,2)

    --SElect * from #tmp

    SELECT id, version, parent
    FROM(
      SELECT *, ROW_NUMBER()OVER(PARTITION BY parent ORDER BY version DESC) rn
        FROM #tmp
    )X
    WHERE ((rn = 1 and parent is not null) or (parent is null))
    AND id not in (SELECT DISTINCT Parent From #tmp where Parent is not null )

    DRop table #tmp


text:
Q: Validating and optimising IPTable and squid firewall rules My requirement :
I need to run a wifi hotspot from a pc. People connecting to the hotspot should be able to access the local web server running on the pc at full speed and at throttled speeds when accessing the internet. I have tried setting up the system using the software tools listed below. I am running this on a low power pc. So I want this to be as optimised as it can be. I need you to check and verify if I am doing all this right.

*

*people connected to wlan0 should access 127.0.0.1:80 at full speed.

*people connected to wlan0 should access the internet through eth0 at
50KBps.

Interface and PC Setup :

*

*eth0 - wired internet connection

*wlan0 - acts as hotspot - using hostapd

*dnsmasq for dhcp and dns for the hotspot

*local web server runs on 127.0.0.1:80

*squid for throttling network transfer rates

dnsmasq config file:(for ip range and dns setting)
interface=wlan0      # Use interface wlan0
except-interface=lo
listen-address=172.24.1.1 # Explicitly specify the address to listen on
bind-interfaces      # Bind to the interface to make sure we aren't sending things elsewhere
server=8.8.8.8       # Forward DNS requests to Google DNS
domain-needed        # Don't forward short names
bogus-priv           # Never forward addresses in the non-routed address spaces.
dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time

For routing the traffic
IP table entries
Rule1
Squid (throttling networkspeed) server runs in port 3128. So route the eth0(internet providing interface name) tcp port 80 and 443 to squid server for throttling network speed. So that squid runs like a proxy server.
 sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 172.24.1.1:3128
 sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to 172.24.1.1:3128

Rule2
Here route the wlan0(client) request to squid proxy server running in port 3128
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 80 -j REDIRECT --to-port 3128
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 443 -j REDIRECT --to-port 3128

Rule3
It helps to give responce for the client who connect with wlan0
sudo iptables --t nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE

Rule4
Route particular ip request to lo (local server runs in 127.0.0.1:80)
iptables -t nat -A PREROUTING -i wlan0 -p tcp -d 172.24.1.1 -j DNAT --to-destination 127.0.0.1:80

Squid configuration
acl test src 172.24.1.2/24

delay_pools 1

delay_class 1 1

delay_parameters 1 100000/100000 #100kilobyte per second

delay_access 1 allow test

All this looks like it is working but the pc and network get slow at times and definitely slow when a lot of people are accessing the hotspot.
Also how do I do a performance analysis of this firewall system?

A: Have you verified that the client requests don't simply exceed the maximum throughput of your network interfaces? Thus causing the hardware bottleneck?


text:
Q: When is the probability of a variable equivalent to a function of the variable i.e. when does p(x)=f(x)? What allows us to conclude that that p(z)= h(z) as shown in the yellow highlights in the below solution? If p(z) didn't equal h(z) then proportionality would still fail to show conditional independence.

A: I would simply add this as a comment but I do not have enough reputation to do so.  So....
Your assumption is wrong and that is what is causing the confusion.  $p(z)$ and $h(z)$ are not necessarily equal to each other, i.e., they did not just cancel each other out in the numerator and denominator as I assume you think.  But rather, it is the proportionality that allows us to get rid of both$p(z)$ and $h(z)$.
Since the pdf $p(x,y|z)$ really only depends on $x$ and $y$ we can drop any terms form the right hand side that do not depend on $x$ and $y$ (i.e., $p(z)$ and $h(z)$ only depend on $z$ and can be dropped) since we are only concerned with proportionality.
For examples that may help, look up examples in Bayesian statistics where they drop lots of terms due to proportionality.


text:
Q: Landau & Lifshitz's Approach (contour method) on the WKB connection formulas Background of the question (see pp. 161, section 47 in Landau & Lifshitz's quantum mechanics textbook Vol3, 2nd Ed. Pergamon Press).
We have the following potential well
$$U(x)\leq E \quad\text{for} \quad x \leq a ,$$
$$U(x)>E \quad\text{for} \quad x>a .\tag{47.0}$$
The WKB solutions right and left to the turning point are
$$\begin{align}\psi=&\dfrac{C}{2\sqrt{p}}\exp{\left(-\dfrac{1}{\hbar}\left|\int_a^x pdx\right|\right)} \cr
&\quad \text{for} \quad x>a, \end{align}  \tag{47.1}$$
$$\begin{align} \psi= & \dfrac{C_1}{\sqrt{p}}\exp{\left(\dfrac{i}{\hbar}\int_a^x pdx\right)}\cr
+&\dfrac{C_2}{\sqrt{p}}\exp{\left(-\dfrac{i}{\hbar}\int_a^x p dx\right)}\cr
&\quad \text{for} \quad x<a,\end{align} \tag{47.2}$$
respectively. Most quantum mechanics textbooks determine the relation between $C$ and $C_i$'s by finding the exact solution near the turning point. And then let the exact solution match with the WKB solutions.
However, in Landau & Lifshitz's quantum mechanics textbooks (vol3, section 47) they let $x$ vary in the complex plane and pass around the turning point $a$ from right to left through a large semicircle in the upper complex plane. Landau claims starting from +$\infty$, when arriving at $-\infty$ (left to $a$), there is phase gain $\pi$ in the denominator of prefactor in Eq.(2). From this we can determine $$C_2=\frac{C}{2}\exp\left(i\frac{\pi}{4}\right).\tag{47.4a}$$
They also claim the first term will exponentially decay along the semicircle in the upper half plane. Question is why? Can we show
$$\Im{\left(\int_a^x pdx\right)},$$ where $\Im$ stands for the imaginary part, is positive?

A: I) L&L are referring to a linearized model where the TISE
$$\begin{align} \hbar^2\psi^{\prime\prime}(x) +P^2(x) \psi(x)~=~&0,\cr  P(x)~:=~ \sqrt{2m (E-V(x))}~=~& |P(x)| e^{i\theta(x)}, \end{align} \tag{1}$$
becomes the Airy differential equation. Near a turning point $x_0$, we can approximate the square momentum
$$\begin{align} P^2(x)~\approx~& \alpha (x\!-\!x_0), \cr (P^2)^{\prime}(x)~\approx~&\alpha~=~2mF_0 ~\neq~0,\end{align}  \tag{2} $$
with an affine function, where $\alpha\in \mathbb{R}\backslash\{0\}$ is a non-zero real constant. (In L&L's example $\alpha < 0$ is negative).
II) Let us first reproduce L&L's argument. In the classically allowed region $x<x_0$, L&L choose the momentum $P^{>}>0$ positive. (The superscripts $>$ and $<$ refer to the classically allowed and forbidden regions, respectively.) Hence the WKB wave function (47.2) becomes
$$\begin{align} \psi^{>}~\stackrel{(47.2)}{=}&~\frac{1}{\sqrt{P^{>}}}\sum_{\pm}C_{\pm} \exp\left(\pm \frac{i}{\hbar}\int_{x_0}^x \! P^{>}~\mathrm{d}x\right) \cr
~=~&\frac{1}{\sqrt{|P|}} \sum_{\pm}C_{\pm} \exp\left( \mp \frac{2i\sqrt{|\alpha|}}{3\hbar}\left(x_0-x \right)^{\frac{3}{2}}\right)\cr
& \qquad\text{for}\qquad x<x_0.\end{align}\tag{3}$$
III) L&L is next analytically continuing the WKB wave function (47.1) (which is valid in the classically forbidden region) along an (upper/lower) semicircle in the complex $x$-plane
$$ x-x_0~=~\rho e^{\pm i\phi} , \qquad \phi~\in~[0,\pi], \tag{47.4a}$$
in order to derive the WKB connection formulas.
L&L choose the momentum variable
$$\begin{align} P^{<}~=~&\sqrt{|\alpha|(x-x_0)}\cr
~=~&\sqrt{|\alpha|}\rho^{\frac{1}{2}}  e^{\pm\frac{ i\phi}{2}}, \qquad \rho~>~0,\end{align}\tag{4} $$
such that it starts out positive
$$ \left. P^{<}\right|_{\phi=0}
~=~|P|~>~0. \tag{5} $$
The analytical continuation of the WKB wave function (47.1) then becomes
$$\begin{align} \psi^{<}~\stackrel{(47.1)}{=}&~\frac{C}{2\sqrt{P^{<}}} \exp\left( -\frac{1}{\hbar}\int_{x_0}^x \! P^{<}~\mathrm{d}x\right)\cr
~=~&\frac{C}{2\sqrt{|P|}} \exp\left( -\frac{2\sqrt{|\alpha|}\rho^{\frac{3}{2}}e^{\pm\frac{ i3\phi}{2}} }{3\hbar} \mp i\frac{\phi}{4}\right).
\end{align}\tag{6} $$
By setting $\phi=\pi$ in eq. (6), and comparing with the WKB wave function (3), one deduces from the analytical continuation along the (upper/lower) semicircle that
$$\begin{align} C_2~\equiv~& C_-~=~\frac{C}{2}e^{-\frac{i\pi}{4}}, \tag{47.4b}\cr
C_1~\equiv~& C_+~=~\frac{C}{2}e^{\frac{i\pi}{4}} , \tag{47.4c}\end{align} $$
respectively. This is L&L's main argument. (We will return to the question of what happens to the other branch in Section VII below.)
IV) Alternatively, since the Airy functions have Fourier integral representations (cf. e.g. my Math.SE answer here), one may instead use the method of steepest descent to derive matching asymptotic expansions on each side of the turning point. It is interesting to compare this method with L&L's above argument.
One may show that the Airy-like wave function
$$ \psi(x) ~=~ \sqrt{\frac{|\alpha|}{\pi\hbar}}\int_{\mathbb{R}-i~{\rm sgn}(\alpha)~\varepsilon} \! \mathrm{d}p~
\exp\left(\frac{i}{\hbar}S(p,x)\right),\tag{7}$$
$$\begin{align} S(p,x)~:=~& px  - \tilde{S}(p),  \cr
\tilde{S}(p)~:=~& p\left(x_0+\frac{p^2}{3\alpha}\right),\end{align} \tag{8}$$
$$\begin{align} S^{\prime}(p,x)~=~&x-\tilde{S}^{\prime}(p)\cr ~=~& x\!-\!x_0 - \frac{p^2}{\alpha}\cr ~\stackrel{(2)}{\approx}~& \frac{P^2(x)-p^2}{\alpha},\end{align} \tag{9} $$
$$-S^{\prime\prime}(p,x)~=~\tilde{S}^{\prime\prime}(p)~=~ \frac{2p}{\alpha},\tag{10}  $$
satisfies the TISE (1):
$$\begin{align} \hbar^2& \psi^{\prime\prime}(x) +P^2(x)  \psi(x)\cr
~\stackrel{(7)}{=}~&
\sqrt{\frac{|\alpha|}{\pi\hbar}}
\int_{\mathbb{R}-i~{\rm sgn}(\alpha)~\varepsilon} \! \mathrm{d}p~\left(P^2(x)- p^2\right) \exp\left(\frac{i}{\hbar}S(p,x)\right)\cr
~\stackrel{(9)}{\approx}~&
-i \hbar \alpha\sqrt{\frac{|\alpha|}{\pi\hbar}}
\int_{\mathbb{R}-i~{\rm sgn}(\alpha)~\varepsilon} \! \mathrm{d}p~\frac{d}{dp}  \exp\left(\frac{i}{\hbar}S(p,x)\right)\cr
~=~&0 \end{align}\tag{11}$$
for the chosen contour in the complex $p$-plane.
V) There are 2 critical points:
$$\begin{align} p_{\sigma} ~=~& \sigma~ {\rm sgn}(\alpha)~P   , \cr
S_{\sigma}~=~& \frac{2\sigma P^3 }{3|\alpha|}  , \cr
S^{\prime\prime}_{\sigma}~=~&  -2\sigma |\alpha| P  , \cr
\sigma ~\in~&\{\pm 1\}.\end{align} \tag{12}$$
The steepest descent contribution from each critical point comes from a Gaussian integral:
$$\begin{align} I_{\sigma}~=~& \sqrt{\frac{|\alpha|}{\pi\hbar}} \sqrt{\frac{2\pi i\hbar}{S^{\prime\prime}_{\sigma} } }  \exp\left(\frac{i S_{\sigma}}{\hbar}\right)\cr
~=~&\frac{1}{\sqrt{P}} \exp\left(\frac{2i\sigma P^3}{3\hbar |\alpha|} -\frac{i\sigma \pi}{4}\right)\cr
~=~& \frac{1}{\sqrt{|P|}} \exp\left(\frac{2i\sigma |P|^3e^{3i\theta}}{3\hbar |\alpha|} -i\left(\frac{\sigma \pi}{4}+\frac{\theta}{2}\right)\right) \end{align} \tag{13} $$
with angular steepest descent direction $-\frac{\sigma \pi}{4}-\frac{\theta}{2}$.

$\uparrow$ Fig. 1. The complex $p$-plane with 3 possible integration contours ${\cal C}_1$, ${\cal C}_2$, ${\cal C}_3$ for $\alpha<0$. The shaded regions denote exponentially decaying sectors. (If $\alpha>0$, it is opposite.) Since the integrand is an entire function in $p$, the $p$-integral only depend on the monodromy of the contour. (Figure taken from Ref. [W].)
VI) Now let us return to L&L's example with $\alpha<0$.
Classically forbidden region $x>x_0$: Then $P=\pm i|P|$, with $\theta=\pm \frac{\pi}{2}$, where $\pm$ corresponds to two different possible sign choices. The contour along the real $p$-axis is reproduced by the steepest descent contour corresponding to the critical point $p_{\mp 1}$:
$$\begin{align} \psi_{<}(x)~\sim~&  I_{\mp 1}\cr
~=~& \frac{1}{\sqrt{|P|}} \exp\left(-\frac{2|P|^3}{3\hbar |\alpha|} \right). \end{align} \tag{14} $$
Classically allowed region $x<x_0$: Then $P=|P|>0$ with $\theta=0$. The contour along the real $p$-axis is reproduced by the sum of both steepest descent contours:
$$\begin{align} \psi_{>}(x)~\sim~& \sum_{\sigma\in\{\pm 1\}}I_{\sigma}\cr
~=~& \frac{1}{\sqrt{|P|}}\sum_{\sigma\in\{\pm 1\}} \exp\left(i\sigma\left(\frac{2|P|^3}{3\hbar |\alpha|} -\frac{ \pi}{4}\right)\right)\cr
~=~&\frac{2}{\sqrt{|P|}} \cos\left(\frac{2|P|^3}{3\hbar |\alpha|} -\frac{\pi}{4} \right)\cr
~=~& \frac{2}{\sqrt{|P|}} \sin\left(\frac{2|P|^3}{3\hbar |\alpha|} +\frac{\pi}{4} \right).\end{align} \tag{15} $$
By comparing eqs. (14) & (15), we have derived a connection formula. In detail, by comparing the contributions to the critical points $p_{\mp 1}$, we deduce L&L's eqs. (47.4c) and (47.4b), respectively. So the two methods agree.
VII) Exponentially growing solutions are physically possible if the classically forbidden region has finite length, e.g. in quantum tunneling. However, in L&L's example, the classically forbidden region is non-compact, so exponentially growing solutions must be discarded.
It remains to explain why only one of the 2 oscillatory branches in the classically allowed side gets analytically continued to the classically forbidden side.
On one hand, L&L argue that the exponentially growing WKB branch cannot be trusted during the $\frac{3\pi}{2}$ phase shift in the Boltzmann factor because it becomes momentarily exponentially suppressed. This highlights the fact that the connection formulas are one-directional.
On the other hand, from the perspective of the method of steepest descent in Sections IV-VI, one crosses a Stokes line in the complex $x$-plane, so that the steepest descent contours pick up monodromy in the complex $p$-plane, cf. Fig. 1.
For more information, see also e.g. my related Phys.SE answer here.
VIII) Finally, we should mention that the $\frac{\pi}{2}$ phase shift between the incoming and outgoing wave at the turning point in eq. (15) corresponds to a Maslov index $|\mu|=1$,
cf. e.g. this Phys.SE post.
References:

*

*[LL] L.D. Landau & E.M. Lifshitz, QM, Vol. 3, 2nd & 3rd ed, 1981; $\S47$ & $\S b$.

*[W] E. Witten, Analytic Continuation Of Chern-Simons Theory, arXiv:1001.2933; p. 23-29, 48-49. A related 2015 KITP lecture by Witten, A New Look At The Path Integral Of Quantum Mechanics, can be found on YouTube.


text:
Q: Go to Typescript Source Definition instead of Compiled Definition in Visual Studio Code I am working on a typescript project with Visual Studio Code including multiple npm packages structured like this:

*

*Source code: /src/index.ts

*Compiled code: /dist/...
When I right click on imported objects and choose "Go to Definition" or click F12 or by clicking on the object with holding down CTRL, Visual Studio Code opens the corresponding .d.ts file in /dist

However, I want VSCode to open the corresponding .ts file in /src

Is it possible to change this behavior, as it is really annoying to manually search for the source file.
I've created git repo, so that you can try it yourself:
https://github.com/flolude/stackoverflow-typescript-go-to-definition

*

*you just need to run yarn bootstrap in order to replicate the issue.

A: TypeScript 2.9 introduced a compilerOption called declarationMap.  Per the release notes:

Enabling --declarationMap alongside --declaration causes the compiler
  to emit .d.ts.map files alongside the output .d.ts files. Language
  Services can also now understand these map files, and uses them to map
  declaration-file based definition locations to their original source,
  when available.
In other words, hitting go-to-definition on a declaration from a .d.ts
  file generated with --declarationMap will take you to the source file
  (.ts) location where that declaration was defined, and not to the
  .d.ts.

I submitted a PR on your example repo to enable this setting.

A: The newer VSCode version (April 2022 or later) supports this with a feature called "Go to Source Definition" (see here). It is still a work in progress I believe (given this discussion thread), but should be working properly in most cases.


text:
Q: Installed Python library but can't Import Basically, I've been trying to use the spotipy python library and have tried everything but can't get it to work (Mac OS). When I do:
pip install spotipy

I get
Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

And I wasn't sure what I did after that but I did something that seemed to upgrade six to 10.X. But then pip show would say it's in 1.4.1 still. I've been going at this for hours, can someone please help!

A: It looks like you need to be using virtualenv. This will allow you to have differing python packages without conflicts. Look this over https://virtualenv.pypa.io/en/latest/ .


text:
Q: Merge a pandas dataframe with a list through an outer join I have a dataframe that looks as follow
   A  B
0  1  4
1  2  5
2  3  6

and a list
names = ['x','y']

I want to get a dataframe that kind of performs and outer join with that list. The desired result is:
   A  B  name
0  1  4  x
1  1  4  y
2  2  5  x
3  2  5  y
4  3  6  x
5  3  6  y

A: Using pd.concat:
res = pd.concat([df.assign(name=i) for i in names], ignore_index=True)

Result:
   A  B name
0  1  4    x
1  2  5    x
2  3  6    x
3  1  4    y
4  2  5    y
5  3  6    y

A: Using additional key for merge
df.assign(key=1).merge(pd.DataFrame({'Name':names,'key':1})).drop('key',1)
Out[54]:
   A  B Name
0  1  4    x
1  1  4    y
2  2  5    x
3  2  5    y
4  3  6    x
5  3  6    y

A: Comprehension
pd.DataFrame(
    [r + (n,) for r in zip(*map(df.get, df)) for n in names],
    columns=[*df.columns, *['name']]
)

   A  B name
0  1  4    x
1  1  4    y
2  2  5    x
3  2  5    y
4  3  6    x
5  3  6    y


text:
Q: Range of $f(x,y)=\sqrt{x-y}+\ln(9-x^2-y^2)$ I have to find the range of $f(x,y)=\sqrt{x-y}+\ln(9-x^2-y^2)$.
I know its domain is the set
$$x\geq y\quad\text{and}\quad x^2+y^2<9$$
I also know $\sqrt{x-y}\geq0$ and $\ln(9-x^2-y^2)>0$. So I may say the range is
$$f>0$$
Is it right?

A: As you said, we need to discuss the Domain of your function $f$, which is
$$
D=\{(x,y)\subset \mathbb{R}^2: x^2+y^2< 9, y \leq x\}.
$$
Clearly, $9-x^2-y^2$ can be as close to zero as we wish over $D$, so $f$ does not have a lower bound. Regarding the upper bound, it can be attained at a point on the line $y=x$, in which case the upper bound would be $\ln 9$, or at a critical point in the interior of $D$. If you run the calculations, you will see that the upper bound is $m = f(x^*,y^*)$, where $(x^*,y^*)$ is the critical point (you can compute it solving a nonlinear system of equations) and you'll conclude that the range is $(-\infty, m]$, with $m \approx 3.36729$.


text:
Q: Default path changed after uninstalling python and reinstalling ubuntu-desktop I was trying to uninstall python3 from ubuntu 12.04 with the following command:
sudo apt-get remove --purge python3*
and it just remove many things from system, including the ubuntu-desktop. After that, I reinstalled the desktop with the command:
sudo apt-get install ubuntu-desktop
The problem is that, when I open a terminal, it shows me a
~
sign on top off the screen, and didn't start from home, as in
nilson@GHOSTRIDER~$
What's wrong and how can I correct this?
For details see the marked area in the following picture:

A: OP wrote:

[...]the problem was with the $PS1 variable in the ~/.bashrc. There was
  another line above, and I just uncomment it and comment the second
  one. The new echo $PS1 is \[\e]0;\u@\h:
  \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ $(parse_git_branch)$(parse_svn_branch).


text:
Q: raising an Exception in an Except without calling the original Exception My code is the following:
try:
    *Do something*
except *anError*:
    if (condition):
        methodCalled()
    else:
        raise "my own Exception"

The problem is that when I raise my own exception ("my own Exception"), the "anError" exception also gets raised. Is there a way to make sure that Error that I caught doesn't get raised when I raise my own Exception?

A: Quoting the docs:

When raising (or re-raising) an exception in an except or finally
  clause __context__ is automatically set to the last exception caught;
  if the new exception is not handled the traceback that is eventually
  displayed will include the originating exception(s) and the final
  exception.

This is exactly your case:
try:
    try:
        raise ValueError
    except ValueError:
        raise TypeError
except Exception as e:
    print('Original:', type(e.__context__)) # Original: <class 'ValueError'>
    print('Explicitly raised:', type(e))    # Explicitly raised: <class 'TypeError'>

There's only one active exception; I might have written except TypeError instead of except Exception and the output would still be the same.
If you want to prevent Python from printing the original exception, use raise  ... from None:
try:
    raise ValueError
except ValueError:
    raise TypeError from None


text:
Q: Using same java hierarchy for Eclipse and Netbeans Some of our developers prefer Eclipse and some prefer Netbeans.
We want the same file hierarchy for both so that it's kept under one directory in subversion.
The directory structure is:
src
| +main
| | +java
| |   +com
| |     +mycompany
| |       +utils
| |         +Bar.java
| |         +Foo.java
| +test
| | +java
| |   +com
| |     +mycompany
| |       +utils
| |         +BarTest.java
| |         +FooTest.java
bin
| +com
| | +mycompany
| |   +utils
| |     +Bar.class
| |     +Foo.class

This not only works fine in Netbeans, but it appears to be a standard. (http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html)
The problem I'm having is that in Eclipse I can see all this hierarchy, but it complains that the file Bar.java (above), which has a package declaration: "package com.mycompany.utils;", should be declared as "package main.java.com.mycompany.utils;", which is not what I want.
How can I configure Eclipse to recognize this hierarchy?
Thanks,
Chelmite

A: Eclipse is not recognizing the proper class hierarchy because the definition of source folders is in its metadata files, which you have probably not checked into SVN. Since you seem to be using Maven I would recommend you have your developers install m2e, which natively recognizes and handles Maven projects, no extra setup required.
Indigo and Helios come with m2e installed afaik.
If you want to manually fix up those source trees, then just right click on the project and define two source folders
src/main/java
src/test/java

A: You need to edit your classpathentry.  Try editing the .classpath file for your eclipse project and changing it to something like the following:
<classpathentry kind="src" output="bin" path="src/main/java"/>

A: The mismatch is that your Eclipse project is configured with src as the root of the Java source path, when in fact you have two separate source trees both under that folder. To configure it correctly:

*

*Open the Project Properties (via right-click)

*Select Java Build Path on the left, then the Source tab on the right side

*Remove src as a source folder

*Add src/main/java and src/test/java as source folders

That tells Eclipse that the project has two source folders and it will compile them together into the bin folder.
Note: it is strongly recommended to check in the .project and .classpath files and the .settings folder into svn, so that anyone who checks out the project into Eclipse will automatically get this configuration.
If wanted, you could configure separate build output locations for each of the source folders (instead of both going into bin).


text:
Q: CityEngine Rule for Area I have been successful at creating rules for already established footprints in CityEngine.  However, I recently received a project to create a proposed commercial and residential development.  I have all the known buildings extruded but for the new buildings I only have empty parcels.  Creating a rule to extrude based on floors, shape, height, and setback is not the issue and all are based on a zone, which I have a rule file for already.   What I can't figure out is how to create the building size based on Sq Feet, which is the only numbers given to me.
Is there a rule for Sq Feet/meters instead of width and length?
Also how can I put a random number of buildings on a parcel using a density based on Acreage?
For example 16-24 units per acre.  The acreage is included in the parcel features in CityEngine.

A: As @MaryBeth already pointed out there are infinite possibilities to create a rectangle given the area of the rectangle. Therefore you can't just provide that information to an operation and it'll do what you want.
One option you have is to use innerRectangle to create some sort of an optimal rectangle in your parcel. Using scope.sx and scope.sy you could then compute the area of this rectangle (in meters if you don't convert).
Now you know how much area less area your building should have. From that you can compute the setback from the large rectangle you need. Feed this number into the operation setback and you'll have a shape that has the requested area.