text:
Q: I want text on my button tag Below mention is the code for my button
<button type="button"  Value="End Test" class="testBtns" style="float:right;"onclick="location.href='@Url.Action("StudentResult", "Student", new {  TestId = ViewBag.TestId ,style="color:white"} )'" />

i am not getting the "End Text" text on my button anybody know then please help

A: Try this;
<button type="button"  class="testBtns" style="float:right;" onclick="location.href='@Url.Action("StudentResult", "Student", new {  TestId = ViewBag.TestId ,style="color:white"} )'" >End Test</button>

The value attribute specifies the initial value for a <button> in a <form>, not the display text.

A: Just correct your button as:
<button type="button"  class="testBtns" style="float:right;" onclick="location.href='@Url.Action("StudentResult", "Student", new {  TestId = ViewBag.TestId },new { @style="color:white" } )'">End Test</button>

text which you want to show in button should be enclosed between opening and closing tags of button tag and just correct @url.action you are mixing your
object route and html attributes.


text:
Q: Validator called twice In RestController, I am using @Valid annotation to validate custom class's members as below
@PostMapping("/path1")
public ResponseEntity<String> function1(@Valid CustomClass customClass) {
...
}

I defined custom validator to CustomClass's specific member, for instance, @CustomValid.
And, I have to use @Validated for other function's @RequestParam
@PostMapping("/path2")
public ResponseEntity<String> function2(@RequestParam("param") @NotBlank String param) {
...
}

To run second validator, I have to add @Validated annotation at class level.
But when I add @Validated, the @CustomValid called twice. When I remove @Validated, @NotBlank does not called.
How can I fix this?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Activity Indicator Animation Ceases upon App Resuming From Background I've got an activity indicator set up to start spinning when a file is getting downloaded from the internet. The file is downloaded asynchronously, and it also makes a request to continue downloading should the user send the app into the background or start another app. However, upon resuming my app, the activity indicator is no longer spinning, even though I haven't stopped it in code.
I set up a flag to let me know whether the activity indicator should be spinning, and I thought I could detect when the app came to the foreground, test the flag, and start the activity indicator up again, but none of the logical methods appear to fire when I set them up. I've tried the following:
- (void)applicationDidBecomeActive:(UIApplication *)application
- (void)applicationWillEnterForeground:(UIApplication *)application
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- (void)applicationWillResignActive:(UIApplication *)application
- (void)applicationDidEnterBackground:(UIApplication *)application

As I said, none of these methods fire when when the user switches back to the app (or away from it, for that matter).
What am I doing wrong?

A: My guess is that your app is stuck in an infinite loop on the UI thread somewhere, never allowing the run loop to continue.  This would explain both why those resume methods are never called and why the spinner is not animating.

A: The problem eventually "went away" while I was working with the code; I never figured out what caused the problem. Ed, maybe you were right? I just don't know.


text:
Q: Code generation tool for SQL schema to Korma entities Is there a tool to convert a SQL schema to Korma entities?

A: Not yet, but you could query you DBMS' Data Dictionary to get you started.
For instance, on MySQL you could start with:
select concat('(defentity ', t.table_name ,')') as defentity
  from information_schema.tables t
  where table_schema = 'mySchema';

A: This works for me, took some thought to implement. I was a bit blown back that Korma does not have this feature! (note: I ran this against MSSQL)
(defentity INFORMATION_SCHEMA.tables)
(def tables (map #(get % :TABLE_NAME)
              (select 'INFORMATION_SCHEMA.tables (fields :TABLE_NAME)
                      (where {:TABLE_TYPE "BASE TABLE"})))) ;notice the quote

(prn tables)
;(map #(def %) tables) ;additional concept
(map #(defentity %) tables) ;not sure this is required anymore

(select (first tables))


text:
Q: Mention post disassociation in the help center and contact form As per §4.a of the Creative Commons Attribution-ShareAlike license that all Stack Exchange posts are under,

upon notice from any Licensor [Stack Exchange] must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested.

The most obvious way for a contributor to do that is to flag their own post. This is what is mentioned by the Meta.SO post on the subject; I couldn't find any mention in the help center. This transmits the request to moderators, who have no way to honor it and must pass on the request to Stack Exchange staff.
It would be more direct if content disassociation requests went directly to Stack Exchange staff, via the contact form. Please mention content credit removal in the help center — possibly under What is the license for the content I post?

A: If you wanted to frame it as a legal obligation, StackExchange could be nasty and tell you that you already have a way to remove your name: deleting your account.


text:
Q: dynamic memory created inside a function I would like to know the technical reason(in terms of memory) why this piece of code will not work:
#include <stdio.h>
#include <stdlib.h>

int* fun(int*);
int main()
{
  int a=5;
  int* ptr;
  //  ptr=(int*)malloc(sizeof(int));
  fun(ptr);
  a=*ptr;

  printf("\n the val of a is:%d",a);
  return 0;
}

void fun(int* ptr)
{

  ptr = (int*)malloc(sizeof(int));
  *ptr = 115;

}

Why will this not  work? I thought that the heap(more importantly the addresses) is common to all the function's variables in the stack .
Also, why would this work.
If i comment the memory allocation inside the function fun and uncomment the one in main . It works fine.

A: The fun() function parameter is a copy of the variable you passed into fun(). So when you do:
ptr = (int*)malloc(sizeof(int));
*ptr = 115;

you only change that copy. You should change the function signature:
int* fun(int** ptr)
{
     *ptr = (int*)malloc(sizeof(int));
     **ptr = 115;
}

and change how you call it accordingly.

A: You are confused about several things here, but one easy way of writing the function is:
int * fun()
{
  int * ptr = (int*)malloc(sizeof(int));
  * ptr = 115;
  return ptr;
}

You are now responsible for freeing the memory, so in main():
int * ip = fun();
printf( "%d", * ip );
free( ip );

The alternative is to pass the address of  apointer (a pointer to a pointer) to the function:
void fun( int ** pp )
{
  * pp = (int*)malloc(sizeof(int));
  ** pp = 115;
}

then your code in main() looks like:
int * ip;
fun( & ip );
printf( "%d", * ip );
free( ip );

I think you can see that the first function is simpler to use.

A: In C, everything is passed by value.
What you are passing to fun() is a copy of the pointer you have in main().
That means the copy of ptr is aimed at the allocated memory, and that memory set to 115.
The ptr in main() still points at an undefined location because it has never been assigned.
Try passing a pointer to the pointer, so that within fun() you have access to the pointer itself:
#include <stdio.h>
#include <stdlib.h>

int* fun(int**); // <<-- CHANGE
int main()
{
    int a=5;
    int* ptr;
    //  ptr=(int*)malloc(sizeof(int));
    fun(&ptr); // <<-- CHANGE
    a=*ptr;

    printf("\n the val of a is:%d",a);
    return 0;
}

int* fun(int** another_ptr) // <<-- CHANGE
{

    *another_ptr = (int*)malloc(sizeof(int)); // <<-- CHANGE
    **another_ptr = 115; // <<-- CHANGE
    return *another_ptr;
}

The other option would be to make fun() actually return the updated pointer (as advertised), and assign this to ptr:
#include <stdio.h>
#include <stdlib.h>

int* fun(int*);
int main()
{
    int a=5;
    int* ptr;
    //  ptr=(int*)malloc(sizeof(int));
    ptr = fun(ptr); // <<-- CHANGE
    a=*ptr;

    printf("\n the val of a is:%d",a);
    return 0;
}

int* fun(int* another_ptr)
{
    another_ptr = (int*)malloc(sizeof(int));
    *another_ptr = 115;
    return another_ptr; // <<-- CHANGE
}

Edit: I renamed the variable in fun() to make it clear that it is different from the one you use in main(). Same name doesn't mean anything here.

A: You need to pass the address of the pointer in main if you want to change it:
fun(&ptr);

(and change fun appropriately, of course)
At the moment, it's changing the local variable ptr inside the function, and of course that change doesn't magically appear anywhere else.

A: You're passing the ptr by value to fun. fun will recieve a copy of ptr which will be modified. You need to pass ptr as int**.
void fun(int** ptr)
{
   *ptr = (int*)malloc(sizeof(int));
   **ptr = 115;
}

and call it with:
fun(&ptr);

(I also removed the return value from fun since it wasn't used)

A: The variable int* ptr is passed by value to the function fun. So the value assigned to  ptr inside the function using ptr = (int*)malloc(sizeof(int)); will not be reflected outside the function. So when you do a = *ptr; in main() you are trying to use an un-initialized pointer. If you want to to reflect the changes done to ptr outside the function then you need to change the signature of fun to fun(int** ptr) and do *ptr = (int*)malloc(sizeof(int));

A: Remember that if you want a function to modify the value of an argument, you must pass a pointer to that argument.  This applies to pointer values; if you want a function to modify a pointer value (not what the pointer points to), you must pass a pointer to that pointer:
void fun (int **ptr)
{
  /**
   * Do not cast the result of malloc() unless you are
   * working with a *very* old compiler (pre-C89).
   * Doing so will supress a valuable warning if you
   * forget to include stdlib.h or otherwise don't have
   * a prototype for malloc in scope.
   *
   * Also, use the sizeof operator on the item you're
   * allocating, rather than a type expression; if you
   * change the base type of ptr (say from int to long),
   * then you don't have to change all the corresponding
   * malloc() calls as well.
   *
   * type of   ptr = int **
   * type of  *ptr = int *
   * type of **ptr = int
   */
  *ptr = malloc(sizeof **ptr);
  *ptr = 115;
}

int main(void)
{
  int *p;
  fun(&p);
  printf("Integer value stored at %p is %d\n", (void *) p, *p);
  return 0;
}

BTW, you have a type mismatch in your example; your initial declaration of fun returns an int *, but the definition returns void.


text:
Q: calling an array defined in one method in another method am learning ruby and i had come across this particular issue.
I have method which reads the user input data into an array and i have another method which displays the values in the same array to the user with some processing.
However this doesnt seem to be the correct way as the system always throws a
Arraypass.rb:23:in <main>': undefined local variable or methodnames' for main:Object (NameError)
Appreciate if someone can show a way forward in this,
for example:
class School

   def askdetails
     print "How many students are there"
     n=(gets.chomp.to_i - 1)
     print "Enter names one by one"
     names=Array.new(n)
       for i in (0..n)
       names[i]=gets.chomp
       end
     return names,n
   end

   def showdetails(names,n)
     for i in (0..n)
     puts names[i]
     end
   end
end

stud=School.new
stud.askdetails
stud.showdetails(names,n)

A: Write the code as
#!/usr/bin/env ruby

class School

  def askdetails
    print "How many students are there"
    n = gets.chomp.to_i - 1
    print "Enter names one by one"
    names = Array.new(n)
    for i in (0..n)
      names[i]=gets.chomp
    end
    return names,n
  end

  def showdetails(names,n)
    for i in (0..n)
      puts names[i]
    end
  end
end

stud = School.new
names, n = stud.askdetails
stud.showdetails(names,n)

The thing, you missed is #askdetails methods returning an Array, which you didn't assign any where before using those.
Read Array Decomposition, this is what I did here :
names, n = stud.askdetails

A: here is your answer:
names,n = stud.askdetails
stud.showdetails(names,n)


text:
Q: How to solve null value in MySQL? I want to show data separately from income and expense table in MySQL using same query for both things but it show me when show income title date then same show  expense title date. But I need to do if it find income table's 4th row and if find expense table's 2nd row, but it show me 4th row. Why?
SELECT  income.date,
        IF(income.income_sourch IS NULL, 'N/A', income.income_sourch )as 'Income Title',
        income.amount as 'income',
        IF(expense.expense_sourche IS NULL, 'N/A', expense.expense_sourche)  as 'ExpenseTitle',
        expense.amount as 'Expense'
from expense  RIGHT JOIN income
     ON expense.date=income.date
where expense.date='30-Aug-2016'

A: Why - because that's how joins work when you have only a date to join the 2 tables. To solve this you need to create a relationship in addition to the date bearing in mind that at any one time the number of records in income could be greater than, less than or equal to the number of records in expenses. If we generate a row number for each row in income and independently generate a row number for each row in expenses then we can join income and expenses on row number
for example
/*
CREATE TABLE INCOME (ID INT,DESCRIPTION VARCHAR(10),DT DATE,AMOUNT INT);
INSERT INTO INCOME VALUES
(1,'SALE','2016-08-30',100),
(2,'ROKY','2016-08-30',200),
(3,'KORIM','2016-08-30',300),
(4,'SALEVOUCHR','2016-08-30',400);
CREATE TABLE EXPENSES (ID INT,DESCRIPTION VARCHAR(10),DT DATE,AMOUNT INT);
TRUNCATE TABLE EXPENSES;
INSERT INTO EXPENSES VALUES
(1,'RENT','2016-08-30',100),
(2,'UTILITIES','2016-08-30',100);
/*

This code
SELECT S.DT,S.DESCRIPTION,S.AMOUNT, s.rn,T.DESCRIPTION,T.AMOUNT, t.rn1
FROM
(
SELECT I.DT,I.DESCRIPTION,I.AMOUNT,
            @RN:=@RN + 1 RN
FROM     (SELECT @RN:=0) RN,INCOME I
) S
LEFT OUTER JOIN
(SELECT E.DT,E.DESCRIPTION,E.AMOUNT,
            @RN1:=@RN1 + 1 RN1
FROM     (SELECT @RN1:=0) RN1, EXPENSES E
) T ON T.RN1 = S.RN AND T.DT = S.DT
WHERE S.DT IS NOT NULL

results in
+------------+-------------+--------+------+-------------+--------+------+
| DT         | DESCRIPTION | AMOUNT | rn   | DESCRIPTION | AMOUNT | rn1  |
+------------+-------------+--------+------+-------------+--------+------+
| 2016-08-30 | SALE        |    100 |    1 | RENT        |    100 |    1 |
| 2016-08-30 | ROKY        |    200 |    2 | UTILITIES   |    100 |    2 |
| 2016-08-30 | KORIM       |    300 |    3 | NULL        |   NULL | NULL |
| 2016-08-30 | SALEVOUCHR  |    400 |    4 | NULL        |   NULL | NULL |
+------------+-------------+--------+------+-------------+--------+------+

BUT this is UNSAFE because it assumes that there are always more income than expense items
for example if we add 3 more expense rows
TRUNCATE TABLE EXPENSES;
INSERT INTO EXPENSES VALUES
(1,'RENT','2016-08-30',100),
(2,'UTILITIES','2016-08-30',100),
(3,'RATES','2016-08-30',100),(4,'SALARY','2016-08-30',100),(5,'INSURANCE','2016-08-30',100);

then the last expense item is lost resulting in
+------------+-------------+--------+------+-------------+--------+------+
| DT         | DESCRIPTION | AMOUNT | rn   | DESCRIPTION | AMOUNT | rn1  |
+------------+-------------+--------+------+-------------+--------+------+
| 2016-08-30 | SALE        |    100 |    1 | RENT        |    100 |    1 |
| 2016-08-30 | ROKY        |    200 |    2 | UTILITIES   |    100 |    2 |
| 2016-08-30 | KORIM       |    300 |    3 | RENT        |    100 |    3 |
| 2016-08-30 | SALEVOUCHR  |    400 |    4 | UTILITIES   |    100 |    4 |
+------------+-------------+--------+------+-------------+--------+------+

To cope with this we can simulate a full join like so
SELECT S.*,T.*
FROM
(
SELECT I.DT,I.DESCRIPTION,I.AMOUNT,
            @RN:=@RN + 1 RN
FROM     (SELECT @RN:=0) RN,INCOME I
) S
LEFT JOIN
(SELECT E.DT,E.DESCRIPTION,E.AMOUNT,
            @RN1:=@RN1 + 1 RN1
FROM     (SELECT @RN1:=0) RN1, EXPENSES E
) T ON T.RN1 = S.RN AND T.DT = S.DT

UNION

SELECT S.*,T.*
FROM
(
SELECT I.DT,I.DESCRIPTION,I.AMOUNT,
            @RN3:=@RN3 + 1 RN3
FROM     (SELECT @RN3:=0) RN3,INCOME I
) S
RIGHT JOIN
(SELECT E.DT,E.DESCRIPTION,E.AMOUNT,
            @RN4:=@RN4 + 1 RN4
FROM     (SELECT @RN4:=0) RN4, EXPENSES E
) T ON T.RN4 = S.RN3 AND T.DT = S.DT

result
+------------+-------------+--------+------+------------+-------------+--------+------+
| DT         | DESCRIPTION | AMOUNT | RN   | DT         | DESCRIPTION | AMOUNT | RN1  |
+------------+-------------+--------+------+------------+-------------+--------+------+
| 2016-08-30 | SALE        |    100 |    1 | 2016-08-30 | RENT        |    100 |    1 |
| 2016-08-30 | ROKY        |    200 |    2 | 2016-08-30 | UTILITIES   |    100 |    2 |
| 2016-08-30 | KORIM       |    300 |    3 | 2016-08-30 | RATES       |    100 |    3 |
| 2016-08-30 | SALEVOUCHR  |    400 |    4 | 2016-08-30 | SALARY      |    100 |    4 |
| NULL       | NULL        |   NULL | NULL | 2016-08-30 | INSURANCE   |    100 |    5 |
+------------+-------------+--------+------+------------+-------------+--------+------+

A: you just need to add limits inside the query

if expense table limit 2
  if other limit 4

See how to add limit to the query with if condition


text:
Q: PHP, need file to be overwritten or deleted after use I have written a function to get a file from S3 and get the number of pages from it. (It's a PDF.) Everything works fine until I try and do the same for multiple files.  Now it is just returning the number of pages of the last file. I think that the problem is that local.pdf needs to be deleted or overwritten, but I'm not sure how.  I thought it would automatically overwrite it.
I tried using $pdf->cleanUp(); but that doesn't seem to do anything. It is still returning the page count of the last file.
This is the function that gets called for each child job:
public function getPageCountPDF($jobid) {
    $this->load->library('Awss3', null, 'S3');
    $PdfTranscriptInfo = $this->MJob->getDOCCSPdfTranscript($jobid);
    $filename = $PdfTranscriptInfo['origfilename'];
    $PdfFilename = 'uploads/' . $jobid . '/' . $filename;
    $localfilename = FCPATH . 'tmp\local.pdf';
    $this->S3->readfile($PdfFilename, false, 'bucket');
    require_once 'application/libraries/fpdi/fpdf.php';
    require_once 'application/libraries/fpdi/fpdi.php';
    $pdf = new FPDI();
    $pageCount = $pdf->setSourceFile($localfilename);
    $pdf->cleanUp();
    return $pageCount;
}

I am not getting any error messages, but the $pageCount should be 8 and then 6. The return I am getting from the function is 6 and 6.
I also tried adding
    ob_clean();
    flush();

But that clears the whole page, which I don't want.
I also tried using a generated name instead of local.pdf, but that doesn't work (I get a "cannot open file" message).
EDIT: This is the part that calls the function getPageCountPDF($jobid):
foreach ($copies as $copy) {
    .
    .
    $CI = &get_instance();
    $pageCount = $CI->getPageCountPDF($copy['jobid']);
    .
    .
}

A:     function get_all_directory_files($directory_path) {
    $scanned_directory = array_diff(scandir($directory_path), array(
        '..',
        '.'
    ));

    return custom_shuffle($scanned_directory);
}

function custom_shuffle($my_array = array()) {
$copy = array();
while (count($my_array)) {
    // takes a rand array elements by its key
    $element = array_rand($my_array);
    // assign the array and its value to an another array
    $copy [$element] = $my_array [$element];
    // delete the element from source array
    unset($my_array [$element]);
}
return $copy;

}
So you can call get_all_directory_files which calls custom_shuffle
Then you can loop through while reading them. In case you want to delete the files
You can proceed with :
 $arrayfiles = get_all_directory_files('mypath');
    foreach ($arrayfiles as $filename) {
        echo 'mypath/'.$filename;  //You can do as you please with each file here
       // unlink($filename); if you want to delete
    }

A: What happens to $pageCount after
$pageCount = $CI->getPageCountPDF($copy['jobid']); ?
This gets overwritten after each iteration. Maybe you want something like $pageCount[$copy['jobid']] = $CI->getPageCountPDF($copy['jobid']); so you actually keep an array of $pageCounts to be processed further down the line.


text:
Q: Cannot get jPlayer to give me sound anymore It used to, and i dont know why it doesnt now.  Anyway my JS is as follows:
$(document).ready(function(){
    var $container = $('#soundboard');

    $("#jplayer").jPlayer({
        supplied: "mp3",
        wmode: "window"
    });

    $("a.playbutton").click(function(e) {
        var current = $("#jplayer").data().jPlayer.status.src
        var playing = current.split("/");
        var href = encodeURIComponent($(this).attr("href"));

        if(playing[3] != href) {

            console.log("href:" + href);
            console.log("playing:" + playing);
            console.log("current:" + current);

            $("#jplayer").jPlayer("setMedia", {mp3: "http://mp3.mydomain.net/" + href});
            $("#jplayer").jPlayer("play");

            $("a.playbutton").removeClass("stop");
            $(this).addClass('stop');

            $("a.playbutton > img").each(function () {
                $(this).attr("src","http://i.mydomain.net/icons/play.png");
            });
        } else {
            $("#jplayer").jPlayer("stop");
            $("#jplayer").jPlayer("clearMedia");
            $("a.playbutton").removeClass("stop");
        }
        return false;
    });
});

Last time I checked this page it worked fine, and for some reason it's gone.  I updated my jplayer.js file with jquery.jplayer.min.js.
The HTML is:

The filenames are correct, the variables seem correct, however no audio is playing at all.  I don't get any error messages either, the pictures all change nicely too as seen from the JS.  I just have nothing to work with as there are no error messages :(
Edit:  This is a chrome specific error.  The player is working fine in internet explorer.

A: Apparently the latest stable version of Chrome broke html5 audio for jPlayer because jPlayer is using a non-standard mimetype for mp3 files.
See this: https://code.google.com/p/chromium/issues/detail?id=386073
Fix here but it requires editing the jplayer javascript file: https://github.com/happyworm/jPlayer/issues/223
Around line 704 (in version 2.6.3) change to:
mp3: {
  //codec: 'audio/mpeg; codecs="mp3"',
  codec: 'audio/mpeg',
  flashCanPlay: true,
  media: 'audio'
},

Update:
Fixed in latest version of jPlayer: https://cdnjs.cloudflare.com/ajax/libs/jplayer/2.6.4/jquery.jplayer/jquery.jplayer.min.js


text:
Q: Can we access node/host process from the Kubernetes pod? Is there a way to access the underlying host/node's process from Kubernetes pod in the same way like we access the host/node's filesystem by using hostPath volume mount?
PS: I am trying to monitor the node process with the help of auditbeat deployed as a pod on Kubernetes.

A: I believe what you are looking for is hostPID: true in the PodSpec:
spec:
  hostPID: true
  containers:
  - name: show-init
    command:
    - ps
    - -p
    - "1"

should, in theory, output "/sbin/init" since it is running in the host's PID namespace


text:
Q: onChange Event not trigerred AM sure there is something that am missing in this html. The onChange event never gets fired. anyone help?? Thanks
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>Wake up call</title>
    <script type="text/javascript">
      function v(elementName) {    // Function is defined here
        alert(elementName);
      }
    </script>
  </head>

  <body bgcolor="lightblue">
    <form>
      <input type="text"
        value="Wake me" id="wake"
        onchange="v(wake)">
    </form>
  </body>
</html>

A: you don't have a variable named wake. either change it to a string:
 <input type="text" value="Wake me" id="wake" onchange="v('wake')">

or if it's meant to be a variable, set the variable somewhere.


text:
Q: Why does Spring Security always respond with 403 Forbidden on all form Posts? I'm putting together a simple website using spring-boot (v2.1.3) and spring-mvc.  It was working well until I added spring-security by including the spring-boot-starter-security dependency and adding an implementation of WebMvcConfigurer.  Everything worked fine, including the default login and logout views, but all other forms respond with 403-Forbidden on POST's.
The bulk of the guidance I've seen involves csrf protection.  Ultimately, you want to include csrf tokens in your form, but the simplest advice is to disable csrf protection completely (http.csrf.disable()).  Adding that to the security configuration had no effect.
Here is my WebMvcConfigurer implementation...
@EnableWebSecurity
 public class WebSecurityConfig implements WebMvcConfigurer {

    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                    .anyRequest().authenticated()
                .and()
                    .formLogin()
                .and()
                    .httpBasic()
                .and()
                    .csrf().disable();
    }

    @Bean
    public UserDetailsService userDetailsService() throws Exception {
        InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();

        manager.createUser(User.withDefaultPasswordEncoder()
                .username("user")
                .password("password")
                .roles("USER")
                .build());

        return manager;
    }
 }

Looking for any assistance on basic spring security configuration as it relates to form POST's.

A: Implement WebSecurityConfigurer instead of WebMvcConfigurer
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurer {
}


text:
Q: Trigger to ensure a value cannot happen This is using Oracle SQL.
Apologies in advance as I am new to the SQL world.
I'm trying to create a simple trigger to ensure a sports event cannot happen in a certain month (we'll use December as the example). So if someone tries to insert a new row with a date in December, the trigger will prevent it.
The current table uses the DATE datatype, inserted as 'DD-MMM-YYYY' but when selected it's displayed as 'DD-MMM-YY' (I don't know why.)
Anyway, I've never made triggers before and I've tried it two ways but it bugs out because when I press ENTER on SQL Plus, it just keeps going as if I was missing a semi-colon. And I'm guessing the trigger itself is not working.
CREATE OR REPLACE TRIGGER event_test
BEFORE INSERT OR UPDATE
ON sports_event
BEGIN
    IF DATE
        IS 'DEC' THEN
        'Sports cannot occur during December.';
    END IF;
END;

I've also tried with a CASE and I could not get it to work.

A: Triggers aren't really meant for data validation. Why not use a check constraint instead?
ALTER TABLE sports_event
ADD CONSTRAINT not_in_december_ck
CHECK (TO_CHAR(event_date, 'MM') != '12')

A:
I'm trying to create a simple trigger to ensure a sports event cannot happen in a certain month
[...]
The exercise that I'm trying to do this for specifically asks to create a trigger to ensure the event cannot happen in a certain month.

As this is for homework / educational purpose, here are some hints first:

*

*First, as this was said by Mureink in his answer, remember that a CHECK CONSTRAINT is the preferred way to do data validation;

*Then, as you are required to use a trigger, you will need both an INSERT trigger and an UPDATE trigger;

*As you will do data validation, you need a BEFOREINSERT OR UPDATE trigger;

*You will access to incoming data using the NEW. pseudo-record;

*And you will reject DML statement by raising an exception.

You already have the (2) and (3) in your code. Starting from that, one complete solution might look like this:
CREATE OR REPLACE TRIGGER event_test
BEFORE INSERT OR UPDATE
ON sports_event
FOR EACH ROW WHEN (EXTRACT(MONTH FROM NEW.event_date) = 12)
BEGIN
    RAISE_APPLICATION_ERROR (
           num=> -20107,
           msg=> 'Sports cannot occur during December.');
END;

Untested. Beware of typos !


text:
Q: How to mark CRM 2011 Early Bound Data Context as Internal? I am using CRMSVCUTIL.exe to generate an early bound data context against my CRM 2011 On Premise instance. I noticed in the generated code that the context is marked public. I would prefer this to be internal in order to hide the context from the consuming tier. It is easy enough to open the generated file and change the access modifier manually, but I would prefer this to be automatic if there is a setting to do that instead.

A: There isn't a command line parameter or setting for this specifically; however, you could automate it by using the command line and then modifying it appropriately.
http://msdn.microsoft.com/en-us/library/ff681563.aspx


text:
Q: Iterate a map in a map I have a variable in tf declared as an object map that takes a string, and a child map of string values.

variable "apps" {
  type = map(object({
    hits = number,
    id = map(string),
  }))

Variable looks like this:
 default     = {
test = {
  hits = 1,
  id  = {
    one = "image-1234"
    two = "image-4567"
  }
}

In a resource declaration, I need the hits variable but also the child keys and values of the id map. How can I achieve this?
I have tried many code iterations, but would love to do something like:
name = id[each.key] to get the current key
I tried using count and getting a list of keys/values, e.g
I also tried to see if I can get the key value from the map, e.g.:
 description  = each.value[currentiteration].Value

In other words, I tried lots of combinations, even though the above is not right.


text:
Q: Organising and display thousands of photos in media library I've been looking at ways to organise and display several thousand images in the media library as well as a gallery-style page.
Just to put things into a bit more perspective...
The website I'm creating for my client is a fashion and sewing website for their company. In particular, what they would like to do is display a list of the patterns they have available, all of these patterns have two distinct features - type and brand.
An example of types might be bridal dresses or general clothing or formal jackets or whatever (up to the client)...
Examples of the brands are "New Look" or "Simplicity" who are the companies that make the patterns.
Ideally, my client would like to upload photos of the pattern covers (organised by type) and have the ability for customers to browse the patterns by type to find ones they like.
I've looked at solutions such as enhanced media library, however, that only allows categories, as opposed to an actual structure. This also means they have to go and tag each individual image with the categories... which with 3000+ images, will take a lot of time and effort.
They would ideally like to be able to upload their existing folder structure (or upload images to the media library and quickly organise them into that same folder structure through drag/drop and have a folder-display on the media library).

The second half of all this is displaying the images in an organised way.
However we categorise or sort out these images... The client needs to have a page which lists the categories of types for the patterns, and then the customer can click on a category and view all the patterns inside that category... However, it needs to -only- display the galleries/categories relating to patterns.
An example might be:
Main Pattern Gallery:

*

*Formal wear

*Bridal

*Sleep wear

*etc...

If they click on "Formal wear"

Gallery displaying the patterns classed as "formal wear"

I've tried a few gallery plugins, including Gallery Bank, Gallery, Gallery by supsytic, a couple I can't remember the names on...
All of them (from what I've seen) only allow display of a single select gallery, or display of -all- galleries...
I also had a play with next-gen gallery, however it seemed to have broken my wordpress (whenever I click on manage gallery it downloads an admin.htm rather then loading the gallery... and it won't delete things)... I'm going to try a fresh WP install with it to see if it works and to see if it offers any of the requirements I am after.

A: I had a very similar issue not so long ago, albeit, my scenario was allowing the user to select images by type of room, color, feature etc..
Using inspiration form this site: Inspiration and a combination of these two plugins, Custom Upload Dir, Media Tags it worked out quite well.
I dont think your going to be able to do what you want though without going through every image and tagging it in some form or other.
Again I had the same issue as developing a site AFTER uploading images. In the end I categorized all the images by type into folders on pc, then selected all images and whilst in windows,adding a tag to the copyright exif.. couldn't workout how to get the keyword exif :)
Then using this piece of code, the copyright exif info got written to the meta tag (tag) on upload.
add_filter('wp_read_image_metadata', 'hk_filter_add_exif','',3);

//******************************************************************************************
// this hook function adds also the exif tag "copyright" in the database of each uploaded image
//******************************************************************************************
function hk_filter_add_exif($meta, $file, $sourceImageType)
{
    if ( is_callable('exif_read_data') &&
        in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)) ) )
    {

        $exif = @exif_read_data( $file );

        if (!empty($exif['Copyright']))      $meta['tags'] = $exif['Copyright'] ;

        return $meta;
    }
}

Could then use standard wordpress functions to get this tag info to use in the plugins.
This isnt an answer as such, but hopefully it may give you ideas.


text:
Q: Azure Active Directory Roles I'm trying to figure out how do Azure AD roles work.
I signed into the old portal (manage.windowsazure.com) because the Active Directory is not yet moved to the new portal (portal.azure.com). Then I added a user with the role "User", another user with the role "Billing Admin" and another one with "Global Admin".
In the new portal, I can assign roles to manage the resources both users have access to. However, if I try to log in the Azure AD with either of those accounts, I get a "No subscriptions found" message. I don't understand why, because according to this Microsoft's article, at least the Global Admin and Billing Admin should have access.
So, how could I have roles so that people in the finances team can only access finances-related information?

A: The way I understand this is that roles in Azure AD (User Admin, Billing Admin etc.) are only applicable to Azure AD only. They have nothing to do with subscription roles (the roles you set in Azure portal like Owner, Contributor, Reader).
What you have to  do is once you have created these users in Azure AD in the old portal, go back to Azure Portal and assign subscription roles to these users according to your requirement. Once these folks have a subscription role assigned to them, they should be able to access Azure Portal. You may find this link useful for assigning subscription roles: https://azure.microsoft.com/en-in/documentation/articles/role-based-access-control-configure/.


text:
Q: Swift Toast not working in Swift 3 Can someone take a look at my code and tell me what I am doing wrong? My code is written exactly the same as it is specified in the documentation but I am getting an error saying "use of unresolved identifier ToastStyle"
func showToast() {
    let style = ToastStyle()
    style.messageColor = UIColor.white
    self.view.makeToast("Product added successfully!", duration: 3.0, position: .bottom, style: style)
}

@IBAction func saveProduct(_ sender: AnyObject) {
    self.showToast()
}

A: As I think of, self.view.makeToast() is not expecting style parameter remove it and check or please check if you are calling makeToast() with correct parameters.
UPDATE:
Try this
1) Added dependency to Podfile
2) Ran "pod install"
3) Launch project by clicking .xcworkspace file
4) Build the project "cmd+B"
5) Added "import Toast_Swift" to ViewController and check.


text:
Q: CORS issue with SignalR 2.2 on Azure I am trying to Connect SignalR from my Angular2 for messaging.
I am getting error in chrome:

XMLHttpRequest cannot load https://ls-dev-signalr.azurewebsites.net/signalr/negotiate?clientProtocol=1…onData=%5B%7B%22name%22%3A%22realtimemessaginghub%22%7D%5D&_=1490197517724. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

My SignalR configuration is in the OWIN Startup file which looks like this:
public void Configuration(IAppBuilder app)
{
    var config = new HttpConfiguration();

    var corsOption = new CorsOptions
        {
            PolicyProvider = new CorsPolicyProvider
            {
                PolicyResolver = context =>
                {
                    var policy = new CorsPolicy { AllowAnyOrigin = true, AllowAnyHeader = true, AllowAnyMethod = true };

                    return Task.FromResult(policy);
                }
            }
        };

    app.Map("/signalr", map =>
    {
        var hubConfiguration = new HubConfiguration
            {
                EnableDetailedErrors = false,
                //EnableJSONP = true,
                EnableJavaScriptProxies = true,
            };
       map.UseCors(corsOption).RunSignalR(hubConfiguration);
    });

    app.UseCors(corsOption);
    WebApiConfig.Register(config);
    app.UseWebApi(config);

}

I have researched lots of SO posts but did not have any success.
What should I do to enable CORS for SignalR?
UPDATE from @ShaulBehr, who is working with the OP on this issue:
We have narrowed the problem down to the fact that the browser client is not sending an Origin header when making the SignalR connection request.  We can repro this behavior in Postman: if you send an Origin header, the SignalR endpoint responds with an Access-Control-Allow-Origin header.  If not, not.
The question (for bounty) now is:

*

*How do we get the client to send an Origin header?  OR

*How do we get the Azure site to respond with the Access-Control-Allow-Origin header even if the Origin header is omitted from the request?

A: I have always found that adding this section to the web.config file works best:
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
       <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>

NOTE: These settings are "wide-open", accepting any callers.  You may need to be more restrictive in your use case.
Hope this helps!

A: According to the HTTP spec (URL below):

While following the requirements for cross-site access requests, user
  agents must ensure that for each request (including redirects, et
  cetera) the Origin HTTP request header is set, with the value set to
  access control origin.

https://www.w3.org/TR/2008/WD-access-control-20080912/#cross-site0
IIS respects the spec in this aspect as to only send the Access-Control-Allow-Origin header if the Origin request header is set.
That being said, it is possible, even if not recommended, to force the server to always set the Access-Control-Allow-Origin header with each request by adding it as a custom header in your web.config file.
You will also have to remove any entries in the Cors blade in the Azure portal.
To achieve this, you can add the following section to your web.config file:
<configuration>
  <system.webServer>
    <httpProtocol>
         <customHeaders>
            <add name="Access-Control-Allowed-Origin" value="*" />
         </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

A: I'm using SignalR cross domain, and am also on v2.2. I'm using Angular 1.5 though. But if the problem is truly on the SignalR side, this should work.
  app.Map("/signalr", map =>
     {
        // Setup the CORS middleware to run before SignalR.
        // By default this will allow all origins. You can
        // configure the set of origins and/or http verbs by
        // providing a cors options with a different policy.
        map.UseCors(CorsOptions.AllowAll);
        var hubConfiguration = new HubConfiguration
        {
           EnableDetailedErrors = true
        };
        map.RunSignalR(hubConfiguration);
     });


text:
Q: Using MIN function in LINQ I have a SQL Query of a view. This view
SELECT
  [ID]
  [Name],
  [Category],
  MIN(OrderDate) as OrderDate,
  MIN(DeliveryDate) as DeliveryDate
GROUP BY
  [ID], [Name], [Category]
FROM
  [OrdersView]

I know this query is correct because my DBA gave it to me. But I need to convert it into LINQ. Currently, I have the following:
var orders = from o in dataContext.OrdersView
             group o by new { o.ID, o.Name, o.Category } into grouping
             select new Order() {
               ID = grouping.Key.ID,
               Name = grouping.Key.Name,
               Category = grouping.Key.Category,
               OrderDate = ?,
               DeliveryDate = ?
             };

My problem is I do not know how to execute the MIN function on the OrderDate and DeliveryDate and use those values in my LINQ query. Unfortunately, I cannot change the database because its locked down. Can someone please point me in the right direction?
Thanks!

A: OrderDate = grouping.Min(a => a.OrderDate)
DeliveryDate = grouping.Min(a => a.DeliveryDate)
Edit: Used o instead of grouping accidentally. That should do it for you.

A: var orders = from o in dataContext.OrdersView
         group o by new { o.ID, o.Name, o.Category } into grouping
         let orderDate = grouping.Min(order => order.OrderDate)
         let deliveryDate = grouping.Min(order => order.DeliveryDate)
         select new Order() {
           ID = grouping.Key.ID,
           Name = grouping.Key.Name,
           Category = grouping.Key.Category,
           OrderDate = orderDate,
           DeliveryDate = deliveryDate
         };

In future I'd recommend to use LINQPad for testing your queries. It allows to view generated SQL code.


text:
Q: How to reference nested object into other collection Mongodb I want to reference nested object exist in another Collection object, in my Event object so that when i get Event of User than Venue of Event shall retrieve with it, i am new in mongodb and spring can any one help to do this.
class User{
private String name;
private Venue venue;

//Getter and Setter
}

class Event {
@DBRef
private Venue venue;

//Getter and Setter
}

A: If each User has one Venue, you can reference User instead of Venue in Event. If a User may have more than one Venue, you better make Venues a seperate collection and reference both in User and Event.

A: Try this.
class Venue{
    //Getter and Setter
}

class User{
    private String name;
    @DBRef
    private Venue venue;

    //Getter and Setter
}

class Event {
    @DBRef
    private Venue venue;

    //Getter and Setter
}


text:
Q: C#: When should I use TryParse? I understand it doesn't throw an Exception and because of that it might be sightly faster, but also, you're most likely using it to convert input to data you can use, so I don't think it's used so often to make that much of difference in terms of performance.
Anyway, the examples I saw are all along the lines of an if/else block with TryParse, the else returning an error message. And to me, that's basically the same thing as using a try/catch block with the catch returning an error message.
So, am I missing something? Is there a situation where this is actually useful?

A: Where possible, use TryParse - using it is far cheaper then getting an exception thrown.

A: Apart from the performance aspect that you mentioned yourself, there's also a semantic difference:
Using try/catch is meant for exceptional circumstances. Inputting invalid data is something you expect, not something exceptional.

A: Suppose you're reading a log file:
public IEnumerable<LogEntry> GetAllValidEntries() {
    while (!logReader.Finished) {
        string nextLine = logReader.ReadLine();
        LogEntry nextEntry;

        if (TryParseLogEntry(nextLine, out nextEntry))
            yield return nextEntry;
    }
}

private bool TryParseLogEntry(string line, out LogEntry logEntry) {
    logEntry = null;

    if (string.IsNullOrEmpty(line))
        return false;

    string[] cells = line.Split(';');
    if (cells.Length < 3)
        return false;

    DateTime time;
    decimal price;
    int quantity;

    // We just want to read this line of text as a LogEntry
    // IF it is valid; otherwise, there's no reason to throw
    // an error in the user's face
    if (!DateTime.TryParse(cells[0], out time) ||
        !decimal.TryParse(cells[1], out price) ||
        !int.TryParse(cells[2], out quantity))
        return false;

    logEntry = new LogEntry(time, price, quantity);
    return true;
}

Since the whole purpose of the above code is to extract valid items from a sequence (which is presumably expected to contain some invalid items), I think TryParse methods make a lot more sense in this case than Parse methods, which demand valid input.

A: It's pretty much as simple as this: Use Parse if you want an exception when you encounter invalid data; use TryParse if you don't. Your question seems, therefore, to be:

Why would you not want an exception if data is invalid?

Exceptions should only be used for exceptional cases, and the data being invalid might not be an exceptional case. Maybe you're writing a data cleansing program that's expecting to get invalid data and will try to infer what a reasonable value is when the data is invalid. Maybe the data isn't all that important and you can just skip the record that contains it.
It depends on context, and having the choice of Parse and TryParse methods lets you choose the appropriate parsing mechanism for yours.

A: If you need to set a default value on failed parsing, TryParse along with an if is a great way to do so.

A: Well int.TryParse returns a bool allowing you to test if it was successful instead of catching an exception.  I usually use it in situations where if the information was successfully translated, I want to use it, but if not, it's not important, I can ignore the failure in-so-far as I want to use a default unless I get a meaningful value in which case I'll override it, but if the value wasn't meaningful, I'll keep the default.
The theory says that exceptions are inherently expensive, and thus you shouldn't use them to dictate program flow.  You should catch them where something is semantically wrong, rather than something that may be interpreted as data flow.

A: For cases that either don't mind setting the value to 0 on a failed parse (perhaps invalid input) or cases where you want brevity, the return code of TryParse allows that.

A: Everytime you have a parse to perform as it is pretty less expensive to use than an Exception, plus you can make it part of a simple if statement instead of a big try...catch block.

A: I'm no c# monkey but...
An exception interrupts normal code flow by transferring processing to the catch block.
TryParse will give you more control (eg highlight an error in a text box) rather then relying on the Exception mechanism.

A: If you're doing validation of input on a form, you could set the ErrorProvider on the control (or a MessageBox or some other notification) when it returns false.  It's not an exceptional case because like others have said, you should plan for it.


text:
Q: Creating tabs in AngularJs I'm trying to create simple tabs using only divs with ng-show and ng-hide. I don't want to use jQuery or BootStrap. I have created the tabs but I cannot handle the divs correctly.
JS Fiddle

tab 1

tab 2

first

second

Even if I click the first tab displays the content of the second tab.
How can I display only the first content when I click the first tab and the second content when I click the second one?
Thank you in advance.

A: http://jsfiddle.net/x8xfM/2/

tab 1

tab 2

first

second

In your case showDetails = !showDetails will switch active tab each time you click on ANY tab.


text:
Q: Postgred pg_notify/listen only working if channel name is lower case I've read https://www.postgresql.org/docs/9.6/static/sql-notify.html and the channel name is just described as an 'identifier'.
I'm using NodeJS and pg https://www.npmjs.com/package/pg to access postgres.
If I use a lower case word in both, e.g. pg_notify('foo', ... and LISTEN foo it works.  I've tested all combinations:
pg_notify  LISTEN  outcome
lower      lower   works
lower      upper   works
upper      lower   fails
upper      upper   fails

Is this a bug, or is it a logical result of being an 'identifier'?  (If so, should this  be documented on pg_notify page?)

A: confusion comes from quotes.
single quotes are used for a string, double are used for identifier and can be skipped to none if you don't use mixed case/start from number/ or other tricks.
when you run pg_notify function you pass 'foo' as a string argument and thus use single quotes, when you run NOTIFY "Virtual" you use Virtual as channel name - an identifier, so you need to use " here.
So as you answered yourself, changing
client.query("LISTEN 'Virtual'");

to
client.query('LISTEN "Virtual"');

fixes an issue
https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

A: You should look for an identifier definition: Identifiers and Key Words.
Unquoted identifiers are case insensitive in that sense that regardless of how they are written by a user, Postgres sees them as in lowercase. In the function pg_notify() the first argument is not an identifier but a text literal which is treated as an identifier without parsing, so it is not converted to lowercase.


text:
Q: How can I make a center-aligned text's with to be just the text's width? Wondering how I can make centered text's width the width of the text?
Highlighted in red, it shows that the width is 100%.
http://jsfiddle.net/kenhimself/ktkdypyo/
CSS:
h1 {
    text-align: center;
    font-size: 5vh;
    line-height: 1;
    white-space: nowrap;
    background:red;
    color:white;
}

Thanks in advance!

A: Change your HTML structure like below and apply style for h2 as well.

text is centered

but the width is 100%.

How can I make it so that the width

is only the widht of the text?

CSS
h1 {
font-size: 5vh;
line-height: 1;
white-space: nowrap;
background:red;
color:white;
display:inline-block;
}

DEMO

A: http://jsfiddle.net/ktkdypyo/2/ you can add span inside h1 tag and then just give red color to span
html, body {
    width:100%;
    height:100%;
    font-size:100%;
    font-family:helvetica;
    font-weight:normal;
    font-style:normal;
}
h1 {
    text-align: center;

}
span{
  font-size: 5vh;
    line-height: 1;
    white-space: nowrap;
    background:red;
    color:white;
}

text is centered

but the width is 100%.

How can I make it so that the width

is only the widht of the text?

And your another question in the comments How can I make it so that when I hover over any of those texts, it fades out and gets replaced by a different text?
here is a working fiddle: http://jsfiddle.net/u7tYE/5060/

A: You need to wrap your text in a span and apply the background-color in span instead of h1. You can't use the same element because they are block-level element. You will need to put an inline-block element in a block-element to get the result you want.
For example

this is the entered text

CSS
span {
    background: red;
}

A: Question is already answered but adding
margin: 0 auto;
display: table;

to the css gets the job done without changing the markup. I've tested it on ie, chrome, mozilla and opera, seems okay on all.


text:
Q: How to permanently disable monitor power saver using the command line? I have tried as following:
1. Turn off: export DISPLAY=:0.0 && xset dpms force off
2. Turn on: export DISPLAY=:0.0 && xset -dpms

Which works but that is a temporary solution, which does not fix my problem yet. When i reboot system it start again and again the same auto turn off mode.
How can i now remotely using SSH turn it off forever?
IMPORTANT:
- KIOSK (ATM machine will use this option)
- 24/7 advertising display/slides will use this

Optional Note: this guide i followed  http://v2kblog.blogspot.com/2008/08/disabling-monitor-power-saver.html , but permanent solution did not worked.

A: The solution to the screen blanking problem is simple once the right option is found.  This has to do with power saving, but it isn't in an obvious place.
In 12.04 Gnome go to:
Applications > System tools > System Settings.
Select Brightness and Lock.
Uncheck the box for Dim screen to save power.
Next to the Turn screen off when inactive for option, select the amount of time before the screen is turned off. I selected 1 hour. Never is one selection that is available.

A: This will work.  Open terminal in the /etc/xdg/autostart directory.
Issue this command:
sudo -H gedit nodpms.desktop

Hit enter, you will have to input your password.
Gedit will open, copy and pasted the following code in and then save.
[Desktop Entry]
Type=Application
Exec=xset -dpms
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=nodpms
Name=nodpms
Comment[en_US]=
Comment=

Issue this in the still open terminal:
sudo -H gedit noscreenblank.desktop

Hit enter, you will have to input your password.
Gedit will open, copy and pasted the following code in and then save.
Exec=xset s off
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=noscreenblank
Name=noscreenblank
Comment[en_US]=
Comment=

Close the terminal.
Open the file browser and navigate to the etc/xdg/autostart directory.
Ensure that the files, nodpms.desktop and noscreenblank.desktop are there.  If so, close everything and then reboot.
After reboot you can run an xset q command in terminal and see that dpms and screen blanking are turned off.

A: #!/bin/bash
export DISPLAY=:0.0

if [ $# -eq 0 ]; then
  echo usage: $(basename $0) "on|off|status"
  exit 1
fi

if [ $1 = "off" ]; then
  echo -en "Turning monitor off..."
  xset dpms force off
  echo -en "done.\nCheck:"
  xset -q|grep "Monitor is"
elif [ $1 = "on" ]; then
  echo -en "Turning monitor on..."
  xset dpms force on
  echo -en "done.\nCheck:"
  xset -q|grep "Monitor is"
elif [ $1 = "status" ]; then
  xset -q|sed -ne 's/^[ ]*Monitor is //p'
else
  echo usage: $(basename $0) "on|off|status"
fi
Save this script in something like /usr/bin, give it a name (like switch_dpms) and make it executable with chmod 664 /usr/bin/switch_dpm.
Now all you need to do is add it to a cron job. So open your crontab file with:
crontab -e

and add this at the bottom:
@reboot /usr/bin/switch_dpms off

Every reboot it will turn dpms to off and you can also turn it on from commandline by doing /usr/bin/switch_dpms on or check its status with /usr/bin/switch_dpms status.
Source for the script

A: The previous answer will not work.  If you open a terminal and issue: xset q you will see that dpms will be enabled.  The easiest way I have found to solve this issue is by going into the startup applications and create 2 applications.  The name you give them does not matter, the 2 commands you need are this: xset s off (this disables the screensaver) and xset -dpms (disables dpms).  I wish that I new which config file to put these commands in, but I do not.


text:
Q: can we send applet through sms (binary data) Is it possible to send Java Applet through SMS.
The requirement is to download a Java applet through SMS to a mobile. Later install it.

A: SMS is probably not going to work very well with this. The limit for a single message is 140 bytes (which gives you 160 7-bit characters), and (according to Wikipedia) the standard only supports up to 255 segments in a long message. This means you are limited to 140 * 255 = approx 35Kb, which is fairly small.
It will also get expensive very quickly if you pay per message sent or received.
You are probably better off just using the internet. Any phone that can run an applet probably has proper internet access.

A: SMS is just 160 printable bytes :-) You can send a link to download applet at best.


text:
Q: Git not tracking a file from a folder - contents.json from .xcassets I have checked almost all the questions on SO but nothing has worked for me. The issue that I'm unable commit the Contents.json file of .xcassets whatsoever. Whenever I add new images to .xcassets the source control does list the images but not the Contents.json file. I'm using a bitbucket repository and not even SourceTree is showing this file in the uncommitted changes. Even tried adding all the files via terminal.
git add --all

Any guess why this is happening and what could possibly be the solution?
Update: The .gitignore file looks like:
ProjectName.xcworkspace/xcuserdata
ProjectName.xcodeproj/xcuserdata
*.xcscheme
xcschememanagement.plist

And .git/info/exclude looks something like:
.DS_Store
UserInterfaceState.xcuserstate

A: A lot of time has passed, but it seems I know what it is. I encountered the same problem, and every time I added resources, I had to manually do the following steps: git add -f
However, I found out about the command: git status --ignored
The command shows all ignored files. After that, I made the git add -f command manually, and it worked.

A: Probably you have .xcassets/Contents.json in one or more of the three ignore files .gitignore, .git/info/excludes and ~/.gitexclude.
If that is not the case then try executing below command which will ask Git to start tracking the file again:
git update-index --no-assume-unchanged <file>

For your case:
git update-index --no-assume-unchanged .xcassets/Contents.json


text:
Q: How can I scan from Microsoft Word 2010? I couldn't find the scan option in Microsoft Word 2010  but in Microsoft Word 2007 I used to have that option.
Can you please tell me how to scan from Microsoft Word 2010?

A: This is a feature that has been removed - TechNet Article Changes in Word 2010.

MODI provided a common document imaging and scanning solution for Office. It was also the basis of the Fax feature for Office. When MODI was installed, it was the default handler for .tif, .tiff, and .mdi files. In Office 2010, MODI is fully deprecated. This change also affects the setup tree, which no longer shows the MODI Help, OCR, or Indexing Service Filter nodes on the Tools menu. The Internet Fax feature in Office 2010 uses the Windows Fax printer driver to generate a fixed file format (TIF). MODI and all its components are deprecated for 64-bit Office 2010.

Searches on the internet show some various work arounds to be using OneNote 2010 to scan/insert into Word, a Word macro or scan using scanner software and inserting into Word.

A: Microsoft have not actually removed the facility, only the means of getting there.  A macro is freely available to restore the scan as an image function.
If you have omnipage just open it and go to tools/options and register the Winword .exe file (very intuitive) and then when you restart Word go to the tab marked 'Add ins' and you will find the OmniPage options (the old aquire text dialogue) you will be able to OCR as normal directly into the document - This applies to MS Word 2010.

A: The link may be helpful in resolving this issue, you can add a button scan.
http://www.pcpro.co.uk/realworld/360373/how-to-scan-into-word-2010/2


text:
Q: How to assign return of async value to initial state of reducer? Full code: https://github.com/kenpeter/test_infinite_scroll_1
I have a reducer. It has a prop called list. createList([], 0) calls remote api and gets data, then assign to list.
./reducers/loadMore.js
import { MORE_LIST } from "../actions/types";
import { createList } from "../utils/func";

const initState = {
  list: createList([], 0) // <--------------------
};

// able to fire
export default function list(state = initState, action = {}) {
  switch(action.type) {

    case MORE_LIST:
      return {
        list: action.list,
      }

    default:
      return state;
  }
}

./utils/func.js
import _ from 'lodash';
import axios from "axios";

// clone the array
export function createList(arr=[],start=0) {
  let apiUrl = "http://www.mangaeden.com/api/list/0?p=0";

  return axios.get(apiUrl).then((obj) => {
    let arr = obj.data.manga; // array of obj

    //console.log("--- start ---");
    //console.log(arr);

    return arr;
  });
}

The issue I have with function createList(arr=[],start=0) is
arr has data from remote api, but it is not able to return back to list in  ./reducers/loadMore.js

A: I feel that making ajax requests in your initial state for your reducer is an anti-pattern.
Instead, I would just have the initial state as an empty array and then either as your app starts or in an appropriate component's lifecycle (componentWillMount for example) I would dispatch an action to fetch the data.
You can use indicators like loading bars/spinners etc. to indicate to the user that data is coming back. Additionally, you can perform a check on the length of your array or just do a .map on the empty array anyway and this won't get errors.

A: Your createList returns a Promise. So in your client/actions/loadMore.js you need to do:
return createList(list, list.length+1).then((tmpList) => {
    dispatch({
      type: MORE_LIST,
      list: tmpList
    });
});

Also, as patric mentioned, the following code in client/reducers/loadMore.js is async,
const initState = {
  list: createList([], 0)
};

the initState.list here is a Promise. Instead initialize it with empty list and dispatch the loadMore() action in the ComponentDidMount method of your component/container


text:
Q: querying json at the back-end I'm building an app with Angularjs with its data stored on json files, so basically i just $http them and have them sorted into the templates.
It was perfectly fine when every .json was ~2kB, now it's over 20kB, so i'm thinking of separating the various parts of the json files into smaller chucks so that every chunk would be exactly what the client needs to receive in order to view a single page in the app (or state) and nothing more. But i want to keep the files as they are, if that's possible.
So, this my question then - is it possible to query json files at the back-end and send to the client only the queried part of it? And if so, how?
Thanks

A: the only way that I can think of is to use a server side code for that.
For example if we use PHP on the server side it would be something like this:
$string = file_get_contents("file.json");
$json_a = json_decode($string, true);
// server side pagination

The do some classic server side pagination.


text:
Q: Format part of string using formula I'm wondering if there is a way to do this without using vba. At the moment I have a column full of ID numbers for a Test Script that I am constructing.
The ID's up until now have been 001; 002; 003;....etc Now what I'm trying to do is auto populate the ID but prepending CLL- to the front of the ID to give me CLL-001
I'm using the formula
="CLL-" & ROW()-1

However, this returns CLL-1. What I'd like to do is have the numerical part of the ID formatted to 3 s.f. but I can't see a way to do this without using vba. Therefore is there anyway to do this in an excel formula instead of using something like:
cell.value = "CLL-" & Format(cell.row-1, "000")

A: ="CLL-" & TEXT(ROW()-1,"000") is one way.
This will break down on row 1001. You could use a MOD to maintain only 3 digits.


text:
Q: How to understand the realification of a complex vector space Let $V$ be a vector space over $\mathbb{C}$. A definition for the realification of $V$ is:

The realification of $V$ uses the same addition, but allow scalar multiplication of real numbers only. Then $V$ becomes a vector space over $\mathbb{R}$.

I just cannot understand this definition:
(i) How to understand "allow scalar multiplication of real numbers only"? Will $V$ itself change or not?
(ii) Why is $V$ still a vector space after realification?
(iii) If $\mathcal{B}$ is a basis of $V$, what will be the basis of $V$ after realification?
(iv) If $V$ is normed, will the norm change?

A: *

*The set $V$ itself does not change. And vector addition remains the same. What changes is that, when you consider the multiplication of a vector $v\in V$ by a scalar $\lambda$, you do it only when $\lambda$ is a real number.

*Because the vector space axioms still hold. I suggest that you check that yourself.

*No, never (unless $V=\{0\}$). For instance, $\{(1,0),(0,1)\}$ is a basis of $\Bbb C^2$, but not of its realification. In fact, $(i,0)\in\Bbb C^2$, but you cannot write it as e linear combination with real coefficients of $(1,0)$ and $(0,1)$.

*No, it doesn't. The norm of $V$ is still a norm of the realification of $V$.


text: Q: Cadastro com campo de biometria SpringBoot com Angular não sei se aqui é o lugar certo para dúvida que tenho, já peço desculpa antecipadamente. Tenho um cliente que me pediu pra registrar a biometria no cadastro do funcionário, utilizo spring boot na minha api back end, no mobile ate tenho uma ideia de como fazer, caso o Smartphone tenha leitor biométrico. Agora via api usando o angular não faço a mínima ideia, se alguém puder me ajudar, ficarei muito agradecido!


text:
Q: Elementary proof of $\mathcal{O}_K$ is a free abelian group of rank $n$ Let $K$ be a number field of degree $n$. It is known that $\mathcal{O}_K$ is a free abelian group of rank $n$. Most of the proofs start with defining a non-degenarete form and after some arguments, conclude the result. Also, the result can be shown via geometric methods like: The ring of integers of a number field is finitely generated..
So, I wonder whether there is an elementary proof that only uses basic abstract algebra? Alternative proofs are also appreciated.

A: I ambitiously claim that there is no proof that doesn't use properties of the trace pairing (or equivalent) - and here's a sketch of why.
One half is easy: we need to show that there is a linear map $\mathbb{Z}^n\hookrightarrow \mathcal{O}_K$. Well, an integral basis $a_1, \dots, a_n$ for $K/\mathbb{Q}$ clearly does this for us: the sum $a_1 \mathbb{Z} + \dots + a_n \mathbb{Z}$ is a direct sum (this follows easily from the definition of a integral basis), so has rank $n$, and it lives inside $\mathcal{O}_K$ (by definition of an integral basis). The definitions were set up to make this work.
For the converse: we need to show that there is some linear map $\mathcal{O}_K \hookrightarrow \mathbb{Z}^n$. Well, if this exists, then we can certainly project onto any of its $n$ coordinates, which will give us a nontrivial linear map $\mathcal{O}_K\to \mathbb{Z}$. Now, what functions are there that do this?
(Important note: we already know - because some clever person has told us so - that the maps $t_i: x\mapsto \mathrm{Tr}_{K/\mathbb{Q}}(a_ix)$ work. In fact, the map $(t_1, \dots, t_n): \mathcal{O}_K\to \mathbb{Z}^n$ is injective, which is another way of saying that the $t_i$ are all $\mathbb{Z}$-linearly independent. So we happen to know, a fortiori, that $\mathcal{O}_K \cong \mathbb{Z}^n$.
But that's not the question you asked. What you asked is: couldn't we have chosen something simpler than the maps $t_i$? And we're going to use the above knowledge to show that the answer is "no".)
We know that we need linear maps from $\mathcal{O}_K$ to $\mathbb{Z}$. Let's look at the space of all such maps we could have chosen - I'll it denote by $\mathrm{Hom}(\mathcal{O}_K, \mathbb{Z})$, and note that it's a $\mathbb{Z}$-module. Our question is: are there nontrivial elements of $\mathrm{Hom}(\mathcal{O}_K, \mathbb{Z})$ that are somehow "nicer" than the maps $t_i$?
But, if $\mathcal{O}_K\cong \mathbb{Z}^n$ (as we secretly know by the important note above), then $\mathrm{Hom}(\mathcal{O}_K, \mathbb{Z})$ is just isomorphic to $\mathrm{Hom}(\mathbb{Z}^n, \mathbb{Z})$. This is the dual of $\mathbb{Z}^n$, which is again isomorphic to $\mathbb{Z}^n$. In particular, $\mathrm{Hom}(\mathcal{O}_K, \mathbb{Z})$ is a $\mathbb{Z}$-module of rank $n$. But in our important note above, we showed that the maps $t_1, \dots, t_n$ were $n$ linearly independent elements of this module. In other words, there's nothing in $\mathrm{Hom}(\mathcal{O}_K, \mathbb{Z})$ that isn't just a linear combination of the $t_i$.
So no, in conclusion: you need to use properties of the $t_i$ because you need some maps, and (up to linear combination) they're the only ones available.


text:
Q: Why Vue official example 'markdown' don't works in .vue file? I'm using ES6 and migrate vue official markdown example to .vue file, but it doesn't update this.input value in compiledMarkdown computed method?
the result and the .vue code is here:

<template>

    <textarea :value="input" @input="update"></textarea>

</template>

I know computed property can bind data vaule and automatically update, but why not here?

A: you shouldn't be using an arrow function here:
methods: {
  update: _.debounce((e) => {
    this.input = e.target.value;
  }, 300)
}

This will bind this to the wrong context - the context of module file that you are writing, not the component instance created from it. Use a normal function instead.
methods: {
  update: _.debounce(function(e) {
    this.input = e.target.value;
  }, 300)
}


text:
Q: Analytic solution for AC current density in a wire? (skin effect) As I was reading about skin effect , I realized that the skin depth $\delta$ is defined assuming a plane wave incidence with a flat media and then the surface current is given by:
$$J=J_se^{-{\delta}/{z}}$$
I think the method is not applicable to a wire, specially at low frequencies were the current can not be considered as surface current anymore. I'm looking for an analytic solution for the ac current density in a cylindrical wire carrying a total sinusoidal current $I$ with frequency $f$.


text:
Q: Bonjour/Cocoa: Is the NSNetServerBrowser still listening if 'moreServicesComing' is NO? When an NSNetServiceBrowser instance discovers a service, it calls the following method on its delegate:
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser didFindService:(NSNetService *)netService moreComing:(BOOL)moreServicesComing

My question: if moreServicesComing is NO, does that mean that the browser instance has completely stopped listening for services, and you'll never get another update? Or does it just mean, "that's all for now," but it'll keep on searching?
(If NSNetServiceBrowser instances had a flag to indicate their state, this wouldn't be an issue. Unfortunately, they don't, so it's kind of a mystery.)

A: So after doing some tests where I had the service remove itself not long after it appeared on the network, it appears that yes, the NSNetServiceBrowser instance is still running.


text:
Q: Concurrent delegate methods I'm currently working with a Corebluetooth, with my phone acting as central, and a separate peripheral.
I'm successfully reading data from a peripheral device using the didUpdateValueFor delegate method. The problem I'm having is when I'm sending multiple packets of information at the same time.
For instance, I send "abc" first and "def" later. As the central updates the reading upon indication from the peripheral, I should be able to get "abcdef" at the end. This works fine if I am sending indications at a speed of 10 packets per second.
However, once my speed gets to the default indication speed, it's too fast for the central to keep up. I only get the first indication "abc", but I never receive the indication for "def".
Is there a way I can force the didUpdateValueFor method to run concurrently so it captures all incoming notifications regardless of speed?

A: The best-practices chapter of the Core Bluetooth Programming Guide recommends the use of subscription  via  setNotifyValue:forCharacteristic: rather than plain reads for characteristics that will change often.
It isn't clear from your question as to whether you are using subscription or polling via readValueForCharacteristic:

A: I think that you mean didUpdateValueForCharacteristic instead of didWriteValueForCharacteristic. Otherwise, the question doesn't seem correct as didWriteValueForCharacteristic can not be used to read data from the remote device (except if you are using error codes for communication - which you shouldn't ;) ).
There are two methods to push data from the peripheral to the central: indications and notifications.

*

*Notifications may be discarded if sent too fast or for whatever reasons.

*Indications can only be sent one at a time (you'll have to wait until the central replies with a confirmation that the indication has been processed, before sending another one!).

I see multiple ways how your current implementation may be incorrect:

*

*You are not waiting for the Handle Value Confirmation packet and send the next indication too early.

*You are sending indications / notifications before the Client Characteristic Configuration has been written by the central.

*Your peripheral has flagged the characteristic to support both notifications and indications. In this case, Core Bluetooth only supports notifications and doesn't enable indications, in which case you are back at unreliable notifications ([CBPeripheral setNotifyValue:forCharacteristic:])

If the specified characteristic is configured to allow both notifications and indications, calling this method enables notifications only.


text:
Q: How do I get the libc development libraries for Ubuntu 12.04? I want to install glibc-devel package in Ubuntu 12.04. I am VM Ware work station in my project and this package is one of the dependency to build project image. I tried to find information on google about this package but didnt find any staisfactory answer.
Is this package not supported in Ubuntu 12.04? If not then what is the alternative package for it.
Any help on this will be useful.

A: If you just need the libc header files, install libc6-dev .
If you prefer to install on the command-line, you can use:
sudo apt-get update && sudo apt-get install libc6-dev

This is worth mentioning, as if you're using a compiler other than the version of GCC as provided by build-essential  / gcc-defaults , you may want to just install the libc6-dev package.
(Installing build-essential will work because it will cause libc6-dev to be installed. libc6-dev is what actually provides the header files that enable you to link against GNU libc.)

A: The build-essential  package should sort you out.
sudo apt-get install build-essential

A: I have the same issue, and I clone the glibc (GNU libc) source with the command:
git clone git://sourceware.org/git/glibc.git

It runs fine for me.


text:
Q: What is the propper way to polyfill datetime-local in react? Firefox and Safari lacks the support of HTML5 input of type datetime-local,is there a way to use a polyfill so these inputs can be properrly used without the usage of a custom date time picker ?
the used input can be found here.


text: Q: How to display accounts of a user in which he is a account team member in alookup field? I have a custom lookup field which is related to account. I want to select only the accounts that I am a team member of. Those accounts have to be shown how to give this filter?


text:
Q: process is not using new open file configuration which I have set? I have a process which is running as golden user and I am trying to increase the open file limit for that user so that all the process that gets started up by that user, it should uses that settings. I changed the limits into below file and changes are not taking into affect:
/etc/security/limits.conf:

*       soft    nofile  65535
*       hard    nofile  100000

I modified settings for all the users by changing the limits for * wildcard as shown above. Now I started my process as golden user and I executed below cat command and I see it is using 8092 as open files so I am not sure why my changes are not getting into affect.
golden@machineA:~$ cat /proc/1442/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        unlimited            unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             483036               483036               processes
Max open files            8092                 8092                 files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       483036               483036               signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

I am using Ubuntu 14.04 box. Any idea what is wrong here and how can I make sure all process that gets started with golden user uses the new open file configuration? I think there is some place where 8092 is hardcoded because of which it is not overriding this value.
cat /proc/sys/fs/file-max
6145946

A: /etc/limits is a login-time setting. A change there applies when a user logs in, not when a process is started. There is no configuration for process startup. A process inherits the limits of its parent.
Note that a process can always choose to lower its limits. If you start a login session, and confirm the higher limits by running ulimit -a in a shell, and run the process in that shell, and the process's limits end up lower, it means that the process is lowering its limits. If so you'll have to explore the program's configuration to see if you can prevent it from doing that.


text:
Q: Docx to Google Doc using Google Script I have a lot of docx files ( ~ 72 ) , their MIMETYPE is :
application/vnd.openxmlformats-officedocument.wordprocessingml.document

and I want to convert all of them to GoogleDocument so I can edit them online to do so I need them to be
application/vnd.google-apps.document

Is this possible ? I've tried with blob but nothing works , there is a way to create a new google doc with the same format ?

A: Got it .
var docx = DriveApp.getFileById("###");
var newDoc = Drive.newFile();
var blob =docx.getBlob();
var file=Drive.Files.insert(newDoc,blob,{convert:true});

The {convert:true} convert it .
Ps : you need to set document name since it's not included in teh blob
DocumentApp.openById(file.id).setName(docx.getName());


text:
Q: Why is my sed script not returning the data I expect? I've written a sed script to pull the value of a field out of the multi-line output of a command, but it's not working, and I can't see what is wrong.
$ cf target | sed -e 's/space:\s+\(\S+\).*/\1/p'
api endpoint:   https://api.sys.gn01.pcf.my.com
api version:    2.112.0
user:           userid
org:            cart-creation
space:          stage

I am expecting to see the value stage, but when I use the -n option, I am seeing no output at all. I took out the -n above just to show what the output from my command looks like.

A: You got a reasonable awk answer in the comments but consider this approach instead:
$ awk '{t=$0; sub(/:.*/,"",t); sub(/^[^:]+:[[:space:]]*/,""); f[t]=$0} END{print f["space"]}' file
stage

$ awk '{t=$0; sub(/:.*/,"",t); sub(/^[^:]+:[[:space:]]*/,""); f[t]=$0} END{print f["api version"]}' file
2.112.0

$ awk '{t=$0; sub(/:.*/,"",t); sub(/^[^:]+:[[:space:]]*/,""); f[t]=$0}
    END{print f["space"], f["org"], f["api version"]}' file
stage cart-creation 2.112.0

$ awk -v n='space' '{t=$0; sub(/:.*/,"",t); sub(/^[^:]+:[[:space:]]*/,""); f[t]=$0} END{print f[n]}' file
stage

as it allows you to print any values(s) you like in any order just by their name.


text:
Q: How to set radio button checked in Angular 2 I am new to Angular 2.
I have a list and iterate it and display as radio buttons as shown below.  Now I want to set the check property if condition is TRUE.  How to do that in Angular 2?

              <input type="radio" name="optradio" *ngIf=" (CONDITION HERE) ? 'checked' : 'non' ">
              {{op.option_text}}

A: You can use it like this
<input type="radio" name="optradio" [checked]="savedVal == currentRadioVal ? true : false" >

A: try this

          <input type="radio" name="optradio" [checked]=" (CONDITION HERE)">
          {{op.option_text}}

Online demo: https://embed.plnkr.co/jSht4Do3DzpoVQG2SAwl/

A: You can use the simple way
<input type="radio" name="Availble" [value]="true" (change)="changeLogs()" [(ngModel)]="isLogsActive" [checked]="isLogsActive">

<input type="radio" name="Unavailable" [value]="false" (change)="changeLogs()" [(ngModel)]="isLogsActive" [checked]="!isLogsActive" >

A: <input type="radio" name='{{prod.configurationItem}}' value = '{{prod.additionalCost}}' [checked] = "prod.isDefault == 'Y' ? true : false">
prod is object item


text:
Q: Typesetting sparse matrices with long entries When typesetting a (square) matrix with arbitrary dimension but repeated entries (in particular null entries), I make use of the \cdots, \vdots and \ddots commands. When the entries of the matrix are short enough, this works quite well. However, as soon as some entries are long, the dots get messed up and the structure of the matrix is much less readable (not speaking of the dots not joining up properly, but that is a minor problem here). Here is an example:
\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
\begin{bmatrix}
a_{11}  & a_{12}  & 0 & \cdots & \cdots & \cdots & \cdots & 0 \\
a_{21}  & a_{22}  & a_{23}  & \ddots & && & \vdots \\
0 & a_{32}  & a_{33} & a_{34}  & \ddots & &  & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots &  & \vdots \\
\vdots & & \ddots & \ddots & \ddots & \ddots & \ddots& \vdots\\
\vdots  &  & & \ddots & a_{76}  & a_{77}  &  a_{78}  & 0\\
\vdots  &  & & & \ddots & a_{87}  & a_{88}  &  a_{89}\\
0 & \cdots &  \cdots & \cdots & \cdots & 0 & a_{98} & a_{99}  \\
\end{bmatrix}
\end{equation}

\begin{equation}
\begin{bmatrix}
a_{11}  & a_{12}  & 0 & \cdots & \cdots & \cdots & \cdots & 0 \\
a_{21}  & a_{22}  & a_{23}  & \ddots & && & \vdots \\
0 & a_{32}  & a_{33} & a_{34}  & \ddots & &  & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots &  & \vdots \\
\vdots & & \ddots & \ddots & \ddots & \ddots & \ddots& \vdots\\
\vdots  & & & \ddots & a_{n-2n-3}  & a_{n-2n-2}  &  a_{n-2n-1}  & 0\\
\vdots  & && & \ddots & a_{n-1n-2}  & a_{n-1n-1}  &  a_{n-1n}\\
0 & \cdots &  \cdots & \cdots & \cdots & 0 & a_{nn-1} & a_{nn}  \\
\end{bmatrix}
\end{equation}

\begin{equation}
\begin{bmatrix}
A_{-n,0}^{-n}  & A_{-n+1,-1}^{-n}  & 0 & \cdots & \cdots & \cdots & \cdots & 0 \\
A_{-n,1}^{-n+1}  & A_{-n+1,0}^{-n+1}  & A_{-n+2,-1}^{-n+1}  & \ddots & && & \vdots \\
0 & A_{-n+1,1}^{-n+2}  & A_{-n+2,0}^{-n+2} & A_{-n+3,-1}^{-n+2}  & \ddots & &  & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots &  & \vdots \\
\vdots & & \ddots & \ddots & \ddots & \ddots & \ddots& \vdots\\
\vdots  & & & \ddots & A_{n-3,1}^{n-2}  & A_{n-2,0}^{n-2}  &  A_{n-1,-1}^{n-2}  & 0\\
\vdots  & && & \ddots & A_{n-2,1}^{n-1}  & A_{n-1,0}^{n-1}  &  A_{n,-1}^{n-1}\\
0 & \cdots &  \cdots & \cdots & \cdots & 0 & A_{n-1,1}^{n}  & A_{n,0}^{n}  \\
\end{bmatrix}
\end{equation}

\end{document}

In this example, matrix (1) is fine, things start to get ugly with matrix (2), and matrix (3) is even worse:

I guess if I was able to force the height of each row (and width of each column) to be equal to the maximum width of the columns, the matrix would like fine. Do you know how to do that?

A: My answer only deals with the third matrix in your MWE, as it's the most challenging one to typeset in a visually appealing way. Like some of the other answers and comments have already noted, it's not necessary (as well as, I'd say, rather ugly) to make the column heights equal to the column widths. My answer below therefore adds only a small amount of whitespace between the rows (via the \extrarowheight parameter). The column widths, however, are all forced to be the same. Furthermore, it would seem (at least for the case at hand) that it's preferable to left-align rather than to center the cells' contents.
\documentclass{article}
\usepackage{amsmath}
\usepackage[margin=1in]{geometry}

\newlength{\mycolwidth}
\settowidth{\mycolwidth}{$A_{n-1,-1}^{n-2}$} % widest entry

\usepackage{array}
\newcolumntype{Z}{>{$}p{\mycolwidth}<{$}}

\begin{document}
First, the plain (bmatrix) solution:
\begin{equation}
\begin{bmatrix}
A_{-n,0}^{-n}  & A_{-n+1,-1}^{-n}  & 0 & \cdots & \cdots & \cdots & \cdots & 0 \\
A_{-n,1}^{-n+1}  & A_{-n+1,0}^{-n+1}  & A_{-n+2,-1}^{-n+1}  & \ddots & && & \vdots \\
0 & A_{-n+1,1}^{-n+2}  & A_{-n+2,0}^{-n+2} & A_{-n+3,-1}^{-n+2}  & \ddots & &  & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots &  & \vdots \\
\vdots & & \ddots & \ddots & \ddots & \ddots & \ddots& \vdots\\
\vdots  & & & \ddots & A_{n-3,1}^{n-2}  & A_{n-2,0}^{n-2}  &  A_{n-1,-1}^{n-2}  & 0\\
\vdots  & && & \ddots & A_{n-2,1}^{n-1}  & A_{n-1,0}^{n-1}  &  A_{n,-1}^{n-1}\\
0 & \cdots &  \cdots & \cdots & \cdots & 0 & A_{n-1,1}^{n}  & A_{n,0}^{n}  \\
\end{bmatrix}
\end{equation}

Second, a solution that forces all columnwidths to be the
same, left-aligns the cells' contents, and increases the
distances between rows:

\setlength{\extrarowheight}{1.5\baselineskip}
\begin{equation}
\left[ \begin{array}{*{8}{Z}}
A_{-n,0}^{-n}  & A_{-n+1,-1}^{-n}  & 0 & \cdots & \cdots & \cdots & \cdots & 0 \\
A_{-n,1}^{-n+1}  & A_{-n+1,0}^{-n+1}  & A_{-n+2,-1}^{-n+1}  & \ddots & && & \vdots \\
0 & A_{-n+1,1}^{-n+2}  & A_{-n+2,0}^{-n+2} & A_{-n+3,-1}^{-n+2}  & \ddots & &  & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots &  & \vdots \\
\vdots & & \ddots & \ddots & \ddots & \ddots & \ddots& \vdots\\
\vdots  & & & \ddots & A_{n-3,1}^{n-2}  & A_{n-2,0}^{n-2}  &  A_{n-1,-1}^{n-2}  & 0\\
\vdots  & && & \ddots & A_{n-2,1}^{n-1}  & A_{n-1,0}^{n-1}  &  A_{n,-1}^{n-1}\\
0 & \cdots &  \cdots & \cdots & \cdots & 0 & A_{n-1,1}^{n}  & A_{n,0}^{n}  \\[5ex]
\end{array} \right]
\end{equation}

\end{document}

A: I would use less dots and make the triangles of zeroes more clear:
\documentclass{article}
\usepackage[hmargin=1in]{geometry}
\usepackage{amsmath}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\begin{gather}
  \begin{bmatrix}
    a_{11} & a_{12} & 0 & \cdots &&&&&& \cdots & 0
    \\
    a_{21} & a_{22} & a_{23} & 0 & \cdots &&&&& \cdots & 0
    \\
    0 & a_{32} & a_{33} & a_{34} & 0 & \cdots &&&& \cdots & 0
    \\
    \vdots &&&&& \ddots &&&&& \vdots
    \\
    0 & \cdots &&&& \cdots & 0 & a_{76} & a_{77} & a_{78} & 0
    \\
    0 & \cdots &&&&& \cdots & 0 & a_{87} & a_{88} & a_{89}
    \\
    0 & \cdots &&&&&& \cdots & 0 & a_{98} & a_{99}
  \end{bmatrix}
  \\
  \begin{bmatrix}
    a_{11} & a_{12} & 0 & \cdots &&&&&& \cdots & 0
    \\
    a_{21} & a_{22} & a_{23} & 0 & \cdots &&&&& \cdots & 0
    \\
    0 & a_{32} & a_{33} & a_{34} & 0 & \cdots &&&& \cdots & 0
    \\
    \vdots &&&&& \ddots &&&&& \vdots
    \\
    0 & \cdots &&&& \cdots & 0 & a_{n-2,n-3} & a_{n-2,n-2} & a_{n-2,n-1} & 0
    \\
    0 & \cdots &&&&& \cdots & 0 & a_{n-1,n-2} & a_{n-1,n-1} & a_{n-1,n}
    \\
    0 & \cdots &&&&&& \cdots & 0 & a_{n,n-1} & a_{n,n}
  \end{bmatrix}
  \\
  \begin{bmatrix}
    A^{-n}_{-n,0} & A^{-n}_{-n+1,-1} & 0 & \cdots &&&&&& \cdots & 0
    \\
    A^{-n+1}_{-n,1} & A^{-n+1}_{-n+1,0} & A^{-n+1}_{-n+2,-1} & 0 & \cdots &&&&& \cdots & 0
    \\
    0 & A^{-n+2}_{-n+1,1} & A^{-n+2}_{-n+2,0} & A^{-n+2}_{-n+3,-1} & 0 & \cdots &&&& \cdots & 0
    \\
    \vdots &&&&& \ddots &&&&& \vdots
    \\
    0 & \cdots &&&& \cdots & 0 & A^{n-2}_{n-3,1} & A^{n-2}_{n-2,0} & A^{n-2}_{n-1,-1} & 0
    \\
    0 & \cdots &&&&& \cdots & 0 & A^{n-1}_{n-2,1} & A^{n-1}_{n-1,0} & A^{n-1}_{n,-1}
    \\
    0 & \cdots &&&&&& \cdots & 0 & A^n_{n-1,1} & A^n_{n,0}
  \end{bmatrix}
\end{gather}
\end{document}

Of course the whole matrix could be made quadratic, e.g. by setting an appropriate \arraystretch:
\documentclass{article}
\usepackage[hmargin=1in]{geometry}
\usepackage{amsmath}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\newcommand*{\matrixC}[1][2]{%
  \begingroup
    \renewcommand*{\arraystretch}{#1}%
    \begin{bmatrix}
      A^{-n}_{-n,0} & A^{-n}_{-n+1,-1} & 0 & \cdots &&&&&& \cdots & 0
      \\
      A^{-n+1}_{-n,1} & A^{-n+1}_{-n+1,0} & A^{-n+1}_{-n+2,-1} & 0 & \cdots &&&&& \cdots & 0
      \\
      0 & A^{-n+2}_{-n+1,1} & A^{-n+2}_{-n+2,0} & A^{-n+2}_{-n+3,-1} & 0 & \cdots &&&& \cdots & 0
      \\
      \vdots &&&&& \ddots &&&&& \vdots
      \\
      0 & \cdots &&&& \cdots & 0 & A^{n-2}_{n-3,1} & A^{n-2}_{n-2,0} & A^{n-2}_{n-1,-1} & 0
      \\
      0 & \cdots &&&&& \cdots & 0 & A^{n-1}_{n-2,1} & A^{n-1}_{n-1,0} & A^{n-1}_{n,-1}
      \\
      0 & \cdots &&&&&& \cdots & 0 & A^n_{n-1,1} & A^n_{n,0}
    \end{bmatrix}%
  \endgroup
}
\newcommand*{\test}[1]{%
  \begingroup
    \sbox0{$\displaystyle\matrixC[#1]$}%
    \typeout{arraystretch=#1 -> (\the\wd0,\the\dimexpr\ht0+\dp0)}%
  \endgroup
}
\test{5.1}
\begin{gather}
  \matrixC[5.1]
\end{gather}
\end{document}

Log file message:
arraystretch=5.1 -> (428.8665pt,428.4004pt)

It already looks quite ugly for me, therefore I save my time to make equal column widths.

A: For completeness, here is an alternative solution based only on diagonal dots, inspired from this post already cited above.
\documentclass{article}

\usepackage{amsmath}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}

\newcommand{\diagdots}[3][-25]{%
  \rotatebox{#1}{\makebox[0pt]{\makebox[#2]{\xleaders\hbox{$\cdot$\hskip#3}\hfill\kern0pt}}}%
}

\begin{document}

\begin{equation}
\begin{bmatrix}
A_{-n,0}^{-n}  & A_{-n+1,-1}^{-n}  & 0 &  \multicolumn{4}{c}{\diagdots[0]{19em}{.4em}}   & 0 \\
A_{-n,1}^{-n+1}  & A_{-n+1,0}^{-n+1}  & A_{-n+2,-1}^{-n+1}  &  & && &  \\
0 & A_{-n+1,1}^{-n+2}  & A_{-n+2,0}^{-n+2} & A_{-n+3,-1}^{-n+2}  &  & &  &  \\
 & &  &  & \multicolumn{2}{c}{\raisebox{0.25\normalbaselineskip}{\diagdots[-18]{20em}{.4em}}}  &  & \diagdots[-90]{6em}{.4em}  \\
 & &  & \multicolumn{2}{c}{\diagdots[-18]{10em}{.4em}} &  &  & \\
\diagdots[-90]{6em}{.4em} & & \multicolumn{2}{c}{\raisebox{-0.5\normalbaselineskip}{\diagdots[-18]{20em}{.4em}}} &  &  &  &  \\
  & & &  & A_{n-3,1}^{n-2}  & A_{n-2,0}^{n-2}  &  A_{n-1,-1}^{n-2}  & 0\\
  & && &  & A_{n-2,1}^{n-1}  & A_{n-1,0}^{n-1}  &  A_{n,-1}^{n-1}\\
0 &  \multicolumn{4}{c}{\diagdots[0]{19em}{.4em}}   & 0 & A_{n-1,1}^{n}  & A_{n,0}^{n}  \\
\end{bmatrix}
\end{equation}

\end{document}

And the output:


text:
Q: To what extent does Floer cohomology detect Hamiltonian non-displaceability of immersed curves? Floer cohomology for immersed Lagrangians is introduced by
Akahi, Manabu; Joyce, Dominic, Immersed Lagrangian Floer theory, J. Differ. Geom. 86, No. 3, 381-500 (2010) and its one-dimension version (in the absence of "teardrops")
is developed in Abouzaid, Mohammed, On the Fukaya categories of higher genus surfaces, Adv. Math. 217, No. 3, 1192-1235 (2008).
See also the embedded case described in de Silva, Vin; Robbin, Joel W.; Salamon, Dietmar A., Combinatorial Floer homology.  As in the embedded case, non-triviality of Floer cohomology of immersed Lagrangians obstructs Hamiltonian displaceability.   For example, consider the following example of an immersion $f: L \to X $ in the two sphere $X$ (thought of as the one-point compactification the plane) dividing the two sphere into areas $A_0,A_1,A_2,A_3$ (smoothing used curve-shortening by A. Carapetis)
an immersed curve
A computation shows that the Floer cohomology admits a weakly bounding cochain and is Floer-non-trivial if $A_2 < \min(A_1,A_3)$ and
$$A_0 = A_1 + A_3 - 3A_2.$$
Indeed in this case using the Morse model there are six generators in the Floer cochains, given by the max and min of the height function and four generators corresponding to the two self-intersection points;  the zeroth Fukaya map is non-zero because of the two teardrops but the teardrops can be "killed" by taking a bounding cochain that is the sum of generators coming from the self-intersections with coefficients $q^{A_1 - A_2}$ and $q^{A_3 - A_2}$.    On the other hand, Moser's principle Moser, Jürgen, On the volume elements on a manifold, Trans. Am. Math. Soc. 120, 286-294 (1965)  implies that $f(L)$ is non-displaceable iff each of the areas is at most the sum of the other three:
$$ A_i \leq A_j + A_k + A_l, \quad i,j,k,l \ \text{distinct}. $$
Indeed, if one of these inequalities fails then there is a symplectomorphism that takes the complement of the interior of one of these regions into its interior, while if they all hold then such a symplectomorphism obviously does not exist.  The conditions
$$A_0 + 3A_2 = A_1 + A_3, A_2 < A_1, A_2 < A_3$$
imply the "Moser conditions" (exercise), but are much stronger.  So there seems to be a fairly big gap between Floer non-triviality and non-displaceability in this case.
Question:  (1) Can anyone do better, i.e. is it possible to detect the non-displaceability of immersed curves in the two-sphere using some other version of Floer theory, or a different weakly bounding cochain?
(2) Suppose one takes the product of two such curves in $S^2 \times S^2$.  Here Floer theory still works, but there is no analog of Moser's results although presumably one could use McDuff, Dusa, Displacing Lagrangian toric fibers via probes,  Proceedings of Symposia in Pure Mathematics 82, 131-160 (2011). When is the image of an immersion of product form displaceable?


text:
Q: Can we use sharepoint online root site as source variation Hi we are now working in multi language in SharePoint and we need to set the root site as source instead of its sub site.
I read that in variation we need to set the en-US as main source but in our case it needs to be the global root site because other countries has specific contents.
Below is our structure
company.sharepoint.com <---Root / Global
                      /US  <---Unit States
                      /China  <--- China
                      /Italy

Any tips on how to achieve this?

A: Variations are build on subsites. You cant make the root itself a variation, since that will be the variation root site. Below will be the different variation labels in the hierarchy.
There is a (fairly old) post by Steffan which explains this in a lot of detail:
https://blogs.technet.microsoft.com/stefan_gossner/2011/11/14/sharepoint-variations-the-complete-guide-part-1-the-basics/

A: No, this is not possible since it would introduce overlap between labels / the navigation hierarchy.
There are many methods to redirect users from different countries to the right site when using variations, you can check this article:
How to redirect users to the right site when using variations?


text:
Q: How to use a HTML file in Google Script I have just started using google apps and I was wondering how to add and use a HTML File in google script editor. I want to use the HTML with CSS as an Email template (i.e personalizing the email).  and send the email using:
MailApp.sendEmail("name@gmail.com", "Hello", "no html", {htmlBody: html});

A: With HtmlService.createHtmlOutputFromFile(fileName).getContent() you can generate the HTML as with anywhere in apps script, not sure emails will accept CSS though.
MailApp.sendEmail("name@gmail.com", "Hello", "no html", {htmlBody: HtmlService.createHtmlOutputFromFile(fileName).getContent()});

The HTML also have to be in the APP SCRIPT directory though, if you want to use an external hosted HTML you can use URLFetch() to get the HTML and treat it as such:
var emailHTML = UrlFetchApp.fetch("http://www.example.com/myemail.html").getContent()[0];

Also a more advanced option, you can also upload your HTML directly to Drive, and create a Database with them. Just another choice.


text:
Q: validates record on modal popup asp.net I am working on a project where I have Dropdownlist and add button to  open a modal in the modal I have a textbox and a button  to add the records in the table
value is inserting in the DB, after inserting modal popup close, now I want to validate the duplicate records if the record is already in the database it shows already inserted if it is not there then insert the record and close the popup modal. what is happening now is when I click submit it validates but it closes the modal popup and when I again open the popup the error is visible there I am sharing the screenshot and the code please guide me if anyone has an idea on that  on the first image I click on add button then  modal pops up  like the second image

Now I want the validation on the modal to check on submit button  if the record already exists in DB without closing the modal popup
Here is my code.

     Region

        <asp:DropDownList ID="ddlRegion" runat="server" class="form-control"
        AutoPostBack="True" OnSelectedIndexChanged="ddlRegion_SelectedIndexChanged"></asp:DropDownList>

                                        <asp:LinkButton ID="lbaddRegion" runat="server" data-toggle="modal" data-target="#modal-region"> </asp:LinkButton>

                                        <asp:LinkButton ID="LinkButton2" runat="server" data-toggle="modal" data-target="#modal-region" Visible="False"> </asp:LinkButton>

            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              ×</button>

Setup Region

Enter Region Name
<asp:Label ID="lblRegionError" runat="server" Text=" (Region Already exist)" Visible="false"></asp:Label>
               <asp:RequiredFieldValidator ID="NameRequired" runat="server" ControlToValidate="txtRegion" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
              <asp:TextBox ID="txtRegion" runat="server" CssClass="form-control"></asp:TextBox>

            <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
              <asp:Button ID="btnSubmitRegion" runat="server" Text="Save Changes" class="btn btn-primary" OnClick="btnSubmitRegion_Click"/>