text:
Q: Setting a timeout in a .net desktop application Hi I have created a little application to move some files around and put them into a database. This is working well except that the application needs a timeout.
If my app has not completed the task within 2 hours it re opens and locks out everything. I need to say that if my application has been open for 2 hours close it.
One thought was can you set a time out in an application. I have had a google for this and found some stuff in system.threading about timeout=infinite and threading.sleep=200 but don't really understand this.
Another thought, is using the timer and counting up to 2 hours and then calling a close method, this seams like a bit of a cheat.
Any ideas on time out in either C# or Vb

Sadly this is not for a db connection this is not where the application is failing.

A: What about allowing just one instance of your application to run at the same time?
I guess you are scheduling runs: have a look at this code as a way of preventing multiple instances of your application without changing the scheduling.
static void Main(string[] args)
{
    Mutex flag = new Mutex(false, "UNIQUE_NAME");
    bool acquired = flag.WaitOne(TimeSpan.FromMilliseconds(0));  // 0 or more milliseconds
    if (acquired)
    {
        Console.WriteLine("Ok, this is the only instance allowed to run.");

        // do your work, here simulated with a Sleep call
        Thread.Sleep(TimeSpan.FromSeconds(5));

        flag.ReleaseMutex();
        Console.WriteLine("Done!");
    }
    else
    {
        Console.WriteLine("Another instance is running.");
    }
    Console.WriteLine("Press RETURN to close...");
    Console.ReadLine();
}

Please, don't abandon your Mutex... ;-)
HTH

A: What about another option? Set a flag which says whether the process is currently running or not.
If the process is running then dont start the second one or close the first one or may be be set a timer and check again after few minutes(?)

A: Maybe a timeout for the DbConnection/DbCommand objects is more appropriate (have a look at MSDN)


text:
Q: A question about interior. Let $X$ a topological space. Let $A,B$ and $C$ subsetes of $X$.

If $$A\subseteq\text{Int}(B\cup C)$$
  Under what conditions can we say that $\text{Int}(A)\cap\text{Int}(B\cup C)\ne\emptyset$?
Could you give me some examples and / or counterexamples?

Thanks!

A: Since you want $\mathrm{Int}(A) \cap \mathrm{Int}(B \cup C) \neq \emptyset,$ the first requirement is that $A \neq \emptyset,$ this also prevents $\textrm{Int} (B \cup C)$ from being empty. The next condition needed is that $\textrm{Int} (A) \neq \emptyset.$ With these two conditions we have that $\textrm{Int} (A) \subseteq A \subseteq \textrm{Int} (B \cup C)$ where $\textrm{Int} (A)$ is non empty. From the above inclusion we have $\mathrm{Int}(A) \cap \mathrm{Int}(B \cup C) = \textrm{Int} (A) \neq \emptyset.$

A: Assuming $Int(A) \neq \emptyset$.  We know that $Int(A) \subseteq A$, so we always have
$$ Int(A) \cap Int(B \cup C) \neq \emptyset $$
The only way for this to fail is if $Int(A) = \emptyset$ or $Int(B \cup C) = \emptyset$

redpajama_set_name: RedPajamaStackExchange


text:
Q: MVC ASP.NET Best way to get 52 textbox key/values from View to Controller I'm hoping that it isn't to pass each as a parameter to the controller post method..
Have a grid of 52 text boxes representing weeks in a year, each will be containing a decimal value, need ALL of these passed back to the controller for mass updating of the database..
edit: Adding more details.
So my action Index(); returns a view with a list of 52 objects in it.
so
return View(dates);
inside the view I do a foreach for all the objects of that type in the model, and put their values into textboxes, I then want to change them and hit submit.
is there any way to get the updated list into my POST controller without having to give it 52 parameters with the id's of the textboxes?
Thanks a lot in advance!
edit: Maybe there is a way I can post the forum to the controller and iterate through the textbox controls and get out id/value, any idea how?

A: I would suggestion using a Model Binder:
http://www.singingeels.com/Articles/Model_Binders_in_ASPNET_MVC.aspx
http://www.singingeels.com/Articles/Model_Binders_in_ASPNET_MVC__Part_2.aspx

A: Check out this question. It should provide you with a better answer than using the FormCollection.
Complex model binding to a list

A: Hey, I got the solution I wanted after a bit of messing about. I just passed in the parameter "FormCollection myForm" and after a bit of exploring within that object I found my 52 values! Thanks for the help.
edit: I deleted this due to peer pressure probably over a year ago... but looking back on it I don't see what the problem was, aside from answering my own question..


text:
Q: Add & Remove prefix to GUID via ModelBuilder conversion I'm trying to add and remove a prefix to a GUID on each request to my service.
Something like this
 modelBuilder.Entity<MyEntity>()
                .Property(e => e.Id)
                .HasConversion(
                    v => PrefixConstant + v,
                    v => Guid.Parse(v.Substring(PrefixConstant.Length)));

Where PrefixConstant is just a string holding something like "ABC_". The idea is to store the id as a GUID, but return it with a prefix to the client.
The above hasn't been working too well with an error of id is of type uuid but expression is of type text

A:
The idea is to store the id as a GUID, but return it with a prefix to the client.

The implementation though does the exact opposite. The defined value conversion here
.Property(e => e.Id)
.HasConversion(
    v => PrefixConstant + v, // (1)
    v => Guid.Parse(v.Substring(PrefixConstant.Length)) // (2)
)

implies that the class property Id type is Guid, stored as string in the database, and using (1) for writing and (2) when reading the database value.
So all you need is to simply exchange the types and conversions, e.g. making the Id property type string
public class MyEntity
{
    public string Id { get; set; }
}

and configuring to/from database Guid conversion
.Property(e => e.Id)
.HasConversion(
    v => Guid.Parse(v.Substring(PrefixConstant.Length)),
    v => PrefixConstant + v
)

For more info, see the EF Core documentation of Value Conversions and ValueConverter<TModel,TProvider> class.

A: The reason of error is almost clear. You get error because you want to convert Guid to string and save it to database column whose type is Guid!
I think you choose a wrong option. HasConversion is suitable for situations where you want convert data and save converted data, but your intention is just displaying property to client in another way (Your concern here is about UI, not logic). So I think doing change in your model is very better option:
public class MyEntity
{
    private const string PrefixConstant = "ABC_";
    private Guid id;
    public string Id
    {
        set => id = Guid.Parse(value.Replace(PrefixConstant, string.Empty));
        get => $"{PrefixConstant}{id.ToString()}";
    }
}

It's just to show you the idea. Even this code is not a best practice if you use that as your DataModel because you shouldn't use your DataModel instead of ViewModel.
My intention here as MyEntity is ViewModel not DataModel and you should pay attention to their differences and separate them from each other.


text:
Q: Query data from postgresql functions not working in app, but works when testing manually I met an annoyance when trying to use simple function to query data for my web app. The idea is to use one function to list the contents of one table; the other function to use the user-selected record_id in this table to query the detailed contents data in another table.
When running, the app ran the two functions without any error while no data got. Checked the console and found the second function query results is null (I console.log the input for the second function, found they got and  using the correct query keys). Since I am sure database has the data for query.
I tried:

*

*use psql command line to query data using the same query keys, I have the results without problem;

*I run a node command line, and try to run the two functions by providing the query keys, it also gave me the correct results.

So the functions should work. Now my question is why put them in the app and let them run by themselves, they did not get the query results?
I am using pg = require("pg"); and const pool = new pg.Pool(config) for database connection;
Your sharing of your experience will be very appreciated.
(UPDATE)The functions are like below:
function listItemDB(callback){

pool.connect(function(err, client, done) {
  if(err) {
    return console.error('error fetching client from pool', err);
  }

  //use the client for executing the query
  client.query(`SELECT * FROM basicdb.items`,
                function(err, result) {
                    //call `done(err)` to release the client back to the pool (or destroy it if there is an error)
                    done(err);

                    if(err) {
                      return console.error('error running query', err);
                    }
                    // console.log(result.rows);
                    callback(result.rows);
  });
});

}
The above function is only trying to get "item1" and "dataset1" for future use and pass them to below function args. It does its job perfectly.
function getFileName(itemName,datasetName, callback) {

let fileName;

console.log(itemName,datasetName);

pool.connect(function(err, client, done) {
    if(err) {
      return console.error('error fetching client from pool', err);
    }

    client.query("SELECT * "+
                 "FROM basicdb.dataset "+
                 "INNER JOIN basicdb.items "+
                 "ON basicdb.dataset.item_id = basicdb.items.item_id "+
                 "WHERE (basicdb.items.item_name = ($1)) "+
                   "AND (basicdb.dataset.datasetname = ($2))",[itemName,datasetName],

                   function (err, result){
                      done();
                      if(err) {
                          return console.error('error running query', err);
                      }
                      let records = result.rows;
                      fileName = records[records.length-1].filename;
                      callback(fileName);
                    });
});

}
This above function is trying to get the filename so the main app can use it. The code to call the above function in my main app.js is like below:
    db.getFileName("item1","dataset1",function(fileName) {
//do something with the fileName....}

("db" is the module name which include the functions.)

A: I finally found the problem, which is a low-level mistake and has nothing to do with the database and the queries.
The item names got from the dropdown list in the app, which was feed to the function args, has one " "(space) attached to the end of the name(i dont know why?), which always "!=" the record in the database:-(, so always no query result in the app. But for the function test, I hardcode the item name which is correct "==" the record in the database. Since it is " ", even when I console.log(itemName), I did not find the space at the end.
It turns out to be 'A mistake of space'.


text:
Q: Convert u32 -> sha256 -> String Really important to mention: I'm working in NOSTD env: elrond_wasm
https://docs.rs/elrond-wasm/0.17.1/elrond_wasm/api/trait.CryptoApi.html#tymethod.sha256
I'm trying to get a u32 => sha256 => String
let hash = self.crypto().sha256(&[1u8, 2u8, 3u8]);
if (String::from_utf8(hash.to_vec()).is_err()) {
uri.append_bytes("error".as_bytes());
}

Am I doing something wrong? It's always giving an error. When printed, I get some gibberish like: D�z�G��a�w9��M��y��;oȠc��!
&[1u8, 2u8, 3u8] this is just an example, but I tried a bunch of options
let mut serialized_attributes = Vec::new();
"123".top_encode(&mut serialized_attributes).unwrap();

or 123u32. to_be_bytes()
or 123u32.to_string().to_bytes()
all same result.

A: You should not try to print the raw hash bytes directly (as that is basically binary garbage), but instead convert it into a meaningful representation like hex.
You can try to use the hex crate for that:
https://docs.rs/hex/0.3.1/hex/fn.encode.html


text:
Q: accessing property in wrapped Ember.js component I have a simple component like this:
# app/components/outside-component.js
import Ember from 'ember';

export default Ember.Component.extend({
  counter: 1
});

with its template defined as
# app/templates/components/outside-component.hbs
{{yield}}

and I want to render it inside of template like this
# app/templates/application.hbs

{{#outside-component}}
  {{counter}}
{{/outside-component}}

The counter is however not being render here and I think that's because the context is set to outer context. How do I render a component like this and enforce it to use the component scope?

A: The context of application.hbs is the application controller, counter is defined on the component unless you yield it from inside the component it will lookup counter on the controller.
outside-component.hbs
{{yield counter}}
Application.hbs
{{#outside-component as |counter|}}
  {{counter}}
{{/outside-component}}

Twiddle


text:
Q: Show that B is a tight frame if and only iff $\sum_{j=1}^N \|v_j\|^2e^{2i\theta_j}=0$
*

*Let $B=\{ v_0, \dots, v_k \} \subset \mathbb{R}^2$ be a frame in $\mathbb{R}^2$. Assume $v_0=(1,0)$. Let $\theta_i$ be the angle formed by $v_i$ and $v_0$. Show that B is a tight frame if and only iff $$\sum_{j=1}^N \|v_j\|^2e^{2i\theta_j}=0$$ Hint: Let $v_j=(r_j\,cos\theta_j,r_j\,sin\theta_j) \dots$

*Use the previous identity to show that the vertices of a regular polygon with n sides inscribed in a circle of radius 1 form a tight frame in $\mathbb{R}^2$.

A tight frame is if the rows of the matrix are orthogonal to each other and have the same length. Also $$\|v\|^2=c^2 \sum_{i=1}^k \langle x,v_i \rangle^2$$ if B is tight.
$\textbf{Proof:}$ Let $v_i=\{ \begin{bmatrix} r_j\cos(\theta_j) \\ r_j\sin(\theta_j) \end{bmatrix} \}_{j=1}^k$ Then $$\sum_{j=1}^k \|v_j\|^2e^{2i\theta_j}= \sum_{j=1}^k r^2_j(\cos(2\theta_j) +i\sin(2\theta_j))$$
$\Rightarrow$: Assume B is tight then
$$ \|(1,\dots,|r_k|\cos\theta_j)| =\|(0,\dots, |r_k|\sin\theta_j)\|  \Rightarrow \sum_{j=1}^k r_j^2(\cos^2\theta_j-\sin^2\theta_j)=0=\sum_{j=1}^kr_j^2\cos(2\theta_j)$$
$$\langle (1,\dots,|r_j|\cos\theta_j),(0,\dots, |r_j|\sin\theta_j) \rangle =0 \Rightarrow \sum_{j=1}^k r_j^2(\cos\theta_j\sin\theta_j)=0=\sum_{j=1}^k r_j^2sin(2\theta_j)=-\sum_{j=1}^k r_j^2isin(2\theta_i)$$
From these two equations we have:
$$-\sum_{j=1}^k r_j^2i\sin(2\theta_i)=\sum_{j=1}^kr_j^2\cos(2\theta_j) \Rightarrow \sum_{j=1}^N r^2_j(\cos(2\theta_j) +i\sin(2\theta_j))=0$$
$\Leftarrow$: Assume that the following is true: $$\sum_{j=1}^k \|v_j\|^2e^{2i\theta_j}=\sum_{j=1}^k r^2_j(\cos(2\theta_j) +i\sin(2\theta_j))=0$$
We are going to show that B is a tight frame by proof by contradiction.
Let $p=\sum_{j=1}^kr_j^2\cos(2\theta_j)$, where $0 \neq p \in \mathbb{R}$, and $q=\sum_{j=1}^k r_j^2\sin(2\theta_i)$, where $0 \neq q \in \mathbb{R}$.
\begin{equation*}
\begin{split}
-\sum_{j=1}^k r_j^2isin(2\theta_i)=\sum_{j=1}^kr_j^2\cos(2\theta_j) & \Rightarrow  p=-iq \\
& \Rightarrow (p+0i)=(0-iq) \\
& \Rightarrow (p+0)+(0-q)i=0 \\
\end{split}
\end{equation*}
This is only true if $p,q=0$, which is a contradiction.
How would I prove part 2?

A: he vertices of a regular polygon with n sides  have coordinates in the form of $(\cos(\frac{2\pi k}{n}), \sin(\frac{2\pi k}{n}))z$, where $k=0,\dots,n$. Having the knowledge from part a, we can do the following:
\begin{equation*}
\begin{split}
\sum_{j=1}^k (\cos(\frac{2\pi j}{k}) +i\sin(\frac{2\pi j}{k})) & =\sum_{j=1}^k e^{\frac{2\pi ij}{k}} \\
& =\frac{1-e^{\frac{2\pi ik}{k}}}{1-e^{\frac{2\pi i}{k}}} \\
& =\frac{1-1}{1-e^{\frac{2\pi i}{k}}} \\
& =0 \\
\end{split}
\end{equation*}


text:
Q: Cannot select multiple files with FileChooser I'm trying to implement a screen with a FileChooserListView using Kivy for an application that may require the user to select hundreds of files. The issue I am having is that I cannot select multiple input files, even though multiselect: True. If I use the icon view with the same configurations I am able to select multiple files, but only by clicking in each one of them individually. This is quite cumbersome for hundreds of files.
The behaviour I desire is simply to click on an initial file and then Shift+click on a final file in order to select a large number of files. Is there a way to change the behaviours that I might be missing?
My code in the .kv file containing the screen for the FileChooser:
ShowcaseScreen:
    name: "fc"

    BoxLayout:
        orientation: "vertical"

        FileChooserListView:
            id: list_view_tab
            multiselect: True

        BoxLayout:
            size_hint_y: .1
            padding: 10
            spacing: 30

            Button:
                text: "Open"
                on_release:
                app.load(list_view_tab.path, list_view_tab.selection)

            Button:
                text: "Cancel"
                on_release: app.go_previous_screen()


text:
Q: Using the URL option in a form_for I have a form with a url option.
- form_for [@organization, @video], :url => organization_media_videos_with_session_path(@organization), :html => { :multipart => true } do |f|

That URL is specifically a helper that I wrote here :
def organization_media_videos_with_session_path(organization)
  session_key = ActionController::Base.session_options[:key]
  organization_media_videos_path(organization, session_key => cookies[session_key], request_forgery_protection_token => form_authenticity_token)
end

My question is this..
On my working production the form HTML looks like this :
<form method="post" id="new_video" enctype="multipart/form-data" class="new_video dirtyform" action="/organizations/470/media/videos">

On my non-working testing server, the form HTML looks like this :
<form method="post" id="new_video" enctype="multipart/form-data" class="new_video" action="/organizations/1/media/videos?_hq_channel_session=BAh7CjoQX2NzcmZfdG9rZW4iMTVrM3NyWkMzVGk5OGJFNXR6WTZ1V3djWWtyUThnS01OaFlDZVBsUzA5SEU9IhV1c2VyX2NyZWRlbnRpYWxzIgGAODQ4NjQwMzViZTNkODkyYmQ1NmNkY2U3ZTcxOTBhYzc2ZGFhMWNlMGQ0ZjVhOGFlMDZjODUyZGU5N2MzMzM5MGFhOTRkNmZlNmNhMGQ1N2Y3YmU4NzY2OWJjYzk1ZDhiOWVkNzQ3OGQxOTJjMGViMDdiZWQ1MGI0NmZhODQ4YWUiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewAiGHVzZXJfY3JlZGVudGlhbHNfaWRpBjoPc2Vzc2lvbl9pZCIlZDk4Mjg0MTBkOGZiMGJkOTYxNDMyZmY5NzNkMGE1NDY%3D--c46c8a31da47833661393e399510802b2924f128&authenticity_token=5k3srZC3Ti98bE5tzY6uWwcYkrQ8gKMNhYCePlS09HE%3D">

How could this be?

A: That looks very much like your session secret. I imagine this is something to do with your environment setup, which is passing the key in the URL in dev but not in production.
Have a look at this for more details.


text:
Q: How to implement unique pointers? Thanks to some useful and informative comments on my previous code. Now I start to work on how to implement unique pointers in my code. I would like to ask if I used the unique pointers correctly. Also, I would like to know if my code would be efficient if I used unique pointers that way. So far I only observed that the unique pointers are destructed automatically once it is out of scope. what are some other variations when unique pointers are used. I need some further explanation on how to use unique pointers in the context of the creation of my own vector class. Part of my code is as following:
#include <iostream>
#include<memory>
template<typename S>
class MyVector{
private:
    size_t size;
    size_t capacity;
    std::unique_ptr<S[]>a;
    void allocate(){
        capacity = size*2;
        auto temp = std::make_unique<S[]>(capacity);
        for(size_t i=0; i<this->getSize();++i){
            temp[i]=std::move(a[i]);
        }
    }

public:
    MyVector():size(0), capacity(1), a(new S[1]){};
    size_t getSize(){return size;}
    size_t getCapacity(){return capacity;}
    void pushBack(S input){
        ++size;
        if(this->getSize()==this->getCapacity()){
            this->allocate();
        }
        a[this->getSize()-1]=input;
    }
    S &operator[](size_t p){return a[p];}

A: There were numerous issues with your code. Below, I addressed all I found in an improved code.
#include <iostream>
#include<memory>

template<typename S>
class MyVector
{
    size_t m_size = 0;           // use `size` as name for public member
    size_t m_capacity = 0;       // give default value
    std::unique_ptr<S[]> m_data;
    void grow_capacity()
    {
        m_capacity += m_capacity? m_capacity : 1;
        auto temp = std::make_unique<S[]>(m_capacity);
        for(size_t i=0; i!=m_size; ++i)
            temp[i] = std::move(m_data[i]);
        m_data = std::move(temp);      //
    }
public:
    MyVector() = default;         // let compiler work this out
    size_t size() const noexcept  // const member
    { return m_size; }
    size_t capacity() const noexcept
    { return m_capacity; }
    void pushBack(S const&input)
    {
        if(m_size == m_capacity)   // only grow when needed
            grow_capacity();
        m_data[m_size++] = input;
    }
    void pushBack(S &&input)       // version for moving in
    {
        if(m_size == m_capacity)
            grow_capacity();
        m_data[m_size++] = std::move(input);
    }
    S &operator[](size_t p)
    { return m_data[p]; }
    S const &operator[](size_t p) const  // const data access
    { return m_data[p]; }
};


text:
Q: Opening a linked table in Access is much faster than query in SQL Server Management Studio I have an Access 2010 .accdb front end with a linked table to a view in SQL Server (2008 R2).
Surprisingly, opening it in Access takes around 5-10 seconds while executing a select in SSMS doesn't finish in 3 minutes (after that I just cancel the execution).
What can be the cause?
EDIT:
My mistake: What makes it unbearably slow is that I am trying to select only the first (TOP 1 *) record.
Now I can keep on with my work and the question is only academic:
I thought that selecting one record would be faster than selecting the whole recordset. What can be the cause?
I see it doesn't happen only to me:
Why select Top clause could lead to long time cost

A: When you open the table in Access, Access requests the first records (at least as many to fill the first screen), and then continues to load more records in the background.
Simply doing a SELECT TOP 1 * FROM someTable in SSMS should always be fast if the table has a primary key.
Only if you add an ORDER BY clause on an non-indexed column, performance will suffer because the whole table must be scanned.


text:
Q: Powershell netsh automatically run script Is there a way to input text to notepad stating an IP Address, Subnet mask and Gateway and then running a powershell script that would execute the following netsh interface ipv4> set address name="Wireless Network Connection" source=static addr=192.xxx.x.xx mask=255.255.0.0 gateway=xxx.xxx.x.x gwmetric=0
At the moment I just type that manually in a Powershell terminal or cmd and it works (changes what i want changed) but i want to be able to just edit a notepad file and exute a batch file that would automatically do it..
i am pretty new to powershell and scripting but if someone can point me in the right direction it would be hugely appreciated.
Thanks.

A: There are many ways for you to do this. Here is one:
ip_properties.txt contents:
192.168.1.15,255.255.255.0,192.168.1.1

powershell script contents:
$properties = (Get-Content ip_properties.txt) -split ','
Invoke-Expression "netsh interface ip set address name='Wireless Network Connection' source=static addr=$($properties[0]) mask=$($properties[1]) gateway=$($properties[2]) gwmetric=0"

Essentially you're supplying your interface parameters in a comma separated format, splitting the those properties into an array and then using the array elements as inputs to the netsh command


text:
Q: How do I send an image to the server computer and download it? I want to send a screenshot that I took on another computer and send it to mine, the host. I want to do this using sockets. How do I do it? I have this:
if command == "screenshot":
    s.send("Command received.".encode())
    screensaveshot = pyautogui.screenshot()
    screensaveshot.save('screenshot.png')
    imgcounter = 1
    basename = "screenshot.png"
    data = s.recv(4096)
    txt = str(data)
    myfile = open(basename % imgcounter, 'wb')
    myfile.write(data)
    data = s.recv(40960000)
    myfile.close()

A: You can use tqdm for your purpose.
Have a look at this site https://www.thepythoncode.com/article/send-receive-files-using-sockets-python
And if you want to send files to other computers you can use ngrok as a server provider by replacing ngrok's address in your socket connection.


text:
Q: Select All CheckBoxes I am having a problem, I am trying to make a link for a acsx file. Basically checkboxes get dynamically generated through pulling information out of a sharepoint list. These are HTML boxes. Ive tried using the runat=server on the boxes, ive tried using javascript to select the by creating a form that just contains the checkboxes but neither of those will select any checkboxes. Anyone have any idea on how I can select all the checkboxes on a page.
Thanks

A: Without really understanding, what you need to do, this JavaScript code will select all checkboxes within a container with the id boxes (i.e.
...
):
var checkboxes = document.getElementById( 'boxes' ).getElementsByTagName( 'input' );
for ( var i = 0; i < checkboxes.length; i++ )
{
    if ( checkboxes[i].type == 'checkbox' )
    {
        checkboxes[i].chcked = true;
    }
}

(This is a solution without jquery & other frameworks, but of course if you are already using one, just use their built-in method for doing this)

A: something like this should do the trick:
$("input[type=checkbox]:not(:checked)").attr('checked','checked');

A: You could use jQuery to select all checkboxes in a page and set them that way.


text:
Q: Using a Map type attribute in aura:if Trying to create a custom Navigation Bar and display menu entries based on user privileges.
I defined this attribute in my component:
<aura:attribute name="navItemPrivs" type="Map" default="{ Task: false }"/>

In the JS controller and helper I'm able to access and modify it using navItemPrivs['Task'], but when I try and use it inside an aura:if expression:
<aura:if isTrue="{!and(v.navItemLabel1 != undefined, v.navItemPrivs['Task'] == true}">

I get an error:

expecting a positive integer, found ''Task'' at column 50 of expression: and(v.navItemLabel1 != undefined, v.navItemPrivs['Task'] == true

I can't access it using v.navItemPrivs[0] because the "0" key isn't defined (nor do I want it to be).
Is there something I'm doing wrong and this isn't the way to do it? Because I don't see why I would not be able to access Map values if they exist in the framework..

A: You can access the attribute as v.navItemPrivs.Task and that should work just fine. Object properties are accessible by dot notation but not brackets unless they are integers.
Unfortunately you can't bind to dynamically named keys (e.g. you can't do v.myMap[v.myKey] in Lightning so far). Be aware that under the current way Locker functions (as of Summer '16 Patch 10.0) if you want a Map/Object key binding to be successful the key must exist when you first push the object to the v.attribute it will reside in.


text:
Q: Having trouble getting distinct and Case statement working in SQL When I execute the SP, I get this error message:

Msg 102, Level 15, State 1, Line 1
  Incorrect syntax near '.'.

I tested the SQL without the case statement and it works, it returns everyone that is an admin.
ALTER PROCEDURE [dbo].[GetRoles]
AS
DECLARE @num varchar(25),
@reportid Decimal,
@dom varchar(10)
set @reportid = 1
set @dom = 'use5'

SELECT @num =
Case @reportid

 WHEN 1 THEN
  'select distinct u.id as userId, u.domain, u.isAdmin, u.email, u.canReport, a.[site],
  a.bldgNum, a.dataCenterNum, l.shortName, l.[description], a.canApprove, a.canComplete
  from locAdmin a inner join location l on (a.site=l.site and a.bldgNum = l.bldgNum
  and a.dataCenterNum = l.dataCenterNum) right outer join [user] u on u.id=a.userId
  and u.domain=a.domain where u.isAdmin = 1'

 End

 EXEC (@num)

Also distinct doesn't filter out duplicate userid for some reason too. Some of the Userids are inputted 3x depending on what access they have (That's the way it is setup before I came in)

A: You have limited @num to 25 characters - but the string you're setting it to is much longer than that - it'll be truncated
(also: @num is a very odd and potentially misleading name for this - it suggest something numeric - and this is really more of a SQL statement or something - use the principle of least surprise when naming your variables!)
Try something like this:
DECLARE @stmt NVARCHAR(2000)
.....

SELECT @stmt =
   CASE @reportid
      WHEN 1 THEN
          N'select distinct u.id as userId, u.domain, u.isAdmin, u.email, u.canReport, a.[site],
  a.bldgNum, a.dataCenterNum, l.shortName, l.[description], a.canApprove, a.canComplete
  from locAdmin a inner join location l on (a.site=l.site and a.bldgNum = l.bldgNum
  and a.dataCenterNum = l.dataCenterNum) right outer join [user] u on u.id=a.userId
  and u.domain=a.domain where u.isAdmin = 1'

 EXEC (@stmt)


text:
Q: Is calling a method in Java the same as sending a message to an object in Objective-C? The Java's syntax for calling a method is the following:
object.methodName(...)

In Objective-C, the syntax for sending a message to an object is the following:
[object methodName:...]

Better, suppose you have an interface in Java (say Aj) and an object which implements this interface (say Bj).
Suppose also to have a protocol in Objective-C (say Ac) and a class which implements that protocol (say Bc).
Java:
Aj object = new Bj();
Aj.method();

Objective-C:
Ac* object = [[Bc alloc] init];
[Ac method];

Obviously it is different. But what I think is: in both cases the binding of the method to the right object is done dynamically, then I think that also Java uses messages and chooses the right method at runtime. Is it correct?
Can I affirm that also Java uses the "messages' mechanism" for calling object's methods?

A: According to this article, it looks like the Java VM has a similar "message" mechanism to Obj-C: http://www.informit.com/articles/article.aspx?p=1571983
Just breezed through it though, could be wrong.

A: One important difference is that Objective-C allows you to pass messages to nil. If you try to call a method on null in Java, it won't compile.


text:
Q: Schedule workflow to run at every 7 PM in Dynamics CRM I'm new to Dynamics CRM.
I want to send email to the client everyday at 7 PM. Also I want to create report in the email, showing sum of value of records created on current date.

*

*What we need to do for daily schedule, WF or Task? How to schedule?

*How can I get the condition to find the records created on current date and sum the value field of all the records?

A: Console application + Task scheduler is the combo we use for sending reminders/report summary.
Console app will do all the business logic/record filtering using QueryExpression or FetchXML & CRM Email Activity can be created to send out. Windows Task Scheduler can be configured to run on desired window.
If you designed the workflow already, you can still use the QE to filter records & call ExecuteWorkflowRequest message to invoke from Console app.


text:
Q: Custom logic on social Login Is there any way to override the default social login providers and add some additonal functionality?
I would like to create an account directly as soon as the first login takes place.
Also I would like to know where the auth controller is implemented. Could not find it within https://github.com/Azure/azure-mobile-apps-net-server repository.
Where are these login/auth controllers are coming from?

A: The authentication providers are in a module sitting in front of your service, so the authentication already happens before you get there.  You cannot add functionality to this module.
What you can do is call a custom API on login.  Normally, you would use the client.loginAsync() or client.loginWithProvider() methods (depending on the SDK in use).  Immediately after the login routine returns, call the client.invokeApi() (or the Async version) to call a custom API to do whatever you need to.


text:
Q: Get users who renew the package after expiry I have a table which gives information about which users bought a package, when it started, expired etc.
table:
+------+--------------+------------+------------+---------+
| user | Package_Type |   Start    |    End     | Status  |
+------+--------------+------------+------------+---------+
|  111 | A            | 2019-06-01 | 2019-06-18 | Valid   |
|  123 | A            | 2019-06-01 | 2019-06-18 | Valid   |
|  124 | A            | 2019-06-02 | 2019-06-06 | Expired | //Type A expired
|  124 | C            | 2019-06-02 | 2019-06-18 | Valid   |
|  125 | B            | 2019-06-03 | 2019-06-09 | Expired |
|  126 | B            | 2019-06-04 | 2019-06-20 | Valid   |
|  127 | B            | 2019-06-04 | 2019-06-07 | Expired |  // Type B expired
|  124 | B            | 2019-06-06 | 2019-06-18 | Valid   |  //Renewal to type B after expiry of type A
|  127 | B            | 2019-06-08 | 2019-06-18 | Valid   |  // Renwal to Type B
+------+--------------+------------+------------+---------+

In a time frame (let timeframe be WHERE start BETWEEN '2019-06-01' AND '2019-06-10') I wanted to know how many users whose package expired have renewed it.
Expected output is as follows
+------------+---------+---------+
|    Date    | Expired | Renewed |
+------------+---------+---------+
| 2019-06-01 |       0 |       0 |
| 2019-06-02 |       0 |       0 |
| 2019-06-03 |       0 |       0 |
| 2019-06-04 |       0 |       0 |
| 2019-06-05 |       0 |       0 |
| 2019-06-06 |       1 |       1 | // Expiry and renewal of user 124
| 2019-06-07 |       1 |       0 | // Expiry of user 127
| 2019-06-08 |       0 |       1 |//  Renewal of user 127
| 2019-06-09 |       1 |       0 |// Expiry of user 125
| 2019-06-10 |       0 |       0 |
+------------+---------+---------+

It is not necessary that user has to renew to same kind of package.

*

*For user 124 Type A expired but he renewed to Type B. (Also note that user 124 is still active for type C).

*So there can be cases where a type of package expires, but same user can be active on some other package and he can renew to some different package itself.

*I just want to know after expiry of package when the user renews.(Even if he is active on any other package)

Update 1
I also wanted above data to be represented as
+--------------+---------+---------+
| Package_Type | Expired | Renewed |
+--------------+---------+---------+
| A            |       1 |       0 |
| B            |       2 |       2 |
| C            |       0 |       0 |
+--------------+---------+---------+

I wanted a query in which if I change
WHERE start BETWEEN '2019-06-01' AND '2019-06-10')*
The above table will be updated according to start filter
SQL Server Link

A: You can use a cumulative max() to get the users who have renewed:
select t1.*,
       (case when max(case when status = 'expired' then [start] end) over (partition by user order by [start]) < [start] and
                  status = 'Valid'
             then 1 else 0
        end) as renewed
from table1 t1;

You can then use this information to summarize the data.  However, this summarization is rather tricky.  The renews are counted on the start date but the expires are on the expire date.  To handle this, it unpivots the data using apply.
select dte, sum(is_expire), sum(is_renew)
from (select t1.*,
             (case when max(case when status = 'expired' then [start] end) over (partition by user order by [start]) < start and
                        status = 'Valid'
                   then 1 else 0
              end) as renewed
      from table1 t1
     ) t1 cross apply
     (values (start, 0, renewed),
             ([end], case when status = 'expired' then 1 else 0 end, 0)
     ) v(dte, is_expire, is_renew)
group by dte
order by dte;

Here is a SQLFiddle.


text:
Q: What will be the Java Regular expression to validate the subsequent pattern and get anything inside curly braces as a string? abc12={p,q} What I need help with?
I want to write a Java Regular expression to validate the following expressions:
    fruits={apple,banana1,mango}

    fruits2={pear}

    x={}

All the above expressions should be considered valid. The general pattern is the following (but I am unable to write a regex as I am new to it):
someAlphaNumericString={empty,OneOrMoreCommaSeparated,Alpha123NumericStrings}

Some examples that should not be considered valid are:
        = {a,b}     // Missing string before =
    abc =           // Missing {} after =
    123 {1,3}       // Missing =

 **Conclusion**: There should be an alphanumeric string before =
                 There should be a =
                 There should be at least {} after =

Once the expression is valid, I want to get anything in between curly braces { } into a string.
What I have done so far?
So far, I have the following code:
 String tempStr = "a={b,c}";
 Pattern entry = Pattern.compile("\\{(.*?)\\}");  // This will match anything between {}
 Matcher matchPattern = entry.matcher(tempStr);

 String result;
 while(matchPattern.find()) {
    result = matchPattern.group(1);   // The result variable has "b,c"
 }

But this code lacks enough validation to meet all the aforementioned criteria.


text:
Q: Binding event in jQuery to be executed always in the end Is there a way to bind events to some object, and ensure that one of those events will be executed always last?
  $('#something').bind('click', function () {
    // do something first
  });
  $('#something').bind('click', function () {
    // do this always last
  });
  $('#something').bind('click', function () {
    // do this after first one
  });

Thank you!

A: May not be that good approach, but I found it pretty useful. You can use setTimeout without any parameter.
$('#something').bind('click', function () {

  setTimeout(function(){
    // This will always execute at last
    // Write your code here.
  });
});

Basically setTimeout() re-queues the function at the end of the execution queue.

A: You could bind all the handlers in one go:
$('#something').click(function () {
    first();
    second();
    third();
});

This comes with the added bonus of being a bit more efficient/lightweight than binding 3 separate listeners.

A: Edit: this can be useful but may not work as OP's question requires. The handler that fires on one does not get attached to the end of the current handler queue, it only runs on subsequent events.
For future readers, you can achieve this by proxying the handler using one().
$('.some-class').on('anevent', function(evt) {
    $(this).one(evt.type, function(evt) {
        //this code will fire after all other handlers for this event, except others that are proxied the same way
        console.log(evtO == evt, 'same event');
        if (evt.isDefaultPrevented())//can check signals to see whether you should still handle this event
            return;
        //do stuff last
    });
})

Later on somewhere else:
$('.some-class').on('anevent', function(evt) {
    //do stuff first
    evt.preventDefault();//can signal to prevent the proxied function. could use evt.stopPropagation() instead
})

The one caveat is that if a later handler uses a return false; or stopImmediatePropagation(), the function bound with one() will fire first the next time that event occurs, unless you explicitly unbind it somehow.


text:
Q: Counting the max number of consecutive runs in a column I have a dataset containing Site, Year and Total
structure(list(Site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c("B1",
"B10", "B100", "B101", "B102", "B103", "B104", "B105", "B106",
"B107", "B108", "B109", "B11", "B110", "B111", "B112", "B113",
"B114", "B115", "B116", "B117", "B118", "B119", "B12", "B120",
"B121", "B122", "B123", "B124", "B125", "B126", "B127", "B128",
"B129", "B13", "B130", "B131", "B132", "B133", "B134", "B135",
"B136", "B137", "B138", "B139", "B14", "B140", "B141", "B142",
"B142A", "B143", "B144", "B145", "B146", "B147", "B148", "B149",
"B15", "B150", "B151", "B152", "B153", "B154", "B155", "B156",
"B157", "B158", "B159", "B16", "B160", "B161", "B162", "B163",
"B164", "B165", "B166", "B168", "B169", "B17", "B170", "B170A",
"B171", "B172", "B173", "B174", "B175", "B176", "B177", "B178",
"B179", "B18", "B180", "B181", "B182", "B183", "B184", "B185",
"B186", "B187", "B188", "B189", "B19", "B190", "B191", "B192",
"B193", "B194", "B194A", "B195", "B196", "B197", "B198", "B199",
"B2", "B20", "B200", "B201", "B203", "B204", "B205", "B206",
"B207", "B208", "B21", "B211", "B212", "B213", "B214", "B215",
"B216", "B217", "B218", "B219", "B22", "B220", "B221", "B222",
"B223", "B224", "B225", "B226", "B227", "B228", "B229", "B23",
"B24", "B25", "B26", "B27", "B28", "B29", "B3", "B30", "B307",
"B31", "B32", "B33", "B34", "B35", "B36", "B37", "B38", "B39",
"B4", "B40", "B42", "B43", "B44", "B45", "B46", "B47", "B48",
"B49", "B5", "B51", "B52", "B53", "B54", "B55", "B56", "B57",
"B58", "B59", "B6", "B60", "B62", "B62A", "B63", "B64", "B65",
"B66", "B67", "B68", "B69", "B7", "B70", "B71", "B72", "B74",
"B75", "B76", "B77", "B78", "B79", "B79A", "B8", "B80", "B80A",
"B81", "B84", "B85", "B86", "B87", "B88", "B89", "B9", "B90",
"B91", "B92", "B93", "B94", "B95", "B96", "B97", "B98", "B99",
"B99A", "C0", "C1", "C10", "C101", "C102", "C103", "C104", "C105",
"C106", "C107", "C108", "C109", "C11", "C110", "C111", "C112",
"C113", "C114", "C115", "C116", "C117", "C118", "C119", "C12",
"C120", "C121", "C122", "C123", "C124", "C125", "C126", "C127",
"C128", "C129", "C13", "C130", "C131", "C132", "C133", "C134",
"C135", "C136", "C137", "C138", "C139", "C14", "C140", "C141",
"C142", "C143", "C144", "C145", "C146", "C147", "C148", "C149",
"C15", "C150", "C151", "C152", "C153", "C154", "C155", "C156",
"C157", "C158", "C159", "C16", "C160", "C160A", "C160B", "C161",
"C162", "C163", "C17", "C18", "C19", "C2", "C20", "C21", "C22",
"C23", "C24", "C24A", "C24B", "C24C", "C25", "C26", "C27", "C28",
"C29", "C3", "C30", "C31", "C32", "C33", "C34", "C34A", "C35",
"C36", "C37", "C38", "C39", "C3A", "C3B", "C4", "C40", "C41",
"C42", "C43", "C44", "C45", "C46", "C47", "C48", "C49", "C5",
"C50", "C51", "C52", "C53", "C54", "C55", "C56", "C57", "C58",
"C59", "C6", "C60", "C61", "C61A", "C62", "C63", "C7", "C8",
"C9", "C9A", "CP0", "CP000", "CP1", "CP10", "CP100", "CP101",
"CP102", "CP103", "CP104", "CP105", "CP107", "CP108", "CP109",
"CP11", "CP110", "CP111", "CP112", "CP113", "CP114", "CP115",
"CP116", "CP117", "CP118", "CP119", "CP12", "CP120", "CP121",
"CP122", "CP123", "CP124", "CP125", "CP126", "CP127", "CP128",
"CP129", "CP13", "CP130", "CP131", "CP132", "CP133", "CP134",
"CP135", "CP136", "CP137", "CP138", "CP139", "CP14", "CP140",
"CP141", "CP142", "CP143", "CP144", "CP145", "CP146", "CP147",
"CP148", "CP149", "CP14A", "CP15", "CP150", "CP151", "CP152",
"CP153", "CP154", "CP155", "CP156", "CP157", "CP158", "CP16",
"CP17", "CP18", "CP188", "CP18A", "CP19", "CP191", "CP2", "CP20",
"CP21", "CP215", "CP22", "CP23", "CP24", "CP25", "CP26", "CP27",
"CP28", "CP29", "CP3", "CP30", "CP31", "CP32", "CP33", "CP34",
"CP35", "CP36", "CP37", "CP38", "CP38A", "CP39", "CP4", "CP40",
"CP40A", "CP41", "CP42", "CP42A", "CP43", "CP5", "CP54", "CP55",
"CP5A", "CP5B", "CP6", "CP64", "CP65", "CP7", "CP72", "CP73",
"CP8", "CP80", "CP82", "CP89", "CP9", "CP95", "CP97", "CP9A",
"EX0", "EX041D", "EX059", "EX064", "EX1", "EX10", "EX100", "EX101",
"EX102", "EX103", "EX104", "EX105", "EX106", "EX107", "EX108",
"EX109", "EX10A", "EX11", "EX110", "EX111", "EX112", "EX113",
"EX114", "EX115", "EX116", "EX117", "EX118", "EX119", "EX12",
"EX120", "EX121", "EX122", "EX123", "EX124", "EX125", "EX126",
"EX127", "EX12A", "EX13", "EX13A", "EX14", "EX14A", "EX14B",
"EX15", "EX16", "EX17", "EX18", "EX18A", "EX19", "EX19A", "EX2",
"EX20", "EX21", "EX22", "EX23", "EX24", "EX25", "EX25A", "EX26",
"EX27", "EX28", "EX29", "EX29A", "EX3", "EX30", "EX31", "EX31A",
"EX32", "EX32A", "EX33", "EX34", "EX34A", "EX35", "EX35A", "EX36",
"EX37", "EX38", "EX38A", "EX39", "EX39A", "EX39B", "EX39C", "EX3A",
"EX4", "EX40", "EX41", "EX41A", "EX41B", "EX41C", "EX41D", "EX41E",
"EX42", "EX42A", "EX43", "EX43A", "EX43B", "EX43C", "EX43D",
"EX43E", "EX44", "EX45", "EX46", "EX47", "EX47A", "EX48", "EX48A",
"EX49", "EX49A", "EX49B", "EX49C", "EX5", "EX50", "EX51", "EX51A",
"EX51B", "EX51C", "EX51D", "EX52", "EX53", "EX54", "EX55", "EX56",
"EX57", "EX58", "EX59", "EX5A", "EX5B", "EX6", "EX60", "EX61",
"EX62", "EX62A", "EX62B", "EX62C", "EX62D", "EX62E", "EX62F",
"EX62G", "EX62H", "EX62I", "EX62X", "EX63", "EX64", "EX65", "EX65A",
"EX66", "EX67", "EX68", "EX69", "EX69A", "EX7", "EX70", "EX71",
"EX71A", "EX72", "EX72A", "EX73", "EX73A", "EX74", "EX75", "EX75A",
"EX76", "EX77", "EX78", "EX79", "EX7A", "EX8", "EX80", "EX80A",
"EX81A", "EX84", "EX85", "EX86", "EX87", "EX88", "EX89", "EX8A",
"EX9", "EX90", "EX91", "EX92", "HE0", "HE1", "HE2", "HE3", "HE4",
"HE5", "MP1", "MP10", "MP100", "MP11", "MP12", "MP13", "MP14",
"MP15", "MP16", "MP17", "MP18", "MP19", "MP2", "MP20", "MP21",
"MP22", "MP23", "MP24", "MP25", "MP26", "MP27", "MP28", "MP29",
"MP3", "MP30", "MP31", "MP32", "MP33", "MP34", "MP34A", "MP35",
"MP36", "MP37", "MP38", "MP39", "MP4", "MP40", "MP41", "MP42",
"MP43", "MP44", "MP45", "MP46", "MP47", "MP48", "MP49", "MP5",
"MP50", "MP51", "MP52", "MP53", "MP54", "MP55", "MP56", "MP57",
"MP58", "MP59", "MP6", "MP60", "MP61", "MP62", "MP63", "MP64",
"MP65", "MP66", "MP66A", "MP67", "MP68", "MP69", "MP7", "MP70",
"MP71", "MP72", "MP73", "MP74", "MP75", "MP76", "MP77", "MP78",
"MP79", "MP8", "MP80", "MP81", "MP82", "MP83", "MP84", "MP85",
"MP86", "MP87", "MP88", "MP89", "MP9", "MP90", "MP91", "MP92",
"MP93", "MP94", "MP95", "MP96", "MP97", "MP98", "O1", "O10",
"O100", "O101", "O102", "O103", "O104", "O105", "O106", "O107",
"O108", "O109", "O11", "O110", "O111", "O112", "O113", "O114",
"O115", "O116", "O117", "O118", "O119", "O12", "O13", "O131",
"O13A", "O14", "O15", "O16", "O17", "O18", "O19", "O2", "O20",
"O201", "O202", "O203", "O204", "O205", "O206", "O207", "O208",
"O209", "O21", "O210", "O211", "O212", "O213", "O214", "O215",
"O216", "O217", "O218", "O219", "O22", "O220", "O221", "O222",
"O223", "O224", "O225", "O226", "O227", "O228", "O229", "O23",
"O230", "O231", "O232", "O234", "O235", "O236", "O237", "O238",
"O239", "O24", "O240", "O241", "O242", "O243", "O244", "O245",
"O246", "O248", "O249", "O25", "O250", "O251", "O252", "O253",
"O254", "O255", "O256", "O257", "O258", "O259", "O26", "O260",
"O261", "O27", "O27A", "O28", "O29", "O3", "O30", "O30A", "O31",
"O31A", "O32", "O33", "O34", "O35", "O36", "O37", "O38", "O38A",
"O38B", "O39", "O4", "O40", "O41", "O42", "O43", "O44", "O45",
"O46", "O47", "O48", "O49", "O5", "O50", "O51", "O52", "O53",
"O54", "O55", "O56", "O57", "O58", "O59", "O5A", "O6", "O60",
"O61", "O62", "O63", "O64", "O65", "O66", "O67", "O68", "O69",
"O7", "O70", "O71", "O72", "O73", "O73A", "O73B", "O74", "O75",
"O75A", "O75B", "O75C", "O75D", "O76", "O77", "O78", "O78A",
"O79", "O8", "O80", "O81", "O82", "O83", "O84", "O85", "O86",
"O87", "O88", "O88A", "O89", "O9", "O90", "O92", "O93", "O94",
"O95", "O96", "O97", "O999", "P1", "P10", "P100", "P101", "P102",
"P103", "P104", "P105", "P106", "P107", "P108", "P109", "P11",
"P110", "P111", "P112", "P113", "P115", "P116", "P117", "P118",
"P119", "P12", "P120", "P121", "P122", "P123", "P124", "P125",
"P126", "P13", "P14", "P15", "P16", "P17", "P18", "P19", "P2",
"P20", "P21", "P22", "P23", "P24", "P3", "P4", "P5", "P6", "P7",
"P8", "P9", "SM1", "SM2", "SM4", "SM5", "SM6", "SW1", "SW10",
"SW101", "SW101A", "SW102", "SW103", "SW104", "SW104A", "SW104B",
"SW105", "SW106", "SW107", "SW108", "SW109", "SW109A", "SW11",
"SW110", "SW111", "SW112", "SW113", "SW114", "SW115", "SW116",
"SW117", "SW118", "SW119", "SW12", "SW120", "SW121", "SW122",
"SW123", "SW124", "SW125", "SW126", "SW127", "SW128", "SW129",
"SW12A", "SW13", "SW130", "SW131", "SW132", "SW133", "SW134",
"SW14", "SW15", "SW16", "SW17", "SW18", "SW19", "SW2", "SW20",
"SW21", "SW22", "SW23", "SW24", "SW25", "SW26", "SW27", "SW28",
"SW29", "SW3", "SW30", "SW31", "SW32", "SW33", "SW34", "SW35",
"SW36", "SW37", "SW38", "SW39", "SW4", "SW40", "SW41", "SW42",
"SW43", "SW44", "SW45", "SW46", "SW47", "SW48", "SW49", "SW49A",
"SW5", "SW50", "SW51", "SW52", "SW53", "SW54", "SW55", "SW56",
"SW57", "SW58", "SW59", "SW6", "SW60", "SW61", "SW61A", "SW62",
"SW63", "SW64", "SW65", "SW66", "SW67", "SW68", "SW69", "SW7",
"SW70", "SW71", "SW72", "SW73", "SW74", "SW75", "SW76", "SW77",
"SW78", "SW79", "SW8", "SW80", "SW80A", "SW81", "SW82", "SW83",
"SW84", "SW84A", "SW85", "SW86", "SW87", "SW88", "SW89", "SW9",
"SW90", "SW93", "SW94", "SW96", "SW98", "SW99", "W1", "W10",
"W100", "W101", "W102", "W103", "W103A", "W104", "W105", "W11",
"W12", "W13", "W14", "W15", "W16", "W16A", "W17", "W17A", "W18",
"W19", "W2", "W20", "W200", "W201", "W202", "W203", "W204", "W205",
"W206", "W207", "W208", "W209", "W20A", "W21", "W210", "W211",
"W22", "W22A", "W23", "W24", "W25", "W26", "W27", "W28", "W29",
"W3", "W30", "W31", "W32", "W33", "W34", "W35", "W36", "W37",
"W38", "W39", "W4", "W40", "W41", "W42", "W43", "W43A", "W44",
"W45", "W46", "W47", "W48", "W49", "W4A", "W4B", "W5", "W50",
"W51", "W51A", "W52", "W53", "W54", "W54N", "W55", "W56", "W57",
"W58", "W59", "W6", "W60", "W61", "W62", "W63", "W64", "W64A",
"W64B", "W65", "W66", "W67", "W68", "W69", "W7", "W70", "W71",
"W72", "W73", "W74", "W75", "W75A", "W76", "W77", "W78", "W79",
"W8", "W80", "W81", "W82", "W83", "W84", "W85", "W86", "W87",
"W88", "W89", "W9", "W90", "W91", "W92", "W93", "W94", "W95",
"W96", "W97", "W98", "W98A", "W99", "W99A", "X0", "X10", "X13",
"X14", "X17", "X2", "X204", "X209", "X221", "X23", "X24", "X25",
"X26", "X28", "X3", "X30", "X32", "X33", "X34", "X35", "X37",
"X4", "X40", "X41", "X42", "X48", "X49", "X5", "X52", "X53",
"X54", "X57", "X58", "X59", "X6", "X61", "X62", "X63", "X65",
"X66", "X67", "X68", "X7", "X70", "X71", "X73", "X74", "X78",
"X80", "X82", "X86", "X87", "X88", "X90", "X96", "XBN1", "XBN3",
"XBN6", "XBY1", "XBY13", "XBY16", "XBY18", "XBY19", "XD1", "XD10",
"XD11", "XD12", "XD13", "XD14", "XD15", "XD16", "XD18", "XD19",
"XD2", "XD20", "XD21", "XD22", "XD23", "XD24", "XD25", "XD26",
"XD3", "XD31", "XD35", "XD36", "XD37", "XD38", "XD4", "XD5",
"XD6", "XD7", "XD8", "XD9", "XDE1", "XDE12", "XDE14", "XDE15",
"XDE2", "XDE3", "XDE4", "XDE7", "XDE9", "XF1", "XF10", "XF11A",
"XF11C", "XF17", "XF1B", "XF20", "XF20B", "XF21", "XF24", "XF25A",
"XF25B", "XF25C", "XF25D", "XF26", "XF3", "XF4", "XFR10", "XFR13",
"XFR23", "XFR7", "XG2", "XG3", "XG4", "XG6", "XG9", "XH1", "XH11",
"XH2", "XH3", "XH4", "XH5", "XH6", "XH6B", "XH7A", "XH7B", "XH8",
"XH9", "XHE20", "XHE28", "XHG11", "XHG5", "XHG8", "XHG9", "XJ1",
"XJ15", "XJ17", "XJ22", "XJ28", "XJ3", "XJ33", "XJ38", "XJ39",
"XJ4", "XJ40", "XJ41", "XJ42", "XJ8", "XM3", "XMX1", "XN1", "XN2",
"XN3", "XN4", "XN5A", "XN5B", "XN5C", "XN5D", "XN7", "XN8", "XN9",
"XS1A", "XS1B", "XS4", "XS7", "XSC1", "XSC10", "XSC11", "XSC14",
"XSC2", "XSC3", "XSC5", "XSC6", "XSC8", "XSW5", "XSW9", "XT10",
"XT11", "XT12", "XT13", "XT14", "XT3", "XT4", "XT5", "XT6", "XT7",
"XT8", "XT9", "XTH3", "XTH8", "XW1", "XW14", "XW19B", "XW2",
"XW20", "XW21", "XW22", "XW23", "XW23C", "XW5", "XWF3", "XWF5",
"XWY16", "XWY19A", "XWY19B", "XWY25", "XWY3", "XWY4"), class = "factor"),
    Year = c(1961L, 1983L, 1986L, 1987L, 1990L, 1996L, 2001L,
    2002L, 2006L, 2012L, 1954L, 1973L, 1977L, 1979L, 1980L, 1981L,
    1985L, 1988L, 1991L, 1993L, 2001L, 2002L, 2007L, 2008L, 2010L,
    2013L, 2018L, 1960L, 1961L, 1980L, 1983L, 1986L, 1998L, 2000L,
    2001L, 2004L, 2007L, 2010L, 1956L, 1981L, 1982L, 1994L, 2003L,
    2011L, 1959L, 1961L, 1965L, 1987L, 1989L, 2002L), Total = c(8L,
    5L, 7L, 6L, 11L, 7L, 7L, 14L, 8L, 10L, 9L, 9L, 6L, 10L, 7L,
    8L, 10L, 2L, 3L, 7L, 5L, 13L, 6L, 7L, 7L, 4L, 9L, 7L, 8L,
    7L, 6L, 4L, 6L, 6L, 14L, 7L, 8L, 9L, 9L, 9L, 7L, 10L, 4L,
    6L, 4L, 4L, 6L, 11L, 7L, 6L)), row.names = 2:51, class = "data.frame")

I have been trying to count the max number of consecutive years that a site has been used. The Total column doesn't matter for now. I can isolate consecutive years and identify them using variations of
s <- split(df$Year, cumsum(c(TRUE, diff(df$Year) != 1)))

but this doesn't give me what I want which ideally would look something like
Site   Max Consecutive Years  Range
B10    10                     1947-1956
B107   2                      2000-2001
B122   8                      1988-1995

If anyone can point me in the right direction I would be very grateful

A: Maybe this helps, there are certainly faster ways. The idea is to build an indicator whether there are consecutive rows and filter for more than one occurence per group (i.e. consecutive rows).
df %>%
  group_split(Site) %>%
  map_dfr(~ .x %>%
    mutate(consec_helper = cumsum(c(1, diff(Year) != 1))) %>%
    group_by(consec_helper) %>%
    filter(n() > 1) %>%
    mutate(
      count_consectuive_years = n(),
      period = stringr::str_c(first(Year), "-", last(Year))
    ) %>%
    ungroup()) %>%
  select(-consec_helper, -Year) %>%
  distinct(Site, period, .keep_all = T)

Result:
Site Total count_consectuive_years    period
   B1     7                       2 1986-1987
   B1     7                       2 2001-2002
  B10    10                       3 1979-1981
  B10     5                       2 2001-2002
  B10     6                       2 2007-2008
 B100     7                       2 1960-1961
 B100     6                       2 2000-2001
 B101     9                       2 1981-1982

A: Another solution using dplyr
df2 <- df %>% group_by(Site) %>% mutate(a=cumsum(c(TRUE, diff(Year) != 1))) %>% #Using your variable
  group_by(Site,a) %>% summarise(Range = if_else(min(Year)!=max(Year),paste(min(Year),max(Year),sep="-"),as.character(min(Year)))
                                 , Max = sum(Total)) %>% #Calculating ranges and number of visits grouping by your variable
  group_by(Site) %>% slice(which.max(Max)) %>% select(-a) # Taking max, deleting a

A: Another possible solution:
library(tidyverse)

df %>%
  group_by(Site) %>%
  mutate(aux = (Year == (lead(Year, default = 0) - 1)))  %>%
  mutate(aux2 = data.table::rleid(aux)) %>%
  ungroup() %>%
  filter(aux) %>%
  add_count(Site, aux2) %>%
  mutate(n = n + 1) %>%
  group_by(Site, aux2, n) %>%
  summarise(Range = str_c(min(Year), max(Year)+1, sep = "-"), .groups = "drop") %>%
  select(-aux2)

#> # A tibble: 8 × 3
#>   Site      n Range
#>   <fct> <dbl> <chr>
#> 1 B1        2 1986-1987
#> 2 B1        2 2001-2002
#> 3 B10       3 1979-1981
#> 4 B10       2 2001-2002
#> 5 B10       2 2007-2008
#> 6 B100      2 1960-1961
#> 7 B100      2 2000-2001
#> 8 B101      2 1981-1982


text:
Q: Drawing minarea rectangle for convex hull Hi i've been trying to recognize hand signatures(numbers) using OpenCV.i am encountering a problem where 1 and 2 show the same number of convexity defects.
One way i thought i could rectify this was by drawing a Minbounding rectangle..and find the ratio of the area of the convex hull to that of the bounding rectangle.
However im not aware how to do this.
vector<vector<Point>> hull;

The index of the hull i am interested in is say k;
How do i draw a rotated rectangle for this convex hull?

A: // Assuming
// vector<vector<Point>> hull;
// Mat3b frame;

if((k >= 0) && (k < hull.size()) && (!hull[k].empty()))
{
    RotatedRect rotated = minAreaRect(hull[k]);
    Point2f rect_points[4];
    rotated.points( rect_points );
    for( int j = 0; j < 4; j++ ) {
       line( frame, rect_points[j], rect_points[(j+1)%4], Scalar(255,0,0), 1, 8 );
    }
}


text:
Q: How to delete ALL Cookies from windows phone WebBrowser control In my app I use WebBrowser control. User can visit http://mail.google.com then without logging out from google.com he visits http://twitter.com then http://abcd.com etc.
Now my requirement is to do the fresh start of the WebBrowser control and revisit those website and force the user to login again on those sites.
How can I clear ALL Cookies from windows phone WebBrowser control in WP7? I tried few  JavaScript examples available in net. Nothing worked. Can you anybody help me on this?

A: the control is not to give you that fine grained control over cookies etc. it is meant to be use to display html data.
since a given instance of webbrowser control would cache data in given session, I'd suggest you either create new instance either by redirecting user to that page or doing so onclick etc


text:
Q: Equivalence of norm Am I right, when I state the following:
Let $p\in[1,\infty) \text{ then }\exists c>0 \text{ s.t. } (\sum_{i=1}^n |a_i| )^p\leq c \sum_{i=1}^n |a_i|^p $ where c is independent of the vector $a=(a_1,\dots,a_n)$.
This follows trivially by the fact that all norms of finite vectorspaces are equivalent, right?
Cheers

A:
This follows trivially by the fact that all norms of finite vector spaces are equivalent, right?

Yes, but it may be a too sophisticated tool. An alternative way is to use the convexity of the map $t\geqslant 0\mapsto t^p$. Notice that $c$ depends on the dimension $n$.

A: This is correct.
Since we are only dealing with absolute values of the terms, let's assume that $a_k\ge0$.
It also follows from Jensen's Inequality, and the fact that $x\mapsto x^{q/p}$ is convex when $p\le q$, that
$$
\left(\frac1n\sum_{k=1}^ na_k^p\right)^{q/p}
\le\frac1n\sum_{k=1}^ n\left(a_k^p\right)^{q/p}\tag{1}
$$
Taking $q^\text{th}$ roots, gives
$$
\left(\frac1n\sum_{k=1}^ na_k^p\right)^{1/p}
\le\left(\frac1n\sum_{k=1}^ na_k^q\right)^{1/q}\tag{2}
$$
which is
$$
\|a_k\|_p\le n^{\frac{q-p}{qp}}\|a_k\|_q\tag{3}
$$
In the other direction, find an integer $m\ge\frac qp$, then by simply tossing out terms we have
$$
\left(\sum_{k=1}^na_k^p\right)^m
\ge\sum_{k=1}^na_k^{pm}\tag{4}
$$
Taking $pm^\text{th}$ roots and using $(3)$,
$$
\begin{align}
\|a_k\|_p
&=\left(\sum_{k=1}^na_k^p\right)^{\frac1p}\\
&\ge\left(\sum_{k=1}^na_k^{pm}\right)^{\frac1{pm}}\\
&=\|a_k\|_{pm}\\
&\ge n^{\frac{q-pm}{qpm}}\|a_k\|_q\tag{5}
\end{align}
$$
That is,
$$
n^{\frac{q-pm}{qpm}}\|a_k\|_q\le\|a_k\|_p\le n^{\frac{q-p}{qp}}\|a_k\|_q\tag{6}
$$


text:
Q: Eclipse Referenced Library jar is detected by compiler, but not at run time I added a jar file to my project by following these steps:
Right click on your project
Select Build Path
Click on Configure Build Path
Click on Libraries and select Add External JARs
Select the jar file from the required folder
Click and Apply and Ok

This imports my jar file just fine, and the Java compiler can detect references to the new library just fine.
When I run the application though, it crashes, saying it doesn't recognize the library:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONObject
    at com.ebook.Main.main(Main.java:14)
Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONObject
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 1 more

What am I doing wrong when importing this jar (json-simple)?

A: If you have added the jar files properly then you should check in your com.ebook.Main.main(Main.java:14) class whether the related import statement is proper or not.after that clean and rebuild.Hope this will solve your problem.

A: When you are running the jar file, if you are using library's you need to setup the classpath:
java -cp C:\foo\bar\JsonLibrary.jar your_jar_file.jar
 this answer might help you setup your classpath.
Note: The reason why it worked in Eclipse, is because Eclipse automatically handles the classpath for you, but after compiling you need handle it yourself.


text:
Q: How to define the same names from one sheet to other sheets in the same workbook? I created a form on an Excel sheet where I defined names (not in contiguous cells), the defined names already entered on the "Source" form like
Name: zzz xxx
Address: 456 mmm dddd
Number: 123456
Date: 20-Dec-2019

I want to define the same names on other existing forms on other sheets that do not have names defined.
Then, I need to combine all data from all sheets copied to a new sheet and all data collected from all sheets to be in a table with data in columns and rows like this
Name     Address        Number  Date
zzz xxx  456 mmm dddd   123456  20-Dec-2019
tyr utr  677 gjgjh      765768  30-Nov-2018

Thanks for the support and advice.


text:
Q: Extract only Capital letters from a string - javascript  function onlyCapitalLetters (str)

 {

let newStr = "";

for (let i = 0; i < str.length; i ++) {
    if (str[i].includes("ABCDEFGHIJKLMNOPQRSTUVWXYZ")) {
        newStr += str[i];

    }
}
return newStr;
}

onlyCapitalLetters("AMazing"); // should get AM

Hi, I'm trying to write a function, that will return a new string with only capital letters. When I try to run this function, I don't see any output. Please help!!!

A: In practice, you would probably use a regex approach here:

function onlyCapitalLetters (str) {
    return str.replace(/[^A-Z]+/g, "");
}

console.log(onlyCapitalLetters("AMazing")); // should get AM

A: Include requires everything within to be included in the provided string. Use regex instead

function onlyCapitalLetters (str) {
  let newStr = "";

  for (let i = 0; i < str.length; i++) {
      if (str[i].match(/[A-Z]/)) {
          newStr += str[i];
      }
   }
   return newStr;
}

console.log(onlyCapitalLetters("AMazing")); // should get AM

You could one line this function like this

const capital = (str) => str.split('').filter(a => a.match(/[A-Z]/)).join('')

console.log(capital("AMazinG"))

A: The string of letters (uppercaseLetters) should include the current letter (str[i]), and not the other way around:

function onlyCapitalLetters(str) {
  let newStr = "";

  const uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  for (let i = 0; i < str.length; i++) {
    if (uppercaseLetters.includes(str[i])) {
      newStr += str[i];
    }
  }

  return newStr;
}

console.log(onlyCapitalLetters("AMazing")); // should get AM

A better option would be to use String.match() to find all uppercase letters. The match method returns an array of letters found, or null if none found, so we'll need to use an empty array as a fallback. Join the resulting array with an empty string.

function onlyCapitalLetters(str) {
  return (str.match(/[A-Z]/g) || []).join('');
}

console.log(onlyCapitalLetters("AMazing")); // should get AM

A: String.Includes() checks for all the characters in the string.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
You can also use ASCII code for the Characters to verify if it is a capital letter.
function onlyCapitalLetters (str) {
 let newStr = "";

    for (let i = 0; i < str.length; i++) {
      if (str[i].charCodeAt(0) >= 65 && str[i].charCodeAt(0) <= 90) {
          newStr += str[i];
       }
    }
  return newStr;
}

console.log(onlyCapitalLetters("AMazing"));


text:
Q: Use complex numbers to prove that the composition of rotations is another rotation From ACOPS by Paul Zeitz, q4.2.30, a section on complex numbers.
"Let $R_a(\theta)$ denote the transformation of the plane that rotates everything about the center point $a$ by $\theta$ radians counterclockwise. Prove the interesting fact that the composition of $R_a(\theta)$ and $R_b(\phi)$ is another rotation $R_c(\alpha)$. Find $c,\alpha$ in terms of $a,b,\theta,\phi$."
I've tried to argue that $R_a(\theta)$ maps the point $z$ on the complex plane to $z^\prime = e^{i\theta}(z-a)+a,$ and therefore the composition of $R_a(\theta)$ and $R_b(\phi)$ maps $z$ to $z^\prime = e^{i\phi}(e^{i\theta}(z-a)+a-b)+b.$ I have then tried to write this expression in the form $e^{i(\phi+\theta)}(z-c)+c$ but have been unsuccessful.

A: You need to solve
$$e^{i\phi}(e^{i\theta}(z-a)+a-b)+b=e^{i(\phi+\theta)}(z-c)+c$$ for $c$.
Rearranging the terms, you get
$$e^{i(\phi+\theta)}z+e^{i\phi}\left(\left(1-e^{i\theta}\right)a-b\right))+b=e^{i(\phi+\theta)}z+c\left(1-e^{i(\phi+\theta)}\right),$$
which validates the claim about composition and yields
$$c=\frac{e^{i\phi}\left(\left(1-e^{i\theta}\right)a-b\right))+b}{1-e^{i(\phi+\theta)}}.$$

A: Hint: Try to find a fixed point $c$, that is $$(R_b\circ R_a) (c) =c$$
that should be a center of a new rotation. Anyway, you are right about rotation angle, which is pretty obvious from formula you derive.

If my calculation are correct it should be $$ c={{e^{i\phi}(ae^{i\theta}-a+b)-b.}\over e^{i(\phi+\theta)}-1 }$$


text:
Q: show mysql myisam locks when dropping or renaming a table with myisam storage engine, I realize that it's waiting for table metadata lock, however, show full processlist doesn't reveal the offending query.  any idea?

| 462 | root | xxx.xxx.xxx.xx:54658 | mydb | Sleep   | 1162 |                                 | NULL                                                 |
| 465 | root | localhost           | mydb | Query   |    0 | NULL                            | show full processlist                                |
| 466 | root | localhost           | mydb | Query   |  125 | Waiting for table metadata lock | alter table mytable rename to mytable_junk |

A: If you are using MySQL 5.5, there is a bug report on it.
If fact, click here for an explanation of metadata locking. It is meant to protect tables from getting DDL executed against it while in the middle of a transaction.
What seems strange is that you are getting this on a MyISAM table.

A: I was trying to convert a table collation as follows:
 alter table xxx convert to character set utf8 collate utf8_unicode_ci;

I then noticed that on the "show full processlist" the request was freeze on the following state "Waiting for table metadata lock"
To resolve the issue, I opened another console in parallel and launched the following SQL command :
flush tables

Regards


text:
Q: Adding net462 library in .net core project I was able to configure .net462 into asp.net core project based on suggestions here and here
But  now I want to reference a library that was developed in .net 4.6.2. When I add that project as net462 framework dependency I get error

The dependency MyLibrary could not be resolved

This is my entire project.json
{
  "dependencies": {
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ],
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.0.0",
          "type": "platform"
        }
      }
    },
    "net462": {
      "dependencies": {
        "MyLibrary": {
          "target": "project"
        }
      }
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Note that I'm adding MyLibrary dependency for .net462 framework not as global dependency


text:
Q: Trying to decode hex to binary representation in C# I'm saving a bitarray (40 bits) from Python (using bitarray lib) to Redis.
When I retrieve this value from Redis, I get: \xe8\x00\x00\x00\x00
How do I convert this value to "01010101" in C#?
Thank you!
EDIT:
When i use this form:
http://easycalculation.com/hex-converter.php, the binary value returned is what i'm expecting.

A: You could do this:
// Chop up the string into individual hex values
string[] hexStrings = hexString.Split(new[] { "\\x" }, StringSplitOptions.RemoveEmptyEntries);

// Convert the individual hex strings into integers
int[] values = hexStrings.Select(s => Convert.ToInt32(s, 16)).ToArray();

// Convert the integers into 8-character binary strings
string[] binaryStrings = values.Select(v => Convert.ToString(v, 2).PadLeft(8, '0')).ToArray();

// Join the strings together
string binaryString = string.Join("", binaryStrings);

EDIT - Here's an example of what you could do if you want to use a BitArray:
// Chop up the string into individual hex values
string[] hexStrings = hexString.Split(new[] { "\\x" }, StringSplitOptions.RemoveEmptyEntries);

// Convert the individual hex strings into bytes
byte[] bytes = hexStrings.Select(s => Convert.ToByte(s, 16)).ToArray();

BitArray bitArray = new BitArray(bytes);


text:
Q: I reinstalled MikTEX and installed it but i can't load the .bib file again? I uninstalled MikTex and installed it. Now, when i want to add .bib file to Winedt I face this warning:

LaTeX Warning: Empty `thebibliography' environment on input line 11

I searched for a good solution, but I couldn't find.
My tex code is like this:
\documentclass[twocolumn]{svjour3}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{RN34,
   author = {Hu, Xiaoqing and Bao, Ming and Zhang, Xiao-Ping and Guan, Luyang and Hu, Yu Hen},
   title = {Generalized Iterated Kalman Filter and its Performance Evaluation},
   journal = {IEEE Trans. Signal Processing},
   volume = {63},
   number = {12},
   pages = {3204-3217},
   year = {2015},
   type = {Journal Article}
}
\end{filecontents}

\begin{document}

\cite{RN34}

\bibliographystyle{spbasic}
\bibliography{FinalSpringerRefs}

\begin{thebibliography}{}

\bibitem{Ref1}
Hu, X., Hu, Y.-H., Xu, B.: Generalised Kalman filter tracking with multiplicative measurement noise in a wireless sensor network. IET Signal Processing 8(5), 467-474 (2013).

\end{thebibliography}

\end{document}

and my .bbl file contains:
\begin{thebibliography}{0}
\providecommand{\natexlab}[1]{#1}
\providecommand{\url}[1]{{#1}}
\providecommand{\urlprefix}{URL }
\expandafter\ifx\csname urlstyle\endcsname\relax
  \providecommand{\doi}[1]{DOI~\discretionary{}{}{}#1}\else
  \providecommand{\doi}{DOI~\discretionary{}{}{}\begingroup
  \urlstyle{rm}\Url}\fi
\providecommand{\eprint}[2][]{\url{#2}}

\end{thebibliography}

A: Well, there is a missunderstanding!
If you use \bibliography{} you need not to add your following code:
\begin{thebibliography}{}

\bibitem{Ref1}
Hu, X., Hu, Y.-H., Xu, B.: Generalised Kalman filter tracking with multiplicative measurement noise in a wireless sensor network. IET Signal Processing 8(5), 467-474 (2013).

\end{thebibliography}

Delete that in your mwe to get (see the changed parameter for \bibliography please to fit your created bib file with filecontents)
\documentclass[twocolumn]{svjour3}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{RN34,
   author = {Hu, Xiaoqing and Bao, Ming and Zhang, Xiao-Ping and Guan, Luyang and Hu, Yu Hen},
   title = {Generalized Iterated Kalman Filter and its Performance Evaluation},
   journal = {IEEE Trans. Signal Processing},
   volume = {63},
   number = {12},
   pages = {3204-3217},
   year = {2015},
   type = {Journal Article}
}
\end{filecontents}

\begin{document}

\cite{RN34}

\bibliographystyle{spbasic}
\bibliography{\jobname} % <=============================================

\end{document}

and the result:


text:
Q: Offline storage HTML5 using jQuery I have a simple web mobile app that is calculating values in given fields. I've been trying to  save the values on the local host in the browser and haven't had any luck. I am using jQuery to save the values, but somehow it doesn't work.
     <script>
    $(document).ready(function() {
$('#field_wc').val(localStorage.getItem('wc') );
$('#field_tax').val(localStorage.getItem('tax') );
$('#field_sui').val( localStorage.getItem('sui') );
$('#field_o').val( localStorage.getItem('o') );
$('#field_fp').val( localStorage.getItem('fp') );
$('#field_misc').val( localStorage.getItem('misc') );
$('#field_t').val( localStorage.getItem('t') );

    });

    $('#field_tax').keyup(function() {
$('#field_wc').val( localStorage.setItem('wc') );
$('#field_tax').val( localStorage.setItem('tax') );
$('#field_sui').val( localStorage.setItem('sui') );
$('#field_o').val( localStorage.setItem('o') );
$('#field_fp').val( localStorage.setItem('fp') );
$('#field_misc').val( localStorage.setItem('misc') );
$('#field_t').val( localStorage.setItem('t') );

    });
    </script>

A: $(document).ready(function() {
  var
    key,
    fields = ['wc', 'tax', 'sui', 'o', 'fp', 'misc', 't'];

  for(key in fields) {
    (function (){
      var
        name = fields[key],
        field = $('#field_' + name)
          .val(localStorage.getItem(name) || '')
          .on('keyup', function() {
            localStorage.setItem(name, field.val());
          });
    }());
  }
});

Hi! I optimized your script and fixed a few other problems with it: http://jsfiddle.net/q78d8/4/

*

*Using locally scoped variables to store the jQuery objects in is the biggest performance improvement. In your original script you made jQuery create those over and over again, for every keyup event fired

*I think you wanted to bind each input to the "Save" function, but realize, you don't have to update values which haven't changed! If the user updated #field_tax, only save that value

*Remember you can Chain jQuery methods

*I used a little trick here, where I know that the return value of each chain, would still be the jQuery object I originally selected, so I could store the object in the same line in which I assigned a keyup handler on it & filled the value with what was in the localstorage

*I wrapped the whole thing in a for loop, and an self-invoking function, to create an easy-to-do-maintenance-on script

Edit --
I left out that you used setItem incorrectly, since others already told you.

A: As mdmullinax said, your setItem syntax is the problem.  Also, you may want to abstract those calls, as well as checking that the key yet exists.  Here's the basic abstraction layer I use; I also namespace my keys to avoid clashes between different scripts.  The isJSON argument is optional, depending if I want to get back a stored JSON string, or have a stored JSON string converted back to an object for me.
Also, your keyup should be inside of document ready, and (assuming you're using the latest jQuery [1.7.1]), you'd probably want to use .on() instead of .keyup()
$(document).ready(function() {

    var namespace = 'user1078259';

    storage = {
        check: function (key) {
            key = storage.nsKey(key);
            return localStorage.hasOwnProperty(key);
        },

        nsKey: function (key) {
            return namespace + '_' + key;
        },

        read: function (key, isJSON) {
            key = storage.nsKey(key);
            return isJSON || 0 ? JSON.parse(storage.read(key)) : localStorage.getItem(key);
        },

        store: function (key, valueToStore, isJSON) {
            key = storage.nsKey(key);
            localStorage.setItem(key, isJSON || 0 ? JSON.stringify(valueToStore) : valueToStore);
        }
    };

    $('#field_wc').val(storage.check ? storage.read('wc') : '')
    $('#field_tax').val(storage.check ? storage.read('tax') : '')
    $('#field_sui').val(storage.check ? storage.read('sui') : '')
    // and so on...

    $('#field_tax').on('keyup', function() {
        storage.store('wc', $('#field_wc').val());
        storage.store('tax', $('#field_wc').val());
        storage.store('sui', $('#field_wc').val());
        // and so on...
    });

});

A: It appears your issue is that you're using the localStorage.setItem API incorrectly. You need both a key and a value to store.
Here's a localStorage primer:
// set
localStorage.setItem('blah', 'blahblah')

// check if it is set
localStorage.getItem('blah')

// check how many items are stored
localStorage.length

// another way to get the item
localStorage.key(0);

// remove the item
localStorage.removeItem('blah')

Here's a Fiddle with a tiny library I wrote for show and tell purposes. It allows objects or strings to be added to localstore via JSON.parse and stringify.
Hit 'run' a few times and the output should look like:
blah is not set. setting to blahblah
["blah"]
blah is set to blahblah
[]
blah is not set. setting to blahblah
["blah"]
blah is set to blahblah
[]


text:
Q: Allow only anonymous users via web.config authorization I want to use authorization in the web.config to block access to SignUp.aspx to authenticated users.  It cannot be accessed by user such as their roles is administrator and Guest.
<location path="SignUp.aspx">
    <system.web>
        <authorization>
            <allow users="?"/>
        </authorization>
    </system.web>
</location>

    <authentication mode="Forms">
        <forms name="AuthCookie" loginUrl="Login.aspx" timeout="60"
                           defaultUrl="Index.aspx"/>
    </authentication>
    <authorization>
        <deny users="?"/>
    </authorization>

A:     <authorization>
        <allow users="?"/>
        <deny users="*"/>
    </authorization>

Can't actually validate it now but it should do the trick. The explicit denial of all other users should allow only unauthenticated users allow the page.


text:
Q: Differentiating summations Consider the following equation
$$
\sum_{m=0}^{M}b_m r^m \left(\frac {d^2}{dr^2}+\frac{2}{r}\frac d {dr}+2E\right)\Psi-2\sum_{k=0}^{K}a_k r^k \Psi=0 \tag{1}
$$
Now suppose
$$
\Psi(r)=A \exp{[-S(r)]} \tag{2}
$$
where
$$
S(r)=\sum_{n=1}^N \lambda_n r^n \tag{3}
$$
and
$$
A=exp[-\lambda_0]
$$
If we substitute equation (2) in equation (1), How can we obtain the following equation?
$$
\sum_{m=0}^M b_m r^m \left[\sum_{i,j}i j\lambda_i \lambda_j r^{i+j-2}-\sum_j j(j+1) \lambda_j r^{j-2}+2E\right]-2\sum_{k=0}^K a_k r^k=0 \tag{4}
$$
and specially I can't understand how $i$ emerges?

A:
Comparison  of (1)  and  (4)  shows  it is sufficient to focus on the  calculation of
  \begin{align*}
\left(\frac {d^2}{dr^2}+\frac{2}{r}\frac d {dr}+2E\right)\Psi\tag{1a}
\end{align*}

From  (2) we  obtain
\begin{align*}
\frac{d}{dr}\Psi(r)&=\frac{d}{dr}\left(Ae^{-S(r)}\right)\\
&=Ae^{-S(r)}\left(-S^{\prime}(r)\right)\\
&=-S^{\prime}(r)\Psi(r)\\
\frac{d^2}{dr^2}\Psi(r)&=\frac{d}{dr}\left(-S^{\prime}(r)\Psi(r)\right)\\
&=-S^{\prime}(r)\Psi^{\prime}(r)-S^{\prime\prime}(r)\Psi(r)\\
&=\left(\left(S^{\prime}(r)\right)^2-S^{\prime\prime}(r)\right)\Psi(r)\tag{2a}
\end{align*}
From (3) we obtain
\begin{align*}
S(r)&=\sum_{j=1}^N\lambda_jr^j
\qquad S^{\prime}(r)=\sum_{j=1}^Nj\lambda_jr^{j-1}
\qquad S^{\prime\prime}(r)=\sum_{j=1}^Nj(j-1)\lambda_jr^{j-2}\tag{3a}\\
\left(S^{\prime}(r)\right)^2&=\left(\sum_{i=1}^Ni\lambda_i r^{i-1}\right)\left(\sum_{j=1}^Nj\lambda_j  r^{j-1}\right)
=\sum_{n=2}^{2N}\sum_{{i+j=n}\atop{i,j\geq   1}}ij\lambda_i   \lambda_jr^{i+j-2}\tag{4a}
\end{align*}

Putting (1a) - (4a) together we obtain
  \begin{align*}
&\color{blue}{\left(\frac {d^2}{dr^2}+\frac{2}{r}\frac d {dr}+2E\right)\Psi}\\
&\qquad=\left(\left(S^{\prime}(r)\right)^2-S^{\prime\prime}(r)-\frac{2}{r}S^{\prime}(r)+2E\right)\psi\\
&\qquad=\left(\sum_{n=2}^{2N}\sum_{{i+j=n}\atop{i,j\geq   1}}ij\lambda_i   \lambda_jr^{i+j-2}
-\sum_{j=1}^Nj(j-1)\lambda_jr^{j-2}
-2\sum_{j=1}^Nj\lambda_jr^{j-2}+2E\right)\Psi\\
&\qquad\,\,\color{blue}{=\left(\sum_{n=2}^{2N}\sum_{{i+j=n}\atop{i,j\geq   1}}ij\lambda_i   \lambda_jr^{i+j-2}-\sum_{j=1}^Nj(j+1)\lambda_jr^{j-2}+2E\right)\Psi}\tag{5a}\\
\end{align*}

We see the  index $i$  emerges from  the  square of the series in (4a).


text:
Q: Git to existing SVN I have tried all of the suggestions I can find on SO but nothing quite works. I want to periodically move an active Git repo over to an existing, but currently empty, SVN repo. Following the higher rated suggestions from SO the best I can do is  check out the Git repo into my SVN trunk but then I end up with a huge number of merge issues as I try to rebase (as per the suggestions on can find).
What do I need to do to periodically move my Git master branch into this SVN repo while preserving my Git history?

A: git-svn is an okay solution. SubGit is a much better solution in my experience. I suggest you start by looking at the translation limitations to see if any of those limitations will affect the ability to translate your repository.
From the rebasing issues you describe it sounds like you need to focus on your branch management strategy.

A: As an option - put it into github: https://help.github.com/articles/support-for-subversion-clients/


text:
Q: Shape segmentation using Depth-First-Search How to solve this in Depth-First-Search:

*

*6x6 squares, cut along the edges of the lattice into two parts.

*The shape of the two parts is required to be exactly the same.

Try to calculate: There are a total of how many different segmentation methods.
Note: Rotational symmetry belongs to the same segmentation method.

For example:

Sorry, it looks like I'm just looking for an answer without thinking. Actually, I think a lot. The original title didn't require a Depth-First-Search, and I think it needs to be used to solve this problem, but I don't have a clear idea. I think that meet the requirements is between grid is continuous, but I don't know how to express this kind of situation.

A: I think the idea to use dfs is good. You could start the search on a clear (no walls) maze.
Start the search on an arbitrary cell.
For each cell explored : mark the symmetric one as "wall".
A pseudo code to find one segmentation could be:
    boolean dfs(cell) {

        if cell is not empty or was explores or null - return false
        symCell = get Symetric Cell of cell

        if symCell is not empty or was explores or null - return false
        else mark symCell as wall

        mark cell as explored

       //loop over neighbors
       for(Cell c : getNeighbors of cell){
          if ( dfs(c) )   return true
       }

       return false
    }

The process can be repeated over and over again to find more segmentations.
I did not come up yet with any good idea about a stop criteria: how do you know that all possible segmentations were found.
Here is a simple java swing demonstration of finding one segmentation:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class SwingMaze extends JFrame {

    private JPanel mazePanel;
    private Cell[][] cells;
    private int mazeRows = 6, mazeCols = 6; //default size

    public SwingMaze() { this(null); }
    public SwingMaze(Cell[][] cells) {

        this.cells = (cells == null) ?
                getCells(mazeRows,mazeCols) : cells;
        mazeRows = this.cells.length; mazeCols = this.cells[0].length;
        setTitle("Grid");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        buildUi();
        pack();
        setVisible(true);
    }

    void buildUi() {

        mazePanel = new JPanel();
        mazePanel.setLayout(new GridLayout(cells.length, cells[0].length));
        add(mazePanel, BorderLayout.CENTER);

        for (Cell[] cellsRow : cells) {
            for (Cell cell : cellsRow) {
                cell.addMouseListener(cellMouseListener(cell));
                mazePanel.add(cell);
            }
        }

        add(new JLabel("Click any cell to set it origin and start search"),
                                                             BorderLayout.SOUTH);
    }

    private MouseListener cellMouseListener(Cell cell) {
        return new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {solve(cell);}
        };
    }

    private List<Cell> getNeighbors(Cell cell){

        List<Cell> neighbors = new ArrayList<>();

        for(int row = (cell.getPosition().x -1) ;
                row <= (cell.getPosition().x +1) ; row++) {

            if(! validPosition (row,0)) { continue;}

            for(int col = (cell.getPosition().y -1) ;
                    col <= (cell.getPosition().y +1) ; col++) {
                if(! validPosition (row,col)) { continue;}
                if((row == cell.getPosition().x) &&
                        (col == cell.getPosition().y) ) { continue;}
                if((row != cell.getPosition().x) &&
                        (col != cell.getPosition().y) ) { continue;}
                neighbors.add(cells[row][col]);
            }
        }

        Collections.shuffle(neighbors);
        return neighbors;
    }

    private boolean validPosition(int row, int col) {

        return (row >= 0) && (row < mazeRows)
                                    && (col >= 0) && (col < mazeCols);
    }

    private Cell getSymetricCell(Cell cell) {

        if(! validPosition(cell.getPosition().x,
                cell.getPosition().y)) { return null; }
        int row = mazeRows - cell.getPosition().x -1;
        int col = mazeCols - cell.getPosition().y -1;
        return cells[row][col];
    }

    private Cell[][] getCells(int rows, int cols) {

        Cell[][] cells = new Cell[rows][cols];

        for(int row=0; row <cells.length; row++) {
            for(int col=0; col<cells[row].length; col++) {
                cells[row][col] = new Cell();
                cells[row][col].setPosition(row, col);
            }
        }

        return cells;
    }

    boolean solve(Cell cell) {
        reset();
        return dfs(cell);
    }

    boolean dfs(Cell cell) {

        if(cell == null){ return false; }
        //if cell is wall, or was explored
        if( !cell. isToBeExplored()) { return false; }

        Cell symCell = getSymetricCell(cell);

        if((symCell == null) || ! symCell.isToBeExplored()) { return false; }
        symCell.setState(State.WALL);

        cell.setState(State.WAS_EXPLORED);

        //loop over neighbors
        for(Cell c : getNeighbors(cell)){
            if (dfs(c)) {  return true; }
        }

        return false;
    }

    private void reset() {

        for(Cell[] cellRow : cells) {
            for(Cell cell : cellRow) {
                cell.setState(State.EMPTY);
            }
        }
    }

    public static void main(String[] args) {
        new SwingMaze();
    }
}

class Cell extends JLabel {

    Point position;
    State state;
    private static int cellH =65, cellW = 65;

    Cell() {
        super();
        position = new Point(0,0);
        state = State.EMPTY;
        setBorder(BorderFactory.createLineBorder(Color.RED));
        setPreferredSize(new Dimension(cellH , cellW));
        setOpaque(true);
    }

    boolean isToBeExplored() {  return state == State.EMPTY; }

    Point getPosition() {return position;}

    void setPosition(Point position) {this.position = position;}

    void setPosition(int x, int y) { position = new Point(x, y);    }

    void setState(State state) {
        this.state = state;
        setBackground(state.getColor());
    }

    State getState() { return state; }

    @Override
    public String toString() {
        return "Cell " + position.getX() + "-" + position.getY()+ " " + state  ;
    }
}

enum State {

    EMPTY (Color.WHITE), WALL (Color.BLUE), EXPLORED(Color.YELLOW),
    WAS_EXPLORED(Color.PINK);
    private Color color;

    State(Color color) {  this.color = color; }

    Color getColor() { return color; }
}

Clicking will set it as origin and start search. Click the same cell again to see different segmentation.

A: I saw a way to solve this problem, which is to search from the line dividing the grid, the code is as follows:
public class Maze {

int point[][] = new int[10][10]; // The intersection between the line and the line
int dir[][] = {{-1,0},{1,0},{0,-1},{0,1}}; // get Neighbors
static int N = 6; // default size
static int count = 0;

public void dfs(int x, int y) {
    if (x == 0 || y == 0 || x == N || y == N) {
        count++;
        return;
    }

    for(int i = 0; i < 4; i++) {
        int n = x + dir[i][0];
        int m = y + dir[i][1];

        if (n < 0 || n > N || m < 0 || m > N) { continue; }
        if (point[n][m] == 0) {
            point[n][m] = 1;
            point[N-n][N-m] = 1;
            dfs(n, m);
            point[n][m] = 0;
            point[N-n][N-m] = 0;
        }
    }
}

public static void main(String[] args) {
    Maze test = new Maze();
    test.point[N/2][N/2] = 1; // Search from the center point
    test.dfs(N/2, N/2);
    System.out.println(count/4); // There are four types of rotational symmetry
} }


text:
Q: Saxon throws 'top-level text node' exception for XSLT, but XML seems well-formed to me I'm running Cocoon with Apache Tomcat 7.0.42, on Mac OSX. I'm continually getting a very strange error from Saxon. It says I have a top-level text-node in my XML. First off, I'm not sure if they mean my output xml or my xsl xml. Secondly, I believe neither has a top-level text node.
Here is the error message from the stack trace:

net.sf.saxon.trans.XPathException: When 'standalone' or 'doctype-system' is specified, the document must be well-formed; but this document contains a top-level text node
      net.sf.saxon.serialize.XMLEmitter.characters(XMLEmitter.java:574)
      net.sf.saxon.event.ReceivingContentHandler.flush(ReceivingContentHandler.java:543)

<...long stack trace...>

org.apache.cocoon.servletservice.DispatcherServlet.service(DispatcherServlet.java:106)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.apache.cocoon.servlet.multipart.MultipartFilter.doFilter(MultipartFilter.java:131)

Here is my departments_list.xsl, which imports common.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:import href="common.xsl" />

    <xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" indent="yes" />

    <xsl:template match="/">

                <xsl:call-template name="header" />
                <xsl:call-template name="footer" />

    </xsl:template>

</xsl:stylesheet>

Here is my common.xsl:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/1999/xhtml">

<xsl:template name="header">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

        <title>

    Harvard University FAS Course Catalog
        </title>
        <xsl:call-template name="css" />
        <xsl:call-template name="js" />

</xsl:template>

<xsl:template name="footer">

Web Development with XML

Bret Fontecchio

Fall 2013

</xsl:template>

<xsl:template name="css">

</xsl:template>

<xsl:template name="js">

</xsl:template>

</xsl:stylesheet>

A: I can't reproduce the problem, and I'm pretty sure that your explanation (putting the head inside the body) is irrelevant.
It's a serialization error; what it means is that when either doctype-system or standalone is requested as a serialization option, the output must be a well-formed document; it can't have top-level text outside any element.
Firstly, I don't believe the error can occur unless one of the serialization parameters "standalone" or "doctype-system" is specified. It's possible these are being set from the calling application rather than from the stylesheet code.
Secondly, I'm pretty sure the error can only occur if you write text to the output file when there is no open element.
So there's something going on that you haven't told us about.