text:
Q: Function call to object created by directive I have the following situation:
Having my main view containing header, footer and ng-view to load the view according to the controller  (controller chosen based on route).

  Next Slide

In the controller i have a view with a directive creating a slider and returning the slider object:
    angular.module('App').directive('npSwiper', [
  '$timeout',
  function($timeout) {
    return {
      restrict: 'A',
      link: function(scope, element, attrs) {
        $timeout(function() {
          // This code will run after template has been loaded
          // and transformed by directives
          $timeout(function() {
            // and properly rendered by the browser
            $timeout(function() {
              $timeout(function() {
                var params = {
                  slideElement: 'article',
                  mode: 'horizontal',
                  calculateHeight: true,
                  paginationClickable: true,
                  pagination: '.pagination',
                  resizeReInit: true
                };
                if (attrs.npSwiper === 'gallery') {
                  params.slidesPerView = 1;
                  params.createPagination = false;
                  params.loop = true;
                }
                scope.swiper = new Swiper('.swiper-container', params);
                console.log('directive', scope.swiper);

                new Swiper('.swiper-container-instagram', {
                  slideElement: 'article',
                  mode: 'horizontal',
                  calculateHeight: false,
                  paginationClickable: true,
                  pagination: '.pagination-instagram',
                  resizeReInit: true
                });

              });
            });
          });
        });
      }
    };
  }
]);

I can make a function
$scope.nextSlide = function(slider) {
  slider.swipeNext();
}

assigned to ng-click to a span for example in the same view that is being loaded from the controller, but when I want to assign it to the footer (outside the slider view) it gives no result.
Also calling the swiper from the controller by simply:
$scope.swiper

gives undefined. Any ideas how to reach it?


text:
Q: Python Automated Data Driven Pages - Labeling and Symbolizing Errors I am trying to use a python script to automate the export of the data driven map document.
However when I use the python script to run the DDP export some of the labels are not exported and the symbols that have a rotation angle based on a attribute in the layer table is not rotating.
Other than the labels and the symbols the python script to automate the exports works fine.
When I run the DDP manually (through the MXD) all the labels and symbols are exported correctly.  Have anyone else encountered this problem?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Autoplay not working in mediaelement.js I am trying to get mediaplayer.js to autoplay. Autoplay works perfect with the native audio tags but as soon as I implement the mediaelement java script the player works and looks great but will not autoplay anymore.
I've tried various javascript answers, none of which have worked and I have tried changing the autoplay="true" to auto or autoplay or... nothing works. I can't find anything about it on google either. There is a lot about wordpress but none of that seems to apply to non-wordpress scenarios.
The article "Autoplay MediaElementPlayer" said there was a solution but it failed to work for me.
This is my code:
<audio controls="controls" autoplay="true">
    <source src="music/male.ogg" type="audio/ogg" /> <!--change song here for FF-->
    <source src="music/male.m4a" type="audio/mpeg" /><!--change song here for webkit-->
</audio>

I've tried it in every browser too with no results: IE, Opera, FF, Chrome, Safari etc.
Everything works great except it will not autoplay anymore once the mediaelement javascript works. This is a simple feature of the audio tag. I've tried to implement autoplay in the provided demos and it will not work there either.
Any help would be great, thanks!
I know some might think autoplay is not good practice but my client wants it.

A: This works partially for me.
It's works for HTML5 but not for flash fallback.
vplayer = new MediaElementPlayer('video');
vplayer.play();


text:
Q: How to specifying what msbuild version to use for a given project My build machine should compile some projects that been created in vs 2010 with MSBuild 4.0.
And some projects that also been created in vs2010 to build them using MSBuild v13.0.
Any ideas how I can specify in the project file or by some other way what msbuild to use for this given project...

A: Your .csproj has a start tag called Project which has an optional attribute called ToolsVersion. The version of the toolset MSBuild uses to determine the values for $(MSBuildBinPath) and $(MSBuildToolsPath).
Via msbuild command-line you could set those properties to determine which version of the msbuild you are going to use.
source: MSDN


text:
Q: End of Hom-profunctor in Grp What is the end of the $\operatorname{Hom}$ profunctor in the category of groups?
$$\int_{X\in\mathsf{Grp}} \operatorname{Hom}(X, X)$$
Preface: if we examine ends of $\operatorname{Hom}(-, -)$ in other categories, in $\mathsf{Set}$ we get the identity function, or rather a mapping $S \mapsto \{\operatorname{id}_S\}$.
In $\mathsf{Vect}_K$ the end is $\{(k \cdot -) : k \in K\}$ - the set of uniformly scaling linear maps, and if we take the end of the internal $\operatorname{hom} : \mathsf{Vect}_K^{op} \times \mathsf{Vect}_K \to \mathsf{Vect}_K$, we get the vector space of those maps (isomorphic to $K$).
Intuitively, the end of $\operatorname{Hom}$ seems to be the set of morphisms (or rather morphism families parameterised by the domain object) that can be applied to any object, $\{x \mapsto x\}$ in $\mathsf{Set}$ and $\{(x \mapsto k\cdot x) | k \in K\}$ in $\mathsf{Vect}_K$.
Continuing the line of thought the end of $\operatorname{Hom}$ in $\mathsf{FinGrp}$ and likely $\mathsf{Grp}$ too, is $\{(x \mapsto x^i) | i \in \mathbb{Z}\}$.
The proof that $G \mapsto \{(x \mapsto x^i) : G \to G | i \in \mathbb{Z}\}$ is a wedge of $\operatorname{Hom}(-, -)$ is simple enough, for any group homomorphism $f : G \to H$, $f(x^i) = f(x)^i$ and hence pre- and post-compositions of a hom-set with $-^i$ are necessarily equal.
However I have no proof that this wedge is universal.

A: You're either approaching, or already made without saying so explicitly, the realization that the end of the hom bifunctor is the set of natural endomorphisms of the identity functor. This follows directly from the definition, once you unravel it. This immediately gives us the first two results you list: since a singleton represents the identity endofunctor of $\mathbf{Set}$, its single endomorphism represents the end of the hom bifunctor, and analogously in vector spaces. Since groups aren't enriched over themselves, we can't make quite the same argument to calculate $\int_G\mathrm{Gp}(G,G)$ as $\mathrm{Gp}(\mathbb{Z},\mathbb{Z})$. However, there's a nice trick we can use: groups have a faithful forgetful functor $U$, and so a natural endormorphism of the identity is just a natural endomorphism of the forgetful functor whose components happen to be group homomorphisms. But the forgetful functor is represented by $\mathbb{Z}$, so its endomorphisms are just $\mathrm{Gp}(\mathbb{Z},\mathbb{Z})$, each element of which corresponds to the natural endomorphism $g\mapsto g^n$ of $U$. However, none of these endomorphisms of $U$ are group homomorphisms for nonabelian groups $G$, except when $n=1$ or $n=0$! Thus there are only two elements in the end of the hom bifunctor for groups, corresponding to the identity natural transformation and to that which maps each group to its identity element.
The object we've just computed is often known as the center of the category, as it's guaranteed to be a commutative monoid by the Eckmann-Hilton argument. Note that, indeed, all of our computations so far are commutative monoids, mostly rather boring ones.


text:
Q: passing this to a function changes all clicked elements Shapes are added to a canvas and a click function is assigned to each item. On click an edit window shows up that enables the user to edit the shapes
function place(id, top, leftpx, width, height, color) {
  var dropped;

  dropped.attr('s_id', id)
    .appendTo('.xy')
    .data({
      'posleft': leftpx,
      'postop': top,
      'width': width,
      'height': height,
      'color': color
    })
    .css({
      top: top + "px",
      left: leftpx + "px",
      position: "absolute",
      width: width,
      height: height
    });

  dropped.resizable({
    containment: '.xyz',
    handles: 'all',
    stop: function(event, ui) {
      $(this).data('width', ui.size.width);
      $(this).data('height', ui.size.height);
    }
  });

  dropped.click(function(e) {
    var id = $(this).attr("shelf_id"); // gives the correct id
    edit($(this));
  });

When I click one item, it changes the color correctly, but as soon as I click a second one, it also changes the color of the item that was clicked before. Corresponding function is the following:
function edit(item) {
  //edit window shows up

  $("#editDataForm").submit(function(e) {

    var id_color = $("#colorSelect option:selected").val();

    if (item.data('color') != id_color) {
      switch (id_color) {
        case '1':
          item.css("background-color", "yellowgreen");
          item.data('color', id_color);
          break;
        case '2':
          item.css("background-color", "indianred");
          item.data('color', id_color);
          break;
        default:
          break;
      }
    }
    e.preventDefault();
  });
}

Could someone please give me a hint where my mistake in reasoning is. I just cant crack it

A: Every time you call edit(item) you add an additional submit() handler to the form. When you submit the form, all those handler functions run, and they each change the color of the item that was clicked on when you called edit.
If you only want to affect the last one, you need to remove the previous event handler. You can do this with the .off() method.
function edit(item) {
  //edit window shows up

  $("#editDataForm").off("submit").submit(function(e) {

    var id_color = $("#colorSelect option:selected").val();

    if (item.data('color') != id_color) {
      switch (id_color) {
        case '1':
          item.css("background-color", "yellowgreen");
          item.data('color', id_color);
          break;
        case '2':
          item.css("background-color", "indianred");
          item.data('color', id_color);
          break;
        default:
          break;
      }
    }
    e.preventDefault();
  });
}


text:
Q: Which numbers of [0,1) have a unique base g expansion? Good evening,
i know that is question is rather standard, but unfornunately I have not much knowledge of number theory.
Take $2 \leq g\in \mathbb{N}$. I know that every $x \in [0,1)$ can be represented as $x = \sum_{k=1}^\infty \frac{x_k}{g^k}$ with $x_k \in \{0, .. , g-1\}$.
I know that this repesentation is not unique (for example if $x_k= g-1 ~~ \forall k > N_0 \in \mathbb{N}$). I know that there are  $x \in [0,1)$ with a unique representation (for example if $x_k= 0 ~~ \forall k > N_1 \in \mathbb{N}$).
Here is my question: Is there any characterisation of the $x \in [0,1)$ which have a unique base g expansion?
I am very thankful for any reference! With best regards.

A: Here's a proof that supports the characterization stated in the comments:
The $g$-ary representations for numbers $x\in[0,1)$ are of the form
$$\tag1 x=\sum_{k=1}^\infty x_kg^{-k}$$
with $x_k\in\{0,\ldots,g-1\}$. Let $(x_k)$ and $(y_k)$ be two distinct digit sequences in $\{0,\ldots,g-1\}$ representing the same number and wlog. $(x_k)$ lexically precedes $(y_k)$, say $x_n<y_n$ whereas $x_k=y_k$ for $k<n$.
Then
$$\begin{align}0&=\sum_{k=1}^\infty y_kg^{-k}-\sum_{k=1}^\infty x_kg^{-k}\\&=\sum_{k=1}^\infty (y_k-x_k)g^{-k}\\&=g^{-n}(y_n-x_n)+g^{-n}\sum_{k=1}^\infty (y_{n+k}-x_{n+k})g^{-k}\\&\stackrel{(1)}\ge g^{-n}+g^{-n}\sum_{k=1}^\infty (y_{n+k}-x_{n+k})g^{-k}\\&\stackrel{(2)}\ge g^{-n}+g^{-n}\sum_{k=1}^\infty(0-(g-1))g^{-k}\\
&=g^{-n}-g^{-n}(g-1)\sum_{k=1}^\infty g^{-k}
\\&=g^{-n}-g^{-n}(g-1)\frac1{g-1}=0.\end{align}$$
Since we end up with equality, we must have equality at $(1)$ and $(2)$.
But equality at $(1)$ holds if and only if $y_n=x_n+1$ and at $(2)$ if and only if for all $k\ge1$ we have $y_{n+k}=0$, $x_{n+k}=g-1$.
Note that in this case we additionally obtain
$$\tag2x = \sum_{k=1}^\infty y_kg^{-k} =\sum_{k=1}^n y_kg^{-k}=\frac{\sum_{k=1}^ny_kg^{n-k}}{g^n}.$$
Likewise, if $x=\frac m{g^n}$ in shortest trerms (i.e. with $m$ not divisible by $g$), the $g$-ary integer representation of $m$ ands in a nonzero digit, gives us a terminating representation with $y_n>0$ of $x$ via $(2)$, from which we obtain two $g$-ary representations as above.
This shows that a number $x\in[0,1)$ has two different $g$-ary representations if and only if $x=\frac m{g^n}$ with $0<m<g^n$.


text:
Q: magento 2 sales_order_shipment_save_after does not fire I created an observer for changing the shipping method amount but it does not work.
This is my code

Cop/Postexpres/etc/events.xml

<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_shipment_save_after">
    <observer name="popopp" instance="Cop\Postexpres\Model\Observer"  />
</event>

and

Cop/Postexpres/Model/Observer.php

 namespace Cop\Postexpres\Observer;
      use Magento\Framework\Event\ObserverInterface;

class Observer implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $shipment = $observer->getEvent()->getShipment();
        $order = $shipment->getOrder();
       var_dump($order->getData());

    }

}

A: Try following code:

*

*app/code/[VendorName]/[ModuleName]/etc/adminhtml/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_order_shipment_save_after">
        <observer name="sales_order_shipment_save_after" instance="
            [VendorName]\[ModuleName]\Observer\ProcessShipment" />
    </event>
</config>

*app/code/[VendorName]/[ModuleName]/Observer/ProcessShipment.php

<?php
namespace [VendorName]\[ModuleName]\Observer;

use Magento\Framework\Event\ObserverInterface;

class ProcessShipment implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $shipment = $observer->getEvent()->getShipment();
        $order = $shipment->getOrder();
    }
}

A: It looks like you passed wrong instance in your events.xml. You passed
<observer name="popopp" instance="Cop\Postexpres\Model\Observer"  />

and your namespace Observer is
namespace Cop\Postexpres\Observer;

So, you just need to add correct namespace(you are missing Model in your namespace).

A: Your namespace is incorrect. In your observer class, namespace should be

Cop\Postexpres\Model\Observer

instead of

Cop\Postexpres\Observer

Rest everything is fine!


text:
Q: Update order with basket xml I'm trying to update a sagepay order's basket xml via shopify's create order webhook.
However, I cannot find any reference in the sagepay integration docs on an API endpoint for updating an orders basket xml. A lot of different examples of how to format the XML but nothing specific on where it should be sent.
For those who don't know/use shopify, I do not have access to the sagepay form but the webhook has full access to the transaction and order details itself.
Thanks for any help given!

A: The BasketXML forms part of the transaction post. As soon as the transaction post is submitted to Sage Pay with basket details the basket cannot be subsequently amended with Sage Pay for that transaction.


text:
Q: Forcing x64 bit builds in cmake I have a CMake project that should not be built in 32-bit mode on x86, and I can't for the life of me figure out how to prevent that from happening.
Right now, it appears cmake <path>, by default on windows assumes a 32-bit build.
How can I make my CMake project always build the 64-bit variant, without requiring the passing of command-line arguments to CMake?
Alternatively, how can I make CMake abort if it is trying to be built as 32-bit?

A: You can add to our CMakeLists.txt the following code to ensure that only x64 builds are allowed:
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
    message("Please switch to x64 build.")
    return()
endif()


text:
Q: How to react to to user scrolling on Accompanist Pager? The Accompanist Pager documentation suggests reacting to page changes as follows :
val pagerState = rememberPagerState()

LaunchedEffect(pagerState) {
    // Collect from the pager state a snapshotFlow reading the currentPage
    snapshotFlow { pagerState.currentPage }.collect { page ->
        AnalyticsService.sendPageSelectedEvent(page)
    }
}

VerticalPager(
    count = 10,
    state = pagerState,
) { page ->
    Text(text = "Page: $page")
}

How can we distinguish scrolling to a page from user gesture, and scrolling to a page using animateScrollingToPage() / scrollingToPage() ? I would like to perform a certain action only on user scroll, not on programmatic scroll.

A: Did you try :
val isScrollInProgressFlow = snapshotFlow { pagerState.isScrollInProgress }

A: I had a similar problem and I solved it using interactionsSource. No interaction is emitted when automatic scroll happens. But it emits interactions on user actions.
You can also use other interaction source types.
LaunchedEffect(Unit) {
    pagerState.interactionSource.interactions
        .collect {
            if (it is DragInteraction.Start) {
                Log.d("test", "User interaction is started")
            }
        }
}

In my case I had to cancel automatic scroll on user drag. The simplified version looks like this:
LaunchedEffect(Unit) {

    val autoscrollJob = launch {
        while(true) {
            yield() // exit the coroutine if the job is completed
            delay(autoScrollDelay)
            animateScrollToPage(
                page = (currentPage + 1) % pageCount
            )
        }
    }

    launch {
        interactionSource.interactions
            .collect {
                if (it is DragInteraction.Start) {
                    autoscrollJob.cancel()
                }
            }
    }
}


text:
Q: How to create dynamic json in php? I want to display dynamic dependent dropdown list in CI.
I create below dynamic json but I am not understanding how to convert this to php format.
{
    "salary": [
        {
            "id": 0,
            "text": 2017,
            "data": {},
            "children": [
                {
                    "id": 1,
                    "text": "May"
                },
                {
                    "id": 2,
                    "text": "July"
                },
                {
                    "id": 3,
                    "text": "August"
                },
                {
                    "id": 4,
                    "text": "September"
                },
                {
                    "id": 5,
                    "text": "October"
                }
            ]
        }
    ]
}

Below is my PHP code where I want to implement this code.
If text = 2017 is same means PAY_YEAR IS SAME then in it will display all months that are in its children part.it should be displayed in PAY_MONTH part.
Like: in json we can see 2017 is there and in children part 5 months inside it.
So, if a user will select 2017 from dropdown then in another dropdown of pay_month all months should come.
<form action="#" method="get" class="form-horizontal">

        Select Year

            <select>
                <?php
                foreach ($salary  as $row) {?>
                <option><?php  echo $row->PAY_YEAR;}?></option>
            </select>

        Select Month

            <select>
                <?php
                foreach ($salary  as $row) {?>
                <option><?php  echo $row->PAY_MONTH;}?></option>
            </select>

        <button type="submit" class="btn btn-success">Search</button>
        <button type="submit" class="btn btn-success">Cancel</button>

</form>

I hope you guys understand me.

A: I have done something like this.
First add id for both the dropdown.
For year dropdown add id="year_select"
For salary dropdown add id="sal_select"

$("#year_select").change(function() {
 $.getJSON('json_data.txt', function(read_data) {
  var data = read_data.salary[0].children;
  var str_opt = "<option value=''></option>";
  $.each(data, function(i, item) {
   str_opt += "<option value='"+data[i].id+"'>"+data[i].id+"</option>";
  });
  $('#sal_select').html(str_opt);
 });
});

A: I'm not quite certain what you are asking, but if you need to convert JSON to PHP variable (turns it into an array) you can use json_decode($json) and the other direction json_encode($variable).
PHP manual reference for decode
PHP manual reference for encode
Edit: Now I see that's not what you are asking. I think this will help, except using a XMLHttpRequest in the changecat(value) function like this.


text:
Q: Update multiple documents with mongoose using node-cron I'm trying to update multiple document with mongoose using node-cron. What I'm trying to accomplish is all documents that was created, let's say, July 1, will have an status of inactive after 30 days.
I manage to update multiple document using the code below but I don't know how to update multiple documents with products which date is less than the current date:
I know how to get the list of product that is less than the current date using but I don't know how to apply this logic to the code below -
let currentDate = new Date();
let query = Product.find({ dateCreated: {$lt: currentDate}});

Code is unrelated to what I'm trying to accomplish. This is a sample
  code that will update multiple documents every 10 seconds.

const mongoose  = require('mongoose');
const Product   = require('../model/product');
const cron      = require('node-cron');

cron.schedule('*/10 * * * * *', function(){
    let productArray = ['Bacon', 'Apple', 'Fork', 'Beans'];
    productArray.map(product => updateProduct(product));
});

let updateProduct = (name) => {
    let randomNumber = Math.floor(Math.random() * (999 - 1 + 1));
    let query = Product.findOne({name: name}).select({ 'name': 1 });
    query.exec((err, product) => {
        if(err) throw err;
        if(product){
            product.description = `Random description generate every 10 seconds: ${randomNumber}`;
            product.save(err =>{
                if(err) throw err;
                console.log(`Successfully updated random description for: ${product.name}\n ${product.description}\n`);
            });
        }
    });
};

Product Schema

const mongoose = require('mongoose');
const Schema   = mongoose.Schema;

const productSchema = mongoose.Schema({
    name            :   String,
    description     :   String,
    status          :   String,
    dateCreated     :   { type: Date, default: Date.now }, //
});

module.exports = mongoose.model( 'Product', productSchema );

This is the only way I know to update multiple document in mongoose. So is there other way to update multiple document in mongoose after 30 days of creation using mongoose and node-cron? Pardon me if my question is confusing.

A: Here you go the full version of code.

Here you no need to make multiple queries, like first selecting all
  the products whose currentdate has matched your criteria. Cause that
  you can do while updating the products itself.

const mongoose = require('mongoose');
const Product = require('../model/product');
const cron = require('node-cron');

cron.schedule('*/10 * * * * *', function() {
    let productArray = ['Bacon', 'Apple', 'Fork', 'Beans'];
    updateAllProducts(productArray, (err, res) => {
        if (err)
            //error handle, you can log here
        else
        //success handle, you can log here
    })
});

let updateAllProducts = (productArray, callbackFn) => {
    let randomNumber = Math.floor(Math.random() * (999 - 1 + 1));
    description = `Random description generate every 10 seconds: ${randomNumber}`;
    Product.update({
        name: {
            $in: productArray
        },
        dateCreated: {
            $lt: currentDate
        }
    }, {
        description: description
    }, {
        multi: true
    }, (err, res) => {
        if (err) {
            callbackFn(err, null)
        } else {
            callbackFn(null, err);
        }

    });

};

In this case you can also log if Db update was failure or success. So there is better control over code. Rather than making multiple Calls in loop. That would be really time consuming and error prone.
Hope this helps!


text:
Q: Problems with Search on graph When i search for something in my computer like:
https://graph.facebook.com/search?q=swarmetrics&type=post&limit=75
return 6 results, but, when I search the same in another computer or another browser, returns nothing
what I'm missing?

A: I get an empty result as well, and also if I try to search in the facebook search box and then select "Public Posts" I get "No results found for your query".
Maybe the user you are logged in with has access to some private results for that query.
Try loggin into facebook from the other browser/computer with the same user and then make the search.

A: Been experiencing similar results lately where our dev machines and local machines will return empty results for a known good search, while the production server and other off-site machines will return results. It typically lasts for 30min-2hrs then things work normally again. I've filed a fb bug ticket here http://developers.facebook.com/bugs/456910301017301?browse=search_509b0c1b72a008e55394686


text:
Q: Compilation error when declaring variables in BEGIN..END procedure PL/SQL I have a compile error that unable to declare variables in procedure PL/SQL which trying solutions from other sources. Can anybody help to check what is the problem?
CREATE OR REPLACE PROCEDURE add_vaccine
(p_id IN VARCHAR, d_id IN VARCHAR, p_vdate IN DATE, p_vaccinated IN VARCHAR)

AS

BEGIN

    DECLARE counter NUMBER(MAX);

    --Prompt user to input vaccination and visit detail
    DBMS_OUTPUT.PUT_LINE('Patient ID = ' || p_id);
    DBMS_OUTPUT.PUT_LINE('Doctor ID = ' || d_id);
    DBMS_OUTPUT.PUT_LINE('Date = ' || p_vdate);
    DBMS_OUTPUT.PUT_LINE('Vaccinated = ' || p_vaccinated);

END;
/

The code is unfinished but I'm stuck at the variable declaration.

A: Whenever you have a DECLARE section, you must have a BEGIN and END with some code.
If you don't need to declare inside, you can always declare them after AS.
CREATE OR REPLACE PROCEDURE STH()
AS
<DECLARE VARIABLES HERE>
BEGIN

DECLARE
<YOU CAN DECLARE HERE AS WELL>
BEGIN
    DBMS_OUTPUT.PUT_LINE('HELLO');
END;
-- Do something here
END;

A: There is an implict DECLARE before the first BEGIN in your procedure hence
SQL> CREATE OR REPLACE PROCEDURE add_vaccine
  2  (p_id IN VARCHAR, d_id IN VARCHAR, p_vdate IN DATE, p_vaccinated IN VARCHAR)
  3  AS
  4
  5      counter NUMBER;
  6  BEGIN
  7      --Prompt user to input vaccination and visit detail
  8      DBMS_OUTPUT.PUT_LINE('Patient ID = ' || p_id);
  9      DBMS_OUTPUT.PUT_LINE('Doctor ID = ' || d_id);
 10      DBMS_OUTPUT.PUT_LINE('Date = ' || p_vdate);
 11      DBMS_OUTPUT.PUT_LINE('Vaccinated = ' || p_vaccinated);
 12  END;
 13  /

Procedure created.


text:
Q: How to call a page from custom AppBar using onPressed? I have created a custom appBar in flutter MyApplicationBar.dart
I am including every page? now how to call Login Page   onPressed: () function
  class MyApplicationBar extends AppBar {
  MyApplicationBar({Key key, Widget title})
    : super(key: key, title:title, actions:<Widget>[
    IconButton(
        icon: new Icon(Icons.lock),
        tooltip: 'Login',
        onPressed: () {
          print('sssss');

        },
      ),
    IconButton(
              icon: const Icon(Icons.supervised_user_circle),
              tooltip: 'Accounts',
              onPressed: () {

              },
            ),
  ]);

}

A: There are more than one methods to navigate to new page
1. Easy way is Navigator.of(context).pushNamed(routeName, arguments: arguments)
but the best approach is to use because it is very clean and increase code readability.
And this is how professional do Navigation.
2. using  onGenerateRoute in your MaterialApp Widget
return MaterialApp(
      // remove debug banner
      debugShowCheckedModeBanner: false,
      title: APP_NAME,
      home: Home(),
      onGenerateRoute: (RouteSettings settings) {
        switch (settings.name) {
        case "abc":
              return CupertinoPageRoute(
                builder: (BuildContext context) {
                  return VideoTopics();
                },
                settings: settings);
        break;
}});

Now to navigate from any page to abc page just use this line of code
   Navigator.of(context).pushNamed("abc");

make sure the text you are passing in Navigator is same to as in onGeneratedRoute
so it is advisiable to use constants for such things


text:
Q: Is there any way to universally define the notion of $\text{Isomorphism}$? Suppose we want to give a very general definition of the term Isomorphism, first of all, we'll want an isomorphism to be a bijective function.
Informally, we want our function to preserve whatever 'structure' we're talking about, may it be: multiplication, addition, order if we're about ordered fields, or maybe adjacency if talking about graphs, etc.
However, after thinking about this for a few hours, I could not come up with a precise definition of the term which could fit every context.
Do you think such a definition is possible?

A: I think category theory answers the question. An isomorphism in a category is just a morphism which has a two-sided inverse.
Now, what is a morphism? This depends on the category you're working on. For example we have:

*

*the category of topological spaces, where continuous functions are the morphisms;

*the category of vector spaces, where continuous linear maps are the morphisms;

*the category of groups, where group homomorphisms are the morphisms;

*the category of differentiable manifolds, where smooth functions are the morphisms;

*the category of sets, where functions are morphisms,

*etc.

For example, homeomorphisms are the isomorphisms in the category of topological spaces (we even see once in a while people say that homeomorphic topological spaces are topologically isomorphic).

A: Well, since all your examples are first-order structures, let's look at model theory.
We consider structures of the following form: an underlying set $X$ ("domain") and a bunch of functions, relations, and constants on that set - denoted $\mathcal{M}=(X; ...)$.
In the background is a signature: a set of function, relation, and constant symbols. Really, $\mathcal{M}$ is a set $X$ together with an interpretation in $X$ of each of the symbols in the relevant signature. For instance, in the context of groups the signature (usually) has a binary function symbol, a unary function symbol (inverse), and a constant (identity).
Fixing a signature $\Sigma$, a homomorphims between two $\Sigma$-structures $\mathcal{M}=(X; ...)$ and $\mathcal{N}=(Y; ...)$ is a function $H$ from $X$ to $Y$ which preserves the signature; that is -

*

*For each constant symbol $c\in \Sigma$, $c^\mathcal{N}=H(c^\mathcal{M})$.

*For each $n$-ary function symbol $f\in\Sigma$ and each tuple $a_1, . . . , a_n\in X$, we have $H(f^\mathcal{M}(a_1, . . . , a_n)=f^\mathcal{N}(H(a_1),  . . . , H(a_n))$.

*And for each $n$-ary relation symbol $R\in\Sigma$ and each tuple $a_1, . . . , a_n\in X$, we have $R^\mathcal{M}(a_1, . . . , a_n)\implies R^\mathcal{N}(H(a_1), . . . , H(a_n))$. Note that this is not an "$\iff$".
Here expressions like "$f^\mathcal{M}$" denote the interpretation of the symbol $f$ in the structure $\mathcal{M}$.
I've been a bit imprecise above. More formally, we start with the signature $\Sigma$, and then a $\Sigma$-structure is a set $X$ (usually assumed to be nonempty) together with a map $\mathfrak{I}$ from $\Sigma$ to $$X\cup[\bigcup_{n\in\mathbb{N}}\mathcal{P}(X^n)]\cup[\bigcup_{n\in\mathbb{N}} X^{(X^n)}]$$ such that for each $n$-ary relation symbol $R$ in $\Sigma$, $\mathfrak{I}(R)\in\mathcal{P}(X^n)$, etc.
This is explained in detail in any good book on model theory.

OK, so what doesn't this capture?
Well, the most glaring example is something like a topological space - where you don't only have properties of elements, but also properties of sets of elements (e.g. "is open" is a property of sets of points). A topological space isn't really a first-order structure.
Now, we can salvage this! We can view a topological space as a structure, with underlying set the disjoint union of $\{$points$\}$ and $\{$sets of points$\}$, and structure given by the relation $\in$ and the predicate "is not open". Then if $\mathcal{M}$ and $\mathcal{N}$ are structures in this signature arising from topological spaces, a homomorphism in the sense above is exactly a continuous map.
But this is kind of unnatural, and it's around this point that category theory really starts to be the right way to do things.

A: I think your question is somewhat backwards.  Saying what the isomorphisms of a kind of structure are is part of what it means to even define that structure.  That is, if you're inventing some new kind of mathematical structure called a "widget", and you just define what a "widget" is, you haven't truly defined what "widget" means.  Only once you've also defined what an "isomorphism of widgets" is do you really know what a widget is.
Let's take the example of a group.  A group is an ordered quadruple $(G,\cdot, 1,{}^{-1})$, where $G$ is a set, $\cdot:G\times G\to G$ is a function, $1\in G$ is an element, ${}^{-1}:G\to G$ is a function, and these satisfy certain axioms ($\cdot$ is associative, $1$ is a unit for $\cdot$, and ${}^{-1}$ maps an element to its inverse with respect to $\cdot$).  The problem with this definition is that it contains too much information.  In particular, we don't actually care what the elements of $G$ are; we only care about how they interact with each other using the other parts of the definition.  To indicate that we don't care about this information, we define what an isomorphism of groups is.  Since an isomorphism of groups is allowed to replace the elements with other elements, that tells us that when we have a group, we don't really care what its elements are.  That is, our choice of definition of "isomorphism" clarifies what parts of the definition we're allowed to change without changing what the "group" really is.
In most familiar cases, "isomorphisms" follow the pattern of groups: the only information they "throw away" is the identities of the elements of the "underlying set" of your structure.  But sometimes you define isomorphisms to ignore more of the structure.  For instance, a smooth manifold is sometimes defined as a topological space with a covering by Euclidean charts with smooth transition functions.  But a "smooth manifold" doesn't actually care about exactly what atlas you put on it; some atlases give rise to the same manifold structure.  To clarify this, you must define what it means for a map to be an isomorphism of smooth manifolds (usually called a diffeomorphism).  (Alternatively, it turns out that any manifold does have a single atlas which is "canonical", namely the maximal atlas.  But in practice, you usually define individual manifolds by just giving some atlas, so it can be convenient to just let your definition allow any atlas.)
So, if isomorphisms are something you must specify when defining a kind of structure, what exactly can they be?  I would say that the only real restriction on what you can define "isomorphisms of widgets" to be is that they must form a groupoid whose objects are widgets.  That is, there is an operation called "composition" which takes isomorphisms $A\to B$ and $B\to C$ and gives isomorphisms $A\to C$, composition is associative, each widget has an isomorphism $A\to A$ which is an identity for composition, and for each isomorphism $A\to B$ there is an isomorphism $B\to A$ which is an inverse with respect to composition.  You should think of this as a "categorification" of the notion of "equivalence relation": isomorphisms are "ways that two widgets are the same", so the relation of being isomorphic (namely, that there exists an isomorphism between two widgets) should be an equivalence relation.  Indeed, the procedure described above of using isomorphisms to "throw away unnecessary information" is very similar to the common procedure of putting an equivalence relation on a set to forget about distinctions between its elements that you don't care about.  The axioms of a groupoid then correspond to the axioms of an equivalence relation: the existence of identities is reflexivity, the existence of inverses is symmetry, and composition is transitivity.  But the groupoid of isomorphisms carries more information than just the equivalence relation "isomorphic", because two widgets can be isomorphic to each other in multiple different ways.


text:
Q: iphone app runtime exception 2014-02-14 13:30:41.013 MyInvitationCard[2043:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CardIndexViewController 0x8d34d60> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key CardLabel.'
*** First throw call stack:
(
    0   CoreFoundation                      0x017435e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014c68b6 objc_exception_throw + 44
    2   CoreFoundation                      0x017d36a1 -[NSException raise] + 17
    3   Foundation                          0x011879ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
    4   Foundation                          0x010f3cfb _NSSetUsingKeyValueSetter + 88
    5   Foundation                          0x010f3253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
    6   Foundation                          0x0115570a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
    7   UIKit                               0x004d6a15 -[UIRuntimeOutletConnection connect] + 106
    8   libobjc.A.dylib                     0x014d87d2 -[NSObject performSelector:] + 62
    9   CoreFoundation                      0x0173eb6a -[NSArray makeObjectsPerformSelector:] + 314
    10  UIKit                               0x004d556e -[UINib instantiateWithOwner:options:] + 1417
    11  UIKit                               0x00347605 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
    12  UIKit                               0x00347dad -[UIViewController loadView] + 302
    13  UIKit                               0x003480ae -[UIViewController loadViewIfRequired] + 78
    14  UIKit                               0x003485b4 -[UIViewController view] + 35
    15  UIKit                               0x003623e2 -[UINavigationController _startCustomTransition:] + 778
    16  UIKit                               0x0036f0c7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
    17  UIKit                               0x0036fcb9 -[UINavigationController __viewWillLayoutSubviews] + 57
    18  UIKit                               0x004a9181 -[UILayoutContainerView layoutSubviews] + 213
    19  UIKit                               0x0029f267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    20  libobjc.A.dylib                     0x014d881f -[NSObject performSelector:withObject:] + 70
    21  QuartzCore                          0x03b512ea -[CALayer layoutSublayers] + 148
    22  QuartzCore                          0x03b450d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    23  QuartzCore                          0x03b44f40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    24  QuartzCore                          0x03aacae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    25  QuartzCore                          0x03aade71 _ZN2CA11Transaction6commitEv + 393
    26  QuartzCore                          0x03aae544 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    27  CoreFoundation                      0x0170b4ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    28  CoreFoundation                      0x0170b41f __CFRunLoopDoObservers + 399
    29  CoreFoundation                      0x016e9344 __CFRunLoopRun + 1076
    30  CoreFoundation                      0x016e8ac3 CFRunLoopRunSpecific + 467
    31  CoreFoundation                      0x016e88db CFRunLoopRunInMode + 123
    32  GraphicsServices                    0x036e89e2 GSEventRunModal + 192
    33  GraphicsServices                    0x036e8809 GSEventRun + 104
    34  UIKit                               0x00234d3b UIApplicationMain + 1225
    35  MyInvitationCard                    0x000070bd main + 141
    36  libdyld.dylib                       0x01d8170d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

A: Check your .xib file and look for "!" marks in outlets tab. Seems that you changed outlet name in .h/.m file but forgot to re-connect it in .xib.
See more information here.

A: Check your xib name you are giving when pushing your viewController. May be you are passing different xib name to a different viewController during its allocation.
Also do check your IBOutlet connections.


text:
Q: ListBox SelectedItem is always null When I click on an item in a ListBox it always returns null. Of course my ListBox is already filled :-)
My XAML-Code:
<Window x:Class="WpfTimeClock.AdminWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfTimeClock"
    mc:Ignorable="d"
    ResizeMode="CanMinimize"
    Title="AdminWindow" Height="527" Width="750">
<Grid>
    <ListBox x:Name="listBoxUsers" HorizontalAlignment="Left" Height="250" VerticalAlignment="Top" Width="200" Margin="10,10,0,0"/>
</Grid>
</Window>

My C#-Code:
TimeClockRepository<User> repUser = new TimeClockRepository<User>();

public AdminWindow()
{
    InitializeComponent();
    Loaded += AdminWindow_Loaded;
    listBoxUsers.PreviewMouseLeftButtonDown += ListBoxUsers_PreviewMouseLeftButtonDown;
}

private void ListBoxUsers_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    var item = sender as ListBoxItem;
    if (item != null && item.IsSelected)
    {
        // why is sender always null??
    }
}

private void AdminWindow_Loaded(object sender, RoutedEventArgs e)
{
    listBoxUsers.ItemsSource = repUser.Get().ToList();
    listBoxUsers.DisplayMemberPath = "UserName";
}

My sender item is always null, when i click on it. What is the problem? Thanks for your help!

A: You should handle ListViewItem, not ListBox. Just create handler for ListViewItem in ListView.ItemContainerStyle:
XAML:
<ListView ItemsSource={Binding YourItems}>
    <ListView.View>
        <GridView>
            <!-- Declare a GridViewColumn for each property -->
        </GridView>
    </ListView.View>
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListViewItem_PreviewMouseLeftButtonDown" />
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

Code-behind:
private void ListViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    var item = sender as ListViewItem;
    if (item != null && item.IsSelected)
    {
        //Do your actions
    }
}

A: You should use SelectionChanged event instead.
this.listBoxUsers.SelectionChanged += ListBoxUsers_SelectionChanged;

private void ListBoxUsers_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    // do your things with listBoxUsers.SelectedItem
    // If you want to click same item more than once, set SelectedIndex to -1 after use it.
}


text:
Q: What is required for HiDPI mode? I followed the directions in this question.  I've checked "Enable HiDPI display modes" in Quartz Debug, and I've rebooted and logged in again, but no HiDPI modes appear.  I've rerun Quartz Debug and confirmed that the checkbox is still checked.
Are there any other things that need to be set in order for this to work?  Are there any specific hardware requirements for this?
(I have 2 large displays, for example -- is there a limitation that it only works on single displays?  I can't think of any reason it would be, but I'm out of ideas.)
EDIT: I found something that suggested you need to log out of all accounts, not just the current one -- maybe something happens when all accounts are logged-out simultaneously?  But I tried that, too, and still do not see any HiDPI modes listed.
EDIT 2: According to this post, HiDPI can work on the 30" Cinema display (2560x1600 becomes 1280x800), so that's not the problem.  This screenshot shows HiDPI modes and an "Arrangement" tab (indicating multiple displays), so that's not the problem.  It even shows the mythical "1280x800 (HiDPI)" mode!

A: As I've mentioned in the other topic...
If the checkbox is already enabled, but it doesn't work, disable it, logout when prompted to, login again, re-enable it and at the next login you should find the HiDPI settings in the Displays settings.


text:
Q: bash string split and concatenate I have hundreds files need to loop through for an analysis using a bash script. One step I need to do is to split a long string and cat it as an output name. For example, suppose I have one string such like:
5018.a.Radiation_Induced_Lymphoma.Tumor__p53+_-.SL200300_SL200300.exome_1tier.mm10.kapa_re_cap_v6_3utr.final.bam

What I wanted is to rename it as two output file names such as:
5018.a.Radiation_Induced_Lymphoma.Tumor__p53+_-.SL200300_SL200300.exome_1tier.mm10.kapa_re_cap_v6_3utr.final_R1.fastq
5018.a.Radiation_Induced_Lymphoma.Tumor__p53+_-.SL200300_SL200300.exome_1tier.mm10.kapa_re_cap_v6_3utr.final_R2.fastq

The only changes are removing .bam from the original and cat _R1.fastq and _R2_fastq. Does somebody know how to realize it using bash commands?

A: somefile=blahblahblah.final.bam
foo "$somefile" "${somefile%.*}_R1.fastq" "${somefile%.*}_R2.fastq"


text:
Q: How to use jodaTime with hibernate I want to use JodaTime LocalDate with hibernate. I wrote this:
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "DATE_DEBUT", nullable = false)
@Type(type = "org.joda.time.contrib.hibernate.PersistentLocalDate")
private LocalDate dateDebut;

but it didn't work. I get this error :
Caused by: Exception [EclipseLink-7165] (Eclipse Persistence Services -   2.5.2.v20140319-9ad6abd):   org.eclipse.persistence.exceptions.ValidationException
Exception Description: The type [class org.joda.time.LocalDate] for the attribute [dateDebut] on the entity class [class ch.test.application.beans.mandat.Mandat] is not a valid type for a temporal mapping. The attribute must be defined as java.util.Date or java.util.Calendar.

Do you know why ?
Thanks

A: You can use Jadira
All you have to is add this as dependency and then anotae like this:
@Column
  @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
  private DateTime endTime;

For more info check their website.
There is another library that integrates Joda Time with Hibernate from Joda themselves. Here is the link. But personally I could not make it work for me.


text:
Q: Pygame-Space invaders bullets I'm sorry for editing this question. I really have a hard time explaining my question because this thing is really nerve wracking. I started about 3 weeks ago and my mind is already exploding. To summarize what I want, this is the code right here:
import sys
import pygame

pygame.init()

# Setting up a window
screen = pygame.display.set_mode((1200, 800))
screen_rect = screen.get_rect()

# Caption
pygame.display.set_caption("space shooter".title())

# Setting up the icon
icon = pygame.image.load("undertake.png").convert_alpha()
pygame.display.set_icon(icon)

# Identifying a Background
bg = pygame.image.load("bg.png").convert_alpha()

# Setting up the jet
jet = pygame.image.load("jet.png").convert_alpha()
jet_rect = jet.get_rect()
jet_rect.centerx = screen_rect.centerx
jet_rect.bottom = screen_rect.bottom

# Setting up 2 bullets
bullet = pygame.image.load("pixel_laser_red.png").convert_alpha()
bullet_rect = bullet.get_rect()
bullet_state = "ready"

# Moving the jet
def move_jet(x):
    jet_rect.centerx += x

# Changing the bullet state
def fire_bullet():
    global bullet_state
    bullet_state = "fire"
    screen.blit(bullet , (bullet_x - 28 , bullet_y +7) )

# Adding Boundaries
def boundaries():
    if jet_rect.left >= 1200:
        jet_rect.right = 0
    elif jet_rect.right <= 0:
        jet_rect.left = 1200

# Game Loop
while True:
    screen.blit(bg, (0, 0))
    screen.blit(jet, jet_rect)

    # EVENTS
    for event in pygame.event.get():
        # Quitting
        if event.type == pygame.QUIT:
            sys.exit()

        # KeyStrokes
    pressed = pygame.key.get_pressed()
    jet_xincrement = 0
    if pressed[pygame.K_RIGHT]:
        jet_xincrement += 3
    if pressed[pygame.K_LEFT]:
        jet_xincrement -= 3

    if pressed[pygame.K_SPACE]:
        if bullet_state == "ready":
            bullet_x = jet_rect.centerx
            bullet_y = jet_rect.top
            fire_bullet()

    if bullet_state == "fire":
        bullet_y -= 3
        screen.blit(bullet, (bullet_x - 28, bullet_y + 7))
        if bullet_y < 400:
            bullet_state = "ready"

    boundaries()
    move_jet(jet_xincrement)

    pygame.display.flip()

My question: When I hold the space bar the fire_bullet function is called which changes the bullet_state to "fire" and prints it in my required position, when the bullet state is "fire" the bullet is printed each time in the loop incremented by -3 in the y direction until it reaches 400 where the bullet_state is then changed to ready, but the same bullet object is reseted I want a new bullet to shoot when the previous bullet reaches 400.
I hope that makes my point clear and I'm really sorry for any confusion

A: I would recommend creating a deque list for the bullets (can also be done with an array or another list structure), and keeping track of a limitation of how many active bullets are allowed for the player at one time. Keep track of the "oldest" (first item in the list) and the latest (last item) in the list - that way you can just check if the oldest bullet has left the screen, and remove it, if it has.
There are two approaches to limiting the number of bullets on the screen, either setting a max number of allowed bullets, or controlling the interval with which the player is allowed to fire a new bullet. The latter option gives better granularity of control, of the shooting power of the player in my opinion.
Further more, it is beneficial to encapsulate game objects such as bullets, player and enemies in objects. It gives greater convenience when writing the code, and promotes readability and reusability.
To summarize, I would introduce the following variables in the game code that you have posted:

*

*milliseconds_between_allowed_shots (how many milliseconds need to pass before the player can fire another shot)

*last_shot_time (keeping track of when the last shot has been fired)

*bullets a list structure for holding all the active bullets.

The logic would then be, if the space bar is down:

*

*If the amount time since last_shot_time is greater than the minimum amount of time allowed before another shot can be fired (milliseconds_between_allowed_shots)

*

*Fire another bullet, add it to the end of the list of bullets

*Set the last_shot_time to the current time.

Here's a bit of a crude example of how to write it (this will probably not run, I have not tested it - but it should give you the idea):
import sys
import pygame
from collections import deque

pygame.init()

# Setting up a window
screen = pygame.display.set_mode((1200, 800))
screen_rect = screen.get_rect()

# Caption
pygame.display.set_caption("space shooter".title())

# Setting up the icon
icon = pygame.image.load("undertake.png").convert_alpha()
pygame.display.set_icon(icon)

# Identifying a Background
bg = pygame.image.load("bg.png").convert_alpha()

# Setting up the jet
jet = pygame.image.load("jet.png").convert_alpha()
jet_rect = jet.get_rect()
jet_rect.centerx = screen_rect.centerx
jet_rect.bottom = screen_rect.bottom

# Setting up the bullets
bullet = pygame.image.load("pixel_laser_red.png").convert_alpha()
bullet_rect = bullet.get_rect()

# deque structure for holding the current bullets
bullets = deque()
milliseconds_between_allowed_shots = 250
last_shot_time = 0

# a class for defining a bullet (could hold more, like bounds, graphics, etc.
class Bullet:
    x = 0
    y = 0

# Moving the jet
def move_jet(x):
    jet_rect.centerx += x

# fire a bullet, and push the bullet to the collection of bullets
def fire_bullet():
    global last_shot_time
    last_shot_time = pygame.time.get_ticks()
    new_bullet = Bullet()
    new_bullet.x = jet_rect.centerx
    new_bullet.y = jet_rect.top
    bullets.push(new_bullet)
    screen.blit(bullet , (new_bullet.x - 28, new_bullet.y + 7))

# Adding Boundaries
def boundaries():
    if jet_rect.left >= 1200:
        jet_rect.right = 0
    elif jet_rect.right <= 0:
        jet_rect.left = 1200

# Game Loop
while True:
    screen.blit(bg, (0, 0))
    screen.blit(jet, jet_rect)

    # EVENTS
    for event in pygame.event.get():
        # Quitting
        if event.type == pygame.QUIT:
            sys.exit()

    # KeyStrokes
    pressed = pygame.key.get_pressed()
    jet_xincrement = 0
    if pressed[pygame.K_RIGHT]:
        jet_xincrement += 3
    if pressed[pygame.K_LEFT]:
        jet_xincrement -= 3

    if pressed[pygame.K_SPACE]:
        current_time = pygame.time.get_ticks()
        # only allow firing a bullet, if sufficient time has passed
        if current_time > last_shot_time + milliseconds_between_allowed_shots:
            fire_bullet()

    # move all bullets, and render them
    for a_bullet in bullets:
        a_bullet.y -= 3
        screen.blit(bullet, (a_bullet.x - 28, a_bullet.y + 7))

    # remove oldest bullet, if it is offscreen (TODO: check list length > 0)
    if bullets[0].y <= 0
        bullets.popleft()

    boundaries()
    move_jet(jet_xincrement)

    pygame.display.flip()

I hope this answers your question. Let me know if you need more input, or want another type of answer. Or if it was helpful.

A: Use pygame.time.get_ticks() to get the time in milliseconds and define a minimum time interval (bullet_interval) for ths bullets. Set a variable which stores the time when the next bullet is allowed to be fired (next_bullet_time). Increment the time when a bullet is fired:
bullet_interval = 300 # 300 milliseconds = 0.3 seconds
next_bullet_time  = 0

while True:
    current_time = pygame.time.get_ticks()

    # [...]

    if pressed[pygame.K_SPACE]:
        if bullet_state == "ready" and current_time > next_bullet_time:
            next_bullet_time = current_time + bullet_interval

            bullet_x = jet_rect.centerx
            bullet_y = jet_rect.top
            fire_bullet()


text:
Q: Get player details from Google Play Games Service storage I have an android game configured with Google Play Games API. API works perfectly and user can sign in, use leaderboard, earn achievements, etc. Now i want to access Player details if possible like email, name, age who are already signed in the game.
I am doing this right now from the app itself, what if i want to access this data remotely?
Also is this possible to get all connected player details even without having their individually Player ID? For example, Getting a list of all the users who are signed in through web?

A: From here: https://developers.google.com/games/services/web/api/players/get
You need to send an HTTP GET request with playerId as
GET https://www.googleapis.com/games/v1/players/playerId

This request requires authorization with the following scope
https://www.googleapis.com/auth/games

If successful, this method returns a Players resource in the response body.
Here's the JSON template for a Player resource:
https://developers.google.com/games/services/web/api/players#resource


text:
Q: Other than stabbing it with an enchanted, 1000-year-old, goblin-made sword, how else can I kill a Basilisk? So today I found out that my best friend's sister got taken by a beast into a place called the Chamber of Secretions.
I went down there together with my best friend Wazlib to try and rescue her using only two magical wooden sticks (one was broken) and a hysterical teacher.
Unfortunately along the way I get separated from them and I'm left with only one wand. Anyways, it gets stolen by a memory-ghost later on and I couldn't be bothered to wrest it back just yet.
No phoenix arrives to save the day. No magical hat containing a sword appears.
Is there another sure-fire way to kill a Basilisk other than using the Sword of Gryffindor (and the help of a phoenix)?
If they're similar to snakes, could I just conjure a few giant mongooses to help me kill it, or alternatively Avada it to death? Does Rowling answer this?

For those with a low sense of humour... read on

 So, I was wondering if the Basilisk in the Chamber of Secrets had any other weaknesses other than having to be stabbed by the Sword of Gryffindor. I think it's a bit ridiculous that Harry and Ronald decide to just waltz into the Chamber armed with only two wands, trying to save Ginny from the "likely" Basilisk in there.  If Fawkes didn't come, how else could the Basilisk have been killed?

A: From Chamber of Secrets (emphasis mine):

It was a page torn from a very old library book [...]
  Spiders flee before the Basilisk, for it is their mortal enemy, and the
  Basilisk flees only from the crowing of the rooster, which is fatal to it.

So, the Basilisk has no natural enemies other than the rooster (so the mongooses won't be any good). I don't think something like Avada Kedavra would be enough to kill it though, but I can't remember any reference in the books.

A: Possibly a mirror.
Certainly in the legends about basilisks (and likewise the similar cockatrice, who is also killed by rooster crows and may be a variant on the same original myth), it was often held that basilisks were not immune to their own petrifying gaze, and therefore a direct stare at a mirror would cause it to suffer the same fate as its victims.
One way that Rowling differs from that legend (and of course, like all legends there are variations so there's no "real" version), is that mirrors weaken the force of the attack. That does not mean that it is immune to that weakened attack, so potentially you could use a mirror to put one into a magical coma, and then while it was safely in that state just cut it into nice manageable chunks.
This isn't confirmed or denied canonically, so since Rowling says conventional armies would defeat wizards in a fight, which presumably includes whatever creatures they could recruit to fight with them, I'd recommend a large-caliber machine-gun fired at long-range, or maybe a few grenades.

A: Well, there are a few ways (definitely not foolproof) I can think of:

*

*Thanks to the memory ghost guy, you can talk to snakes. And if you have a good sense of humour, you can crack one or two great rooster jokes and let him DIE laughing.

*As the dark lord suggested in comments as well, if you know swimming, jump into water. The basilisk will follow suit and if he sees his own eyes in the reflection, he'll die.

*As you can talk to snakes, tell him that we are living in 21st century and slavery is over and the heir is making him a fool by letting him follow thousand years old practice (slavery), he might spare you and beat the crap out of the Slytherin heir.

*As its almost 2 years since you have joined school now and there's quite some chance that you have interacted with Cedric Diggory. If he might have told you about Twilight, you can tell the full Twilight story to basilisk. He will automatically die of boredom.
P.S. : Please ignore if you find it odd that I'm using he/him rather than it for Basilisk. I am from India. We don't write animals/birds as non-livings.

A: While the crow of a rooster is a sure-fire way to kill a Basilisk, there is no sense in the books that Basilisks have any special defenses.
After all, Fawkes was able to poke out its eyes, which at least suggests that it would be susceptible to the Conjunctivitis Curse. Though, "susceptible" might be a little strong, since you usually need to be looking at the target of a curse, and that's probably not the best play when taking on a creature that kills you if you see its eyes.
It is also not stated that Basilisks have any special magical defenses the way Giants and Dragons mostly do. After all, most curses involve looking at the target, so the Basilisk's death glare would seem sufficient defense against them.
Given the lack of details, I would say that it's perfectly reasonable to assume that a Basilisk is a very dangerous and large snake. And thus, outside of rooster crowing, they would tend to be vulnerable to things that large snakes are vulnerable to: crushing, chopping, etc. I rather suspect that a sword would not need to be made of Goblin silver to be capable of cutting the head off of a Basilisk.
Though the sword probably wouldn't survive, due to the incredibly destructive Basilisk venom. But it might last long enough to do the job. Though this would involve getting within fang-range of the Basilisk, which also is quite fatal unless Phoenix tears are handy.
Mongooses would likely not be helpful because Basilisks can kill with a look. Also, Basilisks are quite large, and the mongoose is not.
The big problem here is that you posed this as a wand-less fight. That tends to narrow down ones Wizarding options pretty drastically. So unless there were weapons lying around, or one could lure the Basilisk into some kind of trap (and do so while effectively blind), this encounter will probably not end well. While the Basilisk would likely be injured by hurled rocks, hitting targets while blind is quite hard.


text:
Q: Inject text dynamically to facebook's share dialog via content-script - javascript
*

*my app is a chrome extension

*I have a content-script injected to Facebook share pop-up.
I successfully manage to add text to the input via DOM manipulation,
but when I click share, it clears the input and then share the link.. any idea why?

A: Best practice for FB share is via Open Graph, http://ogp.me/

    <meta property="og:title" content="OG title" />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="http://domain.com" />
    <meta property="og:image" content="http://domain.com/fb-image.png" />
    <meta property="og:description" content="OG description" />

You can also try FB sharer, but keep in mind that it's deprecated and not advised to use.
fb share


text:
Q: Converter does not seem to be used when component has a renderer As known, we can easily write our custom conveter and register it to the component as follows:
<f:converter converterId="cId" />

or
<f:converter binding="#{mybean}" />

depneds on our needs. But now consider the source code of UIInput that's responsible for the exact conversion (comments ommited):
 protected Object getConvertedValue(FacesContext context,
                                       Object newSubmittedValue) throws ConverterException {
        Renderer renderer = getRenderer(context);
        Object newValue;

        if (renderer != null) {
            newValue = renderer.getConvertedValue(context, this,
                 newSubmittedValue); // <----------- 1
        } else if (newSubmittedValue instanceof String) {
            Converter converter = getConverterWithType(context);
            if (converter != null) {
                newValue = converter.getAsObject(context, this,
                     (String) newSubmittedValue);// <----------- 2
            } else {
                newValue = newSubmittedValue;
            }
        } else {
            newValue = newSubmittedValue;
        }
        return newValue;
    }

So, it's clear that we make a choise about what converter we should use. Moreover, as far as I understand, if a component has a separated Renderer we can't apply our custom converter specified as a tag in a facelet (because of the if(renderer != null){...} else if(newSubmittedValue instanceof String){...}). For instance <h:inputText /> the component class is UIInput, and also it has a custom com.sun.faces.renderkit.html_basic.TextRenderer, therfore getRenderer(context) returns something that's not null. So, we should skip the convertion specified by our converter tag even if we define it as
<h:inputText  value="#{myBean.prop}"/>
    <f:converter inding="#{bean}" />
</h:inputText>

The inputText has a custom renderer, so the converter shouldn't do anything specified here:
 Converter converter = getConverterWithType(context);
 if (converter != null) {
     newValue = converter.getAsObject(context, this,
           (String) newSubmittedValue);// <----------- 2
 } else {
       newValue = newSubmittedValue;
 }

Couldn't you explain it? How does the conversion actually work and what's the difference between Renderer's converter and our custom converter

A: Actually, the renderer does the same. See also javadoc of Renderer#getConvertedValue().

Attempt to convert previously stored state information into an object of the type required for this component (optionally using the registered Converter for this component, if there is one). If conversion is successful, the new value should be returned from this method; if not, a ConverterException should be thrown.

In case of <h:inputText> in Mojarra, source code can be found in HtmlBasicInputRenderer.
This design allows the renderer to take full control over the conversion step and if necessary manipulate this step. Note that it's possible to declaratively (via faces-config.xml) override the renderer of a (standard) component without changing the component itself in the view. Also note that the term "custom renderer" in your question is not entirely right. It's just the standard renderer. We talk about a "custom renderer" only when the web application provides its own, overriding the standard one.


text:
Q: GPO - Default File Association from user/machine combination I have a GPO that uses ComputerConfiguration\Policies\AdminstrativeTemplates\WindowsComponents\FileExplorer\Set a default associations configuration file to set the file associations for a particular computer.
Is it possible to control this by a combination of user and computer, rather than just by computer. eg if UserA logs onto Computer1, they get one set of file associations, but if UserB logs onto Computer1, they get a different set? I realise I would need multiple GPOs for this setup.
I've tried creating a security group with the users I want to target, but the policy isn't being applied because Filtering:  Denied (Security). I guess this is because it's a computer level policy, and not a user level one? Thanks.
UPDATE
In response to @OOOO's comment, there are some settings, such as file associations, that are implemented via a computer policy, but that are also relevant to a particular user.
Imagine the situation that I have two different PDF readers installed on the same machine. A certain group of users expect to use Sumatra PDF because it is more secure (no javascript processing), whereas another group need Acrobat Reader DC because it can handle encrypted attachments. In this situation it makes perfect sense to be able to implement a GPO based on which computer a user is logged in to, or rather, which user is logged into a particular computer.
UPDATE 2
I have managed to make this work (I think!), by creating a security group, and adding both the users and the computer into that group. The GPO is applied, and seems to work for the users I have specified, but I am wondering if the computer policy part is working because the computer is in the security group, rather than the combination of computer and user.
Does anyone know if the computer policy is applied because the user and computer are part of the group, or is it just because of the computer's membership in said group?
1 hour left on the bounty. Does anyone want 50 points for answering the question below?!
Does anyone know if the computer policy is applied because the user and computer are part of the group, or is it just because of the computer's membership in said group?


text:
Q: Create EventMessage in Exchange Office 365 Have been getting trouble with one issue which I guess someone can help me out. So we are pragmatically migrating emails from Office 365 to Office 365 and one scenario is in inbox we have got EventMessage type items. Here is a scenario;
Migration Happening from User A to User B
User A got an event invitation from other account (Lets say User C). So as part of migration we have to migrate the invitation which was received by User A from User C.
Using EWS when we try to read inbox this item is being read as MailMessage and it gets migrated however it becomes NORMAL Email instead of Event Invite. And we do not see any way to create an item in inbox with EventMessage type. Does anyone has any solution? We are happy to use REST API if that is possible,

A: Unfortunately, this scenario isn't covered today by Outlook REST APIs that you are using.  EventMessage can only be generated by the service, as part of workflows that are kicked off when a new meeting is created on a calendar and when someone responds to the invite.  This is by design, because there business logic in these workflows dealing with delegates, and making sure the right actions happen when a meeting is updated or cancelled.  So, there is no way for you to create this event message by doing a POST on a message collection.
For your migration scenario, your best bet may be to use our older EWS SOAP APIs - ExportItems and UploadItems and see if that meets your needs.


text:
Q: Configuring an Ubuntu DHCP server for dhcp scopes that are not directly connected I am currently configuring an Ubuntu server with ISC DHCP.
My goal is for it to hand out IP Addresses to several client subnets which are not directly connected to this DHCP Server. I have configured DHCP Relaying on the gateways of these remote networks, and I can also see the DHCP REQUESTS coming in on my server.
THe problem I have now is that unless I configure an ip address on the servers interface within those remote networks I am unable to start the isc-dhcp-server service.
Does anyone have experience setting up an isc dhcp server to serve ip addresses to clients that exist in remote networks, ie not directly connected to the servers interface?
Thanks.


text:
Q: How to Get a Vector Layer to add to a QGIS Project I used QGIS a little bit a few years ago and used some layers for my city that I had. I have a simple project that I would like to use it for and am having a little problem. I would like to simply get an orthophoto of a parcel that we recently purchased. I found this thread.
It is practically what I want to do.  I just want the data for another township in the same state.
I can set up the coordinate system and know the WMS layer I would like to use for the orthos, but, the instructions say to add a vector layer of the specific area I'm interested in.  The example gives Acme Township as an example.  The instructions don't tell me where I can find the layer so I can add it.  In my case I am looking for Mecosta Township, MI.
Can anyone tell me where I might be able to find some sort of shapefile for Mecosta Township. If the layer includes parcels that would be ideal.

A: You don't need a vector layer first to add a WMS layer. Just ignore those instructions. If you post the link to the WMS you are planning to use, we can verify if it works.


text:
Q: Virtualization is not working anymore after installing WSL on the host I run windows 10 version 20H2 build 19042 and use VMWare Workstation version 16.2.1 as a hosted hypervisor. I installed WSL on one of the VMs and activated nested virtualization. It was perfectly working until I installed WSL on my host. I got the below error when trying to power on the VM:
Virtualized Intel VT-x/EPT is not supported on this platform.
Continue without virtualized Intel VT-x/EPT?s
Both Yes and No answers couldn't help powering on the VM.
Then I uninstalled WSL on the host and disabled "Windows Subsystem for Linux" from windows features list, but still got the same error.
I am only able to power on the VM if I untick "Virtualize Intel- VT-x or AMD-V/RVI" in VM CPU setting which is not the case, because I need nested virtualization in the VM. Could anyone please help me solving this issue?

A: Try disabling hyper-v virtualization through bcdedit.
You will probably not be able to do both WSL2 and VMWare stuff at the same time.
EDIT:  Mr. @Ramhound had this to say (and he is almost never wrong)

VMWare and Hyper-V should be able to coexist on the same system, certainly, the version of VMWare should allow it.

Do you REALLY NEED WSL2 vs WSL1?  WSL1 doesn't require virtualization. I myself use WSL1 and the ONLY THING that it can't do for me is mount other file systems or run kernel mode stuff like docker.  The I/O is also a little slow (but mostly unnoticeable).
Search google for "disable virtualization bcdedit".
I myself use the boot menu that allows me to turn it on or off at boot time.  You will find that in your search if that is what you seek.
I use VirtualBox and some of the microsoft virtualization technologies and they don't like each other so I need the ability to turn it on or off.
I hope this solves your problem.


text:
Q: How to read SQL Server COUNT from SqlDataReader I'm trying to find the count for a table using C# SqlDataReader but I keep getting

invalid attempt to read when no data is present

My code:
string sql = "SELECT COUNT(*) FROM [DB].[dbo].[myTable]";

SqlCommand cmd = new SqlComman(sql, connectionString);
SqlDataReader mySqlDataReader = cmd.ExecuteReader();

int count = mySqlDataReader.GetInt32(0); // Here is where I get the error.

I know I have a valid connection to the database because I can read and write to it in many places, what's special about the COUNT(*) that I cannot read it properly? How do I get the int count to be populated?

A: You have to read it:
if (mySqlDataReader.Read()) {
  count = mySqlDataReader.GetInt32(0);
}

Alternatively, you can just use ExecuteScalar:
int count = (int)cmd.ExecuteScalar();

which is defined as:

Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.

A: ExecuteScalar is what you require.


text:
Q: How to load one controller action in other phtml file, in Zend I have a controller 'test' with action 'index'.
Now i need to load another controller action in this  index.phtml
for example index(controller) & add(action)
How can i do that?

A: in your controller you can use the following code to change the controller and action
$this->_forward('someaction', 'somecontroller');

to include another phtml from view you should use following code in your phtml
<?php  echo $this->render("somecontroller/common.phtml");?>

If you want to use some common function in some controller keep it separate and call from every action


text:
Q: Use Docker to keep track of software versions/installations? I have an data processing application which is updated on a regular basis. This application has a bunch of dependencies which are also updated every now and then. However, different versions of the software (+dependencies) might produce different results (this is expected). The application is run on a remote computer and it can be accessed through a Web page. Every time the user uses the Web page to do some processing she/he also chooses which version of the software he/she wants to use.
Now I am trying to decide which is the best way of keeping track different software (+dependencies) versions. The simplest way of course is to just compile and install each version of my software and its dependencies in a different folder, and then based on the request the user sends, the appropriate folder is selected. However, this sounds very clunky to me. So I thought I could use Docker to keep track of the different software versions. Do you think that it is a good idea? If yes, what is most appropriate to do every time I have a new version of the software (and/or dependencies): 1) Create a new container from scratch with the new version (and end up having multiple containers), or 2) Update the existing container and commit the changes? (I suppose I can access the older commits of the container, right?)
PS: Keep in mind that the reason I looked into Docker and not a simple virtual machine solution is that the application I am running is a high-performance GPU-based software.

A: Docker is a reasonable choice.  Your repository would contain all of the app versions you wish to publish.  Note, you will only realize savings if you organize the resulting app filesystem into layers, of which the lower layers are the least likely to change between versions.  This will keep the storage requirements at a minimum.
Then you have to decide how you will process each job.  A robust (but complex) solution would be to have one or more API containers which take in processing jobs from your user and "dole" them out to worker containers (one or more from each release version).  This would provide the lowest response latency and be non-blocking.  You can look at different service discovery models to see how your "worker" containers can register with your "manager" containers.  This is probably more than you'd like to bite off, but consider using a good key-value database (another container!) like etcd or a 3rd party service discovery tool like zookeeper/eureka/consul.
A much simpler model would have a single API container with one each of the release containers created, but not started.  The API container would start, direct, and then stop the appropriate release container.  You would incur the startup latency, but this is the least resource intensive... and easiest to manage.  But this is a blocking operation.
Somewhere in the middle, but less user friendly is to have each release container running but listening on different host ports (the app always sees the same port).  The user would would connect to the port which is servicing the desired release of the app.  You'd have to provide some sort of index to make this useful.


text:
Q: Accessing a common field from Go generics with existing packages I'm trying to create a generic function that creates k8s resources (custom and built-in) using Operator SDK.
package common

import (
    "context"
    "reflect"
    "time"

    "k8s.io/apimachinery/pkg/api/errors"
    "k8s.io/apimachinery/pkg/runtime"
    "k8s.io/apimachinery/pkg/types"
    ctrl "sigs.k8s.io/controller-runtime"
    "sigs.k8s.io/controller-runtime/pkg/client"
    "sigs.k8s.io/controller-runtime/pkg/log"
)

type Reconciler interface {
    client.Reader
    client.Writer
    GetScheme() *runtime.Scheme
}

func EnsureResource[T client.Object, P client.Object](r Reconciler, ctx context.Context, res T, parent P) (ctrl.Result, error) {
    log := log.FromContext(ctx)

    existing := res
    if err := r.Get(ctx, types.NamespacedName{Name: res.GetName(), Namespace: res.GetNamespace()}, existing); err != nil && errors.IsNotFound(err) {
        ctrl.SetControllerReference(parent, res, r.GetScheme())

        if err = r.Create(ctx, res); err != nil {
            log.Error(err, "failed to create resource", "Name", res.GetName(), "Namespace", res.GetNamespace())
            return ctrl.Result{}, err
        }
        return ctrl.Result{RequeueAfter: 1 * time.Second}, nil // created successfully, requeue
    } else if err == nil && !reflect.DeepEqual(res.Spec, existing.Spec) {
        // exists already but modified
        r.Update(ctx, res)
    } else {
        log.Error(err, "couldn't fetch existing resource", "Name", res.GetName(), "Namespace", res.GetNamespace())
        return ctrl.Result{}, err
    }

    // already exists, finish reconcile
    return ctrl.Result{}, nil
}

The creation part works perfectly and can create any k8s resource. Now I am working on the part that detects updates to an existing resource. In the middle if block, I need to check if the Spec fields of res and existing are DeepEqual, but I can't imagine a way of accessing them with generics.
client.Object is of course in k8s package. Also, some resource definitions that will be used as T and P will be from k8s api, and some were Custom Resources created by me, so not sure if I can use an interface here.
Is there a reasonable way to achieve this?
Alternatively, is it even necessary to check for updates to an existing k8s resource and only propagate if necessary? For example, if I get a reconciliation event, but there is no difference between existing and new Specs, then will calling r.Update trigger reconciliation on all child resources?


text:
Q: Shader graph connections not visible in Unity3D About a week ago I opened shader graph in one of my projects when I noticed the connections between nodes are just gone (like shown in the image). The shader still works just fine as if the connections are there, but it's impossible to work with since they are not visible. Today I have noticed that the Visual effect graph also lacks the connections. The problem started on Unity 2021.3.6f1, then I upgraded to Unity 2022.1.22f1 and the problem remains. Even if I create a new project I still can not see any connections. I am working on Macbook pro 2017. Any help would be appreciated.
shader graph without connections
I tried restarting computer, reinstalling Unity Editor, downgrading to an older version of Unity Editor and creating a blank project but nothing fixed the problem.

A: I experienced this same issue in Unity 2021.3.11f1, and confirmed the bug in multiple projects that were previously fine (only one of which was recently changed).
What MacOS version are you running? My best guess is that MacOS Ventura 13.1 broke some versions of Unity, as upgrading from macOS Monterey was the biggest change to my system this week (2019 MacBook Pro 16").
The following steps appear to have resolved the issue for me (so far so good):

*

*Reboot the computer (just to be sure)

*Backup the project (I just created an archived duplicate)

*Install Unity 2021.3.16f1 (the latest LTS release)

*Delete the project library (in case there's something weird cached)

*Open the project in the new version of Unity (which also regenerates the library)

I am now able to edit shader graphs again. Of note, deleting the library and regenerating in 2021.3.11f1 did not fix the issue. Only opening it and regenerating the library in 2021.3.16f1 worked for me.
I did not test leaving the old library intact while opening the project in the newest LTS version of Unity; it's possible regeneration isn't necessary, but it does seem like the safest bet. Especially if you didn't try removing the library before upgrading the project to Unity 20221.22f1 and you're still experiencing issues. You might try deleting the library to see if that resolves the issue now, without trying to downgrade to 2021.3.16f1?
There's a post over on the Unity Answers support site about this issue as well, but the login system appears to be broken (the irony!), so I can't respond there. https://answers.unity.com/questions/1927887/shader-graph-connections-not-visible.html


text:
Q: Is there a one-liner closure function in Python? I've been making good use of this function that usually define anytime I need because it's so small:
def func(_lambda, *args):
    return _lambda(*args)

i.e.
[func((lambda x: (("fizbuz" if x%5==0 else "fiz")
    if x%3==0 else ("buz" if x%5==0 else x))), x)
    for x in list(range(1,101))]

Is there a built-in equivalent function to this in Python?

A: Take a look at functools.partial (docs).
Broadly, you're looking at something like this:
from functools import partial

def func(*args):
    # your logic here

myfunc = partial(func, *args)

It's possible to pass additional arguments to myfunc, if needed; the example from the docs demonstrates this well:
>>> from functools import partial
>>> basetwo = partial(int, base=2)
>>> basetwo('10010')
18

None of this is necessary for your case, since moving your fizzbuzz logic out of the list comprehension and into a separate function allows you to use it like this (which, in my opinion, is much easier to follow):
[fizzbuzz(x) for x in range(1, 101)]

(The partial is a handy trick to have up your sleeve though.)

A: Python 3 no longer has an apply function (though Python 2 did).
The list comprehension eliminates the need for this use of the function. Just use the body of the function directly.
[("fizbuz" if x%5 == 0 else "fiz")
 if x%3 == 0
 else ("buz" if x%5 == 0 else x)
   for x in list(range(1,101))]

This is also more efficient, as you are no longer repeated calling a user-defined function.


text:
Q: poppler pdfunite cannot merge encrypted PDF files, how to remove encryption? (no password needed to open) I have some PDF files which I want to merge into one. I typically use pdfunite from the Poppler PDF toolkit to do this.
However now I'm getting this error:

Could not merge encrypted files ('foo.pdf')

When I run exiftool foo.pdf to see its properties, it does mention this:

Encryption                      : Standard V1.2 (40-bit)

I don't fully understand how encryption in PDF files work or what it's supposed to do, but I can open and read this particular file without entering any password. I can open the file in macOS Preview, no problem. I can convert the PDF into a PNG image using Poppler's own pdftoppm tool, no problem.
How do I override or remove this encryption, so I can merge this PDF file with other PDFs using Poppler's pdfunite ?
In case this encryption is just a metadata property, I already tried removing all metadata using exiftool like this:
exiftool -all= -overwrite_original foo.pdf
And exiftool has no problem removing the metadata. But the resulting file is still encrypted and pdfunite can't process it.

A: In order to prepare files reported as encrypted for pdfunite, install the qpdf utility and run the following command:
qpdf --decrypt "in.pdf" "out.pdf"
or qpdf --decrypt "in.pdf" --replace-input to overwrite the original file, which appeared safe to do during my experiments.
Then, the files can be merged using pdfunite as usual.

A: I have had the same problem with PDFv1.6 files.  I was able to resolve by downgrading to PDFv1.4 using: "gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -o output.pdf input.pdf". As described in https://superuser.com/questions/184288/how-to-convert-a-pdf-document-to-an-older-version .
I had been using pdfunite to combine files at different PDF versions and think the PDFv1.6 file had some kind of signature in it.


text:
Q: How to access the resource files under a self-defined resource directory? The Android Project Resource directories are located at,
app/src/main/res/drawable
app/src/main/res/layout
app/src/main/res/values

...
Suppose I would like to add a source file as,
app/src/main/res/myRes/res001.xml

Is it possible to read the resource info from my code? or my resource files are strictly restricted to the supported resource directories?

A:
Suppose I would like to add a source file as app/src/main/res/myRes/res001.xml

You should get a compile error, as you cannot invent new resource types. Either put that file in res/xml/ (which can handle any sort of XML), res/raw/ (which can handle any sort of file), or assets/.

A: You'll have to decide on a type.
Androids resource system have specific directories for specific resource types. You can't just 'add a resource', you have to decide on the type, for example:

*

*a layout file res/layout/main.xml

*a generic XML file (which will be compressed) res/xml/somedata.xml, or

*a raw type (which will also be compressed, unless you name it with an uncompressable extension, like for example MP3) res/raw/mydata.json

That being said you can make gradle do anything, like for example include several resource directories, like main/res and release/res

A: Custom resources are not supported by Android. You must use any of the predefined structure folders of Android. If you still would like to add custom resources use /res/xml for xml resources and /res/assets for all other resources like fonts, text files etc.
This link may help


text:
Q: The value of the selected radio button is empty after adding a jQuery This is my last attempt to solve the problem of my Radio button scenario. I can't figure out how to select one button only. (By the way I can't use RadioButtonList cause it doesn't allow html codes inside its block so it doesn't suit me).
I have a list of pictures and radio buttons that are selected in a ListView as follows:
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource_BGlist">
        <ItemTemplate>
            <input id="Radio1" name="BG_list" type="radio" runat="server" value='<%# Eval("BG_fileName") %>'/>
            <img alt="" style="width:150px" src="/Images/Editors/BG/<%# Eval("BG_fileName") %>">
        </ItemTemplate>

    </asp:ListView>

Unfortunately the ListView mechanism assigns a different name to each radio button behind the scene which means that I can select multiple radio buttons. I want to be able to select one button only.
So I added the following script:
<script type="text/javascript">
    var inputElements = document.getElementsByTagName("input");
    for (var inputName in inputElements) {
        var input = inputElements[inputName];
        if (input.type === "radio") {
            input.name = "BG_list";
        }
    }

Now I can select one single button BUT it created another problem in codebehind. The value of the selected button is always empty. Why? Can anyone see the error?
CODE BEHIND
foreach (ListViewItem itemRow in this.ListView1.Items)
                {
                    //RadioButton radioBtn = (RadioButton)itemRow.FindControl("Radio1");
                    var radioBtn = (HtmlInputRadioButton)itemRow.FindControl("Radio1");

                    if (radioBtn.Checked)
                    {
                       // Do Stuff
                        //Response.Write(radioBtn.Value);
                    }
                }

A: You can use jquery where deselect all radio button except the clicked one, see below jquery :
$(document).ready(function (){
    // bind change event for radio button
    $('input[type=radio]').change(function(){
        // remove checked attribute for all radio button except the current one.
        $('input[type=radio]').not(this).removeAttr('checked');
    });
});

Demo


text:
Q: Powershell, NAS access & Permissions? issues I have recently run into the "Guest access in SMB2 & SMB3" issue outlined by Microsoft here, and I am trying to understand the full scope of the issue.
So far as I can tell, this only impacts NAS access or the like, because a share on a domain member computer is not accessed as a guest. However, I have an account on my NAS, with matching name and password, and permissions are handled properly. Meaning, on a Windows build that doesn't have the outlined problem, I CAN access folders that user has permissions for, and I can't access folders that user doesn't have permission for. Which seems like I am NOT accessing the NAS as a guest, but rather with user credentials. So, can someone explain what is actually happening under the hood?
Also, I was alerted to the issue because a customer was seeing this behavior, and the "fix" outlined by Microsoft is not working for them. Their scenario is slightly different in that they are using Azure in a way that I am not familiar with, basically syncing Group Policy, or at least permissions, with Azure. But Microsoft's information linked above makes no mention of Azure at all, so not sure what the Azure based version of Group Policy is capable of.
And finally, on my Windows 10 Enterprise VM, accessing a Synology NAS, I lose not only PowerShell access to the NAS, but Explorer as well. I get the error mentioned in the link.

You can't access this shared folder because your organization's
security policies block unauthenticated guest access. These policies
help protect your PC from unsafe or malicious devices on the network.

But for this customer, the issue is not showing up in Explorer, only (so far as we have seen) in PowerShell. And in PowerShell it manifests as Test-Path failing on a valid path, that we can access in Explorer. Does that suggest some other problem, and my Google-Fu has led me astray?

A: •   The document that you are referring to is basically an official documentation for the support of SMB 2 and SMB 3 in various versions of Windows. Kindly refer to the below table for summary of the whole document: -

•   The document implies that starting from adoption of support for SMB 2 and 3, the guest account authentication by default for access to the remote network shares is not possible/is denied and in some cases, will be given access as a guest user (with least possible privileges to the files of that network share) when the actual user credentials entered when asked are not verified. The document also states that SMB 1 is not supported in the versions of Windows stated above in the table. In the above table too, certain versions of Windows 10 require an update is for the stated behavior of guest account earlier while certain versions of Windows 10 where update is not required, the administrator has the authority to allow guest user access to remote network shares.
•   Also, guest user logons are disabled by default in various versions of Windows as they do not support standard security features such as signing and encryption thus making them vulnerable to the man-in-middle attacks. Thus, if you want to enable insecure guest logon centrally on all the systems in your network or a subset of systems in your network, then you can do so by enabling the same through a group policy as described below in the link: -
https://learn.microsoft.com/en-US/troubleshoot/windows-server/networking/guest-access-in-smb2-is-disabled-by-default#resolution
The above setting to enable insecure guest logon is described for on-premises environment while the same setting in group policy can be enabled or set in Azure also through Azure AD Domain Services group policy options. For that purpose, you will need a domain managed by Azure AD Domain Services and a Windows Server VM joined to it acting as the DC of the domain environment. For more details on setting up the Group Policy Management server in Windows Server VM, kindly refer to the link below for more details and then do the same setting as said in the link above. Once you enable the insecure guest logon for your Azure AD managed domain, you will not encounter the same issue again and you would then be able to use powershell with guest access.


text:
Q: How to get a key with highest value from a dictionary that is created from a string? I have a string that is in the format of k1=v1,k2=v2 and so on. I want to return that k which has highest v.
I am trying to run below code but it does not seem to work -
s1 = "0=0.0,1=4.097520999795124e-05,2=0.0007278731184387373,3=0.339028551210803,4=0.33231086508575525,5=0.32789173537500504"
stats = dict(map(lambda x: x.split('='), s1.split(',')))
x = max(stats, key=stats.get)
print(x)

This prints 1 whereas the expected output is 3.

A: You could use max, with a key to consider only the second value in the key/value tuples. Also note that the values must be cast to float, since otherwise element's comparisson will be lexicographical:
from operator import itemgetter

max_val = max(((k,float(v)) for k,v in stats.items()), key=itemgetter(1))
print(max_val)
# ('3', 0.339028551210803)

print(max_val[0])
# 3