text:
Q: Variadic Tuple Types: example from the docs TS beginner.
In docs it says in JS we could have such function:
function concat(arr1, arr2) {
  return [...arr1, ...arr2];
}

Then it says

For concat, the only valid thing we could do in older versions of
the language was to try and write some overloads.

And then proceeds to show overloads (not all shown):
function concat(arr1: [], arr2: []): [];
function concat<A>(arr1: [A], arr2: []): [A];
function concat<A, B>(arr1: [A, B], arr2: []): [A, B];
function concat<A, B, C>(arr1: [A, B, C], arr2: []): [A, B, C];
.......

My question is: why in the  older versions of the language we would need to use so many overloads? Are there no better primitives in the older versions of the language to type that function?
Basically I want an answer which explains why none of the existing primitives in the older version of the language could be used to type this
For example why not use concat(arr1: any[], arr2: any[])? etc.
Or why not use just tuples? Why we needed variadic?

A: The primary goal of TypeScript is to add type information to otherwise untyped bare JavaScript. There are constructs like any that don't have type information, but they have specific purpose to be a temporary placeholder for transitioning from bare JavaScript to TypeScript.
When using TypeScript and writing a custom concat(…) function, one might want to reflect the fact that concat([T, U], [V, W]) is not just some array, but precisely [T, U, V, W].
("T", "U", "V", and "W" here are common placeholders for types.)
Now imagine that this function can accept any two arrays of any type. In order to write typings for such a function using pre-4.0 TypeScript you would have to use function overloads. This quickly gets very repetitive:

*

*"if the first array is [] and the second array is [], the result is []"

*"if the first array is [T], and the second array is [], the result is [T]"

*"if the first array is [T, U], and the second array is [], the result is [T, U]"

*"if the first array is [], and the second array is [V], the result is [V]"

*"if the first array is [T], and the second array is [V], the result is [T, V]"

*…

… and so on. That's very painful, isn't it?
With TypeScript 4.0+ you can just infer the types of the input arrays and combine them ahead of time:

*

*"the first array is some tuple A, and the second array is some tuple B, and the result is [...A, ...B]"
All the necessary information is there, there's nothing left to add. Hence, you don't need to use the repetitive and verbose overloads.

A: it is mentioned right after:
"TypeScript 4.0 brings two fundamental changes, along with inference improvements, to make typing these possible."
Inference is the key word here. In other words typescript became smarter in understanding the code and figuring out which possible types could result out of [...arr, ...arr2]
In older versions you would need to do the "hard" work, now typescript is doing it for you.


text:
Q: Creating a DOM element on the fly, but fading it in I'm having a problem creating a DOM element, appending it to another element and having it fade into place.
This doesn't seem to work:
$('
').html('hello').appendTo('#parentDiv').fadeIn();

Can anybody put me on the right track

A: Try:
$("
hello
").hide().appendTo("#parentDiv").fadeIn();

or alternatively set display none instead of hide().

A: Have you tried
$('
').html('hello').appendTo('#parentDiv').hide().fadeIn();

redpajama_set_name: RedPajamaStackExchange


text:
Q: Azure RBAC Permissions Tree? Is there a way to query Azure (via REST or CLI) to see which permissions are required/granted for certain actions?
For example, if I wanted to assign an SPN with Microsoft.Compute/virtualMachines/write permissions so it could create a VM, I would want to review what other permissions are granted/required before assigning it to said SPN.

A: As far as I know there is no way to list dependencies in the way you describe. The Powershell cmdlet Get-AzureRmProviderOperation gives some good information on what permissions needed.
https://learn.microsoft.com/en-us/powershell/module/azurerm.resources/get-azurermprovideroperation?view=azurermps-5.0.0

A: The Actions property of a custom role specifies the Azure operations to which the role grants access. It is a collection of operation strings that identify securable operations of Azure resource providers. Operation strings follow the format of
Microsoft.<ProviderName>/<ChildResourceType>/<action>
Use Get-AzureRmProviderOperation (in PowerShell) or azure provider operations show (in Azure CLI) to list operations of Azure resource providers.
For more details, refer "Create custom roles for Azure Role-Based Access Control".


text:
Q: Unity - stop animation loop How can I stop make unity continuous looping
what I have done
1- I add animator to my object.
2- I create animator controller
3- I create my animation
4- finally link my animation controller to my object

it works just fine , but it keep looping
how can I make it animate just once

A: In your project panel select your animation and in inspector unCheck Loop Time property. That will stop looping your animation :)


text:
Q: Serverless AWS same layer for multiple services I'm fairly new to AWS and serverless, so far I've been working with lambda functions and layers.
We have two services:
lambda1.yml
service: lambda1
provider: ...
functions:
 hello:
  handler: ...
  name: ...
  layers:
   - { Ref: GlobalLambdaLayer }

layers:
  global:
    path: global_layer

lambda2.yml
service: lambda2
provider: ...
functions:
 hello:
  handler: ...
  name: ...
  layers:
   - { Ref: GlobalLambdaLayer }

layers:
  global:
    path: global_layer

When I deploy lambda1 using 'sls deploy --config lambda1.yml', the layer is uploaded and assigned to lambda1 function succesfully.
However, when I deploy lambda2 using 'sls deploy --config lambda2.yml', Serverless uploads and creates a new layer. It doesn't reuse the one uploaded from lambda1.
According to my research, this is correct because each lambda function is declared in a different service.
My question is. Is my research correct?
I know I can create a separate service to hold my layer and share with both lambdas, as described here:
https://forum.serverless.com/t/layers-upload-on-each-deploy/6634/3
Nonetheless, I'm curious, is there a different way to do it? I can't put both lambdas in the same service. They need to be independent and share the same layer.
Thank you!

A: As I can see that you declared layers: in the both files which create two different layers, but the purpose of layers is to abstract, and resue shared code between functions. So in lambda2.yml no need to recreate a layer you just need to tell your function to use the layer which you already created in lambda1.yml so for lambda2.yml code it should be:
service: lambda2
provider: ...
functions:
hello:
 handler: ...
 name: ...
 layers:
   - { Ref: GlobalLambdaLayer }


text:
Q: Location Accuracy on Windows Phone 8 Is it somehow possible to get the location accuracy?
I know how to get the location, but I would like to know the location accuracy radius in meters, for example.
Thanks to all in advance.

A: When You use class Geolocator:
Geolocator geolocator = new Geolocator();
var acc=geolocator.DesiredAccuracyInMeters;

From docs:
DesiredAccuracyInMeters

Windows Phone only. Gets or sets the desired accuracy in meters for data returned from the location service.

More information about class: LINK

A: If you have a position as a Geoposition you can do this
Geoposition MyGeoPosition
...
double acc = MyGeoPosition.Coordinate.Accuracy;

Accuracy is returned in meters.


text:
Q: How to center horizontal table-cell I want the Content A, Content B, and Content C columns to be horizontally centered. I have this code been trying to add
http://jsfiddle.net/hsX5q/24/
HTML:margin: 0 auto to .columns-container and it doesn't work. Could anyone help?

/*************************
 * Sticky footer hack
 * Source: http://pixelsvsbytes.com/blog/2011/09/sticky-css-footers-the-flexible-way/
 ************************/

/* Stretching all container's parents to full height */

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}
/* Setting the container to be a table with maximum width and height */

#container {
  display: table;
  height: 100%;
  width: 100%;
}
/* All sections (container's children) should be table rows with minimal height */

.section {
  display: table-row;
  height: 1px;
}
/* The last-but-one section should be stretched to automatic height */

.section.expand {
  height: auto;
}
/*************************
 * Full height columns
 ************************/

/* We need one extra container, setting it to full width */

.columns-container {
  display: table-cell;
  height: 100%;
  width: 300px;
  margin: 0 auto;
}
/* Creating columns */

.column {
  /* The float:left won't work for Chrome for some reason, so inline-block */
  display: inline-block;
  /* for this to work, the .column elements should have NO SPACE BETWEEN THEM */
  vertical-align: top;
  height: 100%;
  width: 100px;
}
/****************************************************************
 * Just some coloring so that we're able to see height of columns
 ****************************************************************/

header {
  background-color: yellow;
}
#a {
  background-color: pink;
}
#b {
  background-color: lightgreen;
}
#c {
  background-color: lightblue;
}
footer {
  background-color: purple;
}

    foo

Contents A

Contents B

Contents C

    bar

A: Sometimes you have things other than text inside a table cell that you'd like to be horizontally centered.  In order to do this, first set up some css...

Then declare a div with class="centered" inside each table cell you want centered.

        Anything: text, controls, etc... will be horizontally centered.

A: If you add text-align: center to the declarations for .columns-container then they align centrally:
.columns-container {
    display: table-cell;
    height: 100%;
    width:600px;
    text-align: center;
}

/*************************
 * Sticky footer hack
 * Source: http://pixelsvsbytes.com/blog/2011/09/sticky-css-footers-the-flexible-way/
 ************************/

/* Stretching all container's parents to full height */

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}
/* Setting the container to be a table with maximum width and height */

#container {
  display: table;
  height: 100%;
  width: 100%;
}
/* All sections (container's children) should be table rows with minimal height */

.section {
  display: table-row;
  height: 1px;
}
/* The last-but-one section should be stretched to automatic height */

.section.expand {
  height: auto;
}
/*************************
 * Full height columns
 ************************/

/* We need one extra container, setting it to full width */

.columns-container {
display: table-cell;
height: 100%;
width:600px;
text-align: center;
}
/* Creating columns */

.column {
  /* The float:left won't work for Chrome for some reason, so inline-block */
  display: inline-block;
  /* for this to work, the .column elements should have NO SPACE BETWEEN THEM */
  vertical-align: top;
  height: 100%;
  width: 100px;
}
/****************************************************************
 * Just some coloring so that we're able to see height of columns
 ****************************************************************/

header {
  background-color: yellow;
}
#a {
  background-color: pink;
}
#b {
  background-color: lightgreen;
}
#c {
  background-color: lightblue;
}
footer {
  background-color: purple;
}

    foo

Contents A

Contents B

Contents C

    bar

This does, though, require that you reset the .column elements to text-align: left (assuming you want them left-aligned, obviously (JS Fiddle demo).

A: Short snippet for future visitors - how to center horizontal table-cell (+ vertically)

html, body {
  width: 100%;
  height: 100%;
}

.tab {
  display: table;
  width: 100%;
  height: 100%;
}

.cell {
  display: table-cell;
  vertical-align: middle;
  text-align: center; /* the key */
  background-color: #EEEEEE;
}

.content {
  display: inline-block; /* important !! */
  width: 100px;
  background-color: #00FF00;
}

Content

A: Just add this class in your css
.column p{
   text-align:center;
}


text:
Q: Implementing stripe connect directly from within an iOS app There is a post re: implementing stripe connect from a couple of years ago.
How to use Stripe Connect in an iOS app
I have built an app where only User A needs to register and login while User B can choose from a list of User As and i am trying to set up the app so User B can pay directly to a User A.
While the basic version of stripe is relatively easy to implement Stripe connect is giving me a bit of grief.
Specifically there is an example called Rocket Rider on github (which is meant to.mimic uber, etc.) made by stripe but in this example the "Pilot" had to register via a website.
I'd like it all to happen from within my app. I've read the docs a few.times now and still a touch uncertain.
Is the post from a few years ago still relevant? Is the only way to have the registration done via the app to use a webview?
In the stripe docs there is a section https://stripe.com/docs/mobile/ios/standard
Which essentially goes through the implementation for iOS. But I wasn't sure if these docs only refer to payment that as the developer I would receive if say I was selling a product to users.
Again, in my app there is a list of User As and each User A would register ideally within the app and then User B can choose who to pay. I wasn't sure if the "Standard" doc above also refers to this scenario.
Thanks

A: Been looking into the same thing today (March 2019) and have a few answers for you
The current state of the Stripe Cocoa Pod does not have anything that has to do with connect accounts. That will not help you in any way with creating connect accounts.
All is not lost. If you must stay in-app, you may create what is called a Custom Account--This means that you are responsible for the UI, User Validation, and Communication. Your users will not be able to use the Lovely Express Dashboard either....but you can stay in app.
As you alluded to, you are still able to use Safari to open Stripe Express and have your app handle the deep linking once the experience is complete. While this is an annoyance, there are some serious perks to having the Express experience. You don't have to deal anything bank account related because the Express Dashboard will handle it for you and Stripe will handle all verification communication. (Outside app).
TLDR: You can do it completely in app using Custom Accounts......but you'll be on your own!


text:
Q: jQuery function inside a for loop Lets say that I want to turn the paragraph elements red when I mouseover the corresponding link elements.
Why would the following code not work and what is the simplest alternative?
for (i = 0; i < 100; i++) {
$("a").eq(i).mouseover(function(){
$("p").eq(i).css({"color":"red"})
})
}

Need simple explanation.

A: You dont have to loop through the elements. Do like this,
$("a").mouseover(function() {
    $("p").eq($('a').index(this)).css("color", "red");
});


text:
Q: SwiftUI: On tap gesture switches views I have the following simplified code in a project using XCode 13.2. The intended functionality is to have 2 tabs (Tab1 and Tab2), and the user is able to tap the screen on Tab2 to toggle the background from red to green.
Instead, however, when Tab2 is clicked, the screen displays tab 1, instead of Tab2 with the changed color. I'm wondering why the app goes to Tab1 when Tab2 is tapped.
There are no NavigationLinks or actions that make the user go to Tab1. My only thought is that maybe the app is rebuilding when Tab2 is clicked, which is why it goes back to the first tab? If so, are there any good workarounds for this?
Note: the color still changes on Tab2, but not before the app switches to Tab1.

struct ContentView: View {

    var body: some View {
        TabView {
            Tab1()
                .tabItem {
                    Text("Tab 1")
                }
            Tab2()
                .tabItem {
                    Text("Tab 2")
                }
        }
    }
}

struct Tab1: View {
    var body: some View {
        Text("Tab 1")
    }
}

struct Tab2: View {
    @State var isRed: Bool = false

    var body: some View {
        if !isRed {
            Color.green
                .onTapGesture {
                    isRed = true
                }
        } else {
            Color.red
                .onTapGesture {
                    isRed = false
                }
        }
    }
}

A: I have noticed that using if/else in that way causes strange behavior. Refactor Tab2 as shown below and it should work as expected.
struct Tab2: View {
@State var isRed: Bool = false

var body: some View {
    ZStack {
        Color.red
        Color.green
            .opacity(isRed ? 0 : 1)
    }
    .onTapGesture {
        isRed.toggle()
    }
}

}

A: The reason why tapping on Tab2 causes it to jump back to Tab1 is that the structural identity of Tab2 changes whenever you tap on it causing swiftUI to reload the body. See the explanation here.
A simple fix to the example you have above would be to wrap the entire body in a ZStack
var body: some View {
  ZStack {
    if !isRed {
      Color.green
        .onTapGesture {
          isRed = true
        }
    } else {
      Color.red
        .onTapGesture {
          isRed = false
        }
    }
  }
}


text:
Q: Einstein Summation Convention: One as Upper, One as Lower? My question refers to the often specified rule defining Einstein Summation Notation in that summation is implied when an index is repeated twice in a single term, once as upper index and once as lower index.
Thus, a term that appears such as:
$$
A^i B_i\quad=\quad\sum_i A^i B_i\quad=\quad A^1B_1+A^2B_2+A^3B_3
$$
According to this rule, the following repeated index term would not be summed at all.
$$
A^iB^i
$$
Because the repeated index does not appear as one upper and one lower in the term.  Yet, I sometimes see various texts and other references invoke the Einstein Summation convention when such terms (both indexes upper or both indexes lower) exist.
Now, this aberrant use of Einstein Summation notation often appears in Math texts rather than Physics.  For example, Chapter 1 of the Schaum's Outline Series on Tensor Calculus is named "The Einstein Summation Convention" and goes on to introduce the notation and never mentioning the upper and lower repeated index rule but explicitly gives an example of using repeated lower indexes:
$$
a_1x_1+a_2x_2+a_3x_3+\cdots+a_nx_n = \sum_{i=1}^n a_ix_i
$$
Usually I work with index notation in Physics subjects in my self-study of field theory and General Relativity and I don't recall ever running across examples of the summation convention that do not invoke the repeated index rule as one upper and one lower.  But I am puzzled because in spite of this usage in Physics, I can't see any reason why one index must be upper and the other index lower.  In other words, repeated index both as lower or both as upper does not seem to violate anything (for example, this more lax approach is used throughout the above cited Schaum's book.
My question: does the correct definition of Einstein Summation Convention demand that one index must be upper and the other repeated index must be lower.  Or, is this merely style convention used in Physics (e.g. General Relativity).

A: In the 'strict' sense, you should only apply the summation convention to a pair of indices if one is raised and another is lowered.
For example, consider a vector $v$ and a dual vector $f$ (i.e. a map from vectors to numbers). Then one can compute $f(v)$, the number that results from $f$ acting on $v$. In components, this would be written as $f_i v^i$, since dual vectors have lower indices.
If, instead, you have two vectors $v$ and $w$, there is generally no way to combine them into a number, and the quantity $v^i w^i$ makes no sense. But if you have a metric $g_{ij}$, you can use it to turn $w$ from a vector into a dual vector, with new components $g_{ij} w^j$. Then you can act with this dual vector on $v$, giving $g_{ij} v^i w^j$. Note that all indices are paired correctly.
That being said, there are lots of exceptions:

*

*A lot of field theory texts and even GR texts will write $v^i w^i$, but you're supposed to remember it really means $g_{ij} v^i w^j$. When you do explicit computations, you have to put that factor in yourself.

*If you're working in a space with a simple metric (like Euclidean space, where $g_{ij}$ is the identity), texts might omit $g_{ij}$ because it doesn't "do anything". That is, the vector $w^j$ and corresponding dual vector $g_{ij} w^j$ always have the exact same components, so they might as well identify them.

*If the previous point is true, the author might choose to use index position to store some other kind of information, so the summation convention remains 'strict'. This happens more often in non-physics texts.

There are enough possible conventions that you should just check the front of the book every time.

A: There is nothing wrong by summing up indices when both indices are either up or down. It is just a matter of convention. However the meanings can be different if you are in a Relativistic theory.
When you sum one up and one down indices in Relativity it means you have a Lorentz invariant quantity because you are combining covariant and contravariant components in such a way that the combination does not change under Lorentz Transformations. This is a (nice) rule adopted by most authors and its importance is in the fact we can immediately identify invariant quantities. A few authors though use always down indices even for relativistic theories. For instance, Rubakov's Classical Theory of Fields.
If you are in Euclidean space, there is nothing to worry about. Normally people use all indices down.


text:
Q: Idiom for being skilled There's a recently-created idiom to assert that one has skills, and I don't remember what it is. It sounds like it was created by a Millennial. I want to say it has either a martial-art or science-fiction vibe, but it might be just a little silly wordplay.
It's something along the lines of:

*

*"My troubleshooting game is strong."

*"She has good birdwatching force."

*"He has mad baby-sitting skillz."

I think it takes the form of: "My [skill] <idiom> is good." where [skill] is replaced by whatever the skill or field is, and <idiom> is the word I can't remember.
Please suggest alternate expressions that have originated in about the past few years (post-2010) that one might use to claim proficiency with a skill.

A: The idiom in question is the ending -fu (wiktionary)

Suffix[edit]
-fu
(slang) Used to form nouns indicating expertise or mastery of specified skill or area of knowledge
My Google-fu is weak!
Aragorn uses Ranger-fu to figure out that Sam and Frodo have taken a boat.

It comes from kung-fu, most commonly seen as google-fu


text:
Q: T-SQL left join a table with UDF I have a table with Employee ID, and an UDF with ID as parameter. How can I join this table left join MyUDF on EmployeeNumber. Something like
Select T.*, U.* FROM MyTable T leftJoin MyUDF(T.id) U
On T.id = U.id

I tried CROSS APPLY but it returns too much row because of Crossing. I couldn't find left join equivalence of CROSS APPLY. Any help would be greatly appreciated

A: Select T.*, U.*
FROM MyTable T
           OUTER APPLY dbo.MyUDF(T.id) U
WHERE T.id = U.id


text:
Q: PHP / MySQL: How to modify working Select when the result is always one row I am new to PHP and MySQL and am looking for some help with the following.
Usually when I need to fetch data from the db and I know the result will be more than one row than I fetch the data and store it an array as below for further use in PHP which works as intended:
$sql = "SELECT " . $selectedLang . ", tID, info FROM TranslationsMain WHERE location LIKE '%language main%' ORDER BY " . $selectedLang;
$result = $conn->query($sql);
while($arrLanguagesMain = $result->fetch_assoc()){
    $languagesMain[] = $arrLanguagesMain;
}

Now I have a scenario where the result will always be just one row.
Currently I use the following query for this but in this case I don't need an array (this returns e.g. "Array ( [en] => English )" ).
Here I simply need it to return the value from the column $selectedLang which in this example would be "English".
$sql = "SELECT " . $selectedLang . " FROM TranslationsMain WHERE info = '" . $selectedLang . "'";
$result = $conn->query($sql);
while($arrSelectedTrans = $result->fetch_assoc()){
    $selectedTrans = $arrSelectedTrans;
}

Can someone tell me what is the best / preferred approach to modify the above so that it returns a single value instead of creating an array ?
Many thanks in advance.

A: Just get the value of that array by its index:
$sql = "SELECT " . $selectedLang . " FROM TranslationsMain WHERE info = '" . $selectedLang . "'";
$result = $conn->query($sql);
while($arrSelectedTrans = $result->fetch_assoc()){
    $selectedTrans = $arrSelectedTrans[$selectedLang];
    //you can use break; here to make sure it runs only once
}

A: You can try using

fetch_object()

$sql = "SELECT " . $selectedLang . " FROM TranslationsMain WHERE info = '" . $selectedLang . "'";
$selectedTrans = $conn->query($sql)->fetch_object()->$selectedLang;

A: I figured out a way that works best for me here:
To select the single row:
$sql = "SELECT " . $selectedLang . " FROM TranslationsMain WHERE info = '" . $selectedLang . "' LIMIT 1";
$result = $conn->query($sql);
$selectedTrans = $result->fetch_assoc();

...and to echo it somewhere on the page:
echo $selectedTrans[$selectedLang];

Thanks anyways for the help.


text:
Q: JS - If it contains text in class x, then it takes the value from class y Ahoy, I have a question regarding JS, more specifically, I have a situation like below in the code and I would like to create a script that if there is a value of Xx in class X, it gets me the value of Yy from class Y. In this case, it is about "Color" and "Black".

    Kolor

      czarny


text:
Q: Make validation fail for a certain enum value with asp.net mvc Does there exist an enum validation attribute which validates a certain enum value?
Or should I do that manually:
if(viewModel.State == State.None) base.AddModelError("","wrong enum selected...");

How would you do that?

A: Enum:
public enum SomeEnum
{
    Right = 1,
    Wrong = 2,
    Other = 3
}

ViewModel:
public class TestModel
{
    [Range((int)(SomeEnum.Right), (int)(SomeEnum.Right), ErrorMessage = "Please select an Enum value")]
    public SomeEnum Value { get; set; }
}

No other code needed. Enums are basically integers so you can use the Range attribute to validate them.

A: I would create my own validation attribute something like (untested):
public enum SomeEnum
{
    Right,
    Wrong
}

[AttributeUsage(AttributeTargets.Property)]
public sealed class EnumValueAttribute : ValidationAttribute
{
    private const string DefaultErrorMessage = "Cannot be that value";

    public SomeEnum EnumVal { get; private set; }

    public EnumValueAttribute(SomeEnum enumVal)
        : base(DefaultErrorMessage)
    {
        EnumVal = enumVal;
    }

    public override string FormatErrorMessage(string name)
    {
        return string.Format(ErrorMessageString, name, EnumVal);
    }

    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        var enumVal = (SomeEnum) Enum.Parse(typeof (SomeEnum), value.ToString());
        if (enumVal != EnumVal)
        {
            return new ValidationResult(DefaultErrorMessage);
        }

        return ValidationResult.Success;
    }
}

Usage:
public class TestModel
{
    [EnumValue(SomeEnum.Right)]
    public SomeEnum Value { get; set; }
}

UPDATED
So this is as generic as you can reasonably take it, I've not tested this code, but it does compile. Notice that I've assigned number values to the enums.
public enum SomeEnum
{
    Right = 1,
    Wrong = 2,
    Other = 3
}

[AttributeUsage(AttributeTargets.Property)]
public sealed class DisallowEnumValueAttribute : ValidationAttribute
{
    public object DissallowedEnum { get; private set; }
    public Type EnumType { get; private set; }

    public DisallowEnumValueAttribute(Type enumType, object dissallowedEnum)
    {
        if (!enumType.IsEnum)
            throw new ArgumentException("Type must be an enum", "enumType");

        DissallowedEnum = dissallowedEnum;
        EnumType = enumType;
    }

    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        var disallowed = Convert.ChangeType(DissallowedEnum, EnumType);
        var enumVal = Convert.ChangeType(value, EnumType);

        if (disallowed == null || enumVal == null)
            throw new Exception("Something is wrong"); //or return validation result

        if (enumVal == disallowed)
        {
            return new ValidationResult("This value is not allowed");
        }

        return ValidationResult.Success;
    }
}

public class TestModel
{
    [DisallowEnumValue(typeof(SomeEnum), SomeEnum.Wrong)]
    public SomeEnum Thing { get; set; }
}

A: My enum validation was like this and works in dataannotation validation
public enum CreatedBySelfOrOthersEnumValues
{
    Self,
    Others
}

public class CampaignRegisterValidationModel
{
    [Required]
    public string Name { get; set; }

    [Required]
    public CreatedBySelfOrOthersEnumValues CreatedForSelfOrOthers { get; set; }

    [Required]
    public int CountryCode { get; set; }

    public string Phone { get; set; }
    public string Email { get; set; }
}

Then validating it
if (ModelState.IsValid)
{

}


text:
Q: sending mail in background in android 4.4.4 KitKat source code(android) I am trying to make an app that send email without user interaction..
I get the error which you can see. please help whats the cause of it.
this is my mail.java
package com.example.javamail;
import java.util.Date;
import java.util.Properties;

import javax.activation.CommandMap;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.activation.MailcapCommandMap;
import javax.mail.BodyPart;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

public class Mail extends javax.mail.Authenticator {
  private String _user;
  private String _pass;

  private String[] _to;
  private String _from;

  private String _port;
  private String _sport;

  private String _host;

  private String _subject;
  private String _body;

  private boolean _auth;

  private boolean _debuggable;

  private Multipart _multipart;

  public Mail() {
    _host = "smtp.gmail.com"; // default smtp server
    _port = "465"; // default smtp port
    _sport = "465"; // default socketfactory port

    _user = ""; // username
    _pass = ""; // password
    _from = ""; // email sent from
    _subject = ""; // email subject
    _body = ""; // email body

    _debuggable = false; // debug mode on or off - default off
    _auth = true; // smtp authentication - default on

    _multipart = new MimeMultipart();

    // There is something wrong with MailCap, javamail can not find a handler for the multipart/mixed part, so this bit needs to be added.
    MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
    mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
    mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
    mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
    mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
    mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
    CommandMap.setDefaultCommandMap(mc);
  }

  public Mail(String user, String pass) {
    this();

    _user = user;
    _pass = pass;
  }

  public boolean send() throws Exception {
    Properties props = _setProperties();

    if(!_user.equals("") && !_pass.equals("") && _to.length > 0 && !_from.equals("") && !_subject.equals("") && !_body.equals("")) {
      Session session = Session.getInstance(props, this);

      MimeMessage msg = new MimeMessage(session);

      msg.setFrom(new InternetAddress(_from));

      InternetAddress[] addressTo = new InternetAddress[_to.length];
      for (int i = 0; i < _to.length; i++) {
        addressTo[i] = new InternetAddress(_to[i]);
      }
        msg.setRecipients(MimeMessage.RecipientType.TO, addressTo);

      msg.setSubject(_subject);
      msg.setSentDate(new Date());

      // setup message body
      BodyPart messageBodyPart = new MimeBodyPart();
      messageBodyPart.setText(_body);
      _multipart.addBodyPart(messageBodyPart);

      // Put parts in message
      msg.setContent(_multipart);

      // send email
      Transport.send(msg);

      return true;
    } else {
      return false;
    }
  }

  public void addAttachment(String filename) throws Exception {
    BodyPart messageBodyPart = new MimeBodyPart();
    DataSource source = new FileDataSource(filename);
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName(filename);

    _multipart.addBodyPart(messageBodyPart);
  }

  @Override
  public PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication(_user, _pass);
  }

  private Properties _setProperties() {
    Properties props = new Properties();

    props.put("mail.smtp.host", _host);

    if(_debuggable) {
      props.put("mail.debug", "true");
    }

    if(_auth) {
      props.put("mail.smtp.auth", "true");
    }

    props.put("mail.smtp.port", _port);
    props.put("mail.smtp.socketFactory.port", _sport);
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.socketFactory.fallback", "false");

    return props;
  }

  // the getters and setters
  public String getBody() {
    return _body;
  }

  public void setBody(String _body) {
    this._body = _body;
  }

public void setTo(String[] toArr) {
    this._to= toArr;

}

public void setFrom(String string) {
    this._from = string;

}

public void setSubject(String string) {
    this._subject = string;

}
}

automaticMailActivity
package com.example.javamail;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class automaticMailActivity extends Activity {
    private Mail m;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.activity_main);

        Button sendmail = (Button) findViewById(R.id.send_email);

        sendmail.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                m = new Mail("wahidullah.mdr@gmail.com", "password");

                  String[] toArr = {"wahidullah.mdr@gmail.com"};
                  m.setTo(toArr);
                  m.setFrom("mujibjan@gmail.com");
                  m.setSubject("This is an email sent using my Mail JavaMail wrapper from an Android device.");
                  m.setBody("Email body.");

                  try {
//                  m.addAttachment("/sdcard/filelocation");

                    if(m.send()) {
                      Toast.makeText(automaticMailActivity.this, "Email was sent successfully.", Toast.LENGTH_LONG).show();
                    } else {
                      Toast.makeText(automaticMailActivity.this, "Email was not sent.", Toast.LENGTH_LONG).show();
                    }
                  } catch(Exception e) {
                    Toast.makeText(automaticMailActivity.this, "There was a problem sending the email.", Toast.LENGTH_LONG).show();
                    Log.e("automaticMailActivity", "Could not send email", e);
                  }
                }
              });
    }
}

my XML file
actvity_mail.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.javamail.automaticMailActivity" >

    >
<Button android:id="@+id/send_email"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Send Email"
/>

</RelativeLayout>

but i have still some problems that shown as follow:
03-08 23:08:11.800: E/automaticMailActivity(366): Could not send email
03-08 23:08:11.800: E/automaticMailActivity(366): javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;
03-08 23:08:11.800: E/automaticMailActivity(366):   nested exception is:
03-08 23:08:11.800: E/automaticMailActivity(366):   java.net.UnknownHostException: Host is unresolved: smtp.gmail.com:465
03-08 23:08:11.800: E/automaticMailActivity(366):   at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1389)
03-08 23:08:11.800: E/automaticMailActivity(366):   at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
03-08 23:08:11.800: E/automaticMailActivity(366):   at javax.mail.Service.connect(Service.java:310)
03-08 23:08:11.800: E/automaticMailActivity(366):   at javax.mail.Service.connect(Service.java:169)
03-08 23:08:11.800: E/automaticMailActivity(366):   at javax.mail.Service.connect(Service.java:118)
03-08 23:08:11.800: E/automaticMailActivity(366):   at javax.mail.Transport.send0(Transport.java:188)
03-08 23:08:11.800: E/automaticMailActivity(366):   at javax.mail.Transport.send(Transport.java:118)
03-08 23:08:11.800: E/automaticMailActivity(366):   at com.example.javamail.Mail.send(Mail.java:104)
03-08 23:08:11.800: E/automaticMailActivity(366):   at com.example.javamail.automaticMailActivity$1.onClick(automaticMailActivity.java:34)
03-08 23:08:11.800: E/automaticMailActivity(366):   at android.view.View.performClick(View.java:2408)
03-08 23:08:11.800: E/automaticMailActivity(366):   at android.view.View$PerformClick.run(View.java:8816)
03-08 23:08:11.800: E/automaticMailActivity(366):   at android.os.Handler.handleCallback(Handler.java:587)
03-08 23:08:11.800: E/automaticMailActivity(366):   at android.os.Handler.dispatchMessage(Handler.java:92)
03-08 23:08:11.800: E/automaticMailActivity(366):   at android.os.Looper.loop(Looper.java:123)
03-08 23:08:11.800: E/automaticMailActivity(366):   at android.app.ActivityThread.main(ActivityThread.java:4627)
03-08 23:08:11.800: E/automaticMailActivity(366):   at java.lang.reflect.Method.invokeNative(Native Method)
03-08 23:08:11.800: E/automaticMailActivity(366):   at java.lang.reflect.Method.invoke(Method.java:521)
03-08 23:08:11.800: E/automaticMailActivity(366):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-08 23:08:11.800: E/automaticMailActivity(366):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-08 23:08:11.800: E/automaticMailActivity(366):   at dalvik.system.NativeStart.main(Native Method)
03-08 23:08:11.800: E/automaticMailActivity(366): Caused by: java.net.UnknownHostException: Host is unresolved: smtp.gmail.com:465
03-08 23:08:11.800: E/automaticMailActivity(366):   at java.net.Socket.connect(Socket.java:1038)
03-08 23:08:11.800: E/automaticMailActivity(366):   at java.net.Socket.connect(Socket.java:997)
03-08 23:08:11.800: E/automaticMailActivity(366):   at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
03-08 23:08:11.800: E/automaticMailActivity(366):   at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:163)
03-08 23:08:11.800: E/automaticMailActivity(366):   at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
03-08 23:08:11.800: E/automaticMailActivity(366):   ... 19 more

A: 465 port use for SSL so i think you getting something error here , instead of you can try 587 port with TLS (not SSL) to send mail.
Try code bellow:
Properties props = new Properties();
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth", "true");  // If you need to authenticate
// Use the following if you need SSL
props.put("mail.smtp.socketFactory.port", d_port);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");

and read more at here


text:
Q: Linear Operator: Boundedness I'm stuck at: $\sup_{\overline{B_1}}\lVert T x\rVert\leq\sup_{B_1}\lVert T x\rVert$?
For sure it holds: $\sup_{B_1}\lVert T x\rVert=\sup_{B_1\setminus\{0\}}\lVert x\rVert\lVert T \frac{x}{\lVert x\rVert}\rVert\leq 1\sup_{S_1}\lVert T x\rVert\leq \sup_{\overline{B_1}}\lVert T x\rVert$
Moreover, I know that: $\lVert T(A)\rVert=\lVert \overline{T(A)}\rVert$
But even when requiring continuity it could happen that: $T(\overline{A})\subsetneq \overline{T(A)}$

A: Clearly $\overline{B}_1\subset B_r$, for any $r>1$, and hence
$$\sup_{\overline{B_1}}\lVert T x\rVert\leq\sup_{B_r}\lVert T x\rVert. \tag{1}$$
But
$$
\{\|Tx\|: x\in B_r\}=\{\|Tx\|: x\in rB_1\}\stackrel{x=rw}{=}\{\|T(rw)\|: w\in B_1\}=r
\{\|Tx\|: x\in B_1\}.
$$
Hence $(1)$ becomes
$$\sup_{\overline{B_1}}\lVert T x\rVert\leq\sup_{B_r}\lVert T x\rVert=r\sup_{B_1}\lVert T x\rVert,$$
for all $r>1$. In particular, it holds for $r=1+\frac{1}{n}$, i.e.,
$$\sup_{\overline{B_1}}\lVert T x\rVert\leq\big(1+\tfrac{1}{n}\big)\sup_{B_1}\lVert T x\rVert,$$
Letting $n\to\infty$, we obtain that
$$\sup_{\overline{B_1}}\lVert T x\rVert\leq\sup_{B_1}\lVert T x\rVert.$$


text:
Q: Como puedo suspender un setInterval en acción? Cree un documento HTML5 para ver videos local. Trato de hacer similar a YouTube, al terminar el vídeo, muestra una sugerencia de vídeo similar y el siguiente vídeo a reproducir con setInterval.
Mi problema aún, no logró detener el setInterval para volver a ver el vídeo.
  // AL FINAL DEL VIDEO
  var mas = $('.relacionados');
  var fin = $('video');
  var counter=10;

  $("video").on("ended", function() {
   mas.show();

  //Siguiente vídeo
  setTimeout (function() {
  window.location.href = 'yoVideos.html';
  },10000);
  //Cuenta regresiva
  var id = setInterval(function(){
  if(counter==0) clearInterval(id);
  else {
  counter=counter-1;
  document.querySelector('.counter').innerHTML=counter;
  } }, 1000);

  });

  // CANCELAR SIGUIENTE VIDEO
  function cancelar() {
    clearTimeout(fin);
    mas.toggle();
    document.getElementById("cancelar");
  }

    Siguente vídeo:

Título del siguiente vídeo

    En: 10s
      Cancelar

A:

var counter = 5;

var id = setInterval(function(){
if(counter == 0){
clearInterval(id);
document.
}
document.getElementById("contador").innerHTML = counter;

counter--;

},1000);

Puedes poner el código del setTimeout dentro del setInterval ya que ambos terminan al mismo tiempo:
var id = setInterval(function(){
  if(counter==0) {
    clearInterval(id);
    window.location.href = 'yoVideos.html';
  }
  else {
   counter=counter-1;
   document.querySelector('.counter').innerHTML=counter;
  }
 }, 1000);

Y en la función cancelar() cancelas el setInterval:
function cancelar() {
    clearInterval(id);
    mas.toggle();
    document.getElementById("cancelar");
  }

Ejemplo:

var counter = 5;

var id = setInterval(function(){
if(counter == 0){
clearInterval(id);
//document.location.href="";
}
document.getElementById("contador").innerHTML = counter;

counter--;

},1000);

function cancelar(){

clearInterval(id);

}

<button onclick="cancelar()">cancelar</button>


text:
Q: JavaDB/Derby Error 08006 In the article Using Java DB in Desktop Applications the Address Book demo have a method disconnect which have a try-catch block that catch and ignores the exception. If you add a printStackTrace you can see that the exception always occur.
What's wrong here? The JavaDB should not throw this exception, or they should fix something in the example program?

A: Shutdown commands always raise SQLExceptions. So nothing's wrong. That's just the way Derby works.


text:
Q: How to Execute the Delete Button in a DataGrid Column having the Delete ICommand definition in ViewModel Xaml Code
What other property for Datagrid Button Should be used to trigger the CmdDeleteUser ICommand Property. The Datagrid Row gets Selected but then the Delete button Doesn't work.
'''
<DataGridTemplateColumn Header="Delete Record" IsReadOnly="True">
        <DataGridTemplateColumn.CellTemplate >
               <DataTemplate>
                   <Button Width="60" Margin="2" Command="{Binding CmdDeleteUser}"  Content="Delete" />
               </DataTemplate>
         </DataGridTemplateColumn.CellTemplate>

'''
ViewModel Code
'''
public ICommand CmdDeleteUser
        {
            get
            {
                return new DelegateCommand(DeleteUser);
            }
        }

    private void DeleteUser()
    {
        if (null != SelectedCustomer)
        {
            customer.Remove(SelectedCustomer);
        }
        try
        {
            con = new SqlConnection(connectionString);
            con.Open();
            cmd = new SqlCommand($"Delete from Customer where Id='{Convert.ToInt32(SelectedCustomer.id)}'", con);
            cmd.ExecuteNonQuery();
            Customer current = customer.Where(x => x.id == SelectedCustomer.id).FirstOrDefault();
            customer.Remove(current);

        }
        catch (Exception)
        {
        }
        finally
        {
            con.Close();
        }
    }

'''

A: Inside your Listview you can use the RelativeSource to access the Command in the ViewModel:
Command="{Binding DataContext.CmdDeleteUser, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
CommandParameter="{Binding}

The AncestorType ist the type of your control, which have the Bindingcontext you need.
The problem is that you try to Bind the CmdDeleteUser in your DataGrid meanwhile the Command is defined in your ViewModel but the BindingContext of your DataGrid is not the ViewModel, if you use an ItemsSource.


text:
Q: Double integrals and area? What does  $\displaystyle \iint_U \, dx \,dy$ describe, where $U$, say, is some region in, say, the $(x,y)$ plane?
Is it the net area of $U$ in the $(x,y)$ plane?
How about $\displaystyle \iint_U f \, dx \,dy$, for some (appropriate?) $f$.  Is the net area enclosed  by $U$ in $f$?
I'm confused by so many different types of integrals in multivariable calculus. Thanks.

A: Yes and yes.
For a subset $U$ of $\Bbb R^2$ we have $$\text{Area of $U$}=\iint_U dA$$
where $dA=dxdy$. This is because you're just integrating at height $1$ above all of $U$, so you get $1$ times the area of $U$.
Now if we throw in an integrable function $f:U\to\Bbb R$ then $$\text{Area below $f$ on $U$}=\iint_U f ~dA$$
This is because you're integrating over $U$ at a height of $f(x,y)$, which changes with $x$ and $y$.
Note: I use "area" under $f$, but this is really a 3D volume.

A: Just as a definite integral of the form $\int f dx$ is an area under $y=f(x)$, $\int f dx dy$ is a volume under $z=f(x,\,y)$. The special case $f=1$ gives your first integral.

A: In fact, integration and Measure Theory are quite synonymous, which can be explained in very simple terms. We can say that the measure of a set can be calculated as follows:
$$ \mu(A) = \int_A 1 dx$$
For instance, suppose we wanted to find the distance between two locations $a$ and $b$, we can represent this as $A = [a,b]$ then we would expect the measure (distance) of this set to be its length, $b-a$.
$$\mu(A)= \int_{a}^{b} 1~dx$$
$$~~~~~~~ = b - a$$
Now say a rectangle has one side with length $a$ and another of length $b$. We would expect the area to be $ab$. Note from the example before, the measure of $[a,b]$ is some $x\in \mathbb{R}$. So why not say one side of the rectangle is just some set $[c,d]$ and the other is another set $[e,f]$?
Then if $B= [c,d]\times[e,f]$, the area of the rectangle is
\begin{align*}
\mu(B) &= \int_{c}^{d}  \int_{e}^{f} 1~dxdy\\
&= (d-c)\times(f-e) \\
\end{align*}
Hopefully this gives you an intuition of integration from another perspective? To get the area of the rectangle we are finding the measure (integral) in the $x$-plane first, and then in the $y$-plane second, which covers all of the set. Note triple integrals are used to calculate the volume of a $3$D object and so on.


text:
Q: Any amsalpha-like style in Biblatex? Did anyone know is there a way to set style for biblatex? I would like a way to backref the cited page with linkedin hyperref, it seems that the Biblatex can do this, but the style is quite ugly!!! I'd like a style as amsalpha, any ideas?
Some examples:
My original tex source
\documentclass{article}
\usepackage{backref}
\usepackage[backref]{hyperref}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book {jost1995riemannian,
    AUTHOR = {Jost, J{\"u}rgen},
     TITLE = {Riemannian geometry and geometric analysis},
    SERIES = {Universitext},
   EDITION = {Sixth},
 PUBLISHER = {Springer},
   ADDRESS = {Heidelberg},
      YEAR = {2011},
     PAGES = {xiv+611},
      ISBN = {978-3-642-21297-0},
   MRCLASS = {53Cxx (35R01 53-02 57R58 58E05 58E20 58J05)},
  MRNUMBER = {2829653},
MRREVIEWER = {Fr{\'e}d{\'e}ric Robert},
       DOI = {10.1007/978-3-642-21298-7},
       URL = {http://dx.doi.org/10.1007/978-3-642-21298-7},
}
@book {freed1984instantons,
    AUTHOR = {Freed, Daniel S. and Uhlenbeck, Karen K.},
     TITLE = {Instantons and four-manifolds},
    SERIES = {Mathematical Sciences Research Institute Publications},
    VOLUME = {1},
   EDITION = {Second},
 PUBLISHER = {Springer-Verlag},
   ADDRESS = {New York},
      YEAR = {1991},
     PAGES = {xxii+194},
      ISBN = {0-387-97377-X},
   MRCLASS = {57R55 (57M40 57N05 57R57 57R60 58D27 58G10)},
  MRNUMBER = {1081321 (91i:57019)},
       DOI = {10.1007/978-1-4613-9703-8},
       URL = {http://dx.doi.org/10.1007/978-1-4613-9703-8},
}
\end{filecontents}
\begin{document}
\cite{jost1995riemannian,freed1984instantons}
\bibliographystyle{amsalpha}
\bibliography{\jobname}
\end{document}

The one for Biblatex
\documentclass{article}
\usepackage[backref=true,backend=bibtex]{biblatex}
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book {jost1995riemannian,
    AUTHOR = {Jost, J{\"u}rgen},
     TITLE = {Riemannian geometry and geometric analysis},
    SERIES = {Universitext},
   EDITION = {Sixth},
 PUBLISHER = {Springer},
   ADDRESS = {Heidelberg},
      YEAR = {2011},
     PAGES = {xiv+611},
      ISBN = {978-3-642-21297-0},
   MRCLASS = {53Cxx (35R01 53-02 57R58 58E05 58E20 58J05)},
  MRNUMBER = {2829653},
MRREVIEWER = {Fr{\'e}d{\'e}ric Robert},
       DOI = {10.1007/978-3-642-21298-7},
       URL = {http://dx.doi.org/10.1007/978-3-642-21298-7},
}
@book {freed1984instantons,
    AUTHOR = {Freed, Daniel S. and Uhlenbeck, Karen K.},
     TITLE = {Instantons and four-manifolds},
    SERIES = {Mathematical Sciences Research Institute Publications},
    VOLUME = {1},
   EDITION = {Second},
 PUBLISHER = {Springer-Verlag},
   ADDRESS = {New York},
      YEAR = {1991},
     PAGES = {xxii+194},
      ISBN = {0-387-97377-X},
   MRCLASS = {57R55 (57M40 57N05 57R57 57R60 58D27 58G10)},
  MRNUMBER = {1081321 (91i:57019)},
       DOI = {10.1007/978-1-4613-9703-8},
       URL = {http://dx.doi.org/10.1007/978-1-4613-9703-8},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{jost1995riemannian,freed1984instantons}
\printbibliography
\end{document}

A: A not so perfect solution is:
\documentclass{article}
\usepackage[backref=true,
    backend=bibtex,% or biber
    style=alphabetic,
    citestyle=authoryear,
    sortlocale=de_DE,
    natbib=true,
    doi=false,
    isbn=false,
    url=false]{biblatex}
\usepackage{hyperref}
%\DefineBibliographyStrings{english}{%
%  backrefpage = {page},% originally "cited on page"
%  backrefpages = {pages},% originally "cited on pages"
%}
\makeatletter
\newrobustcmd*{\parentexttrack}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  \blx@bibopenparen#1\blx@bibcloseparen
  \endgroup}

\AtEveryCite{%
  \let\parentext=\parentexttrack%
  \let\bibopenparen=\bibopenbracket%
  \let\bibcloseparen=\bibclosebracket}

\makeatother
\renewcommand{\cite}{\parencite}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book {jost1995riemannian,
    AUTHOR = {Jost, J{\"u}rgen},
     TITLE = {Riemannian geometry and geometric analysis},
    SERIES = {Universitext},
   EDITION = {Sixth},
 PUBLISHER = {Springer},
   ADDRESS = {Heidelberg},
      YEAR = {2011},
     PAGES = {xiv+611},
      ISBN = {978-3-642-21297-0},
   MRCLASS = {53Cxx (35R01 53-02 57R58 58E05 58E20 58J05)},
  MRNUMBER = {2829653},
MRREVIEWER = {Fr{\'e}d{\'e}ric Robert},
       DOI = {10.1007/978-3-642-21298-7},
       URL = {http://dx.doi.org/10.1007/978-3-642-21298-7},
}
@book {freed1984instantons,
    AUTHOR = {Freed, Daniel S. and Uhlenbeck, Karen K.},
     TITLE = {Instantons and four-manifolds},
    SERIES = {Mathematical Sciences Research Institute Publications},
    VOLUME = {1},
   EDITION = {Second},
 PUBLISHER = {Springer-Verlag},
   ADDRESS = {New York},
      YEAR = {1991},
     PAGES = {xxii+194},
      ISBN = {0-387-97377-X},
   MRCLASS = {57R55 (57M40 57N05 57R57 57R60 58D27 58G10)},
  MRNUMBER = {1081321 (91i:57019)},
       DOI = {10.1007/978-1-4613-9703-8},
       URL = {http://dx.doi.org/10.1007/978-1-4613-9703-8},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{jost1995riemannian,freed1984instantons}
\printbibliography
\end{document}

A: Here I also found a perfect one:
\documentclass{article}
\usepackage[pagebackref]{hyperref}
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{
    \ifcase #1
        No cited.
    \or
        page #2.
    \else
        pages #2.
    \fi
}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book {jost1995riemannian,
    AUTHOR = {Jost, J{\"u}rgen},
     TITLE = {Riemannian geometry and geometric analysis},
    SERIES = {Universitext},
   EDITION = {Sixth},
 PUBLISHER = {Springer},
   ADDRESS = {Heidelberg},
      YEAR = {2011},
     PAGES = {xiv+611},
      ISBN = {978-3-642-21297-0},
   MRCLASS = {53Cxx (35R01 53-02 57R58 58E05 58E20 58J05)},
  MRNUMBER = {2829653},
MRREVIEWER = {Fr{\'e}d{\'e}ric Robert},
       DOI = {10.1007/978-3-642-21298-7},
       URL = {http://dx.doi.org/10.1007/978-3-642-21298-7},
}
@book {freed1984instantons,
    AUTHOR = {Freed, Daniel S. and Uhlenbeck, Karen K.},
     TITLE = {Instantons and four-manifolds},
    SERIES = {Mathematical Sciences Research Institute Publications},
    VOLUME = {1},
   EDITION = {Second},
 PUBLISHER = {Springer-Verlag},
   ADDRESS = {New York},
      YEAR = {1991},
     PAGES = {xxii+194},
      ISBN = {0-387-97377-X},
   MRCLASS = {57R55 (57M40 57N05 57R57 57R60 58D27 58G10)},
  MRNUMBER = {1081321 (91i:57019)},
       DOI = {10.1007/978-1-4613-9703-8},
       URL = {http://dx.doi.org/10.1007/978-1-4613-9703-8},
}
\end{filecontents}

\begin{document}
\cite{jost1995riemannian,freed1984instantons}
\bibliographystyle{amsalpha}
\bibliography{\jobname.bib}
\end{document}


text:
Q: Why Exception inside a method should be handled within the method itself and not outside? Consider a method() that throws some exception in its body.
Consider the following scenarios:
Scenario 1:
{
  //..
  // ..
  method();    //Exception handled inside the method
  //..
  //..
}

In this case the exception should be handled within the method() itself.
Also consider this:
Scenario 2:
{
   //..
   //..
   try{
      method();   //Exception not handled with-in the method
      }
    catch(){}
   //..
   // ..
}

Why a situation like scenario 2 is not allowed? ie why it is forced that the exception should be handled within the method?

A: You can add throws clause to your method and make it throw an exception, which can be handled, as mentioned in Situation 2. So its allowed, like this:-
void method() throws Exception{
}

A: Both scenarios are allowed. The restriction (if that's the right term) that Java imposes is that the exception must be handled somewhere.
In the first scenario, the called method handles the exception itself - so there's no need for the try-catch in the calling method.
The second scenario is valid - but only if method() includes the throws declaration to indicate that the exception must be handled somewhere else.
void method() throws Exception
{
}

A: It is allowed!
use as follows
public void method() throws ClassNotFoundException {

to catch a ClassNotFoundException.
(In most cases you should not throw a bare Exception, like other posters simplified)
Whether to chatch inside or outside is software design. There is no rule of thumb.
My experience is that catching outside leads to less complex code, which can be better unit tested .
Look for design pattern "last line of defense":
That means that in your top most class e.g in main() there is a  catch (Exception ex) {
which catches when no other method catched it. in that case you can log the exception and (try to) safely shut down your system. This is the last line of defense.
Note: spmetimes it also makes sense to catch(Throweable th),

A: If you handle exception using senario-2, then cannot map the exception to the actual one. i.e you cannot state it as per the code in block. So please handle the exception to the spot itself, so that you can specifically explain why the exception has occurred.

A: As said above, the idea is to throw early and catch late. Overall, you want to minimize exceptions you throw by simply making your logic "flow". But there are always situations which are tricky to handle, or obfuscate code too much, so it is worth ensuring the user understands the risks of using certain methods and handles them accordingly.

A: TL;DR: Never trap InterruptedException unless you really mean to. It almost always needs to be thrown.
This great question is actually a very important design decision. Getting this right is difficult and getting this right across an entire team is even more difficult. The answer to the question lies within your implementation. Does the error need to be immediately shown to the user? Do you have an auxiliary method to recover from the failure? Is the exception a fatal event?
Please do yourself a favor and never write an empty exception handler. You will be very happy to have put in a log.debug statement in there when things go awry. Other than that: learn what every exception means and respond to it in the most graceful way possible.


text:
Q: Liferay: com.liferay.portal.NoSuchResourceActionException when adding calevent I got this error when adding calendar event:
com.liferay.portal.NoSuchResourceActionException: com.liferay.portlet.calendar.model.CalEvent#ADD_DISCUSSION

Here is also similar issues from other forum (check this out for additional details):
https://web.liferay.com/community/forums/-/message_boards/message/77820684?refererPlid=14540956
https://web.liferay.com/community/forums/-/message_boards/message/77820704
I'm using Liferay 6.2 and Calendar portlet Version: 6.2.0.1
----------------------UPDATES SECTION (08/18/2016)------------------------------
The snippet below resides on my -LocalServiceImpl.java;
//Create a Calendar Event
CalEvent calEvent = CalEventLocalServiceUtil.addEvent(
    serviceContext.getUserId(), //userId
    "title event", //title
    "description event", //description
    "office", //location
    startDateTime.getMonth(), //int startDateMonth || 0 > Jan || 1 > Feb || 2 > Mar || 3 > Apr||.....|| 11 > Dec||
    startDateTime.getDay(), //int startDateDay,
    startDateTime.getYear(), //int startDateYear,
    startDateTime.getHours(), //int startDateHour,
    startDateTime.getMinutes(), //int startDateMinute,
    1, //int durationHour,
    0, //int durationMinute,
    false, //boolean allDay,
    true, //boolean timeZoneSensitive,
    "Meeting", //String type,
    false, //boolean repeating,
    null, //TZSRecurrence recurrence,
    0, //int remindBy,
    0, //int firstReminder,
    0, // int secondReminder,
    serviceContext);

//Import the event to Calendar Booking - Requires calendar-portlet-service.jar(tomcat-7.0.42\webapps\calendar-portlet\WEB-INF\lib)
CalendarImporterLocalServiceUtil.importCalEvent(calEvent);

Service Context below was retrieved from -Portlet.java action method; then I call a method from -LocalServiceImpl.java and pass serviceContext as argument. Then it will hit the code snippet above.
ServiceContext serviceContext = ServiceContextFactory.getInstance([MyCustomClass].class.getName(), actionRequest);

FULL STACK TRACE
com.liferay.portal.NoSuchResourceActionException: com.liferay.portlet.calendar.model.CalEvent#ADD_DISCUSSION
    at com.liferay.portal.service.impl.ResourceActionLocalServiceImpl.getResourceAction(ResourceActionLocalServiceImpl.java:214)
    at sun.reflect.GeneratedMethodAccessor347.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
    at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
    at com.sun.proxy.$Proxy88.getResourceAction(Unknown Source)
    at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.doUpdateResourcePermission(ResourcePermissionLocalServiceImpl.java:1211)
    at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.updateResourcePermission(ResourcePermissionLocalServiceImpl.java:1336)
    at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.setOwnerResourcePermissions(ResourcePermissionLocalServiceImpl.java:1059)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
    at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
    at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
    at com.sun.proxy.$Proxy92.setOwnerResourcePermissions(Unknown Source)
    at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addModelResources(ResourceLocalServiceImpl.java:741)
    at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addModelResources(ResourceLocalServiceImpl.java:796)
    at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addModelResources(ResourceLocalServiceImpl.java:202)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
    at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
    at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
    at com.sun.proxy.$Proxy87.addModelResources(Unknown Source)
    at com.liferay.portlet.calendar.service.impl.CalEventLocalServiceImpl.addEventResources(CalEventLocalServiceImpl.java:298)
    at com.liferay.portlet.calendar.service.impl.CalEventLocalServiceImpl.addEvent(CalEventLocalServiceImpl.java:226)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
    at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
    at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
    at com.sun.proxy.$Proxy290.addEvent(Unknown Source)
    at com.liferay.portlet.calendar.service.CalEventLocalServiceUtil.addEvent(CalEventLocalServiceUtil.java:346)
    at com.ms3.ptotracker.service.impl.PaidTimeOffLocalServiceImpl.addPaidTimeOff(PaidTimeOffLocalServiceImpl.java:164)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
    at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
    at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
    at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
    at com.sun.proxy.$Proxy544.addPaidTimeOff(Unknown Source)
    at com.ms3.ptotracker.service.PaidTimeOffLocalServiceUtil.addPaidTimeOff(PaidTimeOffLocalServiceUtil.java:369)
    at com.ms3.ptotracker.portlet.PaidTimeOffPortlet.submitPtoRequestAction(PaidTimeOffPortlet.java:139)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.liferay.portal.kernel.portlet.LiferayPortlet.callActionMethod(LiferayPortlet.java:163)
    at com.liferay.util.bridges.mvc.MVCPortlet.callActionMethod(MVCPortlet.java:249)
    at com.liferay.portal.kernel.portlet.LiferayPortlet.processAction(LiferayPortlet.java:90)
    at com.liferay.util.bridges.mvc.MVCPortlet.processAction(MVCPortlet.java:212)
    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:71)
    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
    at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:112)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:604)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:543)
    at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:583)
    at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:628)
    at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:308)
    at com.liferay.portlet.PortletContainerImpl._doProcessAction(PortletContainerImpl.java:389)
    at com.liferay.portlet.PortletContainerImpl.processAction(PortletContainerImpl.java:107)
    at com.liferay.portlet.SecurityPortletContainerWrapper.processAction(SecurityPortletContainerWrapper.java:109)
    at com.liferay.portlet.RestrictPortletContainerWrapper.processAction(RestrictPortletContainerWrapper.java:75)
    at com.liferay.portal.kernel.portlet.PortletContainerUtil.processAction(PortletContainerUtil.java:115)
    at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:386)
    at com.liferay.portal.action.LayoutAction.doExecute(LayoutAction.java:200)
    at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:95)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
    at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:168)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:557)
    at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:534)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.uploadservletrequest.UploadServletRequestFilter.processFilter(UploadServletRequestFilter.java:93)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:308)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
    at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:161)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.uploadservletrequest.UploadServletRequestFilter.processFilter(UploadServletRequestFilter.java:93)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:361)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:308)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:254)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:268)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
    at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:226)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:185)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
    at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:57)
    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:185)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

A: I was able to get rid of this error, because I tried using the service from the new calendar portlet instead.
Here is my code:
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;

 import com.liferay.calendar.model.CalendarBookingConstants;
 import com.liferay.calendar.service.CalendarBookingServiceUtil;
 ...

Map<Locale, String> titleMap = new HashMap<Locale, String>();
Map<Locale, String> descriptionMap = new HashMap<Locale, String>();
long[] childCalendarIds = {};

[MyCustomClassName] [myCustomClassName] = [MyCustomClassName]LocalServiceUtil.get[MyCustomClassName](
16Long.parseLong(workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK).toString()));

titleMap.put(Locale.US, "Event title");
descriptionMap.put(Locale.US,"Event Description");

CalendarBookingServiceUtil.addCalendarBooking(
                Long.parseLong("27458"),//calendarId,
                childCalendarIds,//childCalendarIds,
                CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT,//parentCalendarBookingId,
                titleMap,//titleMap,
                descriptionMap,//descriptionMap,
                "",//location,
                [myCustomClassName] .getStartDateTime().getTime(),//startTime,
                [myCustomClassName] .getEndDateTime().getTime(),//endTime,
                false,//allDay,
                null,//recurrence,
                0,//firstReminder,
                "email",//firstReminderType,
                0,//secondReminder,
                "email",//secondReminderType,
                (ServiceContext) workflowContext.get(WorkflowConstants.CONTEXT_SERVICE_CONTEXT ));

Take Note the ff.:

*

*I'm using the Workflow Context here since I'm calling the snippet from a workflow definition, you can use your serviceContext as
substitute.

*Don't forget to copy-paste the jar file of the calendar portlet.

*I copy and paste the snippet below on the liferay-plugin-package.properties
required-deployment-contexts=\
calendar-portlet
It seems that there is a permission problem on LR6.2 when using the old calendar Util/service (specifically CalEventLocalServiceUtil.addEvent()); that's why we encounter the error of this post.
By the way I'm using LR 6.2 GA4 sdk, LR 62. GA5 server and the new Calendar portlet Version: 6.2.0.1, when I encounter the error.
References:
https://web.liferay.com/community/forums/-/message_boards/message/55716640
https://web.liferay.com/community/forums/-/message_boards/view_message/46787835
Other Links:
https://web.liferay.com/community/forums/-/message_boards/message/74181399
https://web.liferay.com/community/forums/-/message_boards/message/74232388

A: serviceContext.setAddGuestPermissions(true);
serviceContext.setAddGroupPermissions(true);
serviceContext.setDeriveDefaultPermissions(true);
So it will take permission as default permission


text:
Q: How should I go about doing this correlation problem? I have an idea of how to do this but I'm not sure if this is the right direction.

A stick of length $1$ is broken into $2$ pieces at a random point. Find the correlation coefficient and the covarience of the pieces.

I let $X$ be the length of the first piece and $Y$ be the length of the second piece, and I have come to conclusion that $P(X=x)=1-y$ and $P(Y=y)=1-x$ but for some reason it doesn't seem right to me. I know I need to find $E(XY)$, $E(X)$, and $E(Y)$ for the covarience but I'm just feeling skeptical about $P(X=x)=1-y$ and $P(Y=y)=1-x$. Did I do this right?

A: We assume that the breakpoint is uniformly distributed on the interval $[0,1]$. I interpret the meaning of the question as follows. Let $X$ be the length of the left piece, and $Y$ the length of the right piece. We want to find the covariance of $X$ and $Y$, and the correlation coefficient of $X$ and $Y$. You undoubtedly know the relevant formulas.
For the covariance of $X$ and $Y$, we will use the simplified formula
$$\text{Cov}(X,Y)=E(XY)-E(X)E(Y).$$
The easiest items here are $E(X)$ and $E(Y)$. By symmetry, each is $\dfrac{1}{2}$.
For $E(XY)$, use the fact that $Y=1-X$. So $E(XY)=E(X(1-X))$. This is $E(X-X^2)$. By the linearity of expectation, this is $E(X)-E(X^2)$.
We need $E(X^2)$. This is $\int_0^1 (x^2)(1) \,dx$. I expect you can handle the rest of the calculations.

A: Ask youself: Is the length of the broken piece  a continuous or discrete random variable? Also, write one random variable in terms of the other to simplify things.
EDIT:  Intuitively you should see that $$ \rho(X,1-X) = -1$$ for any r.v. $X$.  Which also follows directly from the result: $$\mathrm{Cov}(a+bX,Y) = b\,\mathrm{Cov}(X,Y)$$This hopefully makes sense because correlation measures the "normalized" interaction between two random variables.  As $X$ changes by a certain amount, $Y$ changes by the same amount but in the opposite direction (e.g. length of $X$ increases by a quarter of an inch, $Y$ contracts by a quarter of an inch, etc.)


text:
Q: Procedure to check for columns not null in a table if true then log into error column in the same table I have an emp table where I do a cross-check:
eid int,
ename varchar,
desig varchar,
sal number,
validation_error varchar

After creating table I want to load data by checking for the column should not be null. If null it should log the error into the validation_error column.

A: If I understood you correctly you can do this with computed column, like this:
create table emp (
    eid int
    , ename varchar(100)
    , desig varchar(100)
    , sal int
    , validation_error as (case when ename is null then 'ename is null ' else '' end)
            + (case when desig is null then 'desig is null ' else '' end)
            + (case when sal is null then 'sal is null ' else '' end)
);


text:
Q: How to Enable first Text Field when when first checkbox is checked My sample table:
 ____________________________________________________________________________
  | Select All |  Quantity  | Name & Description  |        Remarks           |
  ____________________________________________________________________________
  |   []           |    2       |    BallPen          | text field here      |
______________________________________________________________________________
  |   []           |    10      |    Pencil           | text field here      |
  ____________________________________________________________________________

I want to enable the first text field when the user click the first checkbox which Name & description = " BallPen" or enable the second text field when the second checkbox is clicked..the default value of the text field is disabled. How can I do that?
Table values is from my database.
This is my code:
if(isset($_POST['faculty'])){
         $faculty = $_POST['faculty'];
      $query = mysql_query("SELECT * FROM are A, are_item AI WHERE AI.Reque = '$faculty' AND A.Reque = '$faculty' AND A.are_no = AI.are_no");
      $row = mysql_fetch_array($query);
      $are_no = $row["are_no"];

      $query = mysql_query("SELECT * FROM user_info WHERE id = '$faculty'");
        while($row = mysql_fetch_array($query)){
            $firstname = $row['firstname'];
            $middle = $row['middlename'];
            $last = $row['lastname'];
            $name = $firstname . " " .$middle . " " . $last;
                  }
        echo" Item(s) ownned by " . $name  ;

    echo '
';

    echo "
";
        echo"Select All<input type='checkbox' id='selectall' onClick='selectAll(this)'/>	";
        echo "Quantity	";
        echo "Unit	";
        echo "Name & Description	";
        echo "PR No.	";
        echo "Date Acquired	";
        echo "Property Number	";
        echo "Number of items	";

    echo "
";
      echo "
";
   $query = mysql_query("SELECT * FROM tblitems I, are_item AI ,tblpur P WHERE AI.are_no = '$are_no' AND I.itemid = AI.itemid AND I.pr_no = P.pr_no");
             $k = 1;
          while($row = mysql_fetch_array($query)){
          $item_id = $row["itemid"];

            $check = 'check' . $k;
          $quantity = $row["quantity"];
          $unit = $row["unit"];
          $description = $row["description"];
          $purchase_no = $row["pr_no"];
          $property = $row["property_no"];
          $date_acquired = $row["date_acquired"];
         $stat = $row["stat"];

             if($stat == '1'){

             }
             else
             {

            echo "
";

            ?>
             <input name="check[]" type="checkbox" value = "<?php echo $row['itemid']; ?>">
            <?php
            echo "$quantity	";
            echo "$unit	";
            echo "$description	";
            echo "$purchase_no	";
            echo "$property	";
             echo "$date_acquired	";

             ?>
            <input type="text" name = "<?php echo $noof; ?>" maxlength=5 >
              <?php
              echo "
";

          }
      }
    echo "
";
    echo "
";
     $k++;
     }
    ?>

A: Use jQuery to accomplish this.

    <input type="checkbox" class="mode" data-for="text1">
    Blah blah blah
    <input type="text" id="text1" disabled>

A check all option
<input type="checkbox" id="all">

A: Since you are using a table then the generic solution could be something like
jQuery(document).ready(function(){
  $("table").delegate("input[type='checkbox']", "change", function(){
    if($(this).prop("checked") == true){
      $(this).closest("tr").find("input[type='text']").attr("disabled", false);
    } else {
      $(this).closest("tr").find("input[type='text']").attr("disabled", true);
    }
  });
});

I've done the example with .delegate incase you might be adding extra rows with jQuery/AJAX in the future.
Check this jsFiddle for a demo.

A: HTML Code

        <input type="checkbox" id="chk" />
         Quantity
         Name & Description
         Remarks

        <input type="checkbox" class="chk" />
        1
         BallPen
        <input type="text" disabled  />

        <input type="checkbox" class="chk" />
        2
         BallPen
        <input type="text" disabled />

        <input type="checkbox" class="chk" />
        3
         BallPen
        <input type="text" disabled />

jQuery Code
$(function(){
    $('input.chk').click(function(){
       $(this).closest('td').next('td').next('td').next('td').children('input').attr('disabled',!this.checked);
    });
});


text:
Q: Is there a way to change the background image in inspect element? I haven't really been able to find anything that shows how to change a background image in inspect element.
My background image is set like the following:

How can I change this background image in inspect element?

A: Paste the image link in like:
background-image: url(http://vignette4.wikia.nocookie.net/someordinarygamers/images/a/a1/Sanic.gif/revision/latest?cb=20150624143958)

Then you need to uncheck the color of the background. It should work then.

A: You should be able to click the background-image property value, "url(/images/rate.jpg)", and change the url to the desired image.