text:
Q: Problema al leer el final de un archivo usando .eof() Estoy intentando leer las coordenadas x e y escritas dentro de un fichero hasta el final. Para después introducir cada una en un vector.
Me falla cuando introduzco .eof() dentro del while.
La salida muestra; request for member 'eof' in 'nombre_coords', which is of non-class type 'const
#include<iostream>
#include<fstream>
#include<sstream>
#include<vector>
#include<iomanip>
#include<cmath>

using namespace std;

//Nombres del Fichero
const char nombre_coords[]="2PECSepiembre2017Coordenadas.txt";

int main(){
//Vectores
vector<double>vX;
vector<double>vY;
//Donde almacenar datos del fichero
double coordX;
double coordY;

ifstream Fichero(nombre_coords, ios::in);
if(!Fichero)
{
    cout<<"Algo incorrecto has hecho";
    return 1;

}
while(!nombre_coords.eof()){ //Aqui se produce el fallo
    Fichero>>coordX;
    Fichero>>coordY;
    vX.push_back(coordX);
    vY.push_back(coordY);
}

return 0;


text:
Q: line separator between a relativelayout and a listview hello I have a view with a title at top and a listView with pulltorefresh functionality.
I would like to show the line separator before the first item in the listView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:background="@drawable/background_azul"
   android:orientation="vertical" >

<RelativeLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="50dip"
    android:background="@color/usualBike"
>

    <TextView
        android:id="@+id/noticesLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        android:text="@string/tituloNoticias"
        android:textColor="@color/white"
        android:textSize="30dip"
        android:textStyle="bold" />

</RelativeLayout>

<View
    android:id="@+id/View01"
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:background="#3b5998"/>

<com.mypackage.myapp.PullToRefresh
    android:id="@+id/listNews"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:cacheColorHint="#00000000"
    android:layout_marginLeft="8dip"
    android:layout_marginRight="8dip"
    android:divider="#3b5998"
    android:dividerHeight="2dip"/>

</LinearLayout>

But the line is not shown. How should I do this?

A: Your code seems okay ... to place a separator it is enough to use the View you used. To use a separator the common practice is
< ViewGroup

....... />

< View

......../>

< ViewGroup

......../>

The only reason that you are not saying may be background color you used in the View. IF you use same color as its parent then it will not be visible

redpajama_set_name: RedPajamaStackExchange


text:
Q: Build server fails to load custom code analysis ruleset We are using Code Analysis on our projects. As part of this we have Code Analysis enabled on the build server allowing for continious checks.
Now we are receiving this error:

CA0063 : * Failed to load rule set file '[name].ruleset' or one of its
  dependent rule set files.

[name] being a ruleset on our internal network, available for everyone.
Code Analysis runs perfectly fine on each local machine, but not on the build server. How can we fix this issue?
Notes:

*

*We use a custom made ruleset

*We are not using any custom rules (yet)

A: I was having this issue as well. How I solved it was to add my custom ruleset into version control (Git) as a new directory within my project files. We are using Jenkins for our CI, so in my Jenkins.build I then made sure to specify the absolute file path to my ruleset on the Jenkins server, which you can get by looking at your Workspace on Jenkins. For example the path may look like :
e:\Jenkins\workspace\SampleProj-Dev\Rulesets\CustomRules.ruleset
In Jenkins.build file, I added an argument to the msbuild.exe program execution with:
<arg line="/p:RunCodeAnalysis=true;CodeAnalysisRuleSet=e:\Jenkins\workspace\SampleProject-Dev\Rulesets\CustomRules.ruleset"/>
Before I had tried using a relative path but with a build containing many sub-projects, Jenkins tried to append the path onto a changing path. This path was based on the currently building sub-project, resulting in the same error you received.

A: I stumbled onto a fix for this tonight for a project that has been suffering from it for ages. I created a new configuration CHECKED and the problem disappeared. Then by:

*

*Deleting the existing configurations from Configuration Manger;

*Exiting and saving (this step might not be necessary); and finally

*Recreating the dropped configurations from the newly created one, CHECKED

the problem has now disappeared completely in all configurations.
This was all in Visual Studio 2013.


text:
Q: Hyper-V: my custom virtual switch disappears from time to time On my Windows 10 Pro x64 PC, I have Hyper-V with multiple VMs. Some VMs use a custom virtual switch (let's call it "MySwitch"), which I need so that I can set it to type "External" and have my VMs ports exposed.
The issue is that, from time to time (this already happened 4-5 times), "MySwitch" disappears and the VMs using it cannot start anymore

The message is a bit cryptic, but the issue is that "MySwitch" doesn't actually exist anymore. Meaning: when this happens, I can no longer see it under "Network connections".
This never happens with the default virtual switch created by Hyper-V, only with my own.
I'm having an hard time pinpointing the cause:

*

*today is February 24th, so we are far away from "patch Tuesday" (I checked to be sure: no patch were installed recently)

*I didn't do any maintenance of sort recently, so it's unlikely to be some side-effect of something I did interactively

*I Googled it: nothing useful came back

Any ideas?


text:
Q: Sencha Touch error: 'myapp.mainpanel has no method setActiveItem' Edit: Upon further examination I discovered that I hadn't included certain namespaces. Adding the relevant name spaces now gives the error:
'myapp.mainpanel has no method setActiveItem'
I am trying to build a sencha touch web app using the card layout mechanism. I make use of the following handler on a button on the landing page:
handler:function(){
            myapp.mainpanel.setActiveItem(myapp.cards.vehicleSearchResults, { type: 'slide', cover: false, direction: 'left'})
            }

But when I click on the button I get the error: Sencha Touch error: 'myapp.mainpanel has no method setActiveItem'
Does this mean myapp.cards.vehicleSearchResults is undefined?
I define it here:
myapp.cards.vehicleSearchResults = new Ext.Panel({
    scroll:false,
    layout:{
            type:"vbox",
            align:"stretch"
    },
    id: "vehicle-search-results-card",
    dockedItems: [myapp.toolbars.searchResultsTitle, myapp.toolbars.searchResultsNav, myapp.toolbars.searchResultsCaption]

})

Any clues as to what I am doing wrong based on the above code?

A: The setActiveItem() method is only available if the panel has a card layout. Make sure you add the 'card' layout property in your panel definition.


text:
Q: Converting C++ code to visual c++ I have done my project on image processing using opencv, however, it is completely command line oriented there is no GUI. Will it be too much of a task to convert my whole source code into GUI using Visual C++ [Windows Forms Applications] given that i only have about a week to submit my source code? If it can be done how should i go about it?

A: It ultimately depends on how well you designed your existing code:

*

*If your logic is cleanly separated from any user I/O then using C++/CLI and WinForms is probably the quickest way to get a GUI implemented.

*However if your code is littered with e.g. std::cout with no separation of concerns, then you have quite a rewrite ahead regardless of which GUI framework you decide to use in the end.

I.e., aside from C++/CLI's learning curve (it is in fact a completely different language than C++), whether you use WinForms or something like Qt or wxWidgets for the GUI is mostly irrelevant -- getting all the console-oriented cruft out of your existing code is the time-consuming part.

A: It really depends.
I don't know Windows Forms... but using a good library indeed (e.g. Qt) if what you need to do is showing for example an image and display some widgets for parameters or may be allowing some area selection it's something that can take even less than an hour to do.
However this assuming you know GUI programming and the library/framework.
Knowing nothing about either it may be much much harder unless you can find an already made example quite close to what you need.
Not knowing what the GUI is supposed to present the user it's quite hard to give an estimate...

A: I think you should go for it!!
Save a copy as you have it and have a go! How quickly it will go depends on you, of course. It mostly comes down to how well structured your code is and how modular it is. For example, if your code is completely tied up with command line input then it'll be more difficult. If you need to make bits of code independent of the command line then I'd recommend doing that first, and then (save that copy again) GUI it up.
You will also have to choose your method of GUI (MFC, your own Win32 implementation, other people might have other suggestions there).


text:
Q: Angular JS: how to href inside of a ng-if depeding of the extension I have the following code:

This code will open the following div:

What I want is to open a pop-up if the file ends with ".vid" but if it ends with ".aspx" it a page to "x" location.
Is it possible to do that?
To diferentiate extensions, i inserted the following code:
vm.commonPageExtensions = 'aspx$';

vm.commonVideoExtensions = '3g2$|3gp$|amv$|asf$|avi$';

EDIT: To get the URL I have the following snip
href="{{vm.selectedShareItem.path}}"


text:
Q: vim parenthesis matching only while typing In emacs, as you type, it will show you the matching parentheses, but there is a separate setting to highlight matching parentheses that the cursor is on. Is there something I can write in .vimrc to make this happen? Everything I've found completely turns off parenthesis matching, which is not quite what I want.
Thanks for any help!
EDIT: Addressing the comment about a possible duplicate, that answer explains how to turn on what I want to turn off. I want paren matching as I type, but I don't want highlighting when my cursor is on a parenthesis. Thanks!

A: " Briefly jump to the matching bracket when typing
set showmatch
" Turn off the default matchparen plugin (on demand):
NoMatchParen
" Alternatively (in your .vimrc, to completely disable the plugin):
let loaded_matchparen = 1


text:
Q: A verification for a proof that $\omega_1 \leq \mathfrak s$ I am trying to prove that

$\omega_1 \leq \mathfrak s$

where $\mathfrak s$ is the splitting number which is the smallest cardinality of any splitting family. This statement was left as an exercise to the reader in a book I am reading.
A splitting family is a family $\mathcal L \subseteq [\omega]^\omega$  such that each set $y \in [\omega]^\omega$ is split by at least one $x \in \mathcal L$.
Also, a set $x \subseteq \omega \space$  splits an infinite set $y \in [\omega]^\omega$ if both $y \cap x$ and $y\setminus x$ are infinite.
Here is the proof I was thinking about:
Given a splitting family $\mathcal L$, we will show that $\mathcal L$ is uncountable.
Suppose that $\mathcal L$ was countable. Then we can write it a $\bigcup_{n \in \omega}U_n$. Take now: $a_1 \in U_1,a_2 \in U_2\setminus U_1,...a_n \in U_n\setminus \{U_1 \cup U_2 \cup ... \cup U_{n-1}\}$. Take $A=\{a_n\}$ We get that for every $n \in \omega$, $U_n \cap A$ is finite. Contradicting our assumption that $\mathcal L$ was a splitting family.
What do you think, is this proof ok?
Thank you!
Shir

A: We show that a countable family $U_1,U_2,U_3,\dots$ of subsets of $\omega$ can't be a splitting family.
Choose an infinite set $S_1\in\{U_1,\omega\setminus U_1\}$.
Choose $a_1\in S_1$.
Choose an infinite set $S_2\in\{S_1\cap U_2,S_1\setminus U_2\}$.
Choose $a_2\in S_2\setminus\{a_1\}$
Choose an infinite set $S_3\in\{S_2\cap U_3,S_2\setminus U_3\}$.
Choose $a_3\in S_3\setminus\{a_1,a_2\}$.
וכן הלאה


text:
Q: need help understanding a bash read command Below is read command I'm trying to understand:-
read -p $'\e[1;92m List of sites: \e[0m' records

-p flag prompts the user to enter a file name for a list of sites which it names records. Can someone help me with the the rest of the syntax between the quotes.
Thanks

A: The second argument in your command - i.e. the parameter for the -p argument - that starts with $' and ends with ', is the text to be displayed to the user, prompting them to enter some text to be assigned to the records shell variable.
The content of that argument is some text interspersed with ANSI control sequences that instruct the terminal to color the prompt green and then reset the color before the user starts typing.


text:
Q: 'list' object not callable error while using sorted() in Python on Jupyter notebook I am trying the below piece of code where I am trying to read the contents of a file and identify the 3 most used words. I have the individual words and their frequencies as a key:value in a python dict. When I try to use the sorted() on it, I get 'list' object not callable error.
content=open("Assignment1_Q8.txt").read().split()
freq={}
for item in content:
    if item in freq:
        freq[item]+=1
    else:
        freq[item]=1

print(freq)

freq_sort=sorted(freq,key=freq.values())

Output:
{'Hello': 5, 'World': 3, 'Hi': 3, 'Bye': 5}
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-220-40658aa1ff31> in <module>
      8 print(freq)
      9
---> 10 freq_sort=sorted(freq,key=freq.values())

TypeError: 'list' object is not callable

A: Read the documentation of sorted(iterable, key=key, reverse=reverse).
key is a function to execute to decide the order.
You use list as key so it throws an error.
How do I sort a dictionary by value?
You may use this as a reference for what you wanted.

A: Issue was that I had used 'sorted' earlier as a variable and I was trying to use it as a function later. I deleted the 'sorted' variable annd executed the code and it works. Thanks.


text:
Q: Non-breaking space turns into 'ă' under XeLaTeX Earlier today I noticed the following curious output in a LaTeX file I was editing:

After some investigation I determined that there was a Unicode non-breaking space (U+00A0) between the + and the B, which somehow turned into an 'ă' in the PDF output. Curiously enough, this happens only when the lmodern package is loaded, only in math mode, and only when compiled with XeLaTeX — when compiled with pdfLaTeX, there output merely contains an extra-large space between the + and the B. What causes this behaviour, and why does it only occur under these specific conditions?
Minimal reproducible example:
\documentclass{article}

\usepackage{lmodern}

\begin{document}

$A + B = C$

\end{document}

(Note that the space in + B is U+00A0 rather than U+0020, which may or may not show up in the rendered post.)
Compile with xelatex; pdflatex gives different output as discussed above.

A: You shouldn't load lmodern when running XeLaTeX.
This doesn't really solve the problem, because you get
Missing character: There is no   (U+00A0) in font cmr10!

but, at least, nothing is printed.
What happens when you run XeLaTeX with lmodern is that the text font for family 0 is set to rm-lmr10, which has the upper half filled with characters in nonstandard positions. In particular, in slot 0xA0 there is ă and this character is therefore printed.
You can use the math font provided by lmodern also in XeLaTeX, but for this you have to extract only the math font definitions in lmodern.sty, basically what's after \ProcessOptions\relax, so
\SetSymbolFont{operators}   {normal}{OT1}{lmr} {m}{n}
\SetSymbolFont{letters}     {normal}{OML}{lmm} {m}{it}
\SetSymbolFont{symbols}     {normal}{OMS}{lmsy}{m}{n}
\SetSymbolFont{largesymbols}{normal}{OMX}{lmex}{m}{n}
\SetSymbolFont{operators}   {bold}  {OT1}{lmr} {bx}{n}
\SetSymbolFont{letters}     {bold}  {OML}{lmm} {b}{it}
\SetSymbolFont{symbols}     {bold}  {OMS}{lmsy}{b}{n}
\SetSymbolFont{largesymbols}{bold}  {OMX}{lmex}{m}{n}

\SetMathAlphabet{\mathbf}{normal}{OT1}{lmr}{bx}{n}
\SetMathAlphabet{\mathsf}{normal}{OT1}{lmss}{m}{n}
\SetMathAlphabet{\mathit}{normal}{OT1}{lmr}{m}{it}
\SetMathAlphabet{\mathtt}{normal}{OT1}{lmtt}{m}{n}
\SetMathAlphabet{\mathbf}{bold}  {OT1}{lmr}{bx}{n}
\SetMathAlphabet{\mathsf}{bold}  {OT1}{lmss}{bx}{n}
\SetMathAlphabet{\mathit}{bold}  {OT1}{lmr}{bx}{it}
\SetMathAlphabet{\mathtt}{bold}  {OT1}{lmtt}{m}{n}

\def\mathsterling{\mathit{\mathchar"70BF}}

However, this would still print ă if 0xA0 sneaks in. You can cure the problem by making 0xA0 math active and define it to be \space, so in math it gets ignored.
Full code:
\documentclass{article}

\SetSymbolFont{operators}   {normal}{OT1}{lmr} {m}{n}
\SetSymbolFont{letters}     {normal}{OML}{lmm} {m}{it}
\SetSymbolFont{symbols}     {normal}{OMS}{lmsy}{m}{n}
\SetSymbolFont{largesymbols}{normal}{OMX}{lmex}{m}{n}
\SetSymbolFont{operators}   {bold}  {OT1}{lmr} {bx}{n}
\SetSymbolFont{letters}     {bold}  {OML}{lmm} {b}{it}
\SetSymbolFont{symbols}     {bold}  {OMS}{lmsy}{b}{n}
%\SetSymbolFont{largesymbols}{bold}  {OMX}{lmex}{m}{n}

\SetMathAlphabet{\mathbf}{normal}{OT1}{lmr}{bx}{n}
\SetMathAlphabet{\mathsf}{normal}{OT1}{lmss}{m}{n}
\SetMathAlphabet{\mathit}{normal}{OT1}{lmr}{m}{it}
\SetMathAlphabet{\mathtt}{normal}{OT1}{lmtt}{m}{n}
\SetMathAlphabet{\mathbf}{bold}  {OT1}{lmr}{bx}{n}
\SetMathAlphabet{\mathsf}{bold}  {OT1}{lmss}{bx}{n}
\SetMathAlphabet{\mathit}{bold}  {OT1}{lmr}{bx}{it}
\SetMathAlphabet{\mathtt}{bold}  {OT1}{lmtt}{m}{n}

\def\mathsterling{\mathit{\mathchar"70BF}}

\mathcode"A0="8000
\begingroup\lccode`~="A0 \lowercase{\endgroup\let~}\space

\begin{document}

$A + B = C$

\end{document}

(I'm not sure that 0xA0 will still be in front of B in the code above, fill it in when checking.)
Note 1: I commented out the largesymbols definition, because Latin Modern default choice is completely wrong. You may find it useful to also load fixcmex to get correctly scaling large operators.
Note 2: this is the same for LuaLaTeX.


text:
Q: JavaScript event is being fired twice when event has only happened once I have been working on a small JavaScript library that is for simple touch events such as tapping and swiping. I placed it on GitHub for the time being.
See it here: thumb.js - Repository
If you take a look at thumb.html, you can see how I am using my library.
//JavaScript portion
//Assign the tap event to all elements with specific classname
thumb.get('.swipearea').on('tap', function(e) {
    console.log('The event "' + e.detail.name + '" occured.')
})

//Assign the swipeleft event by ID
thumb.get('#a1').on('swipeleft', function(e) {
    console.log('The event "' + e.detail.name + '" occured.')
})

As you can see from the HTML file, I am assigning a "tap" to all elements with a classname of "swipearea". However, I want to add a "swipeleft" event to only one element with the that same classname, so I attached the event using the element's ID.
This is working for the most part. The issue is that when I tap on the element with both events attached, it logs the message twice. It also logs twice when swiping left. However, when I tap on the other element that only has "tap" assigned, it correctly logs to the console one time.
Am I creating each instance incorrectly? I have tried to create a method outside of the thumb instance, but that has resulted in the same behavior.
How can I eliminate this behavior?
More about the console logs
When I tap once on the element with the ID a1 I get The event "Tap" occurred. logged to the console 2 times.
When I "swipeleft" on the element with the ID a1 I get The event "Swipe Left" occurred. logged to the console 2 times.
When I tap once on the element with the ID a2 I get The event "Tap" occurred. logged to the console one 1 time.

A: There is a high likelihood that your code is structured such that the listener is being added twice. We'd need to see more of your code to say for sure.
In some environments, a listener which EXACTLY matches a previous listener (in the === sense) will not be added again (this is also the case for the native addEventListener API). I don't know if this is the case with jQuery. To try this, you could define the listener as a separate function:
function listener(e) {
    console.log('The event "' + e.detail.name + '" occured.');
}

then add it as
thumb.get('.swipearea').on('tap', listener);

You might ask, even if I'm adding the listener twice in my origin code, the listener function code is exactly the same, doesn't this mean that the function is the same, and so it won't be added as a duplicate listener? Well, no. If the function is defined inside some other function, it will be a "different" function each time. Consider the following:
function am_i_the_same() {
    return function() {return 42;};
}
am_i_the_same() === am_i_the_same(); // false

If you are working in an object-oriented environment, then you can do something like
my_object = {
    tap_listener: function(e) {
        console.log('The event "' + e.detail.name + '" occurred.');
    },
    set_listener: function() {
        thumb.get('.swipearea').on('tap', this.tap_listener);
    }
};

However, the minute you do this.tap_listener.bind(this), for example, you now have a different function each time it's called and so duplicate listeners will result.
Update
First, I would not prebuild your custom events. I'd create a new one each time you need to emit it. Otherwise you may have strange conflicts with time stamps, target elements, and propagation settings.
Speaking of propagation settings, it would be better to stop propagation immediately on all touch events.
Next, this may be personal preference, but I would not build in the multiple-element support as you have. It complicates your code with all these loops and forEach's and maps. Just write a component that does one thing, which is managing touch, not two things, which is managing touch AND managing groups of elements.
I'm curious as to why you declare variables like distanceX in global scope instead of in the function where they are used.
As for your specific problem, I can't see why that is happening, but I would try adding an else on line 112 of thumb.js and see if for some reason your if statements are constructed so as to allow both tap and swipe events to be omitted.
I assume you know there are libraries out there that do this for a living. They are going to do a better job at lots of little details, including edge cases like a touchend coming to your element when the touchstart was outside your application area, etc.


text:
Q: Joomla Site - have a form that calls a javascript function - but it also is redirecting my url - why? the code:
javascript:

html
this function shows the alert and then returns to page as normal

<form action="javascript:alert('action sent');" >
<input type="submit" value="But1">
 </form>

this form scrolls the page as expected but then immediately redirects the URL to the main page

 <form  onsubmit="scroll(400)" >
<input type="submit" value="But1">
          </form>

A: You are not preventing the form to submit. Try adding this :
onsubmit="scroll(400); return false;"


text:
Q: Let $f$ be of bounded variation. Then $f$ is continuous at $c$ IFF its variation $V$ is continuous at $c$ Let $f:[a, b] \to \mathbb R$ and $V:[a, b] \to \mathbb R \cup \{+\infty\}$ be such that $V(x) := \operatorname{Var}_{[a, x]} f$ for all $x \in [a, b]$. I'm trying to prove a continuity relation between $f$ and $V$, i.e.,

Theorem Let $f$ be of bounded variation and $c \in [a, b]$. Then $f$ is continuous at $c$ IFF $V$ is continuous at $c$.

Could you have a check on my below attempt?

Proof Notice that $V$ is real-valued.

*

*Let $f$ be continuous at $c$. By symmetry, it suffices to prove $V$ is right continuous at $c$.

Fix $\varepsilon>0$. There is $\delta>0$ such that $0 < x-c<\delta$ implies $|f(x)-f(c)| <\varepsilon$. There is a partition $c=x_1 < x_2 < \cdots < x_n = b$ of $[c, b]$ such that
$$
\operatorname{Var}_{[c, b]} f < \sum_{i=1}^{n-1} |f(x_{i+1})-f(x_i)| + \varepsilon.
$$
Let $c<x< \min \{x_2, c+\delta\}$. By this lemma, we have the decomposition
$$
V(x) -V(c) =\operatorname{Var}_{[c, x]} f  = \operatorname{Var}_{[c, b]} f - \operatorname{Var}_{[x, b]} f.
$$
Notice that $x < x_2 <x_3 < \cdots < x_n$ is a partition of $[x, b]$. So
$$
\operatorname{Var}_{[x, b]} f \ge |f(x_2)-f(x)| + \sum_{i=2}^{n-1} |f(x_{i+1})-f(x_i)| .
$$
As such,
$$
V(x) -V(c) \le |f(x)-f(x_1)| + \varepsilon < 2 \varepsilon.
$$

*

*Let $V$ is continuous at $c$. By symmetry, it suffices to prove $f$ is right continuous at $c$.

Let $x>c$. We have $|f(x)-f(c)| \le \operatorname{Var}_{[c, x]} f = V(x)-V(c)$. The claim then follows easily. $\tag*{$\blacksquare$}$

Corollary If $f$ is continuous and of bounded variation, then $f$ can be written as the difference of two strictly increasing continuous functions.

Proof We have $V, V+f, V-f$ are increasing. Also,
$$
f (x) = (V(x) +x) - [(V(x)-f(x)) +x ].
$$
The claim then follows by taking $f=f_1-f_2$ with $f_1 (x) := V(x)+x$ and $f_2(x) = (V(x)-f(x)) +x$. $\tag*{$\blacksquare$}$


text:
Q: MERGE statement with "WITH FUNCTION" definition I am trying to use a function declared in WITH clause, into a MERGE statement.
Here is my code:
create table test
  (c1 varchar2(10),
   c2 varchar2(10),
   c3 varchar2(10));

insert into test(c1, c2) values ('a', 'A');
insert into test(c1, c2) values ('b', 'A');

select * from test;

begin
with function to_upper(val varchar2) return varchar is
begin
    return upper(val);
end;
merge into test a
    using (select * from test) b
on (upper(a.c1) = upper(b.c2))
when matched then
    update set a.c3 = to_upper(a.c1);
end;

but I am getting this error:

Error report - ORA-06550: line 2, column 15: PL/SQL: ORA-00905:
missing keyword ORA-06550: line 2, column 1: PL/SQL: SQL Statement
ignored ORA-06550: line 6, column 1: PLS-00103: Encountered the symbol
"MERGE"
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

Can someone explain why it is not working, please?
Thank you,

A: The with clause is part of the select syntax. As the railroad diagram for that shows, the only thing that's valid after the with clause is the select keyword - you don't have that, hence the error you are seeing.
As the documentation also says says:

The plsql_declarations clause lets you declare and define PL/SQL functions and procedures. You can then reference the PL/SQL functions in the query in which you specify this clause, as well as its subqueries, if any.

and

If the query in which you specify this clause is not a top-level SELECT statement, then the following rules apply to the top-level SQL statement that contains the query:

*

*If the top-level statement is a SELECT statement, then it must have either a WITH plsql_declarations clause or the WITH_PLSQL hint.

*If the top-level statement is a DELETE, MERGE, INSERT, or UPDATE statement, then it must have the WITH_PLSQL hint.

So, you can't apply the with clause to the whole merge statement, you can only use it as part of a query within that, i.e. in the using clause:
merge /*+ WITH_PLSQL */ into test a
    using (
        with function to_upper(val varchar2) return varchar is
        begin
            return upper(val);
        end;
        select to_upper(c2) as c2 from test
    ) b
on (upper(a.c1) = b.c2)
when matched then
    update set a.c3 = upper(a.c1);

Without the /*+ WITH_PLSQL */ hint this would error with "ORA-32034: unsupported use of WITH clause" (though only if you actually call the function, otherwise the complier seems to strip the unused function out and not complain about it).
But the function is still only in scope for the using clause; you can't refer to it in the on or update clauses. You would need to do any function calls within the using clause; and if you need the same function applied to anything from the target table, you would need to repeat the function and call that with the into clause, e.g.:
merge /*+ WITH_PLSQL */ into (
        with function to_upper(val varchar2) return varchar is
        begin
            return upper(val);
        end;
        select to_upper(c1) as c1, c3 from test
    ) a
    using (
        with function to_upper(val varchar2) return varchar is
        begin
            return upper(val);
        end;
        select to_upper(c2) as c2 from test
    ) b
on (a.c1 = b.c2)
when matched then
    update set a.c3 = a.c1;

db<>fiddle showing things that do and don't work.
It's quite a contrived example so it would probably be clearer with a more real-world scenario.


text:
Q: Refresh activity in List-View in Tab (Android) I have a listview in a Tab in a Tab Activity. Lets say that the Activity's name is "Main". I want it so when I press on an item in the listview (which is in a tab, which is in an activity), it refreshes "Main" (The Overall Activity).

A: Use onItemClickListener() for your listview as shown below.
In following example, MainActivity will restart when "Item 1" is clicked.

ListView listView=findViewById(R.id.list_view);
List<String> mList= Arrays.asList("Item 1","Item 2","Item 3");
listView.setAdapter(new ListViewAdapter(this,R.layout.list_item_layout,mList));

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //Restart activity when Item 1 gets clicked
                if("Item 1".equals(parent.getAdapter().getItem(position).toString())){
                    startActivity(new Intent(MainActivity.this,MainActivity.class));
                    finish();
                }
            }
        });

Example: ListViewAdapter.class

public class ListViewAdapter extends ArrayAdapter<String> {
    private List<String>  mList;

    public ListViewAdapter(@NonNull Context context, int resource, @NonNull List<String> list) {
        super(context, resource, list);
        this.mList = list;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_layout,parent,false);
        }

        ((TextView) convertView.findViewById(R.id.tv_item)).setText(getItem(position));
        return convertView;
    }

    @Nullable
    @Override
    public String getItem(int position) {
        return mList.get(position);
    }
}

Considering you are using a FragmentPagerAdapter in your tabbed activity,
you can put the code for the ListView in onCreateView() of the corresponding fragment instance,

   @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            ListView listView=rootView.findViewById(R.id.list_view);
            List<String> mList= Arrays.asList("Item 1","Item 2","Item 3");
            listView.setAdapter(new ListViewAdapter(rootView.getContext(),R.layout.list_item_layout,mList));
            listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    //Restart activity when Item 1 gets clicked
                    if("Item 1".equals(parent.getAdapter().getItem(position).toString())){
                        if(getActivity()!=null){
                            startActivity(new Intent(getActivity(),MainActivity.class));
                            getActivity().finish();
                        }
                    }
                }
            });
            return rootView;
        }
    }


text:
Q: Controlling data edit of form objects while navigating the saved records I have built a form on table which will navigate showing data stored in each record in the table.
I need to restrict the edition of  data  while navigating records from the form. Edition can be permitted by clicking a command button for example (Edit) to change the stroed data.
Can this happen?
If so, please advise.

A: You can use the Allow Edits property of the form to control whether the user can change data or not. Note that Allow Edits set to false, even unbound controls cannot be changed. Ensure that you switch Allow Edits to false in the Current Event for the form after you have set it to true in your button click.
 Me.AllowEdits = True ''False


text:
Q: tmux is not using screen-256color even it is set in the config file I am trying to get tmux to use screen-256color instead of xterm-256color, as it is not recommended. But when I am not using tmux, I would like to keep it as xterm-256color
A little bit of my setup, I am currently using iTerm2 and ssh to my development linux box, which is using zsh.
In my ~/.zshrc, I have:
export TERM="xterm-256color"

In my ~/.tmux.conf, I have:
set -g default-terminal "screen-256color"

With this configuraiton, without tmux, echo $TERM returns xterm-256color (which is right) and with tmux, echo $TERM is still returning xterm-256color instead of screen-256color.
Is there anything else I need to set in order for this to work?
Thanks!

A: The reason this does not work as expected is, that the zsh session that is started inside tmux overwrites TERM.
You should not set TERM from within in your shell. TERM is the way the terminal informs the shell and other applications about its capabilities (number of colors, key sequences for special keys, etc.). If you change TERM inside the shell, you change the what features the shell and applications expect from the terminal without the terminal itself knowing about it. Oftentimes this may not be an actual issue, but it is better to change the terminal configuration and set the desired value there.
You already did so when setting screen-256color in the configuration of tmux, which is essentially a terminal emulator, too. To do it for iTerm2 (tested with version 3.0.10):

*

*Open the Preferences dialog (in the Menu: iTerm2 → Preferences, or press ⌘+,).

*In the dialog go to Profiles → Terminal.

*There you can choose the desired value for TERM under Report Terminal Type.

A: You could modify your .zshrc file to check if you are running in tmux:
[ -z "$TMUX" ] && export TERM=xterm-256color


text:
Q: Can Gallifreyan be translated? When a series gets a large enough following the unique languages used therein are normally translatable either by fans who work it out or by offically released material (Klingon in Star Trek, the runes in Puella Magi Madoka Magica, Deadric in The Elder Scrolls).
When I was watching the new episodes of Doctor Who I noticed Gallifreyan script drawn on the spinny things around the center of the TARDIS which made me remember the Gallifreyan on his cot in A Good Man Goes to War. However I don't think in the series I've seen The Doctor explain the meaning behind any of it, or how one goes about translating it rather letting the TARDIS do it for his companions.
So I am wondering, is there a method to translate Gallifreyan?

A: No, because the Doctor Who franchise does not have any interest in such internal continuity.
Sometimes Gallifreyan is mathematical gibberish:

or some kind of vaguely Persian/Egyptian script:

The production team never worried itself with that kind of continuity, though there's some indication that it's supposed to be "Old" and "Modern" Gallifreyan. For more detail, this essay analyses Old Who Gallifreyan.
Now in New Who it's most often geometric:

New Who --especially under Moffat-- may be making a more concerted effort to show a continuity of language (at the very least, they're making it visually consistent--which is still not to say it's translatable). But since Gallifrey is burning for most of New Who, we don't yet have as many samples to analyse. That said, there are fan versions of Gallifreyan which are reminiscent of some of the kinds of visuals you'll see on the show.


text:
Q: "Error in `[.data.frame`(database, , apollo_control$indivID) : undefined columns selected" in R studio At this moment i want to create a model from apollo packages. I import the data from .txt file and want to create appollo_fixed variable.Then, this error message occured. (The data was imported succesfully)

apollo_inputs = apollo_validateInputs()
Error in [.data.frame(database, , apollo_control$indivID) :
undefined columns selected

The code I use is shown here,
rm(list = ls())
### Load libraries
library(apollo)
### Initialise code
apollo_initialise()

### Set core controls
apollo_control = list(
     modelName  ="MNL",
     modelDescr ="Simple MNL model on mode choice data",
     indivID    ="id")

# ####################################################### #
#### 2. Data loading                                   ####
# ####################################################### #

mydata <- read.table("/Documents/Travelmode_Final_project.txt", header=TRUE)
database = mydata
rm(mydata)

# ####################################################### #
#### 3. Parameter definition                           ####
# ####################################################### #

### Vector of parameters, including any that are kept fixed during estimation
apollo_beta=c(shuttlebus=0,
               citybus=0,
               bike=0,
               ubike=0,
               motorbike=0,
               car=0,
               mrt=0,
               taxi=0,
               b_SB_TC=0,
               b_SB_TT=0,
               b_CB_TC=0,
               b_CB_TT=0,
               b_B_TC=0,
               b_B_TT=0,
               b_UB_TC = 0,
               b_UB_TT=0,
               b_M_TC=0,
               b_M_TT=0,
               b_C_TC=0,
               b_C_TT=0,
               b_MRT_TT=0,
               b_MRT_TC=0,
               b_T_TT=0,
               b_T_TC=0)

apollo_fixed = c("shuttlebus")

# ####################################################### #
#### 4. Input validation                               ####
# ####################################################### #

apollo_inputs = apollo_validateInputs()

Is there any solution I may need to change to solve this error? Or any potential reasons that may cause this error?


text:
Q: How can i bind a key to list snippets in sublime text 3? Can i bind a key, like command + shift + i to show snippets in current context just like command + shift + p , type "snippets:" do ?
thanks !

A: Add the following to your user keybindings.
{ "keys": ["super+shift+i"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "snippet:"} }

A: This is a tiny tid-bit expansion on the answer above.  Thanks for that answer, I had been looking for this as well.
{ "keys": ["super+shift+i"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Snippet: "} }

Note the "text": has a capital 'S' and a trailing space included...with this, it shows the shortcut keys in the Tools menu beside Snippets...
i.e.
Snippets...             Win+Shift+I


text:
Q: Find next birthday that occurs on a specific day in Oracle SQL I got a students table and I need to find , for each student, his next birthday that will occur on a Sunday. How can I do that in Oracle Sql?
Example: Bob, found in table students has his dob '23/10/1994'. The output would be '23/10/2016' because this is the first date(starting from sysdate) that will occour on a Sunday and will also be his birthday.

A: SQL Fiddle
Oracle 11g R2 Schema Setup:
CREATE TABLE Students ( Name, DateOfBirth ) AS
          SELECT 'Alice', DATE '1994-10-22' FROM DUAL
UNION ALL SELECT 'Bob',   DATE '1994-10-23'   FROM DUAL
UNION ALL SELECT 'Carol', DATE '1992-02-29'   FROM DUAL;

Query 1:
WITH Dates ( Name, DateOfBirth, Birthday, Incr ) AS (
  SELECT Name,
         DateOfBirth,
         ADD_MONTHS( DateOfBirth, ( EXTRACT( YEAR FROM SYSDATE ) - EXTRACT( YEAR FROM DateOfBirth ) ) * 12 ),
         EXTRACT( YEAR FROM SYSDATE ) - EXTRACT( YEAR FROM DateOfBirth )
  FROM   Students
  UNION ALL
  SELECT Name,
         DateOfBirth,
         ADD_MONTHS( DateOfBirth, ( Incr + 1 ) * 12 ),
         Incr + 1
  FROM   Dates
  WHERE  TO_CHAR( ADD_MONTHS( DateOfBirth, Incr * 12 ), 'DAY' ) <> 'SUNDAY   '
)
SELECT Name, DateOfBirth, Birthday
FROM   Dates
WHERE  TO_CHAR( Birthday, 'DAY' ) = 'SUNDAY   '

Results:
|  NAME |                DATEOFBIRTH |                   BIRTHDAY |
|-------|----------------------------|----------------------------|
|   Bob |  October, 23 1994 00:00:00 |  October, 23 2016 00:00:00 |
| Alice |  October, 22 1994 00:00:00 |  October, 22 2017 00:00:00 |
| Carol | February, 29 1992 00:00:00 | February, 28 2021 00:00:00 |

A: Use the EXTRACT function with DAY.
nls_territory = 'AMERICA';
SELECT *
FROM student
WHERE EXTRACT(DAY FROM dob) = 7

or
nls_territory = 'UNITED KINGDOM';
SELECT *
FROM student
WHERE EXTRACT(DAY FROM dob) = 6

(Assuming table is called student and birthday/date of birth field is called dob)

A: --prepare test data
create table students(name varchar2(50), dob date)

insert into students(name, dob)
select 'Student '||rownum, to_date('1970.12.31','yyyy.mm.dd')-rownum from all_objects
 where rownum < 365

--the query
select s.*
,to_char(s.next_dob,'DAY') day_of_week
 from (
select st.*
       ,to_date((extract(YEAR from sysdate) + addyear)*10000+extract(MONTH from dob)*100+extract(DAY from dob),'YYYYMMDD') as next_dob
from students st
    ,(select rownum -1 as addyear from all_objects where rownum < 9)
)s
where s.next_dob > sysdate
 and rtrim(to_char(s.next_dob,'DAY')) = 'SUNDAY'
order by next_dob

A: You can replace the birthdate by select statement and save it to new_birthdate.
declare

birthdate DATE:= to_date('10-23-1994', 'mm/dd/RRRR');
yr NUMBER;
new_birthdate DATE;
temp DATE;
X BOOLEAN:=FALSE;
BEGIN

new_birthdate := birthdate; --you can remove this and

 --dbms_output.put_line(temp);
   while (X = FALSE) loop

      new_birthdate:=  to_date(TO_CHAR(add_months(new_birthdate,12), 'MM/DD/RRRR'),'mm/dd/RRRR');
      temp:=new_birthdate;
       dbms_output.put_line(TO_CHAR(TEMP,'DAY'));

       IF TRIM(to_char(temp,'DAY')) = 'SUNDAY' AND TEMP > SYSDATE THEN

         X:=TRUE;
       EXIT;
       END IF;
   END loop;
   dbms_output.put_line(TEMP);

end;

A: WITH
  params AS (SELECT DATE '1994-10-23'  dob
                  , SYSDATE            since_date
                  , 12                 hits
                FROM dual)
SELECT next_dob_date
  FROM (
        SELECT dob + numtoyminterval(LEVEL, 'YEAR') next_dob_date
          FROM params CONNECT BY LEVEL < 100
       )
 WHERE to_char(next_dob_date, 'D', 'NLS_DATE_LANGUAGE=''numeric date language''') = 7
   AND next_dob_date >= (SELECT since_date from params)
   AND rownum <= (SELECT hits from params)


text:
Q: Remove duplicates from custom entities in Microsoft Dynamics CRM Has anyone found a good way to either merge or remove duplicates that are in custom entities? In our case we have two custom entities, literature history and subscriptions which relate contacts back to a custom entity named literature.
I can run a duplicate detection job, but this returns thousands of records and deleting them one at a time is impractical at best. We would like to either be able to merge them or just delete the duplicates. However, much Google searching has not turned up any good suggestions other than "you can write something."
Okay, but where to even get started? Should I be bulk deleting from the duplicate detection job? Should I try just writing a quick and dirty c# program with the SDK? Is there a way to merge custom entities that just requires some magical workflow voodoo?
EDIT: FYI What I eventually did was setting the deletion state code using some fun SQL to quickly find duplicates:
UPDATE T1 SET DeletionStateCode = 2
FROM New_subscriptionhistory T1 INNER JOIN New_subscriptionhistory T2 ON t1.New_LiteratureId = T2.New_LiteratureId AND t1.New_ContactId = t2.New_ContactId
AND t1.CreatedOn > t2.CreatedOn AND t1.statecode = 0 AND t2.statecode = 0

A: You should look into creating a Bulk Delete Job using the SDK.
Here's a short tutorial.

A: I won't say with certainty that this is the only or the best way, but we've used SQL queries in the _MSCRM database, setting the DeletionStateCode of any duplicated entity to 2.


text:
Q: Enter value in cell which already contains formula I'm creating a LibreOffice calc spreadsheet but I can also use Excel if this will make things easier.
The spreadsheet is based around a scientific formula with 3 variables, let's call them a, b and c. To be honest, there is also a 4th variable, d. However, d is just c in a different representation (like in d=1/c). Sometimes, it's more intuitive to enter c, sometimes d.
OK, I end up with 4 variables.
It is necessary for the user to enter 2 of them, the missing 2 can be calculated easily (except if the user enters c and d, this will not work of course).
Let's say column A, B, C and D are for entering the variables a, b, c and d.
I want my spreadsheet to calculate the missing two values.
That's no problem. Each cell is prefilled with the necessary formula.
However, imagine the user to enter a and b.
c and d will now be calculated and displayed. But by entering a and b, the formulas for calculating a and b are overwritten!
It's now not possible to clear b and enter c instead. If the user want to enter different variables he has to copy the formulas from "backup cells".
To make it short: I want the cell to contain their formulas even if a value is entered. Is this possible without macros?
I can think of a solution using helper cells...

A: Add a different scenario for each possibility.  For example, start with the following formulas.
A      B        C
~~~~~  ~~~~~~~  ~~~~
=B1+1  =A1+1.5  =A1+B1

To begin with, all of these formulas depend on each other, resulting in a circular dependency Err:522.
Now, select all three cells and create a scenario with Tools -> Scenarios.  Name the first one "All Formulas" and press OK.
Create three more scenarios, one for each variable, named "Variable A", "Variable B", "Variable C".
Then select the scenario named "Variable A" and enter a value in cell A1.  Likewise, use "Variable B" when setting B1 to a value.
The "Variable C" scenario in this example is a little trickier because it depends on both A1 and B1.  Thankfully, Calc provides a tool for this as well.  Go to Tools -> Solver and set Target cell to C1, By changing cells to either A1 or B1, and then specify the desired resulting number in Value of.

For my example, it may be necessary to use two scenarios for variable C, one in which By changing cells is A1 and another in which it is B1.  So the name could be something like "Variable C by changing A".


text:
Q: CSV file: Change the position of column to row and reorganize dataset INTRODUCTION: I have a CSV file (fossil-fuel-input.csv) that contains the data on fossil fuels utilization by country and year. The layout of data (order of rows and columns) in this CSV is not in a proper way.
DESCRIPTION: The layout in which I want the data is shown in the second CSV file (fossil-fuel-output.csv). This second CSV only contains few records from the first CSV. Actually, I want all records from fossil-fuel-input.csv to be present in fossil-fuel-output.csv. Manually doing copy-paste is not feasible as it will take a lot of time.
QUESTION: How can I achieve this? Feel free to use any tool like Excel, Python, etc. (Tried V-lookup and Transpose in Excel, but, it didn't work for me).

A: You can do this with pandas by creating a pivot table:
import pandas as pd
df = pd.read_csv('https://gitlab.com/sysuin/datasets/-/raw/main/fossil-fuel-input.csv?inline=false')
df = df.pivot_table(values='Fossil Fuels (TWh)', index='Entity', columns='Year', aggfunc='first')
df.to_csv('output.csv')


text:
Q: IE issues z-index css I am utterly confused. I have read thru the articles recommended for this topic and still can't seem to find something that works.
Here's how it's SUPPOSED to look:
------> use FIRFOX or SAFARI
http://lisareisman.com/tests/focusTest
then look at it on IE 8 or 9. the 2 'i' icons and the iPod label have been 'relocated'.
this is the css:
#feature_top, feature_bottom {
z-index:1;
}

#feature_top img.info_btn {
position:relative;
float:right;
margin-top:-28px;
margin-right:165px;
z-index:2;
}

.img_overlay {
float:right;
margin-right:-15px;
margin-top: -150px;
position:relative;
z-index:3;
}

#feature_bottom img.info_btn {
position:relative;
float:right;
margin-top:-155px;
margin-right:125px;
z-index:2;
}

i have a separate ie style sheet.
html for the top section:

QwickPay Mobile Payment System

QwikPay is a complete payment solution allowing your PC, Mac, IiPhone, iPod Touch, iPad or any other mobile smart phone, to evolve into a highly secure payment system. With QwikPay, you can easily accept credit and signature debit sales anytime, anyplace. Don't type, safely swipe and you and your customer will enjoy the convenience and peace of mind unmatched by any other secure, POS system. It is easy to use and can help merchants lower their cost of accepting cards by as much as 30%. When your customers want to pay with a card, QwikPay is the safest way.

I sure appreciate the help. I am close to wits end. I am using the Explorer Developer bar and I am trying to nudge the 'i' icons & the iPod label down and they get close then jump down past the image below.
I keep going back and trying things in other posts being suggested but can't seem to find the right one. Really appreciate the time. Have a good one!!
Thank you!!!
Lisa
'I should know how, but I don't' l;o)

A: You can fix this using IE conditional comments in your CSS. Put them at the end of your current CSS declarations just in case (precedence)...


text:
Q: How and when does ktpass set the salt? A user's password and salt determine the Kerberos keys generated by ktpass. I have noticed that ktpass sometimes changes the user's salt, but other times it does not. I was able to discover the salt by capturing a packet trace of a kinit. The salt appears to be generated based on the Kerberos realm and the userPrincipalName. However, it's not this simple. If the UPN is later updated manually, the salt is not updated. (I suspect that whether the /mapop option is specified may play a role.)

*

*In what circumstances does ktpass set the user's salt?

*How is the salt determined?

*Is the salt stored in AD, or just in the KDCs?

*Is there a straightforward way to read the current value of the salt?

*Is there a way to manually change the salt?

A: *

*In Microsoft Windows Active Directory, which has used Kerberos v5 since its inception in Windows 2000, the ktpass command sets the salt automatically. The salt is always used in Kerberos v5.  In Kerberos v4, a salt was never used.

*The complete principal name (including the realm) is used as the salt,  e.g., accountname/somedomain.com@SOMEDOMAIN.COM, which is then paired with the encrypted hash of the password to absolutely ensure the result is unique throughout the AD forest.

*As mentioned, the salt is the complete principal name (including the realm).  It is stored in the ntds.dit file, which is the Active Directory database.  The KDC get spun up in a process spawned by by kdcsvc.dll - and it relates to the values stored in ntds.dit.  So while the KDC and AD database are not one and the same inside the runtime environment, they are, so to speak, "joined at the hip".  I think when the domain controller shuts down, all the important elements within the KDC is persisted inside of ntds.dit.  Microsoft does not provide exact details on how this is done. I have looked extensively, and my partial knowledge is drawn from careful study and inferences made from bits and pieces of articles found on the web.  Note that the ntds.dit database is also the LDAP database.  It is also the DNS database, if DNS is AD-integrated.  All these protocols working together, plus a few more, form "Active Directory".

*Open up Active Directory Users and Computers, go to the Account tab.  The "user logon name" is the most straightforward way to "read" the salt.  You don't see the realm name concatenated with it right there but it is implied.    The SPN, if also defined, is listed in a straightforward way like you are looking for under the Attribute Editor tab (look for servicePrincipalName).  Make sure you have View > Advanced Features selected in order to expose this tab.  A corresponding UPN will also be listed lower down in this same section, in the manner that looks exactly like: accountname/somedomain.com@SOMEDOMAIN.COM.

*When you change the account name on the AD Account tab, you have just changed the salt.  Note if there is a keytab out there tied to this AD account, you will have just invalidated it, as its secret key inside is a concantaention of the password hash and the salt.  When either the salt or the password changes, then the keys will no longer match between the AD account and that inside the keytab.  You will have to re-generate it at this point.

Makes sense?   This is really a field explanation.  To learn more about Kerberos as it relates to AD, start here:  Kerberos Survival Guide

A: There is a slightly easier way to read the current salt value (it is not really straightforward but at least no paket tracing is required):

*

*Install MIT Kerberos for Windows

*Open a PowerShell and run:
$env:KRB5_TRACE="kinit-trace.log"
'C:\Program Files\MIT\Kerberos\bin\kinit.exe' -fV UPN-or-USER@REALM
Get-Content $env:KRB5_TRACE | Select-String "salt"
rm $env:KRB5_TRACE

I assume here that MIT Kerberos is installed at its default location. If not you need to adjust the path name in the second command.

This solution was originally suggested here on Stackoverflow for Linux by user Spezieh.


text:
Q: What's the purpose of (IN.uv.xyxy).xy)? I'v got a surface shader some other people wrote.And it works fine.However I see codes like this:
struct Input
{
    float2 uv;
    //...
}

void surf(Input IN,//...)
{
    float4 tex = tex2D(_Tex, (IN.uv.xyxy).xy);
}

...
I tried to replace (IN.uv.xyxy).xy with IN.uv. The output effect seems nothing different.
So I was wondering what does the (.xyxy).xy do?
Does the code have to be like this?Thanks for any help!

A: In GLSL, this is known as swizzle operation.
You can use it to filter, reorder, and repeat float components.
You can use any combination of up to 4 of the letters to create a vector4 (of the same basic type) of that length.
So
IN.uv.xyxyis a vector4, created using only x and y components on uv in repetition.
Then
(IN.uv.xyxy).xy is vector2 same type as IN.uv but so with called enhancement. I guess in your code these two would not be much different as its just like creating a Vector4 from Vector2 and then using its first 2 values to create Vector2.
Like in following example:
Vector2 v2 = new Vector2(2f,4f);
Vector4 v4 = new Vector4(v2.x, v2.y, v2.x, v2.y);
Vector2 v2_new = new Vector2(v4.x, v4.y); // same as v2

Any combination of up to 4 letters is acceptable, so long as the source vector actually has those components.
Hope this helps.


text:
Q: Loading multiple reportviewers in parallel We have a requirement to show 3 graphs in SSRS report format.
So, we have developed an ASP.NET (F/W 4.0) web page with 3 report viewer (Version:10) controls placed on the web page (hosted under IIS 7.0).
Each report viewer control will be loaded with the respective SSRS report (.rdl) from the SSRS server in REMOTE mode (with AsyncRenedering = True which is default).
When we run the page, we expected that 3 reports will get loaded concurrently (or) in parallel.
But in reality, the reportviewer controls are loading the reports sequentially in the order their placement on the web page.
I tried to move the report population logic into a ThreadStart but that did not help - getting an error

Object reference not set to instance of an object

when I access reportviewer control in the thread.
Please let me know if there is a way to have the reportviewer control load the reports in parallel & not in sequence (without using IFRAMEs).
Thanks & Regards
Praveen.

A: It seems known issue with ReportViewerControl.
Please go through link below for more information.
https://social.msdn.microsoft.com/Forums/en-US/a8fc7b09-ae3b-4a4c-822b-fede10685436/multiple-report-viewers-on-one-page-issue?forum=sqlreportingservices
Adding summery from above link
This is a known limitation with the current version of the report viewer and something we would like to address in the future.  I have seen customers work around this problem by placing the report viewers on their own page and using an iframe on your main page.  The browser should then render them in parallel if they are using server mode and you don't use ASP.Net session.  In local mode or in server mode with ASP.Net session, ASP.Net will serialize the requests by locking on the session.
Thanks


text:
Q: Login with Facebook/Twitter on Distributed CMS Essentially, what I'm doing is writing my login and authentication routines for the CMS I'm developing. I'd like to incorporate the ability for a user to log in using Facebook or Twitter instead of having to type in their username and passwords. Part of the feature is the site owner would be able to turn this feature on and off, depending on their security preferences for managing their site.
I've got the app set up in Facebook and Twitter, though what I'm running into is that the request will only ever be bounced back to one URL, even though I'm intending that the CMS be downloaded and installed on separate domains and run independently from one another.
I've tried setting up a simple service that my CMS can dial home to (which is where the responses have to be funneled to due to Facebook and Twitter policy). Idealistically, my service would retrieve the user's facebook or twitter ID, and output the response data as an XML feed so that my CMS could parse the response and log them in accordingly. The part that I'm snagged on is the feed will prompt the user to login every time, so it seems like the permissions are not where they need to be, or the data just isn't crossing the domains appropriately.
What am I missing here?


text:
Q: Moving items in ItemsControl I have a list of items, which every item include a few of notes, like this:
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        List<Item> items = new List<Item>();
        Item item1 = new Item() { Title = "First Item" };
        Item item2 = new Item() { Title = "Second Item" };

        item1.ItemNotes.Add(new ItemNote() { Note = "first_note" });
        item1.ItemNotes.Add(new ItemNote() { Note = "second_note" });
        item1.ItemNotes.Add(new ItemNote() { Note = "third_note" });
        item2.ItemNotes.Add(new ItemNote() { Note = "fourth_note" });
        item2.ItemNotes.Add(new ItemNote() { Note = "fifth_note" });

        items.Add(item1);
        items.Add(item2);

        ic_tasks.ItemsSource = items;
    }
}

public class Item
{
    public Item()
    {
        this.ItemNotes = new ObservableCollection<ItemNote>();
    }
    public string Title { get; set; }
    public ObservableCollection<ItemNote> ItemNotes { get; set; }
}
public class ItemNote
{
    public string Note { get; set; }
}

In XAML I present those items by ItemsControl, like this:
<Grid>
   <ItemsControl Name="ic_tasks">
      <ItemsControl.ItemTemplate>
          <DataTemplate DataType="{x:Type local:Item}">
              <StackPanel Orientation="Vertical">
                  <Border BorderThickness="1" CornerRadius="8" Background="DarkGray">
                      <StackPanel Orientation="Horizontal" Height="30">
                          <TextBox Text="{Binding Title}" Margin="5,5,5,5"/>
                          <Button Margin="5,5,5,5">Fold</Button>
                      </StackPanel>
                  </Border>
                  <ItemsControl ItemsSource="{Binding ItemNotes}">
                      <ItemsControl.ItemTemplate>
                          <DataTemplate DataType="{x:Type local:ItemNote}">
                              <TextBox Margin="40,5,5,5" Text="{Binding Note}"/>
                          </DataTemplate>
                      </ItemsControl.ItemTemplate>
                  </ItemsControl>
              </StackPanel>
          </DataTemplate>
      </ItemsControl.ItemTemplate>
   </ItemsControl>
</Grid>

And now my goal is to make those Items moveable. For example, I would like to be able to move the second item over the first item, like below:

What I tried?
I try to wrap all ItemsControl by Canvas and bind position by Canvas.Top & Canvas.Left by using Mouse Events, but there's no such property for StackPanel which I want to move. There's only such propery for ItemsControl, like below:
<Canvas x:Name="canvas_of_items">
    <ItemsControl Name="ic_tasks" Canvas.Top="{Binding YPosition}" Canvas.Left="{Binding XPosition}">
        <...>
             <StackPanel Orientation="Horizontal" Height="30" PreviewMouseDown="StackPanel_MouseDown" PreviewMouseMove="StackPanel_MouseMove" PreviewMouseUp="StackPanel_MouseUp">
        <...>
    </ItemsControl>
</Canvas>

So my question is:
What are the options to allow Items to be moved between themselves? Importantly, when moving the Item, it should be visible, not the mouse cursor itself.

A: You can set the ItemsControl to place your items in a canvas using ItemsControl.ItemsPanel like this:
<ItemsControl Name="ic_tasks">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Canvas></Canvas>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

But to move the items you cant just set the Canvas properties on the StackPanel because they are surrounded by ContentPresenter. Instead you use ItemsControl.ItemContainerStyle to set  a style on these ContentPresentors and there you can do something like this:
<Style>
     <Setter Property="Canvas.Left" value="<<somthing - propebly a binding so it will be easy to change>>"
</Style>


text:
Q: Event delegation in KineticJS I'm wondering if possible do create a event delegation from an object reference inside another object, this is the scenario.
I have 2 circles and 1 line between those two circles, every time any circle changes its own postition it have to update the line's position as well, by this time I have created a custom line that is going to have a reference to the two circles as a properties (origin, target)
but isn't binding the event in that way.
what I'm tryting to do is something like>
this.origin.on('dragstart dragmove',function(){
    console.log("origin mouse move");
    this.setPoints([origin.getX(),origin.getY(), target.getX(), target.getY()]);
    this.draw();
});

this is the fiddle

A: buildArrow: function(origin,target){
    var arrowInstance = new Shape.Arrow({
       points: [origin.getX(),origin.getY(), target.getX(), target.getY()],
        stroke: '#629DD1',
        tension: 1
    });
    arrowInstance.origin=origin;
    origin.line = arrowInstance;

    arrowInstance.target=target;
    target.line = arrowInstance;
    return arrowInstance;
},
updatePosition : function() {
    this.points([this.origin.getX(),this.origin.getY(), this.target.getX(), this.target.getY()]);
},

Then:
this.on('dragstart dragmove',function(){
    var centerpoint = (this.cellSize/2)
     this.setX(((Math.round(this.getX() / centerpoint) * centerpoint)));
    this.setY(((Math.round(this.getY() / centerpoint) * centerpoint)));
    this.line.updatePosition();
});

Demo: http://jsfiddle.net/lavrton/5Wkph/28/


text:
Q: Error in request then using WSDL2APEX Im facing an issue when I try to import my WSDL into Salesforce and generate APEX code from this one. When I add a targetnamespace to my second schema in the following file, which is required in Salesforce, I need to update the reference so that my request still has the valid format:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wss="http://www.boomi.com/connector/wss">
   <soapenv:Header/>
   <soapenv:Body>
      <wss:querySearch>
         <!--Optional:-->
         <Car>
            <Reg_Number></Reg_Number>
         </Car>
      </wss:querySearch>
   </soapenv:Body>
</soapenv:Envelope>

My current WSDL:
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.boomi.com/connector/wss" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="WebServiceProvider" targetNamespace="http://www.boomi.com/connector/wss" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <xs:schema elementFormDefault="qualified" targetNamespace="http://www.boomi.com/connector/wss" version="1.0">
      <xs:import />
      <xs:element name="querySearch" type="tns:querySearch" />
      <xs:complexType name="querySearch">
        <xs:sequence>
          <xs:element minOccurs="0" ref="Car" />
        </xs:sequence>
      </xs:complexType>
      <xs:element name="querySearchResponse" type="tns:querySearchResponse" />
      <xs:complexType name="querySearchResponse">
        <xs:sequence>
          <xs:element minOccurs="0" ref="Car" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
    <xs:schema elementFormDefault="qualified" version="1.0">
      <xs:element name="Car" type="Car" />
      <xs:complexType name="Car">
        <xs:sequence>
          <xs:element minOccurs="1" maxOccurs="1" name="Reg_Number" type="xs:string" />

        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="querySearch">
    <wsdl:part name="parameters" element="tns:querySearch" />
  </wsdl:message>
  <wsdl:message name="querySearchResponse">
    <wsdl:part name="parameters" element="tns:querySearchResponse" />
  </wsdl:message>
  <wsdl:portType name="WebServiceProviderPortType">
    <wsdl:operation name="querySearch">
      <wsdl:input message="tns:querySearch" />
      <wsdl:output message="tns:querySearchResponse" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="WebServiceProviderPortBinding" type="tns:WebServiceProviderPortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="querySearch">
      <soap:operation soapAction="querySearch" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="WebServiceProvider">
    <wsdl:port name="WebServiceProviderPort" binding="tns:WebServiceProviderPortBinding">
      <soap:address location="XXXXXXXX" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

When I alter my WSDL to the following (adding a targetnamespace and adding the "tns:" to the types):
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.boomi.com/connector/wss" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="WebServiceProvider" targetNamespace="http://www.boomi.com/connector/wss">
  <wsdl:types>
    <xs:schema elementFormDefault="qualified" targetNamespace="http://www.boomi.com/connector/wss" version="1.0">
      <xs:element name="Car" type="tns:Car"/>
      <xs:complexType name="Car">
        <xs:sequence>
          <xs:element maxOccurs="1" minOccurs="1" name="Reg_Number" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:element name="querySearch" type="tns:querySearch"/>
      <xs:complexType name="querySearch">
        <xs:sequence>
          <xs:element minOccurs="0" ref="tns:Car"/>
        </xs:sequence>
      </xs:complexType>
      <xs:element name="querySearchResponse" type="tns:querySearchResponse"/>
      <xs:complexType name="querySearchResponse">
        <xs:sequence>
          <xs:element minOccurs="0" ref="tns:Car"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="querySearch">
    <wsdl:part element="tns:querySearch" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="querySearchResponse">
    <wsdl:part element="tns:querySearchResponse" name="parameters"/>
  </wsdl:message>
  <wsdl:portType name="WebServiceProviderPortType">
    <wsdl:operation name="querySearch">
      <wsdl:input message="tns:querySearch"/>
      <wsdl:output message="tns:querySearchResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="WebServiceProviderPortBinding" type="tns:WebServiceProviderPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="querySearch">
      <soap:operation soapAction="querySearch"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="WebServiceProvider">
    <wsdl:port binding="tns:WebServiceProviderPortBinding" name="WebServiceProviderPort">
      <soap:address location="XXXXXXXXXXXXXXXXX"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

It goes through Salesforce but generates the following request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wss="http://www.boomi.com/connector/wss">
   <soapenv:Header/>
   <soapenv:Body>
      <wss:querySearch>
         <!--Optional:-->
         <wss:Car>
            <wss:Reg_Number>?</wss:Reg_Number>
         </wss:Car>
      </wss:querySearch>
   </soapenv:Body>
</soapenv:Envelope>

It adds the "wss" prefix to the Car element and the input paramter in the request, which makes the request invalid. Can I solve this in some way by altering the namespaces or something like that? The wsdl is generated from Dell Boomi and hence a solution from there would be prefered but for now I am satisfied if I can alter the WSDL manually.
Ciao!


text:
Q: why am i getting error when trying to open new activity in android studio
I'm getting this error when I write the intent inside the onCreate method.
But when I write the intent inside an outer method and call it, it works.

A: Button click listener is an interface and you implemented it here as an anonymous class, so inside of that class this refers to that anonymous class, not your activity class, but Intent constructor needs activity class implementation, therefore as @ADITYA RANADE answered you need to change it to MainActivity.this.
However if you replace anonymous class with lambda you can avoid this:
    Button button = new Button(context);
    button.setOnClickListener(v -> {
        Intent intent = new Intent(this, MainActivity.class);
    });

A: Change it to MainActivity.this inside the intent

A: Well that is because of the place or more precisely "context" (not the androidish Context) of where you are calling it.
When you call it from the anonymously created inner class which implements the listener for a view click, so in this case the this represents something else - anonymous class.
But on the other side when you make the method e.g. openScheduleActivity() inside the activity itself, the this keyword represents the activity itself and in fact represents the androidish Context or in this particular case even the activity. So you can either stay with case that you have already had there and slightly edit it, or you can use lambda expression, or you can use the method inside the activity itself as you have already discovered.
edited case:
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, schedule.class);
                startActivity(intent);
            }
        });

lambda expression:
        button.setOnClickListener(v -> {
            Intent intent = new Intent(MainActivity.this, schedule.class);
            startActivity(intent);
        });


text:
Q: Not sure how to implement the SMB project into my app I'm trying to implement SMB into my app and found this https://github.com/amosavian/AMSMB2. I'm not sure how to implement this code into the UI of my app. For example, do I connect the connect function to a button and if so how would I proceed to do so. What would I put into the parameters of connect() when I call it if I call it.
Here's the code from the repository:
import AMSMB2

class SMBClient {
/// connect to: `smb://guest@XXX.XXX.XX.XX/share`

let serverURL = URL(string: "smb://XXX.XXX.XX.XX")!
let credential = URLCredential(user: "guest", password: "", persistence: URLCredential.Persistence.forSession)
let share = "share"

lazy private var client = AMSMB2(url: self.serverURL, credential: self.credential)!

private func connect(handler: @escaping (Result<AMSMB2, Error>) -> Void) {
    // AMSMB2 can handle queueing connection requests
    client.connectShare(name: self.share) { error in
        if let error = error {
            handler(.failure(error))
        } else {
            handler(.success(self.client))
        }
    }
}

func listDirectory(path: String) {
    connect { result in
        switch result {
        case .success(let client):
            client.contentsOfDirectory(atPath: path) { result in
                switch result {
                case .success(let files):
                    for entry in files {
                        print("name:", entry[.nameKey] as! String,
                              ", path:", entry[.pathKey] as! String,
                              ", type:", entry[.fileResourceTypeKey] as! URLFileResourceType,
                              ", size:", entry[.fileSizeKey] as! Int64,
                              ", modified:", entry[.contentModificationDateKey] as! Date,
                              ", created:", entry[.creationDateKey] as! Date)
                    }

                case .failure(let error):
                    print(error)
                }
            }

        case .failure(let error):
            print(error)
        }
    }
}

func moveItem(path: String, to toPath: String) {
    self.connect { result in
        switch result {
        case .success(let client):
            client.moveItem(atPath: path, toPath: toPath) { error in
                if let error = error {
                    print(error)
                } else {
                    print("\(path) moved successfully.")
                }

                // Disconnecting is optional, it will be called eventually
                // when `AMSMB2` object is freed.
                // You may call it explicitly to detect errors.
                client.disconnectShare(completionHandler: { (error) in
                    if let error = error {
                        print(error)
                    }
                })
            }

        case .failure(let error):
            print(error)
        }
    }
  }
}

A: late but for reference as i couldnt find much when i tried
add the amsmb2 library and that template class file to your project
in the class file set serverurl, share, credential correctly for your smb server
then
declare  a  variable of class smb_client
then from your button or whatever
var myclient:smb_client=smb_client()
myclient.connect()

to connect to your smb server for example
you can extend that class templete to download/upload items etc
the operations are asynchronous


text:
Q: js-tree multiple instances issue I have multiple instances of jstree. I am using js-tree.directive.
var selectedNode = $('js-tree').jstree(true).get_selected(true)[0];
var parentNodeId = $('js-tree').jstree("get_parent",selectedNode);`

but parentNodeId is returning false. It does not understand which tree it is on.
I want ParentNodeId.
Regards
Sonal


text:
Q: R function to remove all rows with at leat one NA doesn't work using dplyr Can you please help me to see why my function is not working? Given this table, my_df
  sexo edad
1    m   23
2    f   34
3   NA   34
4    f   NA
5    m   33

I want to make a function that removes every row with a NA field to use it for different data frames. I made this function:
filter_out_nas = function(df){
  vars = names(df)
  for(var in vars){
    print(var)
    df = filter(df, !is.na(var))
  }
  return(df)
}

I want the output to look like this:
  sexo edad
1    m   23
2    f   34
5    m   33

However when I try to use the function on my_df, it doesn't do anything:
library(dplyr)
my_df = filter_out_nas(m_df)
## returs the same table given above, `my_df` does not change.

Thank you very much for your time

A: I wasn't entirely clear on what you wanted, so here are two things that may help.
First: remove all rows that have NA from your dataframe.
library(tidyr)
df_no_NA <- drop_na(df)

Second: make a new dataframe with only rows that have NA.
library(dplyr)
df_only_NA <- filter_all(df, ~!is.na(.))

Hope this helps.

A: For a base R option here, you could just use rowSums with is.na:
df[rowSums(is.na(df)) == 0, ]

  sexo edad
1    m   23
2    f   34
5    m   33

Data:
df <- data.frame(sexo=c("m", "f", NA, "f", "m"), edad=c(23,34,34,NA,33))

A: you can do it in a simple way!
my_df<- my_df[rowSums(is.na(my_df)) == 0,]

And if you have " " (empty) values and NA you can use
my_df<- my_df[rowSums(is.na(my_df)| my_df=="") == 0,]

A: the easiest solution should be na.omit(df)


text:
Q: Experimental Analysis of an Algorithm - How to prove that the graph is $O(n\log n)$? This question is probably stupid, but I've been trying to figure this out for hours and I still couldn't find anything about it. Probably I'm just too lost.
So basically, I'm analysing an algorithm by doing an asymptotic and experimental analysis. The asymptotic analysis went well and I concluded that my algorithm is $O(n\log n)$. The problem is the experimental analysis. Firstly, I did some tests to get the time taken for each input. For example:
$n = 1, t = 0 | n = 2, t = 2 | n = 4, t = 8 | n = 8, t = 24 | n = 16, t = 64 | n = 32, t  = 160 (...)$
If I do the graph with this example, I can see that it is an O(n log n)/linearithmetic graph, but how do I prove it? Do I have to calculate the order of growth? If so, how do I do it?
Thanks for the help!

A: You can try to see (e.g., by plotting) if the function $\frac{T(n)}{n}$  has a logarithmic growth (to reduce the number of hidden constants, instead of checking $T(n)$ itself).
For example, you can try to use non-linear least square curve fitting (e.g., with R) and fit a logarithm function (of the form Const + A * log(n), e.g.,) and compare the growths. The following R code shows an example of the same on randomly generated time
n <- 1:100
T <- 5*n*(log(10*n))+2+10*runif(1) # randomly generated time complexity T(n)

nlmod <- nls(T/n ~  Const + A * log(n), start = list(A = 1, Const=1), trace=TRUE)
summary(nlmod)
# Formula: T/n ~ Const + A * log(n)

# Parameters:
#  Estimate Std. Error t value Pr(>|t|)
#  A      4.14962    0.07108   58.38   <2e-16 ***
#  Const 15.05845    0.26675   56.45   <2e-16 ***
# ---
# Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# Residual standard error: 0.6563 on 98 degrees of freedom

# Number of iterations to convergence: 1
# Achieved convergence tolerance: 3.671e-09

plot(n,T/n, main = "nls(*), data, true function and fit, n=100", pch=19)
lines(n, predict(nlmod), col = 2)
lines(n, predict(nlmod,n), col = 2, lwd=2)
legend("bottomright", legend=c("T(n)/n", "fitted"),
   col=c("black", "red"), pch=c(19,NA), lty=c(NA,1), lwd=2)

You can also compute the distance (e.g., MSE, KL-divergence etc.) between the fitted logarithmic curve and the actual $\frac{T(n)}{n}$, to ensure that it's sufficiently small for large enough $n$.


text:
Q: how do you subset R data frame based on provided column names via a function argument? I am trying to create a R function based on given data frame as the first argument, subset the data frame based on provided arguments:
For example, my df is like this:
Date       Server1 Server2 Server3 Server4
1/1/2004     10     20       10      5
2/1/2014      4     4        4       20
3/2/2014      1     5        5       39

I need to subset this df:
For example, if I pass to this function(x, Server1, Server3, Server4), it will look like this:
data<-function(x, ...) {

subset(x, select=c("Server1","Server3", "Server4"))
}

But, I the argument list should not be known. It should apply to all data frames not knowing the column names.
Any ideas how I could accomplish this in R?

A: If you pass your arguments as strings it should would work fine like this:
subset2<-function(x, ...) {
  cols <- c(...)
  subset(x, select=cols)
}

subset2(dat, "Server1", "Server3", "Server4")

But I'm not sure why such a wrapper is necessary.  Perhaps I am missing what your true goal is?

A: Maybe you should reconsider whether a wrapper function around subset is really necessary. As far as I can see, your intended function does the same as subset itself and requires the same arguments with slightly different sintax.
In any case, if you don't know the column names, you can use column indices instead (e.g. subset(x, select=c(1,3,4)).

A: Get rid of subset, as on its help page it says specifically in a warning that it's intended for interactive use only. I don't see the problem here, you can simply do the following:
data<-function(x, select, ...) {
    tmp <- x[select]
    # do some stuff with it
    return(tmp)
}

A simple illustration:
data(iris, c("Sepal.Width", "Species"))
#     Sepal.Width    Species
# 1           3.5     setosa
# 2           3.0     setosa


text:
Q: How can I entirely disable browser media integration in KDE Plasma 5? I'm using a fully updated KDE Neon, currently with KDE Plasma 5.16.3. Using Vivaldi as a web browser.
Plasma has a feature that allows you to control in-browser media players (such as YouTube, but not only) in the same way you control media player applications: Using desktop widgets, keyboard buttons etc.
The above is normally implemented as a browser extension, working with a plugin for the Plasma environment.
I want to disable this feature, but surprisingly I'm unable to do it. I've removed the extension from Vivaldi and I've also removed the plasma-browser-integration package from my system but still, both widgets and my keyboard's play/pause buttons work on videos playing in the browser.
How is the feature still working? What can I do to disable it?

A: The wiki gives a hint at how to activate this feature for common browsers. The answer is then to disable or remove the browser extension.


text:
Q: Disable one unused variable warning How can I disable one warning in one place only?
I have one variable which I temporarily don't use. Xcode shows me a warning about the "unused variable". I want to disable the warning, but for this variable only, not all warnings of this type.
Is it possible without setting/getting this variable's value?

A: From GCC / Specifying Attributes of Variables (understood by Clang as well):
int x __attribute__ ((unused));

or
int y __attribute__((unused)) = initialValue ;

A: __unused int theInt = 0;
// there will be no warning, but you are still able to use `theInt` in the future

A: It's pretty simple:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
    NSUInteger abc; /// Your unused variable
#pragma clang diagnostic pop

But keeping unused variable is redundant and generally bad idea. Unused code should be removed. If you use git, there all changes are still in your repo and you can revert your code if you found that this variable is necessary.

A: Shortest keystroke answer, change:
int x; // this variable temporarily unused

to:
// int x; // this variable temporarily unused

and the warning will go. Also you cannot forget to remove it when you need the variable again, which you can do with any approach which leaves the variable declared.
If you want the removal to be a bit more visible, but wish to keep the property that you can't forget to remove it, try:
#if 0
int x; // this variable temporarily unused
#endif

HTH


text:
Q: How to set a dropdownlist item as selected in ASP.NET? I want to set selecteditem for asp. net dropdownlist control programmatically.
So I want to pass a value to the dropdownlist control to set the selected item where is the value of the item equal to the passed value.

A: dropdownlist.ClearSelection(); //making sure the previous selection has been cleared
dropdownlist.Items.FindByValue(value).Selected = true;

A: You can set the SelectedValue to the value you want to select. If you already have selected item then you should clear the selection otherwise you would get "Cannot have multiple items selected in a DropDownList" error.
dropdownlist.ClearSelection();
dropdownlist.SelectedValue = value;

You can also use ListItemCollection.FindByText or ListItemCollection.FindByValue
dropdownlist.ClearSelection();
dropdownlist.Items.FindByValue(value).Selected = true;

Use the FindByValue method to search the collection for a ListItem
  with a Value property that contains value specified by the value
  parameter. This method performs a case-sensitive and
  culture-insensitive comparison. This method does not do partial
  searches or wildcard searches. If an item is not found in the
  collection using this criteria, null is returned, MSDN.

If you expect that you may be looking for text/value that wont be present in DropDownList ListItem collection then you must check if you get the ListItem object or null from FindByText or FindByValue before you access Selected property. If you try to access Selected when null is returned then you will get NullReferenceException.
ListItem listItem = dropdownlist.Items.FindByValue(value);

if(listItem != null)
{
   dropdownlist.ClearSelection();
   listItem.Selected = true;
}

A: You can use the FindByValue method to search the DropDownList for an Item with a Value matching the parameter.
dropdownlist.ClearSelection();
dropdownlist.Items.FindByValue(value).Selected = true;

Alternatively you can use the FindByText method to search the DropDownList for an Item with Text matching the parameter.
Before using the FindByValue method, don't forget to reset the DropDownList so that no items are selected by using the ClearSelection() method. It clears out the list selection and sets the Selected property of all items to false. Otherwise you will get the following exception.
"Cannot have multiple items selected in a DropDownList"

A: This is a very nice and clean example:(check this great tutorial for a full explanation link)
public static IEnumerable<SelectListItem> ToSelectListItems(
              this IEnumerable<Album> albums, int selectedId)
{
    return
        albums.OrderBy(album => album.Name)
              .Select(album =>
                  new SelectListItem
                  {
                    Selected = (album.ID == selectedId),
                    Text = album.Name,
                    Value = album.ID.ToString()
                   });
}

In this MSDN link you can read de DropDownList method documentation.
Hope it helps.

A: Set dropdown property
selected="true"


text:
Q: sum of all the values from that row If I have a dataset with a column as shown below
 Col1
 1.080042
 1.083287
 1.141108
 1.191246
 1.117395

What I want to create is a another column Col2 like this
 Col1        Col2
 1.080042    1.080042/(1.080042 + 1.083287 + 1.141108 + 1.191246 + 1.117395)
 1.083287    1.083287/(1.083287 + 1.141108 + 1.191246 + 1.117395)
 1.141108    1.141108/(1.141108 + 1.191246 + 1.117395)
 1.191246    1.191246/(1.191246 + 1.117395)
 1.117395    1.117395 /1.117395

Col2 is Col1 value divided by the sum of Co1 values below it. I am not sure how to achieve this efficiently.

A: We can get the cumulative sum of reverse elements of 'Col1', get the reverse and divide by 'Col1'
df1$Col2 <- df1$Col1/rev(cumsum(rev(df1$Col1)))
df1$Col2
#[1] 0.1924153 0.2389760 0.3307800 0.5159945 1.0000000

-checking with OP's calculation
1.080042/(1.080042 + 1.083287 + 1.141108 + 1.191246 + 1.117395)
#[1] 0.1924153

1.083287/(1.083287 + 1.141108 + 1.191246 + 1.117395)
#[1] 0.238976

data
df1 <- structure(list(Col1 = c(1.080042, 1.083287, 1.141108, 1.191246,
1.117395)), class = "data.frame", row.names = c(NA, -5L))

A: library(tidyverse) # dplyr and purrr

df %>%
  mutate(Col2 = Col1/accumulate(Col1, `+`, .dir = 'backward'))

#       Col1      Col2
# 1 1.080042 0.1924153
# 2 1.083287 0.2389760
# 3 1.141108 0.3307800
# 4 1.191246 0.5159945
# 5 1.117395 1.0000000

A: Another base R solution besides cumsum by @akrun
df <- within(df,Col2 <- Col1/rev(Reduce(`+`,rev(Col1),accumulate = TRUE)))

such that
> df
      Col1      Col2
1 1.080042 0.1924153
2 1.083287 0.2389760
3 1.141108 0.3307800
4 1.191246 0.5159945
5 1.117395 1.0000000


text:
Q: Stick footer to bottom of wrapper, and get page to fit the whole space between nav & footer Here is the problem,
I'm using bootstrap, and I face this problem :
I have a webpage, containing a wrapper divided in 3 distinct items.
First item is a bootstrap nav.
Second item is a div (class col-lg-12 -> bootstrap).
Third item is a div (class col-lg-12 -> bootstrap).
The navbar is always on top of the page, perfect.
Problem is that the footer must always be at the bottom of the page, I thought about absolute positionning but that doesnt fit, wrapper has some style attributes that footer should respect. AND, #page element has to fit the whole space (in height) between nav & footer. I mean that, even if there is only 1 text line in the #page element, the #page height must fit all available space.
ALSO CONSIDER THAT the #page div can contain MANY data, and so, its height can be bigger than the window height (at that moment, wrapper still contains all since it has a min-height 100% attr, and footer should still be under the #page element...)

Style, actually, looks like this :

I think the problem comes from the mix of custom css and bootstrap classes... but can't find any solution that fixes it... already went through many asked questions here on stack, but not working...
here is the actual fiddle :
http://jsfiddle.net/0eepqj4m/18/
thanks!

A: If you're willing to use absolute positioning this would be easier.
Just add this to your footer:
position: absolute;

And then fix up a few on the other styles. Like adding position: relative; to the wrapper div, this gives the footer a reference to base it's position off of.
EDIT
Here's a jsfiddle with a short body length:
http://jsfiddle.net/NateW/0eepqj4m/93/
Here's a jsfiddle with a long body length:
http://jsfiddle.net/NateW/0eepqj4m/94/
Another Edit
If you want to use jQuery use something like this...
http://jsfiddle.net/NateW/0eepqj4m/92/
I modified the answer from this SO question: set div height using jquery (stretch div height)

A: Getting the wrapper just right
Link to fiddle
This is how i would solve it:
First remove this:
css
body,html{
    height:100%;
}

You don't want to limit your content to the size of the view port (html height 100%).
(this almost solves it)
Now it will work with most content except the small one since the entire wrapper will be to small.
for this we simply add:
#page {
    min-height: 50vh;
}

then it will keep taking up space even if its content is smaller :D

A: You can achieve this using flexbox.  Fiddle here
body,html{
height:100%;
}
.navbar {
  height:auto;
  flex-shrink:1;
}
#wrapper{
  border:2px solid red;
  min-height:100%;
  padding:2%;
  display:flex;
  flex-direction:column;
 }
 #page{
  border:2px solid blue;
  flex-grow: 5;
}
#footer{
  margin-top:20px;
  position:relative;
  border:2px solid green;
  flex-grow:2;
}


text:
Q: UIViewController: detecting when view appears again I have a UIViewController class that contains a WKWebView and implements WKNavigationDelegate.
I would like to detect when a the view controller appears again. I understand the method loadView but, if I push a new view on the stack and then go back from that view to the previous view (my view controller) which method is called on the view controller?

A: The method that will be called is viewWillAppear:.

A: If you push to next view then viewDidLoad will be called first
Then viewWillAppear, viewDidAppear
If you pop to previous screen again (your UIViewController) then
viewWillAppear will be called first and after entire view appears
then viewDidAppear will be called..
viewDidAppear is useful in the cases where any method called at viewWillAppear after that you can Load the data at ViewDidAppear..

A: The ViewControllers viewDidLoad method is only called once when the view is created for the first time.
// viewDidLoad is called only once when the view is created for the first time
 - (void) viewDidLoad
{
     [super viewDidLoad];
     // do your code here
}

You can also implement the below two methods in side your ViewController.m class
// viewWillAppear is called just before the view is about to be appeared
- (void) viewWillAppear
{
     [super viewWillAppear];
     // do your code here
}

// is called when the view has appeared
- (void) viewDidAppear
{
     [super viewDidAppear];
     // do your code here
}


text:
Q: How can I count the number of dates per ID for each month of a year? Task:
Calculate the frequency of each ID for each month of 2021

*

*Frequency formula: Count of dates within each month for each ID (e.g. ID: 44; Month: 01-2021; Frequency: 3)

Sample:
times = [
    '2021-02-18',
    '2021-03-02',
    '2021-03-02',
    '2021-04-23',
    '2021-01-18',
    '2021-01-19',
    '2021-01-20',
    '2021-01-03',
    '2021-02-04',
    '2021-02-04'
]

id = [1, 1, 1, 1, 44, 44, 44, 46, 46, 46]

df = pd.DataFrame({'ID':id, 'Date': pd.to_datetime(times)})

df = df.reset_index(drop=True)

print(df)

   ID       Date
0   1 2021-02-18
1   1 2021-03-02
2   1 2021-03-02
3   1 2021-04-23
4  44 2021-01-18
5  44 2021-01-19
6  44 2021-01-20
7  46 2021-01-03
8  46 2021-02-04
9  46 2021-02-04

Desired Output:
   id  01_2021  02_2021  03_2021  04_2021
0   1        0        1        2        1
1  44        3        0        0        0
2  46        1        2        0        0

A: Use crosstab with convert datetimes to strings in format MM-YYYY:
df = pd.crosstab(df['ID'], df['Date'].dt.strftime('%m_%Y')).reset_index().rename_axis(None, axis=1)
print(df)
   ID  01_2021  02_2021  03_2021  04_2021
0   1        0        1        2        1
1  44        3        0        0        0
2  46        1        2        0        0

With month periods solution is similar, use Series.dt.to_period:
df = pd.crosstab(df['ID'], df['Date'].dt.to_period('m')).reset_index().rename_axis(None, axis=1)
print(df)
   ID  2021-01  2021-02  2021-03  2021-04
0   1        0        1        2        1
1  44        3        0        0        0
2  46        1        2        0        0

EDIT: For half of month is used SMS Dateoffset in resample:
f = lambda x: x.strftime('first_half-%m-%Y')
              if x.day == 1
              else x.strftime('second_half-%m-%Y')
df = (df.set_index('Date')
        .groupby('ID')
        .resample('SMS')
        .size()
        .unstack(fill_value=0)
        .sort_index(axis=1)
        .rename(columns=f)
        .reset_index()
        .rename_axis(None, axis=1))

print (df)
   ID  first_half-01-2021  second_half-01-2021  first_half-02-2021  \
0   1                   0                    0                   0
1  44                   0                    3                   0
2  46                   1                    0                   2

   second_half-02-2021  first_half-03-2021  second_half-03-2021  \
0                    1                   2                    0
1                    0                   0                    0
2                    0                   0                    0

   first_half-04-2021  second_half-04-2021
0                   0                    1
1                   0                    0
2                   0                    0


text:
Q: Similar product price comparison result as per various retailer from product table I am using these query. Table name are  wp_pc_products_merchants and wp_pc_products. The name user is inserting in search box. We have split that in array and we have taken in variables as per the position in query.
select image,feed_product_name,feed_product_desc,feed_product_image,price,deeplink,id_merchant from wp_pc_products_merchants m,wp_pc_products p
where m.slug = p.id_merchant and
feed_product_name LIKE '%$expname[0]%' and
feed_product_name LIKE '%$expname[1]%' and
feed_product_name LIKE '%$expname[2]%' and
feed_product_name LIKE '%$expname[3]%' and
feed_product_name LIKE '%$expname[4]%' Limit 5 ")
or die(mysql_error());

I am using php and mysql.
It's giving me multiple results from the same retailer and I can say it's giving me similar results.
I need help to display similar products with their respected result once.
Thanks

A: select image,feed_product_name,feed_product_desc,feed_product_image,price,deeplink,id_merchant from wp_pc_products_merchants m,wp_pc_products p
where m.slug = p.id_merchant and
feed_product_name LIKE '%$expname[0]%' or
feed_product_name LIKE '%$expname[1]%' or
feed_product_name LIKE '%$expname[2]%' or
feed_product_name LIKE '%$expname[3]%' or
feed_product_name LIKE '%$expname[4]%' Limit 5 ")
or die(mysql_error());