text:
Q: Am I using the Nouveau driver or the proprietary NVIDIA driver? For a long time, I have used the NVIDIA proprietary driver. In Additional Drivers the NVIDIA driver was activated. However, I just "Removed" that driver because I would like to use the Nouveau driver for other reasons. Yet, I have reason to believe I am still using the NVIDIA driver as the output of modprobe -l is as follows:
$  modprobe -l | grep 'nvidia'
kernel/drivers/video/nvidia/nvidiafb.ko

How do I really determine what driver I am using, and how to I enable Nouveau?

A: This is an old question but here is a reliable answer that you can count on in case someone else is looking for the same answer.
Run the following command:
sudo lshw -class video | grep driver=

Sample output:
configuration: driver=nouveau latency=0

If you want to get more details, run:
sudo lshw -class video

Here is a sample output:
  *-display
       description: VGA compatible controller
       product: GP106M [GeForce GTX 1060 Mobile 6GB]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
       configuration: driver=nouveau latency=0
       resources: irq:124 memory:db000000-dbffffff memory:90000000-9fffffff memory:a0000000-a1ffffff ioport:e000(size=128) memory:c0000-dffff

A: You may need to either reboot or restart X first. You can then try :
grep nouveau /var/log/Xorg.0.log

Output:

[    29.227] (==) Matched nouveau as autoconfigured driver 0
[    29.227] (==) Matched nouveau as autoconfigured driver 2
[    29.227] (II) LoadModule: "nouveau"
[    29.227] (II) Loading /usr/lib64/xorg/modules/drivers/nouveau_drv.so
[    29.227] (II) Module nouveau: vendor="X.Org Foundation"
[    29.240] (II) [drm] nouveau interface version: 1.1.0
[    29.534] (II) NOUVEAU(0): [DRI2]   DRI driver: nouveau
[    29.534] (II) NOUVEAU(0): [DRI2]   VDPAU driver: nouveau
[    30.474] (II) AIGLX: Loaded and initialized nouveau

A: On any linux system with the NVIDIA driver installed and loaded into the kernel, you can execute:
cat /proc/driver/nvidia/version

A: nvidiafb is a framebuffer driver inside the Linux Kernel. Is not the proprietary module from nvidia. (nvidia.ko).
If you want to see the short description of the module, issue the following command in terminal
modinfo nvidiafb | grep description
If you want to read more a about framebuffer , read the FrambeBuffer on Ubuntu Wiki.
You can see if some nvidia package is installed by applying the following command
dpkg -l | grep -i nvidia
If you want to search if the nouveau module is loaded you can apply
lsmod | grep nouveau
If nvidia restricted module was loaded , then the nouveau module Cannot be loaded too (conflict each other).
Nvidia's (restricted) module name is nvidia . Not nvidiafb or something similar.
Also you can search from Additional Drivers page . In example below , no proprietary drivers are in use

And another command that can show you, which driver is in use:
lspci -nnk | grep -iA2 vga

There you will see a line like
kernel driver in use: *****

If it's nvidia , then you have nvidia driver installed and in use. If it's nouveau, then you don't.

A: You can use excellent inxi tool. Install it from repository :
sudo apt install inxi

or from github : https://github.com/smxi/inxi
Then do a query by :
$ inxi -Gx
Graphics:  Card: NVIDIA GP104 [GeForce GTX 1080] bus-ID: 01:00.0
Display Server: X.Org 1.19.5 driver: nvidia Resolution: 3440x1440@74.92hz
OpenGL: renderer: GeForce GTX 1080/PCIe/SSE2 version: 4.5.0 NVIDIA 390.25 Direct Render: Yes

At the third line You can see string NVIDIA 390.25 which means that I am using Nvidia Binary driver.


text:
Q: What happens to variables/objects in inner classes of function objects? I have a function multi2 which returns inner class Inner as an Object.
What happens to a - where is it saved and how can I access it?
public class C {
    private static Object multi2(final int a) {
        class Inner {
            public int hashCode() {
                return 2*a;
            }
        }
        return new Inner();     // What happens to a?
                                // Who allocates a?
                                // Can I Access a?
    }

    public static void main(String[] args) {
        Object o = multi2(6);
        System.out.println("o.hashCode() = " + o.hashCode());

        o = multi2(4);
        System.out.println("o.hashCode() = " + o.hashCode());
    }
}

A: What happens at the implementation level is that a copy of the value of a is saved in a synthetic instance variable declared in the compiled version of the C.Inner class.
The value of a is passed to the compiled Inner constructor via an extra parameter.
The C.Inner.hashCode method uses the value of the synthetic variable.   Accessing a in the source code of Inner.hashCode is transformed into accessing the corresponding synthetic variable in the compiled code.
The variable in the outer scope must be final1.  The synthetic variable must be final2 in the Inner class.  This maintains the illusion that (potentially) multiple instances of the Inner class are seeing the same a variable.  (They aren't, but since the variable(s) can't be changed, it is not possible for the code of the inner class to tell the difference.)
If you use javap to look at the bytecodes for the compiled example, you will see the mechanisms used to implement this in the outer and the inner classes.

1 - or effectively final from Java 8 onwards.
2 - If a could be mutated by an Inner method, then two Inner instances with the same outer class need to share a mutable variable whose lifetime is (now) longer than the stackframe for a multi2 call.  That entails somehow turning a from stack variable into something that lives on the heap. It would be expensive and complicated.

A: You have defined the class Inner inside the function so the scope of the class will be
restricted with in the method. And your function is static so it will be live as long as the class definition is loaded. You have override the hashCode function inside the InnerClass so every time you are calling the multi2(param) you are creating the hashCode for the instance of InnerClass and returning the instance of the InnerClass.
So as for you questions, please correct me if i am wrong.
What happens to a ?
a is with in the scope of your static method, so it will be live as long as the class definition is loaded.
Who allocates a?
scope of a is restricted inside the static method and static method does not require instance to access it but as for the static method/variable allocation, i think it depends on JVM.
Can I Access a?
No you cannot access a from outside you static method, it is restricted with in your static method.

A: Since the "a" is a local parameter, you could use a different approach to read the "a" value:
public class C {

  public static Object multi2(final int a) {
    return new Inner(a);
  }

  public static void main(String[] args) {
    Object o = multi2(6);
    System.out.println("o.hashCode() = " + o.hashCode());
    System.out.println("o.getA() = " + ((Inner) o).getA());

    o = multi2(4);
    System.out.println("o.hashCode() = " + o.hashCode());
    System.out.println("o.getA() = " + ((Inner) o).getA());
  }
}

class Inner{
  public int valueA;

  public Inner(int a)
  {
    valueA = a;
  }

  public int getA() {
    return valueA;
  }

  public int hashCode() {
    return 2*valueA;
  }
}

A: I wanted to know what was actually happening, so I compiled your code and looked at the bytecode output.
Basically what happens is the compiler adds in a constructor to your class 'Inner'. It also adds a single parameter to that constructor which takes 'a'. If your multi2() method was NOT static then there would probably also be a parameter to take 'this' where 'this' is the instance of 'C' that multi2() is executing on. BUT since we're in static context, there is no 'this'.
The compiler adds a private final field to your class 'Inner' and sets that private field using the value passed via the constructor. The compiler also converts
    new Inner()

into
    new Inner(a)

Hashcode then accesses the private field containing the value for a.
If 'a' was an object instead of a primitive, then it would be the same way, but a reference would be passed through instead of an actual number value.
How do you access this variable? Well you access it with reflections, but there are many problems:
1) You don't know the name of the field made by the compiler, so you can only get the name by looking at the bytecode. Don't trust decompilers as they might change the name. You gotta look at the bytecode yourself to find out.
2) The compiler probably marks the field as final, which means even if you can get reflections to access the field for you, you won't be able to update it.
3) It is entirely up to the compiler to figure out field names. Field names could change between builds depending on the compiler and it's mood.

A: Inner is a so called local class. a is a parameter passed to the method multi2 and accessable within that scope. Outside of that method, you cannot access a.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Display No Results Message Flexigid So I hide my Flexigrid until there are search match results.
So my flexigrid intialization:
flexigrid({
        url ='myUrl',
        onSubmit: showFlexigrid(),
        //my other flexigrid options
        });

 function showFlexigrid(celDiv, id) {

        var flexiGrid = $('#gridTablegSearchProperty')

        if (!flexiGrid.is(":visible")) {
            if (id) { //got at least one result if id is not undefined
                $('#flexigridWrapper').show();
            } else {
                //I want to display a no results found message to the user here
                //but this won't work because the showFlexigrid function is
                //not called on flexiReload()
                console.log('no results');
            }
        }
    }

//in my $document.ready my search button click implementation:

 $("#btnSearch").click(function () {
    $('#gridTablegSearchProperty').flexReload();
  });

So whether it is flexigrid onSubmit or onSuccess that I bind to in my flexigrid "instantiation" neither is called on .flexReload unless at least on record is returned. I see no flexigrid option that is trigged every time, not even onSubmit does this.

A: I think there's a bit of a quotation mark related syntax issue with the click event in your $(document).ready(). Have a look at the jQuery style guide for quotes. It reads: "Strings that require inner quoting must use double outside and single inside."


text:
Q: C++ "overloading" second default function argument Is there a way to choose which function arguments to override in c++ like in Python?
example code:
#include <iostream>

using namespace std;

void test(int a=1, int b=1) {}

int main()
{
    test(b=2);
    cout << "kkk" << endl;
}

A: No there is isn't. In C++ you always need to supply the parameters in the order they appear in the function declaration.
A workaround that exists for many cases is to supply overloads to that function.


text:
Q: How to pass variable from python to javascript I have a server in python to process an id (the id of youtube video), this is the code:
class MessageHandler(tornado.web.RequestHandler):
  def get(self, action_id):
    print "Message = " + action_id

    if action_id == "id":
        for ws in opened_ws:
            ws.write_message("ID: " + action_id)
            return render_template('js/player.js', action_id=json.dumps(action_id))
(...)

I use the return render_template to pass "action_id" to player.js, which is a function to process films using the API from Youtube, the code is :
var PushPlayer = (function () {

    var player = null;

    function new_player() {
        player = new YT.Player('yt-player', {
            videoId: action_id,
            }
        });
    }

(...)

With action_id, i can have everything id of youtube's video.. but i don't know who pass the action_id from python to javascript..any idea?
Thanks!

A: If you are using a Python framework like Flask, you can access the value of action_id using a template engine like Jinja2 (see http://flask.pocoo.org/docs/0.10/quickstart/#rendering-templates).
Otherwise, to access the action_id using javascript you can use an AJAX call, which is an asynchronous javascript request to your Python web server (see http://api.jquery.com/jquery.ajax/). Note that the .ajax call is part of the JQuery library, but this can also be done without it.

A: It looks like you're using Tornado. You can write raw Python in a Tornado template. Your player.js file is a Tornado template in this case. You would want to update it like this:
var PushPlayer = (function () {

var player = null;

function new_player() {
    player = new YT.Player('yt-player', {
        videoId: {{ action_id }},
        }
    });
}

Anthing inside the double curly braces will be evaluated as Python by Tornado.


text:
Q: 'Untrusted token JWK' error when trying to verify access token using flask_azure_oauth from flask import Flask

from flask_azure_oauth import FlaskAzureOauth

app = Flask(__name__)

app.config['AZURE_OAUTH_TENANCY'] = 'xxx'
app.config['AZURE_OAUTH_APPLICATION_ID'] = 'xxx'
app.config['AZURE_B2C_TENANT_MODE'] = 'true'
app.config['AZURE_TENANT_NAME'] = 'xxx.onmicrosoft.com'
app.config['AZURE_B2C_REGISTERLOGIN_USERFLOW_NAME'] = 'B2C_1_signin'

auth = FlaskAzureOauth()
auth.init_app(app)

@app.route('/protected')
@auth()
def protected():
    return 'hello authenticated entity'

I get this error when trying to access my /protected endpoint:
{"errors": [{"status": 401, "title": "Untrusted token JWK",
"detail": "The JSON Web Key (JWK) identified by the 'kid' (Key ID) field in the token
header, does not correspond to one of the JWKs in the JSON Web Key Set (JWKS) trusted by this API.
Ensure you are using the correct 'kid' and try again, or contact support."}]}

Question: How can I ensure to be using the correct 'kid'?
My use case: I am coming from a Vue frontend application with an access token and need to verify that token in Flask in order to access protected resources. Both my frontend and backend applications are registered as Azure AD B2C applications.


text:
Q: Schedulable batch class to insert a list then update a related parent list I am trying to create a scheduled batch class to query existing records for a custom object, add it to a list then insert the list of records for the same custom object, then update a custom field for a list belonging to the parent object, via a lookup field . The GF__c is the child object, and the Opportunity is the parent object.  when I run it, it does create the new list of child records,  but I am getting an error regarding the parent list:

Duplicate id in List::...

and the custom field of the parent isn't getting updated.  I've posted my code below, any assistance is appreciated.
public class GF__cBatch implements Database.Batchable<SObject>, Schedulable {
    public GF__cBatch() {}
    public void execute(SchedulableContext sc) {
        Database.executeBatch(this, 60);
    }
    public Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator([SELECT Id, Opportunity_Name__c, Forecast_Month_Year_Current_Month_Year__c FROM GF__c WHERE Forecast_Month_Year_Current_Month_Year__c=true]);
    }
    public void execute(Database.BatchableContext bc, List<sObject> scope) {
        list<GF__c> gfList = new list<GF__c>();
        list<Opportunity> OppList = new list<Opportunity>();
        datetime myDateTime = datetime.now();
        For(Sobject s :scope){
            GF__c GF = (GF__c) s;
            gfList.add(new GF__c(
                Opportunity_Name__c = GF.Opportunity_Name__c
            ));
            Opplist = [SELECT Id, Forecast_Month_Year__c FROM Opportunity WHERE Id = :GF.Opportunity_Name__c];
            OppList.add(new Opportunity(
                Id = GF.Opportunity_Name__c,
                Forecast_Month_Year__c = myDateTime.format('MMMM, YYYY')
            ));
        }
        try{
            insert gfList;
            if(OppList.size() > 0){
                update OppList;
            }
        }
        catch(Exception E){
            system.debug('Error is: ' + E.getMessage());
        }
    }
    public void finish(Database.BatchableContext bc) {
        system.debug('FORECAST CREATE JOB IS FINISHED');
    }
}

A: You're going to run into trouble here when you're processing more than one GF__c record with the same Opportunity as parent. The reason that's the case is that your code accumulates a List<Opportunity> to update, with one entry for each GF__c.
As a result, if you have N GF__c records with the same Opportunity, you'll have N Opportunities in the update list with the same Id. Salesforce doesn't allow that in a single DML operation.
The typical idiom is to use a Map<Id, Opportunity>, where you set each Opportunity needing to be updated in the map under its Id:
// We found an Opportunity with Id myId needing to be updated
myMap.put(myId, new Opportunity(Id = myId, ANOTHER_FIELD = VALUE, ...)

and then do
update myMap.values();

This ensures they're deduplicated appropriately, because Maps are inherently one-to-one mappings. Your code can also check whether it's already looked at a child record for that Opportunity by simply looking at whether myMap.containsKey(someOpportunityId). If, for example, you need to populate the largest value of a field on the child object, you could then pull the Opportunity instance back out of the Map and run some logic to decide which child object value you wanted to populate.
Additionally, your batch has a bulkification issue, which I assume is why you set the scope size to 60. You need to move the Opportunity query outside the loop. However, if you adopt the Map-based pattern above, it looks to me like you don't need to query at all, since you're constructing new sObject instances.


text:
Q: winRM Transport error since Ansible Upgrade Im running an ansible playbook from a debian machine that connects with 3 hosts to deploy some features.
Since upgrading the ansible to 2.9.2 from 2.8 , I've repeatedly started to get errors from python libraries such as:
     res = self.send_message(xmltodict.unparse(req))
   File "/usr/local/lib/python3.7/dist-packages/winrm/protocol.py", line 243, in send_message
     resp = self.transport.send_message(message)
   File "/usr/local/lib/python3.7/dist-packages/winrm/transport.py", line 323, in send_message
     response = self._send_message_request(prepared_request, message)
   File "/usr/local/lib/python3.7/dist-packages/winrm/transport.py", line 328, in _send_message_request
     response = self.session.send(prepared_request, timeout=self.read_timeout_sec)
   File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 646, in send
     r = adapter.send(request, **kwargs)
   File "/usr/local/lib/python3.7/dist-packages/requests/adapters.py", line 449, in send
     timeout=timeout
   File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 672, in urlopen
     chunked=chunked,
   File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 447, in _make_request
     exc_info=True,
 Message: 'Failed to parse headers (url=%s): %s'
 Arguments: ('http://{{MY.DEST.IP}}:5985/wsman', HeaderParsingError("[StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''"))

MY.DEST.IP = my public IP
Port 5985 is open in the destination and i could connect with telnet.
Is there any issue known about the newest Ansible version?
Thanks, any help would be appreciated


text:
Q: Divide screen by percentage from top and sides I am trying to create a layout with image situated 20% size of screen from left, 20% size of screen from right and 30% size of screen from top. I can situate an image as 20% of the distance from the sides but don't know how to combine the percentages from the top and sides simultaneously. Now I'm using android:layout_marginTop to jump from the top edge. I want to use something what will make 30% free space of screen from top on any screen resolution. Please take a look on Fig.1. Thanks a lot for any help.

XML Code:
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:weightSum="100" >

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="20" />

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_marginTop="100dp"
        android:layout_weight="60"
        android:src="@drawable/logo_line" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="20" />
</LinearLayout>

A: I have a dynamic solution for that:
final Display display = getWindowManager().getDefaultDisplay();
final Point size = new Point();
display.getSize(size);

final WindowManager.LayoutParams params = getWindow().getAttributes();
params.width = (int) (size.x * 0.6);
params.height = (int) (size.y * 0.6);

That would be to leave 20% off for the height (100% - (20% + 20%)) and same for the width.
---- EDIT ----
The above solution would be to format the layout window itself. To do so with just a layout item, I'd go by this:
  final TextView tv = findViewById(R.id.my_text_view);

  LinearLayout.LayoutParams tvlp = (LinearLayout.LayoutParams) tv.getLayoutParams();

  tvlp.rightMargin *= 0.6;
  tvlp.leftMargin *= 0.6;
  tvlp.topMargin *= 0.6;
  tvlp.bottomMargin *= 0.6;

That would redimension a TextView's layout.

A: use a RelativeLayout or wrap the ImageView in a LinearLayout :
---- EDIT ----
on the ImageView : take out the layout_gravity and margin_top attributes and set layout_height to 0dp
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="100" >

<TextView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="20" />

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="60"
    android:orientation="vertical"
    android:weightSum="100" >

<TextView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="30" />
<ImageView
    android:id="@+id/imageView4"
    android:layout_width="match_parent"
    android:layout_height="0dp"
     android:layout_weight="40"
    android:src="@drawable/logo_line" />
</LinearLayout>
<TextView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="20" />
</LinearLayout>

A: Put the ImageView within another LinearLayout so you can set the horizontal weight(the LinearLayout the ImageView is in) and another for the vertical weight
Edited

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="30" />
    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:weigth="40"
        android:weightSum="100" >

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="20" />

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="60"
        android:src="@drawable/logo_line" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="20" />
    </LinearLayout>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="30" />
    </LinearLayout>

This should work.. important are the right configurations of the Views and the orientation of the LinearLayouts.
Create a LinearLayout that has 3 'items' in it with a width matched to their parent.
You can set the weight for them all to that creates the vertical(top/bottom) margins.
Then the second item in the LinearLayout should be another LinearLayout that creates the horizontal(left/right) margins. This LinearLayout should be oriented horizontal.
This isn't a clean solution for margins. If it doesn't work you should do it dynamically
Let me know if it works


text:
Q: Flex ChangeWatcher bind to a negative condition I have a bindable getter in a component which informs me when a [hidden] timer is running.  I also have a context menu which, if this timer is running, should disable one of the menu items.  Is it possible to create a ChangeWatcher which watches for the negative condition of a bindable property/getter and changes the enabled property of the menu item?
Here are the basic methods I'm trying to bind together:
Class A:
[Bindable]
public function get isPlaying():Boolean {
    return (_timer != null) ? _timer.running : false;
}

Class B:
private var _playingWatcher:ChangeWatcher;
public function createContextMenu():void {
    //...blah blah, creating context menu
    var newItem:ContextMenuItem = new ContextMenuItem();
    _playingWatcher = BindingUtils.bindProperty(newItem, "enabled", _classA, "isPlaying");
}

In the code above, I have the inverse case: when isPlaying() is true, the menu item is enabled; I want it to only be enabled when the condition is false.
I could create a second getter (there are other bindings which rely on the current getter) to return the inverse condition, but that sounds ugly to me:
[Bindable]
public function get isNotPlaying():Boolean {
    return !isPlaying;
}

Is this possible, or is there another approach I'm completely missing?

A: Could use bind Setter on binding utils but your approach seems valid otherwise bind property is blind to the types of properties it's mapping so it has no negative condition parameter.

A: I would extend ContextMenuItem and create a custom property on it that you can use to set the enabled or not of the underlying ContextMenuItem


text:
Q: I have created a query but it is not working WITH rows AS
(
    SELECT
        *, ROW_NUMBER() OVER (ORDER BY dtDeliveryDate) AS rn
    FROM
        TCheckRecipient
)
SELECT
    AVG(avarage)
FROM
    (SELECT
         TCheck.iCheckId,
         AVG(DATEDIFF(minute, mc.dtDeliveryDate, mp.dtDeliveryDate)) AS average
     FROM
         rows mc
     LEFT JOIN
         TCheck ON TCheck.iCheckId = mc.iCheckId
     JOIN
         rows mp ON mc.rn = mp.rn - 1
     GROUP BY
         TCheck.iCheckId)

A: You have Typo error in AVG(avarage) , it should be average.
And also, remember to assign alias on your subquery.
WITH rows AS
(
    SELECT
        *, ROW_NUMBER() OVER (ORDER BY dtDeliveryDate) AS rn
    FROM
        TCheckRecipient
)
SELECT
    AVG(avarage)
FROM
    (SELECT
         TCheck.iCheckId,
         AVG(DATEDIFF(minute, mc.dtDeliveryDate, mp.dtDeliveryDate)) AS average
     FROM
         rows mc
     LEFT JOIN
         TCheck ON TCheck.iCheckId = mc.iCheckId
     JOIN
         rows mp ON mc.rn = mp.rn - 1
     GROUP BY
         TCheck.iCheckId) as A


text:
Q: How do you play sound in C#? I've tried this but I'm interested in playing sound from where my program starts. Such I have the .wav file inside of the project folder.
   SoundPlayer simpleSound = new SoundPlayer(@"/yay.wav");
    simpleSound.Play();

Thank you

A:
Such I have the .wav file inside of the project folder.

This is probably your problem.
When you compile your application, it doesn't end up straight in the project folder - it ends up in a subdirectory (either /Debug/bin or /Release/bin). Put the wav file there instead of in the project directory and see how that works.

A: Before you have to play sound, you must be familiar with PlaySound() Win32 API function.
private SoundPlayer player = new SoundPlayer();

/// Button click event handler.
private void AsyncBtn_Click(object sender, EventArgs e)
{
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
        // Set .wav file as TextBox.Text.
        textBox1.Text = openFileDialog1.FileName;

        // Add LoadCompleted event handler.
        player.LoadCompleted += new AsyncCompletedEventHandler(LoadCompleted);

        // Set location of the .wav file.
        player.SoundLocation = openFileDialog1.FileName;

        // Load asynchronously.
        player.LoadAsync();
    }
}

/// LoadCompleted event handler.
private void LoadCompleted(object sender, AsyncCompletedEventArgs args)
{
    player.Play();
}


text:
Q: Sorting of tree implemented with NatTable I'm trying to implement sorting of tree implemented with NatTable but I can't really understand how it works. My problem is that after the sorting of any column other than 'tree' column child nodes can move to invalid parent. Though the order of elements is correct on all levels of hierarchy. So basically I don't understand the purpose of TreeList.Format.getComparator() and how it related to comparators registred for the columns, and I don't understand when and why node can change its parent.
I've started with the example
TreeGridExample and I've managed to create test data with which I have the same problem
private void createDatums() {
    createDatum(null, "a", 2);
    createDatum("a", "aa1", 0);
    createDatum(null, "b", 0);
    createDatum("b", "bb1", 0);
    createDatum(null, "m", 1);
    createDatum(null, "n", 0);
}

If I sort column bar, bb1 node jumps from b to n and when sorting removed, it again is child of b

A: Your comparator need to take into account the tree hierarchy.
See here and here some more information.

A: Regarding our example, maybe our SortableTreeComparator is not working correctly. And the answer is not trivial.
First, in order to make the TreeList work correctly you need to bring the elements in the list into the correct order. This is the tree comparator.
What you additionally want is to add a custom sorting on the lowest level. So in that case you need to extend your comparator to check for the tree level.
The reason why the parent changes is because your comparator changes the order in the collection and therefore breaks the whole tree structure.
We managed to make it work with the GroupBy feature in the GroupByComparator, but there we have the GroupByObjects in the list. And I remember it was hard work to get everything working together.
Please create a ticket to fix the SortableTreeComparator, not sure when I'm able to work on it.


text:
Q: set height of the div by using class name? I am having a div with a class name not having that id.
i need to set that div with browser window height usig Javascript or jquery..
<div class="abc">

some content

</div>

how i set height of the div?..

A: You can do this with jQuery and .height():
Specific height of 100px:
$('.abc').height(100);

For browser inner height, do:
$('.abc').height(window.innerHeight);

A: $('.abc').height($(window).height());

To make that responsive to changes in the browser height, do:
$(window).on('resize load', setHeight);

function setHeight() {
    $('.abc').height($(window).height());
}

A: Use this:
$('.abc').height(value);

A: Just do-
$(document).ready(function(){
  var height = $(window).height();
  $(".abc").height(height);
});

Also make change in css -
.abc{
  overflow: auto;
}

A: Used to css as like this
html, body{
height:100%;
}
.abc{
height:100%;
}

[Live demo][1]


text:
Q: Which class is causing "undefined for the type" error? Eclipse is telling me "undefined for the type Chore" for getName() on the last line. I am not understanding where the problem is. I also have a Chore class, so is it trying to pull Name from the Chore class? Or is there something wrong in my People class? (added the Chore class also)
        System.out.printf("%s's Chores: %n", person.getName());
        for(int i=0; i<person.getNumChores(); i++) {
        System.out.println(person.getChores()[i].getName()); //error here
        }

People class:
public class People {
    private Chore chores[] = new Chore[48];
    private int numChores = 0;

    private final String name;
    private final int birthYear;
    private int age;

    public void addChore(Chore chore) {
        if(numChores == 48) {
            System.out.println("All chores have been assigned.");
        }
        else {
            chores[numChores++] = chore;
        }
    }

    public People(String name, int birthYear, int age) {
        this.name = name;
        this.birthYear = birthYear;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public int getBirthYear() {
        return birthYear;
    }

    public int setAge(int birthYear) {
        int age = 2020 - birthYear;
            return age;
        }

    public int getAge(){
        return age;
    }

    public int getNumChores() {
        return numChores;
    }

    public Chore[] getChores() {
        return chores;
    }
}

Here is the Chore class:
public class Chore{

    private final String choreName;
    private final String difficulty;
    private final String timesPerWeek;
    private String location;
    private String assigned;

    public Chore(String location, String choreName, String timesPerWeek, String difficulty){
       this.location = location;
       this.choreName = choreName;
       this.timesPerWeek = timesPerWeek;
       this.difficulty = difficulty;
       this.assigned = "N";
    }

    public Chore(String choreName, String timesPerWeek, String difficulty){
       this(choreName, timesPerWeek, difficulty, "Whole house");
       this.assigned = "N";
    }

    public String getChoreName(){
        return choreName;
    }
    public String getDifficulty(){
        return difficulty;
    }

    public String getTimesPerWeek(){
        return timesPerWeek;
    }
    public String getLocation(){
        return location;
    }

    public String setAssigned(){
        String assigned = "Y";
        return assigned;
    }

    public String getAssigned(){
        return assigned;
    }
}

A: You do not have getName() method inside Chore.
Replace
System.out.println(person.getChores()[i].getName());

with
System.out.println(person.getChores()[i].getChoreName());


text:
Q: What (conceptually) is "Four Velocity"? Too many text books (in fact, all of them that I've found including 'Gravity'), just throw out the term Four Velocity without digging into what it means, exactly.  I understand $\frac{dx}{dt}$, but I don't understand how you can take the derivative of time against time, $\frac{dt}{dt}$.  I mean, that's 1, isn't it?
So looking at the symbols a little closer, it appears that the components are actually $$\frac{dx}{d\tau}.$$  That is, it's the derivative of normal space to proper time.  So then first component of the 4-Velocity vector is:$$\frac{dt}{d\tau}$$I'm guessing that's the ratio of the observer's time to the proper time?

A: That's right, but you can also think of the four velocity as just the velocity vector with a special parameter. A trajectory in spacetime is an assignment of a spacetime point $x^\mu(\tau)$ (remember this is $(ct, x, y, z)$) for each proper time $\tau$. The four velocity is just the derivative of this, that is, the velocity vector: $u^\mu = dx^\mu/d\tau = (d(ct)t/d\tau, dx/d\tau, dy/d\tau, dz/d\tau)$.
Its first component $u^0 = c dt/d\tau$ measures the rate of change of coordinate time as a function of proper time, and it is always greater than or equal to 1.


text:
Q: Firebase Flask API Deployment Error: /bin/sh: 1: exec: gunicorn: not found i'm trying to deploy my flask REST onto firebase. I'm following this article: https://medium.com/firebase-developers/hosting-flask-servers-on-firebase-from-scratch-c97cfb204579
I get this error when running gcloud beta run deploy --image gcr.io/id/flask-fire.
Here are the relevant messages:
Deploying container to Cloud Run service [flask-fire] in project [project-name] region [europe-west1]
Deploying...
  Creating Revision... Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this rev
  ision might contain more information.

/bin/sh: 1: exec: gunicorn: not found
Here's my Dockerfile :
# 1
FROM python:3.9

# 2
RUN pip install gunicorn
RUN pip3 install gunicorn

# 3
COPY src/ /app
WORKDIR /app

# 4
ENV PORT 8080

# 5
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 app:application

What am I doing wrong? Thanks a ton in advance!
Also, here's my folder structure:


text:
Q: Accessing arguments with argv,and how to convert? In my Objective-C program, I need to pass an argument into argv[1], which would be used in the program.
I want to pass argv[1] an argument like:
CFStringRef test = CFSTR(argv[1]);

but it doesn't work. What should I do?

A: You can get the argument as an NSString with:
NSString *arg1 = [NSString stringWithUTF8String:argv[1]];


text:
Q: About noetherian commutative rings I've trouble with understanding some details about noetherian rings.
For example, I don't understand why this theorem is wrong:

A ring $R$ is noetherian if and only if it's finitely generated $\mathbb Z$-algebra.

My proof: the implication "noetherian $\Rightarrow$ finitely generated" is standard and obvious. The inverse implication also looks rather simple to me: cannot we say that finitely generated $\mathbb Z$-algebra is quotient $\mathbb Z[x_1, \ldots, x_n]$ / $\mathfrak I$ ($\mathfrak I$ is ideal), so by Hilbert basis theorem it's a quotient of the noetherian ring, so it's noetherian itself?
Can somebody help me and explain to me where is my mistake?

A: You should rethink the implication "noetherian $\Rightarrow$ finitely generated". Noetherianness only implies that every ideal is finitely generated as an ideal, but not necessarily as a ring. Every field is noetherian, for example, but an uncountable field cannot be finitely generated. In fact, no infinite field is finitely generated as a ring ; see If a ring is Noetherian, then every subring is finitely generated? for details.


text:
Q: Selecting language of the keyboard for UITextField with secureTextEntry I'm stuck with a problem of changing language for the password field. In my application I need to enter login/password in hebrew with no care of current locale. When I try to enter login, then it is all right, I can change the keyboard to hebrew and enter login. But when I try to enter password in secured textField, the keyboard appears without select language button, so I can enter only english letters.
The thing is that logins/passwords could be in english or in hebrew.
How can I put the select language button to the secured textField?

A: Didn't find a solution. Had to make this snippet:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
textField.text = [textField.text stringByReplacingCharactersInRange:range withString:string];

NSString *pass = password;
pass = [pass stringByReplacingCharactersInRange:range withString:string];

[password release];
password = nil;

password = [[NSString stringWithString:pass] retain];

[self hideTextInTextFieldExceptOne:string];

[self performSelector:@selector(hideTextInTextField) withObject:self afterDelay:1.0];

return NO;
}

- (void)hideTextInTextFieldExceptOne:(NSString *)string
{
int lenght = [passwordTextField.text length];

for (int i = 0; i < lenght-1; i++)
{
    NSRange range = NSMakeRange(i, 1);
    passwordTextField.text = [passwordTextField.text stringByReplacingCharactersInRange:range withString:@"*"];
}
}

- (void)hideTextInTextField
{
NSUInteger lenght = [passwordTextField.text length];
passwordTextField.text = @"";

for (int i = 0; i < lenght; i++)
{
    passwordTextField.text = [passwordTextField.text stringByAppendingString:@"*"];
}
}

A: Unfortunately, the solution posted here does not work for languages with composite characters (like Korean).
Languages like Korean (Hangul) has a composite character where each letter is composed of multiple symbols. For example, 'ㅁ', 'ㅏ' and 'ㄴ' are all individual characters, but when combined, it becomes '만', which is treated as a single letter.
Here is a solution that works for all languages.
Place a UILabel on top of a UITextField.  Set the UILabel's frame slightly smaller than the UITextField so that it sits inside the UITextField, yet still obscures UITextField's text. The textField: shouldChangeCharactersInRange:withReplacementString is called before the text is completed. This means we need to complete the text ourselves.  This is harder to do with composite character languages like Korean.  Instead, register for the UITextFieldTextDidChangeNotification which will be called after the new text appears on the UITextField.
@interface MKSecureTextField()<UITextFieldDelegate>
@property (nonatomic, strong) UITextField* textField;
@property (nonatomic, strong) UILabel* hideLabel;
@property (nonatomic, strong) NSTimer* hideTimer;
@property (nonatomic, strong) NSTimer* blinkTimer;
@end

@implementation MKSecureTextField

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        _textField.userInteractionEnabled = YES;
        _textField.borderStyle = UITextBorderStyleRoundedRect;
        _textField.font = [UIFont systemFontOfSize:14];
        _textField.placeholder = @"enter text";
        _textField.autocorrectionType = UITextAutocorrectionTypeNo;
        _textField.keyboardType = UIKeyboardTypeDefault;
        _textField.returnKeyType = UIReturnKeyDone;
        _textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        _textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        _textField.delegate = self;

        self.hideLabel = [[UILabel alloc] initWithFrame:CGRectMake(6, 5, frame.size.width-10, frame.size.height-12)];
        _hideLabel.backgroundColor = [UIColor whiteColor];

        [self addSubview:_textField];
        [self addSubview:_hideLabel];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:nil];

    }
    return self;
}

When the UITextFieldTextDidChangeNotification is received, hide all but the last character. The hidden text will be programmatically set on the UILabel. Also, schedule a timer that will hide the last character. This timer is invalidated if more text is typed.
- (void)textFieldDidChange:(NSNotification*)notification
{
    UITextField* textField = notification.object;
    if (textField == _textField)
    {
        NSString* text = textField.text;

        [self hideExceptLastCharacter:text];

        [self.hideTimer invalidate];
        self.hideTimer = [NSTimer scheduledTimerWithTimeInterval:1
                                                          target:self
                                                              selector:@selector(hideLastCharacter)
                                                    userInfo:nil
                                                     repeats:NO];

    }
}

UILabel does not have a blinking cursor.  So we emulate it by alternating between a '|' and a space. The blinking cursor is placed when the edit begins, and is removed when the edit ends.
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (_hideLabel.text == nil)
    {
        _hideLabel.text =  @"|";
    }
    else
    {
        _hideLabel.text =  [_hideLabel.text stringByAppendingString:@"|"];
    }

    self.blinkTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(blinkCursor) userInfo:nil repeats:YES];
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    NSRange range;

    range.location = _hideLabel.text.length - 1;
    range.length = 1;

    _hideLabel.text = [_hideLabel.text stringByReplacingCharactersInRange:range withString:@""];

    [_blinkTimer invalidate];
}

- (void)blinkCursor
{
    if (_hideLabel.text.length > 0)
    {
        static BOOL visible = YES;

        NSRange range;
        range.location = _hideLabel.text.length - 1;
        range.length = 1;

        if (visible)
        {
            _hideLabel.text = [_hideLabel.text stringByReplacingCharactersInRange:range withString:@" "];
        }
        else
        {
            _hideLabel.text = [_hideLabel.text stringByReplacingCharactersInRange:range withString:@"|"];
        }
        visible = !visible;
    }
}

Characters except for the last one is hidden. This is set on the UILabel. The UITextField is left untouched.
- (void)hideExceptLastCharacter:(NSString*)string
{
    int length = [_textField.text length];

    NSString* s = @"";
    for (int i = 0; i < length-1; i++)
    {
        s = [s stringByAppendingString:@"●"];
    }

    if (_textField.text.length > 0)
    {
        _hideLabel.text = [s stringByAppendingString:[_textField.text substringFromIndex:_textField.text.length-1]];
        _hideLabel.text = [_hideLabel.text stringByAppendingString:@"|"];
    }
    else
    {
        _hideLabel.text = @"|";
    }
}

- (void)hideLastCharacter
{
    if (_hideLabel.text.length > 1)
    {
        NSRange range;
        range.location = [_hideLabel.text length]-2;
        range.length = 1;

        _hideLabel.text = [_hideLabel.text stringByReplacingCharactersInRange:range withString:@"●"];
    }
}

- (void)dealloc
{
    [_hideTimer invalidate];
    [_blinkTimer invalidate];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end

See this Github project for reference.

A: Optimized @lonlywolf answer to better performance code:
Optimized only two methods where are cycles, which slowed down program when typing more than 30 symbols
- (void)hideTextInTextFieldExceptOne:(NSString *)string
{
    int lenght = [passwordTextField.text length];
    if (lenght -1 > 0) {
        NSString *resultString = @"";
        for (int i = 0; i < lenght-1; i++)
        {
            resultString = [resultString stringByAppendingFormat:@"*"];
        }
        NSRange range = NSMakeRange(0, lenght - 1);
        passwordTextField.text = [fieldPassword.text stringByReplacingCharactersInRange:range withString:resultString];
    }
}

- (void)hideTextInTextField
{
    int lenght = [passwordTextField.text length];
    if (lenght > 0) {
        NSString *resultString = @"";
        for (int i = 0; i < lenght; i++)
        {
            resultString = [resultString stringByAppendingFormat:@"*"];
        }
        passwordTextField.text = resultString;
    }
}


text:
Q: Finding $E[X\mid Y]$ and $E[Y\mid X]$ Finding $E[X\mid Y]$ and $E[Y\mid X]$
I need to find $E[X\mid Y]$ and $E[Y\mid X]$ and I'm having trouble with those indicator functions. I hope I solved it correctly
Given the densities for $X$: $2x\,dx$ in $[0,1]$ and $Y$ is uniform in
$[0,X]$
There is no mention of any sort of independence
$f_X(x)=2x\mathbb1_{[0,1]}(x)$
then I need the density of Y knowing X
$f_{Y\mid X}(y\mid x)=\frac1x \mathbb 1_{[0,x]}(y)$
joint density is: $f_{X,Y}(x,y)=f_{Y\mid X}(y\mid x)f_X(x)=2x\mathbb1_{[0,1]}(x)\cdot \frac1x \mathbb 1_{[0,x]}(y)$
then the marginal of $Y$ is
$f_Y(y)=\int f_{Y\mid X}(y\mid x)f_X(x)\,dx=\int_y^1\frac1x\cdot 2x\mathbb1_{[0,1]}(x)\,dx=2-2y$
so it follows,
$E[X\mid Y]=\int_0^1 x\cdot\frac{f_{X,Y}(x,y)}{f_Y(y)}\,dx=\int_0^1 x\cdot\frac{2\cdot\mathbb1_{[y,1]}(x)}{2-2y}\,dx=\int_y^1\frac{2x}{2-2y}\,dx=\frac{1-y^2}{2-2y}=\frac{1+y}{2}$
$E[Y|X]=\int_0^1 y\cdot\frac{f_{X,Y}(x,y)}{f_X(x)}\,dy=\int_0^1 y\cdot\frac{2\cdot\mathbb1_{[0,x]}(y)}{2x}\,dy=\int_0^x\frac{2y}{2x}\,dy=\frac{1-y^2}{2-2y}=\frac{x^2}{2x}=\frac{x}{2}$


text:
Q: Update & Insert data with php pdo unsuccessfully I'm trying to solve this with quite a lot of code found on the Internet to update/insert MariaDB with PDO.
Some of it executes perfectly.
However, I don't know what's going wrong with a few pages; it just won't execute (INSERT, UPDATE) and refresh data to the database.
Here is my raw code for UPDATE:
(After I run the reset password page. The $result returns TRUE, but the database won't update.)

<?php
session_start();
include('connect.php');
error_reporting(0);

$usertype=$_SESSION['usertype'];
$useremail=$_REQUEST['useremail'];
$password=$_REQUEST['password'];
$password1=$_REQUEST['password1'];
$password2=$_REQUEST['password2'];
$returnurl='request.php';

if ($usertype == 1 or $usertype == 2){
    $password1=password_hash($password1,null);
    $stmt = $pdo->prepare("UPDATE POEUSER SET UserPassword = :password1 WHERE UserEmail = :useremail");
    $stmt->bindValue(":password1",$password1,PDO::PARAM_STR);
    $stmt->bindValue(":useremail",$useremail,PDO::PARAM_STR);
    try {
        $result = $stmt->execute();
      } catch(PDOException $e) {
        echo $e->getCode() . " - " . $e->getMessage();
      }
      $stmt = null;

    ?>

<script language='javascript'>
window.location.href = '<?php echo $returnurl ?>';
alert(
    '<?php echo $result . $e . $useremail .  $password1 ?> password have been reset'
);
</script>;
<?php
};

if ($usertype == 3 or $usertype == 4){
    if($password1==$password2) {

        $password1=password_hash($password1,null);
        $stmt = $pdo->prepare("UPDATE WILUSER SET UserPassword=:password1 WHERE UserEmail=:useremail");
        $stmt->bindValue(":password1",$password1,PDO::PARAM_STR);
        $stmt->bindValue(":useremail",$useremail,PDO::PARAM_STR);
        try {
            $result = $stmt->execute();
          } catch(PDOException $e) {
            echo $e->getCode() . " - " . $e->getMessage();
          }
          $stmt = null;
        ?>

<script language='javascript'>
window.location.href = 'index.php';
alert(
    '<?php echo $result . $e . $useremail .  $password1 ?> password have been reset'
);
</script>;
<?php
        ;}

    else {  ?>
<script language='javascript'>
window.location.href = 'reset.php';
alert(
    '<?php echo $result .  $e .  $useremail .  $password .  $password1  .  $password2 ?>Password not match!'
);
</script>}
<?php }  ; };

?>

Here is my raw code for INSERT:
(The same problem persists; the user supposes to create the database's new user data. However, it is missing.)

<?php
session_start();
include('connect.php');
error_reporting(0);
if($_SESSION['usertype']!=1 AND $_SESSION['usertype']!=2 AND $_SESSION['usertype']!=3 AND $_SESSION['usertype']!=4 ){
    $createdby=5;
}
else {
    $createdby=$_SESSION['userid'];}

$usertype2=$_SESSION['usertype'];
$usertype=$_REQUEST['usertype'];
$userstatus=0;
$useremail=$_REQUEST['useremail'];
$userpassword=$_REQUEST['userpassword'];
$username=$_REQUEST['username'];
$id=$_REQUEST['id'];
$userprofile="Introduce yourself to public";
$userphoto="user.png";

$stmt = $pdo->prepare("INSERT INTO POEUSER (UserType,UserStatus,UserEmail,UserPassword,UserName,UserProfile,UserPhoto,CreatedBy) VALUES (:usertype,:userstatus,:useremail,:userpassword,:username,:userprofile,:userphoto,:createdby )");
$stmt->execute([':usertype'=>$usertype,':userstatus'=>0,':useremail'=>$useremail,':userpassword'=>$userpassword,':username'=>$username,':userprofile'=>$userprofile,':userphoto'=>$userphoto,':createdby'=>$createdby]);
$newid = $pdo->lastInsertId();
$stmt = null;

if ($usertype==3){
    $stmt = $pdo->prepare("INSERT INTO EMPLOYER (CompanyID,UserID) VALUES (:id,:userid )");
$stmt->execute([':id'=>$id,':userid'=>$newid]);
$stmt = null;
}

if ($usertype==4){
    $stmt = $pdo->prepare("INSERT INTO STUDENT (StudentID,UserID) VALUES (:id,:userid )");
$stmt->execute([':id'=>$id,':userid'=>$newid]);
$stmt = null;
}

if ($usertype!=1 AND $usertype!=2 ){
$_SESSION['userid']=$newid;
$_SESSION['username']=$username;
$_SESSION['usertype']=$usertype;
$_SESSION['userphoto']=$userphoto;
$_SESSION['useremail']=$useremail;

        }
;?>

<script language='javascript'>
window.location.href = 'updateprofile.php';
alert('<?php echo $newid?> Thank you for sign-up! Please update more details on next page');
</script>

I will add more coding to prevent SQL Injection after the page works.


text:
Q: Combine two date fields in tableau I'm using Tableau Software and I connected it with Salesforce. I created a calculated field to calculate a ratio of two values from two different columns, and I want to show the evolution of this ratio. The problem is that the two values are linked with two different columns from two different tables. How can I merge the two dates columns ?
Thank you for your help .

A: You need to add the two date fields as keys in the join/relationship/blend between the two tables. Then you can use one of the date fields to create the line chart. Does it make sense?


text:
Q: Why 3 compositing layers for the same scrollable list (Chrome)? I'm getting 3 different layers in Chrome's Layers tab for the same scrollable list. This is the CSS of the element:
display: block;
backface-visibility: hidden;
transform: translate3d(0, 0, 0);
top: 45px;
position: absolute;
right: 0px;
left: 0px;
bottom: 0;
overflow: auto;
z-index: 100;
background: #ccc;
padding: 0 10px;

For each layer, the compositing reasons given are:

*

*"Secondary layer, the vertical scrollbar layer"

*"Secondary layer, to house contents that can be scrolled"

*"Is a scrollable overflow element. Has a clip that needs to be known by compositor because of composited descendants."

Each of these makes sense as individual reasons to promote the node into its own compositing layer, but why 3 layers?
I can't find anything definitive online. The closest I have found is this and the linked pages but some are broken and one is old and boldly states that there were significant upcoming changes. Any ideas/direction will be very welcome, thanks!
Update 1:
Here's a live demo. list-grandparent and first-list are the nodes that are showing the multiple layers in my device. Ideally you should view this with Chrome for Android, that's where I need to fix the issue.

html, body {
  overflow: hidden;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
  min-height: 100vh;
}

.outermost-wrap {
  position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    overflow: hidden;
    background: transparent;
    z-index: 0;
}

.double-viewport-width {
  overflow-x: auto;
    height: 100%;
    position: relative;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translate3D(0, 0, 0);
  width: 200vw;
}

.single-viewport-width {
  width: 100vw;
  position: absolute;
    top: 0;
    bottom: 0;
    overflow-y: hidden;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translate3D(0, 0, 0)
}

.single-viewport-width:nth-child(1) {
  left: 0;
}

.single-viewport-width:nth-child(2) {
  left: 50%;
}

.list-grandparent {
  backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
    top: 45px;
  display: block;
  position: absolute;
    right: 0px;
    left: 0px;
    bottom: 0;
    top: 0;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    z-index: 100;
    background: #ccc;
    padding: 0 10px;
}

.first-list {
  padding: 0 5px;
    background-color: #fff;
    position: relative;
  margin-bottom: 60px;
  list-style: none;
}

.list-item {
  padding: 8px 5px;
    margin: 0;
    position: relative;
    background: #fff;
    border-bottom: solid 2px #eee;
    font-size: 1.1em;
    line-height: 1.3em;
    color: #000000;
    min-height: 54px;
}

.clickable-item {
  text-decoration: none;
  background-color: transparent;
}

.avatar {
  background-image: url(https://placehold.it/100x100);
  background-color: #EEEEEE;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    border-radius: 2px;
    float: left;
    height: 2.3em;
    margin: 2px 2% 0 0;
    width: 2.3em;
    max-width: 18%;
}

.text {
  clear: both;
    float: none;
    word-wrap: break-word;
  display: block;
    color: #666;
}

.image {
  position: relative;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    margin: 10px -13px;
    clear: both;
  display: block;
    color: #666;
}

.image img {
  width: 100%;
}

.more-clickable-stuff {
  background: none;
  color: #222;
    display: inline-block;
    font-size: 0.95em;
    width: 83%;
    max-width: 100%;
    position: relative;
}

.clickable-text {
  max-width: 67%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    padding: 0;
    margin: 0 3px 0 0;
}

              Hello there

              I can be clicked

              Second Hello there

              I can be clicked too

              Third Hello there

              I can be clicked three


text:
Q: File count of a directory in Objective-C I would like to know how can I get the total amount of archives inside of a directory, for example desktop.
I don't just want to know what's inside of the root of the directory, but also inside of its subfolders.
To just get the archives on the root of desktop I can do the following:
NSArray *directoryContent  = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
NSUInteger numberOfFileInFolder = [directoryContent  count];

But I need to get also the count of its subfolders.
Can somebody help me?
Edit:
Finally I have coded this way:
-(int) numberOfDocumentsInPath: (NSString *) path{
    NSFileManager *manager = [[NSFileManager alloc] init];

    NSDirectoryEnumerator* totalSubpaths = [manager enumeratorAtPath: path];

    NSLog(@"Path %@ has %d documents", path, (int)[[totalSubpaths allObjects] count]);

    return (int)[[totalSubpaths allObjects] count];
}

A: Try this:
 NSDirectoryEnumerator *subs = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:FolderPath error:nil];

A: Straight from the docs:

If you need to recurse into subdirectories, use
  enumeratorAtURL:includingPropertiesForKeys:options:errorHandler: as
  shown in "Using a Directory Enumerator").

Check also here:
Using a Directory Enumerator

A: Swift version:
var subs = NSFileManager.defaultManager().subpathsOfDirectoryAtPath(path, error: nil) as! [String]
var filecount = subs.count
println(filecount)

for sub in subs {
    //Do stuff with files
}


text:
Q: Ubuntu replaces wallpaper on startup Background
I have a small script that changes my wallpaper to a random image:
#!/bin/bash
feh --randomize --bg-fill /home/USERNAME/Pictures/wallpapers/*

It works like a charm, so I decided to add it to the startup applications, like in this question:

*

*how to run a specific command via a bash script and add in to a startup
Problem
Everything works fine except for one problem:

*

*On start up, the wallpaper is changed via the script, as expected. Then, seconds after, Ubuntu takes over and replaces that wallpaper with the default one.

Question
How can I keep this from happening?

A: Why Wallpaper is Replaced
Long story short, when you have desktop icons enabled, that essentially enables Nautilus to create the Desktop "window" with all the file and folder icons and manage background. feh works with raw X11 desktop, i.e. bare bones, where no icons exist. So there's two potential solutions: one is to rely on Ubuntu's settings for background, or two - disable desktop icons. One can also make a script to launch both feh and alter Ubuntu desktop settings, but that's redundant in my opinion. Whichever way you decide to go is up to you
Disabling/Enabling icons
This can be done via gsettings org.gnome.desktop.background show-desktop-icons false to disable and org.gnome.desktop.background show-desktop-icons true to enable. Once that's done Nautilus won't manage your desktop, hence won't set the background picture
Ubuntu Wallpaper Settings
Aside from obvious GUI methods, one can use gsettings command to set the wallpaper.
gsettings set org.gnome.desktop.background picture-uri file:///home/my_user/Pictures/cool_wallpaper.png

Of course, previously mentioned caveat applies - the desktop icons have to be enabled.
Alternative to Your Script
I have noticed that you are trying to set a random wallpaper from a folder.  You don't have to rely on feh for that. In the past, I've written two scripts to do this task. One written as bash script and another one as Python script. Both scripts work with Ubuntu's gsettings and alter the desktop wallpaper without disabling icons. Personally, I'd suggest the Python one as it is more polished.


text:
Q: DevServer 16.1 configuration issues I'm trying to move from devserver 14 to devserver 16.1 and I am having the following issues.
DevServer 16.1 doesn't start apache, php and mysql automatically. I need to go into the dashboard and manually start each process - after selecting which version to use. Is there an option somewhere to set these default values so that devserver starts them all automatically?
In mysql the datadir reverts back to the default :
datadir = "C:/myStuff/EasyPHP-Devserver-16.1/eds-binaries/dbserver/mysql5710x160114181656/data/" and not to where I want it to be datadir = "C:/myStuff/mySQL_Data/data". Why and how to resolve this issue?

A: Jeff
- if you haven't already moved to a different dev-server..
I just upgraded EasyPHP from v14 to v16 - its not easy.. ..but::
Once you have selected a version/module for Apache and PHP and started them both.. ..subsequent startups will start these severs automagically.


text:
Q: Convergence of series in p-adic field or non-archimedian field Field of $p$-adic numbers:

Show that  if $ \ \sum_{n=0}^{\infty} a_n \ $ converges , then $ \ \sum_{n=0}^{\infty} a_n^2 \ $ converges in p-adic field.

Answer:
At first remember that this is a Non-Archimedian field.
So the comparison test may be different.
That is why I am getting no way to prove it because
$ \sum_{n=0}^{\infty} a_n \ $ converges means $ \ a_n \to 0 \ $
Thus $ \ a_n \geq a_n^2 \ $
By comparison test,
$ \sum_{0}^{\infty} a_n \geq \sum_{0}^{\infty} a_n^2 \ $ converges.
But here in Non-archimedian field or p-adic field the comparison test is applicable or not I don't know.
Can some one help me?

A: In a non-archimedean space, we have the wonderful property that $\sum_{n \geq 0} a_n$ converges as soon as $a_n \to 0$.
Since $a_n \to 0$ implies that $a_n^2 \to 0$, you can conclude that $\sum_{n \geq 0} a_n^2$ converges.

A: There is a perfectly valid $p$-adic comparison test, as uninteresting as it may be.
Namely, if $\sum a_n$ is convergent and for each $n$, $|b_n|\le|a_n|$, then $\sum b_n$ is also convergent.
But as @Watson has pointed out, if $\sum a_n$ is convergent, then $|a_n|\to0$, and thus under the hypotheses on $\{b_n\}$, you get $|b_n|\to0$, so that automatically $\sum b_n$ will be convergent.


text:
Q: Searching in phone book using IDictionary I am trying to loop through the variable what i have taken as searching parameter but if i use loop the program will print 6 times "Not Found"
If i use m=0 and increment it with 1 with every increment of foreach loop it will only loop 3 times i.e., till the number of times "foreach" loop executed.
I am searcing with name1 parameter with evl.Key of dictionary phoneBook it is printing "Not Found" for every time.
class Solution
{
    public static void Main()
    {

        IDictionary<string, string> phoneBook = new Dictionary<string, string>();
        String[] name = new string[3];
        String[] phoneNumber = new string[3];
        for (int j = 0; j < 3; j++)
        {
            name[j] = Console.ReadLine();
            phoneNumber[j] = Console.ReadLine();
        }
        for (int i = 0; i < 3; i++)
        {
            phoneBook.Add(name[i], phoneNumber[i]);
        }
        String[] name1 = new string[3];
        for (int l = 0; l < 3; l++)
        {
            name1[l] = Console.ReadLine();
        }
        int m = 0;
        foreach (var getData in phoneBook)
        {
            if (getData.Key == name1[m])
            {
                Console.WriteLine(getData.Key + " = " + getData.Value);
            }
            else
            {
                Console.WriteLine("Not Found");
            }
            m = m + 1;
        }
    }
}

====================Input=====================
3
sam 99912222
tom 11122222
harry 12299933
sam
edward
harry

=====================This is my output==================
Not Found
Not Found
Not Found

=====================This will be expected output==============
sam=99912222
Not found
harry=12299933

A: I finally found and corrected the code. The corrected code is :
class Solution {
  static void Main(String[] args) {
    IDictionary<string, string> phoneBook = new Dictionary<string, string>();

        int n = System.Convert.ToInt32(Console.ReadLine());

        String[] name = new string[n];
        String[] phoneNumber = new string[n];
        for (int j = 0; j < n; j++)
        {
            string[] parts = Console.ReadLine().Split(' ');
            name[j] = parts[0].Trim();
            phoneNumber[j] = parts[1].Trim();
        }
        for (int i = 0; i < n; i++)
        {
            phoneBook.Add(name[i], phoneNumber[i]);
        }
        String[] name1 = new string[n];
        for (int l = 0; l < n; l++)
        {
            name1[l] = Console.ReadLine();
        }

        foreach (var name0 in name1)
        {
            string number;

            if (phoneBook.TryGetValue(name0, out number))
            {
                Console.WriteLine(name0 + "=" + number);
            }
            else
            {
                Console.WriteLine("Not found");
            }
        }
    }
}

Thanks to all contributors

A: There were a few problems that I corrected. See comments in the code.
class Solution
{
    public static void Main()
    {

        IDictionary<string, string> phoneBook = new Dictionary<string, string>();
        // First line of input contains 3 which looks like the number of entries in the phone book.
        // You have to read that number first.
        int count = System.Convert.ToInt32(Console.ReadLine());
        // Then, size the string arrays to count.
        String[] name = new string[count];
        String[] phoneNumber = new string[count];
        for (int j = 0; j < 3; j++)
        {
            // Read entire line consisting of name and phone number, and split into two strings
            // consisting of name, and phone number.
            string[] parts = Console.ReadLine().Split(' ');
            name[j] = parts[0].Trim();
            phoneNumber[j] = parts[1].Trim();
        }
        for (int i = 0; i < 3; i++)
        {
            phoneBook.Add(name[i], phoneNumber[i]);
        }
        String[] name1 = new string[3];
        for (int l = 0; l < 3; l++)
        {
            name1[l] = Console.ReadLine();
        }
        // You need to check for each name0 in name1, whether it exists in dictionary.
        foreach (var name0 in name1)
        {
            string number;
            // If name0 is in the phoneBook, number is set to its phone number.
            if (phoneBook.TryGetValue(name0, out number))
            {
                Console.WriteLine(name0 + " = " + number);
            }
            else
            {
                Console.WriteLine("Not Found");
            }
        }
    }
}

A: Console.ReadLine(), as its name suggests, reads a whole line at a time.
In other words, name[0] = "3"; then phoneNumber[0] = "sam 99912222"; and so on...
You will not be able to match "sam" and "harry" in the Dictionary's keys with your current code.
Don't input "3" on the first line, since you're not actually using that in your loops (as I expect you intended), then use something like String.Split() in the following code example...
using System;
using System.Collections.Generic;

namespace Searching_in_phone_book_using_IDictionary
{
    class MainClass
    {
        public static void Main()
        {
            IDictionary<string, string> phoneBook = new Dictionary<string, string>();
            String[] name = new string[3];
            String[] phoneNumber = new string[3];
            for (int j = 0; j < 3; j++)
            {
                var nameAndPhoneNumber = Console.ReadLine();
                name[j] = nameAndPhoneNumber.Split(' ')[0];
                phoneNumber[j] = nameAndPhoneNumber.Split(' ')[1];
            }
            for (int i = 0; i < 3; i++)
            {
                phoneBook.Add(name[i], phoneNumber[i]);
            }
            String[] name1 = new string[3];
            for (int l = 0; l < 3; l++)
            {
                name1[l] = Console.ReadLine();
            }
            int m = 0;
            foreach (var getData in phoneBook)
            {
                if (getData.Key == name1[m])
                {
                    Console.WriteLine(getData.Key + " = " + getData.Value);
                }
                else
                {
                    Console.WriteLine("Not Found");
                }
                m = m + 1;
            }
        }
    }
}

A: I think you have a bug in your code, it's working fine only when you put in the same order your name to search in the book:
You just only need to avoid using the m variable and use name1.Contains instead like follow:
    foreach (var getData in phoneBook)
    {
        if (name1.Contains(getData.Key))
        {
            Console.WriteLine(getData.Key + " = " + getData.Value);
        }
        else
        {
            Console.WriteLine("Not Found");
        }
    }


text:
Q: Can nodes in a hierarchichal layout be ordered with some function? Given a directed graph, where a value is associated with each node, how can we use vis.js to display the nodes ordered according to this value? E.g., all nodes at same depth are displayed left to right from "most valuable" to "least valuable"

A: In the example below, nodes 5 through 8 are children of node 4 and are added to left to right, in that order due to the index of edges and not with respect to the value of each node.
So we can rearrange edges to sort descending over the from node's value in nodes:
function rank(edges) {
  // get a copy of edges
  let edges2 = edges.map(function(edge) {return Object.assign({}, edge);});
  // sort edges by node value
  edges2.sort(function(a, b) {
    let nodeA = nodes.find(function(n) {return n.id == a.from});
    let nodeB = nodes.find(function(n) {return n.id == b.from});
    return nodeB.value - nodeA.value;
  });
  return edges2;
}

Working example with both unranked, and the ranking per this function:

const nodes = [
  {id: 1, level: 0, value: 1, label: "1"},
  {id: 2, level: 1, value: 1, label: "2"},
  {id: 3, level: 1, value: 2, label: "3"},
  {id: 4, level: 2, value: 1, label: "4"},
  {id: 5, level: 3, value: 1, label: "5"},
  {id: 6, level: 3, value: 2, label: "6"},
  {id: 7, level: 3, value: 3, label: "7"},
  {id: 8, level: 3, value: 4, label: "8"}
];

const edges = [
  {from: 2, to: 1},
  {from: 3, to: 1},
  {from: 4, to: 3},
  {from: 5, to: 4},
  {from: 6, to: 4},
  {from: 7, to: 4},
  {from: 8, to: 4}
];

const options = {
  nodes: {
    shape: "dot"
  },
  edges: {
    smooth: {
      type: "cubicBezier",
      forceDirection: "vertical",
      roundness: 0.4
    }
  },
  layout: {
    hierarchical: {
      direction: "UD",
    },
  },
  physics: false
}

// unranked
const data1 = {
  nodes: nodes,
  edges: edges
}
const container1 = document.getElementById("network1");
const network1 = new vis.Network(container1, data1, options);

// ranked
const data2 = {
  nodes: nodes,
  edges: rank(edges)
}
function rank(edges) {
  // get a copy of edges
  let edges2 = edges.map(function(edge) {return Object.assign({}, edge);});
  // sort edges by node value
  edges2.sort(function(a, b) {
    let nodeA = nodes.find(function(n) {return n.id == a.from});
    let nodeB = nodes.find(function(n) {return n.id == b.from});
    return nodeB.value - nodeA.value;
  });
  return edges2;
}
const container2 = document.getElementById("network2");
const network2 = new vis.Network(container2, data2, options);
#wrapper {
  display: flex;
}

#network1 {
  flex: 0 0 50%;
  height: 180px;
  border: 1px solid #000;
}

#network2 {
  flex: 1;
  height: 180px;
  border: 1px solid #000;
}


text:
Q: How to create a directed graph from an array of items? I have an array of objects.
input = [
    {id:1,  from:h, to:l},
    {id:2,  from:b, to:e},
    {id:3,  from:p, to:q},
    {id:4,  from:e, to:h},
    {id:5,  from:e, to:g},
    {id:6,  from:l, to:m},
    {id:7,  from:m, to:k},
    {id:8,  from:k, to:i},
    {id:9,  from:g, to:i},
    {id:10, from:i, to:b}
]

The items in the array are sorted by an attribute called id.
The attribute id is unique.
Nodes in the graph should be connected by the from and to
attributes of each item in the array.
Example (not based in the above array):
{id:1, from:a, to:b} --> {id:2, from:b,to:c} --> {id:3, from:c, to:a}

The output of the algorithm should be this:
output = [
    {id:1,  from:h, to:l, next: [object with id = 6]},
    {id:2,  from:b, to:e, next: [object with id = 4, object with id = 5]},
    {id:3,  from:p, to:q, next: [null]},
    {id:4,  from:e, to:h, next: [object with id = 1]},
    {id:5,  from:e, to:g, next: [object with id = 9]},
    {id:6,  from:l, to:m, next: [object with id = 7]},
    {id:7,  from:m, to:k, next: [object with id = 8]},
    {id:8,  from:k, to:i, next: [object with id = 10]},
    {id:9,  from:g, to:i, next: [object with id = 10]},
    {id:10, from:i, to:b, next: [object with id = 2]}
]

So, the final directed graph should look like this:

A: Your original datastructure is a list of edges and is a fairly standard way to represent a graph datastructure. I think you are confusing the edges with nodes. In your list, the id uniquely identifies an edge, and the lowercase letters uniquely identify nodes.
Graphviz is a nice notation language for graphs. Translated to graphviz, your graph can be written like this:
digraph G {
h -> l
b -> e
p -> q
e -> h
e -> g
l -> m
m -> k
k -> i
g -> i
i -> b
}

You can use an online tool like http://www.webgraphviz.com/ to render this graphically. This will give a result like below. As you can see, this is quite different from the graph you drew.


text:
Q: Add text to field based on data from another table So I am still learning SQL, and I've been able to complete most of the tasks I have, but even the context of the code for this task eludes me.
So this is a small Oracle SQL DB and the task is:
UPDATE the product's description to include on the following string on those products that have not been ordered yet: "Special promotion: 25% off."
So I need to add the text "Special promotion: 25% off" to the end of the value in PRODUCT.PRODUCTDESCRIPTION if PRODUCT.PRODUCTID does not appear anywhere in the column ORDERDETAIL.PRODUCTID.

A: Here is a hint:
"PRODUCT.PRODUCTID does not appear anywhere in the column ORDERDETAIL.PRODUCTID"  .. suspiciously sounds like it .. NOT EXISTS.

 UPDATE PRODUCT
 SET    PRODUCTDESCRIPTION = PRODUCTDESCRIPTION || ' Special promotion: 25% off'
 WHERE  NOT EXISTS (
    SELECT 1
    FROM   ORDERDETAIL
    WHERE  ORDERDETAIL.PRODUCTID = PRODUCT.PRODUCTID
    );

It's a silly assignment, though. Nobody in this right mind would update the description like that. One would append the string dynamically in the display instead of writing it into the column.


text:
Q: Order list of objects I have the list of objects and I want to order by date. Here it is how I am trying to do it:
list_name.order_by('date')

Here it is the model of these objects:
class Tweet(models.Model):
    text = models.CharField(max_length=140)
    date = models.DateField(default=date.today)
    user = models.CharField(max_length=140)

The list consist of spesific filtered objects. However, I get error: 'list' object has no attribute 'order_by'. So, what is the solution to this problem?

A: The generic way to sort a list (or anything that's iterable) in Python is to use the function sorted(iterable, key=key_function).  The key argument is a function that returns the comparison value for each item to be sorted.
To apply this generic solution to your case you might use something like sorted(list_name, key=lambda tweet: tweet.date).
However, because you don't have a generic list but rather a list of items from the database provided by Django, which is order-aware, you should solve your problem in the chain of function calls you use to retrieve the objects in the first place.


text:
Q: installing behat on windows 7: not getting the autoexec I'm trying to install behat on a Windows Virtual Machine, but I'm getting stuck with the windows command prompt. Here is what I did:

*

*Installed xampp

*Installed Composer for windows

*Donwloaded behat using the git method (other methods do not
work for me) to C:\behat so that
C:\behat\bin\behat.bat and C:\behat\bin\behat both exist

*open windowns control panel

*search for "environment"

*click "edit the system environment variables"

*system and security > edit the system environment variables: add the the end of PATH "C:\behat\bin"

At this point I expect to be able to type in behat anywhere on my system using the command prompt as administrator, because the "bin" directory containing "behat.bat" is contained in the PATH, but typing in "behat" gives me "Could not open input file @bin_dir@\behatcd". typeing in behat.bat does not work either
I have never used Windows before so, this is probably obvious but I'm just not getting it.
Any advice greatly appreciated, thanks.
Albert

A: try typing
php behat

windows doesn't know behat is a php file and you need to tell it what to execute it with

A: Here you can find the step by step guide to install Behat on windows machine. openguider


text:
Q: Bootstrap 4 - Grid - last column is taking full width I have a basic Bootstrap 4 grid like this one:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    some content

    some content

    some content

    some content

    some content

    some content

    some content

Columns are correctly stretching and filling out the row width, but on some viewports last column is sent to next row (since it doesn't fit) and somehow stretching too much (and taking full width of row).
How can I prevent this from happening?

A: Use flex-nowrap on the row...

            some content

            some content

            some content

            some content

            some content

            some content

            some content

https://www.codeply.com/go/w8H4wPL8Vj

A: Columns inside a row can be styled using bootstrap class col-xs-* so that all your columns fit into the same row instead of going to the next row.
For example,

A: You can use the bootstrap breakpoints in col by add extra few classes such as:
col-lg-x where x is a given number in the 12 grid system provided by bootstrap, for example you want all seven column to be on one row on large screens, and it should breakdown to two on each row on mobile screen, you simply add a class col-xs-x where x is a given number from 1 to 12, by giving it col-xs-6 col-md-3 col-lg-1 where xs represents small and extra small devices, md represents medium devices and lg represents large screen devices.
You're simply translating that on xs devices it should be two on a row and on md devices it should be four on a row and lg devices should be that seven column on a row.
Link to understand more http://getbootstrap.com/docs/4.1/layout/grid/


text:
Q: How to send response code in REST services.? I am developing RESTful Services to CREATE operations. In my use case, it is enough to tell the clients whether the transaction is success or fail. And if fail, we need to send them back error code.
Is it possible to send only these information back without sending xml response or JSON response. If so, how to do it.
We have existing error code in 5 digits, we wont be changing this for this api. If this is not possible.
Will JSON response better than XML response.? We are accepting XML request.
Requesting your comments.

A: I'm going to assume this service will be called over HTTP, since that's what most people mean when they say "RESTful service."
Generally speaking, most people map "create" type functionality to POST methods (though you can also do it with PUT).
If you just need to indicate that the record was created, the answer is "None of the above" (i.e., you don't need a response body at all). Usually a 201 Created is returned with a Location header which specifies the URL of the newly-created resource. In theory, you could also return a 204 No Content since you don't need to pass anything other than the status code (though this would be more appropriate for a PUT, otherwise there is no way to communicate to the client the identifier of the newly-created resource).
For failures, usually a 400-series error is returned if the request message is bad (i.e., it's the client's fault) and a 500-series error is returned if a system error occurs when processing (i.e., it's the server's fault). If you need to convey additional information in the response body, consider returning a response that uses a media type of something like application/vnd.error which allows you to express context information about where the error occurred.


text:
Q: How to setup private-link using Terraform to access storage-account? I need to test my azure private-endpoint using the following scenario.

*

*We have a virtual netwroks with two sub-nets (vm_subnet and storage_account_subnet)

*The virtual-machine (vm) should be able to connect to the storage-account using a private-link.

So, the below image explains the scenario:

and then i need to test my endpoint using the below manual test-case:

*

*Connect to the azure virtual-machine using ssh and putty username: adminuser and password: P@$$w0rd1234!

*In the terminal ping formuleinsstorage.blob.core.windows.net (Expect to see the ip of storage account in the range of storage_account_subnet (10.0.2.0/24))

I deploy all the infrastructure using the below Terraform code:
provider "azurerm" {

  features {
    resource_group {
      prevent_deletion_if_contains_resources = false
    }
  }
}

resource "azurerm_resource_group" "main_resource_group" {
  name     = "RG-Terraform-on-Azure"
  location = "West Europe"
}
# Create Virtual-Network

resource "azurerm_virtual_network" "virtual_network" {
  name                = "Vnet"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name
}

# Create subnet for virtual-machine

resource "azurerm_subnet" "virtual_network_subnet" {
  name                 = "vm_subnet"
  resource_group_name  = azurerm_resource_group.main_resource_group.name
  virtual_network_name = azurerm_virtual_network.virtual_network.name
  address_prefixes     = ["10.0.1.0/24"]
}

# Create subnet for storage account

resource "azurerm_subnet" "storage_account_subnet" {
  name                 = "storage_account_subnet"
  resource_group_name  = azurerm_resource_group.main_resource_group.name
  virtual_network_name = azurerm_virtual_network.virtual_network.name
  address_prefixes     = ["10.0.2.0/24"]
}

# Create Linux Virtual machine
resource "azurerm_linux_virtual_machine" "example" {
  name                            = "example-machine"
  location                        = azurerm_resource_group.main_resource_group.location
  resource_group_name             = azurerm_resource_group.main_resource_group.name
  size                            = "Standard_F2"
  admin_username                  = "adminuser"
  admin_password                  = "14394Las?"
  disable_password_authentication = false
  network_interface_ids           = [
    azurerm_network_interface.virtual_machine_network_interface.id,
  ]

  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  source_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "16.04-LTS"
    version   = "latest"
  }
}

resource "azurerm_network_interface" "virtual_machine_network_interface" {
  name                = "vm-nic"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.virtual_network_subnet.id
    private_ip_address_allocation = "Dynamic"
    public_ip_address_id          = azurerm_public_ip.vm_public_ip.id
  }
}

# Create Network-interface and public-ip for virtual-machien

resource "azurerm_public_ip" "vm_public_ip" {
  name                = "vm-public-ip-for-rdp"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name
  allocation_method   = "Static"
  sku                 = "Standard"
}

resource "azurerm_network_interface" "virtual_network_nic" {
  name                = "vm_nic"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name

  ip_configuration {
    name                          = "testconfiguration1"
    subnet_id                     = azurerm_subnet.virtual_network_subnet.id
    private_ip_address_allocation = "Dynamic"
  }
}

# Setup an Inbound rule because we need to connect to the virtual-machine using RDP (remote-desktop-protocol)

resource "azurerm_network_security_group" "traffic_rules" {
  name                = "vm_traffic_rules"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name

  security_rule {
    name                       = "virtual_network_permission"
    priority                   = 100
    direction                  = "Inbound"
    access                     = "Allow"
    protocol                   = "*"
    source_port_range          = "*"
    destination_port_range     = "22"
    source_address_prefix      = "*"
    destination_address_prefix = "*"
  }
}

resource "azurerm_subnet_network_security_group_association" "private_nsg_asso" {
  subnet_id                 = azurerm_subnet.virtual_network_subnet.id
  network_security_group_id = azurerm_network_security_group.traffic_rules.id

}

# Setup storage_account and its container

resource "azurerm_storage_account" "storage_account" {
  name                     = "storagaccountfortest"
  location                 = azurerm_resource_group.main_resource_group.location
  resource_group_name      = azurerm_resource_group.main_resource_group.name
  account_tier             = "Standard"
  account_replication_type = "LRS"
  account_kind             = "StorageV2"
  is_hns_enabled           = "true"

}

resource "azurerm_storage_data_lake_gen2_filesystem" "data_lake_storage" {
  name               = "rawdata"
  storage_account_id = azurerm_storage_account.storage_account.id

  lifecycle {
    prevent_destroy = false
  }
}

# Setup DNS zone
resource "azurerm_private_dns_zone" "dns_zone" {
  name                = "privatelink.blob.core.windows.net"
  resource_group_name = azurerm_resource_group.main_resource_group.name
}

resource "azurerm_private_dns_zone_virtual_network_link" "network_link" {
  name                  = "vnet_link"
  resource_group_name   = azurerm_resource_group.main_resource_group.name
  private_dns_zone_name = azurerm_private_dns_zone.dns_zone.name
  virtual_network_id    = azurerm_virtual_network.virtual_network.id

}

# Setup private-link

resource "azurerm_private_endpoint" "endpoint" {
  name                = "storage-private-endpoint"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name
  subnet_id           = azurerm_subnet.storage_account_subnet.id

  private_service_connection {
    name                           = "private-service-connection"
    private_connection_resource_id = azurerm_storage_account.storage_account.id
    is_manual_connection           = false
    subresource_names              = ["blob"]
  }
}

resource "azurerm_private_dns_a_record" "dns_a" {
  name                = "dns-record"
  zone_name           = azurerm_private_dns_zone.dns_zone.name
  resource_group_name = azurerm_resource_group.main_resource_group.name
  ttl                 = 10
  records             = [azurerm_private_endpoint.endpoint.private_service_connection.0.private_ip_address]
}

The problem is, my endpoint does not work ! But, if i try to add the service-endpoint manually then everything works well like a charm. So,i think, my DNS Zone is correct, also apparently the link to the storage-account is also working well. So, I think there should be something wrong with my private-link ! Any idea ?
Update:
Here are versions:
Terraform v1.2.5
on windows_386
+ provider registry.terraform.io/hashicorp/azurerm v3.30.0

A: I believe the issue lies in the name of the dns_a_record. This should be the name of the storage account you want to reach via the private link.
The following Terraform code is working for me:
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=3.30.0"
    }
  }
}

provider "azurerm" {
  features {
    resource_group {
      prevent_deletion_if_contains_resources = false
    }
  }
}

resource "azurerm_resource_group" "main_resource_group" {
  name     = "RG-Terraform-on-Azure"
  location = "West Europe"
}

# Create Virtual-Network
resource "azurerm_virtual_network" "virtual_network" {
  name                = "Vnet"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name
}

# Create subnet for virtual-machine
resource "azurerm_subnet" "virtual_network_subnet" {
  name                 = "vm_subnet"
  resource_group_name  = azurerm_resource_group.main_resource_group.name
  virtual_network_name = azurerm_virtual_network.virtual_network.name
  address_prefixes     = ["10.0.1.0/24"]
}

# Create subnet for storage account
resource "azurerm_subnet" "storage_account_subnet" {
  name                 = "storage_account_subnet"
  resource_group_name  = azurerm_resource_group.main_resource_group.name
  virtual_network_name = azurerm_virtual_network.virtual_network.name
  address_prefixes     = ["10.0.2.0/24"]
}

# Create Linux Virtual machine
resource "azurerm_linux_virtual_machine" "example" {
  name                            = "example-machine"
  location                        = azurerm_resource_group.main_resource_group.location
  resource_group_name             = azurerm_resource_group.main_resource_group.name
  size                            = "Standard_F2"
  admin_username                  = "adminuser"
  admin_password                  = "14394Las?"
  disable_password_authentication = false
  network_interface_ids           = [
    azurerm_network_interface.virtual_machine_network_interface.id,
  ]

  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  source_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "16.04-LTS"
    version   = "latest"
  }
}

resource "azurerm_network_interface" "virtual_machine_network_interface" {
  name                = "vm-nic"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.virtual_network_subnet.id
    private_ip_address_allocation = "Dynamic"
    public_ip_address_id          = azurerm_public_ip.vm_public_ip.id
  }
}

# Create Network-interface and public-ip for virtual-machien
resource "azurerm_public_ip" "vm_public_ip" {
  name                = "vm-public-ip-for-rdp"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name
  allocation_method   = "Static"
  sku                 = "Standard"
}

resource "azurerm_network_interface" "virtual_network_nic" {
  name                = "storage-private-endpoint-nic"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name

  ip_configuration {
    name                          = "storage-private-endpoint-ip-config"
    subnet_id                     = azurerm_subnet.virtual_network_subnet.id
    private_ip_address_allocation = "Dynamic"
  }
}

# Setup an Inbound rule because we need to connect to the virtual-machine using RDP (remote-desktop-protocol)
resource "azurerm_network_security_group" "traffic_rules" {
  name                = "vm_traffic_rules"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name

  security_rule {
    name                       = "virtual_network_permission"
    priority                   = 100
    direction                  = "Inbound"
    access                     = "Allow"
    protocol                   = "*"
    source_port_range          = "*"
    destination_port_range     = "22"
    source_address_prefix      = "*"
    destination_address_prefix = "*"
  }
}

resource "azurerm_subnet_network_security_group_association" "private_nsg_asso" {
  subnet_id                 = azurerm_subnet.virtual_network_subnet.id
  network_security_group_id = azurerm_network_security_group.traffic_rules.id

}

# Setup storage_account and its container
resource "azurerm_storage_account" "storage_account" {
  name                     = <STORAGE_ACCOUNT_NAME>
  location                 = azurerm_resource_group.main_resource_group.location
  resource_group_name      = azurerm_resource_group.main_resource_group.name
  account_tier             = "Standard"
  account_replication_type = "LRS"
  account_kind             = "StorageV2"
  is_hns_enabled           = "true"

}

resource "azurerm_storage_data_lake_gen2_filesystem" "data_lake_storage" {
  name               = "rawdata"
  storage_account_id = azurerm_storage_account.storage_account.id

  lifecycle {
    prevent_destroy = false
  }
}

# Setup DNS zone
resource "azurerm_private_dns_zone" "dns_zone" {
  name                = "privatelink.blob.core.windows.net"
  resource_group_name = azurerm_resource_group.main_resource_group.name
}

resource "azurerm_private_dns_zone_virtual_network_link" "network_link" {
  name                  = "vnet-link"
  resource_group_name   = azurerm_resource_group.main_resource_group.name
  private_dns_zone_name = azurerm_private_dns_zone.dns_zone.name
  virtual_network_id    = azurerm_virtual_network.virtual_network.id
}

# Setup private-link
resource "azurerm_private_endpoint" "endpoint" {
  name                = "storage-private-endpoint"
  location            = azurerm_resource_group.main_resource_group.location
  resource_group_name = azurerm_resource_group.main_resource_group.name
  subnet_id           = azurerm_subnet.storage_account_subnet.id

  private_service_connection {
    name                           = "storage-private-service-connection"
    private_connection_resource_id = azurerm_storage_account.storage_account.id
    is_manual_connection           = false
    subresource_names              = ["blob"]
  }
}

resource "azurerm_private_dns_a_record" "dns_a" {
  name                = azurerm_storage_account.storage_account.name
  zone_name           = azurerm_private_dns_zone.dns_zone.name
  resource_group_name = azurerm_resource_group.main_resource_group.name
  ttl                 = 10
  records             = [azurerm_private_endpoint.endpoint.private_service_connection.0.private_ip_address]
}

Additionally, I'm not sure whether it is possible to ping storage accounts. To test I ran nslookup <STORAGE_ACCOUNT_NAME>.blob.core.windows.net both from my local machine and from the Azure VM. In the former case, I got a public IP while in the latter I got a private IP in the range defined in the Terraform config, which seems to be the behaviour you are looking for.


text:
Q: Как создать копию сайта с измененным дизайном? Поясню вопрос:
Допустим у меня есть страница, в iframe которой грузится сайт
<!DOCTYPE html>
<html>
  <head>
    <title>Винтовые сваи Сергиев Посад</title>
    <script src="http://code.jquery.com/jquery.js"></script>
  </head>

  <body>
    <iframe src="http://www.ya.ru"></iframe>
  </body>
</html>

Моя цель - визуально изменить элементы сайта, который подгружается в iframe, сохранив при этом функциональность сайта. И это можно было бы с делать с помощью jQuery, но кроссдоменная политика запрещает это.
С помощью каких инструментов я могу реализовать подобное? Возможно посоветуете фреймворк на PHP для этих целей или еще какие то методы.
A: Для парсинга сайта есть хорошая библиотека phpQuery.