text:
Q: Windows 7 BSOD at same occasions Since I installed Win7 on my DELL Inspiron 1520 notebook, I frequently experience BSODs.
I noticed that those nearly only happen on two occasions

*

*disconnecting a DUN connection (Bluetooth, UMTS USB stick, even VPN)

*with certain file open dialogs (most of the time UPLOADING in Firefox or Chrome, strangely enough downloading with dialog works perfect)

The BSOD doesn't appear always on these actions.
BluescreenView told me that most of the time it is

*

*srv2.sys+45883 or

*srv2.sys+42982 or

*ntoskrnl.exe+71ef2

*ntoskrnl.exe+71f00

*ntoskrnl.exe+ef6a2

Now I read that srv2.sys is for NETBIOS sharing, which could be triggered when opening the file open dialog. All unused NICs are deactivated.
Any ideas how to fix this?
EDIT: The same BSODs occur after installing some drivers

A: See this thread: srv2.sys causing BSOD in Windows 7 Ultimate x64.
There the problem was analyzed as caused by the personal firewall, which blocks local NETBIOS ports, thus causing Windows 7 system services to crash because of denial of access to the ports, and specially the Smb 2.0 Server driver srv2.sys.
I would turn all firewalls off for a time, including that of Windows. (If you're behind a router, you don't really need a firewall in any case.) If the problem disappears, then replace your firewall by another.
The above thread also recommends updating the Asus AI Suite ATK0110 utility drive. If that applies to your case, the Asus driver updates link is here.
EDIT
According to your input, this is probably a driver problem.
In any case, a driver is always the most likely cause of a BSOD.
Your case is similar to that discussed in this thread, that discusses drivers for Win7 for the Inspiron 1520. It offers the following links:
Intel graphics drivers: Intel Download Center
nVidia graphics drivers: nVidia Drivers
Media Card Reader drivers: from Dell (listed for another laptop) in Dell Search for R234107
Dell Wireless 355 Bluetooth adapter: here

A: Try updating every driver you can download from Dell. Sounds like some sort of hardware glitch (wildly guessing without knowing the STOP number).

A: Aaaancient question, but I ran across the same issue on Windows 8.1 recently:

with certain file open dialogs (most of the time UPLOADING in Firefox or Chrome, strangely enough downloading with dialog works perfect)

It was really persistent, almost 75 % of the time it happened in an identical fashion:

*

*In Firefox, open some website that has an "Open File" dialog button on it

*Click the button

*In the dialog address bar, paste an URL to some file on a website.

*

*I used image files, like https://example.com/example.gif or https://example.com/example.jpg

*Press the "Open" button

*BSOD would happen 75 % of the time, all of a sudden

Now, in my case, the fix was simple, but I found it by sheer accident:
Clear your Temporary Internet Files
For example using the built-in Disk Cleanup program (Windows key --> disk cleanup).
That's it. I never got another BSOD.
I think somehow the "temp" dirs (it has some sort of rotation with different "hex" directories) becomes overpopulated, even if you still have hundreds of gigabytes of disk space left on C:

A: Have installed your firmware? Your laptop model comes with Vista drivers and those work perfectly with Windows 7. I have Windows 7 installed on the same model and  it works perfectly with the Vista drivers that came with the laptop. If you don't have your drivers CD/DVD download them from this link


text:
Q: Django HTTP_REFERER refers to incorrect page I have a django app that contains a link from the homepage that links to View1 that redirects to View2 and should redirect back to View1. However, the HTTP_REFERER header in View2 sees the homepage as the referer and not View1.
Homepage Template
...

Login
...

Login View
class LoginView(views.View):
    def dispatch(self, request, *args, **kwargs):
        if not request.session.test_cookie_worked():
            request.session.set_test_cookie()
            # This redirects to the create_captcha view
            return redirect(reverse('create_captcha'))

        return super().dispatch(request, *args, **kwargs)

create_captcha view
def create_captcha(request):
    if not request.session.test_cookie_worked():
        return render("Please enable cookies and try again.")

    # This SHOULD redirect to LoginView but instead redirects to the homepage.
    return redirect(to=request.META.get('HTTP_REFERER'))

Expected Behavior: homepage link -> LoginView -> create_captcha -> LoginView
Actual Behavior: homepage link -> LoginView -> create_captcha -> homepage
Question: How do I make the HTTP_REFERER point to the LoginView instead of the homepage?

A: There's nothing in the HTTP standard that says what should happen to a HTTP_REFERER after a redirect, so your code is going to be browser dependent. Also, HTTP_REFERER isn't always respected/enabled.
From your code it seems like you can just redirect to the URL directly:
return redirect('login')

but I assume you want to handle some other cases.
You'd be better off adding a query string on to your URL such as:
return redirect(reverse('create_captcha') + '?next=' + reverse('login')

Or a bit nicer on modern Python:
return redirect(f"{reverse('create_captcha')}?next={reverse('login')}")

And in the captcha view:
return redirect(request.GET['next'])

redpajama_set_name: RedPajamaStackExchange


text:
Q: ActiveMQ and Java routes I'm new to ActiveMQ (version 5.9.1) and Apache Camel. I'm experimenting about a couple of routes. I wrote them in Java, then packed in a .jar and deployed on %ACTIVEMQ_HOME%/lib. In my custom foo-activemq.xml I added a camelContext tag with a package child tag. Here is my relevant .xml
...
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
  <package>edu.foo.amq.camel</package>
</camelContext>
...

And here are my two routes:
package edu.foo.amq.camel;

import org.apache.camel.builder.RouteBuilder;

public class NumberRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {
    from("jms:queue:number.queue")
      .marshal("UTF-8")
      .choice()
      .when(header("readyToGo").isNotEqualTo(true))
        .to("jms:queue:big.number.queue");
    }
}

and
package edu.foo.amq.camel;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;

public class BigNumberRoute extends RouteBuilder {

@Override
public void configure() throws Exception {
    from("jms:queue:big.number.queue")
    .marshal("UTF-8")
    .split(body().tokenize("\n")).streaming()
    .process(new Processor() {
        @Override
        public void process(Exchange arg0) throws Exception {
            arg0.getIn().setHeader("readyToGo", true);
            System.out.println(arg0.getIn().getBody(
                    String.class));
            }
        })
        .to("jms:queue:number.queue");
    }
}

When I start my ActiveMQ broker I can see ... Total 0 routes, of wich 0 is started.. If I look at the ActiveMQ web console I can se the queues number.queue and big.number.queue up and running but my java routes don't. What am I missing?
UPDATE:
I remove the camelContext tag from my foo-activemq.xml configuration file and add the import tag instead:
...
<import resource="jetty.xml"/>
<import resource="foo-camel.xml"/>
...

Here is my foo-camle.xml configuration file, I largely use the %ACTIVEMQ_HOME%/examples/conf/camel.xml file. I put this file into %ACTIVEMQ_HOME%/conf:
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://camel.apache.org/schema/spring
    http://camel.apache.org/schema/spring/camel-spring.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd">
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <package>edu.foo.amq.camel</package>
</camelContext>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://amq-broker?create=false"/>
        <property name="userName" value="${activemq.username}"/>
        <property name="password" value="${activemq.password}"/>
      </bean>
    </property>
</bean>

but the result is the same: ActiveMQ says no routes

A: The Camel configuration XML file must be added to the activemq.xml configuration file:
<import resource="foo-activemq.xml" />

EDIT:
What else?

*

*Rename foo-activemq.xml to the default activemq.xml

*Verify again if your jar is really in the lib directory (I am sure you have done that already)

*Add a simple test route to foo-camel-xml and check in the log file if this route is loaded, e.g.
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" >
    <package>edu.foo.amq.camel</package>
    <route>
        <from uri="direct:start" />
        <log message="${body}" />
    </route>
</camelContext>


text:
Q: Stack widget delete & add views dynamicly Android 3.0 Can anyone give me an example of using a Stack Widget and being able to remove and add views dynamically.
Here is an example.
1) Widget loads and you add 4 views to the widget
2) User loads and activity within the same widget package and uses a button to delete one of the 4 views.
I need an example how to do that.
Thanks for the help!!

A: Your StackView widget should have an implemntation of the RemoteViewsService.RemoteViewsFactory interface which includes the onDataSetChanged() method.  Within this method you need to update the widget from your data source.
Then in your application, any time your data set changes you can then tell any instances of your widget to refresh themselves by calling:

AppWidgetManager awm =
  AppWidgetManager.getInstance(getActivity());
  awm.notifyAppWidgetViewDataChanged(awm.getAppWidgetIds(new
  ComponentName(getActivity(),
  Your_App_Widget_Provider.class)),
  R.id.your_stack_view);


text:
Q: Why doesn't my right screen refresh correctly when my left screen does? I'm having a problem for which I can't find a solution.
I'm currently using an AMD Radeon HD 6870 in dual screen.
My left screen is plugged in HDMI and my right screen is plugged in DVI.
My problem is that my left screen works fine while my right screen is only refreshed when I'm changing the window focus or when I do a screenshot.
I did a factice one to be able to show you what's happening everytime, as long as I do not put the focus on an other window :

I installed the amd catalyst driver to be able to use both screens but its options looks weird : I can not change the refresh rate of my right dvi screen. Moreover, amd catalyst control center tells me my screen refresh rate is 75hz while arandr tells me it's 60Hz.
Does anybody have a solution for that ? Or have already faced the same problem ?
Edit :
Here is my xorg.conf file :

Section "ServerLayout"
    Identifier     "aticonfig Layout"
    Screen      0  "aticonfig-Screen[0]-0" 0 0
EndSection

Section "Module"
EndSection

Section "Monitor"
    Identifier   "aticonfig-Monitor[0]-0"
    Option      "VendorName" "ATI Proprietary Driver"
    Option      "ModelName" "Generic Autodetecting Monitor"
    Option      "DPMS" "true"
EndSection

Section "Monitor"
    Identifier   "0-DFP5"
    Option      "VendorName" "ATI Proprietary Driver"
    Option      "ModelName" "Generic Autodetecting Monitor"
    Option      "DPMS" "true"
    Option      "PreferredMode" "1920x1080"
    Option      "TargetRefresh" "60"
    Option      "Position" "0 0"
    Option      "Rotate" "normal"
    Option      "Disable" "false"
EndSection

Section "Monitor"
    Identifier   "0-DFP7"
    Option      "VendorName" "ATI Proprietary Driver"
    Option      "ModelName" "Generic Autodetecting Monitor"
    Option      "DPMS" "true"
    Option      "PreferredMode" "1920x1080"
    Option      "TargetRefresh" "60"
    Option      "Position" "1920 0"
    Option      "Rotate" "normal"
    Option      "Disable" "false"
EndSection

Section "Device"
    Identifier  "aticonfig-Device[0]-0"
    Driver      "fglrx"
    Option      "Monitor-DFP5" "0-DFP5"
    Option      "Monitor-DFP7" "0-DFP7"
    BusID       "PCI:1:0:0"
EndSection

Section "Device"
    Identifier  "amdcccle-Device[1]-1"
    Driver      "fglrx"
    Option      "Monitor-DFP5" "0-DFP5"
    BusID       "PCI:1:0:0"
    Screen      1
EndSection

Section "Screen"
    Identifier "aticonfig-Screen[0]-0"
    Device     "aticonfig-Device[0]-0"
    DefaultDepth     24
    SubSection "Display"
        Viewport   0 0
        Virtual   3840 1920
        Depth     24
    EndSubSection
EndSection

Section "Screen"
    Identifier "amdcccle-Screen[1]-1"
    Device     "amdcccle-Device[1]-1"
    DefaultDepth     24
    SubSection "Display"
        Viewport   0 0
        Depth     24
    EndSubSection
EndSection

Thanks


text:
Q: Simple Trace Question I'm clearly lacking insight on the following problem...
So let $C$ be a $2\times2$ matrix with entries in some field.  I want to know when I can find $A, B$ (also $2\times2$) such that $C=AB-BA$.  In particular, you should be able to find them iff ${\rm Tr}(C)=0$ right?  I'm having trouble with the "given ${\rm Tr}(C)=0$, prove that $A, B$" exist direction.
Methinks the problem is intended to be done with minimal background...i.e. knowing what a determinant is is less than kosher (nor should I know that $AB-BA$ is $[A,B]$).

A: In addition to the question joriki linked to, there exists several more references on the subject. Notably this paper seems to be quite elementary, with the main focus of the proof being a clever lemma. Another reference is this, but it uses the rational canonical form which may be too much.

A: Let $$C=\pmatrix{r&s\cr t&-r\cr}$$ Let $$A=\pmatrix{a&b\cr c&d\cr}\qquad B=\pmatrix{x&y\cr z&w\cr}$$ In a deleted answer, NKS did the hard work of calculating $$
AB-BA = \left( \begin{array}{cc} bz - cy & (a-d)y + b(w-x)\\(d-a)z + c(w-x)&cy-bz \end{array}\right)
$$
Assuming that calculation is correct (I haven't checked it), let $b=1,z=r,c=y=0$, then all we need is $w-x=s,(d-a)r=t$. This is fine unless $r=0$ and $t\ne0$. If $r=0$, let $b=z=c=y=1$, and $a-d+w-x=s,d-a+w-x=t$.
EDIT: Having checked the calculations, I think it should be $$
AB-BA = \left( \begin{array}{cc} bz - cy & (a-d)y + b(w-x)\\(d-a)z + c(x-w)&cy-bz \end{array}\right)
$$ If $r\ne0$ then we can take $b=1,z=r,c=y=0$ and take $a,d,w,x$ to satisfy $w-x=s,d-a=t/r$. If $r=0$, we can take $c=z=t,b=y=-s$ and take $a,d,w,x$ to satisfy $d+x-a-w=1$.

A: In your particular case it is particularly simple:
1) Prove that $\,T_0:=\{A\in M_2(\Bbb F)\;\;|\;\;tr. A=0\}\,$ is a subspace of dimension 3 in $\,M_2(\Bbb F)\,$ (hint: $\,T_0=\ker tr.\,$, and since $\,trace=tr.\,$ is a non-zero linear functional its kernel is a hyperplane=a proper subspace of maximal dimension)
2) Show that $\,M':=\operatorname{Span}\,\{\,[A,B]:=AB-BA\;\;|\;\;A,B\in M_2(\Bbb F)\,\}\,$ is a vector subspace of dimension 3 (hint:
$$A=\begin{pmatrix}a&b\\c&d\end{pmatrix}\,,\,B=\begin{pmatrix}w&x\\y&z\end{pmatrix}\Longrightarrow AB-BA=\begin{pmatrix}k&**\\*&-k\end{pmatrix}$$
with $\,k\,,\,*\,,\,**\in\Bbb F\,$ , so using this show the following is a basis for $\,M'\,$:
$$\left\{\begin{pmatrix}0&1\\0&0\end{pmatrix}\,\,,\,\,\begin{pmatrix}0&0\\1&0\end{pmatrix}\,\,,\,\,\begin{pmatrix}1&0\\0&-1\end{pmatrix}\right\}$$
3) Finally, it's easy to see that $\,M'\leq T_0\,$ , so...

A: This isn't the answer you are looking for, but it is stronger than the other answers so far. I.e. showing that given an nxn matrix, you can express it as the sum of $2n-1$ commutators.
You can show that given an nxn matrix $A$, it is the sum of 2 commutators. Let $A = D + N$, where $D$ is diagonal with trace zero and $N$ has zeros on its diagonal. You can then represent each of $D$, $N$ as a commutator. (This takes a little thought, but not too hard, I can give details if you need them)


text:
Q: get views starting x-y coordinates ontouch specific view
I am working on custom keyboard where i need XY coordinates of touched
  view.
First i tell you what i tried,
I have called getLeft() on view object, which gives me left edge
  measure in pixel and it gives x coordinate.
Then i called getRawX() & getRawY() which is working, but not
  fit for my purpose. Because as it gives XY coordinates on root layout,
  but it gives different measures as i touch different places on same
  view.
So how can i get starting and ending XY coordinate when i touched on
  view.

A: In your xml you will have to capture the click by placing the following in the views where you want to know the x and y coordinates.
android:onClick="findXY"

And then in your java place a function
public void findXY(View view) {
    int[] posXY = new int[2];
    view.getLocationOnScreen(posXY);
    int x = posXY[0];
    int y = posXY[1];
}


text:
Q: JavaScript - split array into groups with random number of objects I am working on this little app and I have an array of more than 100 objects which I want to split in groups. The tricky part is that I want my newly created arrays to contain random number of objects. For example:
initial:
["a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17", "a18", "a19"]
modified:
["a0", "a1", "a2"], ["a3", "a4", "a5", "a6", "a7"], ["a8"], ["a9", "a10"]...
I think you get the idea. I was stuck with this for the last few hours and I just can't figure it out.
I hope you can help me!
Thanks a lot

A: Since you didn't specify minimum number of arrays or min/max elements per array, here's a general purpose function that you can specify min/max elements for each array. Note though that this doesn't strictly enforce min elements, and indeed it may be impossible to 100% do, depending on how many elements there are in the original array vs. how many are randomly assigned to each array element.  For example if you have 10 elements original and you do min 2 max 4, you could end up with 3/3/3/1, because the min will be enforced up until there's not enough to enforce. You didn't really give any "rules" about that.
min and max are both optional and default to 1. If only min is specified, max will default to min.
also note that since arrays are passed by reference, this will by default "empty" the original array. If you want to preserve the original array, uncomment the first line in the function (obviously n/a if you opt to prototype it).
function randChunkSplit(arr,min,max) {
  // uncomment this line if you don't want the original array to be affected
  // var arr = arr.slice();
  var arrs = [],size=1;
  var min=min||1;
  var max=max||min||1;
  while (arr.length > 0) {
    size = Math.min(max,Math.floor((Math.random()*max)+min));
    arrs.push(arr.splice(0, size));
  }
  return arrs;
}

examples
var letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];

// randChunkSplit(letters)
[["a"], ["b"], ["c"], ["d"], ["e"], ["f"], ["g"], ["h"], ["i"], ["j"], ["k"], ["l"], ["m"], ["n"], ["o"], ["p"], ["q"], ["r"], ["s"], ["t"], ["u"], ["v"], ["w"], ["x"], ["y"], ["z"]]

// randChunkSplit(letters,3)
[["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"], ["j", "k", "l"], ["m", "n", "o"], ["p", "q", "r"], ["s", "t", "u"], ["v", "w", "x"], ["y", "z"]]

// randChunkSplit(letters,1,3)
[["a"], ["b", "c"], ["d", "e"], ["f", "g", "h"], ["i", "j", "k"], ["l"], ["m"], ["n", "o"], ["p", "q"], ["r"], ["s", "t"], ["u", "v", "w"], ["x", "y", "z"]]

// randChunkSplit(letters,2,3)
[["a", "b", "c"], ["d", "e", "f"], ["g", "h"], ["i", "j", "k"], ["l", "m", "n"], ["o", "p", "q"], ["r", "s", "t"], ["u", "v", "w"], ["x", "y", "z"]]

// randChunkSplit(letters,2,3)
// same thing as before, but notice how this time we end up with just 1 elem left over
[["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"], ["j", "k", "l"], ["m", "n", "o"], ["p", "q"], ["r", "s"], ["t", "u", "v"], ["w", "x", "y"], ["z"]]

Alternatively, you could prototype it to Array if you want, something like this:
Array.prototype.randChunkSplit = function (min,max) {
  var arrs = [],size=1;
  var min=min||1;
  var max=max||min||1;
  while (this.length > 0) {
    size = Math.min(max,Math.floor((Math.random()*max)+min));
    arrs.push(this.splice(0, size));
  }
  return arrs;
}

var letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];

letters.randChunkSplit(1,4)

A: Here's a framework for what you might want to do:
var initial = ["a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10"];
var modifiedArrays = [];
var totalItems = 0
var arraySize = 1

while (totalItems < initial.length) {
    if ((initial.length - totalItems) <= 30)}
        arraySize = initial.length - totalItems
        totalItems += arraySize
    }
    else
    {
        arraySize = Math.floor((Math.random()*30)+1);
        totalItems += arraySize
    }

    modifiedArrays.push(initial.slice(totalItems - arraySize, arraySize + 1));
}

Diclaimer: I have very little experience with JavaScript and this code is completely untested, so pardon any errors. Also, this script takes chunks of between 1 and 30 elements.

A: I made a few assumptions, namely, that there was no set size to the amount of arrays or a minimum size.
var original = ["a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17", "a18", "a19"];

var results = [];

var breaker = function(arr){
   if(arr.length === 0){
      return;
   }
   var pieceSize = Math.floor(Math.random()*arr.length) + 1,
       result = arr.splice(0, pieceSize);
   results.push(result);
   breaker(arr);
}


text:
Q: which version (jquery.min.js)using for datetimepicker field which version (jquery.min.js)working for datetimepicker.. client side it's working good but server side (javaEE IDE)getting datetime not displayed ..i checked all libraray files getting problem in jquery.min.js file only
which version suitable for datetimepicker ..Please any one help for me
Thanks in adavance

A: If you are using jquery UI's date time picker, then you must check their documentation about minimum Jquery version required for the date time picker to work.
http://jqueryui.com/
May be you have not uploaded jquery UI .js file to your server.
Check which plug-in is required to use date time picker.


text:
Q: examples of lifting properties A number of seemingly unrelated elementary notions can be defined uniformly with help of (iterated) Quillen lifting property
(a category-theoretic construction I define below) "starting" to a single (counter)example or a simple class of morphisms,
for example a finite group being nilpotent, solvable, p-group, a topological space being compact, discrete, T4 (normal).
I would like to see more examplees, to help me understand if there is a bigger picture behind.
Let me give the definitions.
For a property $C$ of arrows (morphisms) in a category, define
its {\em left and right orthogonals} as
$$ C^\perp := \{ f :\text{ for each }g \in C\ f \,\rightthreetimes\,  g \} $$
$$ {}^\perp C := \{ g :\text{ for each }f \in C\ f \,\rightthreetimes\,  g \} $$
here $f \,\rightthreetimes\,  g$ reads " $f$ has the left lifting property wrt $g$ ",
" $f$ is (left) orthogonal to $g$ ",
i.e.  for  $f:A\longrightarrow B$, $g:X\longrightarrow Y$,
$f \,\rightthreetimes\, g$ iff for each $i:A\longrightarrow X$, $j:B\longrightarrow Y$ such that $ig=fj$ ("the square commutes"),
there is $j':B\longrightarrow X$ such that $fj'=i$ and $j'g=j$ ("there is a diagonal
making the diagram commute").
Examples:
In the category Sets of sets the right orthogonal
${}^\perp \{\emptyset \longrightarrow \{*\}\}$ of the simplest non-surjection
$\emptyset \longrightarrow \{*\}$ is the class of surjections.
The triple left orthogonal $ ((\{\emptyset \longrightarrow \{*\}\}^\perp)^\perp)^\perp$ is the class of functions which split.
The left and right orthogonals of $ \{x_{1},x_{2}\}\longrightarrow \{*\} $, the simplest non-injection, are both precisely the class of injections.
A finite group $H$ is nilpotent iff $H\longrightarrow H\times H$ is in ${}^\perp(\{ 0\longrightarrow G : G\text{ arbitrary} \}^\perp)$
A Hausdorff space $K$ is compact iff $K\longrightarrow \{*\}$ is in  ${}^\perp({}^\perp(\{a\}\longrightarrow \{a{<}b\})_{<5})^{\perp})$;
here $^\perp(\{a\}\longrightarrow \{a{<}b\})_{<5}$ denotes maps in $^\perp(\{a\}\longrightarrow \{a{<}b\})$
between spaces of size less than 5.
I give more examples in the answers to my own question I posted,
as they require some notation.

A: A word on the bigger picture. Examples are absolutely ubiquitous in category theory. First note that if $\mathcal{C} \perp \mathcal{D}$, then $\mathcal{C}$ and $\mathcal{D}$ determine each other uniquely up to the closure operations ${}^\perp(()^\perp)$ and $(^\perp())^\perp$, so to understand what's going on largely boils down to understanding classes of morphisms of the form ${}^\perp(\mathcal{C}^\perp)$. Now consider:
Theorem
Let $\mathcal{K}$ be a locally presentable category and $\mathcal{K}^{[1]}$ its category of morphisms. Then the following are equivalent:

*

*Accessible, accessibly-embedded, weakly-reflective full subcategories $\mathcal{L} \subseteq \mathcal{K}^{[1]}$.

*Accessible, accessibly-embedded full subcategories $\mathcal{L} \subseteq \mathcal{K}^{[1]}$ which are closed under coproduct, pushout along arbitrary morphisms of $\mathcal{L}$, composition, transfinite composition, and retracts.

*Full subcategories $\mathcal{L} \subseteq \mathcal{K}^{[1]}$ of the form $\mathcal{L} = {}^\perp(\mathcal{C}^\perp)$ for some small set $\mathcal{C} \subseteq \mathcal{K}^{[1]}$
The proof is via the small object argument. Note that the "closure" conditions of (2) are always satisfied by a subcategory closed under ${}^\perp(()^\perp)$ in an arbitrary category.
And consider this: if $f: A \to B$ is a morphism and you can form the pushout $B\cup_A B$ of $f$ along itself, then the lifting property with respect to the map $B \cup_A B \to B$ is equivalent to lifts with respect to $f$ being unique, which means that the orthogonality relation we're talking about (usually called weak orthogonality) can be used to express strong orthogonality (where unique lifts exist). And we get analogously:
Theorem
Let $\mathcal{K}$ be a locally presentable category and $\mathcal{K}^{[1]}$ its category of morphisms. Then the following are equivalent:

*

*Accessible, accessibly-embedded, reflective full subcategories $\mathcal{L} \subseteq \mathcal{K}^{[1]}$.

*Accessible, accessibly-embedded full subcategories $\mathcal{L} \subseteq \mathcal{K}^{[1]}$ which are closed under colimits and pushouts and retracts along arbitrary morphisms of $\mathcal{L}$.

*Full subcategories $\mathcal{L} \subseteq \mathcal{K}^{[1]}$ of the form $\mathcal{L} = {}^\perp(\mathcal{C}^\perp)$ for some small set $\mathcal{C} \subseteq \mathcal{K}^{[1]}$ (where for the moment I'm using the more standard convention that ${}^\perp$ denotes strong orthogonality.
These theorems have implications for full subcategories of $\mathcal{K}$ rather than $\mathcal{K}^{[1]}$ by identifying an object $X$ with either $X \to 1$ or $\emptyset \to X$, as appropriate.
These two example theorems are meant to be illustrative. The provisos "accessible, accessibly-embedded" are technical, and can be omitted in the presence of the set-theoretical Vopenka's Principle.
In another direction, in a non-locally-presentable category like $\mathsf{Top}$ many of the same principles still apply, allowing one to concluded from "closure" properties of a class of morphisms as in (2) above that it is generated under ${}^\perp(()^\perp)$ by a small class of morphisms. $\mathsf{Top}$ itself also satisfies a weakening of the notion of local presentability called local boundedness; see the references on the nlab page for analogs of the above theorems in the locally bounded case. There is also a way to apply the above theorems directly to $\mathsf{Top}$, which also illustrates an example of the phenomenon you're looking for:
Example $\mathsf{Top}$ is the union of a chain of full, coreflective subcategories $\mathsf{Top} = \cup_\kappa \mathsf{Top}_\kappa$ which are locally presentable. Here $\kappa$ is a regular cardinal and $\mathsf{Top}_\kappa$ is the category of spaces of $<\kappa$-tightness, (I may be off by taking a successor cardinal here) and in fact
$\mathsf{Top}_\kappa = {}^\perp(\mathsf{Disc}_\kappa^\perp)$
where here $\perp$ denotes strong orthogonality and $\mathsf{Disc}_\kappa$ is the category of discrete spaces of cardinality $<\kappa$, considered as a full subcategory of $\mathsf{Top}$.
The moral is: any nice (~ "sufficiently cocomplete") subcategory $\mathcal{L}$ of a sufficiently-good cocomplete category $\mathcal{K}$ is definable in terms of lifting properties, unless some weird set-theoretical phenomenon is occurring.

A: To improve readability of iterated orthogonals, I write $C^l$ instead of $C^\perp$ and $C^r$ instead of $C^r$.
(i) $(\emptyset\longrightarrow \{*\})^r$, $(0\longrightarrow R)^r$, and $\{0\longrightarrow \Bbb Z\}^r$ are the classes of surjections in
      Sets, R-modules, and Groups, resp,
      (where $\{*\}$ is the one-element set, and in the category of groups, $0$ denotes the trivial group)
(ii) $(\{a,b\}\longrightarrow \{*\})^l=(\{a,b\}\longrightarrow \{*\})^r$, $(R\longrightarrow 0)^r$, $\{\Bbb Z\longrightarrow 0\}^r$ are  the classes of  injections in Sets, R-modules, and Groups, resp
(iii) in R-mod, a module $P$ is projective iff $0\longrightarrow P$ is in $(0\longrightarrow R)^{rl}$
a module $I$ is injective iff $I\longrightarrow 0$ is in $(R\longrightarrow 0)^{rr}$
(iv) in the category of groups,
        a finite group $H$ is nilpotent iff
        $H\longrightarrow     H\times H$ is in $\{\, 0\longrightarrow G : G\text{ arbitrary} \}^{lr}$
a finite group $H$ is solvable iff $0\longrightarrow H$ is in $\{\, 0\longrightarrow A : A\text{ abelian }\}^{lr}= \{\, [G,G]\longrightarrow {G} : G\text{ arbitrary }\}^{lr}$
a finite group ${H}$ is of order prime to $p$ iff $H\longrightarrow 0$ is in $\{\Bbb Z/p\Bbb Z\longrightarrow 0\}^{rr}$
a finite group  $H$ is a p-group iff $H\longrightarrow 0$ is in $\{\Bbb Z/p\Bbb Z\longrightarrow 0\}^{rr}$
a group $H$ is torsion-free iff $0\longrightarrow H$ is in $\{ n\Bbb Z\longrightarrow \Bbb Z: n>0 \}^r$
(v) in the category of metric spaces and uniformly continuous maps,
        a metric space $X$ is complete iff $\{1/n\}_n\longrightarrow \{1/n\}_n\cup \{0\} \,\rightthreetimes\,  X\longrightarrow \{0\}$
           where the metric on $\{1/n\}_n$ and $\{1/n\}_n\cup \{0\}$ is induced from the real line
a subset $A \subset  X$ is closed iff  $\{1/n\}_n\longrightarrow \{1/n\}_n\cup \{0\} \,\rightthreetimes\,  A\longrightarrow X$
for a connected topological space X, each function on $X$ is bounded
     iff $ \emptyset\longrightarrow X \,\rightthreetimes\,  \cup_n (-n,n) \longrightarrow  \Bbb R$ (disjoint union)

A: Properties of topological spaces.
Here I need to use some notation for finite topological spaces. I use the fact that a finite topological space
may be thought of as a category such that $card Hom(x,y)\leq 1$ for any objects $x,y$.
By convention, $ \{a{\rightarrow}b\}$ denote the space where $a$ is open and $b$ is closed; more generally, a subset is closed iff there are no arrows going outside the subset.
in maps, each point goes to "itself". The arrow $(\{a{\rightarrow}b\}\longrightarrow \{a=b\}$ denotes
the map to a singleton gluing together points $a$ and $b$.
$(\{a{\rightarrow}b\})^r_{<5}$ denotes maps in the class $(\{a{\rightarrow}b\})^r$ between spaces of size less than $5$.
a Hausdorff space $K$ is compact iff $K\longrightarrow \{*\}$ is in  $((\{a\}\longrightarrow \{a{\rightarrow}b\})^r_{<5})^{lr}$
a  Hausdorff space $K$ is compact iff $K\longrightarrow \{*\}$ is in  $$
     \{\, \{a\leftrightarrow b\}\longrightarrow \{a=b\},\, \{a{\rightarrow}b\}\longrightarrow \{a=b\},\,
     \{b\}\longrightarrow \{a{\rightarrow}b\},\,\{a{\leftarrow}o{\rightarrow}b\}\longrightarrow \{a=o=b\}\,\,\}^{lr}$$
a space $D$ is discrete iff $ \emptyset \longrightarrow  D$ is in $   (\emptyset\longrightarrow \{*\})^{rl}      $
a space $D$ is antidiscrete iff $ {D} \longrightarrow  \{*\} $ is in
$(\{a,b\}\longrightarrow \{a=b\})^{rr}= (\{a\leftrightarrow b\}\longrightarrow \{a=b\})^{lr} $
a space $K$ is connected or empty iff $K\longrightarrow \{*\}$ is in  $(\{a,b\}\longrightarrow \{a=b\})^l $
a space $K$ is connected and non-empty iff  for some arrow $\{*\}\longrightarrow K$ it holds that
$ \{*\}\longrightarrow K$ is in
            $   (\emptyset\longrightarrow \{*\})^{rll} = (\{a\}\longrightarrow \{a,b\})^l$
a space $K$ is non-empty iff $K\longrightarrow \{*\}$ is in $   (\emptyset\longrightarrow \{*\})^l$
a space $K$ is empty iff $K \longrightarrow \{*\}$ is in $   (\emptyset\longrightarrow \{*\})^{ll}$
a space $K$ is $T_0$ iff $K  \longrightarrow \{*\}$ is in $   (\{a\leftrightarrow b\}\longrightarrow \{a=b\})^r$
a space $K$ is $T_1$ iff $K  \longrightarrow \{*\}$ is in $   (\{a{\rightarrow}b\}\longrightarrow \{a=b\})^r$
a space $X$ is Hausdorff iff $\{x,y\} \longrightarrow  {X} \,\rightthreetimes\,  \{ {x} {\rightarrow} {o} {\leftarrow} {y} \} \longrightarrow  \{ x=o=y \}$
a non-empty space $X$ is regular (T3) iff for each arrow $    \{x\} \longrightarrow  X$ it holds
    $    \{x\} \longrightarrow  {X} \,\rightthreetimes\,  \{x{\rightarrow}X{\leftarrow}U{\rightarrow}F\} \longrightarrow  \{x=X=U{\rightarrow}F\}$
a space $X$ is normal (T4) iff $\emptyset \longrightarrow {X} \,\rightthreetimes\,   \{a{\leftarrow}U{\rightarrow}x{\leftarrow}V{\rightarrow}b\}\longrightarrow \{a{\leftarrow}U=x=V{\rightarrow}b\}$
a space $X$ is completely normal iff $\emptyset\longrightarrow {X} \,\rightthreetimes\,  [0,1]\longrightarrow \{0{\leftarrow}x{\rightarrow}1\}$
 where the map $[0,1]\longrightarrow \{0{\leftarrow}x{\rightarrow}1\}$ sends $0$ to $0$, $1$ to $1$, and the rest $(0,1)$ to $x$
 a space $X$ is path-connected iff $\{0,1\} \longrightarrow  [0,1] \,\rightthreetimes\,  {X} \longrightarrow  \{*\}$
a space $X$ is path-connected iff for each Hausdorff compact space $K$ and each injective map $\{x,y\} \hookrightarrow  K$ it holds
   $\{x,y\} \hookrightarrow  {K} \,\rightthreetimes\,  {X} \longrightarrow  \{*\}$
$(\emptyset\longrightarrow \{*\})^r$   is the class of surjections
$(\emptyset\longrightarrow \{*\})^{rr}$ is the class of subsets, i.e. injective maps $A\hookrightarrow B$ where the topology on $A$ is induced from $B$
$(\{b\}\longrightarrow \{a{\rightarrow}b\})^l$ is the class of maps with dense image
$(\{b\}\longrightarrow \{a{\rightarrow}b\})^{lr}$ is the class of closed subsets $A \subset  X$, $A$ a closed subset of $X$
$((\{a\}\longrightarrow \{a{\rightarrow}b\})^r_{<5})^{lr}$ is roughly the class of proper maps, i.e. a map between T4 spaces is in the class iff it is proper


text:
Q: Can't checkout out a remote branch which has been merged on Github I'm having an odd issue with checking out a remote branch from Github.
Scenario:
I checked out the master branch of a repo from Github. I then created a local branch branch_a and made my changes. I committed the changes to branch_a and pushed them to Github. I created a pull request for branch_a which was approved, and I merged it into master. I didn't delete the branch after the pull request.
Later I cloned a new copy of the repo and tried to checkout branch_a. However, when I try to checkout the branch with git checkout branch_a git fails silently and I am left still on master. The weirdest part is that I can see that the branch exists remotely when I call git branch -a.
To get around this I tried creating a new local branch with the same name as branch_a and made some changes. I pushed these changes and was able to create another pull request for the branch. However, if I clone another copy of the repo and try to check out the repo, I have the same problem where I can't checkout the remote branch_a with the pending changes in the pull request.

A: If the branch is in the remote origin and you are trying to checkout from this remote
Run git fetch origin branch_a and then checkout git checkout origin/branch_a

A: This helped me
git fetch --all

git checkout master

git branch new_branch

git checkout new_branch


text:
Q: PostgreSQL - how to order by a repeating set of same field values I'm not sure how to call what I'm aiming to achieve, so it is difficult to find an answer on SO. So I decided to post my own and, hopefully, someone will give it the proper naming.
I have the following values on table foo:
id       | myvalue
-------------------
98ff5ab  | 501
fa69ac0  | 502
66afb6a  | 501
988af2b  | 503
12a3f4b  | 503
81cde8a  | 502
788bf2b  | 502
55b3f4b  | 503
90ade8a  | 502

What I aim to achieve is some sort of ORDER BY where I will get myvalue repeating like:
id       | myvalue
-------------------
98ff5ab  | 501
fa69ac0  | 502
988af2b  | 503
66afb6a  | 501
81cde8a  | 502
12a3f4b  | 503
788bf2b  | 502
55b3f4b  | 503
90ade8a  | 502

So I have the field myvalue ordered as a sequential group, repeating like 501,502,503; 501,502,503; 502,503; 502.
How may I achieve this?

A: You can do this by ordering on the ROW_NUMBER, giving each myValue a position in its own group:
CREATE TABLE o (
  id serial,
  v int
);

INSERT INTO o(v) VALUES (1), (1), (1), (2), (2), (2), (3), (3), (3);

SELECT id, v, r -- you probably don't want to SELECT r here, simply here to show its value
FROM (
  SELECT id, v, ROW_NUMBER() OVER (PARTITION BY v) r
  FROM o
) s
ORDER BY r, v
;
┌────┬───┬───┐
│ id │ v │ r │
├────┼───┼───┤
│  1 │ 1 │ 1 │
│  4 │ 2 │ 1 │
│  7 │ 3 │ 1 │
│  2 │ 1 │ 2 │
│  5 │ 2 │ 2 │
│  8 │ 3 │ 2 │
│  3 │ 1 │ 3 │
│  6 │ 2 │ 3 │
│  9 │ 3 │ 3 │
└────┴───┴───┘
(9 rows)

A: This should do the trick:
select id, myvalue from (
select *, row_number() over(partition by myvalue order by myvalue) [order] from #temp )a
order by [order], myvalue

A: You can use row_number() to sort the result :
select id, myvalue
from (select *, row_number() over (partition by myvalue order by myvalue) seq
      from table t
     ) t
order by seq, myvalue;

A: A subquery is not needed:
select t.*
from t
order by row_number() over (partition by myvalue order by null), myvalue;


text:
Q: How to make disabled state of font awesome icon button? I am using font awesome icon button and I need to have a disabled state of the icon. I am able to make it look like disabled button using Bootstrap disabled class but it's clickable.
Is there any way to make is non-clickable ?
Here is my HTML code:--

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<button class='btn btn-primary disabled' disabled>

</button>

A: use pointer-events: none;

button{
    pointer-events: none;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<button class='btn btn-primary disabled' disabled>

</button>

A: .focus(), trigger(), & .blur()
After clarifying what OP really wanted: ***to keep button.disabled from stealing focus from enabled buttons. Updated demo does that but not to button[disabled] those are truely dead to the world.
[disabled] Attribute Always Works
[disabled] attribute works. Bootstrap .disabled class does not. See the tests in demo below.
Demo

$('.btn').on('click', function(e) {
  console.log('clicked')
});

$('.btn').not('.disabled').on('click', function() {
  $('.btn').removeClass('lastFocus');
  $(this).addClass('lastFocus');
});

$('.disabled').on('focus', function(e) {
  $(this).blur();
  $('.lastFocus').trigger('focus');
});
b {
  color: cyan
}

u {
  color: black;
  font-weight: 700
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />

<button class='btn btn-primary' disabled>
  [disabled] attribute
</button>

<button class='btn btn-primary disabled' disabled>
  [disabled] attribute and .disabled class
</button>

<button class='btn btn-primary disabled'>
  .disabled class
</button>

<button class='btn btn-primary disabled'>
  .disabled class
</button>

<button class='btn btn-primary'>
  enabled
</button>

A: Use this

 <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <button class='btn btn-primary disabled' disabled style="pointer-events:none">

    </button>

A:
You can try in this way also.

.xyz
        {
        cursor: not-allowed;
        pointer-events: none;
        color: #c0c0c0;
        background-color: #ffffff;
        }
 <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<button class='btn btn-primary xyz'>

</button>

A: It worked using pointer-events on icon.
Here is my answer:-

<button class='btn btn-primary disabled' disabled>

</button>

A: You can also use onclick="return false;" to make sure it won't fire click event.

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<button class='btn btn-primary disabled' onclick="return false;" disabled >

</button>


text:
Q: Scala : How to convert a List[String] to List[List[String]] I have a scala list as
scala> c
res18: List[String] = List(123  asd, 234 zxc)

and i want something like this
List(List(123,  asd),List(234, zxc))

how can i achieve that ? I tried
scala> var t = for (x <- c) x.split("\t")
t: Unit = ()

how can i split each element pf my list by space and then assign the result as a list of lists?

A: An alternative is to use map, what usually is more readable if you have only one step:
c.map(_.split(" ").toList)

A: You need to use yield keyword to return a list from for loop:
var result = for (x <- c) yield x.split(" ")

But this will result in List[Array[String]], if you want to have innerList`, use:
var result = for (x <- c) yield x.split(" ").toList


text:
Q: Angular 9 unable to run storybooks on ivy enabled library if library imports another ivy enabled library In Angular 8 without Ivy enabled I was able to code with a mono repo watching the library I was working on and running an app which that imported the library whilst running Storybook as well.
ng build my-lib --watch
ng s
npm run storybook

In an Angular 9 mono repo with Ivy enabled for the app and all feature libraries this works but if one of the feature itself (lib1 is dependent on another ivy enabled library (lib2) the error below be thrown for each component in the library (lib2)
zone.js:699 Unhandled Promise rejection: Failed to load comp1.component.html ; Zone: <root> ; Task: Promise.then ; Value: Failed to load comp1.component.html
I've opened a Storybook issue for this but I thought I would post an SO question to see if anyone else has found a workaround (other than disabling Ivy for the libraries which is not ideal as then I lose all the new Ivy debugging features).
A sample repo to recreate the issue is available here.

A: I've got this working by running ngcc before running storybook.
  "storybook": "ngcc && start-storybook -p 61610",


text:
Q: How to get unresolved externals in lib error? yes I actually want to get that error. I am using MSVC (the command prompt). I would like to have .lib that would require definition of external symbol that gets linked to it. I must understand something wrong about static linking, because to me my approach seems legit:
I have a file that looks roughly like this:
extern INFO_BLOCK user_setup;

int
crtInit()
{
    SetInfoBlock(&user_setup);
    return 0;
}

when I try to use the .obj of this file in compilation with the main module
cl main.c file.obj it says unresolved externals. That is desired behaviour.
Nevertheless, once I pack the file.obj with lib file.obj even using /include:user_data (which frankly I don't trust as being of any use in this case)
using the .lib with cl main.c /link file.lib does not generate missing externals and that is the problem. I need the programmer to define that symbol. Does extern get stripped away once you put your .obj in .lib? Where am I wrong?

A: If main.c does not contain any reference to crtInit there is no reason for the linker to pull that function into the generated binary - Thus it will not "see" the unresolved reference to user_setup at all.
When you mention an object file to the linker, you force it to include the object file into the binary, regardless of whether it is needed by the program or not.
Opposed to that, when you mention a library to the linker, it will only use the library to resolve unresolved references you already have at that point with object files that it pulls in from this library. In case nothing is unresolved up to this point (or not satisfied by any symbol in the library), the linker will not use anything from the library at all.
The above is also the reason why many linkers are a bit picky about the order of libraries when linking (typically from specific to generic - or "user" to "system"), because linkers are normally single pass and will only pull in what they "see" needed at this specific point in the linking process.


text:
Q: Firebase value not being deleted I tried to delete one child from Firebase, however, it is not removing it for some reason.
This is how I tied to delete it(I get the right reference):
FIRDatabase.database().reference().child("posts").child(commentsArray[indexPath.row].key).removeValue()

If I try to po this value the output is e.g:

https://snuspedia.firebaseio.com/posts/coments/-KTzfD1wOa9sRXw93gAF

Which is this:

Am I doing something wrong?

A: So what I recognize is that you miss the key of the post:
https://snuspedia.firebaseio.com/posts/<KEY OF YOUR POST>/comments/-KTzfD1wOa9sRXw93gAF

Reference code should include the key of the specific post:
FIRDatabase.database().reference().child("posts").child(<KEY OF YOUR POST>).child("comments").child(commentsArray[indexPath.row].key).removeValue()


text:
Q: Can't set column name from index to str(index) + string (Pandas, Python) I need to change the names of a subset of columns in a dataframe from whatever number they are to that number plus a string suffix.  I know there is a function to add a suffix, but it doesn't seem to work on just indices.
I create a list with all the column indices in it, then run a loop that, for each item in that list, it renames the dataframe column that matches the list item to the same number, plus the suffix string.
        if scalename == "CDR":
        print(scaledf.columns.tolist())
        oldCols = scaledf.columns[7:].tolist()
        for f in range(len(oldCols)):
            changeCol = int(oldCols[f])
            print(changeCol)
            scaledf.rename(columns = {changeCol:scalename + str(changeCol)})
        print(scaledf.columns)

This doesn't work.
The code will print out the column names, and prints out every item, but it does not rename the columns.  It doesn't throw errors, it just doesn't work.  I've tried variation after variation, and gotten all kinds of other errors, but this error-free code does nothing.  It just runs, and doesn't rename anything.
Any help would be seriously appreciated!  Thank you.

Adding sample of list:
45
52
54
55
59
60
61
66
67
68
69
73
74
75
80
81
82
94
101
103
104
108
110
115
116
117
129
136
138
139
143
144
145
150
151
157
158
159
171
178
180
181
185
186
187
192
193
199
200
201
213
220
222
223
227
228
229
234
235
236

A: Try this:
scaledf = scaledf.rename(columns=lambda c:scalename + str(c) if c in oldCols else c)


text:
Q: Comportamento do Math.Round tenho um projeto em VB.Net que utilizo a Função Round, porém veja o comportamento estranho:
System.Console.WriteLine(math.round(32.625,2)) '32.62
System.Console.WriteLine(math.round(32.635,2)) '32.64
System.Console.WriteLine(math.round(32.645,2)) '32.65

system.console.writeLine(math.round(21.525,2)) '21.52
System.Console.WriteLine(math.round(21.535,2)) '21.54
System.Console.WriteLine(math.round(21.545,2)) '21.54

Alguém sabe o motivo?


text:
Q: Получить полный путь к ключу массива PHP Есть массив:
$array = array(
    '0' => array(
        'KY0' => array(
            'k2' => array(
                'k3' => 0,
                'k4' => 1,
                'k5' => array(
                    'k6' => 1,
                    'k7' => 2,
                        'k8' => array(
                            'k9' => 9,
                        ),
                    'k10' => array(
                            'k11' => 4,
                            'k12' => 1,
                        ),
                ),
            ),
        ),
        'KY1' => array(
            'k2' => array(
                'k10' => 0
            ),
        ),
    ),
    '1' => array(
        'k10' => 6
    )
);

Мне необходимо найти например все ключи "k10" и вернуть их полный путь в виде нового массива.
Пытаюсь это сделать рекурсивным итератором:
    function FindPath(array $array, $SearchKey) {
        $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::CHILD_FIRST);

        foreach ($iterator as $key => $current) {
            if ($key == $SearchKey || $iterator->getDepth() < $depth) {
                $s[] = $key;

                if ($iterator->getDepth() == 0) {
                    $path[] = array_reverse($s);
                    $s = [];
                }

                $depth = $iterator->getDepth();
            }
        }
        return $path;
    }

print_r(FindPath($array, 'k10'));

Но на выходе получаю такой массив:
Array
(
    [0] => Array
        (
            [0] => 0
            [1] => KY1
            [2] => k2
            [3] => k10
            [4] => KY0
            [5] => k2
            [6] => k5
            [7] => k10
        )

    [1] => Array
        (
            [0] => 1
            [1] => k10
        )

)

Подскажите пожалуйста как мне получить массив следующего вида:
 Array
    (
        [0] => Array
            (
                [0] => 0
                [1] => KY0
                [2] => k2
                [3] => k5
                [4] => k10
            )

        [1] => Array
            (
                [0] => 0
                [1] => KY1
                [2] => k2
                [3] => k10
            )

        [2] => Array
            (
                [0] => 1
                [1] => k10
            )

    )

A: Бежим рекурсивно по массиву и добавляем в каждой итерации ключ в $path
После итерации убираем из $path последний элемент, чтобы в след цикле был верный путь
Когда встречаем ключ, который мы ищем - добавляем найденный $path в $paths
$paths = [];
fillPaths($array, 'k10', $paths);

var_dump($paths);

function fillPaths($array, $searchKey, &$paths = [], &$path = []) {
    foreach ($array as $key => $values) {
        $path[] = $key;
        if ($key === $searchKey) {
            $paths[] = $path;
        }
        if (is_array($values)) {
            fillPaths($values, $searchKey, $paths, $path);
        }
        array_pop($path);
    }
}


text:
Q: Effectiveness of Landau's Prime Ideal Theorem Is Landau's Prime Ideal Theorem effective? It seems clear that bounds of the strongest kind known on the error term cannot be made fully effective, due to the possibility of Siegel zeroes. At the same time, it seems hard to believe that an effective version in the style of Page's theorem on the prime numbers within $[1,x]$ in arithmetic progressions of length $\ll (\log x)^{2-\epsilon}$ isn't possible.
I am asking for an effective proof of the asymptotic statement, not, as I've just said, of the best known error term.


text:
Q: Memory layout of multiple inheritance after upcasting I am studying my c++ lecture, and the professor gives a slide with this code example on. He says that because b1 is the first parent (so I think the first one implemented?), it has the same memory adress as the child class (Mi).
Then, I am still confused why b2 is not equal to &mi, even though you specified it that way in Base1* b1 = &mi.
I thought it looked like this in memory (see picture), but I think, when looking at the fact that b2 == &mi is false, that this isn't correct. How should I change the picture to make it a correct representation of the memory layout?
Mi mi;                  //MI inherits both from Base1 and Base2

Base1* b1 = &mi;        // Upcast

Base2* b2 = &mi;        // Upcast

//Suppose b1 is first parent

//now we test:

b1 == &mi;     //true

b2 == &mi;     //false


text:
Q: Caliburn Micro actions I am confused with one thing. When I remove parameter (string firstName) from the methods (or from one of them) called ClearText and CanClearText, the button doesn't become disabled when the data is cleared.
Can you explain what Happens?
this is property;
public string FirstName
{
    get
    {
        return _firstName;
    }
    set
    {
        _firstName = value;
        NotifyOfPropertyChange(() => FirstName);
    }
}

these are the methods:
public bool CanClearText(string firstName)
{
    return !string.IsNullOrWhiteSpace(FirstName);
}

public void ClearText(string firstName)
{
    FirstName = "";
}

this is the corresponding textbox and button
<TextBox x:Name ="FirstName" MinWidth="100" Grid.Column="1" Grid.Row="2"></TextBox>
<Button Grid.Row="4" Grid.Column="1" x:Name="ClearText"> Clear Names </Button>

A: Technically you are not using the parameters passed to the action and guard so there is really no need for it.
You can also use properties as action guards as well
public string FirstName {
    get {
        return _firstName;
    }
    set {
        _firstName = value;
        NotifyOfPropertyChange(() => FirstName);
        NotifyOfPropertyChange(() => CanClearText);
    }
}

public bool CanClearText {
    get {
        return !string.IsNullOrEmpty(FirstName);
    }
}

public void ClearText() {
    FirstName = "";
}

What was happening before was that the UI was unaware of any changes to regarding the action's guard. Using the property approach and notifying the UI that it should recheck the guard will update the button's availability.
Any by using the property approach you can also take advantage of binding to the action guard. Like for example
if there is no reason to clear the text as it is empty then you can also hide the button.
<TextBox x:Name ="FirstName" MinWidth="100" Grid.Column="1" Grid.Row="2"></TextBox>
<Border x:Name="CanClearText" Grid.Row="4" Grid.Column="1">
    <Button x:Name="ClearText" Content="Clear Names" />
</Border>

Through Caliburn.Micro automatically binding the CanClearText border's visibility to the property it will hide whenever the CanClearText property is false.


text:
Q: Opera extension To put it simple: What's the fastest way to get the head element in an injected opera extension script ? (faster than waiting for DOMContentLoaded)
I insert a bunch of styles into loaded pages, and I'm not waiting for DOMContentLoaded (because the user wants to see the rendered css when the page loads, just like an usercss).
So I just get the head element (document.getElementsByTagName("head")[0] or document.head) and insert style elements into it; this works on most websites but I recently found out that it doesn't work on wikipedia because I can't get the head element without waiting for DOMContentLoaded.
PS:
I know that Opera extensions are inserted before any other script so does that mean that the head element isn't loaded when the script is inserted ? So why does it work on some sites ??

A: AFAIK, you can just do document.documentElement.appendChild() right away in your extension's script. The browser should sort things out just fine.


text:
Q: How to get the URL in the middleware in Laravel 5.5? i have project on laravel 5.5
im using middleware
and this is the code
<?php
namespace App\Http\Middleware;
use Closure;
class roleMiddleware
{
 public function handle($request, Closure $next)
{
    // if code to check where the url is
    // code here
    //else
    //code here
    //else
    //code
    //return $next($request);
}
}

so i need code to check where the request come from
and if it == something do this
if it == something else do that

A: You can use inside of your middleware:
$request->url(); // without query string

With query string you can use:
$request->fullUrl();

For more Request methods, see Illuminate\Http\Request.php class.


text:
Q: SQL com SELECT e SUBSELECT para montar um chat Olá galera do Stackoverflow, estou montando o SQL abaixo para montar um chat de atendimento ao usuário, que trás a lista de todas as conversas ativas, porém estou com um problema, meu SQL está trazendo a ultima mensagem de acordo com o id do Cliente, ou seja se a minha mensagem for a ultima, ele não exibe, e eu preciso colocar um COUNT se houverem mensagens novas caso a data_mensagem for > que a data_mensagem(atual) pra mim trazer as notificações de quantas mensagens são.
OBS: Tabela que armazena as mensagens: http://prntscr.com/jmkde8
SELECT CLI.id, CLI.nome, CLI.senha, CLI.email, CLI.cpf, CLI.celular, CLI.data_nasc, CLI.genero, CLI.data_cadastro, CLI.status, CLI.id_socket, ATEN.mensagem, COUNT(ATEN.mensagem) AS novas_mensagens, SUM(COMP.valor) AS valor_total, COMP.data AS ultima_compra, ARQ.nome AS foto, ATEN.data_mensagem
FROM ut_clientes AS CLI

LEFT JOIN ut_compras AS COMP ON COMP.id_cliente = CLI.id
LEFT JOIN ut_arquivos AS ARQ ON ARQ.id_tipo = CLI.id AND ARQ.tipo = 'ut_clientes'
LEFT JOIN ut_atendimentos AS ATEN ON ATEN.id_usuario_envio = CLI.id

WHERE ATEN.id_usuario_envio
  AND NOT EXISTS(
    SELECT ATEN.id_usuario_envio
    FROM ut_atendimentos AS ATEN2
    WHERE ATEN2.id_usuario_envio = CLI.id
    AND ATEN2.data_mensagem > ATEN.data_mensagem
  )
GROUP BY CLI.id
ORDER BY ATEN.data_mensagem DESC

Não sei se a ideia ficou clara, mas qualquer coisa é só me perguntar, agradeceria se alguém pudesse dar uma luz kkk
Valeu!


text:
Q: SVG stroke animation not working in Safari My JS code goes over each path, and adds a stroke-dasharray and stroke-dashoffset according to path length:
setTimeout(() => {
    const $paths = document.getElementsByTagName('path');
    for (const path of $paths) {
        const totalLength = path.getTotalLength();
        path.style.strokeDashoffset = totalLength;
        path.style.strokeDasharray = totalLength;
    }
}, 300);

Then, My CSS just animates the dashoffset to 0, while lowering the stroke opacity and raising the fill opacity:
.character path {
    fill-opacity: 0;
    stroke-opacity: 1;
    stroke-width: 2px;
    stroke: white;
    -webkit-animation: path 4s linear 1s both;
            animation: path 4s linear 1s both;
}

@keyframes path {
    70% {
        fill-opacity: 0;
    }

    80% {
        stroke-dashoffset: 0;
        stroke-opacity: 1;

    }

    100% {
        stroke-opacity: 0;
        stroke-dashoffset: 0;
        fill-opacity: 1;
    }
}

This works perfectly in Chrome - the animation shows the paths being drawn, but in Safari, the paths just show up without any animation.
I tried prefixing but it doesn't work.
EDIT: This is somehow related to the timeout I set, I just added it to the code of the question. I have to add that timeout because the svg is loaded dynamically.
Here is a Fiddle showing the problem (works in Chrome, not in Safari), thanks @kaiido.

A: I solved this by doing two things:

*

*Put the animation property in the JS as well

*I found out that Safari doesn't handle animations in setTimeout if the animation delay is larger than the timeout. So I lowered the delay to 200ms.

Updated JS:
setTimeout(() => {
    const $paths = document.getElementsByTagName('path');
    for (const path of $paths) {
        const totalLength = path.getTotalLength();
        path.style.strokeDashoffset = totalLength;
        path.style.strokeDasharray = totalLength;
        path.style.animation = 'path 4s linear 0.2s both';
  };
}, 300);

Working Fiddle


text:
Q: Creating an array with entries based on their position in the array I'm trying to create an array that is populated by integers given a formula for their position in the array.
Basically I'm trying to make an m X n matrix where the values of the array are determined by a formula based on their m and n value.
For example.
m = 4
n = 3

a^i,j (A sub i,j) where a = i*j would look like this:
[0, 0, 0]
[0, 1, 2]
[0, 2, 4]
[0, 3, 6]

so A(0,0) would be 0*0 = 0
A(3, 2) would be 3*2 = 6

A: A list comprehension can help here:
>>> m = 4
>>> n = 3
>>> [[x * y for y in range(n)] for x in range(m) ]
[[0, 0, 0], [0, 1, 2], [0, 2, 4], [0, 3, 6]]

You can also use NumPy and take advantage of broadcasting:
>>> import numpy as np
>>> np.arange(m).reshape(m, 1) * np.arange(n)
array([[0, 0, 0],
       [0, 1, 2],
       [0, 2, 4],
       [0, 3, 6]])

A: You could use fromfunction for this and just wrap that in numpy.matrix.
numpy.matrix(numpy.fromfunction(lambda x, y: x*y, (4,3), dtype=int))

Pass in any shape you like, I chose (4,3) to match your example.

A: That can easily be accomplished by using indices from numpy:
import numpy as np

ind = np.indices((4, 3))

Then
ind[0] * ind[1]

gives you the desired result:
array([[0, 0, 0],
       [0, 1, 2],
       [0, 2, 4],
       [0, 3, 6]])


text:
Q: Lagrange multiplier when constraint are not linearly dependent. To optimize a function $f:\mathbb R^n\longrightarrow \mathbb R$ under constraint $g_1,g_2$ we need to check that $\nabla g_1$ and $\nabla g_2$ are linearly independent. But what happen if $\nabla g_1$ and $\nabla g_2$ are linearly dependent ? It mean that $$\min_{g_1=0, g_2=0}f=\min_{g_1=0}f\ \ ?$$
Or we can't apply Lagrange multiplier ?

A: No, you can't just drop a constraint in this case. Basically, the solution will be found amongst the feasible points where either the gradient of the Lagrange function is zero or the gradients of constraints are linearly dependent. You will have to find all the feasible points where the gradients of the constraints are not linearly independent and check whether the solution is among them.


text:
Q: ActionLink sending a model of a complex type I'm trying to paginate the results of a "advanced search", I have a complex model that represents the search options;
int ZipCode
int MinAge
int MaxAge
Availability
    bool Monday
    bool Tuesday
    ...
    bool Friday
Requirements
    bool FirstAid
    bool DriversLicense

I'm using;
<%: Html.ActionLink("Next »", "Save", "Notification", Model.options)%>

Which correctly sends all the data at the first level, but anything that is a sub-object (Availability or requirements) isn't expanded in the URL, all I get is the class name and so I lose most of the search options when I click the link to change to a different page.
Any thoughts?

A: Somewhere down the line your Options object gets used as an argument to the RouteValueDictionary constructor:
http://msdn.microsoft.com/en-us/library/cc680272(v=VS.100).aspx
The code in that constructor does not recursively go down into the properties of your nested object.  It only will reflect over the first level of your properties.

A: I ended up creating a overridden ToString() method, which converted the complex model to a query string. Then created a Flat model which mapped the query string and a convert method to pop me back out the original complex object.
I won't lie... It's a lot of a hack.
But it all works, and rather reliably.


text:
Q: What's the best way to find Distinct strings in VB6? Consider a loop where you aggregate strings into a comma separated value string:
Dim Result As String
For Each Something In Things
    If Result <> vbNullString Then
        Result = Result & ","
    End If
    Result = Result & SomeStringFunction(Something)
Next Something

That works, but what if I only want distinct strings?  I've been using this method, but it seems very "heavy-weight":
Dim Dict As Dictionary
Set Dict = New Dictionary
For Each Something In Things
    Dict(SomeStringFunction(Something)) = vbNullString
Next Something

Dim Result As String
Dim vKey As Variant
For Each vKey In Dict.Keys
    If Result <> vbNullString Then
        Result = Result & ","
    End If
    Result = Result & CStr(vKey)
Next vKey
Set Dict = Nothing

A: OK, dirty hack time:
Dim Result As String
Dim noDupes as New Collection
For Each Something in Things
    On Error Resume Next
    noDupes.Add Something, Something
    If Err.Number = 0 Then
         If Result <> vbNullString Then
             Result = Result & ","
         End If
         Result = Result & SomeStringFunction(Something)
    End If
    Err.Clear
Next Something


text:
Q: horizontal line of repeating CSS triangles I am trying to achieve the following using CSS (just the white triangled horizontal line, not the grey background).

I am trying to apply it to a psuedo element like so, but I know I am missing something, or not doing it correctly.
&:after {
  content: '';
  width: 200px;
  height: 50px;
  position: absolute;
  background-repeat: repeat-x;
  background: linear-gradient(to bottom right, #fff 0%, #fff 50%, #a48d01 50%, #a48d01 100%);
}

A:

.gradient-bg{
  height: 50px;
  width: 100%;
  background: linear-gradient(45deg, transparent 50px, transparent 0px, #a48d01 50px, #a48d01 100px), linear-gradient(135deg, transparent 0px, transparent 50px, red 50px, red 100px);
  background-size: 40px;
  background-position: 0 30px;
}

Maybe this can give you some idea. you need to use two gradients.

A: Use a conic-gradient(). Adjust the variable s to control the size and the 80px to control the distance between triangles

.box {
  --s: 25px;
  height:200px;
  background:
   conic-gradient(from -135deg at var(--s) 50%,red 90deg,#0000 0) center/80px calc(2*var(--s)) repeat-x
}


text:
Q: "travelling" vs. "traveling" Is the correct spelling travelling or traveling? I've seen both in common usage, but I can't find an authoritative source that says one way or another.
Is this a difference between British spelling and American spelling?

A: There is no hard-and-fast rule that is universally applied, but in general, many and perhaps most writers of American English use just one single L there.
Other varieties, including British, Irish, Australian, New Zealand, South African, and (usually (but not always)) Canadian, almost invariably use two Ls there.
I draw your attention to the first bullet point under "Doubled Consonants".

A: British English Ngram
American English Ngram
It looks as though it is a difference between British spelling and American spelling, as the OP suspected.


text:
Q: How to check typed callback type inside Fragment.onAttach() I'm trying to implement abstract fragment with typed callback to use it in several subclasses.
How can I check if Context is instance of appropriate class?
My code of abstact CallbackFragment:
public abstract class CallbackFragment<C> extends Fragment {

    protected C mCallback;

    public CallbackFragment() {
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        //just in case
        if(context == null)
            throw new NullPointerException();

        try {
            mCallback = (C) context; //this line not seems to throw any exception
        } catch (ClassCastException exception) {
            throw new RuntimeException(context.toString() + " must implement Callbacks");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mCallback = null;
    }
}

Vehicle list fragment:
public abstract class VehicleListFragment<T extends Vehicle>
        extends CallbackFragment<VehicleListFragment.Callback<T>> {

    //callback for any list of any vehicle
    public interface Callback<T extends Vehicle> {
        void onListItemSelected(T selectedItem);
    }

    //common code for list of any vehicle
    public VehicleListFragment() {
    }
}

Bus, Truck, Boat, Bike, whatever list fragment:
public class BusListFragment
    extends VehicleListFragment<Bus> {

    //code specific for list of bus
    public BusListFragment() {
    }
}

Vehicle details fragment:
public abstract class VehicleDetailsFragment<T extends Vehicle, C extends VehicleDetailsFragment.Callback<T>>
        extends CallbackFragment<C> {

    //common methods of callback for any vehicle
    public interface Callback<T> {
        void onVehicleEdited(T editeItem);
    }

    //common code for any vehicle
    public VehicleDetailsFragment() {
    }
}

Bus, Truck, Boat, Bike, whatever details fragment:
public class BusDetailsFragment
        extends VehicleDetailsFragment<Bus, BusDetailsFragment.Callback> {

    //specific for Bus methods
    public interface Callback
            extends VehicleDetailsFragment.Callback<Bus> {
        void onSomethingSpecificForBusHappened(Bus bus);
    }

    //code specific for Bus
    public BusDetailsFragment() {
    }
}

I've tried to add an abstract method for CallbackFragment to get callback class:
public abstract class CallbackFragment<C> extends Fragment {

    ...

    @NonNull
    protected abstract Class<C> getCallbackClass();

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        ...

        //now checking instanceof like this
        if(!getCallbackClass().isAssignableFrom(context.getClass())){
            throw new RuntimeException(context.toString() + " must implement Callbacks");
        }
    }
}

With BusDetailsFragment everything looks OK:
public class BusDetailsFragment
        extends VehicleDetailsFragment<Bus, BusDetailsFragment.Callback> {

    @NonNull
    @Override
    protected Class<Callback> getCallbackClass() {
        return Callback.class;
    }

    ...
}

But not with BusListFragment:
public class BusListFragment
        extends VehicleListFragment<Bus> {

    @NonNull
    @Override
    protected Class<Callback<Bus>> getCallbackClass() {
        /**
         * I'm not seeing any option here
         *
         * mCallback - is null yet. So, there is no way to use mCallback.getClass()
         *
         * Callback<Bus>.class - Cannot select from parameterized type
         */
        //return mCallback.getClass();
        //return Callback<Bus>.class;
    }

    ...
}

Of course, I could create an own interface for every subclass of VehicleListFragment that extends VehicleListFragment.Callback (like in subclasses of VehicleDetailsFragment) but it will always look like this:
public interface Callback
        extends VehicleListFragment.Callback<Bus> {
    //nothing more here
}

This doesn't look like the best option for me. Maybe there is any other solution? Please share your thoughts. ANY help would be appreciated.

A: mCallback = (C) context; //this line not seems to throw any exception

this call will never throw an Exception. During Runtime, your C is replaced with Object(that's called Type-Erasure) - and everything is an Object. Therefore you can assign anything at this point.
To have the exception (or at least error-determination) at the point, where you need it, you can use:
public abstract class CallbackFragment<C> extends Fragment {

    protected C mCallback;
    protected Class<C> callbackClass;

    public CallbackFragment(Class<C> clazz) {
       this.callbackClass = clazz;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

        //just in case
        if(context == null)
            throw new NullPointerException();

        if (clazz.isAssignableFrom(context.getClass()){
            mCallback = (C) context;
        }else{
           //oops
        }
    }
}

ofc. then your FragmentCreation would change from
 CallbackFragment<Something> fragment = new CallbackFragment<Something>();

to
CallbackFragment<Something> fragment = new CallbackFragment<Something>(Something.class);

It's a little different, but allows you to keep track of the actual type at any time, bypassing the Type-Erasure.
ps.: For Inherited classes, you can do it more generic:
public abstract class CallbackFragment<C> extends Fragment {
    protected Class<C> callbackClass;

    public CallbackFragment() {
          this.callbackClass = (Class<C>) ((ParameterizedType) getClass()
                        .getGenericSuperclass()).getActualTypeArguments()[0];;
     }
}

public class CallbackFragmentOfSomething extends <CallbackFragment<Something>>{

}

This only fails, if your actual class is not defined due to inheritance, but "on the fly":
CallbackFragment<Something> fragment = new CallbackFragment<Something>();

(Everything untested / no copy paste, but should be somewhat accurate)


text:
Q: Where is the Postgresql config file: 'postgresql.conf' on Windows? I'm receiving this message but I can't find the postgresql.conf file:
OperationalError: could not connect to server: Connection refused (0x0000274D/10061)
    Is the server running on host "???" and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
    Is the server running on host "???" and accepting
    TCP/IP connections on port 5432?

A: postgresql.conf is located in PostgreSQL's data directory. The data directory is configured during the setup and the setting is saved as PGDATA entry in c:\Program Files\PostgreSQL\<version>\pg_env.bat, for example
@ECHO OFF
REM The script sets environment variables helpful for PostgreSQL

@SET PATH="C:\Program Files\PostgreSQL\<version>\bin";%PATH%
@SET PGDATA=D:\PostgreSQL\<version>\data
@SET PGDATABASE=postgres
@SET PGUSER=postgres
@SET PGPORT=5432
@SET PGLOCALEDIR=C:\Program Files\PostgreSQL\<version>\share\locale

Alternatively you can query your database with SHOW config_file; if you are a superuser.

A: You can find it by  following this path
C:\Program Files\PostgreSQL\13\data

A: On my machine:
C:\Program Files\PostgreSQL\8.4\data\postgresql.conf

A: On  my machine:
C:\Program Files (x86)\OpenERP 6.1-20121026-233219\PostgreSQL\data

A: you will get postgressql.conf file
C:/programfiles/postgressql/14/data
you will also get the pg_hba to check username password

A: PGDATA is assumed as ConfigDir under Postgresql, this works under docker and normal installation as well, this is default configuration until not changed explicitly.
on my docker PGDATA is configure as "/var/lib/postgresql/data" hence all configuration can be found under this directory.
#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------

# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.

#data_directory = 'ConfigDir'       # use data in another directory
                # (change requires restart)
#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
                # (change requires restart)
#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
                # (change requires restart)

# If external_pid_file is not explicitly set, no extra PID file is written.
#external_pid_file = ''         # write an extra PID file
                # (change requires restart)


text:
Q: Unexpected errors I do not know how to solve After some troubleshooting I am still getting some errors on this code that I do not know how to solve... this code basically divides an image in slices and uses convolution to blur the pixels. Yet I do not know how to eliminate the errors I get and also convolve the image using the function  "multiconvolve_2".
(I have attached the code and the console error message, any help and explannation is well appreciated).
#include <stdio.h>
#include <string.h>
#include <unistd.h>    // Unix-like system calls read and write
#include <fcntl.h>     // Unix-like system calls to open and close
#include<pthread.h>
#include "myutils.h"
//gcc convolution.c myutils.c -o conv -lpthread
#define WIDTH  1024
#define HEIGHT 1024
#define KLEN      7    // works with 3 or 7
#define KSIZE    49    // KLEN * KLEN

#define MAX(a, b) (a < b ? b : a)
#define MIN(a, b) (a < b ? a : b)

unsigned char* pixels; // a pointer to the original image (needs malloc)
unsigned char* target; // a pointer to the target of convolution (needs malloc)

typedef struct kernel_struct {
  int values[KSIZE];
  int sum;
} kernel_type;

kernel_type filter; // the 3x3 kernel used to convolve the image

static unsigned char tga[18];

// read a 1024x1024 image
void read_tga(char* fname) {
  int fd = open(fname, O_RDONLY);
  read(fd, tga, 18);
  read(fd, pixels, WIDTH * HEIGHT);
  close(fd);
}

// write a 1024x1024 image
void write_tga(char* fname, unsigned char *image) {
  int fd = open(fname, O_CREAT | O_RDWR, 0644);
  write(fd, tga, sizeof(tga));
  printf("Created file %s: Writing pixel size %d bytes\n", fname, WIDTH * HEIGHT);
  write(fd, image, WIDTH * HEIGHT);
  close(fd);
}

// create a random filter
void random_filter() {
  filter.sum = 0;
  for (int i = 0; i < KSIZE; i++) {
    filter.values[i] = rand() % 10;
    filter.sum += filter.values[i];
  }
}

void gaussian_3x3() {
  int values[] = { 1, 2, 1,
                   2, 4, 2,
                   1, 2, 1 };

  memcpy(filter.values, values, KSIZE * sizeof(int));

  filter.sum = 16;
}

void gaussian_7x7() {
  int values[] = { 0,  0,  1,   2,  1,  0, 0,
                   0,  3, 13,  22, 13,  3, 0,
                   1, 13, 59,  97, 59, 13, 1,
                   2, 22, 97, 159, 97, 22, 2,
                   1, 13, 59,  97, 59, 13, 1,
                   0,  3, 13,  22, 13,  3, 0,
                   0,  0,  1,   2,  1,  0, 0 };

  memcpy(filter.values, values, KSIZE * sizeof(int));

  filter.sum = 0;
  for (int i = 0; i < KSIZE; i++)
    filter.sum += filter.values[i];
}

// create a Gaussian filter
void gaussian_filter() {
  if (KSIZE == 9) gaussian_3x3();
  else if (KSIZE == 49) gaussian_7x7();
}

// create a horizonal filter
void horizontal_filter() {
  for (int i = 0; i < KSIZE; i++) {
    int row = i / KLEN;
    if (3 * row < KLEN)
      filter.values[i] = -1;
    else if (KLEN < 2 * row)
      filter.values[i] = 1;
    else
      filter.values[i] = 0;
  }

  filter.sum = 0;
}

// create a vertical filter
void vertical_filter() {
  for (int i = 0; i < KSIZE; i++) {
    int col = i % KLEN;
    if (3 * col < KLEN)
      filter.values[i] = -1;
    else if (KLEN < 2 * col)
      filter.values[i] = 1;
    else
      filter.values[i] = 0;
  }

  filter.sum = 0;
}

void interchange() {
  unsigned char* aux = pixels;
  pixels = target;
  target = aux;
}

// compute the target pixel at (x,y)
void compute_target_pixel(int x, int y) {
  int i, j, sum = 0;
  int delta = (KLEN - 1) / 2;
  for (i = -delta; i <= delta; ++i)
    for (j = -delta; j <= delta; ++j)
      if (0 <= x + i && x + i < WIDTH && 0 <= y + j && y + j < HEIGHT)
        sum += filter.values[(i + delta) * KLEN + (j + delta)] * pixels[(x + i) * HEIGHT + (y + j)];

  if(filter.sum > 0) target[x * HEIGHT + y] = sum / filter.sum;
  else target[x * HEIGHT + y] = sum;
}

void convolve() {
  int x, y;
  for (x = 0; x < WIDTH; ++x)
    for (y = 0; y < HEIGHT; ++y)
      compute_target_pixel(x, y);
}

void multi_convolve_1(int iter) {
  // Add Code here
  int i;
  for (i=1;i<iter;i++){
    convolve();
    interchange();

  }
}

void* convolveThread(void* idx){
  int* params=idx;
  int threadid=params[0];
  int totalthreads=params[1];
  int x,y;
  int numberows= WIDTH/totalthreads;
  for(x=numberows*threadid;x <numberows*(threadid+1); ++x){
    for(y=0;y < HEIGHT; ++y){
      compute_target_pixel(x,y);
    }
  }

  return NULL;
}

 void convolve_threaded(int numerodethreads){

   pthread_t thread[numerodethreads];
   int* params = malloc(2*sizeof(int));

   int i;

   params[1]=numerodethreads;
   for(i=0;i<numerodethreads;i++){
      params[0]=i;
      pthread_create( &thread[i],NULL, convolveThread, params);

   }
   for(i=0;i<numerodethreads;i++){
      pthread_join(thread,NULL);
      free(params);
   }
 }

multiconvolve_2(int iter, int nthreads){
  int i;
  for (i=0;i<iter;i++){
    convolve_threaded(nthreads);
    interchange();
  }
}

void load_image() {
  read_tga("test.tga");  // read the image
  memcpy(target, pixels, WIDTH*HEIGHT);
}

int main(void) {
  // Allocate images
  pixels = malloc(WIDTH * HEIGHT);
  target = malloc(WIDTH * HEIGHT);

  load_image();

  // create a filter
  gaussian_filter();
  //vertical_filter();
  //horizontal_filter();

  load_image();
  multiconvolve_2(8,8);

  //gcc convolution.c myutils.c -pthread -o conv
  //./conv

  // write the convolved image
  write_tga("output.tga", target);

  free(pixels);
  free(target);
  return 0;
}

After creating the executable "conv" I get this errors:
free(): double free detected in tcache 2
Aborted (core dumped)

A: In this for loop
for(i=0;i<numerodethreads;i++){
   pthread_join(thread,NULL);
   free(params);
}

there is called free( params ) that tries to free the same allocated dynamically memory in this declaration
int* params = malloc(2*sizeof(int));

numerodethreads times.
Also it seems you mean
pthread_join(thread[i],NULL);

instead of
pthread_join(thread,NULL);


text:
Q: Get git diff for any merged branch For each defect in code I create separate branch. When defect is fixed I merge this branch in master, so I have history like illustrated below (we see two branches with fixes):
          defect1 fix         defect2 fix
         a---b---c---d           e---f
        /             \         /     \
---o---1---x---y---z---2---o---3---w---4---o---

The question is how to get diff for fix1 (between branch start (1) and branch end (2)) or fix2  (diff between (3) and (4)) at any point of time (e.g. for any closed defect in past).
Update: actual question is how to figure out SHA summs of a and d or e and f to perform next obvious diff command diff <commit> <commit>

A: The answer is simple:
git diff 1..d

This shows the differences between the branching point of your defect1 fix branch (i.e. 1) and it's end (i.e. d).
In order to find the start of the defect1 fix branch, use
git merge-base master defect1-fix-branch

as indicated in this answer: https://stackoverflow.com/a/2458173/520162.
This gives you 1 according to the documentation of git merge-base.
The end of the defect1 fix branch is simply identified by it's name. So, finding all differences introduced in defect1 fix, you need to do
git diff 1..defect1-fix-branch

A: Note: this is equivalent, as detailed in "Not able to think of a case where git diff master..lab and git diff master...lab would be different", to:
 git diff master...defect1-fix-branch

git diff A...B is equivalent to git diff $(git merge-base A B) B

(From "git diff doesn't show enough")

A: If you want to see what changes a feature branch introduced, after it has been merged, you simply run:
git diff HEAD^..HEAD

On the master  branch. That shows differences between the HEAD's (merge commit) first parent and the HEAD, effectively displaying differences the whole feature branch merge brought into the master branch.
No need to make things complex :)

A: What about:
git diff <commit> <commit>

Where the commit parameters are the SHA checksums of the actual commits.


text:
Q: Add two more columns to csv file based on matching values of other csv I have two csv files
csv1:

csv2:

What i need to process is:
Get each value of column c of csv1 file and match it with column number of csv2.
If any row of csv2 matches with that number then add a new column c_text into csv1 that will contain value of text column for matching row of csv2
Repeat above process for column d of csv1 and add a new column d_text into csv1
Here is what i need at the end

Am new to pandas. How can i do this using pandas.

A: You can use apply():
csv1['c_text'] = csv1['c'].apply(lambda x: csv2[csv2['number']==x]['text'].values[0])
csv1['d_text'] = csv1['d'].apply(lambda x: csv2[csv2['number']==x]['text'].values[0])

Yields:
   a  b    c    d c_text d_text
0  1  4  101  201   val1   val4
1  2  5  105  202   val2   val5
2  3  6  107  203   val3   val6

In terms of an option using merge(), this will yield the same output:
csv1 = csv1.merge(csv2, left_on='c', right_on='number', how='left')
csv1 = csv1.merge(csv2, left_on='d', right_on='number', how='left')
csv1 = csv1.rename(columns={'text_x': 'c_text', 'text_y': 'd_text'})[['a','b','c','d','c_text','d_text']]

A: Here's something that will do the trick:
df1 = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c':[101, 105, 107], 'd':[201, 202, 203]})

df2 = pd.DataFrame({'number': [101, 105, 107, 201, 202, 203, 205, 2010, 310], 'text': ["val_{x}".format(x=y + 1) for y in range(9)]})

df1

   a  b    c    d
0  1  4  101  201
1  2  5  105  202
2  3  6  107  203

df2

   number   text
0     101  val_1
1     105  val_2
2     107  val_3
3     201  val_4
4     202  val_5
5     203  val_6
6     205  val_7
7    2010  val_8
8     310  val_9
merged = df1.merge(df2, left_on='c', right_on='number', how='left')

merged

   a  b    c    d  number   text
0  1  4  101  201     101  val_1
1  2  5  105  202     105  val_2
2  3  6  107  203     107  val_3

output = merged.merge(df2, left_on='d', right_on='number', how='left')[['a', 'b', 'c', 'd', 'text_x', 'text_y']]

output

   a  b    c    d text_x text_y
0  1  4  101  201  val_1  val_4
1  2  5  105  202  val_2  val_5
2  3  6  107  203  val_3  val_6

A: What you want is the merge functionality of Pandas. Assuming you have imported the Pandas module with the shorthand name like import pandas as pd, then:
csv1_with_text_col = pd.merge(csv1, csv2, left_on='c', right_on='number', how='left')

This will give you a new dataframe, csv1_with_text_col, with the columns from csv2 merged into csv1 where csv1['c'] == csv2['number']. Additionally, by specifying how='left', only rows from the left dataframe, csv1, will be kept.
You can then merge this new dataframe, csv1_with_text_col, with csv2 again but with left_on='d'.


text:
Q: Copy A Header To The Clipboard HTML/JS I am looking for a way to copy the text inside of a header on my website to the users clipboard. I am a beginner at HTML and JS, so I am struggling quite a bit. This is what I have so far:
<!DOCTYPE html>

Test

    <button onclick="copyToClipboard()">Copy To Clipboard</button>

This script does not copy the header and I cannot figure out why. This is the error I get: Uncaught TypeError: copyText.select is not a function Any help would be appreciated.

A: Your html is invalid. It should be
Test

Also I wouldn't advise to use inline onclick in the button element. Instead use the addEventListener function. Read here.


text:
Q: Netlogo making a list out of itself for a given length I want to create a list out of its own values for a given length.
For example, given the list [0 1] and a desired list length of 7, the output would be [0 1 0 1 0 1 0]. The length is defined by population, and is defined by a slider. I declared the variable x that should iterate through the list. If the length of the list is shorter than the value of population it should be set to 0 again.
I tried it with a loop command but it runs infinitely:
let x 0
  loop[
    if length exp-dif-li <= population[
      ifelse x < length exp-dif-li[
        set x 0]
      [ set exp-dif-li lput item x exp-dif-li exp-dif-li
        set x x + 1]
    ]
  ]
]

A: mod and n-values are your friends here:
to-report continue-list [ lst n ]
  report n-values n [ item (? mod length lst) lst ]
end

Example uses:
observer> show continue-list [0 1] 7
observer: [0 1 0 1 0 1 0]
observer> show continue-list [0 1] 1
observer: [0]
observer> show continue-list [0 1 2 3 4] 22
observer: [0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1]

Edit: Realized it would be good to talk about why this works! n-values n [ ... ] creates a list of length n by sending the numbers 0 through  n - 1 to the given reporter. The reporter accesses the number with ? (this is the NetLogo task syntax). So we want to keep repeating the items in the original list. A really good function for repeatedly cycling through numbers is mod. In general, item i of the new list should be item i mod <length of original list>. So, putting that together, n-values n [ item (? mod length lst) lst ] creates a new list of length n by repeating the items from the list lst as necessary.

A: To get out of a loop you need to call end or stop.
inserting the line
if length exp-dif-li = 7 [stop]

the right place would do it. Loop can very easily turn into a infinite loop and a freeze so it is best avoided.
I prefer while loops. they are safer and less prone to infinite loops which would look like this
while length exp-dif-li < 7
  [
   if length exp-dif-li <= population[
  ifelse x < length exp-dif-li[
    set x 0]
  [ set exp-dif-li lput item x exp-dif-li exp-dif-li
    set x x + 1]
  ]

Netlogo has another method which I have not seen elsewhere and is very robust against infinite loops. [repeat] the usage in you case would seem to be
  repeat 7  [
            if length exp-dif-li <= population[
             ifelse x < length exp-dif-li[set x 0]
             [ set exp-dif-li lput item x exp-dif-li exp-dif-li
            set x x + 1]
            ]


text:
Q: How to display array of structure pointer in user space which is copied from kernel via read call Depending on the number of processes currently running, by using for_each_process macro call and one simple counter, I have used kmalloc to allocate memory for those processes to store process pid and its parent pid in structure. And use copy_to_user to copy it into the user space segment like below,
copy_to_user(buffer, &data, sizeof(Data) * process_counter);
But the problem is I am not able to figure out how should I suppose to display it on the user space application using read system call.
Is it possible in one read call Or do i need to use while loop for it ?
Thanks in advance.


text:
Q: Grab text from multiple parts of a string which differs in size and convert them into variables I'm trying to grab specific parts of a string to convert them into variables. I was able to use str_replace() to get the output I wanted but since it changes in length especially file paths it just wont cut it.
STRING TEMPLATE:
$issue->fields->description = "MSI: YES XPF: NO PKG TYPE: XYZ VENDOR: WXYZ USER CODE: AB APP NAME: ATBTOOL VERSION: 1.0 MEDIA ZIP FILE: \\123.456.78.9\Path\TO\MY\MSI\MSIHelpV1.0.zip INSTALL DIR: G:\MSI EXISTING: NO";

This template always stays the same and when this array is dumped there is always a space around the values. The values im trying to grab are:
YES
NO
XYZ
WXYZ
AB
ATBTOOL
1.0
\123.456.78.9\Path\TO\MY\MSI\MSIHelpV1.0.zip
G:\MSI
NO
So i'm wondering if there is any to maybe specify to grab everything inbetween MSI: & XPF:, PKG TYPE: & VENDOR:, and so forth just a thought any help would be appreciated!
This is the code I've been working with.
$stringPosPKG = strpos($issue->fields->description, 'TYPE');
                $stringPosVENDOR = strpos($issue->fields->description, 'VENDOR');
                $stringPosCODE = strpos($issue->fields->description, 'CODE');
                $stringPosAPP = strpos($issue->fields->description, 'APP');
                $stringPosVERSION = strpos($issue->fields->description, 'VERSION');
                echo "
";
                echo "PKG Begins At " . $stringPosPKG;
                echo "
";
                echo "VENDOR Begins At " . $stringPosVENDOR;
                echo "
";
                echo "CODE Begins At " . $stringPosCODE;
                echo "
";
                echo "APP NAME Begins At " . $stringPosAPP;
                echo "
";
                echo "VERSION Begins At " . $stringPosVERSION;
                echo "
";
                echo "
";
                $pkgType = substr( $issue->fields->description, 33, -217 );
                $vendorName = substr( $issue->fields->description, 48, -203 );
                $userCODE = substr( $issue->fields->description, 67, -184 );
                $appName = substr( $issue->fields->description, 83, -163 );
                $versionNum = substr( $issue->fields->description, 103, -147 );
                echo "
";
                echo "PKG Title: " . $pkgType;
                echo "
";
                echo "VENDOR Title: " . $vendorName;
                echo "
";
                echo "CODE CODE: " . $userCODE;
                echo "
";
                echo "APP NAME: " . $appName;
                echo "
";
                echo "VERSION: " . $versionNum;
                echo "
";
                $versionNumStrRArray = ["."];
                $versionNumStrR = str_replace($versionNumStrRArray, "_", $versionNum);
                echo "MSI NAME: MSI_" . $pkgType . "_" . $vendorName . "_" . $userCODE . "_" . $appName . "_" . "$versionNumStrR";

OUTPUT:
PKG Begins At 27
VENDOR Begins At 40
CODE Begins At 61
APP NAME Begins At 73
VERSION Begins At 94

PKG Title: ABC
VENDOR Title: WXYZ
CODE CODE: AB
APP NAME: ATBTOOL
VERSION: 1.0
MSI NAME: MSI_ABC_WXYZ_AB_ATBTOOL_1_0

A: Guess you should be using regular expressions for this one. Something like that:
<?php

function parseFoo(string $foo): array
{
    $splitInput = [];

    preg_match_all(
        '/(?<key>[^\s][A-Z\s]+): (?<value>[\pL\pP\d]+)/',
        $foo,
        $splitInput
    );

    return array_combine(
        $splitInput['key'] ?? [],
        $splitInput['value'] ?? []
    );
};

$input = "MSI: YES XPF: NO PKG TYPE: XYZ VENDOR: WXYZ USER CODE: AB APP NAME: ATBTOOL VERSION: 1.0 MEDIA ZIP FILE: \\123.456.78.9\Path\TO\MY\MSI\MSIHelpV1.0.zip INSTALL DIR: G:\MSI EXISTING: NO";

echo json_encode(
    parseFoo($input)
);


text:
Q: How we can add the botlibre bot to bb messenger app I'm trying to create a bbm chat bot using nodejs sdk.
I'm following this link.
Using this I created a chatbot in botlibre.
Here my problem is, how we can add that bot to my BB messenger android app to send messages.

A: After you have created your bot in botlibre, click on 'embed', and then copy the SDK.applicationId and web.instance fields. Put these values into the config.js file of the Node SDK under the botlibre field. See image
Make sure you have requested a domain for use with the BBM Enterprise SDK. You can get one here.

A: Unfortunately, it is not possible to connect a bot with the BBM Consumer app, as they do not exist under the same SDK 'domain'.
The BBM Consumer and BBM Enterprise apps that are downloaded from iTunes or the PlayStore are not connected to the ones that you are building with the BBM Enterprise SDK. Your bot will not be able to chat with these applications, but it can chat with your own mobile applications that are built with the BBM Enterprise SDK (BlackBerry Communications Platform).


text:
Q: Using a Windowed Dataset for Time Series Prediction I have been working on a time series analysis using a LSTM model implemented via TensorFlow 2.0. Now, it is clear that this is accomplished by creating windows of data. For instance, the first 30 values of the time series is a window, i.e. the input and the next value will be the target.
I came across the following function for creating these windows,
def windowed_dataset(series, window_size, batch_size, shuffle_buffer):
    series = tf.expand_dims(series, axis=-1)
    ds = tf.data.Dataset.from_tensor_slices(series)
    ds = ds.window(window_size + 1, shift=1, drop_remainder=True)
    ds = ds.flat_map(lambda w: w.batch(window_size + 1))
    ds = ds.shuffle(shuffle_buffer)
    ds = ds.map(lambda w: (w[:-1], w[1:]))
    return ds.batch(batch_size).prefetch(1)

This returns a tf.data.Dataset object when a series is passed in along with the other arguments like so,
window_size = 30
batch_size = 32
shuffle_buffer_size = 1000
series_dataset = windowed_dataset(series_train, window_size, batch_size=128, shuffle_buffer=shuffle_buffer_size)

On examination of this object, I found that each element is a batch of 128 windows and each window contains 30 values (as defined by the arguments passed).
This is all well and good, but what confuses me is that after defining a model like so,
model = tf.keras.models.Sequential([
  tf.keras.layers.Conv1D(filters=32, kernel_size=3,
                      strides=1, padding="causal",
                      activation="relu",
                      input_shape=[None, 1]),
  tf.keras.layers.LSTM(32, return_sequences=True),
  tf.keras.layers.LSTM(32, return_sequences=True),
  tf.keras.layers.Dense(1),
  tf.keras.layers.Lambda(lambda x: x * 200)
])

optimizer = tf.keras.optimizers.SGD(lr=1e-7, momentum=0.9)
model.compile(loss=tf.keras.losses.Huber(),
              optimizer=optimizer,
              metrics=["mae"])

this dataset itself can be passed in to the model.fit() method,
history = model.fit(dataset,epochs=500)

How is it possible that the target does not need to be defined here? You would normally need to do something like model.fit(x=inputs, y=targets, epochs=num_epochs). How come this is not necessary?