spring – Save oauth/token body into Java object

After I successfully run the request to http://IP:port/oauth/ token to get the authorization token from oauth using spring framework, the response body looks something like this:

{
     access_token = jsjxjdnjf .... some_acces_token,
     token_type: bearer,
     (....) more fields
}

The client to acces this endpoint is a simple Java app using org.springframework.web.client.RestTeplate
My question is:
Is there a predefined class that allows me to encapsulate(map) that information and access it through getters?
Or I have to implement it myself, which would look like this:

public class OauthTokeWrapper {
private String access_token;
(...)//getters,constructors...
}

python – How do I get object in JavaScript/HTML from Django by ID?

I’m doing a small clinic project using Django. In one page of all html pages I would like to create big buttons in which I have data of specific appointment(id, title, doctor, patient, start hour, end hour). It looks like:

APPOINTMENT BUTTON

There are the fundamental files:

models.py

class Appointment(models.Model):
   id = models.AutoField(primary_key=True)
   title = models.CharField(max_length=100, default=defaultTitle)
   description = models.CharField(max_length=480, null=True, blank=True)
   start_date = models.DateTimeField(null=True, blank=True, default=datetime.date.today)
   end_date = models.DateTimeField(null=True, blank=True, default=datetime.date.today)
   doctor = models.ForeignKey(User, on_delete=models.CASCADE)
   patient = models.ForeignKey(User, null=True, on_delete=models.SET_NULL, related_name='+', blank=True)

def __str__(self):
    return self.title

views.py

def doctortoday(request):
   today = datetime.date.today().strftime("%d.%m.%Y")
   today_appointments = None
   if request.method == 'GET':
      today_min = datetime.datetime.combine(datetime.date.today(), datetime.time.min)
      today_max = datetime.datetime.combine(datetime.date.today(), datetime.time.max)

      try:
         today_appointments = Appointment.objects.filter(doctor=request.user, start_date__range=(today_min, today_max))
      except:
         today_appointments = None

   context = {
       'today': today,
       'appointments': today_appointments
   }
   return render(request, 'doctortoday.html', context)

If we click the appointment button then will show popup modal. At the moment there is only QuerySet – {{ appointments }}. POPUP MODAL

And the my major problem – how can I display in the popup modal the specific appointment’s data without refreshing page? I just want, if we click the button with Appointment 2 then in the popup modal will be data of the Appointment 2. The same with Appointment 3 etc.

index.html

<div class="today-appointments">
   {% for appointment in appointments %}
      {% if user.username == appointment.doctor.username %}
          <button id="{{ appointment.id }}" class="btn btn-info" onclick="showProperties(this)">
              <h1>{{ appointment.title }}</h1>
              <p>Doctor: {{ appointment.doctor }}</p>
              <p>Patient: {{ appointment.patient }}</p>
              <p>Date: {{ appointment.start_date|date:'d.m.Y' }}</p>
              <p>Hour: {{ appointment.start_date|date:'H:i' }} - {{ appointment.end_date|date:'H:i' }}</p>
          </button>
      {% endif %}
   {% endfor %}
</div>
<div class="popup-properties center">
   <div class="title">
      <p>Properties</p>
   </div>
        <div class="properties">
             <h1>{{ appointments }}</h1>
             <h1></h1> <!-- I WOULD LIKE HERE TITLE -->
             <p></p> <!-- I WOULD LIKE HERE DESCRIPTION -->
             <p></p> <!-- I WOULD LIKE HERE DOCTOR -->
             <p></p> <!-- I WOULD LIKE HERE PATIENT -->
             <p></p> <!-- I WOULD LIKE HERE DATE -->
             <p></p> <!-- I WOULD LIKE HERE HOURS -->
             <div class="buttons">
                 <button id="close-properties">Close</button>
                 <button type="submit" id="done-properties">Done</button>
             </div>
        </div>
    </div>

I don’t want to use the form tag and csrf_token. I was trying to use AJAX, it looked like that…

I created a new function in views.py:

def getAppointmentByID(request):
   id = request.GET.get('id', 1)
   appointment = Appointment.objects.get(id=id)
   return HttpResponse(appointment)

And i added a new path in urls.py – path(‘getAppointmentByID/’, views.getAppointmentByID, name=”getAppointmentByID”). Then I can write link in the browser like it: http://127.0.0.1:8000/account/getAppointmentByID/?id=2 and it shows me the appointment with specific ID typed in link.

Next, on every button I have parameter onclick=”showProperties(this)”. This Javascript function in that moment looks like:

showProperties()

function showProperties(info) {
        document.getElementsByClassName("popup-properties")(0).classList.add("active");
        document.getElementById("popup-properties-background").style.display = "block";

        $.ajax({
            type: "POST",
            url: '{{ 'getAppointmentByID/' }}',
            data: { csrfmiddlewaretoken: window.CSRF_TOKEN },
            success: function callback(response){
                console.log(response);
            }
        });
}

Unfortunately it doesn’t work. In browser’s console pops an error – ERROR.
There must be problem with $.ajax structure.

Is it possible to correct this $.ajax structure? Or maybe exist other way to get the specify appointment without refreshing page?

Peace brothers.

How to disable search in site using sharepoint client object model

I need to disable search in site level using client Object Model. and search textbox in the top navigation.

Need help on this.

Thank you,

optics – Aperture iris in front of lenses (in object space)

I am looking for such lenses as well.
In general putting the aperture at the front or outside is avoided because not good; best is to put the aperture more or less in the center of the objective. With the aperture in front you’ll have more aberrations and/or need bigger and more expensive design.
Only in two cases the front aperture design is used:

  1. if the lens is very small and simple, like, really just one group (see the Kodak vest camera and the Triplet), here you cannot put the aperture in the middle! Choose, in the front or in the back.
  2. Otherwise, you put the aperture in front only if you are absolutely forced to do that, typically for coupling with other optical systems.

Small & simple:
Mobile phone lenses; to make them so compact, the aperture is usually placed at the brim of the front lens. Not really outside, but on the brim.

Forced:
Pinholes and many probe objectives, that need to peep from an hole; the hole is the natural aperture and the lens must be built to use all the light that goes through such hole; putting another aperture will cause vignetting. Nice example the SO spy lenses by Zeiss Jena:
Marco Cavina or see the catalog of Marshall Electronics.

Non-photographic lenses:

  • Laser scanning lenses, called F-theta Rogonar; the laser light is coming form the aperture position.
  • All eyepieces: the aperture is well outside, at the “exit pupil”, so I can place my eye with my iris in this place.

If you are curious about aberrations etc, the best short introduction I’ve found are those slides from Jena:
Gross Jena 2017; lecture 11/3, stop position.

dnd 5e – Is there anything that is simultaneously a creature and an object?

Whereas nothing is yet explicitly well defined for creature and object I believe the intent at this time is:

No. Nothing is considered an object and a creature simultaneously.

As defined by various Tweets from Crawford:

  • Creature: Crawford
    indicates

    that a creature has a type as defined in the introduction to the
    Monster Manual.
  • A petrified
    creature

    is still a creature as well as no condition changes your type.
  • Intelligent magical
    items

    are also explicitly objects because they don’t have a type,
    presumably from the first point.
  • Contrary to J Foster’s claim on the verbiage of the resurrection
    spells. In English a group of words describing something almost
    always has a single word name. So when the text says it is targeting
    a “creature that has died”, what that means is you are targeting a
    corpse/cadaver which has been repeatedly stated as an object.
    According to
    this
    tweet it was a creature which means it is not any longer such.
    Conversely, a construct is a creature that was an object.
  • Objects are defined as “discrete, inanimate objects” in the DMG on
    p246. This does allude that in game terms that a house plant would be
    considered an object.
  • Even the targeting for spells seem to allude that they are separate
    things on PHB 204 (emphasis mine).

A spell’s description tells you whether the spell targets creatures,
objects, or a point of origin for an area of effect (described below).

  • True Polymorph seems to be an edge case, the fact that if you are
    polymorphed into an object you don’t remember anything and that you
    gain all the statistics of the new form would, to me, indicate that
    for the duration you were in fact an object and not a creature.
  • Animate Object
    spell
    seems to
    use unfortunate and misleading verbiage as well. Although, the spell does explicitly state that the objects in question become creatures under your control until they are reduced to 0 hit points. The prolonged use of the word object is probably used for short hand as opposed to designating that it is an object. To me this seems to solidify that something can be one or the other but not both.

I assume your question is stemming from a question on targeting. Xanathar’s guide has some of the clarifications indicated from the Jan 19, 2017 Podcast which concerns itself with Twin Spell and targeting, it is well worth the listen and might help you out with your game.

In the end if your DM rules that there can be something that fits both definitions regardless if I would personally disagree it is your table. You can argue it but ultimately the decision is theirs.

Clarification on the English portion of my argument in bullet 4:
This was an attempt to take the wording from the spell “a creature that has died” and link it to a word that has game connotations “corpse” this is to make a transitive argument as follows:

  • “a creature that has died” = “corpse/cadaver” -English
  • “corpse” =
    “object” -Game Terms

Therefore

  • “a creature that has died” = “object” -Transitive association

Something with a creature type in its stat block per JC is a creature but objects don’t have creature types therefore something cannot be both a creature and an object at the same time.

I think of this as a state. A spell, as an example, can change your state to that of an object for its duration or grant objects a creature state for its duration but once the duration expires your state reverts to its norm.

Another example…

Animate Dead grants a corpse (object) a creature type, it doesn’t change an existing creature type from one thing to another.

Is there a way to allow for design-time math on a scriptable object in Unity?

Sorry for the title, I did not know how else to describe the question. I am writing a turn-based strategy game and am looking for a way to enable design-time additions of game mechanics where the mechanics each require some different math.

What I’d like to do is to be able to create a ScriptableObject and then modify it with the formula and various descriptions (all through the inspector), then add it to the game.

As an example, my game has cities where each city has several attributes such as population and various technology levels. I’d like to be able to add various “resource generators” at design-time via the inspector with the formula for how the resource is generated per turn.

Some examples of resource generators:

  • A “gold” resource generator with the “population * 0.025” formula to indicate that, each turn, the city generates 2.5% of it’s population as gold.
  • A “research” resource generator with “assigned population * 0.5” as the formula to indicate that, each turn, the population assigned to research generates 0.5 pts of research per person.
  • A “production” resource generator with the “assigned population * production tech level * 0.75” with a max value of “1000 * city level” where excess production gets dumped to gold.

And so on. These are examples, but the formulas should allow for arbitrary interactions with other values in the game.

Some of the simpler formulas seems pretty easy, i.e. create a scriptable object attached to a primary value (say population) and then a simple modifier. But I’m stuck on how to do the more complex ones.

Anyone have an idea about how to accomplish something like this?

object oriented – Modeling data from Excel sheets to parse to Excel sheet

Background:

I have close to 50 excel files – I cannot change the data source – and I steadily get more.
My task is to make sense of all that data and, lo an behold, save that as another excel file (I asked if I should put it in a local database, but no, I should not).

Asking on SO lead me here, as I thought it might be a better fit here, but my problem, if it even is one, is quite specific.


Code:

In my current code I used a couple of classes to model the data; I read somewhere that data should be data and not a class but are dictionaries helpful in this case?

Assembly Class:

Private pPartnumber As String
Private pDescription As String
Private pLevel As Long
Private pSupplier As Supplier
Private pCustomers As CustomerCollection
Private pSubAssemblies As AssemblyCollection
Private pWarehouse As String
Private pEligibility As String
Private pApprovedData As String
Private pApprovedDataBasedOn As String
Private BuyOrMake As AssemblyBuyMake
Public Enum AssemblyBuyMake
    Buy = 0
    Make = 1
    Both = 2
    Other = 4
End Enum
' Lots of getters and setters
' removed for conciseness

Private Sub SetEligibilityOfSubAssemblies(ByVal Value As String)
    Dim subAssembly As Assembly
    If Not pSubAssemblies Is Nothing Then
        For Each subAssembly In pSubAssemblies
            subAssembly.Eligibility = Value
        Next
    End If
End Sub
Private Sub SetApprovedDataOfSubAssemblies(ByVal Value As String)
    Dim subAssembly As Assembly
    If Not pSubAssemblies Is Nothing Then
        For Each subAssembly In pSubAssemblies
            subAssembly.ApprovedData = Value
        Next
    End If
End Sub

'@Description "Checks if Partnumbers are equal, ignores Description- and other deviations"
Public Function Equals(ByVal Assembly As Assembly) As Boolean
    Equals = (pPartnumber = Assembly.Partnumber)
End Function

As you can see my class has lots of fields; the two setter subs are private as any Subassembly automatically inherits the Topassembly’s ApprovedData and Eligibility as per requirement.

AssemblyCollection:

Private pAssemblyCollection As Collection
Private Sub Class_Initialize()
    Set pAssemblyCollection = New Collection
End Sub
Public Sub Add(ByVal Value As Assembly, Optional ByVal Key As String)
    '
End Sub
Public Sub Remove(Optional ByVal Value As Assembly, Optional ByVal Key As String)
    '
End Sub

'@DefaultMember
Public Function Item(Optional ByVal index As Long = -1, Optional ByVal Key As String) As Assembly
    '
End Function

'@MemberAttribute VB_MemberFlags, "40"
'@Enumerator
Public Property Get NewEnum() As IUnknown
    Set NewEnum = pAssemblyCollection.(_NewEnum)
End Property

The CustomerCollection looks the same.

Customer:

Private pName As String
Private pID As String
Private pCountry As String
Private pHTSCode As String
' And its getters and setters

'@Description "Returns True if Name, ID and HTSCode are the same"
Public Function Equals(ByVal Customer As Customer) As Boolean
    Equals = (pName = Customer.Name And pID = Customer.ID And pHTSCode = Customer.HTSCode)
End Function

The HTSCode is currently part of the Customer as the file I found it in contains Customer and sales data and barely enough assembly data to identify an assembly – think “customer has a partnumber for an assembly and my files have a partnumber which don’t match” and you are just supposed to know which ones refer to the same assembly.


Question:

Instead of using these classes should I use dictionaries of dictionaries?
And for comparing data of different sheets should I store either these classes or dictionaries with the data in new dictionaries or arrays?
I’m not sure if there’s a maximum on how many custom objects I can create (other than memory limits), but I fear I’ll end up with a lot of Assembly instances in this case.

Currently I

Dim arr() As Assembly

to collect all the data before parsing it to a sheet.

unity – Why the rotation using the Coroutine is rotating but the object is in slant ? and how to rotate it with Coroutine non stop?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spin : MonoBehaviour
{
    public Vector3 targetRotation;
    public float duration;
    public bool spinInUpdate = false;

    // Start is called before the first frame update
    void Start()
    {
        if (spinInUpdate == false)
        {
            StartCoroutine(LerpFunction(Quaternion.Euler(targetRotation), duration));
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (spinInUpdate == true)
        {
            transform.Rotate(new Vector3(0, 1, 0));
        }
    }

    IEnumerator LerpFunction(Quaternion endValue, float duration)
    {
        float time = 0;
        Quaternion startValue = transform.rotation;

        while (time < duration)
        {
            transform.rotation = Quaternion.Lerp(startValue, endValue, time / duration);
            time += Time.deltaTime;
            yield return null;
        }
        transform.rotation = endValue;
    }
}

slant I mean this is how it’s rotating with the Coroutine the small cube that rotate is in slant :

slant

When using the Update way it’s rotating fine and this is how it should rotating also with the Coroutine for example on the X only :

Cube

The small cube when rotating either in update or in the Coroutine should not be slant. but it’s slant in the Coroutine.

And how can I add a speed factor to the Update to control the rotation in the Update in case using the Update ?

About controlling the speed in the Update I just added a global float variable and in the Update :

transform.Rotate(new Vector3(0, Time.deltaTime * rotationSpeed, 0));

and it’s working for the speed.

Display object list with a parameter on Mongoose

I have a find query that returns me a list of objects:

{
    "_id": "5fb94fda487b9348c4291450",
    "name": [
        {
            "NewConfirmed": 642686,
            "TotalConfirmed": 49315431,
            "NewDeaths": 9555,
            "TotalDeaths": 1242785,
            "NewRecovered": 288131,
            "TotalRecovered": 32473892
        },
        {
            "NewConfirmed": 116262,
            "TotalConfirmed": 6014461,
            "NewDeaths": 4640,
            "TotalDeaths": 371913,
            "NewRecovered": 77575,
            "TotalRecovered": 2492884
        },
        {
    ...

Its all fine but im trying to make a new query with a status parameter with the value NewConfirmed or TotalConfirmed or NewDeaths to display only that specific field. So the endpoints would look like /something/status/:status.
I already tried an aggregation with filter and a simple find but still havent figured nothing out.
Anyone has any idea?

java swing – Check wich object of a combobox is selected

i have a combobox with many countries created, and i wanna make that if you choose a country of that combobox, a new combobox with cities of that country appears, but it seems i cannot get the right if statement

This is the firs combobox

here are the 2 comboboxes
introducir la descripción de la imagen aquí
and here is the condition on the statechanged.

i added a sout to see if the code reaches that, but nope

i also tried with Objects.equals(comboPais.getSelectedItem(), “España”) and comboPais.getSelectedItem().equals(“España”)