text:
Q: Select one radio button in each accordian tab using jquery I just want to select one radio button in each tab. But when I select one radio button in one tab and then when i move in another tab and checked another radio button then the previous selected radio button was automatically removed though i am calling each tab with different id.
Please see the code:
<form id="myForm">

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/collar/point.png'; ?>"  alt="sample" />

                <input type="radio" name="collar" id='point' value="Point" >

                 Point

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/collar/semi-sepread.png'; ?>" alt="sample" />
                <input type="radio" name="collar" id='semi-spread' value="SEMI SPREAD" >

                 SEMI SPREAD

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/collar/spread.png'; ?>"  alt="sample" />

                <input type="radio" name="collar" id='spread' value="SPREAD" >

                 SPREAD

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/collar/button-down.png'; ?>" alt="sample" />
                <input type="radio" name="collar" id='button-down' value="BUTTON DOWN" >

                BUTTON DOWN

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/collar/pinned.png'; ?>" alt="sample" />

                <input type="radio" name="collar" id='pinned' value="PINNED" >

                 PINNED

                <input type="button" class="button custom-s" name="next" value="next">

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/cuff/round.png'; ?>"  alt="sample" />
                <input type="radio" name="cuff" id='round' value="Round" >

                  ROUND

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/cuff/angled.png'; ?>" alt="sample" />
                <input type="radio" name="cuff" id='angled' value="ANGLED" >

                 ANGLED

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/cuff/two-button-angeld.png'; ?>" alt="sample" />
                <input type="radio" name="cuff" id='t-button' value="TWO BUTTON ANGLED" >

                 TWO BUTTON ANGLED

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/cuff/french-cuff.png'; ?>"  alt="sample" />
                <input type="radio" name="cuff" id='french-c' value="FRENCH CUFFS BARREL" >

                 FRENCH CUFFS BARREL

                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK). 'media/measurement_images/cuff/french-angeld.png'; ?>"  alt="sample" />
                <input type="radio" name="cuff" id='french-a' value="FRENCH CUFFS ANGLED" >

                 FRENCH CUFFS ANGLED

                <input type="button" class="button btn-cart" name="next" value="next">

</form>

Please see the code and tell me why it is selected only one radio button
Thanks

A: Radio buttons with the same name form a group from which one can only select one option at a time. What you possibly need is to convert those radio buttons into checkboxes and you will be able to select several of them.
You should put brackets after the name of the checkbox, like this:'collar[]', so the values selected will be set to the post values as an array with only the values of the selected ones.
<input type="checkbox" name="collar[]" value="SEMI SPREAD">
<input type="checkbox" name="collar[]" value="SPREAD">
<input type="checkbox" name="collar[]" value="BUTTON DOWN">
<input type="checkbox" name="collar[]" value="PINNED">

Then if you select the SPREAD and PINNED the post variable will looke like this:
array(...) {
  ["collar"]=>
   array(3) {
    [0]=>
      string(6) "SPREAD"
    [1]=>
      string(6) "PINNED"
  }
  ...
}


text:
Q: Given three non-collinear points then those three points are distinct (Incidence geometry) If $A, B,$ and $C$ are non-collinear points, then $A$ and $B$ are distinct, and $C$ does not lie on the line $\overleftrightarrow{AB}$.

The axioms are the following:

*

*Incidence Axiom 1: There exist at least three distinct noncollinear
points.

*Incidence Axiom 2: Given any two distinct points, there is at least
one line that contains both of them.

*Incidence Axiom 3: Given any two distinct points, there is at most
one line that contains both of them.

*Incidence Axiom 4: Given any line, there are at least two distinct
points that lie on it.

Proof:
I attempted to prove this by the contrapositive by assuming that $A$ and $B$ are equal points and arriving at a contradiction.
Suppose $A, B,$ and $C$ are non-collinear points and that $A=B$ then there is a line, $l$, that contains them. From Incidence Axiom 4, we know given any line $l$ there are at least two distinct points that lie on it, let this distinct point be $D$ therefore $\overleftrightarrow{AD}$ (or similarly $\overleftrightarrow{BD}$ since $A=B$) is a line with two distinct points. Now since $C$ is collinear from $A$, we have that $C \notin \overleftrightarrow{AD}$ therefore $C$ is distinct from $A$ and $B$, however, since $A=B$ and $C$ are two distinct points we have from Incidence Axiom 3 that there is at most one line that contains both of them, however, this a contradiction since $C$ is collinear from $A$ therefore the assumption that $A=B$ is false.

Is my proof correct?
How can I expand on this theroem to prove that, $A$ does not lie on $\overleftrightarrow{BC}$, $B$ does not lie on $\overleftrightarrow{AC}$ and $C$ does not lie on $\overleftrightarrow{AB}$?

A: I think you can conclude more quickly: if $A=B\ne C$ there is a line $l$ passing through $A$ and $C$ (Axiom 3), whence contradiction.
Once you know $A\ne B$, if $C\in \overleftrightarrow{AB}$ we get a contradiction, hence $C\not\in \overleftrightarrow{AB}$.

redpajama_set_name: RedPajamaStackExchange


text:
Q: VB Script to C# - Extract .arch file I have to extract .arch type files. In an old VB script, it is done using wscript.shell commands.
Set shellobj = wscript.createobject ("wscript.shell")
cmdline = "wzunzip -d -n " & source & " " & destination & "\"
cmdexec = shellobj.run((cmdline), 1, true)

I am converting this to c# so I used the following code to extract files:
ZipFile.ExtractToDirectory(source, destination);//Unzip file

But this line is throwing an exception for .arch type files.

"An attempt was made to move the file pointer before the beginning of the file."

Is there a way I can extract .arch type files in C#. My file is of this specific type.

A: Have you read the MS Docs?
https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.extracttodirectory?view=netframework-4.8#System_IO_Compression_ZipFile_ExtractToDirectory_System_String_System_String_System_Text_Encoding_
Under IO Exception:

The directory specified by destinationDirectoryName
  already exists.
-or-
The name of an entry in the archive is Empty, contains only white
  space, or contains at least one invalid character.
-or-
Extracting an archive entry would create a file that is outside the
  directory specified by destinationDirectoryName. (For example, this
  might happen if the entry name contains parent directory accessors.)
-or-
An archive entry to extract has the same name as an entry that has
  already been extracted from the same archive.

So basically,

*

*Does your directory already exist? If so it shouldn't.

*Are any of the file name's empty? If so, they shouldn't be, they require names.

*Does the destination file path have any file path characters (for
example, '..')? If so, they shouldn't.

*Do any of the files have the same name? If so they shouldn't.

It doesn't actually look like any of those issues weirdly, and it's rare Microsoft miss something. The only other thing I see in the docs is that there is an overload for an encoding type, but this is for the encoding of the zip file rather than the files inside it...
It looks like the file is corrupt. This question seems to highlight your issue:
https://superuser.com/questions/457271/identifiying-a-zip-file-that-is-not-really-a-zip-file
Maybe when the .ARCH files are compressed, the file signature is lost? Or the file is corrupted somehow?


text:
Q: (iphone) pushViewController in background thread? IPhone SDK - Leaking Memory with performSelectorInBackground
seems to suggest you can actually pushViewController in background thread.
But I get a warning from stackoverflow people that I shouldn't do this.
eg. (iphone) start timer from background thread?
is pushViewController considered "UI updating"?
(because I know that UI updating should be done in main thread only)
If it is so,
when a viewController takes a while to load, and want to show an indicator while loading.
What is my option?

A: Couple of strategies here.
1) BEFORE you do the push, but at the point you know you are going to do it, bring up a suitable activity view on the current view. I do this in some apps where you click on a row in a table but the pushed view has to do some web comms that takes time, so I leave the table cell highlighted in blue and add a white spinner to the left of the disclosure indicator. Works well.
2) Use lazy loading to get the new view controller on screen quickly, but defer the heavy code until after it has loaded so that the new controller can look after it's own activity view. By lazy loading I mean you should do as little as possible in the init method and make careful use of viewdidload / viewwillappear / viewdidappear etc to spread the work out and get an activity view on screen as soon as you can.


text:
Q: Autofac. How to inject a open Generic Delegate in constructor I am trying to inject a delegate with open generic through constructor like this
protected AQuery(Func<string, IQuery<T>> getQuery)
{
    query = getQuery("contextName");
}

And Register something like
builder
   .Register<Func<string, IQuery<T>>>(
       c => ctx =>
       new Query(c.ResolveNamed<IDbContext>(ctx)));

I could not find any API help documentation for something like this.
I was able to use similar registration where generics are not involved.

A: What you're trying to achieve seems a very functional approach that works great in functional languages like F#, but most DI containers for .NET are built for object oriented languages and they are inherently type oriented, not delegate or function oriented. What you are trying to do, can't be done easily with Autofac, or any other DI container for that matter.
And even if Autofac was able to map generic methods to Func delegates, you still needed a fair amount of reflection to register this. For instance this hypothetical RegisterGenericFunc method:
builder.RegisterGenericFunc(
    typeof(Func<,>).MakeGenericType(typeof(string), typeof(IQuery<>)),
    typeof(Bootstrapper).GetMethod("QueryFuncFactory"));

public static Func<string, IQuery<T>> QueryFuncFactory<T>(IComponentContext c) {
    return ctx => new Query(c.ResolveNamed<IDbContext>(ctx)));
}

For this to work though, Autofac must not only be able to work with delegates, but also be able to understand partial open-generic types (your Func<string, IQuery<T>> is partial open-generic).
So instead of doing this, you might want to fall back to a more object oriented approach and define a clear interface that describes your abstraction:
public interface IQueryFactory<T> {
     IQuery<T> CreateQuery(string context);
}

And your implementation could look like this:
public class AutofacQueryFactory<T> : IQueryFactory<T> {
     private readonly IComponentContext c;

     public AutofacQueryFactory(IComponentContext c) {
         this.c= c;
     }

     public IQuery<T> CreateQuery(string context) {
         return new Query<T>(c.ResolveNamed<IDbContext>(context));
     }
}

This interface-implementation pair can be registered as follows:
build.RegisterGeneric(typeof(AutofacQueryFactory<>)).As(typeof(IQueryFactory<>);

And your consumers can depend on IQueryFactory<T>:
protected AQuery(IQueryFactory<T> getQuery)
{
    query = getQuery.CreateQuery("contextName");
}


text:
Q: Time Series Model (SARIMA) Consistently Underpredicting I have a SARIMA model of order (0,1,1)(0,1,1)52 on a log transformed variable (originally non-negative count data, y = log(x+1), '+1' as zero is possible for x).
The series plot along with prediction (figure 1):

Residuals plots against the training data (figure 2):

Errors against the validation set (figure 3):

As is evident from figures 1 and 3, the model is consistently predicting a lower value than that which actually occurs. How can I improve my model to mitigate this?
I'm using the statsmodels package for Python. Model generated by the following code:
sarima_mod = sm.tsa.statespace.SARIMAX(train, order=(0,1,1), trend = 'n', seasonal_order =(0,1,1,52))
sarima_fit = sarima_mod.fit(disp=False, outer_iter=400)

A: You should search for the best params using pmdarima or you can just grid search with statsmodels and minimize AIC or whatever cost you deem appropriate.
Assuming you did that already and that's how you got those orders or just in general it is entirely possible that your validation data is just different. Perhaps there is a level change which causes the issue and there is NO way a model would be able to perceive this.  Or there may be an exogenous factor that you can account for. Either way, if you just adjust your current parameters to something that is a less 'likely' given your training data but doesn't underforecast then you are just overfitting the validation set by using future knowledge. You could mitigate this by using time series cross validation with a rolling train/validation set but in my 'experience' your best bet is to use AIC/AICc for params in ARIMA models since I have seen arima models go crazy from overfitting on a simple holdout set.
Another possible issue is that you wanted to produce n number of one-step-ahead forecasts but you accidentally produced a n-step forecast. That would put it on the right level overall. Statsmodels api is confusing.


text:
Q: Returning an element from a TreeSet using binary search In TreeSet there is a method called contains that returns true if an element is in the set. I assume that this method uses binary search and does not iterate through all the elements in ascending order. Am I right?
I have a TreeSet that contains objects of a class that uses two String instance variables to distinguish it from other objects of the same class. I want to be able to create a method that searches the TreeSet by comparing the objects two instance variables (using get methods of course) with two other String variables and if they are equal, return the element. If the instance variables are less than go to the first element in the right subtree or if they are greater search in the left subtree etc. Is there a way to do this?
I know I could just store the objects in an ArrayList and use binary search to find the object, but this wouldn't be as fast as just searching the TreeSet.

A: Rather than using a TreeSet, you could store your objects in a TreeMap<Foo, Foo> or TreeMap<FooKey, Foo> (if you can't easily create a new actual Foo each time you want to search). Sets are not really intended for lookup.
For the FooKey example, FooKey would be a simple immutable class that just contains the two Strings and is Comparable. Finding the value of Foo for two Strings would then be a simple matter of treeMap.get(new FooKey(firstString, secondString)). This does of course use the tree traversal you want to find the value.

A: You should either implement Comparable on your object or create a separate Comparator class that you pass in at the time TreeSet is constructed. This allows you to interject your custom entry comparison logic and let the TreeSet do its optimized store/search thing.

A: set.tailSet(obj).first();

does what you want.

A: One thing I was wondering is why you want to search into a sorted set?  If you want to be able to iterate in order as well as lookup quickly you may benefit from storing your objects in two separate data structures.  One like your SortedSet<Foo> and then also a HashMap<FooKey,Foo> similar to what ColinD mentioned.  Then you get constant time lookups instead of log(n) on the TreeMap.  You have a write penalty of having to write to both structures, and a memory resource penalty of having the two data structures, but you have fully optimized your access to the data.
Also if memory resources are constrained, and your strings are really what differentiate the objects, then you can just implement hashcode() and equals() on your object Foo and then just use them as both the key and value (like HashMap<Foo,Foo>. The caveat there is that you have to construct a Foo to call the getter.

A: You got the answer about using comparable/comparator, but I thought I would add that you are right that contains() does a binary search, though you shouldn't need to know those details


text:
Q: creating dynamic HTML. Automatically write HTML to a web page when an action is done I'm creating a web app for a company that sells mp3 sound clips. I have implemented a register, login, payment and admin functions. Within the admin page I have allowed the privileged user to add an mp3 which the name will be added to a mysql database table, the actual file uploaded to an FTP server and the part I'm having problems with is displaying the newly uploaded sound clip to the corresponding page on the site. So basically every time the 'upload' button is pressed then I need a block of HTML code to be written to one of the pages on the site.
I would appreciate any guidance on where to start. I've been reading up on DOM but I don't think it's the right way to go about it.
Thanks in advance

A: You shouldn't try to append a content to the HTML file. What will you do when your user removes the MP3 ? Remove the HTML content ? Heavy process ^^
Where you basically use your HTML file, use a PHP script which reads entries from your database. Something like...
$db = new PDO(/* database settings */);
$query = $db->query("SELECT * FROM musics");
while($result = $query->fetch(PDO::FETCH_OBJ))
{
    echo $result->song_name . " by " . $result->artist;
}

This will list your songs and give that kind of output :
My Little Song by Soroush Shamsfard.
My Favourite Song by Soroush Shamsfard.

Some information about reading data from a database :
http://www.electrictoolbox.com/php-pdo-bound-placeholders/


text:
Q: How does pictonic work? Can anyone explain to me how https://pictonic.co/ works? I'm interested in creating my own imageless icons, but I'm not sure what the best strategy is to attack this, and knowing what techniques they use seems like a good starting point. Can anyone tell from their demo?

A: I'm the lead developer at pictonic.
Our designer recently wrote an article describing the techniques he used to design the icons, this might go some way towards answering your question:
http://blog.pictonic.co/post/31265656514/designing-icons-for-use-in-icon-fonts
The output of this is a bunch of svgs. We have our own techniques for processing these, but essentially, i would point you towards the www.w3.org specification for svg fonts:
http://www.w3.org/TR/SVG/fonts.html
good luck! : >


text:
Q: Create abstract figures in HTML/CSS At the moment I am building a simple personal website to show some of the stuff I am doing.
You can see a little Image I made myself in Photoshop to work up to here:
https://ibb.co/61VxFnD (mobile), https://ibb.co/122nPmv (desktop)
For the content boxes I plan to use CSS grid. But you might have noticed that in the background I wanted to add this slight curvy figure. I think it just looks very nice.
It doesnt have to be exactly this figure right there. Just some sort of colored curve does the job for me.
I know that I could just use an image from this curve as an background but using such big images may cause the website to load slower.
Is there any way to maybe create an Figure and put an solid color on it? I hope like this I can keep my Website lightweight.

A: I would recomend you to use svg: it will scale without any loss of quality. Check this out:

<div style="height: 150px; overflow: hidden; background: lightgray">
  <svg viewBox="0 0 500 150" preserveAspectRatio="none" style="height: 100%; width: 100%;">
    <path d="M0.00,49.98 C216.98,182.06 349.20,-49.98 500.00,49.98 L500.00,150.00 L0.00,150.00 Z"
          style="stroke: none; fill: gray;">
    </path>
  </svg>
</div>

By the way, this guy has created a nice svg wave generator

A: use .png for the gray wave at the bottom. it doesn't matter how big images are if you are using simple shapes like this one. PNG handles these shapes very well and the file size is very small. try exporting from Photoshop in different ways to see what works best. after you export go to https://tinypng.com/ and drop the image to get the best result possible.


text:
Q: Extracting data from tags in XML resultset I need to fetch data for 2 tags "estimated" and "fullSign" for all the occurences on this result set.
RESULT SET:

<?xml version="1.0" encoding="UTF-8"?>
<resultSet xmlns="urn:trimet:arrivals" queryTime="1469138325745"><location desc="Morrison/SW 3rd Ave MAX Station" dir="Westbound" lat="45.5181811277907" lng="-122.675385866199" locid="8381" /><arrival block="9007" departed="true" dir="1" status="estimated" estimated="1469138452000" fullSign="MAX  Blue Line to Hillsboro" piece="1" route="100" scheduled="1469138250000" shortSign="Blue to Hillsboro" locid="8381" detour="false"><blockPosition feet="1901" at="1469138300978" heading="201" lat="45.5214364" lng="-122.6716177"><trip desc="Hatfield Government Center" dir="1" route="100" tripNum="6557314" destDist="77046" pattern="54" progress="75145" /></blockPosition></arrival><arrival block="9050" departed="true" dir="1" status="estimated" estimated="1469138664000" fullSign="MAX  Red Line to City Center & Beaverton" piece="1" route="90" scheduled="1469138670000" shortSign="Red Line to Beaverton" locid="8381" detour="false"><blockPosition feet="4552" at="1469138313683" heading="237" lat="45.5277621" lng="-122.6687878"><trip desc="Beaverton TC Pocket" dir="1" route="90" tripNum="6556307" destDist="66321" pattern="15" progress="61769" /></blockPosition></arrival><arrival block="9018" departed="true" dir="1" status="estimated" estimated="1469139140000" fullSign="MAX  Blue Line to Hillsboro" piece="1" route="100" scheduled="1469139150000" shortSign="Blue to Hillsboro" locid="8381" detour="false"><blockPosition feet="13687" at="1469138320005" heading="239" lat="45.5309688" lng="-122.6350333"><trip desc="Hatfield Government Center" dir="1" route="100" tripNum="6557315" destDist="77046" pattern="54" progress="63359" /></blockPosition></arrival><arrival block="9043" departed="true" dir="1" status="estimated" estimated="1469139577000" fullSign="MAX  Red Line to City Center & Beaverton" piece="1" route="90" scheduled="1469139570000" shortSign="Red Line to Beaverton" locid="8381" detour="false"><blockPosition feet="31909" at="1469138310486" heading="285" lat="45.5320383" lng="-122.5738342"><trip desc="Beaverton TC Pocket" dir="1" route="90" tripNum="6556308" destDist="66321" pattern="15" progress="34412" /></blockPosition></arrival></resultSet>

expected result:
1469138452000 MAX  Blue Line to Hillsboro
1469138664000 MAX  Red Line    to City Center & Beaverton
1469139140000 MAX  Blue Line  to    Hillsboro
1469139577000 MAX  Red Line to City Center &Beaverton

What is a good way for me to extract this data?

A: This is using XMLstarlet with paste.  It can probably be made in a single call to XMLstarlet, but I'm no wizard:
$ paste <(xml sel -T -t -v '//@estimated' data.xml) \
        <(xml sel -T -t -v '//@fullSign' data.xml)
1469138452000   MAX Blue Line to Hillsboro
1469138664000   MAX Red Line to City Center & Beaverton
1469139140000   MAX Blue Line to Hillsboro
1469139577000   MAX Red Line to City Center & Beaverton

A: $ xml2 < sunnx.xml | awk -F= '
   $1 ~ /@fullSign/  { fs=$2 ; sub(/&/,"&",fs) };
   $1 ~ /@estimated/ { est=$2 };
   fs && est         { printf "%s %s\n", est, fs; fs=est="" }'

1469138452000 MAX  Blue Line to Hillsboro
1469138664000 MAX  Red Line to City Center & Beaverton
1469139140000 MAX  Blue Line to Hillsboro
1469139577000 MAX  Red Line to City Center & Beaverton

If you want a literal & rather than &, then get rid of the sub() function call.  xml2 decodes the encoded entities for you, so I added the sub() to change it back to conform to your requested output.
Without the sub(), the output looks like this:
1469138452000 MAX  Blue Line to Hillsboro
1469138664000 MAX  Red Line to City Center & Beaverton
1469139140000 MAX  Blue Line to Hillsboro
1469139577000 MAX  Red Line to City Center & Beaverton


text:
Q: Adding attributes to the xml elements made from the  Here is my class  code:
//class CenyKategorie

public class CenyKategorie
{
    string nazwa { get; set; }
    double cena { get; set; }

    public CenyKategorie()
    {

    }

public CenyKategorie(string Nazwa, double Cena)
    {
        nazwa = Nazwa;
        cena = Cena;
    }
}

And here is code of the method:
private void SomeMethod()
{
List<CenyKategorie> cenykat = new List<CenyKategorie>
                {
                    new CenyKategorie("Kat A", 12),
                    new CenyKategorie("Kat B", 15)
                    };
                using (FileStream fs = new FileStream(@"C:\Program Files\file.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    XmlSerializer xs = new XmlSerializer(typeof(List<CenyKategorie>));
                    xs.Serialize(fs, cenykat);
                }
}

The .xml output is following:
<?xml version="1.0"?>
<ArrayOfCenyKategorie xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <CenyKategorie>
    <nazwa>Kat A</nazwa>
    <cena>12</cena>
  </CenyKategorie>
  <CenyKategorie>
    <nazwa>Kat B</nazwa>
    <cena>15</cena>
  </CenyKategorie>
</ArrayOfCenyKategorie>

Now I want to add an attribute to the  element to make it look like this:
<nazwa="example1">Kat A</nazwa>

But I don't know how to do it via list, can I count on your help?


text:
Q: Template to get map element with default value The problem:
I'm trying to make a function getmap that gets a map<string, string> element, but if none exists return a specified default value (i.e. getmap(mymap, "keyA", mydefault);.
I templated it for int, float and char* return types but I get an error:
error C2664: 'getmap' : cannot convert parameter 3 from 'const char *' to 'char *const '

even though I'm not using char *const. Why is this happening?
The code:
template <typename T> inline
T getmap(const std::map<std::string, std::string> &m, const char* key, const T def, T (*f)(const char*) = NULL) {
    std::map<std::string, std::string>::const_iterator i = m.find(std::string(key));
    return i == m.end() ? def : (f == NULL ? i->second.c_str() : f(i->second.c_str()));
}

inline int getmap(const std::map<std::string, std::string> &m, const char* key, const int def) {
    return getmap<int>(m, key, def, &std::atoi);
}

float atofl(const char* s) {
    return (float)std::atof(s);
}

inline float getmap(const std::map<std::string, std::string> &m, const char* key, const float def) {
    return getmap<float>(m, key, def, &atofl);
}

inline char* getmap(const std::map<std::string, std::string> &m, const char* key, const char* def) {
    return getmap<char*>(m, key, def);  // ERROR HERE
}

A: getmap<char*>(m, key, def);
makes the T of getmap a char*. The 3rd argument you accept is a const T. I know that looks like that should make it a const char* but that actually makes it a char* const.
You are then trying to pass a const char* to a char* const, as the error says. You can pass a non-const to a const, but not the other way around.
So write this instead...
getmap<const char*>(m, key, def);
       ^^^^^


text:
Q: How to structure an application without bundles in Laravel 4 Currently with Laravel 3 bundles, i have structured my application. For example, In a  hospital management system i would created each bundles for

*

*Channeling

*OPD

*Wards
etc.
But with Laravel 4, Bundles overridden by Packages. But after looking at  packagist, i think these kind of separation  is not suitable. So what will be the proper method for this?
Will it be the folder separation in application\controllers like,
application\controllers\
|--------Channeling\
|--------OPD\
|--------Wards\
and in models,
application/models/
|--------Channeling/
       |----------------Services/

       |----------------Some_Model_01

       |----------------Some_Model_02

|--------OPD/
       |----------------Services/

       |----------------Some_Model_03

       |----------------Some_Model_04

|--------Wards/
       |----------------Services/

       |----------------Some_Model_05

       |----------------Some_Model_06

A: The sample structure you provided should work.
If the directories are defined in composer.json these files (including the files in sub-directories) will get loaded automatically
        "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
        ]


text:
Q: JavaScript mouseenter and mouseleave fade effects glitchy I have made an example in JS fiddle if you hover over "Wall" for example then move your cursor over the dropdown menu which fades in below. Before you can use it, it will fadeOut then fadeIn.
I have tried using a timeout and checking if it is the same hover parent. That didn't work as when you come off it completely it would stay on.
https://jsfiddle.net/eqxDev/t49e7amz/
$(document).ready(function () {

$('.places .place-link, .place_dropdown').one().on('mouseenter', function () {
    $("#place_link_" + $(this).data('placement')).addClass('hovered');
    $("#place_dropdown_" + $(this).data('placement')).addClass('hovered');
    $("#place_dropdown_" + $(this).data('placement')).fadeIn(350);
});

$('.places .place-link, .place_dropdown').one().on('mouseleave', function () {
    $("#place_link_" + $(this).data('placement')).removeClass('hovered');
    $("#place_dropdown_" + $(this).data('placement')).removeClass('hovered');
    $("#place_dropdown_" + $(this).data('placement')).fadeOut(350);
});

});
When hovering over the item Wall it shouldn't fadeIn then Out when you try to hover over the list of items below.
Thanks in advance.

A: The problem is because a mouseleave/mouseenter is triggered when moving from the tab to the menu underneath. To fix this, add a stop() call before fading to move the animation queue to the end before adding the new animation:

$(document).ready(function() {
  $('.places .place-link, .place_dropdown').on('mouseenter', function() {
    var placement = $(this).data('placement');
    $("#place_link_" + placement).addClass('hovered');
    $("#place_dropdown_" + placement).addClass('hovered').stop(true).fadeIn(350);
  });

  $('.places .place-link, .place_dropdown').on('mouseleave', function() {
    var placement = $(this).data('placement');
    $("#place_link_" + placement).removeClass('hovered');
    $("#place_dropdown_" + placement).removeClass('hovered').stop(true).fadeOut(350);
  });
});
body {
  background: #fff;
  padding: 20px;
  font-family: Helvetica;
}

.places li {
  display: inline-block;
  margin-right: 100px
}

.place_dropdown {
  border: 1px solid black;
  margin-top: -15px
}

    Wall

    Floor

  Wall

Test Page

Test Page

Test Page

Test Page

Test Page

Test Page

Test Page

Test Page

  Floor

Test Page

Test Page

Test Page

Test Page

Test Page

Test Page

Test Page

Test Page

With all that said, it's worth nothing that with a minor structural change to the HTML you could make this menu entirely in CSS.


text:
Q: Add reference to .dll located on shared drive When referencing NET dynamic link library which is located on shared drive with Python.NET exception FileNotFoundException is raised. Sample code:
import sys
import clr

sys.path.append(PATH_TO_SHARED_NETWORK_DRIVE)
clr.AddReference('MY_DLL')

After some googling I found that real problem is that .NET Framework does not enable CAS policy by default. So to reference dll on shared drive the loadFromRemoteSources switch needs to be enabled. Sample code:
from clr import System
from System import Reflection

Reflection.Assembly.LoadFrom(FULL_PATH_TO_MY_DLL.dll)

Exception:

System.NotSupportedException: An attempt was made to load an assembly
from a network location which would have caused the assembly to be
sandboxed in previous versions of the .NET Framework. This release of
the .NET Framework does not enable CAS policy by default, so this load
may be dangerous. If this load is not intended to sandbox the
assembly, please enable the loadFromRemoteSources switch. See
http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

The problem is that I can't figure out how to enable loadFromRemoteSources switch from Python.

A: Apparently the only way to set this setting is via app.config with the contents like in that link you provided:
<configuration>
   <runtime>
      <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>

First, try to create a python.exe.config file with the above contents in the same folder as python.exe. If that still doesn't help, the usefulness of python.net kinda diminishes, because then you'd have to create an actual .NET library and have it locally that would reference that remote dll and proxy your calls from there. I think this should work, but I haven't tried it.
And are you sure you really need to reference the dll's on the remote host? Maybe you'll be better off redefining the problem?


text:
Q: Multiple instances in loop How can I create an instance for each object in a list?
I am using a loop to store the values of this object but when I access these objects they are all the same, I want them to be different.
In this case, I have two challenges in "registeredChallenges" and I want the int progress and boolean completed to be different when I change them, how I can do that
Ex:
Challenge1: Progress 1 and Completed false - Challenge2: Progress 5 and Completed true
Thank you!
List<Challenge> registeredChallenges = plugin.getChallengeRegistry().getRegisteredChallenges(ChallengeType.COLLECT);
for (Challenge challenge : registeredChallenges) {
    ChallengeHolder challengeHolder = new ChallengeHolder(challenge, 0, false);
    if (!challengeHolder.isCompleted()) {
        int challengeCondition = challenge.getChallengeCondition();
        if (challengeHolder.getProgress() < challengeCondition) {
            challengeHolder.setProgress(challengeHolder.getProgress() + 1);
        }
        int challengeRemaining = plugin.getDatabaseManager().getChallengeRemaining(playerUUID, challenge);
        if (challengeHolder.getProgress() >= challengeCondition) {
            challengeHolder.setCompleted(true);
        }
    }
}


text:
Q: Can we get induction without a transformer core? We usually see induction produced by two coils wound around a transformer core:
[]
Can you please specify if there is induction if we eliminate the core? Do we have to arrange the coils one inside the other? If the core can  increase induction, to what extent can we increase it?
What happens if, in the above transformer, we connect an appliance to both windings, do they both get half power or only the appliance connected to the second winding will work?
Also, can we get induction with straight wires?

A: To answer the questions

*

*Yes, there is still induction even if you remove the core of the transformer.

*No, you do not need to arrange the coils one inside the other, although this will increase the amount of current you induce (given that the two windings are electrically isolated from one another)

*We can increase the induction as determined by a parameter of the core known as the magnetic permeability $\mu$. This will depend on the type of metal you use as your core, and is quite large for iron.

*Connecting the transformer to multiple appliance from either winding will not do anything. In this case, there is no circuit. The intended use of a transformer is to take high voltage AC on the primary and induce current into the secondary winding, usually for the purpose of stepping down the voltage to something reasonable for consumer use.

*Can you get induction with straight wires? This is an interesting question, and the answer is yes. It is most evident with the differential form of Faraday's law: the presence of  a changing magnetic field will produce a curling electric field in the vicinity of the wire, inducing a current.

The primary coil generates an oscillating magnetic field which couples to the secondary coil. In fact, in an ideal world this oscillating EM field will propagate through all of space at the speed of light, and will couple to any coil that is any distance away. However, the effects of this field will be negligible as you move too far away, and in the case of an everyday transformer, it is necessary to incorporate the iron core to facilitate proper inductive coupling between the primary and secondary windings.
You can think about why this is the case with the integral form of Faraday's law of Induction, $$\mathscr{E_{2,1}} = - \frac{d\Phi_{2,1}}{dt}.$$
Suppose the secondary is a loop of wire that encloses a total area A, and that the magnetic field generated by loop 1 passing through loop 2 is $B(t)$ at time $t$ and $B(t+\Delta t)$ at time $t+\Delta t$.
What our good friend Faraday says is that in a short time $\Delta t$, the voltage induced in the 2nd winding is proportional to $A\frac{B(t+\Delta t)- B(t)}{\Delta t}$. It is intuitive then, that the strength of the magnetic flux passing through the loop is important, as having higher peak flux implies that the change in flux will be greater as well.
The amount of current you will induce into the secondary winding will be significantly greater with the iron core, as the iron core traps the magnetic flux generated by the primary into a region of space that passes through the secondary. This is why it is so important to have the iron core in a transformer.

A: The core of a transformer is normally made out of some sort of steel, which is the cheapest material, with a high magnetic permeability.
If the core is removed, there will still be induction, although its flux is not guided through the air as it would do in the transformer and the field strength is much lower. The secondary side will not feel any voltage nor current.
Although if the wires on the primary and secondary side are of the same length, only electromagnetic radiation will be picked up, which is very minimal.


text:
Q: Protractor failed after unsuccessful attempt? I have two test (without angular). First is that test should fail because of wrong credentials. Second test should pass because of right credentials, but protractor won't even fulfill email email form, he just skip it. Any ideas why is this happening?
Also, if I run test separately it works fine.

    describe('When clicking on login with bad credentials', function() {
    it('Should login to dashboard', function() {
      browser.driver.findElement(by.id('email')).sendKeys('wrong@example.com');
      browser.driver.findElement(by.id('password')).sendKeys('pass');
      element(by.id('login')).click().then(function() {
        expect(element(by.id('main-logo')).isPresent()).toBe(false);
      });
    });
  });

  describe('When clicking on login with good credentials', function() {
    it('Should login to dashboard', function() {
    browser.driver.findElement(by.id('email')).sendKeys('right@exmaple.com');
      browser.driver.findElement(by.id('password')).sendKeys('pass@@@');
      element(by.id('login')).click().then(function() {
        expect(element(by.id('main-logo')).isPresent()).toBe(true);
      });
    });
  });

A: I would first assure that the element are visible, because it makes sense doing that first before sending input data. Also you can use elementor npm library to try catch what is going wrong with your test case.

A: Do you mention browser restarting option "restartBrowserBetweenTests: true" on your conf.js file? If not, try it once.
Hope it will resolve your issue

A: If you are on a non-anguar page, and using browser.ignoreSynchronization=false, you will have to perform some kind of wait or ExpectedConditions after you click the login button for this test to ever give consistent results. It may be checking for the logo immediately after clicking, without waiting for the next page to load.
You might trying sending a .clear() to the input element before .sendKeys(), and make sure your test is correct (typo in right@example.com)


text:
Q: Deploy gatsby on nginx has wrong redirect address when refresh and brings out port number? I have a website, and deploy the site on nginx in docker container. The problem is when I refresh the site the chrome address bar brings out the port number and redirects wrong.
I am a front-end programmer and don't have any server permission, so i can try nothing on the back end. On the server side I have already tried editing nginx config file but without success.
This is the website address:
www.haetek.com/case

If you refresh the page it brings out port number 8181.
www.haetek.com:8181/case

I expect normal address redirect.
this is docker-compose.yml
services:
  nginx:
    image: 'bitnami/nginx:latest'
    ports:- '80:8181'- '443:8443'
    volumes:- ./conf:/opt/bitnami/nginx/conf- ./certs:/certs- ./data:/app

A: This qustion is solved just add a slash at the end of the address,
this address
www.haetek.com/case

to this address
www.haetek.com/case/

I don't know the detail why it solved the problem. but it worked.


text:
Q: Support for Foreground and Background geoprocessing in ArcMap tools? If not all ArcGIS tools support both foreground and background Geoprocessing, then how can I tell whether a tool will run in the foreground or run in the background?

A: The tools that do not run in the background are listed on the help page entitled Background Geoprocessing (64-bit):

Tools that do not run in the background include the following:

*

*Tools inside the Metadata conversion toolset

*Tools inside the Geodatabase administration toolset

*All Coverage tools

*Tools which create packages

*Graphing tools (64-bit geoprocessing only; these tools work in traditional 32-bit background processing)

*Custom script, model, or function tools where the author has disabled background processing

  ...
Any script or script tools you run while inside Desktop honors the
  background processing setting.

I encourage you to visit the help page for more information.


text:
Q: How to convert jQuery function into angular js? I am very new to AngularJs, I have written a slider function in jQuery. Now I want to convert thih function into Angular. Here is my code below::

one

two

three

    <input type="button" id="left">
    <input type="button" id="right">

        .slide-container {height: 100px; overflow: hidden; position: relative;}
        .slide-scroller { height: 100px; overflow:hidden;  position: absolute; top: 0px;}
        .slide-scroller .slideContent { height: 100px; overflow: hidden; float: left;}

      function slider() {

           var slideWidth, speed, sc, slideScroller, scSlide, totalSlide, scrollerWidth, maxLeft;

           slideWidth = $(window).width();          // [ get the device width ]
           speed = 0.6;                             // [ control speed 1 = 1s]
           sc = $(".slide-container");              // [ getting the container ]
           slideScroller = $('.slide-scroller');    // [ getting slider scroller ]
           scSlide = $('.slideContent');            // [ getting slide contetnts ]
           totalSlide = $(scSlide).length;          // [ total slide contents ]
           scrollerWidth = totalSlide * slideWidth; // [ slide scroller width ]

           maxLeft = -parseInt(scrollerWidth) + parseInt(slideWidth); // [maxmimum left slide value]

           // adding some initial attributes
            $(sc && scSlide).css({width: slideWidth});
            $(slideScroller).css({width: scrollerWidth});
            $(slideScroller).css('transition', 'all ease '+speed+'s');

            // left click function

            $("#left").click(function () {
                var xvalue = $(slideScroller).css('left'); //console.log('left :: ', xvalue);
                var newvalue = parseInt(xvalue) - parseInt(slideWidth); //  console.log('newValue :: ', newvalue);
                if (newvalue >= maxLeft) {//console.info('no more left left');
                    $(slideScroller).css('left', newvalue);
                }
                else {
                    return false;
                }
            });
            // right click function
            $("#right").click(function () {
                var xvaluetwo = $(slideScroller).css('left'); console.log('lefttwo :: ', xvaluetwo);
                var newvaluetwo = parseInt(xvaluetwo) + parseInt(slideWidth); console.log('newValuetwo :: ', newvaluetwo);
                if (newvaluetwo <= 0) {//console.info('no more right left');
                    $(slideScroller).css('left', newvaluetwo);
                }
                else {
                    return false;
                }
            });
        }

        $(document).ready(function () {
            slider();
        });

I have linked jQuery.min library and called the function in document.ready
Please help me how to make in AngularJS

A: in HTML:

{item.content}

    <input type="button" id="left">
    <input type="button" id="right">

in Controller:
$scope.initSlider = function(){
    slider()
}


text:
Q: How to use ansible to get the hostname of remote machine and set in config file I have 60 client machines and i want to get hostname of each machine and insert it in some config files on corresponding machines.
So i wrote small script named changeName.sh as follows and copied it to 60 machines using ansible.
hostName=`hostname`
sed -i -e "s/Server=127.0.0.1/Server=192.168.1.2/" -e "s/ServerActive=127.0.0.1/ServerActive=192.168.1.2/" -e "s/Hostname=abc server/Hostname=$hostName/" /etc/xyz.config

but when I run the following ansible command on server as follows , it sets the hostname of the server instead of corresponding machine.
ansible DGroup -m command -a "sh /home/sysadmin/changeName.sh" -b


text:
Q: Possible CSRF attack that cause answers to be added to "Top Answers" section In Careers, adding answers to the "Top Answers" section of the profile is done via a pure GET request, e.g. http://careers.stackoverflow.com/cv/stack/add-answer/45190?answerId=227366&site=meta
If I click the above link while logged in to Careers, this answer of mine is being added to my public Careers profile. No confirmation, can only remove manually by editing.
Another example, if Mr. Alien will click this link while logged in to Careers, it will cause this answer to be added to his profile.
Can this please be fixed? (e.g. changing to POST, or requiring confirmation)
(Since the impact is not critical and can be easily undone, I think it's proper to post it here)

A: Good catch! I've just pushed a fix for this. We now use a POST request (with a CSRF token) to add answers to your profile. If you try a GET request you'll now get a 404 error.


text:
Q: What is the C# function that gives the same result as FoxPro Week(date, 2, 2)? How to get week date in C# with identical result as FoxPro function Week(date, 2, 2)?
GetWeekOfYear is not giving the same results no matter which CalendarWeekRule is used.

A: It's not enough to just change the CalendarWeekRule, you also need to change the DayOfWeek.
In VFP, Week(date, 2, 2) specifies Monday as the FirstDayOfWeek.
Try this:
DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

Edit:
check this out: iso 8601 week of year in .net

A: The Week class of the Time Period Library for .NET includes support for the ISO 8601 week format:
public void CalendarWeekSample()
{
  DateTime testDate = new DateTime( 2007, 12, 31 );

  // .NET calendar week
  TimeCalendar calendar = new TimeCalendar();
  Console.WriteLine( "Calendar Week of {0}: {1}", testDate.ToShortDateString(),
                     new Week( testDate, calendar ).WeekOfYear );
  // > Calendar Week of 31.12.2007: 53

  // ISO 8601 calendar week
  TimeCalendar calendarIso8601 = new TimeCalendar(
    new TimeCalendarConfig { YearWeekType = YearWeekType.Iso8601 } );
  Console.WriteLine( "ISO 8601 Week of {0}: {1}", testDate.ToShortDateString(),
                     new Week( testDate, calendarIso8601 ).WeekOfYear );
  // > ISO 8601 Week of 31.12.2007: 1
} // CalendarWeekSample


text:
Q: ECDSA sign with bouncy castle and verify with openssl I have a self-signed certificate(not popular X.509 one). The certificate and ECDSA public/private key pair are generated by java program using bouncy castle.
I need to verify this certificate with C program using openssl. However, the ECDSA signature can be verified by java program correctly, but failed with openssl verification. If I use the same private key to re-sign the message with openssl, the signature verification with openssl would passed though.
Here is the java code snippet related to key generation.(After key pair generated, I actually save them in file, so it will always use the the same key, not shown in following snipet).
KeyPair rootCASigningKeys = cryptoManager.generateKeyPair(SignatureChoices.ecdsaNistP256Signature);

BCECPublicKey bcPub = cryptoManager.toBCECPublicKey(PublicKeyAlgorithm.ecies_nistp256, (java.security.interfaces.ECPublicKey) rootCASigningKeys.getPublic());
ECPublicKey pk = (java.security.interfaces.ECPublicKey) rootCASigningKeys.getPublic();
ECPrivateKey priv = (ECPrivateKey) rootCASigningKeys.getPrivate();

System.out.println("pubkeyX="+getHexString(pk.getW().getAffineX().toByteArray()));
System.out.println("pubkeyY="+getHexString(pk.getW().getAffineY().toByteArray()));
System.out.println("privatekey="+getHexString(priv.getS().toByteArray()));

The C code of verify the signature showed in bellow:
bool v2x_ecdsa_verify(
        const uint8_t *digest,
        size_t dgstlen,
        const void *sig,
        const void *pkey)
{
 ECDSA_SIG *ecdsa_sig;
    EC_KEY *ec_key;
    EC_GROUP *grp
    int ret;

    /* debug */
    EC_POINT *ecpt;
    /* debug end */

    grp = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1); /*TODO: */
    ecpt = EC_KEY_get0_public_key((const EC_KEY *)pkey);
    struct ec_point_st *cpt = (struct ec_point_st *)ecpt;
    printf("Pubkey_x:%d=\n", BN_num_bytes(&cpt->X));
    BN_print_fp(stdout, &cpt->X);
    printf("Pubkey_y:%d=\n", BN_num_bytes(&cpt->Y));
    BN_print_fp(stdout, &cpt->Y);
    printf("\n");

    printf("digest dump\n");
    v2x_dump_hex(V2X_LOG_ERR, digest, 32);
    printf("\n");
    {
        /* DEBUG code, Use the private key outputed by Java code to re-sign the digest */
        uint8_t priv_buf[] = {
            0x00, 0xB2, 0x6C, 0x1D, 0x0C, 0x62, 0x84, 0x45, 0x31, 0x3C, 0xF3, 0x83, 0x1D, 0x4E, 0xA7, 0x4B,
            0x2C, 0x07, 0x19, 0xCF, 0x19, 0xCC, 0x3E, 0xA7, 0xE5, 0x4F, 0xA4, 0xF0, 0x91, 0xBF, 0x5B, 0x96, 0xE8};
        BIGNUM *priv_bn = BN_bin2bn(priv_buf, sizeof(priv_buf), NULL);
        printf("priv_bn=\n");
        BN_print_fp(stdout, priv_bn);
        printf("\n");
        if (!priv_bn) {
            V2X_ERR("Failed to conver privkey \n");
            return false;
        }
        EC_KEY *priv_key = EC_KEY_new();
        if (priv_key) {
            if (!EC_KEY_set_group(priv_key, grp)) {
                V2X_ERR("Failed to set group\n");
                return false;
            }
            EC_KEY_set_private_key(priv_key, priv_bn);
        }
        ecdsa_sig = v2x_ecdsa_sign(digest, dgstlen, NULL, 0, (void *)priv_key);
    /* END of DEBUG code */
    }
    //ret = ECDSA_do_verify(digest, dgstlen, (ECDSA_SIG *)sig, (EC_KEY *)pkey); /* It fail to verify original signature */
    ret =  ECDSA_do_verify(digest, dgstlen, ecdsa_sig, (EC_KEY *)pkey); /* it pass to verify the re-signed signature */

    if (ret < 0)
        V2X_ERR("ret=%d\n", ret);

    return (bool)ret;
}

The keys printed out by java and C are in bellow :
Java using bouncy castle:
provider=BC
pubkeyX=00 E4 B6 E1 50 C2 7A 85 DD BD 92 F8 14 C9 0E B0 5E 1E 28 A6 3C A3 B6 B1 69 32 39 BF 1B 1B F0 B0 03
pubkeyY=00 ED DC 75 F0 E9 36 05 25 5F 54 08 74 E7 9D 6E BC 1B DF 97 5A E4 D2 A7 04 A7 E0 5F 21 06 54 26 1E
privatekey=00 B2 6C 1D 0C 62 84 45 31 3C F3 83 1D 4E A7 4B 2C 07 19 CF 19 CC 3E A7 E5 4F A4 F0 91 BF 5B 96 E8

And the sha256 hash being signed is
F40D983058408C0519D7E238BEBFA5EDCAA7F3B86AD4C83847F5DD66EA1C051B

C Using OpenSSL
Pubkey_x:32=
E4B6E150C27A85DDBD92F814C90EB05E1E28A63CA3B6B1693239BF1B1BF0B003
Pubkey_y:32=
EDDC75F0E93605255F540874E79D6EBC1BDF975AE4D2A704A7E05F210654261E
digest dump
        f4 0d 98 30  58 40 8c 05  19 d7 e2 38  be bf a5 ed
        ca a7 f3 b8  6a d4 c8 38  47 f5 dd 66  ea 1c 05 1b

priv_bn=
B26C1D0C628445313CF3831D4EA74B2C0719CF19CC3EA7E54FA4F091BF5B96E8

I am pretty stuck here, java program can sign and verify that given digest, and  C program can sign and verify the same digest using same key pair. But the C program can NOT verify the signature generated by java program.  I also dumped out the generated signature r/s portion from java and compared with what i am trying to verify in C program , they are the same.
I can go deeper into OpenSSL to add debug, but too bad I am not expert in java bouncy castle. Any suggestion is greatly appreciated! Thanks and sorry for the long post.

A: I figured out what's wrong, the digest used for signing takes one more step which i missed, as a result the digest used for verification is different with what's used for signing, so it failed.


text:
Q: Simple question about submersions Let $f: X \rightarrow Y$ be a $C^1$-diffeomorphism and $g: Y \rightarrow Z$ be a $C^1$-submersion in $y \in Y$.
1- I'm pretty sure that it is true, but $g \circ f$ is also a $C^1$-submersion in some point $x \in X$ right ?
2- Do we have in particular that $g \circ f$ is $C^1$-submersion in $f^{-1}(y)$ ? If yes, why ? If no, using $y$, can we find a particular point $x_y$ where $g \circ f$ is $C^1$-submersion in $x_y$ ?
EDIT: We have that $d_{f^{-1}(y)}(g \circ f) = d_yg \circ d_{f^{-1}(y)}f$, where $d_yg$ and $d_{f^{-1}(y)}f$ are surjective (by assumption). So we can conclude that $d_{f^{-1}(y)}(g \circ f)$ is also surjective ?
Thank you.

A: Yes, if $g$ is submersive at $y\in Y$, then $g\circ f$ is submersive at $f^{-1}(y)$. $df_{f^{-1}y}$ is an isomorphism from $T_{f^{-1}y}X$ to $T_yY$.


text:
Q: Resetting the timestamp of a cached data entry to now() I am trying to reset the timestamp on a cached Entry. I want to know how to achieve that.
Right now i am creating a new instance of  MemoryCacheEntryOptions
        private MemoryCacheEntryOptions GetCacheOptions()
        {
            return new MemoryCacheEntryOptions()
                .SetSlidingExpiration(TimeSpan.FromSeconds(20)); // Cache for some seconds.
        }

I want to be able to reset the SetSlideExpiration() to start counting from Zero (0)second, every time a cached data is present in the MemoryCacheEntry.
So if

public bool hasCached(string key, byte[] values)
{
  return _memoryCache.TryGetValue(GetDocStoreKey(key), out values);
}

returns true i should be able to reset the SetSlideExpiration to start counting from beginning.

A: SetSlidingExpiration(TimeSpan.FromSeconds(20)) will automatically reset the cache timestamp every time the item in the cache is accessed
 public object GetFile(string key)
 {
   return (_memoryCache.Get(Cache(key));
 }

So if the cache entry was access like this resultFromCache = _cacheServiceClass.GetFile(cacheKey); the MemoryCacheEntryOptions() will reset
SetSlidingExpiration(TimeSpan.FromSeconds(20)) every time.


text:
Q: Arbortext Editor Adapter Creation I'm creating adapter for arbortext editor. Also i'm able to create the structured adapter, but while initializing the adapter i'm getting

registerAdapter is not a function, it is org.mozilla.javascript.NativeJavaPackage.

Please help me on this.

A: i resolved the problem, by deleting the target folder and rebuild the classes, then created adapter jar. Now i'm able to register my adapter.


text:
Q: Vertical tiny carousel autoplay horizontally I'm using tiny carousel for my current school project. everything is working fine except for the autoplay.
Here is the code for autoplay and animation config:
$("#upcoming").tinycarousel({ interval: true });
var upcoming = $("#upcoming").data("plugin_tinycarousel");

upcoming.start();
//for carousel
$("#upcoming").tinycarousel({
      axis   : "y",
      animationTime: 500,
      infinite: true
});

When I included
$("#upcoming").tinycarousel({ interval: true });
var upcoming = $("#upcoming").data("plugin_tinycarousel");

upcoming.start();

My carousel that animates vertically is now horizontal. Can anyone tell me why is this happening?

A: By default the plugin's setting axis is x = horizontal. You need to set it to y.
$("#upcoming").tinycarousel({ interval: true, axis: 'y' });
var upcoming = $("#upcoming").data("plugin_tinycarousel");

upcoming.start();


text:
Q: Bootstrap 3.0: How to have text and input on same line? I'm currently switching my website over to Bootstrap 3.0.  I'm having an issue with form input and text formatting.  What worked in Bootstrap 2 does not work in Bootstrap 3.
How can I get text on the same line before and after a form input?  I have narrowed it down to a problem with the 'form-control" class in the Bootstrap 3 version of the example.
How would I go about getting all the text and input on one line?   I would like the bootstrap 3 example to look like the bootstrap 2 example in the jsfiddle.
JS fiddle example

  <form>

 Format used to look like this in Bootstrap 2

          Return:
          <input id="return1" name='return1' class=" input input-sm" style="width:150px"
                 type="text" value='8/28/2013'>
           +/- 14 Days

 BootStrap 3 Version

          Return:
          <input id="return2" name='return2' class="form-control input input-sm" style="width:150px"
                 type="text" value='8/28/2013'>
           +/- 14 Days

  </form>

Update:
I change the code to this which works but having trouble with alignment now. Any ideas?

Class Type

        <select name="class_type" id="class_type" class="  form-control input-lg" style="width:200px" autocomplete="off">
            <option >Economy</option>
            <option >Premium Economy</option>
            <option >Club World</option>
            <option >First Class</option>
        </select>

A: I would put each element that you want inline inside a separate col-md-* div within your row. Or force your elements to display inline. The form-control class displays block because that's the way bootstrap thinks it should be done.

A: just give mother of div "class="col-lg-12""

Class Type

        <select name="class_type" id="class_type" class="  form-control input-lg" style="width:200px" autocomplete="off">
            <option >Economy</option>
            <option >Premium Economy</option>
            <option >Club World</option>
            <option >First Class</option>
        </select>

it will be

Class Type

        <select name="class_type" id="class_type" class="  form-control input-lg" style="width:200px" autocomplete="off">
            <option >Economy</option>
            <option >Premium Economy</option>
            <option >Club World</option>
            <option >First Class</option>
        </select>

A: The way I solved it was simply to add an override for all my textboxes on the main css of my site, as so:
.form-control {
    display:initial !important;
}

A: What you need is the .form-inline class. You need to be careful though, with the new .form.inline class you have to specify the width for each control.
Take a look at this

A: In Bootstrap 4 for Horizontal element you can use .row with .col-*-* classes to specify the width of your labels and controls. see this link.
And if you want to display a series of labels, form controls, and buttons on a single horizontal row you can use .form-inline for more info this link

A: Straight from documentation http://getbootstrap.com/css/#forms-horizontal.
Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout by adding .form-horizontal to the form (which doesn't have to be a <form>). Doing so changes .form-groups to behave as grid rows, so no need for .row.
Sample:
<form class="form-horizontal">

    Email

      <input type="email" class="form-control" id="inputEmail3" placeholder="Email">

    Password

      <input type="password" class="form-control" id="inputPassword3" placeholder="Password">

          <input type="checkbox"> Remember me

      <button type="submit" class="btn btn-default">Sign in</button>

</form>

A: None of these worked for me, had to use .form-control-static class.
http://getbootstrap.com/css/#forms-controls-static

A: You can do it like this:
<form class="form-horizontal" role="form">

        Label

            <input type="text" class="form-control" id="input" placeholder="Input text">

</form>

Fiddle

A: all please check the updated code as we have to use
 form-control-static not only form-control

http://jsfiddle.net/tusharD/58LCQ/34/
thanks with regards

A: Or you can do this:

    Return:
    <input id="return1" name='return1'
              class=" input input-sm" style="width:150px"
              type="text" value='8/28/2013'>

I tried every one of the suggestions above and none of them worked.  I don't want to pick a fixed number of columns in the 12 column grid.  I want the prompt, and the input right after it, and I want the columns to stretch as needed.
Yes, I know, that is against what bootstrap is all about.  And you should NEVER use a table.  Because DIV is so much better than tables.   But the problem is that tables, rows, and cells actually WORK.
YES - I REALLY DO know that there are CSS zealots, and the knee-jerk reaction is never never never use TABLE, TR, and TD.  Yes, I do know that DIV class="table" with DIV class="row" and DIV class="cell" is much much better.  Except when it doesn't work, and there are many cases. I don't believe that people should blindly ignore those situations.  There are times that the TABLE/TR/TD will work just fine, and there is not reason to use a more complicated and more fragile approach just because it is considered more elegant.  A developer should understand what the benefits of the various approaches are, and the tradeoffs, and there is no absolute rule that DIVs are better.
"Case in point - based on this discussion I converted a few existing tds and trs to divs. 45 minutes messing about with it trying to get everything to line up next to each other and I gave up. TDs back in 10 seconds later - works - straight away - on all browsers, nothing more to do. Please try to make me understand - what possible justification do you have for wanting me to do it any other way!" See [https://stackoverflow.com/a/4278073/1758051]
And this: "
Layout should be easy. The fact that there are articles written on how to achieve a dynamic three column layout with header and footer in CSS shows that it is a poor layout system. Of course you can get it to work, but there are literally hundreds of articles online about how to do it. There are pretty much no such articles for a similar layout with tables because it's patently obvious. No matter what you say against tables and in favor of CSS, this one fact undoes it all: a basic three column layout in CSS is often called "The Holy Grail"." [https://stackoverflow.com/a/4964107/1758051]
I have yet to see a way to force DIVs to always line up in a column in all situations.  I keep getting shown trivial examples that don't really run into the problems.    "Responsive" is about providing a way that they will not always line up in a column.  However, if you really want a column, you can waste hours trying to get DIV to work.  Sometimes, you need to use appropriate technology no matter what the zealots say.


text:
Q: Is it possible to use Django's SafeExceptionReporterFilter with something else than the AdminEmailHandler? I'm trying to filter out sensitive informations using Django's @sensitive_post_parameters. I thought prepending these annotations over a the few specific fonctions would be enough, but it doesn't work. I've set breakpoint inside SafeExceptionReporterFilter and  it only breaks when being called from the AdminEmailHandler and not the other handlers. What am I missing ?

A: You can write a custom Handler that uses django.views.debug.ExceptionReporter to format the exception.
Example use of ExceptionReporter:
from django.views.debug import ExceptionReporter

# exc_type, exc_value, traceback are a standard exception
# tuple as returned by sys.exc_info
reporter = ExceptionReporter(request, exc_type, exc_value, traceback)
html_report = reporter.get_traceback_html()
text_report = reporter.get_traceback_text()

ExceptionReporter will use the ExceptionReporterFilter defined by the DEFAULT_EXCEPTION_REPORTER_FILTER setting  which by default is SafeExceptionReporterFilter.
Have a look at AdminEmailHandler's implementation to get info on how to create a custom Handler.

A: Even if you use the SafeExceptionReporterFilter, exceptions will still contains sensitive data (e.g. your Server's ENV variables and other runtime data).
To avoid exposing sensitive data, you should not use this filter. Instead, write your own Exception Handler Middleware and selectively(recursively?) fetch yourself the data you want in the logs.
See sys.exc_info on how to obtain exception's traceback and how to use it for your needs.
Even if you go with a CustomHandler you'll be limited with a specific handler and as far as I know, third-parties handlers won't use the SafeExceptionReporterFilter.


text:
Q: Javascript XMLHttpRequest Post method Hey So I have a question about posting using an XMLHttpRequest.  In theory, if I am to post a username and password to an https domain (which I have yet to get working, unfortunately) would the responseText then change to the next website, or should the text fields become filled in?  What normally happens is you navigate to this page via browser, enter a username and password, and it uses a POST method when the submit button is clicked, doing some authentication under the hood and returning a different page.  I feel like maybe the responseText should even stay exactly the same (which is what happens now), but I don't know as I have no experience with this kind of thing.
this.requests[1].open("POST", "https://" + this.address, true);
var query = "target=%2Fcgi-bin%2FStatusConfig.cgi%3FPage%3Dindex&userfile=&username=user&password=pass&log+in=Log+in";
this.requests[1].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
this.requests[1].setRequestHeader("Content-length", query.length);
this.requests[1].setRequestHeader("Keep-Alive", 115);
this.requests[1].setRequestHeader("Connection", "keep-alive");
this.requests[1].setRequestHeader("Host", this.address);
this.requests[1].send(query);
this.requests[1].onreadystatechange = onReadyStateChange1;

Then basically onReadyStateChange1 displays the responseText when ready.
Any light that could be shed on what SHOULD be happening with the post and responseText would be very appreciated.  As would any advice in getting the new, logged into page.
For further clarification, what I'm trying to do is log in and then return the new page, because the login page displays only log in information/functionality and the page after logging in has a lot of relevant information. I'm not trying to check the credentials as much as I'm trying to get it (the script) to log in so it can access the next page. Granted, the credentials will have to be valid for that.
Thanks all.

A: If I understood correctly, you're trying to check credentials using AJAX? If so, always do server-side validation, and only return {"success": true, "redirect": "/loggedin.html"} back to the client. Then have a callback function ready that forwards response.redirect or something similar.

A: Well I found that the website is supposed to send a query with the relevant information and it would not fill out the text fields or anything.  ResponseText changes.


text:
Q: OS X app tableview datasource updating but not reloading in tableView I have a Mac OS X app which populates a tableView with data from an external web service. If I log into my app, I can add new records, delete them, etc, and my call to [tableView reloadData] works exactly as I would anticipate.
Here's what puzzles me. If I log into my app (simultaneous login from two different instances - one running as an app on my machine, and one running in debug mode from Xcode) I can see the data I expected. However, if I create a new record in one instance of the app it does not load when [tableView reloadData] is called. The strange thing is, if I look at the data coming back from the web server it does contain the new or updated records. They just do not display.
If I log out of the other instance of the app and sign back in, boom - I see the new record. Again, if I add a record somewhere it appears in the data stream (which I have a method [self getData]) but when the [tableView reloadData] is called it still does not display the entry.
What would cause the tableView to not display the new data - despite its source NSMutableArray being updated appropriately? I've confirmed that the app is seeing the appropriate data:
2011-12-04 16:12:40.086 Workshop Manager[8591:707] Loading tickets from API
2011-12-04 16:12:40.711 Workshop Manager[8591:707] Load return_data into tickets and filtered_tickets
2011-12-04 16:12:40.711 Workshop Manager[8591:707] App currently has 8 tickets loaded
2011-12-04 16:13:20.437 Workshop Manager[8591:707] Refresh button pushed
2011-12-04 16:13:20.438 Workshop Manager[8591:707] Removing all existing tickets
2011-12-04 16:13:20.438 Workshop Manager[8591:707] Loading tickets from API
2011-12-04 16:13:20.774 Workshop Manager[8591:707] Load return_data into tickets and filtered_tickets
2011-12-04 16:13:20.774 Workshop Manager[8591:707] App currently has 9 tickets loaded

Since the app is clearly loading the new dataset, what else am I missing? Any advice would be appreciated.
Thanks for your time!


text:
Q: Computing the spectral norm of a projection matrix I was reading a paper in which there was an argument as trivial, but could not make myself sure about it. It is said that given a full row-rank matrix $A$, the norm (probably $\ell_2$-induced matrix norm) of $A^T(AA^T)^{-1}A$ is one. Is that trivial, and correct for any given matrix $A$?

A: Given fat matrix $\rm A$ with full row rank,
$$\rm P := A^\top \left( A A^\top \right)^{-1} A$$
is the (symmetric) projection matrix that projects onto the row space of $\rm A$. Every projection matrix has eigenvalues $0$ and $1$. Since $\rm P$ is symmetric and positive semidefinite,
$$\| \rm P \|_2 = \sigma_{\max} (\rm P) = \lambda_{\max} (\rm P) = 1$$

A: We recognize in that expression a projection matrix onto $\operatorname{Row(A)}$ and since $A$ is a full row rank we have that
$$P=A^T(AA^T)^{-1}A \implies \sup\left\{\frac{\|Ax\|}{\|x\|},\, x\neq 0\right\}=1$$


text:
Q: Prove that for isomorphism $\phi: G\to H$, if $K\leq G$, then $\phi (K)=\left \{ \phi(k):k\in K \right \}\leq H$. Could someone please verify whether my following proof is correct?

Prove that for isomorphism $\phi: G\to H$, if $K\leq G$, then $\phi (K)=\left \{ \phi(k):k\in K \right \}\leq H$.

Proof:
Subset: By definition of $\phi$, $\phi(K) \subset H$.
Identity: Since $K\leq G$, $e_{G}\in K$. Then $\phi(e_{G})=e_{H}\in H$. Then $e_{H}=\phi(e_{G})\in \phi(K)$.
Inverse: Since $\phi$ is an isomorphism, its inverse $\phi ^{-1}$ exists. Then for all $\phi(k)\in \phi(K)$, there exists an inverse $\phi^{-1}(k)$.
Closure: For $k,k'\in K$, then $\phi(kk')\in \phi(K)$ since $K$ is a group. Then $\phi(kk')=\phi(k)\phi(k')\in \phi(K)$.

I am unsure whether closure is correct! Is this proof sufficient?

A: Your proof is correct apart from the bit about inverses. To show that inverses exist, take any $\phi(k)\in\phi(K)$. Since $K$ is a group, each $k\in K$ has an inverse, $k^{-1}$. You can check that $(\phi(k))^{-1}=\phi(k^{-1})$.


text:
Q: After Insert on one table, depending on quantity depends on how many entries in another table- MySQL trigger So I have a strange question. I have two tables:
Table 1:
Id, grade1, grade2, grade 3, quantity
Table 2:
Id, stage, grade
Now- when something is entered into table 1 – Say 1,2, 1, 0, 3 – I need it to enter 3 entries into table two as follows:
Id, stage, grade
1, 0, 1
2, 0, 1
3, 0, 2

So depending what is entered into quantity in table 1, after this is inserted, depends on how many records are entered into table two, and depending on what numbers are entered into table 1, depends on what grade they get given in table 2.
I need this to potentially be done within a trigger. I don't really know how I would approach something like this. If anyone could help that would be great.


text:
Q: Should Slick DatabaseConfig and TableQuery values be shared & reused across threads & requests I am using Slick (v3.1 currently).  I create my DatabaseConfig from TypesafeConfig, and TableQuery values for my schemas.
Which of these things should I be sharing across:

*

*Requests

*Threads

It's not clear to me from reading the docs.

Here's my own attempt at answering.
I observe that the DatabaseConfig (or some part of it) owns a connection pool.  So it seems pretty obvious that it's best to share this object across all requests and threads (treat it like a singleton).
For the TableQuery values, I have less insight.  I haven't done extensive testing but I don't see a particular reason I need to share these either over multiple requests or between my threads.


text:
Q: Unable to install python-levenshtein package on Mac using Python 3.6 I was trying to install the python-levenshtein library using terminal. However, I kept encountering errors. The Python version that I am using is Python 3.6 and the command I had been using to install the package is pip install python-levenshtein.
Could someone tell me what I am doing wrong?
Thank you.

A: For Anaconda users, it is better use the following command as it helped in my case:
conda install -c conda-forge python-levenshtein

A: Maybe your computer have both python2 and python3 installed, if that is the case, you should use pip3 install python-levenshtein.


text:
Q: Do any multi-client IM clients support Skype Chat? It would be best if they can run without having Skype installed at all.  Does such a creature exist?

A: Both Kopete and Pidgin have Skype plugins. The Kopete one is bundled with the main app as far as I know, and for Pidgin you have to download the Skype Pidgin plugin.
Please note that both of these require Skype to be installed and running. I've added them since I don't think you will find a legal app which natively connects to the Skype server, as Wikipedia states that:

Reverse engineering of the Skype protocol by inspecting/disassembling binaries is prohibited by the terms and conditions of Skype's license agreement.

A: SkyLlian is a Skype plugin for trillian.

A: There is IMO.IM which support Skype without Skype installed...
That is for one obvious reason... It is a web service, and not an installed IM client.
That said, the programmers community should look their way (IMO) for knowhow. I am certain that the problem is in strong encryption Skype use in their protocols.

A: Warning - Current status of imo.im suggests that Skype support may be fleeting:

We are unable to support Skype due to our inability to connect to their servers. We don't know if we will be able to support Skype any time soon as it depends on factors out of our control.

https://imo.im/ supports skype, and is web-based.

*

*Completely free

*It runs from any modern browser - no installation required, OS doesn't matter

*No need to keep Skype installed and running (the only IM I know that does that)

*Keeps logs of all your chats

*Available for free for ALL major mobile OSs

*Supports all  major IM protocols

*Links all your accounts from various IM systems to one (i.e. you can log in to any one of them, and the system will log you in to all other automatically)

*Allows more than one Skype account to be running in the same time! (Just discovered it myself - I have two different accounts for work and for private chat, and it was a pin in the head to sign in and out all the time; with IMO it's great.)

With this, all others are simply out of competition.
Only one shortcoming - you can't really install it on a desktop computer as a stand-alone application, like we are used to. But it's more a problem with our habits that with the product itself.

A: IM+ is a chat application for mobile devices (iPhone, BlackBerry, Windows Mobile) and it supports Skype among others.

A: I use Trillion, love it.  It uses SkyLlion as a plug in, must have Skype downloaded and running.  Enjoy this chat client.

A: Trillian 5 doesn't require skype to be running, or installed at all, at least for the windows version.

A: (Disclaimer, I'm on the Yuuguu Dev Team)
Yuuguu (Windows and Mac versions) supports Skype chat and will work with GTalk, MSN, AOL and Yahoo messenger accounts.  However, as far as I know, the Skype API requires Skype to be running (although it can be switched into silent mode).

A: Trillian Astra supports Skype and many other connections.

A: For completeness' sake, there Miranda, too, with its Skype protocol plugin. However, as most of the previously mentioned programs this, too, uses the Skype API, and requires Skype to be installed and running. Moreover, the Skype plugin doesn't seem to be under active development right now.


text:
Q: What happens if the Forward voltage of a diode is not met? Ihave been playing around with transistors and diodes lately, and thinking about switching methods and techniques.
I'm not that educated on the matter of "Forward Voltage", but I illustrated a concept I am trying to grasp in the photo below:

In this circuit concept, I have a 1.5V battery hoked up across the terminals of a capacitor, but...there is a cathode of a diode hooked up between the negative terminal of the battery and the negative terminal of the capicitor.
The Diode, attached to a current limiting resistor,can provide a path to the other terminal of the capacitor, but only if the forward voltage is met???
Is that so? Would the diode act as some type of "flood-gate", allowing the battery to store electrical potential in the capacitor, until the pressure is adequate to provide the forward voltage to the diode?
My goal, or what I envision, is that I could hook up a relay or transistor the other end of the capacitor/ battery, and the temporary discharging of the capacitor would momentarily "power" the switch, allowing me to momentarily connect another power source to make a light blink or something.
If the diode funcctions in tth way I assume, then it would probably do this in a constant cycle, and could possibly be timed in accordance to functionality.
I'm just not sure if this is the actual science...

A: The following is an example of a relaxation oscillator using the 2N6028 PUJT:

simulate this circuit – Schematic created using CircuitLab
In this circuit, \$R_4\$ and \$C_1\$ are the timing pair. I think these are doing what you hoped for. Current flows through \$R_4\$ and charges up \$C_1\$, over time. \$R_2\$ and \$R_3\$ form a voltage divider that sets the "trigger voltage" that \$C_1\$ needs to reach before "things happen." As \$C_1\$ charges up, it eventually reaches that trigger voltage and when it does the PUJT "fires" and dumps the charge sitting on \$C_1\$ into \$R_1\$ as fast as it can. In doing so, the current caused by this charge-dump causes a voltage to develop across \$R_1\$, which is then used to turn \$Q_1\$ on and saturate it -- just as you'd hoped.
No Arduino. No microcontroller. Just a basic timer. You can change the timing of the pulses by adjusting the value of \$C_1\$. At it is, it runs somewhere between \$3\:\textrm{Hz}\$ and \$4\:\textrm{Hz}\$. I've set \$R_{LOAD}\$ to a particular value. If you discuss what your load actually is, I might be able to help adjust the above circuit. But at least this gives you an idea.


text:
Q: Mathematica for automatic image processing and quantification I've been working on image analysis pipeline that involves a set of batch processing macros in ImageJ (for image segmentation) and data processing in Excel (VBA).  I've got the process run in 4-5 clicks.
Is it possible to use Mathematica to run ImageJ and VBA macros and handle directories for multiple image processing?
Thanks


text:
Q: UIView not receive UICollectionViewDataSource and UICollectionViewDelegate event I have a UITableViewCell that contains UIView in which have UICollectionView inside it. UIView have implement the UICollectionViewDataSource and UICollectionViewDelegate, But when i run UIView don't receive event from UICollectionViewDataSource and UICollectionViewDelegate.
- (id)init{
self = [super init];
if(self)
{
    [self initBanDau];
}
return self;
}

- (void)initBanDau{
self.mclv.delegate = self;
self.mclv.dataSource = self;
[self.mclv registerClass:[CellProduct class] forCellWithReuseIdentifier:cellIdentifier];
}

I reloadData of UICollectionView when NSMutableArray change
- (void)setMArray:(NSArray *)mArray{
if(_mArray)
{
    [_mArray release];
    _mArray = [mArray retain];
}
else
{
    _mArray = [mArray retain];
}

[self.mclv reloadData];
}

Can anyone please explain for me. Thanks for any help!

A: Write the below code in different method like viewDidLoad:-
self.mclv.delegate = self;
self.mclv.dataSource = self;


text:
Q: SAP UI5 Routing and Navigation in SplitScreen Application I'm facing an issue with SAPUI5 SplitScreen Concept. I have one initial view on which there is a button that leads to a SplitScreen application. Until this point everything works fine.The issue is that there a two additional views (Master.view, Detail.view) that should be routed to the SplitView.
They simply aren't loaded to it and I can't solve the problem.
I have mentioned manifest.json above.
{
"_version": "1.12.0",
"sap.app": {
    "id": "curvy.SplitApp",
    "type": "application",
    "i18n": "i18n/i18n.properties",
    "applicationVersion": {
        "version": "1.0.0"
    },
    "title": "{{appTitle}}",
    "description": "{{appDescription}}",
    "sourceTemplate": {
        "id": "ui5template.basicSAPUI5ApplicationProject",
        "version": "1.40.12"
    }
},
"sap.ui": {
    "technology": "UI5",
    "icons": {
        "icon": "",
        "favIcon": "",
        "phone": "",
        "phone@2": "",
        "tablet": "",
        "tablet@2": ""
    },
    "deviceTypes": {
        "desktop": true,
        "tablet": true,
        "phone": true
    }
},
"sap.ui5": {
    "flexEnabled": false,
    "rootView": {
        "viewName": "curvy.SplitApp.view.App",
        "type": "XML",
        "async": true,
        "id": "App"
    },
    "dependencies": {
        "minUI5Version": "1.65.6",
        "libs": {
            "sap.ui.layout": {},
            "sap.ui.core": {},
            "sap.m": {}
        }
    },
    "contentDensities": {
        "compact": true,
        "cozy": true
    },
    "models": {
        "i18n": {
            "type": "sap.ui.model.resource.ResourceModel",
            "settings": {
                "bundleName": "curvy.SplitApp.i18n.i18n"
            }
        }
    },
    "resources": {
        "css": [{
            "uri": "css/style.css"
        }]
    },
    "routing": {
        "config": {
            "routerClass": "sap.m.routing.Router",
            "viewType": "XML",
            "async": true,
            "viewPath": "curvy.SplitApp.view",
            "controlAggregation": "pages",
            "controlId": "app",
            "clearControlAggregation": false
        },
        "routes": [{
            "name": "RouteApp",
            "pattern": "RouteApp",
            "target": ["TargetApp"]
        }, {
            "name": "SplitView",
            "pattern": "SplitApp",
            "view":"SplitView",
            "controlId": "App",
            "target": ["SplitView"],

                "subroutes": [{
                    "pattern": "Route_Master",
                    "name": "Master",
                    "view": "Master",
                    "targetAggregation": "masterPages",
                    "targetControl": "splitapp",
                    "target": ["Master"],

                                "subroutes": [{
                                    "pattern": "Route_Detail",
                                    "name": "Detail",
                                    "view": "Detail",
                                    "targetAggregation": "detailPages",
                                    "target": ["Detail"]
                            }]
            }]
        }],
        "targets": {
            "TargetApp": {
                "viewType": "XML",
                "transition": "slide",
                "clearControlAggregation": false,
                "viewId": "App",
                "viewName": "App"
            },
            "SplitView": {
                "viewType": "XML",
                "viewName": "SplitView"
            },
            "Master": {
                "viewType": "XML",
                "viewName": "Master",
                "controlId": "splitapp"
            },
            "Detail": {
                "viewType": "XML",
                "viewName": "Detail",
                "controlId": "splitapp"
            }
        }
    }
}

}


text:
Q: Cartesian rolling join with data.table I'm not exactly sure how to describe this, but I'll gladly edit the title and/or post to reflect comments and answers.
Problem
I have two data.frames that I would like to merge with a combination of a left join, an outer join, and a rolling join.

*

*One of the key columns (year) is for the rolling join.

*Another key column (cat) is common to both data.frames. In the example below I've only supplied exemplary subsets of the full data, which has thousands of values for cat.

*The first data.frame, X, has an additional key column cnty (county), and the second data.frame, Y, has an additional key column pol (pollutant).

*For each group defined by cat and year, I would like the final result to contain a cartesian product of cnty and pol, with value columns emfac (from X) and tput (from Y). The goal is to be able to compute emfac * tput.

Here is an exemplary subset of X:
  cat year cnty  tput
1  29 2011  ALA 67852
2  29 2011   CC 33893
3  29 2011  MRN 11319

... and here is an exemplary subset of Y:
  cat year pol emfac
1  29 1975 TOG   2.4
2  29 1975  PM   5.3

Closest attempt so far
I can almost, but not quite, get the output I want:
X <- structure(list(
       cat = c(29L, 29L, 29L),
       year = c(2011L, 2011L, 2011L),
       cnty = c("ALA", "CC", "MRN"),
       tput = c(67852, 33893, 11319)),
       .Names = c("cat", "year", "cnty", "tput"),
       class = c("data.frame"), row.names = c(NA, -3L))

Y <- structure(list(
       cat = c(29L, 29L),
       year = c(1975, 1975),
       pol = c("PM", "TOG"),
       emfac = c(2.4, 5.3)),
       .Names = c("cat", "year", "pol", "emfac"),
       class = c("data.frame"), row.names = c(NA, -2L))

library(data.table)
X <- data.table(X, key = c("cat", "cnty", "year"))
Y <- data.table(Y, key = c("cat", "pol", "year"))
Y[X, roll = TRUE]

   cat year pol emfac cnty  tput
1:  29 2011  PM   5.3  ALA 67852
2:  29 2011  PM   5.3   CC 33893
3:  29 2011  PM   5.3  MRN 11319

This is my "nearest miss". Most of my other attempts are much more wrong.
Expected result
   cat year pol emfac cnty  tput
1:  29 2011  PM   5.3  ALA 67852
2:  29 2011  PM   5.3   CC 33893
3:  29 2011  PM   5.3  MRN 11319
4:  29 2011 TOG   2.4  ALA 67852
5:  29 2011 TOG   2.4   CC 33893
6:  29 2011 TOG   2.4  MRN 11319

What am I doing wrong?


text:
Q: What is the name of this "" notation and what does it mean? I've come across an expression from the Stanford Neural Network Course Note that looks like this:

(where a, b, c are parameter vectors)
What is the name of this notation "" and what does it mean / do? i.e.

I guess it means "1" (one) but not entirely sure as it seems to be written in a specific way for a reason? (could it be that it means true if x is within the range a to b, and false if x is outside that range? Boolean related?)

A: This is the indicator function. In your case,
$$
\mathbf 1(a_i < x < b_i)(x) = \begin{cases} 1 & \text{ if } a_i < x < b_i \\ 0 & \text{ else} \end{cases}
$$

A: It is the "indicator function". It equals one when the conditions in the subscript are met, and zero otherwise.

A: From the (little) context, my guess is that $$1\!\!1(\phi(x))=\begin{cases}1&\text{if }\phi(x)\\0&\text{if }\neg\phi(x)\end{cases}$$


text:
Q: Javascript Not Displaying Button Text full json is
    {
"id": "70dec1ac-345f-4b94-b255-b09c5ab1b522",
"name": "card",
"auto": true,
"contexts": [],
 "responses": [
{
  "resetContexts": false,
  "affectedContexts": [],
  "parameters": [],
  "messages": [
    {
      "type": 1,
      "platform": "facebook",
      "title": "this is the title updated",
      "subtitle": "this is the subtitle",
      "imageUrl": "https://www.gettyimages.ie/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg",
      "buttons": [
        {
          "text": "this is the button"
        },
        {
          "text": "this is also a button"
        }
      ],
      "lang": "en"
    },
    {
      "type": 0,
      "speech": []
    }
  ],
  "defaultResponsePlatforms": {},
  "speech": []
}
],
"priority": 500000,
"cortanaCommand": {
"navigateOrService": "NAVIGATE",
"target": ""
},
"webhookUsed": false,
"webhookForSlotFilling": false,
"lastUpdate": 1530197695,
"fallbackIntent": false,
"events": [],
"userSays": [
{
  "id": "528c22d4-49d7-4ab9-a8db-fcd84d57694b",
  "data": [
    {
      "text": "card"
    }
  ],
  "isTemplate": false,
  "count": 0,
  "updated": 1530196620,
  "isAuto": false
}
],
"followUpIntents": [],
"templates": []
}

I am actually making a chatbot for wordpress to communicate with api.ai or dialogflow
The code I am currently using to display a card is the following:
var html = "

";
html+="
" + title + "
"
html += "
" + subtitle+ "
";
html += "<input type=\"button\" " + "style=\"background-color:rgb(221, 153, 51);text-transform: none\"" + "class=\"myc-quick-reply\" value=\"" +buttons[0]+ "\" />";
var innerHTML = "

" + html + "
";

I am getting the image ,title ,subtitle correctly but the Button is displayed as [object Object] what is the correct way to do it?

A: The button text is in the text property.
Try to replace buttons[0] with buttons[0].text.

A: in your case buttons is an array of object and have property text. so try buttons[0].text


text:
Q: Why can I not print the entire message in this file using C? char message[500];
printf("\nEnter your message (Not more than 500 words)\n->");
scanf("%s", message);

FILE *ptr;
ptr = fopen("file.txt", "w");

fprintf(ptr, message);
fclose(ptr);

Here I created an array called message and after receiving the input from the user, I printed the stored string into the file named 'file.txt' but it turns out that only first word of the message array is printing in the file.
For example: If I typed 'Hello there, I am learning C' inside the message array and print it to the file, then only 'hello' is being printed on the file.
Please explain elaborately.

A: never use %s in scanf without a maximum field width, or you may very likely overflow your buffer.  Using %s is no better than gets.
The issue you are having is simply that %s reads up until the first whitespace.  If you want to consume all input, you probably should use fread instead of scanf.  That is:
char message[500];
printf("\nEnter your message (Not more than 500 characters)\n->");
size_t s = fread(message, 1, sizeof message - 1, stdin);
message[s] = '\0';

If you want to read only one line of text, you could use fgets.  If you want to use scanf to read only one line, you could do: scanf("%499[^\n]", message); (Note that this is significantly different than %499s in that it will not discard leading whitespace, and stops only at the first line break rather than the first whitespace character.)  If you want to use scanf to read the entire input stream, you could try something like scanf("%499[^\1]", message); which would probably be adequate for textual input.
Whatever input method you use, make sure you check the return value.  If scanf fails to assign an input item (eg, because the input does not match the format string), then reading that item may invoke undefined behavior.  If fread returns 0, or (in this case) 499, you will want to add logic to decide what to do.


text:
Q: "Study law at" -- American English vs. British English When you google "studying/study/studied psychology at" (or any other subject of study e.g. law) you get a lot more results from British English websites where people talk about doing a degree at a certain college or university.
I am wondering why this phrase does not appear so often in American English, even though AmE dominates google searches in all areas.
Can anybody explain?

A: The British and American higher education systems are different, in Britain a person is offered a place at universty  to study a certain subject such as law or psychology whilst still at 6th form at high school or a 6th form college. It is normally expected that a student will continue to study this subject until they graduate.
In American, as I understand it, a person will be offered a place at a university but is then able to choose to study a number of courses from those that are offered by that university. They may study some English Literature, Math, Physics and so on.This will then become their major.Subjects such as law and psychology are studied after graduation in graduate or Proffesional school.
So a British student goes to university to study a particular subject and so it appears more often in British English.


text:
Q: JavaScript get object from json file Im new to js and i dont understand how can i take an object from json file,
for example this file : local.json
{
"server": "myname",
"url": 10.0.0.1
}

I need to get the url to insert in in my js code like this, replace the 127.0.0.1 with what i have in json file at url:
import axios from 'axios';
import jsonFile from '../local.json';
const http = require("http");
const host = '127.0.0.1'; #should be 10.0.0.1 from json file

A: Your json file should be:
{
  "server": "myname",
  "url": "10.0.0.1"
}

(use double quotes)
and just use dot:
const host = jsonFile.url

A: In javascript, Specific Object value can be accessed by following three ways:

*

*DOT (.) operator
const obj = {
   "server": "myname",
   "url": "10.0.0.1"
};
const url = obj.url;
console.log(url); // 10.0.0.1

*Square bracket ([])
const obj = {
   "server": "myname",
   "url": "10.0.0.1"
};
const url = obj["url"];
console.log(url); // 10.0.0.1

*De-structuring (>=ES6)
const obj = {
   "server": "myname",
   "url": "10.0.0.1"
};
const { url } = obj;
console.log(url); // 10.0.0.1

A: You need to use the "dot" syntax.
const host = jsonFile.url

A: I assume you need to get configurations to instantiate your server.
You may like to follow below steps to instantiate settings:
Install the dependency config
It allows you to define a json file of settings.
I define the structure
you create a directory inside your project called config inside you create a json file default.json
│
config
│--- default.json
│

inside the file you write your values
{
   "server": "myname",
   "url": "10.0.0.1"
}

and to access you do the following
file = index.js
const config = require ("config");

console.log (config.get ("url"));


text:
Q: Running VB code in 64 bit Machine I am trying to debug an application in Microsoft Visual Basic. This application uses third party tools like UltraTool Bar, Active Thread, XtremeSuite etc. Some of these tools used, might be for 32 Bit. When I try running the application from code it crashes before loading WinForm. I checked for the exception in event viewer I am getting the below message.
 <Data>Application: vb6.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException at <Module>.CVPCServiceMgr.{ctor}(CVPCServiceMgr*) at <Module>.?A0x1119eba0.??__Eg_oServiceMgr@@YMXXZ() at <Module>._initterm_m(Void* ()*, Void* ()*) at <Module>.<CrtImplementationDetails>.LanguageSupport.InitializePerProcess(<CrtImplementationDetails>.LanguageSupport*) at <Module>.<CrtImplementationDetails>.LanguageSupport._Initialize(<CrtImplementationDetails>.LanguageSupport*) at <Module>.<CrtImplementationDetails>.LanguageSupport.Initialize(<CrtImplementationDetails>.LanguageSupport*) Exception Info: <CrtImplementationDetails>.ModuleLoadException at <Module>.<CrtImplementationDetails>.LanguageSupport.Initialize(<CrtImplementationDetails>.LanguageSupport*) at <Module>..cctor() Exception Info: System.TypeInitializationException</Data>

Is this issue related to running 32 applications on 64 bit machine?


text:
Q: How to parse a row(s) Currently, I retrieve a row(s) from MySQL with a query, and then I emit that row directly (using socket.io) back to the html page. At the html page, I can't seem to access the fields of the row.
For example, (given a row that has field 'id')
<html>
    <script>
    //*some code that grabs the rows here*
    for( var row in rows){
         var id = row.id;
         //do something
    }
    </script>
</html>

In that case, 'id' would be undefined. What is the proper way to handle the rows in this case? (If I do console.log(rows) before emission in the node file, it prints the correct data.)

A: in your case
for( var row in rows){
    var id = row.id;
    //do something
}

row is a String or Key of Object rows
you need to do
rows[row].id

How for...each works
var obj = {
    name:'test',
    age:12
}

for(each in obj) {
    console.log('each: ', each)
    console.log('value of each: ', obj[each])
}
//output
each: name
value of each: test
each: age
value of each: 12

A: row in your case is the key of an object/array.
So you need to do:
rows[row].id