Q: Jquery .change() For some reason this is non functional any help appreciated.
 <script>
 $(document).ready(function(){
   $('select[name=materialSelect]').change(function(){
    alert("Changed");
   });
 });
</script>
<select name="materialSelect" id="materialSelect">
            <option value="-1">-----Select Material-----</option>
            <option value="0">Material</option>

</select>

A: Your code doesn't have any issue, be careful that you've called your
$('select[name=materialSelect]').change(function(){
    alert("Changed");
 });

after which your html is loaded.
For sample binding the document load to a function that called your code.

A: There is a on change function of jquery available already you are binding it with body load which means your select doesn't exists when you call the function, you should do this :
$(document).on('change', '#materialSelect', function () {
alert('changed');
});

A: Your code is fine as long as the HTML element (on which you are binding the event) is present when the binding script is running.
To be on safe side, always bind to a parent element (body for example) which will delegate the event it to the child.
So, try this,
 $('body').on('change', 'select[name=materialSelect]', function(){
    alert("Changed");
 });

Hope it helps.

A: <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
    </head>
    <body>
      <select name="materialSelect" id="materialSelect">
        <option value="">-----Select Material-----</option>
        <option value="0">Material</option>
      </select>
      <script type="text/javascript">
      $(document).ready(function(){
        $('select[name=materialSelect]').change(function(){
          alert("Changed");
        });
      });
      </script>
    </body>
    </html>

A: First, I'd look into where jQuery is being loaded. jQuery needs to be loaded before any scripts that use it.
Incorrect:
<script>
    $('.something').change(...
</script>
<script src=""></script><!-- jquery -->

Correct:
<script src=""></script><!-- jquery -->
<script>
    $('.something').change(...
</script>

Secondly, you should be using some kind of document on ready function. This will ensure your HTML is rendered before applying your events (eg "onchange")
Correct:
<script src=""></script><!-- jquery -->
<script>
    $(function () {
        // DOM is now ready
        $('.something').change(...
    })
</script>


Q: Why does Swagger UI POST form data with Content-Type: undefined? I'm trying to POST form data using Swagger UI, but the request is sent with Content-Type: undefined:

How can I configure it so it works? JSON POST works just fine.
Here is my API definition:
{
  "swagger": "2.0",
  "info": {
    "version": "V1",
    "title": "Title"
  },
  "paths": {
    "/api/getcalculation": {
      "post": {
        "tags": [
          "ArrearsOfPay"
        ],
        "operationId": "ApiArrearsOfPayPost",
        "consumes": [],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "InsolvencyDate",
            "in": "formData",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "DismissalDate",
            "in": "formData",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "UnpaidPeriodFrom",
            "in": "formData",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "UnpaidPeriodTo",
            "in": "formData",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "ApClaimAmount",
            "in": "formData",
            "required": false,
            "type": "number",
            "format": "double"
          },
          {
            "name": "PayDay",
            "in": "formData",
            "required": false,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "ShifPattern",
            "in": "formData",
            "required": true,
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "multi"
          },
          {
            "name": "WeeklyWage",
            "in": "formData",
            "required": false,
            "type": "number",
            "format": "double"
          },
          {
            "name": "StatutaryMax",
            "in": "formData",
            "required": false,
            "type": "number",
            "format": "double"
          },
          {
            "name": "NumberOfDaysWorkedInWeek",
            "in": "formData",
            "required": false,
            "type": "integer",
            "format": "int32"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "$ref": "#/definitions/ArrearsOfPayCalculationResponseModel"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "ArrearsOfPayCalculationResponseModel": {
      "type": "object",
      "properties": {
        "startOfPayWeek": {
          "format": "date-time",
          "type": "string"
        },
        "maximumLiability": {
          "format": "double",
          "type": "number"
        },
        "employerLiability": {
          "format": "double",
          "type": "number"
        },
        "minimumLiability": {
          "format": "double",
          "type": "number"
        }
      }
    }
  }
}

A: The problem is here:
"consumes": []

The consumes keyword specifies the Content-Type header in requests. Since you are POSTing form data, it should be:
"consumes": ["application/x-www-form-urlencoded"]

Tip: You can paste your spec into http://editor.swagger.io to check for syntax errors.


Q: Remove empty array elements Some elements in my array are empty strings based on what the user has submitted. I need to remove those elements. I have this:
foreach($linksArray as $link)
{
    if($link == '')
    {
        unset($link);
    }
}
print_r($linksArray);

But it doesn't work. $linksArray still has empty elements. I have also tried doing it with the empty() function, but the outcome is the same.

A: function trim_array($Array)
{
    foreach ($Array as $value) {
        if(trim($value) === '') {
            $index = array_search($value, $Array);
            unset($Array[$index]);
        }
    }
    return $Array;
}

A: $out_array = array_filter($input_array, function($item)
{
    return !empty($item['key_of_array_to_check_whether_it_is_empty']);
}
);

A: Just want to contribute an alternative to loops...also addressing gaps in keys...
In my case, I wanted to keep sequential array keys when the operation was complete (not just odd numbers, which is what I was staring at. Setting up code to look just for odd keys seemed fragile to me and not future-friendly.)
I was looking for something more like this: http://gotofritz.net/blog/howto/removing-empty-array-elements-php/
The combination of array_filter and array_slice does the trick.
$example = array_filter($example);
$example = array_slice($example,0);

No idea about efficiencies or benchmarks but it works.

A: I use the following script to remove empty elements from an array
for ($i=0; $i<$count($Array); $i++)
  {
    if (empty($Array[$i])) unset($Array[$i]);
  }

A: $my = ("0"=>" ","1"=>"5","2"=>"6","3"=>" ");

foreach ($my as $key => $value) {
    if (is_null($value)) unset($my[$key]);
}

foreach ($my as $key => $value) {
    echo   $key . ':' . $value . '<br>';
}

output

1:5
2:6

A:     $myarray = array_filter($myarray, 'strlen');  //removes null values but leaves "0"
    $myarray = array_filter($myarray);            //removes all null values

A: foreach($arr as $key => $val){
   if (empty($val)) unset($arr[$key];
}

A: Just one line :
Update (thanks to @suther):
$array_without_empty_values = array_filter($array);

A: You can just do
array_filter($array)

array_filter: "If no callback is supplied, all entries of input equal to FALSE will be removed." This means that elements with values NULL, 0, '0', '', FALSE, array() will be removed too.
The other option is doing
array_diff($array, array(''))

which will remove elements with values NULL, '' and FALSE.
Hope this helps :)
UPDATE
Here is an example.
$a = array(0, '0', NULL, FALSE, '', array());

var_dump(array_filter($a));
// array()

var_dump(array_diff($a, array(0))) // 0 / '0'
// array(NULL, FALSE, '', array());

var_dump(array_diff($a, array(NULL))) // NULL / FALSE / ''
// array(0, '0', array())

To sum up:

*

*0 or '0' will remove 0 and '0'

*NULL, FALSE or '' will remove NULL, FALSE and ''

A: foreach($linksArray as $key => $link)
{
    if($link === '')
    {
        unset($linksArray[$key]);
    }
}
print_r($linksArray);

A: In short:
This is my suggested code:
$myarray =  array_values(array_filter(array_map('trim', $myarray), 'strlen'));

Explanation:
I thinks use array_filter is good, but not enough, because values be like space and \n,... keep in the array and this is usually bad.
So I suggest you use mixture array_filter and array_map.
array_map is for trimming, array_filter is for remove empty values, strlen is for keep 0 value, and array_values is for re indexing if you needed.
Samples:
$myarray = array("\r", "\n", "\r\n", "", " ", "0", "a");

// "\r", "\n", "\r\n", " ", "a"
$new1 = array_filter($myarray);

// "a"
$new2 = array_filter(array_map('trim', $myarray));

// "0", "a"
$new3 = array_filter(array_map('trim', $myarray), 'strlen');

// "0", "a" (reindex)
$new4 = array_values(array_filter(array_map('trim', $myarray), 'strlen'));

var_dump($new1, $new2, $new3, $new4);

Results:
array(5) {
  [0]=>
" string(1) "
  [1]=>
  string(1) "
"
  [2]=>
  string(2) "
"
  [4]=>
  string(1) " "
  [6]=>
  string(1) "a"
}
array(1) {
  [6]=>
  string(1) "a"
}
array(2) {
  [5]=>
  string(1) "0"
  [6]=>
  string(1) "a"
}
array(2) {
  [0]=>
  string(1) "0"
  [1]=>
  string(1) "a"
}

Online Test:
http://sandbox.onlinephpfunctions.com/code/e02f5d8795938be9f0fa6f4c17245a9bf8777404

A: Another one liner to remove empty ("" empty string) elements from your array.
$array = array_filter($array, function($a) {return $a !== "";});

Note: This code deliberately keeps null, 0 and false elements.

Or maybe you want to trim your array elements first:
$array = array_filter($array, function($a) {
    return trim($a) !== "";
});

Note: This code also removes null and false elements.

A: use array_filter function to remove empty values:
$linksArray = array_filter($linksArray);
print_r($linksArray);

A: Remove empty array elements
function removeEmptyElements(&$element)
{
    if (is_array($element)) {
        if ($key = key($element)) {
            $element[$key] = array_filter($element);
        }

        if (count($element) != count($element, COUNT_RECURSIVE)) {
            $element = array_filter(current($element), __FUNCTION__);
        }

        return $element;
    } else {
        return empty($element) ? false : $element;
    }
}

$data = array(
    'horarios' => array(),
    'grupos' => array(
        '1A' => array(
            'Juan' => array(
                'calificaciones' => array(
                    'Matematicas' => 8,
                    'Español' => 5,
                    'Ingles' => 9,
                ),
                'asistencias' => array(
                    'enero' => 20,
                    'febrero' => 10,
                    'marzo' => '',
                )
            ),
            'Damian' => array(
                'calificaciones' => array(
                    'Matematicas' => 10,
                    'Español' => '',
                    'Ingles' => 9,
                ),
                'asistencias' => array(
                    'enero' => 20,
                    'febrero' => '',
                    'marzo' => 5,
                )
            ),
        ),
        '1B' => array(
            'Mariana' => array(
                'calificaciones' => array(
                    'Matematicas' => null,
                    'Español' => 7,
                    'Ingles' => 9,
                ),
                'asistencias' => array(
                    'enero' => null,
                    'febrero' => 5,
                    'marzo' => 5,
                )
            ),
        ),
    )
);

$data = array_filter($data, 'removeEmptyElements');
var_dump($data);

¡it works!

A: As per your method, you can just catch those elements in an another array and use that one like follows,
foreach($linksArray as $link){
   if(!empty($link)){
      $new_arr[] = $link
   }
}

print_r($new_arr);

A: I think array_walk is much more suitable here
$linksArray = array('name', '        ', '  342', '0', 0.0, null, '', false);

array_walk($linksArray, function(&$v, $k) use (&$linksArray){
    $v = trim($v);
    if ($v == '')
        unset($linksArray[$k]);
});
print_r($linksArray);

Output:
Array
(
    [0] => name
    [2] => 342
    [3] => 0
    [4] => 0
)

*

*We made sure that empty values are removed even if the user adds more than one space

*We also trimmed empty spaces from the valid values

*Finally, only (null), (Boolean False) and ('') will be considered empty strings
As for False it's ok to remove it, because AFAIK the user can't submit boolean values.

A: As you're dealing with an array of strings, you can simply use array_filter(), which conveniently handles all this for you:
print_r(array_filter($linksArray));

Keep in mind that if no callback is supplied, all entries of array equal to FALSE (see converting to boolean) will be removed. So if you need to preserve elements that are i.e. exact string '0', you will need a custom callback:
// PHP 7.4 and later
print_r(array_filter($linksArray, fn($value) => !is_null($value) && $value !== ''));

// PHP 5.3 and later
print_r(array_filter($linksArray, function($value) { return !is_null($value) && $value !== ''; }));

// PHP < 5.3
print_r(array_filter($linksArray, create_function('$value', 'return $value !== "";')));

Note: If you need to reindex the array after removing the empty elements, use: $linksArray = array_values(array_filter($linksArray));

A: You can use array_filter to remove empty elements:
$emptyRemoved = array_filter($linksArray);

If you have (int) 0 in your array, you may use the following:
$emptyRemoved = remove_empty($linksArray);

function remove_empty($array) {
  return array_filter($array, '_remove_empty_internal');
}

function _remove_empty_internal($value) {
  return !empty($value) || $value === 0;
}

EDIT: Maybe your elements are not empty per se but contain one or more spaces... You can use the following before using array_filter
$trimmedArray = array_map('trim', $linksArray);

A: The most popular answer on this topic is absolutely INCORRECT.
Consider the following PHP script:
<?php
$arr = array('1', '', '2', '3', '0');
// Incorrect:
print_r(array_filter($arr));
// Correct:
print_r(array_filter($arr, 'strlen'));

Why is this?  Because a string containing a single '0' character also evaluates to boolean false, so even though it's not an empty string, it will still get filtered.  That would be a bug.
Passing the built-in strlen function as the filtering function will work, because it returns a non-zero integer for a non-empty string, and a zero integer for an empty string.  Non-zero integers always evaluate to true when converted to boolean, while zero integers always evaluate to false when converted to boolean.
So, the absolute, definitive, correct answer is:
$arr = array_filter($arr, 'strlen');

A: If you are working with a numerical array and need to re-index the array after removing empty elements, use the array_values function:
array_values(array_filter($array));

Also see: PHP reindex array?

A: The most voted answer is wrong or at least not completely true as the OP is talking about blank strings only. Here's a thorough explanation:
What does empty mean?
First of all, we must agree on what empty means. Do you mean to filter out:

*

*the empty strings only ("")?

*the strictly false values? ($element === false)

*the falsey values? (i.e. 0, 0.0, "", "0", NULL, array()...)

*the equivalent of PHP's empty() function?

How do you filter out the values
To filter out empty strings only:
$filtered = array_diff($originalArray, array(""));

To only filter out strictly false values, you must use a callback function:
$filtered = array_diff($originalArray, 'myCallback');
function myCallback($var) {
    return $var === false;
}

The callback is also useful for any combination in which you want to filter out the "falsey" values, except some. (For example, filter every null and false, etc, leaving only 0):
$filtered = array_filter($originalArray, 'myCallback');
function myCallback($var) {
    return ($var === 0 || $var === '0');
}

Third and fourth case are (for our purposes at last) equivalent, and for that all you have to use is the default:
$filtered = array_filter($originalArray);

A: $a = array(1, '', '', '', 2, '', 3, 4);
$b = array_values(array_filter($a));

print_r($b)

A: For multidimensional array
$data = array_map('array_filter', $data);
$data = array_filter($data);

A: $linksArray = array_filter($linksArray);

"If no callback is supplied, all entries of input equal to FALSE will be removed." -- http://php.net/manual/en/function.array-filter.php

A: I had to do this in order to keep an array value of (string) 0
$url = array_filter($data, function ($value) {
  return (!empty($value) || $value === 0 || $value==='0');
});

A: With these types of things, it's much better to be explicit about what you want and do not want.
It will help the next guy to not get caught by surprise at the behaviour of array_filter() without a callback. For example, I ended up on this question because I forgot if array_filter() removes NULL or not. I wasted time when I could have just used the solution below and had my answer.
Also, the logic is language angnostic in the sense that the code can be copied into another language without having to under stand the behaviour of a php function like array_filter when no callback is passed.
In my solution, it is clear at glance as to what is happening. Remove a conditional to keep something or add a new condition to filter additional values.
Disregard the actual use of array_filter() since I am just passing it a custom callback - you could go ahead and extract that out to its own function if you wanted. I am just using it as sugar for a foreach loop.
<?php

$xs = [0, 1, 2, 3, "0", "", false, null];

$xs = array_filter($xs, function($x) {
    if ($x === null) { return false; }
    if ($x === false) { return false; }
    if ($x === "") { return false; }
    if ($x === "0") { return false; }
    return true;
});

$xs = array_values($xs); // reindex array

echo "<pre>";
var_export($xs);

Another benefit of this approach is that you can break apart the filtering predicates into an abstract function that filters a single value per array and build up to a composable solution.
See this example and the inline comments for the output.
<?php

/**
 * @param string $valueToFilter
 *
 * @return \Closure A function that expects a 1d array and returns an array
 *                  filtered of values matching $valueToFilter.
 */
function filterValue($valueToFilter)
{
    return function($xs) use ($valueToFilter) {
        return array_filter($xs, function($x) use ($valueToFilter) {
            return $x !== $valueToFilter;
        });
    };
}

// partially applied functions that each expect a 1d array of values
$filterNull = filterValue(null);
$filterFalse = filterValue(false);
$filterZeroString = filterValue("0");
$filterEmptyString = filterValue("");

$xs = [0, 1, 2, 3, null, false, "0", ""];

$xs = $filterNull($xs);        //=> [0, 1, 2, 3, false, "0", ""]
$xs = $filterFalse($xs);       //=> [0, 1, 2, 3, "0", ""]
$xs = $filterZeroString($xs);  //=> [0, 1, 2, 3, ""]
$xs = $filterEmptyString($xs); //=> [0, 1, 2, 3]

echo "<pre>";
var_export($xs); //=> [0, 1, 2, 3]

Now you can dynamically create a function called filterer() using pipe() that will apply these partially applied functions for you.
<?php

/**
 * Supply between 1..n functions each with an arity of 1 (that is, accepts
 * one and only one argument). Versions prior to php 5.6 do not have the
 * variadic operator `...` and as such require the use of `func_get_args()` to
 * obtain the comma-delimited list of expressions provided via the argument
 * list on function call.
 *
 * Example - Call the function `pipe()` like:
 *
 *   pipe ($addOne, $multiplyByTwo);
 *
 * @return closure
 */
function pipe()
{
    $functions = func_get_args(); // an array of callable functions [$addOne, $multiplyByTwo]
    return function ($initialAccumulator) use ($functions) { // return a function with an arity of 1
        return array_reduce( // chain the supplied `$arg` value through each function in the list of functions
            $functions, // an array of functions to reduce over the supplied `$arg` value
            function ($accumulator, $currFn) { // the reducer (a reducing function)
                return $currFn($accumulator);
            },
            $initialAccumulator
        );
    };
}

/**
 * @param string $valueToFilter
 *
 * @return \Closure A function that expects a 1d array and returns an array
 *                  filtered of values matching $valueToFilter.
 */
function filterValue($valueToFilter)
{
    return function($xs) use ($valueToFilter) {
        return array_filter($xs, function($x) use ($valueToFilter) {
            return $x !== $valueToFilter;
        });
    };
}

$filterer = pipe(
    filterValue(null),
    filterValue(false),
    filterValue("0"),
    filterValue("")
);

$xs = [0, 1, 2, 3, null, false, "0", ""];
$xs = $filterer($xs);

echo "<pre>";
var_export($xs); //=> [0, 1, 2, 3]

A: try this **
**Example
$or = array(
        'PersonalInformation.first_name' => $this->request->data['User']['first_name'],
        'PersonalInformation.last_name' => $this->request->data['User']['last_name'],
        'PersonalInformation.primary_phone' => $this->request->data['User']['primary_phone'],
        'PersonalInformation.dob' => $this->request->data['User']['dob'],
        'User.email' => $this->request->data['User']['email'],
    );

 $or = array_filter($or);

    $condition = array(
        'User.role' => array('U', 'P'),
        'User.user_status' => array('active', 'lead', 'inactive'),
        'OR' => $or
    );


Q: Connecting to a VPN, setting up Recently I got an online job and I need to connect to their VPN. I got it done on Windows laptop by installing Shrew Soft VPN client (I know it's old, it's what they told me to use). Going to my Ubuntu Desktop, I tried using the settings software for VPN but now I'm stuck.
On Windows, I needed to input the Server Address (of course), the group name, and the pre-shared key. I do not see where I can put anything but the server address in either OpenVPN or PPTP options in Ubuntu. I don't have a certificate yet, but on Windows I didn't need it immediately. (Says I must get a key like a week later.)
To try to bypass this, I tried installing Shrew VPN onto Ubuntu. I downloaded the .tgz file from their website and used the tar command to unpack it, now I have no idea what to do with the file to run the application.
I need help either figuring out how to run the file I just un-packed or working with Ubuntu's VPN services to connect to this VPN.


Q: Do...while is not working in input verification So I'm trying to do an input verification for my program in java, and I'm trying to do that in this setter:
  public void setClientName(String clientName) {
        boolean valid;
        do{
            valid = false;
            try{
                 if(clientName.matches("[a-zA-Z]+")){
                    this.clientName = clientName;
                 }else{
                     throw new IllegalArgumentException("Invalid client name");
                 }
            }catch(Exception e){
                System.out.println("Invalid name");
                valid = true;
            }
        }while(!valid);
    }

But when I call it and put a wrong name, the do...while does not work and the program just continue
Here's where I call it
  public void openAccount(int i){
        nCartao = 2021120040 + i;
        System.out.println("Account Number : " + (nCartao));
        System.out.println("Client Name :");

        setClientName(sc.next()); // I CALL IT HERE

        System.out.println("Client Age : ");
        age = sc.nextInt();
        System.out.println("Balance :");
        balance = sc.nextInt();
    }

What am I doing wrong?

A: Maybe that's because in your catch you are stating that valid is true when it should be false to repeat the block.


Q: Deedle Frame From Database, What is the Schema? I am new to Deedle, and in documentation I cant find how to solve my problem.
I bind an SQL Table to a Deedle Frame using the following code:
namespace teste

open FSharp.Data.Sql
open Deedle
open System.Linq

module DatabaseService =

    [<Literal>]
    let connectionString = "Data Source=*********;Initial Catalog=*******;Persist Security Info=True;User ID=sa;Password=****";

    type bd = SqlDataProvider<
                ConnectionString = connectionString,
                DatabaseVendor = Common.DatabaseProviderTypes.MSSQLSERVER >

    type Database() =

        static member contextDbo() =
            bd.GetDataContext().Dbo

        static member acAgregations() =
            Database.contextDbo().AcAgregations |> Frame.ofRecords

        static member acBusyHourDefinition() =
            Database.contextDbo().AcBusyHourDefinition
            |> Frame.ofRecords "alternative_reference_table_scan", "formula"]

        static member acBusyHourDefinitionFilterByTimeAgregationTipe(value:int) =
            Database.acBusyHourDefinition()
            |> Frame.getRows

These things are working properly becuse I can't understand the Data Frame Schema, for my surprise, this is not a representation of the table.
My question is:
how can I access my database elements by Rows instead of Columns (columns is the Deedle Default)? I Thied what is showed in documentation, but unfortunatelly, the columns names are not recognized, as is in the CSV example in Deedle Website.

A: With Frame.ofRecords you can extract the table into a dataframe and then operate on its rows or columns. In this case I have a very simple table. This is for SQL Server but I assume MySQL will work the same. If you provide more details in your question the solution can narrowed down.
This is the table, indexed by ID, which is Int64:

You can work with the rows or the columns:
#if INTERACTIVE
#load @"..\..\FSLAB\packages\FsLab\FsLab.fsx"
#r "System.Data.Linq.dll"
#r "FSharp.Data.TypeProviders.dll"
#endif

//open FSharp.Data
//open System.Data.Linq
open Microsoft.FSharp.Data.TypeProviders
open Deedle

[<Literal>]
let connectionString1 = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\userName\Documents\tes.sdf.mdf"

type dbSchema = SqlDataConnection<connectionString1>
let dbx = dbSchema.GetDataContext()

let table1 = dbx.Table_1

query { for row in table1 do
        select row} |> Seq.takeWhile (fun x -> x.ID < 10L) |> Seq.toList
// check if we can connect to the DB.

let df = table1 |> Frame.ofRecords // pull the table into a df
let df = df.IndexRows<System.Int64>("ID") // if you need an index
df.GetRows(2L) // Get the second row, but this can be any kind of index/key
df.["Number"].GetSlice(Some 2L, Some 5L) // get  the 2nd to 5th row from the Number column

Will get you the following output:
val it : Series<System.Int64,float> =
2 -> 2

>
val it : Series<System.Int64,float> =
2 -> 2
3 -> 3
4 -> 4
5 -> 5

Depending on what you're trying to do Selecting Specific Rows in Deedle might also work.
Edit
From your comment you appear to be working with some large table. Depending on how much memory you have and how large the table you still might be able to load it. If not these are some of things you can do in increasing complexity:

*

*Use a query { } expression like above to narrow the dataset on the database server and convert just part of the result into a dataframe. You can do quite complex transformations so you might not even need the dataframe in the end. This is basically Linq2Sql.

*Use lazy loading in Deedle. This works with series so you can get a few series and reassemble a dataframe.

*Use Big Deedle which is designed for this sort of thing.


Q: Measure Theory - Modes of convergence of $f_n(x) = (1/x)(\sin(x))^n$ Question: Consider the sequence of functions $f_n(x) = \frac{1}{x}(\sin(x))^n$ on $(0, \infty)$, equipped with the Borel σ−algebra and Lebesgue measure $λ$. Does it hold that $f_n \to 0$ as $n \to \infty$ for each of the following types of convergence:
a) pointwise?
b) pointwise a.e?
c) in measure?
d) in $L^p$ for $1 < p < \infty$?
e) in $L^\infty$?
My attempt:
a) is False since for for example the x for which $\sin(x)=1$, then $f_n$ does not converge to $0$.
b) is True because the reason a) was False is that it fails to converge on only a set of measure $0$ since it was countable.
I'm struggling with c), d), and e). My thought on c) was to use that $\sin(x)/x$ is bounded by $x$, and then it would mean that $\sin(x)^{n-1}$ would go to zero a.e. so it converges in measure, but I don't know if that is correct to think like that. On d) and e) I have no idea.
Any suggestions for how to solve c),d), and e)?

A: Consider $\mu \{x: |f_n(x)| >\epsilon\}$. Note that  $|f_n(x)| >\epsilon$ implies $\frac 1  {|x|} >\epsilon$. So  $\mu \{x: |f_n(x)| >\epsilon\} \leq \mu \{|x|\leq \frac 1 {\epsilon}: f_n(x) >\epsilon\}$. On a set of finite measure a.e. convergence implies convergence in measure so $\mu \{|x|\leq \frac 1 {\epsilon}: |f_n(x)| >\epsilon\} \to 0$ proving that $(f_n)$ does converge in measure to $0$.
It is is easy to see that $(f_n)$ does not converge in $L^{\infty}$: If it does then $|f_n(x)|<\epsilon$ a.e. as soon as $n$ exceeds some $m$. By continuity we must have $|f_{m+1}(x)|<\epsilon$ for all $x$. But there exists a  point $x \in (0,\frac   1 {\epsilon})$ with $\sin x =1$ provided $\epsilon <\frac 2 {\pi}$. But then $|f_{m+1}(x)|=\frac 1 x >\epsilon$, a contradiction
$(f_n)$ does converge in $L^{p}$ to $0$ for $1<p<\infty$. This is an easy consequence of DCT since $|f_n(x)|^{p} \leq \frac 1 {|x|^{p}}$ for $|x|>1$. [For $|x|<1$, $|f_n(x)| \leq \frac {|\sin x|} {|x|}\leq 1$].


Q: How to install Netbeans 8.0.2 on ubuntu 14.x I have netbeans downloaded from the netbeans.org site.
This is the file name → netbeans-8.0.2-linux.sh
I dont know how to install it on ubuntu 14.10
Is there any one can help me install netbeans on ubuntu?

A: Open the Terminal and considering the file is in Downloads directory then do

chmod +x ~/Downloads/netbeans-8.0.2-linux.sh

After that

cd ~/Downloads && ./netbeans-8.0.2-linux.sh

And that will bring up the Installation Window.
To Uninstall run

./uninstall.sh

in the install directory

A: Here is how I handled it, after reading this thread;
I tried first to check the file permissions, through the graphical interface, by opening

'home', 'download',

i.e. the location where I put netbeans-8.0.2-linux.sh;
seeing the button for changing the file to executable was unchecked, I checked it;
I opened a terminal, changed to the directory where netbeans was, and typed:

'netbeans-8.0.2-linux.sh'

only to be greeted by a 'command not found'...
so I went over the web to check the reason...
and found this thread;
by reading it, I have a better idea of what is going on;
so, I tried, as a last resort, to issue the command like that:

sudo bash netbeans-8.0.2-linux.sh

...and it went on, smoothly, installing everything.
I just want to add that it didn't really need my password, strange enough;
but it looks it needed to be prefixed with 'bash', otherwise it didn't recognize it, even if the permissions were all there, I checked with
'ls -l', and it was executable for all :user, groups, and others...
I wonder if I have something out of order, or simply configured in some special way, in my config files, maybe in the proc directory...
but now I have another problem:
I started a C project, just to try how netbeans worked, and it did open, create really, a project skeleton;
but it does not find the standard library headers, 'stdio.h' and s'tdlib.h'...
Because, now, this is a separate issue, I will not expand it here; I should start another thread on it.
Anyway, thank so much for the help found in this page :)
I am new to linux, and trying to learn it.
Any clarification would be very welcome.
Ubuntu 14.10 amd turion x2 64 advent 9515 2GB ram


Q: Custom cell in list in Flash AS3 I am no expert in Flash, and I need some quick help here, without needing to learn everything from scratch.
Short story, I have to make a list where each cell contains an image, two labels, and a button.
List/Cell example:

img  - label - label - button

img  - label - label - button

As a Java-programmer, I have tried to quicly learn the syntax and visualness of Flash and AS3, but with no luck so far.
I have fairly understood the basics of movie clips etc.
I saw a tutorial on how to add a list, and add some text to it. So I dragged in a list, and in the code went list.addItem({label:"hello"}); , and that worked ofc. So i thought if I double-clicked the MC of the list, i would get to tweak some things. In there I have been wandering around different halls of cell-renderers etc.
I have now come to the point that I entered the CellRenderer_skinUp or something, and customized it to my liking. When this was done, I expected i could use list.addItem(); and get an empty "version" of my cell, with the img, labels and the button. But AS3 expects an input in addItem. From my object-oriented view, I am thinking that i have to create an object of the cell i have made, but i have no luck reaching it.. I tried to go
var test:CellRenderer = list.listItem;
list.addItem(test);
..But with no luck.
This is just for funsies, but I really want to make this work, however not so much that I am willing to read up on ALOT of Flash and AS3. I felt that I was closing in on the prize, but the compiler expected a semicolon after the variable (list.addItem({test:something});).
Note: If possible, I do NOT want this:
list.addItem({image:"src",label:"text",label"text",button:"text"});
Well.. It actually is what I want, but I would really like to custom-draw everything.
Does anyone get what I am trying to do, and has any answers for me? Am I approaching this the wrong way? I have searched the interwebs for custom list-cells, but with no luck.
Please, any guiding here is appreciated!
Sti

A: You could use a Datagrid as well, with each column pointing to the appropriate part of the data source (possibly even the same field, depending on what you're doing). You can then just use the ImageCell as the renderer for the second and third colums.
I think you're just not understanding that Adobe, in the own woolly-headed little way, is separating the Model from the View on your behalf. You hand the Model to the View and then get out of the way. The extent of what you can/should change is just telling it what renderer to pop your data into.
In fact, the fl.controls don't give you much control at all about how they work--I wouldn't go down the road of trying to create a custom itemRenderer with any signifcant functionality for them if you don't fully understand how the Display List works and if you're not comfortable digging around in the debugger and ferreting out all kinds of undocumented information.
For more details (to the extent anyone knows anything about how these work), see
http://www.adobe.com/devnet/flash/quickstart/datagrid_pt1.html
http://www.adobe.com/devnet/flash/quickstart/datagrid_pt2.htmlhttp://www.adobe.com/devnet/flash/quickstart/datagrid_pt3.html
http://www.adobe.com/devnet/flash/quickstart/tilelist_component_as3.html
Do you have the option to use the Flex Framework instead of pure Flash? It makes this kind of extension much more satisfying. It's aimed more at application developers, whereas Adobe sees Flash users more as designers.


Q: Fragment Missing From Product I created a localization fragment for one of our projects which works nicely when started from the IDE, but not at all when started from the exported product.
The fragment itself only really has two files, a MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: L10N Fragment
Bundle-SymbolicName: org.acme.module.nl_xx;singleton:=true
Bundle-Version: 3.0.6.qualifier
Bundle-Vendor: ACME
Fragment-Host: org.acme.module;bundle-version="[1.0.0,2.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-11

...and a properties file messages_de_de_xx.properties:
Special = Something

The product is started with -nl de_DE_XX and -Djava.language=de -Djava.country=DE -Djava.variant=XX. As noted, it works from Eclipse, but not from the finished EXE.
Things I tried to debug / fix:

*

*made sure the exported product contains the fragment

*made sure the build.properties / fragment JAR contains the above two files

*played around with the country and variant (toggled upper and lower case)

*cleared the OSGi instance area (i.e. the application preferences)

*made sure the fragment is resolved using the OSGi console

*tested it with a messages file for en_UK_XX (which is based on the English localization instead of the German one)

*made sure that the files configuration\org.eclipse.equinox.simpleconfigurator\bundles.info and artifacts.xml contain something that looks plausible for the fragment

Nothing worked, so I'm out of ideas.
What could be the problem? What can I do to debug the application?

A: This is an incredible stupid problem. The messages file is supposed to have the name messages_de_DE_XX.properties (note that the last two segments are in upper case).
My guess is it works when started from the IDE because Eclipse uses the filesystem and hence the OS standard, which is "ignore casing" for Windows.
When started from the finished product however the files are in JARs, where casing is important.


Q: Display or get the HTTP header attributes in Rails 4 I have an application developed in Rails and I am trying to see the attributes in the HTTP header.
Is there any way to read these attributes? Where are they stored?
Someone mentioned request.headers. Is this correct? I am not able to see any attributes inside this array.

A: This code solved my question request.env["HTTP_MY_HEADER"]. The trick was that I had to prefix my header's name with HTTP

A: I've noticed in Rails 5 they now expect headers to be spelled like this in the request:
Access-Token
Before they are transformed into:
HTTP_ACCESS_TOKEN
In Rails. Doing ACCESS_TOKEN will no longer work.

A: request.headers does not return a hash, but an instance of ActionDispatch::Http::Headers, which is a wrapper around rack env.
ActionDispatch::Http::Headers implements many methods like [] and []= which make it behave like a hash, but it doesn't override the default inspect, hence you can't see the key-value pairs by just p or pp it.
You can, however, see the request headers in the rack env:
pp request.headers.env.select{|k, _| k =~ /^HTTP_/}

Remember that the request headers in rack env are the upcased, underscored and HTTP_ prefixed version of the original http request headers.
UPDATE
Actually there are a finite set of request headers that are not prefixed HTTP_. These (capitalized and underscored) header names are stored in ActionDispatch::Http::Headers::CGI_VARIABLES. I list them below:
    AUTH_TYPE
    CONTENT_LENGTH
    CONTENT_TYPE
    GATEWAY_INTERFACE
    HTTPS
    PATH_INFO
    PATH_TRANSLATED
    QUERY_STRING
    REMOTE_ADDR
    REMOTE_HOST
    REMOTE_IDENT
    REMOTE_USER
    REQUEST_METHOD
    SCRIPT_NAME
    SERVER_NAME
    SERVER_PORT
    SERVER_PROTOCOL
    SERVER_SOFTWARE

So the full version of listing request headers would be
pp request.headers.env.select{|k, _| k.in?(ActionDispatch::Http::Headers::CGI_VARIABLES) || k =~ /^HTTP_/}

A: You can see hash of actual http headers using @_headers in controller.


Q: X11 Forwarding with my Entire Screen I am able to ssh to my Linux computer which is on the same network as my Mac. From the Linux machine, I can ssh to my Macbook.
I am currently at work and I want to forward my Mac's display to the Windows machine that I am currently on (using Putty and Xming). I am able to run "Xeyes &" so I know that the X11 forwarding is working correctly.
How can I forward my entire screen, preferably without having to setup VNC? And remember, I only have access to the command line.

A: This isn't how X11 works on the Mac currently (or at any time in the past).
The native Mac window manager uses Quartz 2D and Core Graphics to accomplish the rendering and composting of windows and icons on the Mac screen.
X11 writes into that space as a consumer - not as the end-all provider of drawing services so it can't forward things it doesn't get to see.
You will want to set up VNC sharing (which is the native Mac screen sharing technology) if you can't get by with just forwarding the X11 graphics.

A: You can run a VNC session through ssh.
Connect to the remote system from Terminal:
ssh -Y -g -l username -C -L 5901:localhost:5901 remote_hostname

Start VNC server on the remote system. The above assumes your server starts on display port 1.
Launch a VNC viewer on your local system and enter the connection information. In this example you would use 'localhost' for 'Host', and '5901' for your port.


Q: How to chabge GDM Login theme in ubuntu 12.04 lts I have ubuntu 12.04 lts and I changed my login screen to GDM by typing
sudo apt-get install gdm

how do I change the theme in ubuntu 12.04? I downloaded a theme using gnome-look.org. Where do I extract the theme and how do I apply it?

A: Although this will change gdm by mdm this works and has been tested on 12.04.
How can I replace LightDM with MDM?


Q: Finding files in list using bash array loop I'm trying to write a script that reads a file with filenames, and outputs whether or not those files were found in a directory.
Logically I'm thinking it goes like this:
$filelist = prompt for file with filenames
$directory = prompt for directory path where find command is performed

new Array[] = read $filelist line by line

for i, i > numberoflines, i++
     if find Array[i] in $directory is false
        echo "$i not found"
export to result.txt

I've been having a hard time getting Bash to do this, any ideas?

A: First, I would just assume that all the file-names are supplied on standard input. E.g., if the file names.txt contains the file-names and check.sh is the script, you can invoke it like
cat names.txt | ./script.sh

to obtain the desired behaviour (i.e., using the file-names from names.txt).
Second, inside script.sh you can loop as follows over all lines of the standard input
while read line
do
  ... # do your checks on $line here
done

Edit: I adapted my answer to use standard input instead of command line arguments, due to the problem indicated by @rici.

A: while read dirname
do
  echo $dirname >> result.txt
  while read filename
  do
    find $dirname -type f -name $filename >> result.txt
  done <filenames.txt
done <dirnames.txt


Q: Force browser to display ISO-8859-1 without interpreting as Windows-1252 Historically, a lot of web pages advertising themselves as being in the ISO-8859-1 (Latin-1) encoding actually contained content in the Windows-1252 encoding (which is a strict superset of Latin-1).
This was enough of a problem that browsers updated their behaviour to treat all Latin-1 text as if it were Windows-1252. This behaviour was then rationalised into the HTML5 [draft] standard.
I'm writing a set of pages on which I want to show the difference between the two encodings, however this seems to be impossible because my Latin-1 page is never actually treated as Latin-1. Is there any way, in any browser, that I can actually force the page encoding to be respected and display the demo?

A: I’m afraid there is no direct way. I thought Opera once had an option for this, and its current version has an option (via opera:config) to force a specific encoding, overriding HTTP headers and all, but even there, iso-8859-1 actually means windows-1252. I checked Opera versions 5 and 9 too, no luck.
But using the current version of Opera (12.02), you can set the encoding via View → Encoding, and in the “Western” set (where iso-8859-1 means windows-1252 as usual), selecting iso-8859-15 causes the range 130–159 (decimal) of bytes to be effectively ignored in display, not shown as per windows-1252. So this more or less means treating the data as genuinely iso-8859-1 – except of course that the few graphic characters where iso-8859-1 and iso-8859-15 differ, the latter is used.
Technically, those bytes represent C1 Controls in iso-8859-1, and in the mode described above, Opera actually treats them that way. They are disallowed in HTML but normally just ignored by browsers.


Q: Show the density is an objective quantity I am studying the Lagrangian and Eulerian representations of quantities within the scope of fluid dynamics.
At some point I am asked to show that the density is an objective quantity, which for a scalar variable was defined as
$$\rho(x, t) = \rho'(x',t) $$
Where $x' = Q(t)x + x_0$ represents the change of reference frame, with $Q(t) \in SO(3) $.
We did a couple of exercises on this but I don't really understand what is that I know. I can't even seem to define $\rho$ in a way that opens me up for algebraic manipulations.
On a side note, in a previous exercise I showed that
$$\rho(X, t) = \frac{\rho(X, 0)}{J(X, t)}$$
where $J $ is the determinant of the deformation gradient and $X $ are the lagrangian coordinates. I tried using this but failed to do it.

A: As it says here:
https://books.google.pt/books?id=v_aUAwAAQBAJ&pg=PA200&lpg=PA200&dq=why+do+we+postulate+density+to+be+objective&source=bl&ots=oDDTL7L9jE&sig=MvYZMXYRrZN4KqMhKiIt-rQ3PgQ&hl=pt-PT&sa=X&ved=2ahUKEwjZj-f3z_zeAhVlBMAKHQMkDDoQ6AEwAHoECBMQAQ#v=onepage&q&f=true
A zeroth-order tensor is just a real number, so objectivity simply means that this number is the same in all frames of reference.
Since density is not purely kinematic, I think we have to look at the underlying physics.
In here it says the reason we usually assume that is because of Galilean Invariance of the balance laws and physical experiences:
https://books.google.pt/books?id=sOdGCwAAQBAJ&pg=PA209&lpg=PA209&dq=why+do+we+postulate+density+to+be+objective&source=bl&ots=nLoVFw2--X&sig=Fzd7qnutvrW1IW601Ysyf9ridkI&hl=pt-PT&sa=X&ved=2ahUKEwjZj-f3z_zeAhVlBMAKHQMkDDoQ6AEwAXoECBIQAQ#v=onepage&q=why%20do%20we%20postulate%20density%20to%20be%20objective&f=false
Not sure if I helped.


Q: Cross browser video autoplay loop I have a copy of a mp4 video which I want to show on my website and I want to know how is it possible with javascript to autoplay and loop for ever the video.
I want to make it compatible with all browsers.
I want to load the video on load of the page with js
Thank you.

A: <video autoplay loop>
  <source src="movie.mp4" type="video/mp4" />
  <source src="movie.ogg" type="video/ogg" />
</video>

You mean this?

A: You’ll need to mute the video (adding the muted attribute on the <video> tag) as videos with sound don’t autoplay in all browsers. Then also add the attributes autoplay and playsinline. Also you can use the videoEnd event and call play() to ensure it loops.


Q: Is the quotient of a holomorphic group action a complex manifold? Let $M$ be a complex manifold on which the group $G$ acts properly  and holomorphic. Is $M/G$ then a complex manifold?

My attempt:
We need charts for $M/G$. For any $m \in M$ we take $U\subset M$
  small enough such that the restriction of the quotient map $q$ is a
  homeomorphism. (Is this possible because of proper discontinuity?)
  We have a chart $\phi_U: U \to \mathbb C^n$. As $q|_U$ is a
  homeomorphism, this gives us a chart $\phi_U \circ (q|_U)^{-1}:
 q(U)\to \mathbb C^n$.
We need to check that the functions $[\phi_V \circ (q|_V)^{-1}] \circ
 [\phi_U \circ (q|_U)^{-1}]^{-1}: \mathbb C^n \to \mathbb C^n$ are
  holomorphic. But this is the case if $(q|_U)^{-1} \circ (q|_U)$ is
  holomorphic. But this is simply the translation by a group element
  which is holomorphic as  we assumed the group action to be
  holomorphic.

Is this right and is this enough?
Edit: Actually I want $G$ to also be discrete and act freely.

A: You’re right but the idea is more general.
When your action is properly discontinuous you get that $\pi: M\to M/G$ is a covering map that is open so you can define the local charts in your natural way and you get that $M/G$ is a local Euclidean complex space;
In general $M/G$ is not an Hausdorff space;
$M/G$ will be second countable because $\pi$ is surjective and open and $X$ is second countable;
It is possible built an olomorphic structure on $M/G$? I think that it is a really difficult question because in general your composition
$q|_V^{-1}\circ q|_U$ is not simply a moltiplication with respect a fixed $g\in G$


Q: JSON_QUERY unable to handle NULL I have a table. Few columns are of String, Integer type. And few are JSON type. I am writing a query to form each row as a json object. I have issues with JSON_QUERY(jsondataColumnName). If the column is populated NULL JSON_QUERY fails.
I have already written query below.
select
(
    SELECT     [customerReferenceNumber] as customerReferenceNumber
              ,[customerType] as customerType
              ,[personReferenceNumber] as personReferenceNumber
              ,[organisationReferenceNumber] as organisationReferenceNumber
              ,json_query(isnull(product,'')) as product
              ,json_query(isnull([address],'')) as address

  FROM [dbo].[customer]
  FOR JSON PATH, WITHOUT_ARRAY_WRAPPER) AS customer
from [dbo].[customer] P

Msg 13609, Level 16, State 1, Line 2
  JSON text is not properly formatted. Unexpected character '.' is found at position 0.

A: By default, for JSON don't work with NULL VALUES. Use INCLUDE_NULL_VALUES to handle.
As Example:  JSON PATH, WITHOUT_ARRAY_WRAPPER, INCLUDE_NULL_VALUES) AS customer
As reference:
 https://learn.microsoft.com/en-us/sql/relational-databases/json/include-null-values-in-json-include-null-values-option?view=sql-server-ver15


Q: How to put Messsenger on top of full screen video? Just as the title says, how can I use messenger or any chat client while i'm watching video in browser with full screen? I can use gtalk when watching youtube video in full screen in Windows, but can't figure out how to put chat window on full screen video using alt-tab.

A: In Ubuntu just Right-Click on the Title Bar of the Chat Client window and select the option "Always On Top". The Window will now remain on Top of all other Windows so you can Fullscreen a Video and still continue to chat.
EDIT: Oh I see. The problem here is Flash. Flash puts itself on top of everything else no matter what. The only way around that is to not use the Flash Player's Fullscreen button but instead zoom in on the player while it's still in the browser window. In Firefox CTRL+- Zooms Out, CTRL+ + Zooms In, and CTRL+0 Returns to Default Zoom.


Q: I want to display PDFs and images in Firebase Storage I would like to use FirebaeStorage to display PDFs and images.
↓The code below is the code to display the file list
（I was able to get the data from Firebase and display the List.）

class Gakubu extends StatefulWidget {
  const Gakubu({Key? key}) : super(key: key);

  @override
  State<Gakubu> createState() => _GakubuState();
}

class _GakubuState extends State<Gakubu> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('学部'),
      ),
      body: Container(
        child: ListView(
          children: [
            Card(
              child: ListTile(
                leading: Icon(Icons.folder),
                trailing: Icon(Icons.chevron_right),
                title: Text('工学部'),
                onTap: () =>
                    Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) => kougaku(),
                    )
                    ),
              ),
            ),
            Card(
              child: ListTile(
                  leading: Icon(Icons.folder),
                  trailing: Icon(Icons.chevron_right),
                  title: Text('情報理工学部'),
                onTap: () =>
                    Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) => zyouhourikou(),
                    )
                    ),              ),
            ),
            Card(
              child: ListTile(
                leading: Icon(Icons.folder),
                trailing: Icon(Icons.chevron_right),
                title: Text('教育学部'),
                onTap: () =>
                    Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) => kyouiku(),
                    )
                    ),
              ),
            ),
            Card(
              child: ListTile(
                leading: Icon(Icons.folder),
                trailing: Icon(Icons.chevron_right),
                title: Text('獣医学部'),
                onTap: () =>
                    Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) => zyuui(),
                    )
                    ),
              ),
            ),
            Card(
              child: ListTile(
                leading: Icon(Icons.folder),
                trailing: Icon(Icons.chevron_right),
                title: Text('理学部'),
                onTap: () =>
                    Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) => rigaku(),
                    )
                    ),
              ),
            ),
            Card(
              child: ListTile(
                leading: Icon(Icons.folder),
                trailing: Icon(Icons.chevron_right),
                title: Text('生命科学部'),
                onTap: () =>
                    Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) => seimei(),
                    )
                    ),
              ),
            ),
            Card(
              child: ListTile(
                leading: Icon(Icons.folder),
                trailing: Icon(Icons.chevron_right),
                title: Text('生物地球学部'),
                onTap: () =>
                    Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) => seibutu(),
                    )
                    ),
              ),
            ),
            Card(
              child: ListTile(
                leading: Icon(Icons.folder),
                trailing: Icon(Icons.chevron_right),
                title: Text('経営学部'),
                onTap: () =>
                    Navigator.of(context).push(MaterialPageRoute(
                      builder: (context) => keiei(),
                    )
                    ),
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          //ポップアップメニュー実装
          showModalBottomSheet(
            //モーダルの背景の色、透過
              backgroundColor: Colors.transparent,
              //ドラッグ可能にする（高さもハーフサイズからフルサイズになる様子）
              isScrollControlled: true,
              context: context,
              builder: (BuildContext context) {
                return Container(
                  margin: EdgeInsets.only(top: 150),
                  decoration: BoxDecoration(
                    //モーダル自体の色
                    color: Colors.white,
                    //角丸にする
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(20),
                      topRight: Radius.circular(20),
                    ),
                  ),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      Text(
                        '過去問をアップロード',
                        style: TextStyle(
                          fontSize: 25,
                          color: Colors.black,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.all(8.0), //マージン
                        child: SizedBox(
                          width: double.infinity,
                          height: 50,
                          child: ElevatedButton.icon(
                            icon: Icon(Icons.photo_library),
                            label: Text(
                              'アルバムから選択',
                              textAlign: TextAlign.left,
                            ),
                            onPressed: () {},
                          ),
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.all(8.0), //マージン
                        child: SizedBox(
                          width: double.infinity,
                          height: 50,
                          child: ElevatedButton.icon(
                            icon: Icon(Icons.camera),
                            label: Text(
                              '写真を撮る',
                              textAlign: TextAlign.left,
                            ),
                            onPressed: () {},
                          ),
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.all(8.0), //マージン
                        child: SizedBox(
                          width: double.infinity,
                          height: 50,
                          child: ElevatedButton.icon(
                              icon: Icon(Icons.folder),
                              label: Text(
                                '複数以上のファイル',
                                textAlign: TextAlign.left,
                              ),
                              onPressed: () => launch(
                                  'https://docs.google.com/forms/d/e/1FAIpQLSda45WF5uVd9mRFs_4nPCiM6bxFqpUKZSApYFWUVlAVtDlg_g/viewform?usp=sf_link')),
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.all(8.0), //マージン
                        child: SizedBox(
                          width: double.infinity,
                          height: 50,
                          child: ElevatedButton.icon(
                              icon: Icon(Icons.link),
                              label: Text(
                                'ドライブなどのURL',
                                textAlign: TextAlign.left,
                              ),
                              onPressed: () => launch(
                                  'https://docs.google.com/forms/d/e/1FAIpQLSdEIS3eOynTihQ3AEk0zrp7mSpmcfqpEGxTOUIDp6Mzi19jqA/viewform?usp=sf_link')),
                        ),
                      ),
                      Text(
                        'アップロードあざます！',
                        style: TextStyle(
                          fontSize: 20,
                          color: Colors.black,
                        ),
                      ),
                    ],
                  ),
                );
              });
        },
        child: const Icon(Icons.upload_rounded),
      )
      ,
    );
  }
}

This code is for displaying images and PDFs. (This code can only display PDFs.)

class ImagePage extends StatelessWidget {
  final FirebaseFile file;

  const ImagePage({
    Key? key,
    required this.file,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final isImage = ['.jpeg', '.jpg', '.png'].any(file.name.contains);
    final isPdf = ['.pdf'].any(file.name.contains);

    return Scaffold(
      appBar: AppBar(
        title: Text(file.name),
        centerTitle: true,
      ),
      body: SfPdfViewer.network(
        file.url
      ),
    );

  }
  }

 final isImage = ['.jpeg', '.jpg', '.png'].any(file.name.contains);
    final isPdf = ['.pdf'].any(file.name.contains);

Here I would like to have the process change depending on the file extension.
for example
sfpdfview for PDF
imageview for image
Any ideas?


Q: ImportError: No module named django.core.wsgi for wsgi server setting I am setting with djano and uwsgi
$uwsgi --ini uwsgi.ini
My Django root is here /var/www/html/myapp/current
It must be  quite simple setting however I am not sure the yet.
I have these two files
/var/www/html/myapp/current/myapp/settings.py
/var/www/html/myapp/current/myapp/wsgi.py
[uwsgi]
chdir=/var/www/html/myapp/current #it success
module=myapp.wsgi:application #it success
env DJANGO_SETTINGS_MODULE=myapp.settings # it success
http-socket = 0.0.0.0:8008
processes = 1
threasds = 1
master = 1
max-requests = 100000

The error is below, but I can't dig the detailed logs.
spawned uWSGI worker 1 (pid: 27353, cores: 1)
--- no python application found, check your startup logs for errors ---
[pid: 27353|app: -1|req: -1/1] 172.17.1.143 () {28 vars in 334 bytes} [Thu Mar 26 17:37:01 2020] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

And this error occurs.
*** Operational MODE: single process ***
Traceback (most recent call last):
  File "./myapp/wsgi.py", line 13, in <module>
    from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1705)
spawned uWSGI worker 1 (pid: 1706, cores: 1)
spawned uWSGI http 1 (pid: 1707)

error happens here
from django.core.wsgi import get_wsgi_application

Also I am using anaconda3
$conda activate py37 then
start this command
$uwsgi --ini uwsgi.ini

A: I solved the problem , the problem was uwsgi itself.
My setting file was ok.
install uwsgi by conda
conda install -c conda-forge libiconv
conda install -c conda-forge uwsgi
then start uwsgi /home/ubuntu/anaconda3/envs/py37/bin/uwsgi --ini uwsgi.ini


Q: Sum of polynomial If $p(x)$ is a polynomial of degree $m$, does the polynomial $q(x)$ of degree $m+1$ exist so that $\sum_{i=0}^{n}p(i)=q(n)$? And if so, is there an algorithm to find the expression for $q(x)$?

A: Both questions can be answered in affirmative. Falling factorials are one of the many approaches that can be used both for proving the first part and providing an algorithm for the second part at the same time.
Let $x^{\underline{n}}$ denote the falling factorial; product of $n$ numbers starting from $x$ and decreasing by $1$ in every step:
$$ x^{\underline{n}}=\prod_{k=0}^{n-1}(x-k)=x(x-1)(x-2)\ldots(x-n+1)$$
Thus, for example, we have
$$\begin{eqnarray}
x^{\underline{0}} & & & = & 1 \\
x^{\underline{1}} & & & = & x \\
x^{\underline{2}} & = & x(x-1) & = & x^2-x\\
x^{\underline{3}} & = & x(x-1)(x-2) & = & x^3 - 3x^2 + 2x\\
\end{eqnarray}$$
Since $x^{\underline{n}}$ is a polynomial of degree $n$, it's not too difficult to see that any polynomial can be rewritten as a combination of falling factorials. For example, consider $p(x)=3x^2-x+5$:
$$p(x) = 3x^2 - x + 5 = 3x^{\underline{2}} + 2x+5 = 3x^{\underline{2}} + 2x^\underline{1} + 5 = 3x^{\underline{2}} + 2x^\underline{1} + 5x^\underline{0}$$
In each step, we eliminated the highest power of $x$, replacing it with the respective falling factorial and adjusting the remaining coefficients.
What makes the falling factorials interesting is that when it comes to summation, they behave very much like regular powers in integration:
$$\sum_{x=0}^{n-1} x^{\underline{k}} = \frac{1}{k+1}n^{\underline{k+1}}$$
(provable by a straightforward mathematical induction over $n$)
Thus, if we want to calculate $$q(n)=\sum_{i=0}^{n} p(i)$$ and we know $p(x)$'s representation using falling factorials, we just need to replace every $x^{\underline{k}}$ by $\frac{1}{k+1}(n+1)^{\underline{k}}$ (note that summing up to $n$, inclusive, yields $(n+1)$ in the result). In our example:
$$q(n)=\sum_{i=0}^n p(i)=\sum_{i=0}^n (3i^{\underline{2}} + 2i^\underline{1} + 5i^\underline{0})=(n+1)^{\underline{3}} + (n+1)^\underline{2} + 5(n+1)^\underline{1}$$
This is already sufficient to calculate the value of the sum efficiently (in fact, it can be evaluated efficiently in a way very similar to Horner's scheme), but if we really wanted, we can express it back in the standard form:
$$q(n)=(n+1)^{\underline{3}} + (n+1)^\underline{2} + 5(n+1)^\underline{1}=n^3+n^2+5n+5=(n+1)(n^2+5)$$
Since the described algorithm (express using falling factorials, "integrate", express using standard powers) works for any polynomial and the "integration" step increases the degree of the polynomial just by one, we've both proved that $q(n)$ is of degree $(m+1)$ and found an algorithm for computing it.

A: Just adding a bit of a more linear algebraic flavour. Assume we vectorize the coefficients of the polynomial like this:
$$p(x) = c_0+c_1x+\cdots c_nx^n  \rightarrow [c_0,c_1 \cdots c_n]^T$$
If you furthermore evaluate the polynomial in these points, call the vector $I = [p(1),p(2) \cdots]^T$. You can now write it as a matrix equation system
$$M\text{diag}(p)I = Wq$$
Where M is a triangular matrix with ones on and below the diagonal and zeros elsewhere. W is the matrix of integer monomials first row $1^0,2^0 ...$ second row $2^0, 2^1 ...$. Now we can use our knowledge of linear algebra to further manipulate and solve this. Actually may be more convenient to write it like
$$MWp = Wq$$
Well the point is anyway that both M and W matrices are very redundant. But that is like details you can probably figure out on your own. Making good choices of how to and in what order do calculations involving M and W and to solve the system probably corresponds to the great detailed answer you have already gotten.


Q: Change keyboard back to English in command line from Cyrillic I switched to Russian keyboard via loadkeys ru command and now cannot switch back.
A directory and subsequent files I have are titled in Cyrillic characters and I am trying to get to them by a combination of commands in Latin characters and Cyrillic ones. So far I've been stuck on Cyrillic.
Does anyone know how to switch back if I have only Cyrillic characters available?

A: I feel there must be a much more logical/sane solution compared to what I'm about to propose, such as running sudo loadkeys us from the graphical terminal whose layout is independent, or restarting the machine (as already suggested).
If none of those are an option, however, you could use the following pants-on-the-head technique:

*

*Find the original line in shell history with the ↑ key. It should be sudo loadkeys ru. Alternatively, find any line that has u and s in it.

*Remove all characters except for us. Press Enter. (Bash will complain that command not found.)

*Now go back to your loadkeys ru line.

*Press Alt+/. In the Russian layout / is mapped to .. And Alt+. is mapped yank-last-arg in bash, which is the command that inserts the last argument from the previous command. In this case, it will be us that we've assembled in the previous step.

*This should leave you loadkeys us. All it takes now is to press Enter.

If it happens that there are no commands with both u and s in them, you could do steps 2 and 3 twice, and pick those characters from 2 different commands.

A: The Russian keymap probably has a modifier key for Latin text.
Some likely suspects are the Caps Lock key (Latin lock), the right Alt (AltGr) key, or possibly the combination of Alt and Shift together.
If you could look at the keymap file (or run dumpkeys) then you'd know for sure. But it might be difficult to find information while your keyboard is stuck in an unfamiliar mapping!
The keymap file
The comment at the top of /usr/share/keymaps/i386/qwerty/ru.kmap.gz in Ubuntu 16.04 LTS (Xenial Xerus) says:

"Cyrillic" mode is toggled by Right_Ctrl key and shifted by AltGr key.

I hope your keyboard has a right-Ctrl key! If it doesn't, you'll need to hold down right-Alt (AltGr) while you switch.

A: Have you tried the standard(ish) shortcut that is ctrl+space ?
If, when installing a new keyboard you didn't suppress the English one, this shortcut should switch between one and the other.


Q: Add style to bundled code using webpack GitHub: https://github.com/Chirag161198/react-boilerplate 1
Here is the react boilerplate I’m trying to make from scratch.
I have bundled html with the react code but I’m not able to add styles (CSS).
I have heard about ExtractTextPlugin but not able to configure it.
Please suggest some way to add styles to it.
Thank you in advance.

A: You need to use style-loader and css-loader in your webpack.config.js
First, install these two packages via npm:
npm install style-loader, css-loader --dev
Then, create a styles.css in your src folder and append the following styles into the file (just for demo purpose, so you know it's working correctly):
body {
  background-color: #ff4444;
}

Don't forget to import the css file in your src/index.js:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App.js';
import './styles.css'; // <- import the css file here, so webpack will handle it when bundling

ReactDOM.render(<App />, document.getElementById('app'));

And use style-loader and css-loader in your webpack.config.js:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: { loader: 'babel-loader' },
      },

      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader'],
      },
    ],
  },

  plugins: [
    new HtmlWebpackPlugin({
      template: './src/index.html',
    }),
  ],
};

If you don't see the correct output, you might need to restart the webpack dev server again. I have cloned your repo and made the changes like I mentioned above, it works.
As for ExtractTextPlugin, you will need this when bundling for a production build, you can learn more from their Repo
Hope it helps!

A: Hi Chirag ExtractTextPlugin works great but when it comes to caching and bundle hashing. Css bundle becomes 0 bytes. So they introduced MiniCssExtractPlugin which has tackled this issue. It is really important to cache static files as your app size increase by time.
import plugin first:
var MiniCssExtractPlugin = require("mini-css-extract-plugin");

add these in your webpack config:
rules: [

   {
      test: /\.js$/,
      exclude: /node_modules/,
      use: {
        loader: 'babel-loader'
      }
    },
    {
      test: /\.scss$/,
      use:  [  'style-loader', MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
    }
  ]
}
plugins: [
  new MiniCssExtractPlugin({
    filename: 'style.css',
  }),
  new HtmlWebpackPlugin({
    template: './src/index.html',
  }),

Let me know you the issue still persists.

A: first you need to load style-loader and css-loader.Then you will add the following code in "rules" in webpack.config.js file.
{ test: /\.css$/,use: ['style-loader', 'css-loader']}

then import the "style.css" file location into the "index.js" file and for example:
import "./style.css";

When you package, "css" codes will be added in "bundle.js".


Q: MS Access: Report to contain info from third table I'm currently working on a database for a company, for them to use when making production orders. A report is to be made consisting of several things, mainly product number, order number etc etc. A part of the report is to be made up of a list of spare parts needed for the production of the item in question. I have a table with an order number and product number, which needs to look in another table to find the necessary spare parts. However, the name, location and stock of those spare parts are in a third table, and I can't seem to find a way to include these things automatically when the product number is known. I'm pretty new to MS Access, so any help will be greatly appreciated. Thanks!
I have a table called Table1, which uses a combobox to automatically fill boxes such as production time, test time etc from a given product number. This data is gathered from the second table StandardTimes, which has as a primary key the product number. Other columns in this table includes production area, standard quantity, average production time, and also includes in several columns, the necessary spare parts needed. In a third table called Inventory, we have the product numbers of the spare parts, their location in storage, and number of items currently in store. I created a report using a query which takes an order number, and creates a report on that order number from Table1. What needs to be included in this report is a list of the spareparts necessary, the location in the storage, and the number of items currently in store.

Revised from new user input
Your question still does not provide actual columns or data. As a result, it's hard to model your needs.
However, based on what I can read, I think that you have are missing some basic design setup items in a relational model.
Assuming that you have 3 tables: Table1 (Orders), StandardTimes (Products) and Inventory (SpareParts)
In English, every order has one or more products. Every product has one or more spare parts. Really you'd want an orders table, and an order details table which has records for each item as part of that order. But I'm answering it on your setup which I believe is flawed.
Orders <-(1:M)-> Products <- (1:M) -> SpareParts
You have an OrderID, a ProductID, and a SparePartID.
A query such as this would join those 3 tables together with that kind of relationship.
SELECT  o.OrderNum, o.ProductNum, st.ProductionArea, st.StandardQuality, i.SparePartsNum, i.Location, i.Qty
FROM Orders as o
INNER JOIN StanardTimes as st on o.ProductNum = st.ProductNum
INNER JOIN Inventory as i on i.ProductNum = st.ProductNum

A: Some sample data would be helpful to help design the queries.
In principal you would need to join the tables together to get the desired result.
You would join the productID on tblOrders to the ProductID on tblProducts. This will net you the name of the product etc.
This would be an INNER join, as every order has a product.
You would then join to tblSpareParts, also using the productID so that you could return the status of the spare parts for that product. This might be a LEFT JOIN instead of an INNER, but it depends on if you maintain a value of 0 for spare parts (e.g. Every product has a corresponding spare parts record), or if you only maintain a spare parts record for items which have spare parts.


Q: cgridveiw to display fetched data via customized query I am a newbei in yii, when a person clicks on a category display him all products under that particular category in a gridview
view
productcategory
    <?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'admin-grid',
'dataProvider'=>$model->SelectedCategoryProducts,
'filter'=>$model,
'columns'=>array(
    'Name',
    'Model',
    'Brand',
    'Price',

    array(
        'class'=>'CButtonColumn',
    ),
),
 )); ?>

controller
product
    public function actionProductcategory($id)

{
$model= Product::model()->SelectedCategoryProducts($id);
    var_dump($model);

    $this->render('productcategory',array(
        'model'=>$model,'id'=>$id,
    ));

}
  model
   product
  public function SelectedCategoryProducts($id)
{
    $dataProvider=new CActiveDataProvider('Product', array(
 'criteria'=>array(
                        'select'=>'name,model,price,brand',
        'condition'=>'category=:category',
                        'params'=>array(':category'=>$id),
    )));
    var_dump($dataProvider);
   return $dataProvider;
   }
CException

Property "CActiveDataProvider.sellerSelectedCategoryProducts" is not defined.

PLEASE HELP! I am losing my mind on this ... not able to display in gridview.

A: Hope this might help
Controller file
public function actionProductcategory($id)
      {
$model=new Product;
$this->render('productcategory',array('model'=>$model,
'id'=>$id));
 }

In View file
'dataProvider'=>$model->SelectedCategoryProducts($id),

UPDATE 1
'columns'=>array(
    'name',
    'model',
    'brand',
    'price',

change them to lowercase which are your original column names

A: Pass $id to your view file.
$this->render('productcategory',array('model'=>$model,'id'=>$id));

Then pass id to model function in ccgridview function.
'dataProvider'=>$model->SelectedCategoryProducts($id),

A:         $dataProvider=new CActiveDataProvider('Product', array(
     'criteria'=>array(
                            'select'=>'name,model,price,brand',
            'condition'=>'category=:category',
                            'params'=>array(':category'=>$id),
        )));

this can retrieve needed data....  first check that data is perfect ... is it right after that take second step....


Q: Ошибка в PL/SQL IF ELSE условие При написании такого простого кода возникает следующая ошибка
1.a = null
2.b = 20.08.2022 18:36:19
3.c = 12.08.2022 17:25:03

IF a = 1
OR (b IS NOT NULL AND c IS NOT NULL AND TRUNC(b) = TRUNC(c))
OR (b IS NOT NULL and c IS NULL AND TRUNC(b) = TRUNC(#APPLICATION.TIME_STAMP#))
   THEN RESULT:= 1;
    ELSE RESULT:= 0;
    END IF;

Код выдаёт следующую ошибку:
"ORA-06550: line 5, column 67:
PLS-00306: wrong number or types of arguments in call to '='
ORA-06550: line 5, column 1:
PL/SQL: Statement ignored
"
Подскажите как можно решить проблему?


Q: HyperlinkedRelatedField doesn't work in drf-nested-routers I'm using drf-nested-routers as below
calendar_router = DefaultRouter()
calendar_router.register(r'calendars', views.CalendarViewSet, base_name='calendars')

event_router = routers.NestedSimpleRouter(calendar_router, r'calendars', lookup='calendar')
event_router.register(r'events', views.EventViewSet, base_name='events')

When I add url field to Calendar serializer, it works well, but when add url field to 'Event' serializer, it just raise below exception

Could not resolve URL for hyperlinked relationship using view name
  "event-detail". You may have failed to include the related model in
  your API, or incorrectly configured the lookup_field attribute on
  this field.

A: Replace:
event_router.register(r'events', views.EventViewSet, base_name='events')

with
event_router.register(r'events', views.EventViewSet, base_name='event')


Q: Run Command Prompt Through Python (Or Vice Versa) I found myself doing a repetitive task and wondered how I can automate it.
I can write a function script with python(3), to iterate through each item in a folder, but I'm not sure how I would run that through command prompt.

I have sort of looked into how it would be possible, but I think a direct response to my exact question would be more helpful and easier to grasp.
My question comes more from a desire to learn than it does from laziness!

A: You could use os.system, but subprocess.run is probably better. You should also use glob:
import glob
import subprocess

files = glob.glob('*.wav')

for file in files:
    subprocess.run(['xWMAEncode', file, file.replace('.wav', '.xwm')])


Q: Uncaught TypeError: arr.filter is not a function I have printed arr values in console they are like
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

but when this function gives an error i am not getting any values in arr

Uncaught Type Error: arr.filter is not a function

I am new to java-script and i don't have any idea what's this error is
function filter(arr, criteria) {
   return arr.filter(function (obj) {
        return Object.keys(criteria).every(function (c) {
            return obj[c] == criteria[c];
        });
    });
}

A: Seems like the arr you are sending to the filter function is not an array, which is why the error is saying that arr.filter is not a function.
Just tried this and it works, so your function seems ok:
function filter(arr, criteria) {
   return arr.filter(function (obj) {
        return Object.keys(criteria).every(function (c) {
            return obj[c] == criteria[c];
        });
    });
}

const arr = [
  {
    name: "David",
    age: 54
  },
  {
    name: "Andrew",
    age: 32
  },
  {
    name: "Mike",
    age: 54
  }
];
const myFilter = {"age": 54};
const result = filter(arr, myFilter);

console.log(result);


Q: Pyspark - Divide the customers into income buckets How to divide customers into income buckets using pyspark?
Assume I've 2 columns named Customer and Income having range 10K to 50K.
Now I want to Divide the customers into income buckets 10K -20K, 20K-30K etc using pyspark Data frame.
TIA!


Q: How do I improve my RBX.Lua procedural generation code? This is my first post in stack overflow, and I have no clue whether I can post stuff about roblox development here.
But anyways, here I go. I'm making a top-down pixel art survival game, and am procedurally generating "flat" worlds with many different biomes. The code is working fine, it's just that the results look really unnatural, and I don't know what to do about it.
Some examples of what I mean:
world 1, world 2, world 3
Here is my code:
local biomeInfo = require(script.BiomeInfo)

local heightSeed = math.random(-2147483640, 2147483640)
local moistureSeed = math.random(-2147483640, 2147483640)
local heatSeed = math.random(-2147483640, 2147483640)

local mapSize = 250
local resolution = 20
local frequency = 15
local amplitude = 95

-- Generate noise maps
local grid = {}
for x = 1, mapSize do
    grid[x] = {}

    for z = 1, mapSize do
        local heightMap = math.noise(x / resolution * frequency / amplitude, z / resolution * frequency / amplitude, heightSeed)
        local moistureMap = math.noise(x / resolution * frequency / amplitude, z / resolution * frequency / amplitude, moistureSeed)
        local heatMap = math.noise(x / resolution * frequency / amplitude, z / resolution * frequency / amplitude, heatSeed)

        --[[local heightMap = math.noise(x / resolution * 1.2 / 3.2, z / resolution * 1.2 / 3.2, heightSeed)
        local moistureMap = math.noise(x / resolution * 4 / 5.6, z / resolution * 4 / 5.6, moistureSeed)
        local heatMap = math.noise(x / resolution * 2.7 / 7, z / resolution * 2.7 / 7, heatSeed)]]

        grid[x][z] = {
            ["Height"] = math.clamp(heightMap, -0.5, 0.5) + 0.5,
            ["Moisture"] = math.clamp(moistureMap, -0.5, 0.5) + 0.5,
            ["Heat"] = math.clamp(heatMap, -0.5, 0.5) + 0.5,
        }
    end
end

-- Generate blocks
for x = 1, mapSize do
    for z = 1, mapSize do

        -- Get all available biomes for this block
        local availableBiomes = {}
        for name, value in pairs(biomeInfo) do
            local condition = grid[x][z]["Height"] >= biomeInfo[name]["Height"] and grid[x][z]["Moisture"] >= biomeInfo[name]["Moisture"] and grid[x][z]["Heat"] >= biomeInfo[name]["Heat"]
            if condition and not availableBiomes[name] then
                table.insert(availableBiomes, name)
            end
        end

        -- Calculate value differences for all available biomes for this block
        local valueDiffs = {}
        for _, biome in pairs(availableBiomes) do
            valueDiffs[biome] = (grid[x][z]["Height"] - biomeInfo[biome]["Height"]) + (grid[x][z]["Moisture"] - biomeInfo[biome]["Moisture"]) + (grid[x][z]["Heat"] - biomeInfo[biome]["Heat"])
        end

        -- Get the lowest value difference, assign the corresponding biome
        local lowestValue = 1
        local selectedBiome
        for biome, value in pairs(valueDiffs) do
            if value < lowestValue then
                lowestValue = value
                selectedBiome = biome
            end
        end

        -- Generate the block
        local block = Instance.new("Part")
        block.Anchored = true
        block.Size = Vector3.new(8, 8, 8)
        block.Position = Vector3.new(x * 8, 0, z * 8)
        block.Parent = game.Workspace.World
        if grid[x][z]["Height"] <= 0.2 then -- Water level
            block.BrickColor = BrickColor.new("Electric blue")
        elseif selectedBiome == "Grasslands" then
            block.BrickColor = BrickColor.new("Bright green")
        elseif selectedBiome == "Taiga" then
            block.BrickColor = BrickColor.new("Baby blue")
        elseif selectedBiome == "Desert" then
            block.BrickColor = BrickColor.new("Cool yellow")
        elseif selectedBiome == "Swamp" then
            block.BrickColor = BrickColor.new("Slime green")
        elseif selectedBiome == "Mountains" then
            block.BrickColor = BrickColor.new("Dark stone grey")
        elseif selectedBiome == "Jungle" then
            block.BrickColor = BrickColor.new("Earth green")
        elseif selectedBiome == "Snowy tundra" then
            block.BrickColor = BrickColor.new("White")
        else
            block.BrickColor = BrickColor.new("Bright green")
        end

        block.Position = Vector3.new(x * 8, 4.5, z * 8)
        block.Parent = game.Workspace.World
    end
    game:GetService("RunService").Heartbeat:Wait()
end

Note: I'm aware that the many elseif statements is inefficient, this is temporary, please ignore it.
The "BiomeInfo" module script:
return {
    ["Grasslands"] = {
        ["Height"] = 0.27,
        ["Moisture"] = 0.21,
        ["Heat"] = 0.25
    },
    ["Desert"] = {
        ["Height"] = 0.15,
        ["Moisture"] = 0.05,
        ["Heat"] = 0.49
    },
    ["Taiga"] = {
        ["Height"] = 0.28,
        ["Moisture"] = 0.16,
        ["Heat"] = 0.12
    },
    ["Swamp"] = {
        ["Height"] = 0.16,
        ["Moisture"] = 0.44,
        ["Heat"] = 0.14
    },
    ["Mountains"] = {
        ["Height"] = 0.43,
        ["Moisture"] = 0.08,
        ["Heat"] = 0.11
    },
    ["Jungle"] = {
        ["Height"] = 0.22,
        ["Moisture"] = 0.51,
        ["Heat"] = 0.31
    },
    ["Snowy tundra"] = {
        ["Height"] = 0.17,
        ["Moisture"] = 0.12,
        ["Heat"] = 0.03
    },
}

This is my first time working with procedural generation, so I'm not sure if I'm applying the most efficient methods for everything.


Q: How to test select html control object using SpecFlow? I have html select on page:
<select id="StateName" name="StateName">
<option value=""></option>
<option value="value1">value1</option>
<option value="value2">value2</option>
<option value="value3">value3</option>
<option value="value4">value4</option>
<option value="value5">value5</option>
</select>

I've already tried such step definition
[When("I select value \"(.*)\" of select object with id \"(.*)\"")]
public void ThenSelectValueOfSelect(string value, string selectId)
{
   var select = TestsRunner.Browser.GetElementById(selectId);
   select.Click();
   var item = TestsRunner.Browser.GetElementsByTag(@"option").SingleOrDefault(o => o.GetAttribute("value").Equals(value, StringComparison.OrdinalIgnoreCase));
   item.Click();
}

As testsrunner browser I use firefox. The problem is select items are dropped down but concrete option isn't selected.

A: I think it can be done much shorter/easier. The way I'm selecting values from dropdownboxes:
SelectElement dropdown = new SelectElement(Driver.FindElement(By.Id(dropdownID)));
dropdown.SelectByValue(valueToBeSelected);

It's pretty simple and straight forward and it just works.


Q: Creating private reminders using iOS API? Does EKEventStore allow the creation of "private" reminders, i.e. reminders that will be visible only to my app (the one that calls against the EventKit -- iOS events API) but not e.g. to Apple's default reminders app (for either iOS or OS X)?

A: The EKEventStore provides access to the calendar/reminder resources that are available to the OS that are configured by the user.
It is not possible to configure a separate event store for private developer use.
Reminders can be made local so they are not synced in the cloud.
However, if the device has reminder lists that are synced to the cloud, then it is no longer possible to access the local reminders either by your app or the Reminders app.
This same behavior seems to apply to local Calendars where I answered a question about their availability at Local EKCalendar saved with not errors, disappears.
The question at Unable to create local EKCalendar (Reminders) if iCloud is set to not sync Reminders seems to support my conclusions and suggests this behavior has been present for at least a couple of years.


Q: RTL8821AE issues - fix possible or should I replace it with a different chip? I've spent all day trying to figure out how to get proper WiFi speeds on my Linux machine.
I've narrowed it down to the WiFi chip used by my WiFi adapter, the RTL8812AE (which uses the RTL8821AE driver). It looks like many people are experiencing the same issue with this chip/driver, where download speeds are slower and upload speeds are simply crippled to 5 Mbps. When using Windows 10 on the same computer, download and upload speeds are fine.
A few things that I am trying to understand before I give up and buy a different WiFi adapter:

*

*Is there only one version of the driver for each kernel version, or are there fixes / different versions that can be found?

*Does this chip / driver work better in older kernel versions, or maybe it will be fixed in upcoming kernel versions?

*Is this considered an outdated or not properly maintained chip / driver?

Some system information that might be useful:
saar@saar-desktop:~$ lspci -nn | grep 8812
03:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8812AE 802.11ac PCIe Wireless Network Adapter [10ec:8812] (rev 01)

saar@saar-desktop:~$ modinfo rtl8821ae
filename:       /lib/modules/5.15.0-50-generic/kernel/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/rtl8821ae.ko
firmware:       rtlwifi/rtl8821aefw_29.bin
firmware:       rtlwifi/rtl8821aefw.bin
description:    Realtek 8821ae 802.11ac PCI wireless
license:        GPL
author:         Realtek WlanFAE <wlanfae@realtek.com>
srcversion:     D9A877775845A84FD0B66A7
alias:          pci:v000010ECd00008821sv*sd*bc*sc*i*
alias:          pci:v000010ECd00008812sv*sd*bc*sc*i*
depends:        rtlwifi,rtl_pci,btcoexist,mac80211
retpoline:      Y
intree:         Y
name:           rtl8821ae
vermagic:       5.15.0-50-generic SMP mod_unload modversions
sig_id:         PKCS#7
signer:         Build time autogenerated kernel key
sig_key:        73:82:D7:4C:EB:C9:46:51:9A:DB:8C:D2:62:0E:BC:92:EA:31:B8:BF
sig_hashalgo:   sha512
signature:      <hidden>
parm:           swenc:Set to 1 for software crypto (default 0)
 (bool)
parm:           ips:Set to 0 to not use link power save (default 1)
 (bool)
parm:           swlps:Set to 1 to use SW control power save (default 0)
 (bool)
parm:           fwlps:Set to 1 to use FW control power save (default 1)
 (bool)
parm:           msi:Set to 1 to use MSI interrupts mode (default 1)
 (bool)
parm:           aspm:Set to 1 to enable ASPM (default 1)
 (int)
parm:           debug_level:Set debug level (0-5) (default 0) (int)
parm:           debug_mask:Set debug mask (default 0) (ullong)
parm:           disable_watchdog:Set to 1 to disable the watchdog (default 0)
 (bool)
parm:           int_clear:Set to 0 to disable interrupt clear before set (default 1)
 (bool)

saar@saar-desktop:~$ sudo lshw -class network
  *-network
       description: Wireless interface
       product: RTL8812AE 802.11ac PCIe Wireless Network Adapter
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: wlp3s0
       version: 01
       serial: d0:37:45:ae:37:52
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=rtl8821ae driverversion=5.15.0-50-generic firmware=N/A ip=10.100.102.40 latency=0 link=yes multicast=yes wireless=IEEE 802.11
       resources: irq:147 ioport:d000(size=256) memory:f7d00000-f7d03fff


Q: Using "object" of mainfile, in function saved in other file In my work, I am receiving orders in PDF file, while I need to rewrite them into Excel table. Both Excel file and PDF file have every time exact structure, that does not change, so I have decided to automate this process and create python script that will do it for me.
At the moment, I am about to end, I just need to write into excel file last data, but I am having serious issues, so serious, that I might need to rewrite/redesign half of my code (that has about 500 lines atm).
The "problem" is, that I have my code split into 3 files:

*

*main (the one I am executing)

*functions (where all complicated logical functions are stored)

*config (where constants and configuration is stored)

The problem, however is, that I have in main file constructor of xlsxwritter, which creates Excel files and sheets.
Exactly this:
# Creation of new EXCEL file
xlsx_file = 'Red_vyplaty_' + termin_file + '.xlsx'
print 'Creating excel file "%s"' % xlsx_file
excel_file = xlsxwriter.Workbook(xlsx_file)

# Adding sheet, called "Listky_obce_nad_300"
obce_nad_300_sheet = excel_file.add_worksheet('Listky_obce_nad_300')
print 'Adding data sheet "Listky_obce_nad_300" into "%s"' % (xlsx_file)
obce_nad_300_sheet.set_column(0, 0, 2)
obce_nad_300_sheet.set_column(1, 1, 2)

But, I need(or want is more accurate) to create a function, in functions file that will have one imput, and based on this one imput, it will get data from config-constants file, and write them into this sheet(obce_nad_300_sheet).
The problem is, if i create function like:
def create_footer(suma_cell, starting_row, flag):
    """
    Function to creade footer of listok
    flag = 0 / 1 / 2 (data sheet where to write header)
    """
    obce_nad_300_sheet.write(row, 4, 'Test')

it will (obviously) throw exception, that global variable obce_nad_300_sheet does not exist, bla bla bla..im sure you all know it :)
I know, that I have 2 options how to solve it:

*

*Move whole creating and adding and writting into worksheet from main.py, into functions.py

*

*that could do it, but, it would be too much work for me, and most of those new functions will be just calling one xlsxwritter function, so kinda waste of time

*Create these new function in main.py file

*

*while I am not sure if it would work, I am sure, that having some functions in function.py file, and others in main.py file, will be totally ugly and against my rules of clear code.

BUT I would like to have 3rd option, that I am not aware of yet and will be both, simple and "nice"??? :)
PS: No, xlsxWritter is not able to open/read excel file, it can only create new one, so if i define it inside function, it will rewrite everything I have written into file before.

A: I feel that your code is not very well organized. Without entering into too much trouble, I would use obce_nad_300_sheet as an object an move it around. Like this:
def create_footer(sheet, suma_cell, starting_row, flag):
    """
    Function to creade footer of listok
    flag = 0 / 1 / 2 (data sheet where to write header)
    """
    sheet.write(row, 4, 'Test')

I don't know how the library works however. Does it "commit" the changes with a call to write or need some sort of a save or commit method after that?

Without knowing too much about your situation nor the library, I would probably create an object inheriting from xlsxwriter.Workbook, store the sheets in an attribute of that object (probably a dict of {"sheet_name": WorkSheet}) and write the methods in the object. It could look like this:
class MyWorksheet(xlsxwriter.Workbook):

    def __init__(self, *args, **kwargs):
        [...]
        super(MyWorksheet, self).__init__(*args, **kwargs)
        self.sheets = {}
        [...]

    def add_worksheet(self, name):
        [...]
        self.sheets[name] = super(MyWorksheet, self).add_worksheet(name)
        [...]

    def create_footer(self, sheet_name, suma_cell, starting_row, flag):
        [...]
        self.sheets[sheet_name].write(row, 4, "Test")
        [...]

And then in what you call main file do:
my_sheet = MyWorksheet()
my_sheet.add_worksheet("Listky_obce_nad_300")

my_sheet.create_footer("Listky_obce_nad_300", suma, starting, flag)