text:
Q: htaccess rewrite rules conflict www.example.com/category/sub_category/Having problem with the rewririte rules in .htaccess file.
my current .htaccess file looks like this.
RewriteRule ^([0-9a-zA-Z_-]+)/([0-9]+)$ products.php?cat=$1&id=$2 [NC,L]
RewriteRule ^([^/]*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_categories.php?cat=$2&id=$3 [NC,L]
RewriteRule ^(.*)/(.*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_details.php?cat=$3&id=$4 [NC,L]
RewriteRule ^([0-9]+)$  gallery.php?id=$1 [NC,L]

I'm trying create urls like the following.
www.example.com/product_name/1
www.example.com/category/sub_category/21
www.example.com/category/sub_category/product_name/233
www.example.com/gallery/872

www.example.com/gallery/872 is redirecting to www.example.com/category/sub_category/872 instead of gallery.php?id=872
edit:corrected url from  www.example.com/gallery/872 to www.example.com/category/sub_category/872.

A: Your issue is that the first rule matches, the last one can never get applied...
RewriteEngine on
RewriteRule ^gallery/([0-9]+)/?$  gallery.php?id=$1 [NC,L]
RewriteRule ^([0-9a-zA-Z_-]+)/([0-9]+)$ products.php?cat=$1&id=$2 [NC,L]
RewriteRule ^([^/]*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_categories.php?cat=$2&id=$3 [NC,L]
RewriteRule ^(.*)/(.*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_details.php?cat=$3&id=$4 [NC,L]

Rule of thumb: first the specific exceptions, then the more general rules.
The NC flag does not make sense if you also specify both, lower and upper case letters in your regex patterns. It is either/or, not and.
(note: I also included the correction @anubhava posted in his answer)

A: Your last rule will need regex modification since you're matching /gallery/872 and your pattern is only matching 1 or more digits.
RewriteRule ^gallery/([0-9]+)/?$ gallery.php?id=$1 [NC,L,QSA]
RewriteRule ^([0-9a-zA-Z_-]+)/([0-9]+)$ products.php?cat=$1&id=$2 [QSA,L]
RewriteRule ^([^/]*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_categories.php?cat=$2&id=$3 [QSA,L]
RewriteRule ^(.*)/(.*)/([0-9a-zA-Z_-]+)/([0-9]+)$ product_details.php?cat=$3&id=$4 [QSA,L]

Also you need to recorder your rules like I showed above.


text:
Q: How do I call ForceClient.UserInfo() synchronously I'm converting the data access layer of an old app from MySql to Salesforce using WinForms, DeveloperForce, Visual Studio 2015, .Net 4.6.1, C#.  This is my first real TPL/async/await project.
I'm stuck on how to call ForceClient.UserInfo synchronously.
Anyway, this works:
public ForceClient Connect(){
    if (_forceClient == null){
        _auth = new AuthenticationClient();
        _auth.UsernamePasswordAsync(...).Wait();
        _forceClient = new ForceClient(_auth.InstanceUrl, _auth.AccessToken, _auth.ApiVersion);
    }
    return _forceClient;
}
...
private async Task<int> GetSomeData(){
    var response = await Force.Connect().QueryAsync<dynamic>("SELECT...").ConfigureAwait(false);
    //load data to local storage
    return response.Count
}

So far so good - The connect() blocks the first time until it connects, then I send all my queries at once and load them in pseudo parallel as the results are returned. Yay.  Now I want to add a synchronous call to ForceClient.UserInfo() toward the end of the connect method.
This works asyncronously:
userInfo = await _forceClient.UserInfo<UserInfo>(UserInfoEndpointUrl);

But all my attempts to call it synchronously have failed.  I've tried .Wait(), .RunSynchronously(), Task.WaitAll, Task.WaitAny, ConfigureAwait(false),... Most things I try end up causing the call to hang indefinitely (thread deadlock)
Help?
Thanks!

A: Update based on comments.
You need to use Task.ConfigureAwait(false); to prevent blocking the UI thread context.
See Don't Block on Async Code

I made the call synchronously using the following:
class Program
{
    static void Main(string[] args)
    {
        Task.Run(async () =>
        {
            MainAsync(args);
        }).Wait();

        Thread.Sleep(1000);
        Console.WriteLine("Done");
    }

    static async Task MainAsync(string[] args)
    {
        try
        {
            var auth = new AuthenticationClient();
            auth.UsernamePasswordAsync("ConsumerName", "ClientSecret", "user@example.com", "password goes here").Wait();

            var forceClient = new ForceClient(auth.InstanceUrl, auth.AccessToken, auth.ApiVersion);

            // Without the Thread.Sleep above the application will often close before the result comes back.
            //var userInfo = await forceClient.UserInfo<UserInfo>(auth.Id);
            //Console.WriteLine(userInfo.FirstName);

            var task = forceClient.UserInfo<UserInfo>(auth.Id);
            task.Wait();
            var userInfo2 = task.Result;
            Console.WriteLine(userInfo2.FirstName);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
}

If I made the call asynchronously and didn't have the Thread.Sleep(1000) the application would close before the UserInfo came back.
Note that the usage of Task.Wait and Task.Result isn't ideal as an exception within the Task will be wrapped in an AggregateException.
See also:

*

*How to call asynchronous method from synchronous method in C#?

*Async/Await - Best Practices in Asynchronous Programming

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to perform a crosstab based on data in postgres? So looking at an official example:
CREATE TABLE ct(id SERIAL, rowid TEXT, attribute TEXT, value TEXT);
INSERT INTO ct(rowid, attribute, value) VALUES('test1','att1','val1');
INSERT INTO ct(rowid, attribute, value) VALUES('test1','att2','val2');
INSERT INTO ct(rowid, attribute, value) VALUES('test1','att3','val3');
INSERT INTO ct(rowid, attribute, value) VALUES('test1','att4','val4');
INSERT INTO ct(rowid, attribute, value) VALUES('test2','att1','val5');
INSERT INTO ct(rowid, attribute, value) VALUES('test2','att2','val6');
INSERT INTO ct(rowid, attribute, value) VALUES('test2','att3','val7');
INSERT INTO ct(rowid, attribute, value) VALUES('test2','att4','val8');

SELECT *
FROM crosstab(
  'select rowid, attribute, value
   from ct
   where attribute = ''att2'' or attribute = ''att3''
   order by 1,2')
AS ct(row_name text, category_1 text, category_2 text, category_3 text);

They literally state columns count. They produce:
 row_name | category_1 | category_2 | category_3
----------+------------+------------+------------
 test1    | val2       | val3       |
 test2    | val6       | val7       |

How to make columns count based on total attribute to get something line this:
 row_name | att1       | att2       | att3       | attr4
----------+------------+------------+---------------------
 test1    | val1       | val2       | val3       | val4
 test2    | val5       | val6       | val7       | val8

Composed from pure table data and not from predefined constant column count?


text:
Q: Why can't I create a new issue tracking list alert with a daily or weekly digest? A site owner in my site collection created a new Issue Tracking list from the default list template, then added a handful of custom columns from the default list of available column types.
When they try to create an alert, by going to Actions -> Alert Me the When to Send Alerts option only shows Send e-mail immediately without the other email digest options like "Send a daily summary" or "Send a weekly summary" and the time.
I have created a new Issue Tracking list in the same site and the alerts options are all there.  I have created a new Issue Tracking list in a different site and all the options are there.  I have not recreated the 7 custom columns.
I have poked around in a lot of the list settings, but nothing is standing out.  Where should I be looking and what should I be looking for to enable the digest emails?


text:
Q: How do I get the python package "gtk"? I can't import it right now, but my library imports it.
I don't want the full Windows gtk thing. I just want the package that can be imported by this script:  http://www.koders.com/python/fid798D591F71AC2C5F462B7BFFF0D84E1EA8D5759F.aspx?s=timer

A: Go to the PyGTK website and choose the all-in-one .msi that matches your Python version. Save it and then open the .msi to install GTK for Python.


text:
Q: Linear Algebra-Linear Operator How do i construct a linear operator of rank=2 from R^3 to itself.
Is it sufficient if i find a linear operator and deduce that it is of rank 2 and it fulfills the conditions of being a linear operator?

A: Define it on the basis vectors of $R^3$. Let $v_1,v_2, v_3$ be a basis of $R^3$. Define $T : R^3 \to R^3$ by $$Tv_1 = v_1\\ Tv_2 = v_2\\ Tv_3 = v_2$$ Then range $T$ is a two dimensional subspace of $R^3$ as $Tv_1,Tv_2,Tv_3$ spans $\text{range } T$ and reducing this spanning list to a basis gives us $Tv_1, Tv_2$.
Here I am using the easy to prove theorem that if $v_1,\dots,v_n$ is a basis of $V$, then $Tv_1,\dots,Tv_n$ spans $\text{range }T$ for a linear map $T : V\to W$.


text:
Q: How can we set Header for TabNavigator React-Navigation is used in RN navigation. Then there is a tab page using TabNavigator. The position is top. Now the requirement is that there is still some content on the upper part of the tab page. How can this part be displayed?
My idea is to add a header, because this tab navigation is also in a StackNavigator, then this header, how to add?
Const tab = TabNavigator (
   {
     Xx: {screen:xxxx},
     Xx:{screen:xxxx}
   },
   {
     ...
   }
);

I tried to set the header with navigationOptions in each screen, or in TabNavigator.But it didn't work.
Then, I set it up in an outer StackNavigator. Although there is an effect, there is a problem that every time I jump to this page, the upper header is displayed first, then the lower tab is displayed . There is an left-to-right animation when displayed on iOS, and it is very obvious that the entire page is divided. Is there any solution to this situation? Or is there a problem with my writing?

A: With this
Const tab = TabNavigator (
   {
     Xx1: {screen: tabScreen1},
     Xx2: {screen: tabScreen2}
   },
   {
     ...
   }
);

Do this also
const tabScreen1 = StackNavigator(
  {
    screen1: { screen: xxxx },
  },
  {
    navigationOptions: {
      gesturesEnabled: false,
    },
  }
);


text:
Q: keyboard-interactive authentication (Locked out?) on a Modern Honey Network Ubuntu 14.04 box? I deployed a Modern Honey Network for a course project. I have a Ubuntu Box that hosts the MHN server and now I have deployed a Ubuntu 14.04 box to host several Sensors (Cowrie, Snort, etc.) However, after the testing of the ssh brute force, I can no longer login to my Ubuntu box.
Both putty and Linux terminal state that the Ubuntu Box is now Using keyboard-interactive authentication and even with the correct username and password, I am unable to login.
I have tried copy and passing the password in, typing it in manually, trying to login from different IP addresses, etc. I have no defenses in place as of yet (fail2ban, denyhosts, etc.). There is no SSH Key set-up, and I don't want there to be. Just password authentication.
Here is the output of ssh -v:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: /etc/ssh/ssh_config line 57: Applying options for *
debug1: Connecting to ***SANITIZED*** [***SANITIZED***] port 22.
debug1: Connection established.
debug1: identity file /home/josh/.ssh/id_rsa type -1
debug1: identity file /home/josh/.ssh/id_rsa-cert type -1
debug1: identity file /home/josh/.ssh/id_dsa type -1
debug1: identity file /home/josh/.ssh/id_dsa-cert type -1
debug1: identity file /home/josh/.ssh/id_ecdsa type -1
debug1: identity file /home/josh/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/josh/.ssh/id_ed25519 type -1
debug1: identity file /home/josh/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1
Debian-4+deb7u2
debug1: match: OpenSSH_6.0p1 Debian-4+deb7u2 pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA ***SANITIZED***
debug1: Host '***SANITIZED***' is known and matches the RSA host key.
debug1: Found key in /home/josh/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password,publickey,keyboard-
interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /home/josh/.ssh/id_rsa
debug1: Trying private key: /home/josh/.ssh/id_dsa
debug1: Trying private key: /home/josh/.ssh/id_ecdsa
debug1: Trying private key: /home/josh/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Password:
debug1: Authentications that can continue: password,publickey,keyboard-
interactive
Password:

As requested - sshd_config file:
josh@ubuntu-HP:~$ sudo cat /etc/ssh/sshd_config
# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 2222
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin yes
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

# Added by DigitalOcean build process
ClientAliveInterval 120
ClientAliveCountMax 2

PasswordAuthentication yes


text:
Q: MYSQL count first table ids where value is found in second table I have two tables,
table1 and table2 both tables has these columns
id, name, rel_id

now i would like to have a query to count ids of the table1 where name from table2 is equals to john and table1 rel_id equals to table2 rel_id.
so something like this (this is not correct that's why i need help to make it work).
Select count(ids) from table1
where table2.name="john"
and table1.rel_id=table2.rel_id

A: Well, one way is to use a join:
Select count(t1.id)
from table1 t1 join
     table2 t2
     on t1.rel_id = t2.rel_id
where t2.name = 'john';

Note that this uses table aliases to distinguish all the columns in each table.  Because the tables have the same columns, you need to identify the table for each column.  Also, the I changed the string constant to use single quotes rather than double quotes.

A: You need to look into joins so :
select count(ids)
from table1 join table2 on table1.rel_id=table2.rel_i
where table2.name="john"
A short intro from W3C schools: http://www.w3schools.com/sql/sql_join.asp
The full MySQL URL for more reference http://dev.mysql.com/doc/refman/5.0/en/join.html


text:
Q: How to redraw or refresh in OnRender? I want to draw something dynamically. Following code shows my OnRender. I'm setting DrawItem somewhere in my program where I need it. But when I'm calling DrawItem =5; what do I have to call, so that OnRender gets called?
protected override void OnRender(DrawingContext drawingContext)
{
    switch (DrawItem)
    {
        case 1:
            //Draw Item
            break;
        case 2:
            //Draw Item
            break;
        case 3:
            //Draw Item
            break;
        case 4:
            //Draw Item
            break;
        case 5:
            //Draw Item
            break;
    }
    base.OnRender(drawingContext)
}

public int DrawItem { get; set; }

A: Your question is not clear but from what I can understand you seem to be asking for a method to refresh the visuals after updating your drawing variables. You could use the following after updating your drawing variables:
this.InvalidateVisual();

and with the property:
private int drawItem;
pulic int DrawItem
{
 get {return drawItem;}
 set
 {
    drawItem=value;
    this.InvalidateVisual();
 }
}

A: I ran into similar issue and found an even more elegant solution. Define a DependencyProperty like so:
public static readonly DependencyProperty PropertyNameProperty = DependencyProperty.Register("PropertyName", typeof(PropertyType), typeof(PropertyElementType), new FrameworkPropertyMetadata(DefaultPropertyValue, FrameworkPropertyMetadataOptions.AffectsRender));

The key here is this:
FrameworkPropertyMetadataOptions.AffectsRender

So now the property can be set in XAML and updates visual automatically on changing.

A: If the size of your control changes, you can use InvalidateVisual(), however keep in mind this causes a fairly expensive re-layout of your UI. If the size of your control is staying the same, you shouldn't call InvalidateVisual().
A more efficient way to update your UI is to create a DrawingGroup "backing store" and add it to the DrawingContext during OnRender(). You can then update it whenever you like, using DrawingGroup.Open(), and WPF will update your UI.
If this sounds confusing, remember that WPF is a retained drawing system. That means OnRender() might better be called AccumulateDrawingObjects(). It's actually accumulating a tree of live drawing objects, some of which (like DrawingGroup, RenderTargetBitmap, and WriteableBitmap) can be updated later.
This is what it looks like:
DrawingGroup backingStore = new DrawingGroup();

protected override void OnRender(DrawingContext drawingContext) {
    base.OnRender(drawingContext);

    Render(); // put content into our backingStore
    drawingContext.DrawDrawing(backingStore);
}

// I can call this anytime, and it'll update my visual drawing
// without ever triggering layout or OnRender()
private void Render() {
    var drawingContext = backingStore.Open();
    Render(drawingContext);
    drawingContext.Close();
}

A: http://msdn.microsoft.com/de-de/library/ms598919(v=vs.100).aspx
You have to call InvalidateVisual for the Control that shall be updated. But as you can read, a call to InvalidateVisual causes a complete layout cycle, so be sure for performance reasons that your canvas or whatever you want to draw on contains no or only a few child elements.


text:
Q: How to match variably co-occurring patterns in R My question relates to matching co-occurring patterns in texts.
For example, in this vector:
x <- c("oh well i didn't know that",                        # not match
       "yeah right that's true",                            # not match
       "okay, so she lives in, well, i guess soho",         # not match
       "well, uh oh, okay in that case",                    # match
       "okay, right, well oh why not")                      # match

I would like to match those strings in which the words well, oh, and okay co-occur in any order. I've come up with this regex, which, however, incorrectly also matches "okay, so she lives in, well, i guess soho" (confusingly, despite the fact that I've used word boundary anchors \\b for oh):
grep("(?=\\boh\\b)*(?=\\bwell\\b)*(?=\\bokay\\b).*", x, perl = T, value = T)
# "okay, so she lives in, well, i guess soho"  "well, uh oh, okay in that case"  "okay, right, well oh why not"

How can this regex be tweaked to match all and any strings in which well, oh, and okay co-occur as words?


text:
Q: Does Watson Conversation service support SOAP API? I am planning of making a dynamic conversation service using SOAP API integrated to my Watson Conversation service.
I would like to know if SOAP API is supported in Watson Conversation.I know that REST API is supported doc under the section TIME Zone they mention REST API.
I would like to know if SOAP API is also supported.
The main reason for the question is since SOAP is by default in XML and REST API is mainly in JSON.The Watson Conversation Service is in JSON.
I have looked at this   answer too but this doesn't mention if using REST or SOAP API.


text:
Q: Writing Turkish characters to MySQL using WampServer and Java i am having a problem with my Wamp Server. When i execute a query which contains Turkish characters, i am getting this error:
SEVERE: Incorrect string value: '\xE7l? ya...' for column 'body' at row 1
java.sql.SQLException: Incorrect string value: '\xE7l? ya...' for column 'body' at row 1

Here is my Java code:
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url, user, password);
PreparedStatement p = con.prepareStatement("SET NAMES utf8");
p.executeUpdate();
PreparedStatement ps =
        con.prepareStatement("INSERT INTO duyurular values (?, ?, ?, ?)");
ps.setInt(1, 0);
ps.setString(2, title);
ps.setString(3, body);
ps.setInt(4, writer);
ps.executeUpdate();

My database and table which i am trying to write to are all set to "utf8_turkish_ci" collation. My Wamp Server version is 2.2.

I am able to write Turkish characters using PHPMyAdmin sql console but not able to with my Java code. What should i do to get over this? Thanks in advance.

A: There is nothing in here that would tell the driver to encode strings in UTF-8. You are only making the database expect UTF-8, and then the driver encodes your strings in some other encoding and the database throws an error.
You don't show what your url is, but it's supposed to be like this:
jdbc:mysql:///dbname?useUnicode=true&characterEncoding=utf-8

Then you can remove this:
PreparedStatement p = con.prepareStatement("SET NAMES utf8");
p.executeUpdate();

A: For others benefit, Check the bellow answer
Add these lines to either my.cnf or my.ini:
 [client]
 default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
default-character-set=utf8
character-set-server=utf8

For more details check this


text:
Q: Solid State relay and Limit switch I'm building my first CNC machine, it's a 40W Laser Cutter.
I'm planning on adding a security feature that cuts the laser power supply if the enclosure door is open during while operating.
I want to use this Solid State Relay
I want to use a simple mechanical switch like this and just wanted to see if you think it would be a terrible idea for any reason. I would send 5v to the switch and then to the relay. When the door is closed, the relay would get the 5v and allow electricity to go to the laser. If the door is open, it would kill it.
Thanks in advance.

A: You are right to be thinking of safety. I offer the following observations:
A safety switch shouldn't rely on a spring to driven into the off position when the guarding is open. That way if the switch spring fails then the system fails in a safe mode. This often relies on the use of a cam or similar mechanism to operate the switch. Safety-rated magnetic switches are also available but these are probably out of budget for your application.
The problem with the solid state relay is that you can't predict its failure mode. If the switching element fails it is as likely to fail short-circuit as open-circuit. Mechanical relays are much more reliable in this regard and their major risk is contact welding but this can be mitigated by using a high safety factor in the contact rating.
Industrial safety circuits use redundant circuits: the safety switch will have two contacts and drive two relays in a supervisory unit. Both relays must drop out before the system can be reset. (That way you catch the first fault if a switch or relay fails.)
In summary:

*

*Use forced disconnect when the guard is open.

*Use an over-specified relay or two.

*See if you can add a supervisory circuit to alarm if the relay doesn't match the switch position.

*Add an indicator LED (bright) to indicate when the laser is powered. After a while you'll get used to the LED turning off when the guard is opened to the extent that you should recognize a fault if it occurs.

I have described the operation of a safety relay in my answer to Symbol or marking on safety relay. You might find it of interest.


text:
Q: is Haskell sensitive to order in a function definition? I was trying out the Haskell 99 problems and my first attempt was this one .Although the solution may be a little incorrect ,I just want to know why Haskell throws a warning for the first one and outputs the wrong result
> let { mylast (x:xs) = mylast xs; mylast [] = 0 ;mylast [x] = x;}
Pattern match(es) are overlapped

> mylast [1,2,3,58,8,6,1,231,10]
> 0

but the code below executes just fine.
> let { mylast [] = 0 ;mylast [x] = x;mylast (x:xs) = mylast xs;}
> mylast [1,2,3,58,8,6,1,231,10]
> 10

A: ...in other words, Haskell doesn't consider which of two matches is more general and then use the more specific one first. It just considers "does it match or doesn't it?"
In some cases it wouldn't be possible to say which of two matches is more specific. For instance,
foo :: Int -> Int -> Int
foo 0 _ = 0
foo _ 1 = 1
foo n m = foo (m-1) n

If Haskell was supposed to pick the most specific matching pattern, then what result should foo 0 1 yield?
You need to have some arbitrary tie-breaker for such functions, and in Haskell that's simply the order: always match the upper clause first.

A: Yes, the patterns in a function definition are tried in the specified order, and (only) the first matching line is used.
So in your definition
mylast (x:xs) = mylast xs
mylast [] = 0
mylast [x] = x

(reformatted for clarity), a non-empty-list will always be handled by the first line, even the list [x] (with x=x and xs=[]). So your calculation of mylast will happily ignore every element in the list, and finally look at [], hence returning 0.


text:
Q: Unable to launch URL in edge browser (using replit platform)- Selenium Python I tried to use replit online platform for web scraping using selenium in Edge browser. replit automatically install selenium 4.1.3 but I couldn't find msedge-selenium-tools to support this version.

How can I install selenium (3.141) to support msedge-selenium-tools?
Any help will be highly appreciated.
Thank You
Bibek

A: I don't know much about this online IDE,  but I did some testing and found that it seems to be able to control the version of the referenced package via a configuration in the pyproject.toml file.
First, uninstall selenium 4.1.3 in installed Packages. When installing edge-selenium-tools package, you will find that it bundles selenium 3.141 installed with edge-selenium-tools. Second, add this line in pyproject.toml file.
selenium = "^3.141.0"

Something like this:

In addition, for more questions related to IDE replit, I suggest you post your questions in its community, I think there may be someone with more relevant experience who can answer your questions.


text:
Q: Adding Fling Gesture to an image view - Android Okay I have been referencing the code here: Fling gesture detection on grid layout
but just can not get it to work. In my main activity I have a simple image defined. I want to detect a fling on the image. Here is my code below. The onclick method at the bottom is empty. Is it because of this? I left it blank because in the other code sample its not what I want. I just want a simple toast to pop up saying fling right or fling left.
public class GestureRightLeft extends Activity implements OnClickListener  {

    ImageView peek;

    private static final int SWIPE_MIN_DISTANCE = 120;
    private static final int SWIPE_MAX_OFF_PATH = 250;
    private static final int SWIPE_THRESHOLD_VELOCITY = 200;
    private GestureDetector gestureDetector;
    View.OnTouchListener gestureListener;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        peek =(ImageView) findViewById(R.id.peek);
        peek.setImageResource(R.drawable.bluestrip);

        gestureDetector = new GestureDetector(new MyGestureDetector());
        gestureListener = new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        };
    }

    class MyGestureDetector extends SimpleOnGestureListener {
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            try {
                if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
                    return false;
                // right to left swipe
                if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                    Toast.makeText(GestureRightLeft.this, "Left Swipe", Toast.LENGTH_SHORT).show();
                }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                    Toast.makeText(GestureRightLeft.this, "Right Swipe", Toast.LENGTH_SHORT).show();
                }
            } catch (Exception e) {
                // nothing
            }
            return false;
        }
    }

    @Override
    public void onClick(View v) {}
}

A: Here's the simpliest working version of flinger I can think of.
You can actually tie it to any component, not only ImageView.
public class MyActivity extends Activity {
    private void onCreate() {
        final GestureDetector gdt = new GestureDetector(new GestureListener());
        final ImageView imageView  = (ImageView) findViewById(R.id.image_view);
        imageView.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(final View view, final MotionEvent event) {
                gdt.onTouchEvent(event);
                return true;
            }
        });
    }

    private static final int SWIPE_MIN_DISTANCE = 120;
    private static final int SWIPE_THRESHOLD_VELOCITY = 200;

    private class GestureListener extends SimpleOnGestureListener {
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                return false; // Right to left
            }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                return false; // Left to right
            }

            if(e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
                return false; // Bottom to top
            }  else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
                return false; // Top to bottom
            }
            return false;
        }
    }
}

No activity onClickListener though (if you don't need to catch any onclick actions)
It captures not only horizontal, but vertical also (just delete vertical part if you don't need it), and horizontal swipes have priority as you can see.
In places where method returns (nad where my comments are) just call your method or whatever :)

A: some of the precondition
1) setonClick method
image.setOnClickListener(this);

2) set your gesture detection in onTouch()
image.setOnTouchListener(new OnTouchListener() {
    GestureDetector gestureDetector = new GestureDetector(new SwingGestureDetection((mContext),image,a));
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return gestureDetector.onTouchEvent(event);
    }
});

3) create SwingGestureDetection class and implement all method
@Override
public boolean onFling(MotionEvent start, MotionEvent finish, float arg2,float arg3) {
    if (start.getRawX() < finish.getRawX()) {
        System.out.println("next...swing");
    } else {
        System.out.println("previois...swing");
    }
}

4) pass your imageview in constructor
public SwingGestureDetection(Context con,ImageView image,int pos) {
    mContext = con;
    this.image = image;
    this.position = pos;
}

This is perfect work for me.if any query then put comment.

A: Try to read:
http://illusionsandroid.blogspot.com/2011/05/adding-fling-gesture-listener-to-view.html
It allow you to separate your activity implementation from your custom listener. It is simply a refactoring of the solution reported by Alex Orlov

A: If you dont like to create a separate class or make code complex,
You can just create a GestureDetector variable inside OnTouchListener and make your code more easier
namVyuVar can be any name of the View on which you need to set the listner
namVyuVar.setOnTouchListener(new View.OnTouchListener()
{
    @Override
    public boolean onTouch(View view, MotionEvent MsnEvtPsgVal)
    {
        flingActionVar.onTouchEvent(MsnEvtPsgVal);
        return true;
    }

    GestureDetector flingActionVar = new GestureDetector(getApplicationContext(), new GestureDetector.SimpleOnGestureListener()
    {
        private static final int flingActionMinDstVac = 120;
        private static final int flingActionMinSpdVac = 200;

        @Override
        public boolean onFling(MotionEvent fstMsnEvtPsgVal, MotionEvent lstMsnEvtPsgVal, float flingActionXcoSpdPsgVal, float flingActionYcoSpdPsgVal)
        {
            if(fstMsnEvtPsgVal.getX() - lstMsnEvtPsgVal.getX() > flingActionMinDstVac && Math.abs(flingActionXcoSpdPsgVal) > flingActionMinSpdVac)
            {
                // TskTdo :=> On Right to Left fling

                return false;
            }
            else if (lstMsnEvtPsgVal.getX() - fstMsnEvtPsgVal.getX() > flingActionMinDstVac && Math.abs(flingActionXcoSpdPsgVal) > flingActionMinSpdVac)
            {
                // TskTdo :=> On Left to Right fling

                return false;
            }

            if(fstMsnEvtPsgVal.getY() - lstMsnEvtPsgVal.getY() > flingActionMinDstVac && Math.abs(flingActionYcoSpdPsgVal) > flingActionMinSpdVac)
            {
                // TskTdo :=> On Bottom to Top fling

                return false;
            }
            else if (lstMsnEvtPsgVal.getY() - fstMsnEvtPsgVal.getY() > flingActionMinDstVac && Math.abs(flingActionYcoSpdPsgVal) > flingActionMinSpdVac)
            {
                // TskTdo :=> On Top to Bottom fling

                return false;
            }
            return false;
        }
    });
});

A: Try this
imageView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (gestureDetector.onTouchEvent(event)) {
                return false;
            }
            return true;
        }
  });

A: imageView.setOnTouchListener(new View.OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return !gestureDetector.onTouchEvent(event);
    }
});

A: If you're looking for a method like ImageView.setOnGestureListener, there is none. You can go look at the Android source code. Your best option is to handle it in onTouch() of the View object.
This is the simplest GestureDetector I can make.
I have a class called GenesMotionDetector.java. Here's the code for it:
package gene.com.motioneventssample;

import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class GenesMotionDetector extends Activity implements GestureDetector.OnGestureListener {
    private GestureDetector gestureScanner;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nothing);
        gestureScanner= new GestureDetector(getBaseContext(),this);
    }

    @Override
    public boolean onTouchEvent(MotionEvent me) {
        System.out.println("Inside onTouchEvent() of GenesMotionDetector.java");
        return gestureScanner.onTouchEvent(me);
    }

    @Override
    public boolean onDown(MotionEvent e) {
        System.out.println("Inside onDown() of GenesMotionDetector.java");
        return true;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        System.out.println("Inside onFling() of GenesMotionDetector.java");
        return true;
    }

    @Override
    public void onLongPress(MotionEvent e) {
        System.out.println("Inside onLongPress() of GenesMotionDetector.java");
    }

    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
        System.out.println("Inside onScroll() of GenesMotionDetector.java");
        return true;
    }

    @Override
    public void onShowPress(MotionEvent e) {
        System.out.println("Inside onShowPress() of GenesMotionDetector.java");
    }

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        System.out.println("Inside onSingleTapUp() of GenesMotionDetector.java");
        return true;
    }
}

The corresponding XML layout file for that class is nothing.xml. Here's the code for it:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/screen"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/text"
        android:background="#17528c"
        android:text="testing"
        android:layout_width="100dp"
        android:layout_height="200dp" />

    <ImageView
        android:id="@+id/image"
        android:background="#f8af20"
        android:layout_width="100dp"
        android:layout_height="200dp" />
</LinearLayout>

Now, taking the simplest GestureDetector I can make (from above) and modifying it for what you want, I get this:
package gene.com.motioneventssample;

import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.widget.ImageView;

public class GenesMotionDetector3 extends Activity implements GestureDetector.OnGestureListener {
    private GestureDetector gestureScanner;
    ImageView mView3;

    View.OnTouchListener gestureListener;
    MotionEvent initialME, finalME;
    private VelocityTracker mVelocityTracker = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nothing);

        mView3 = (ImageView) findViewById(R.id.image);

        // Gesture detection
        gestureScanner = new GestureDetector(getBaseContext(), this);

        gestureListener = new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch(event.getAction()){
                    case MotionEvent.ACTION_DOWN:
                        initialME= event;

                        if(mVelocityTracker == null) {
                            // Retrieve a new VelocityTracker object to watch the velocity of a motion.
                            mVelocityTracker = VelocityTracker.obtain();
                        }
                        else {
                            // Reset the velocity tracker back to its initial state.
                            mVelocityTracker.clear();
                        }
                        // Add a user's movement to the tracker.
                        mVelocityTracker.addMovement(event);

                        break;
                    case MotionEvent.ACTION_MOVE:
                        mVelocityTracker.addMovement(event);
                        // When you want to determine the velocity, call
                        // computeCurrentVelocity(). Then call getXVelocity()
                        // and getYVelocity() to retrieve the velocity for each pointer ID.
                        mVelocityTracker.computeCurrentVelocity(1000);
                        break;
                    case MotionEvent.ACTION_UP:
                        finalME=event;
                        break;
                    case MotionEvent.ACTION_CANCEL:
                        // Return a VelocityTracker object back to be re-used by others.
                        mVelocityTracker.recycle();
                        break;
                }
                return onFling(initialME, finalME, mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity());
                //return false;
            }
        };

        mView3.setOnTouchListener(gestureListener);
    }

    @Override
    public boolean onTouchEvent(MotionEvent me) {
        System.out.println("Inside onTouchEvent() of GenesMotionDetector.java");

        return gestureScanner.onTouchEvent(me);
    }

    @Override
    public boolean onDown(MotionEvent e) {
        System.out.println("Inside onDown() of GenesMotionDetector.java");
        return true;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        System.out.println("Inside onFling() of GenesMotionDetector.java");
        System.out.println("e1= "+ e1);
        System.out.println("e2= "+ e2);
        System.out.println("velocityX= "+ velocityX);
        System.out.println("velocityY= "+ velocityY);
        return true;
    }

    @Override
    public void onLongPress(MotionEvent e) {
        System.out.println("Inside onLongPress() of GenesMotionDetector.java");
    }

    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
        System.out.println("Inside onScroll() of GenesMotionDetector.java");
        return true;
    }

    @Override
    public void onShowPress(MotionEvent e) {
        System.out.println("Inside onShowPress() of GenesMotionDetector.java");
    }

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        System.out.println("Inside onSingleTapUp() of GenesMotionDetector.java");
        return true;
    }
}

You might as well just handle everything in onTouch(). I'm basically getting the gestures in onTouch and passing it to onFling().

A: Design your layout with ImageView.
Add setOnTouchListenerto imageView.imageview.setOnTouchListener(this).add unimplemented method View.OnTouchListener.Then onTouch method you can implemtn your guesture logic.This sample tells you left to right and right to left guesture,
float x1,x2;
float y1, y2;

@Override
public boolean onTouch(View view, MotionEvent event) {
    switch ( event.getAction() ){

        case MotionEvent.ACTION_DOWN:{
            x1 = event.getX();
            y1 = event.getY();
            break;
        }

        case MotionEvent.ACTION_UP:{
            x2 = event.getX();
            y2 = event.getY();

            if ( x1<x2 ) {
                //implement what you need to do here
            }
            if ( x1>x2 ) {
                //implement what you need to do here
            }
            break;
        }
    }
    return false;
}

A: Quick example for kotlin:
val flingGesture = GestureDetector(requireContext(), object : GestureDetector.SimpleOnGestureListener() {
    override fun onFling(e1: MotionEvent?, e2: MotionEvent?, velocityX: Float, velocityY: Float): Boolean {
        // your action here
        return true
    }
})

Set to any view:
imageView.setOnTouchListener{ _, motionEvent ->
    flingGesture.onTouchEvent(motionEvent)
    return@setOnTouchListener true
}


text:
Q: Compare rows containing varying length road subsections attributes with set of fixed subsection lengths? I have the following dataframe listing sections of a road (defined by start and endpoints in km format) that contains attrivutes for varying subsections. The length simply derives from the start-end-points.
Start   End     Attrib  Length
0       0.03    K       0.03
0.03    0.036   K       0.006
0.036   0.082   K       0.046
0.082   0.091   H       0.009
0.091   0.096   H       0.005
0.096   0.1     K       0.004
0.1     0.121   K       0.021
0.121   0.123   K       0.002

...
...

What i need is to find and possibly create a new dataframe for
a) the most common attribute per each 0.1km-section and
b) its percentage of the total 0.1km-section.
What i have so far is a list of the 0.1km-section in the form of tuples. I could figure out how to sum up the lengths between set start- and endpoints, but I don't know how to start with using these with string attributes. Can I do this with pandas ?

A: First, create a column that will serve to indicate where each 0.1km-section :
df['label'] = df['Start'].apply(lambda x: int(x/0.1))
print(df)
   Start    End Arrtib  Length  label
0  0.000  0.030      K   0.030      0
1  0.030  0.036      K   0.006      0
2  0.036  0.082      K   0.046      0
3  0.082  0.091      H   0.009      0
4  0.091  0.096      H   0.005      0
5  0.096  0.100      K   0.004      0
6  0.100  0.121      K   0.021      1
7  0.121  0.123      K   0.002      1

Then obtain the attribute  unique value of each 0.1km-section :
unique  = df.groupby('label').agg({'Arrtib': lambda x: np.unique(x,return_counts=True)})
print(unique)
                 Arrtib
label
0      ([H, K], [2, 4])
1            ([K], [2])

Finally get the most common attribute and percentage of the total 0.1km-section:
unique['mostcommon'] = unique['Arrtib'].map(lambda x:x[0][-1])
unique['percentage '] = unique['Arrtib'].map(lambda x:x[1][-1]/x[1].sum())
print(unique)
                 Arrtib mostcommon  percentage
label
0      ([H, K], [2, 4])          K     0.666667
1            ([K], [2])          K     1.000000


text:
Q: How to check special character support with javascript? How can I check if a special character is available in the user's computer?
For example: ♥ ♦ ♣ ♠ ♪ ♫ ¶
If the user's browser doesn't support one of them, then a rectangle () will appear instead of the symbol.

A: I'm afraid there's no way to test it, and there's the added complexity that even if a character is available, browsers (especially IE) may fail to render it.
On the other hand, the information would not be particularly useful, except perhaps in the sense that you could dynamically change the character to an image if it can't be rendered as a character.
A better approach to having your characters rendered properly is to write your style sheets so that they select suitable fonts. This also addresses the problem that a character might be displayed using a font that does not suit the overall design, such as the basic copytext font.
For example, if you need the characters ♥ ♦ ♣ ♠ ♪ ♫ ¶, select a font that contains them and all the other characters you need. This would probably boil down just to
body { font-family: Arial, sans-serif; }

A: a different solution can be using google's webfonts
http://www.google.com/webfonts
if you see a character, every other computer [with a recent browser] will see it


text:
Q: Failed build in Heroku master push I'm trying to deploy my project to Heroku, and my build failed. When it is deployed locally, I have no problem.  When I apply git push heroku master and look at the build log on Heroku, this is what I get.
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> PHP app detected
 !     ERROR: Basic validation for 'composer.json' failed!
 !
 !     It must be a valid JSON document compatible with Composer.
 !
 !     You most likely created or edited the file by hand, and it now
 !     contains a syntax error. Please refer to the documentation at
 !     https://getcomposer.org/doc/ for information on the format.
 !
 !     You can run 'composer validate' locally on your computer for
 !     further diagnosis. Remember to also always keep your lock file
 !     up to date with any changes according to the instructions at
 !     https://getcomposer.org/doc/01-basic-usage.md
 !     Push rejected, failed to compile PHP app.
 !     Push failed


text: Q: Flutter app does not work on some devices i develop mobile app by flutter,but release apk of my app does not work or install on some devices for example samsung a10, p.s it works on some devices for example(s10 plus or xiaomi note7 pro), how can i find what is issue?


text:
Q: Looking for a Form Validation Test I am trying to find a way to test and verify my form validation is doing all it can to protect me from script injections. Is there a tool that I can use to test and verify my forms for any known vulnerabilities.

A: Are you talking about Webdevelopment?
You should prevalidate your forms using javascript or jquery logic. But this will not bring you any security, it will just reduce server traffic, because non valid forms will not be send to the server doing so.
Further more you have to validate your forms at the server using php or what ever you use on server side.
Do not forget to use htmlspecialchars whenever you display variable input values to be aware of xss attacks.
Use mysqlrealescapestring or some escaping for the dbs you are using. If you use an orm escaping is mostly done automaticly.
you asked for a tool? you can use the zend framework, it is complicated but it has some form validation automatisms.
E.g: you can validate ISBN numbers, email addresses or bar codes with it automatically.

A: I noticed this question was never answered well enough for me to except an answer. I ended up using a form fuzzer. A browser add on like this https://addons.mozilla.org/en-US/firefox/addon/immuniweb-self-fuzzer/ will enter data into the form inputs and try to break your form validation inputing various kinds of data. Best to work on a development/sandbox type environment since the data input an potentially destroy your database.


text:
Q: Can plasma cast a shadow I was on Science fiction and fantasy and there was a question on wether or not a lightsaber can cast a shadow, but that would depend on wether or not plasma can cast a shadow.
I became curios and I would like to further my knowledge on the Physics of plasma.
I know little about the physics of light, and much less plasma, so add as much detail to your answer as you can for my learning sake.

A: It depends on whether the light sabre is "optically thick" to light. For a fully ionised plasma and a continuum light source, you would be relying on Thomson scattering from free electrons to provide opacity. The cross-section per electron is $\sigma = 6.6\times 10^{-29}$ m$^2$ and independent of wavelength.
The mean free path of light in the plasma is $(n\sigma)^{-1}$, where $n$ is the electron number density. This then has to be  smaller than the width of the sabre "beam" if it is to block the light and cast a shadow. If we imagine the "beam" width is about 5cm, then $ n> (0.05\sigma)^{-1} = 3\times 10^{29}$ m$^{-3}$.
If the plasma is pure ionised hydrogen, then it would have a density of 500 kg/m$^3$, so I guess this is just about conceivable/portable.
Of course you could cheat. For example if you take a partially ionised plasma and then only illuminate it with a lamp that emits photons at the discrete resonant frequency corresponding to a particular atomic/ionic transition in the plasma, then it could be much sparser and cast a shadow because resonant cross-sections are much greater than the Thomson scattering cross-section.

A: Take a near-colourless Bunsen burner flame.
If you add some sodium (eg a spray of salt water), you will see the typical emission spectrum of excited sodium atoms.  But the flame will also contain large amounts of ground state sodium atoms.
Now turn on a sodium vapour lamp (low pressure).  Again, you will see the same sodium atomic emission spectrum.
But you will also see the flickering black shadow cast as the cool sodium in and above  the flame absorbs the light from the sodium lamp.

A: I found this experiment with plasma : A laboratory plasma experiment for studying magnetic dynamics of accretion discs and jets

. A high-speed multiple-frame CCD camera reveals images of the formation and helical instability of a collimated plasma,

Images of plasma evolution (shot 1210; peak αgun≈66 m-1)in which a plasma column forms and persists for many Alfvén transit times, illustrating the magnetic topology required for an astrophysical jet.

They are using hydrogen and are studying the magnetic control of plasma. One can see thicker lines.
I tried seeing the shadow of a candle flame(though not a plasma, still it is an emitter of light) using a flashlight:  there was a mist around the wick shadow, the light interacting with the burning molecules of wax.
If the imaginative lightsaber  is molded by magnetic fields it looks as if there should be  a shadow in a strong light source.


text:
Q: If $f$ is analytic in and on simple loop $C$, then if $z_0$ lies inside $C$ then $f(z_0)$ lies inside the image $f(C)$ How can I start on this?
I'm thinking about somehow using the maximum and minimum modulus principle so I can guarantee that $f(z_0)$ lies in a annulus-sector region, given by $z_1<|z|<z_2$ and $\theta_1 < \arg(z)<\theta_2$, where they are the minimum and maximum arguments and moduli of $f(z)$. I think that I am allowed to estimate the location of $f(z_0)$ in this way because $\log(f(z))=\text{Log}(|f(z)||+i\arg(f(z))$, and both are harmonic functions.
I've tested it out on desmos, and I have experimentally supported that the property referenced in the question title is true, but I can't seem to prove it. It works for all simple closed contours $C$, which satisfies my needs, but I can't seem to prove it. I know that I'm especially missing something because it holds for even simple concave contours.

A: Only if $z_0$ is not an omitted value of $f$.
Example : consider $f(z) = e^z$ on |z|<1. Then $f(z)$ is analytic in $|z|<1$.
Take $z_0= 0$. Then $f(z) \neq z_0$ for all $z\in |z|<1$.
If $z_0$ is not omitted value of $f$,  then by open mapping theorem, the result follows


text:
Q: Windows batch file to group 1000 files into alphanumeric folders This is my first post/request on here.  I've done numerous searches to try and find a solution, but I think my requirement is a tad ambitious.
I'm using Windows 7 and would prefer to do this in a DOS batch file rather than PowerShell.
I have folders containing 10s of thousands of old Zip archives.  Since there are so many files in one folder, it can be slow to list them.  I want to move the Zip archives into alphabetised folders, but each folder needs to be limited to 1000 files
So the first 1000 a*.zip files would be moved into a folder named A1. The second thousand a*.zip files into a folder named A2 and so on.
The files would need to be moved in order, so that if the last file copied into A1 is an_example_file_97.zip, then the first file moved into the A2 folder would be an_example_file_98.zip
I would need to do this for the whole alphabet and also numerically named Zip archives.  Then I would end up with a folder/file structure like this...
<DIR> 01
    1000 zip archives whose filename begins with a number
<DIR> 02
    Next 1000 zip archives whose filename begins with a number
<DIR> 03
    Next 1000 zip archives whose filename begins with a number

<DIR> A1
    1000 zip archives whose filename begins with A
<DIR> A2
    Next 1000 zip archives whose filename begins with A
<DIR> A3
    Next 1000 zip archives whose filename begins with A
<DIR> B1
    1000 zip archives whose filename begins with B
<DIR> B2
    Next 1000 zip archives whose filename begins with B
<DIR> B3
    Next 1000 zip archives whose filename begins with B

<DIR> Z1
    1000 zip archives whose filename begins with Z
<DIR> Z2
    Next 1000 zip archives whose filename begins with Z
<DIR> Z3
    Next 1000 zip archives whose filename begins with Z

My apologies if this solution already exists on this site, but it's tricky to know exactly what to search for.
Thank you.

A: This is the same LotPings' answer, but with a couple small modifications that make it simpler and faster:
@Echo off
SetLocal EnableExtensions EnableDelayedExpansion

PushD "X:\start\here"
for %%A in (*.*) Do (
   Set "Name=%%~nA"
   Set "N=!Name:~0,1!"
   If "!N!" lss "a" Set "N=0"
   Set /A "Array[!N!]+=1, F=Array[!N!] / 1000 +1"
   Set "Dest=!N!!F!"
   If not Exist "!Dest!" REM MD "!Dest!"
   Echo Move "%%A" "!Dest!\"
)

If the listing of plain for %%A command is not sorted, then change the for %%A in (*.*) Do ( line by these two lines:
for %%L in (0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) Do (
   for /F "Delims=" %%A in ('Dir /B /ON %%L*') Do (

... and add a closing parentheses at end. This is better than a simple for /F "Delims=" %%A in ('Dir /B /ON *') Do ( because if the number of files is huge, then the execution of such a for could take too much time...

A: In PowerShell I'd probably approach it as follows (not really caring for efficiency for now):

*

*Get list of files:
Get-ChildItem |

*Sort them by name (with numbers in the name sorted numerically instead of alphabetically)
Sort-Object {
  [regex]::Replace($_.Name, '\d+', { '{0:0000000000}' -f ([int]$args[0].Value) })
}

This will take care of sorting some-name-100 after some-name-99.

*Group by first character:
Group-Object {
  $first = $_.Name[0];
  # Emit only a 0 for all numbers
  if ($first -match '[0-9]') { '0' } else { $first }
} |

*Take those groups and divide them into batches of at most 1000 elements
ForEach-Object {
  $name = $_.Name
  $group = $_.Group
  0..([Math]::Floor($_.Count / 1000)) |
    ForEach-Object {
      $items = $group[($_ * 1000)..($_ * 1000 + 999)
      [pscustomobject] @{
        FirstLetter = $name
        Index = $_ + 1
        Items = $items
      }
    }
} |

*Create folders and move files to their respective folders
ForEach-Object {
  $dir = New-Item Directory ($_.FirstLetter + $_.Index)
  $_.Items | Move-Item -Destination $dir
}

This is untested, but should more or less work, probably. For testing you should perhaps test on dummy data and include a -WhatIf on the Move-Item.
All this is going to be much more painful in cmd than PowerShell, especially things like grouping, or sorting numerically.

A: Contrary to Joey I don't think it's to complicated or painful for batch.
Counting in an Array requires two level delayed expansion inside a for loop but that's it.
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
PushD "X:\start\here"
for /F "Delims=" %%A in ('Dir /B /ON *') Do (
  Set "Name=%%~nA"
  Set "N=!Name:~0,1!"
  Echo !N!|Findstr "[0-9]" 2>&1>NUL &&Set N=0
  Set /A "Array[!N!]+=1"
  Call Set "Count=%%Array[!N!]%%"
  Set /A "F=!Count! / 1000 +1, I = !Count! %% 1000"
  Set "Dest=!N!!F!"
  If not Exist "!Dest!" REM MD "!Dest!"
  Echo Move "%%A" "!Dest!\"
)
Set Array[
Pause
Popd

While testing the MD command is REMed out,
The Move command is only echoed.
Take a look at the counting Array[ variable finally output to see how much dirs would be created.
Shorted sample output:
Move "WSH_Shell_4.html" "W1\"
Move "xyz" "x1\"
Move "yarn.bat" "y1\"
Move "ZehnerZaehlen.cmd" "Z1\"
Move "zeiten.txt" "z1\"
Array[0]=7
Array[A]=10
Array[B]=3
Array[c]=30
Array[D]=19
Array[E]=15
Array[F]=18
Array[G]=29
Array[H]=11
Array[I]=9
Array[J]=2
Array[K]=1
Array[L]=9
Array[m]=20
Array[N]=5
Array[O]=4
Array[P]=11
Array[r]=16
Array[S]=25
Array[T]=17
Array[U]=19
Array[v]=3
Array[W]=19
Array[x]=1
Array[y]=1
Array[Z]=2

A: @ECHO Off
SETLOCAL ENABLEDELAYEDEXPANSION
SET "sourcedir=U:\sourcedir\t w o"
SET "destdir=U:\destdir"
SET "oldc1=*"
SET "oldsd=*"
SET "dircnt=4"

FOR /f "delims=" %%a IN (
 'dir /b /a-d /on "%sourcedir%\*.zip" '
 ) DO (
 SET "c1=%%a"
 SET "c1=!c1:~0,1!"
 IF /i "!c1!" neq "!oldc1!" (
  REM we changed initial character
  SET "oldc1=!c1!"
  SET "destsd=!c1!"
  FOR %%b IN (0 1 2 3 4 5 6 7 8 9) DO IF "%%b"=="!c1!" SET "destsd=0"
  IF /i "!oldsd!" neq "!destsd!" (
   SET /a fcount=dircnt-1
   SET /a olddestsd2=9
   SET "oldsd=!destsd!"
  )
 )
 SET /a fcount +=1
 SET /a destsd2=fcount / dircnt
 IF !destsd2! neq !olddestsd2! (
  SET /a olddestsd2=destsd2
  ECHO MD "%destdir%\!destsd!!destsd2!" 2>nul
 )
 ECHO MOVE "%sourcedir%\%%a" "%destdir%\!destsd!!destsd2!\"
)

GOTO :EOF

You would need to change the setting of sourcedir to suit your circumstances.
You would need to change the settings of sourcedir and destdir to suit your circumstances.
The required MD commands are merely ECHOed for testing purposes. After you've verified that the commands are correct, change ECHO MD to MD to actually create the directories.
The required MOVE commands are merely ECHOed for testing purposes. After you've verified that the commands are correct, change ECHO MOVE to MOVE to actually move the files.  Append >nul to suppress report messages (eg. 1 file moved)
Cut-and-paste the post to a .BAT file. Do not attempt to reformat for æsthetic reasons - batch can be quite sensitive to layout.
For testing, I set the value dircnt to 4. Your application requires 1000.
I'd suggest you use some dummy directories for testing.
This routine uses delayed expansion where %var% represents the value of a variable when a code block (parenthesised statement group) is parsed and !var! the value as it may change within the loop.
The first issue is to produce a directory-list in memory This listed is sorted in alphabetical order (/on) and of the basic format (/b) [names only] with no directorynames (/a-d). Each line of lines is then read by the for command and assigned to %%a.
c1 is then employed to contain the first character of the filename which is compared with oldc1 - the previous value so that the destination directoryname is only recalculated when the first character of the filename changes.
If the first character of the filename numeric, then the destination subdirectory will be 0?, otherwise it's the first character of the filename now in c1. We initialise the filecount within this directory to the maximum - 1 and the subdirectory's second character to 9.
This has established the new destination if the destination has changed.
We then increment the count of files moved and calculate the second character of the destination by simply dividing the count-of-files by the files-per-directory. Since batch does integer maths, the result is int(total files with this first character/files per directory), so it starts at 1.
We then detect whether the destination directory has changed, and create the new directory if required.
Then move the file.


text:
Q: Compare two lists and give the matching results to another C# I'm a Electronic Engineer.
I have a strugle in a program I made for an Windows Form Application in C#
and I need your help to deal with it. I have two Lists of strings [num] and [work] with the same size and each value of [num] corresponds to [work] like this:
num work
11  0,4
23  0,5
36  0,333
49  13
...

Then I have the List of strings [lnum] wich is almost like [num] but with less numbers like this:
lnum
23
36
49
...

And What I want to do is to get the correspond value to the numbers that exists in the lnum
like this:
lnum lwork
23   0,5
36   0,333
49   13
...

My code to do so that I've developed is this:
List<string> num = new List<string>();
List<string> work = new List<string>();

List<string> lnum = new List<string>();
List<double> lwork = new List<double>();

for (int i = 0; i < num.Count; i++)
{
    for (int j = 0; j < lnum.Count; j++)
    {
        if(lnum[j] == num[i])
        {
            lwork.Add(Convert.ToDouble(work[j].ToString()));
        }
    }
}

Now the problem is that It seems I'm not doing it in the rigth way if the Lists of numbers have a lot of variables. What I'm doing wrong? What is the best way to do this? What changes of my code I need to make?
If you need further more explanation I'll try to explain with more detail. Sorry for any mistake in English, I'm Portuguese and English is not my nature language and I apolagyse if the title doesn't describe better my struggle.
I really really need your help people, and I'll be forever grateful for your help.
I hope the best weekend for all of you!

A: Build a dictionary from you num and work lists:
Dictionary<string,string> lookup = new Dictionary<string,string>();
for(int i = 0; i < num.Count; i++)
    lookup.Add(num[i], work[i]);

With this lookup dictionary it is easy to create the new pairings:
for(int i = 0; i < lnum.Count; i++)
{
    string lkey = lnum[i];
    string lwork = lookup[lkey];
    ....
}

Of course you should add some error handling, for example if lnum contains strings not found in lookup

A: You can select the lwork values using linq:
Dictionary<String, String> origin = new Dictionary<String, String>();
            // TODO populate origin with key = num and value = work
            PopulateOrigin(origin);

            List<String> lnum = new List<String>();
            // TODO populate lnum list
            PopulateLNum(lnum);

            List<Double> lwork = origin.Where(kv => lnum.Contains(kv.Key)).Select(kv => Convert.ToDouble(kv.Value)).ToList<Double>();


text:
Q: repair mongodb database using pymongo How can I repair a specific mongodb database using "pymongo", similar to "db.repairDatabase" shell command? My goal is to get the freed space back to OS after I drop a few collections in DB, which requires that I repair the DB. Thanks!

A: Repair is not directly exposed via pymongo, but you can actually execute it using "command". In this particular case use:
 db.command("repairDatabase")


text:
Q: SVM multiclassification with MATLAB R2015a I try to use MATLAB R2015a classification toolbox for my 4 classes. I imported my dataset and selected a Gaussian kernel to train my classifier. This is my dataset:
my Data=[9.36 0;8.72 0;9.13 0;7.38 0;8.02 0;12.15 1;11.02 1;11.61 1;
12.31 1;15.23 1;52.92 2;54.49 2;48.82 2;52.00 2;49.79 2;22.46 3;30.38 3;
21.98 3;24.46 3;26.08 3];

Then I export it into my workspace to use it with my new test data, but when I want to use it in work space this error apears:

Variables have been created in the base workspace.
To use the exported classifier trainedClassifier to make predictions on new data, T, use
yfit = predict(trainedClassifier, T{:,trainedClassifier.PredictorNames})
If your new data contains any integer variables, then preprocess the data to doubles like this:
X = table2array(varfun(@double, T(:,trainedClassifier.PredictorNames)));
yfit = predict(trainedClassifier, X)

I don't understand what does it mean exactly and what is T and yfit?
How can I test my new data with this classifier?

A: The thing is that you are trying to predict the classes of the data stored in a cell. First import it as a table.
Home_>import_>file name_>import_>(here choose Table from the imported data part). Now you can use your predictor by providing this table name.

A: yfit= a vector of predicted class labels for predictor data in the table T.
T = Sample data, specified as a table. Each row of T corresponds to one observation, and each column corresponds to one predictor variable. Optionally, T can contain additional columns for the response variable and observation weights. T must contain all of the predictors used to train SVMModel. Multi-column variables and cell arrays other than cell arrays of strings are not allowed.
Test data: example
load newdataset
rng(1);
CVSVMModel = fitcsvm(X,Y,'Holdout',0.15,'ClassNames',{'classname1','classname2'},...
'Standardize',true);
CompactSVMModel = CVSVMModel.Trained{1}; % Extract trained, compact classifier
testInds = test(CVSVMModel.Partition);   % Extract the test indices
XTest = X(testInds,:);
predict(CompactSVMModel,XTest);% test here


text:
Q: Xcode 5.1 Cordova iOS config.xml I know there are several issues with the new version of xcode 5.1/cordova and it simply wont run apps on 64x bit devices / emu but I followed this tutorial and now it somehow works (even though it spits 14 warnings in my case)
But for some reasons config.xml is still being ignored. It's in red and you can't edit it.

Any suggestions?

A: You need to close your xcode. Build again using cordova build and open up again your xcode then you can run your app.


text:
Q: LightsOut game solving method "reduced echolean ".Does it always gives correct result? I am studing the algorithm given here, and
somewhere it is claimed that it is efficent and always give correct result.
But, I try to run the algorithm and it is not giving me correct or efficent output for the following patterns.
For 5 x 5 grid, where (n) is light number and 0/1 state whethere the light is on/off, 1 ON and 0 OFF.
(1)1    (2)0    (3)0    (4)0    (5)0      the output should be 1,7,13,19,25(Pressing this light will make the full grid OFF. But what I am getting is this
(6)0    (7)1    (8)0    (9)0    (10)0     3,5,6,7,8,10,13,16,18,19,20,21,23.
(11)0   (12)0   (13)1   (14)0   (15)0
(16)0   (17)0   (18)0   (19)1   (20)0
(21)0   (22)0   (23)0   (24)0   (25)1

While for some pattern it is giving me correct output as below.
    (1)0    (2)0    (3)0    (4)0    (5)1      the output should be 5,9,13,17,21, and the algorithm is giving me correct result.
    (6)0    (7)0    (8)0    (9)1    (10)0
    (11)0   (12)0   (13)1   (14)0   (15)0
    (16)0   (17)1   (18)0   (19)0   (20)0
    (21)1   (22)0   (23)0   (24)0   (25)0

If somebody need a code let me know I can post it.
Can please somebody let me know if this methods will always give correct as well as efficient result or not ?

A: (I'm the author of the code you linked to.) To the best of my knowledge, the code is correct (and I'm sure that the high-level algorithm of using Gaussian elimination over GF(2) is correct). The solution it produces is guaranteed to solve the puzzle, though it's not necessarily the minimal number of button presses. The "efficiency" I was referring to in the writeup refers to the time complexity of solving the puzzle overall (it can solve a Lights Out grid in polynomial time, as opposed to the exponential-time brute-force solution of trying all possible combinations) rather than to the "efficiency" of the generated solution.
I actually don't know any efficient algorithms for finding a solution requiring the minimum number of button presses. Let me know if you find one!
Hope this helps!


text:
Q: WaitForExit process in Windows XP versus Windows 7 I have a .net console that is working perfectly fine in windows 7 but for some reason if i run the same exact code in windows XP, I am getting errow message "No Process is associated with this object", it then points to prc.WaitForExit();
The code is below:
   string path;

   path = System.IO.Path.GetDirectoryName(
           System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

   Process prc = new Process();
   prc.StartInfo.FileName = path + "\\Process2.bat";
   prc.Start();

   prc.WaitForExit();
   System.Threading.Thread.Sleep(10);
   Console.WriteLine("{0} Task Process2 completed with process ID {1} and return code {2}. ", DateTime.Now.ToString(), prc.Id, prc.ExitCode.ToString());

   System.IO.StreamWriter file =
      new System.IO.StreamWriter(logpath + "\\logfile.txt", true);
        file.WriteLine(DateTime.Now.ToString() + " Task Process2 completed with process ID " + prc.Id + " and return code " + prc.ExitCode.ToString());

  file.Close();

Please help. Any help is greatly apprecaited.


text:
Q: Make free shipping available for certain shipping zones on specific days of the week in WooCommerce I am trying to enable free shipping for specific shipping zones (array) on selected days.
I'm using therefore this code:
add_filter( 'woocommerce_shipping_free_shipping_is_available', 'enable_free_shipping_on_selected_days', 10, 3 );
function enable_free_shipping_on_selected_days( $is_available, $package, $shipping_method ) {

    $shipping_zones = array('US, Europe');

        if ( array_key_exists( $shipping_zones, $rates ) && in_array( date( 'w' ), [ 6, 7 ] ) ) {
        return true;
    }
    return $is_available;
}

But I am getting an error: "Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in.."
Any advice on how to make free shipping available for certain shipping zones on specific days of the week?

A: $rates is not set in your code, hence the error message
To make free shipping available based on shipping zones and specific days of the week, you can use:
function filter_woocommerce_shipping_free_shipping_is_available( $available, $package, $shipping_method ) {
    // The targeted shipping zones. Multiple can be entered, separated by a comma
    $shipping_zones = array( 'US', 'Europe', 'België' );

    // The targeted day numbers. 0 = Sunday, 1 = Monday.. to 6 for Saturday. Multiple can be entered, separated by a comma
    $day_numbers = array( 0, 1, 6 );

    // Message
    $notice = __( 'free shipping available', 'woocommerce' );

    /* END settings */

    // Default
    $available = false;

    // Get shipping zone
    $shipping_zone = wc_get_shipping_zone( $package );

    // Get the zone name
    $zone_name = $shipping_zone->get_zone_name();

    // Checks if a value exists in an array (zone name)
    if ( in_array( $zone_name, $shipping_zones ) ) {
        // Set the default timezone to use.
        date_default_timezone_set( 'UTC' );

        // Day number
        $day_number = date( 'w' );

        // Checks if a value exists in an array (day number)
        if ( in_array( $day_number, $day_numbers ) ) {
            // Clear all other notices
            wc_clear_notices();

            // Display notice
            wc_add_notice( $notice, 'notice' );

            // True
            $available = true;
        }
    }

    // Return
    return $available;
}
add_filter( 'woocommerce_shipping_free_shipping_is_available', 'filter_woocommerce_shipping_free_shipping_is_available', 10, 3 );

// Optional: Hide other shipping methods when free shipping is available
function filter_woocommerce_package_rates( $rates, $package ) {
    // Empty array
    $free = array();

    // Loop trough
    foreach ( $rates as $rate_id => $rate ) {
        if ( $rate->method_id === 'free_shipping' ) {
            $free[ $rate_id ] = $rate;

            // Break loop
            break;
        }
    }

    return ! empty( $free ) ? $free : $rates;
}
add_filter( 'woocommerce_package_rates', 'filter_woocommerce_package_rates', 10, 2 );

Based on:

*

*Make free shipping available on specific days of the week in WooCommerce

*Enable free shipping for products on sale in WooCommerce

*How to restrict WooCommerce shipping zone from certain days of the week


text:
Q: I am trying to add my data to database and this error showed up The model backing the 'DonorContext' context has changed since the database was created. Consider using Code First Migrations to update the database
Where did I go wrong?
This is my controller
  public class RegisterController : Controller
{
    private DonorContext dc = new DonorContext();
    // GET: Register
    public ActionResult Create()
    {
        return View();
    }

    [HttpPost]
    [AllowAnonymous]
    public ActionResult Create(RegisterModel registerModel)
    {
        if (ModelState.IsValid)
        {
            dc.RegisterModel.Add(registerModel);
            dc.SaveChanges();
            return RedirectToAction("Login","Account");
        }
        return View();
    }
}

This is my model
 public class RegisterModel
{
    public int Id { get; set; }
    public string UserName { get; set; }
    public string Password { get; set; }
}

This is my DAL
 public class DonorContext : DbContext
{
    public DbSet<DonorModel> DonorModel { get; set; }
    public DbSet<RegisterModel> RegisterModel { get; set; }
}

A: This simply means that your model has become out of sync from the database, probably if you looked at the database you would probably see that there is a difference in the columns or something like this.
By default Entity framework will just report this as an error, but you can change this behaviour.
As it suggests you can switch on code first migrations (see here for process), the advantage to this, is that you can use the Update-Database command (in the package manager console) to update the database schema.
It is also possible to get this to run automatically whenever your application runs, but I would recommend caution when dealing with Database schema. You ideally want to ensure your model is exactly the way you want it before you make changes in the DB

A:
The model backing the 'DonorContext' context has changed since the
  database was created. Consider using Code First Migrations to update
  the database

If you used Code-First Migration
And previously you implement and model like
public class RegisterModel
{
    public string Id { get; set; }
    public string UserName { get; set; }
    public string Password { get; set; }
}

And now you changed the model means by changing any property datatype or adding any property as your need like
public class RegisterModel
{
    public int Id { get; set; }
    public string UserName { get; set; }
    public string Password { get; set; }
}

Here i changed property "Id" datatype from string to int
Then the above error occurred while you run you project
Question: Why this above error comes?
Answer:
In simple language,
In Entity Framework Code-First Migration, you always saw the "_MigrationHistory" table in database so this table contains all the entries that you made while you enabling migrations to your project.
If you change any model property or datatype then those models are mismatch with entries in "_MigrationHistory" table
So the entity framework throws an exception and as a result above error comes.
Again
Question: How can i get rid from this error?
Answer: Just open package manager console and type "update-database -verbose" and hit Enter key.
Note: -verbose gives you all your changes details on console that you made now.
Be sure before this, the data loss may happen.


text:
Q: Need a little recursion in RELAX NG external references We've been using RELAX NG to specify and validate XML messages for our web-based API, and I was doing some housecleaning and started to make use of the <external> element.
In our schemas we have a <subscription> element, which has things like id and a period and so on, and also an <account>. This is pretty simple to spec in RELAX NG:
<?xml version="1.0"?>
<element name="subscription" xmlns="http://relaxng.org/ns/structure/1.0">
  <element name="id">
    <text />
  </element>

  <zeroOrMore>
    <externalRef href="./account.xml" />
  </zeroOrMore>
</element>

This schema would then be included by the actual message schema for a particular request.
The problem is that the <account> element can also have a number of <subscription> elements depending on the request (for example, sometimes we are searching for subscription data based on account information, and sometimes we would be searching for account information based on subscription data).
I tried:
<?xml version="1.0"?>
<element name="account" xmlns="http://relaxng.org/ns/structure/1.0">
  <element name="id">
    <text />
  </element>

  <zeroOrMore>
    <externalRef href="./subscription.xml" />
  </zeroOrMore>
</element>

But I got a (not unexpected) error when loading the schema: Detected an externalRef recursion
Is there a way to specify some kind of recursion limit - some way to know that my current <subscription> is a child of <account> and so should not have <account> children itself?

A: As long as you point to the subscription element defined in you first Relax NG, the substruture has to match the pattern you are pointing to.
To achieve your goal, you should have another pattern definition for another subscription element with a different substructure.
Something like :
<define name="subscriptionDEF-2">
    <element name="subscription">
        <text/>
    </element>
</define>

And refer to if from your account element with a ref element.
<element name="account">
    <ref name="subscriptionDEF-2"/>
</element>


text:
Q: Ubuntu One v2 for Windows doesn't install or run properly I had the Beta 1 installed on Windows 7, downloaded v2 and

*

*It doesn't install properly as there's no way of UNINSTALLING it in
Control Panel

*It won't synchronise nor start up at startup.

*When I click on the icon it starts OK giving me the normal dialog box
but I also get a huge pop-up full of gibberish. Here is a screenshot:

*It also says that syncing is up to date when it plainly isn't - I
saved a file to my Ubuntu One folder in Windows today and the version
on my Ubuntu One web page is still showing the previous one from four
weeks ago...
So how do I either completely uninstall, or fix this?

A: Ok, that looks like you are getting a 500 error from the ubuntu one server when trying to retrieve your account information (let it be account info, which devices you have, or shares and folders).
I'd say we should file two different bugs for this issue:

*

*That dialog is a horrible user experience.

*We should take a look of why your are getting that 500.

I have filled bug 1 but I cannot fill bug 2 for you. Can you please go to the bugs page  and explain the steps you followed and zip the folder in C:\Users\%your_user%\AppData\Local\xdg
Please do make sure that you mark the bug as private until we make sure that there is no important data there.


text:
Q: Is there any easy way to put boxes around text of selected pages with the page number below the box? I'd like to be able to create boxes around a whole page or selection of pages with the box extending the full length of the page but with the bottom edge of the box above the page number as in the attached example.  It would be ideal if this could be defined as an environment so that all pages in that environment are boxed.  This environment could be used to set an executive summary off from the rest of the document.
Any hints or suggestions would be much appreciated.

A: With tikz and eso-pic. I've defined two commands, \addframe and \removeframe which, respectively, add the frame and remove the frame in the page.
MWE:
\documentclass{article}

\usepackage{tikzpagenodes}
\usetikzlibrary{calc}

\usepackage{eso-pic}

\newcommand{\addframe}{%
  \AddToShipoutPicture{%
  \begin{tikzpicture}[remember picture, overlay]
      \draw[line width=1pt]
           ($(current page text area.north west) +(-5mm,5mm)$)
           rectangle
           ($(current page text area.south east) +(5mm,-5mm)$);
  \end{tikzpicture}%
  }%
}

\newcommand{\removeframe}{\ClearShipoutPicture}

\usepackage{lipsum} % just for the example

\begin{document}
\addframe
\lipsum[1-10]
\clearpage
\removeframe
\lipsum[1-10]
\clearpage
\addframe
\lipsum[1-10]
\end{document}

Output:

You can adjust the parameters (1pt for the thickness and 5mm for the distance from the text) as you want.
Alternatively, you can define \addframe in this way
\newcommand{\addframe}{%
  \begin{tikzpicture}[remember picture, overlay]
      \draw[line width=1pt]
           ($(current page text area.north west) +(-5mm,5mm)$)
           rectangle
           ($(current page text area.south east) +(5mm,-5mm)$);
  \end{tikzpicture}%
}

and use \addframe in every page where you need the frame, as in the following MWE:
\documentclass{article}

\usepackage{tikzpagenodes}
\usetikzlibrary{calc}

\newcommand{\addframe}{%
  \begin{tikzpicture}[remember picture, overlay]
      \draw[line width=1pt]
           ($(current page text area.north west) +(-5mm,5mm)$)
           rectangle
           ($(current page text area.south east) +(5mm,-5mm)$);
  \end{tikzpicture}%
}

\usepackage{lipsum} % just for the example

\begin{document}
\addframe
\lipsum[1-10]
\clearpage
\lipsum[1-10]
\clearpage
\addframe
\lipsum[1-10]
\end{document}

A: You can use package mdframed to do this.
mdframed is very customizable, you can define a backgroundcolor and much more things.
If you want your boxes to appear everywere using the same style, best practice is to define a new environment with newmdenv, setinng some style options. In this case, the standard is used, a single frame around the box. You can later overrule the settings locally by giving options to the environment, as seen in the second example.
\documentclass{article}
\usepackage{mdframed}
\newmdenv{boxed}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{boxed}
\blindtext

\blindtext
\begin{description}
    \item [something] \blindtext
    \item [something else] \blindtext[2]
\end{description}
\end{boxed}

\blindtext

\begin{boxed}[backgroundcolor=yellow]
    \blindtext
\end{boxed}
\end{document}


text:
Q: How to obtain Role in Liferay Themes? How to obtain Role of a logged in User in Liferay Themes? How to check if User belongs to a particular role?

A: UserLocalService has hasRoleUser method which can be used to find out if User belongs to a particular role.
Below code can be put in navigation.vm file under templates folder.
#set($UserLocalServiceUtil = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#if ($UserLocalServiceUtil.hasRoleUser(roleID, $user.getUserId())) // It takes roleID as input to check.
  //Proceed with whatever you want to
#else
  //Proceed with something else

Note: Instead of com.liferay.portal.service.UserLocalService, if you use com.liferay.portal.service.UserLocalServiceUtil,
  as might be found in some resources like this then you will encounter below exception,
ERROR com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No
  bean named 'com.liferay.portal.service.UserLocalServiceUtil' is defined
  com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.liferay.portal.servi
ce.UserLocalServiceUtil' is defined

Another way is,
#set($role=$serviceLocator.findService("com.liferay.portal.service.RoleLocalService"))
$role.getUserRoles($user_id)

A: Just loop through the $user object defined in init.vm
#set ($user_roles = $user.getRoles())
#foreach($role in $user_roles)
   $role.name<br />
#end


text:
Q: Which "Standard arrows" (Wooden, Large etc) are the same "weight" as "Special arrows"? In DkS1 and DkS2, there are several types of arrows you can use; both "plain" (wooden, large, etc) and "special" (like Poison, or Fire for example). However, if you compare the flight of a Standard Arrow to the flight of a Heavy Arrow, you will find they have different trajectories. I.e, a Heavy Arrow will not fly as far as a Standard Arrow, if you aim at the same point.
Now, my question is; which "Standard arrow" variant has the same trajectory as a "Special arrow"?
Note: I realize that this may be different between games, and that there are different versions in either game (e.g. DkS2 has "Special" Great Arrows, while DkS1 does not)

A: Dark Souls 1 Answer - Standard Arrows.
This was tested in the invasion of Lautrec's World. I tested both the Poison and Fire Arrows, with comparison against Wooden, Standard, Feathered, and Large arrows.


text:
Q: How to change html content using JavaScript or JQuery? How to change html content using JavaScript or JQuery?

I want to change contents from 1 to 5 sequentially according to the time as stated in the picture. What should I do using JavaScript or JQuery?
Please let me know if you have any search keywords or links to related documents.

A: As per the picture, I assume that you want to randomly shuffle the contents each day.
you can do this by using an array of contents and on each day randomly select an element from the array and set it as the content of div using DOM manipulation.


text:
Q: Retrieving value of a radio button I'm trying to retrive a value of selected radio button but getting undefined value, why?
Here is my code:
$(document).ready(function(){

 /* var col = document.querySelector('input[name="color"]:checked').value();(didn't work either) */

var col = $('input[name=color]:checked').val();

/* printing value (giving me undefined) */

document.write(col);

 Please pick your colour

<input type = "radio" name="color" value="red">Red

<input type = "radio" name="color" value="blue">blue

<input type = "radio" name="color" value="green">green

<input type = "radio" name="color" value="yellow">yellow

A: Try:
var col = $('input:radio[name=color]:checked').val();

A: If you're trying to do this on document ready, then there is no result because nothing is checked. To get the checked item when it changes:
$("input[name='color']").click(function(){
    var col = $(this).val();
    console.log(col);
});

A: The reason you're getting undefined is that nothing is selected on document ready.  You have to give something the checked property if you want to have a value on load.
If you're trying to get the value when it's clicked then you need to have a click handler for that.  Here is an example of binding the click event.
http://jsfiddle.net/4f7kC/
If you just want to get the value on load simply add a checked="checked" to any one of those radio buttons like so <input type = "radio" name="color" value="yellow" checked="checked">yellow