text:
Q: Android jQuery can't load image from certain server I'm using jQuery to load some images in to a list view. The image exists under that URL but it wont show, I tried to open an other images on the server but none of them will open. If I upload the same image to Imgur or any other server jQuery can load the image.
Has someone ever encountered a similar problem with jQuery and certain servers?
boolean memCache = true;
boolean fileCache = true;

AQuery aq = new AQuery(activity, imageFavorite);
aq.id(R.id.favorite_img).image("http://abc-production.ch/_data/img/icon/20141203-103242-880.jpg", memCache, fileCache);

// Imgur Test
aq.id(R.id.favorite_img).image("http://i.imgur.com/3kQB1o7.jpg", memCache, fileCache);


text:
Q: Can I use socket.io on apigee APIS Proxies? I was trying to figure out how do this question, but I saying simple, is it possible to use the node_module socket.io on apigee APIs Proxies?

A: As of the present day, you can not use socket.io on Apigee node implementation. The node container in Apigee sits behind a standard Apigee proxy. Apigee proxies are accessible over plain http or https and allow all sort of functionalities one needs to expose APIs or control access or generate analytics . And the node piece behind the proxy can then offer a place to host more hairy implementation logic.

redpajama_set_name: RedPajamaStackExchange


text:
Q: multiple expressions for single condition result I have to change the header string of primefaces dialog, acording to a variable state in my backing bean. The condition would be the following (pseudo code):
#{backingBean.editing ? resourceBundle.edit_string resourceBundle.item.id : msg.add_string}

and the short snippet example:
<p:dialog id="dokDialog" header="#{backingBean.editing ? resourceBundle.edit_string resourceBundle.item.id : msg.add_string}" ...>
   <!-- content -->
</p:dialog>

In this example I want to display either value #{msg.edit_string} #{resourceBundle.item.id} or #{msg.add_string} according to boolean value of #{backingBean.editing}.
What I want to do is to show either Editing Item 01 or New Item in the title.
Also I get the following exeption because I have two expressions (resourceBundle.edit_string resourceBundle.item.id) for one result:
Caused by: org.apache.el.parser.ParseException: Encountered " <IDENTIFIER>

Thanks!

A: resourceBundle.edit_string resourceBundle.item.id - it's a wrong expression. You need to concatenate
String.concat may help if you are using an appropriate version of EL: resourceBundle.edit_string.concat(' ').concat(resourceBundle.item.id)


text:
Q: LaTeX Error: Something's wrong--perhaps a missing \item - Unsure, why? What am I doing wrong? (I am very new to LaTeX, and this is my 1st question, pls forgive my ignorance)
   \section*{TERM 2}
    \textbf{10 weeks} (30 hrs)
        \begin{itemize}
            \subsection*{UNIT 1: Number \& Algebra (9 wks)}
                \subsubsection*{Topic 1.2: Real Numbers}
                    \begin{itemize}
                      \item \underline{Week 1:} Sub-Topic 5
                      \item \underline{Week 2:} Sub-Topic 6
                      \item \underline{Week 3:} Sub-Topic 7
                      \item \underline{Week 4:} Sub-Topic 8
                      \item \underline{Week 5:} Sub-Topic 9
                      \item \underline{Week 6:} Sub-Topic 10
                      \item \underline{Week 7:} Sub-Topic 11
                      \item \underline{Week 8:} Sub-Topic 12
                    \end{itemize}

The error comes up at "sub-topic 5" (line 7). I'm using Overleaf, and this bit is part of a 100-page doc. This same error comes up four times. It displays well on PDF, though. I appreciate any help you can provide.

A: You combine two different types of structure:

*

*outline (sections, subsections, subsubsections)

*(nested) lists

A (nested) list should be completely inside one level of your outline, for example
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
   \section{abc}
   \begin{itemize}
      \item a
      \item b
      \item c
   \end{itemize}
   \subsection{def}
   \begin{itemize}
      \item d
      \item e
      \item f
   \end{itemize}
\end{document}

A: I think those sections subsections etc. are to change font size and shape. The standard itemize environment is not very useful. Therefore, we need to load enumitem for the extra options.
I am not sure how exactly you want the list to look like, so I added a few things like bold, italics, different fontsizes etc. and hopefully the following code will be a good start for further experimenting.

\documentclass{article}
\usepackage{enumitem}

%%% Sets global keys
\SetEnumitemKey{cancelfont}{
    before=\normalfont\normalsize}
\SetEnumitemKey{customlabel}{label={}}

%%% Sets formatting per each level of itemize
\setlist[itemize,1]{
    customlabel,
    cancelfont, before*=\LARGE\bfseries}
\setlist[itemize,2]{
    customlabel,
    cancelfont, before*=\large\bfseries\slshape}
\setlist[itemize,3]{
    customlabel,
    cancelfont, before*=\bfseries}
\setlist[itemize,4]{customlabel, cancelfont}

%%% Document
\begin{document}

\noindent
\begin{itemize}
    \item TERM 1
    \item 10 weeks (30 hrs)
    \begin{itemize}
        \item UNIT 1: Number \& Algebra (9 wks)
        \begin{itemize}
            \item Topic 1.2: Real Numbers
            \begin{itemize}
                \item \underline{Week 1:} Sub-Topic 5
                \item \underline{Week 2:} Sub-Topic 6
                \item \underline{Week 3:} Sub-Topic 7
                \item \underline{Week 4:} Sub-Topic 8
                \item \underline{Week 5:} Sub-Topic 9
                \item \underline{Week 6:} Sub-Topic 10
                \item \underline{Week 7:} Sub-Topic 11
                \item \underline{Week 8:} Sub-Topic 12
            \end{itemize}
        \end{itemize}
        \item UNIT 2: Number \& Algebra (9 wks)
        \begin{itemize}
            \item Topic 1.2: Real Numbers
            \begin{itemize}
                \item \underline{Week 1:} Sub-Topic 5
                \item \underline{Week 2:} Sub-Topic 6
                \item \underline{Week 3:} Sub-Topic 7
                \item \underline{Week 4:} Sub-Topic 8
                \item \underline{Week 5:} Sub-Topic 9
                \item \underline{Week 6:} Sub-Topic 10
                \item \underline{Week 7:} Sub-Topic 11
                \item \underline{Week 8:} Sub-Topic 12
            \end{itemize}
        \end{itemize}
    \end{itemize}
    \item TERM 2
    \item 10 weeks (30 hrs)
    \begin{itemize}
        \item UNIT 3: Number \& Algebra (9 wks)
        \begin{itemize}
            \item Topic 1.2: Real Numbers
            \begin{itemize}
                \item \underline{Week 1:} Sub-Topic 5
                \item \underline{Week 2:} Sub-Topic 6
                \item \underline{Week 3:} Sub-Topic 7
                \item \underline{Week 4:} Sub-Topic 8
                \item \underline{Week 5:} Sub-Topic 9
                \item \underline{Week 6:} Sub-Topic 10
                \item \underline{Week 7:} Sub-Topic 11
                \item \underline{Week 8:} Sub-Topic 12
            \end{itemize}
        \end{itemize}
    \end{itemize}
\end{itemize}

\end{document}


text:
Q: HTTP header, Getting particular value (string) HTTP/1.1 200 OK
Content-Language: en
Content-Type: application/json; charset=utf-8
Date: Wed, 24 Oct 2012 21:38:50 GMT
Server: nginx
Vary: Accept-Language, Cookie, Accept-Encoding
X-Ratelimit-Limit: 5000
X-Ratelimit-Remaining: 4976
transfer-encoding: chunked
Connection: keep-alive

From the header above i want the value of X-Ratelimit-Remaining. How do i store that in a variable in php.

A: Use get_headers() (Documentation) to retrieve any value from the header.

A: This is an alternate solution using Curl:
$ch = curl_init('http://example.com/');
curl_setopt_array($ch, array(
    CURLOPT_HEADER => true,
    CURLOPT_NOBODY => true,
    CURLOPT_RETURNTRANSFER => true
));

$headers = curl_exec($ch);
preg_match('/^X-Ratelimit-Remaining: (.+)$/m', $headers, $m);
list(, $remaining) = $m;

echo '$remaining: ' . $remaining;

A: As the first answer from @justderb already said, use get_headers() PHP function.
If you have a string with the header info. you can convert into an array an get it anyway.
Example:
$url = "http://www.your-web.com";
$xr = get_headers($url, 1);
echo 'The X-Ratelimit-Remaining value is: '.$xr['X-Ratelimit-Remaining'];

Or:
$url = Array(
    "0" => "HTTP/1.1 200 OK",
    "Date" => "Sat, 29 May 2004 12:28:14 GMT",
    "Server" => "Apache/1.3.27 (Unix)  (Red-Hat/Linux)",
    "X-Ratelimit-Remaining" => "4976"
);
echo 'The X-Ratelimit-Remaining value is: '.$url['X-Ratelimit-Remaining'];

Hope it helps,
good luck!


text:
Q: How to find if the heights of a triangle with given sides can make up another triangle I'm solving a problem I found on the Internet. You input 3 integers - the sides of a triangle. The goal is to tell if you can make a triangle out of the 3 heights of the triangle
I tried writing this:
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    float a, b, c, p, h1, h2, h3;
    cin >> a >> b >> c;
    p = 0.5 * (a + b + c);
    h1 = (2 * sqrt(p * (p - a) * (p - b) * (p - c))) / a;
    h2 = (2 * sqrt(p * (p - a) * (p - b) * (p - c))) / b;
    h3 = (2 * sqrt(p * (p - a) * (p - b) * (p - c))) / c;
    if (h1 * h2 > h3 && h1 * h3 > h2 && h3 * h2 > h1) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
}

But I keep getting only 70/100 points for this one. Some test has gotten a wrong answer.
Can you help me make this more accurate? Thanks!


text:
Q: ModuleNotFoundError when running python script installed via deb created using stdeb I've build a really simple Python project I'm packaging into a .deb file for installation. I've got the building of .deb working, but when I run my script via it's command, I get a ModuleNotFoundError.
My project structure is as follows:
setup.py
hello
  |
  | - __init.py__
  | - hello.py
  | - world.py

setup.py
import os
from setuptools import setup, find_packages
setup(
    name = "hello_py",
    version = "1.3",
    author = "Sion Hughes",
    author_email = "",
    description = "It's a simple hello world, but this time with 2 python file",
    license = "",
    url = " ",
    packages=find_packages(),
    entry_points = {
        'console_scripts' : ['hello = hello.hello:main',
        'command-name = hello.hello:main']
    },
    classifiers=[
        "License :: OSI Approved :: BSD License",
    ],
)

hello.py
#!/usr/bin/env python3
import world

def main():
    print("Hello, this is Siôn's python script")
    world.hello()

if __name__ == "__main__":
    main()

world.py
#!/usr/bin/env python3

def hello():
    print("Hello from another Python file")

All runs fine locally, but when I run using hello command, I get the following error:
# hello
Traceback (most recent call last):
  File "/usr/bin/hello", line 11, in <module>
    load_entry_point('hello-py==1.3', 'console_scripts', 'hello')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/hello/hello.py", line 5, in <module>
    import world
ModuleNotFoundError: No module named 'world'

Where am I going wrong to get this working? Thanks in advance.
Update: Forgot to say in the initial post, I want to be able to run the scripts in their local directory for development purposes too, not just always run via installed .deb

A: Instead of import world in hello.py, try using import .world.


text:
Q: Croogo Theme issue in localhost [Windows] I am using Croogo CMS in my Cakephp website, its working fine in server and all linux machines but it's not working properly in windows machine. Please find below issue what I am facing in my local host
PHP Version:5.3.13
Croogo Version: 1.4.3
OS: Windows 7 - 32 bit
Goal: I want to use my Cakephp default layout instead of croogo theme layout and css and js from croogo theme
Cakephp Layout location:
app/Views/Layouts/default.ctp
Croogo Theme Layout
    Views/Themed/[MyTheme]
                 default.ctp
                 css[folder]
                 js[folder]

Now problem is css and images point to this directory theme/[MyTheme]/css/style.css. But this folder structure is not available, so I am getting below error
"NetworkError: 404 Not Found - http://localentrust.dev/theme/[MyTheme]/css/style.css"
Please guide me to solve this issue. Thanks!

A: probably u have permissions issues, there is no logical reason for your css to not be displayed, the other thing i see is that your default view is not under Layouts folder, and your js and css folders should be under webroot folder. greetings


text:
Q: It seem not fetch the $_POST I'm stuck in login page. From home,user will login (form send to check_login) and from check_login user will be directed to page based on their role. However, I cannot pass through the login page. I mean I keep getting the error message from header('location: 1.php?error=1');
fyi, i've successfully connected to db. The data is there. But if I echo oci_num_rows, the result is 0..
Here is my code login.php
<form action="check_login.php" method="post" name="login">

<?php include('error-handler.php'); ?>

 Matric / Staff ID :

<input type="text" name="id" size="20" maxlength="10" onkeypress="return isNumberKey(event)" required value=""/>

Password  :

<input type="password" name="password" id="password" size="20" maxlength="8" min="6" required value="" />

<input type="submit" name="submit" value="Login"/>
 </form>

and here is my check_login.php
    <?php
ob_start();
// Inialize session
session_start();
require_once('connection.php');

//if the login form is submitted
if(isset($_POST['submit']) && !empty($_POST['submit']))
{
    $id = $_POST['id'];
    $pass = $_POST['password'];

    $stmt2= oci_parse($conn, "SELECT * FROM user1 WHERE id = '$id'")or die(oci_error());
    $check2 = oci_execute($stmt2);

     //Gives error if user dosen't exist
     $check3 = oci_num_rows($stmt2);

       if ($check3 == 0)
       {
       header('location: 1.php?error=1'); //the msg will be: you are not eligible user.
        exit();
       }
       else
       {
        while($info2=oci_fetch_array($stmt2,OCI_ASSOC+OCI_RETURN_NULLS))
            {
            //gives error if the password is wrong
            if ($pass != $info2['password'])
            {
            header('location: 1.php?error=2'); //password mismatch with id
            exit();
            }
            else
            {
            // if login is ok then we add a cookie
            $_SESSION['id'] = $_POST['id'];
            $_SESSION['password'] = $_POST['password'];
            $hour = time() + 86400;

            setcookie(ID_site, $_SESSION['id'], $hour);
            setcookie(Pass_site, $_SESSION['password'], $hour);

            //then redirect them to the members area
                if ($info2['role']=='admin')
                {
                header('Location: homeAdmin.php');
                }
                elseif ($info2['role']=='staff')
                {
                header('Location: homeStaff.php');
                }
                elseif ($info2['role']=='student')
                {
                header('Location: homeStudent.php');
                }
                else
                {
                header('Location: 1.php');
                }

            } //end else

         } //end while

}//end else

}// end if submit
 else
{
 header('Location: 1.php');
 }

 ?>

Please share your opinion or pls correct if i'm wrong. Thank you. :)

A: From PHP manual 'oci_num_rows' : http://php.net/manual/en/function.oci-num-rows.php

This function does not return number of rows selected! For SELECT
  statements this function will return the number of rows, that were
  fetched to the buffer with oci_fetch*() functions.


text:
Q: CSS div display not working I want the div #aboutBlurb to appear on #aboutLink:hover. I am using Foundation 5.2's grid system if that is of any relevance. Here is my code:

     About

blah

#navBar a.circleLink:hover
{
    background-color: #bc2029;
    color:white;
}
#aboutBlurb
{
    text-align: center;
    position: absolute;
    width:100%;
    font-size: 2em;
    display:none;
}
#navBar #aboutLink:hover + #aboutBlurb
{
    display:block;
}

I have tried using the ~ and > selectors as well as no selector also.

A: I know you asked for a CSS answer, but doing this with JavaScript is fairly easy. If you have jQuery installed just add this line:
$( "#aboutLink" ).hover(function() {
  $( '#aboutBlurb' ).show();
});

A: To fix this need to change your DOM order please check this

#navBar a.circleLink:hover
{
    background-color: #bc2029;
    color:white;
}
#aboutBlurb
{
    text-align: center;
    position: absolute;
    width:80%;
    font-size: 2em;
    color: red;
    display: none;
}
#aboutLink:hover + #aboutBlurb
{
    display:block;
}

     About

blah


text:
Q: Calling two functions within another function in Gatling is not working I am trying to execute multiple HTTP calls within one function
Main:
def requestChain: ChainBuilder = {
    feed(feeder(dataSource))
    .exec(cleanTransactions("Revoke Transaction"))
  }

Now within this method, I am calling 2 other methods which do different http calls. the first call saves the result (Array)in a getLicensesForDevice_TA session variable. When iterating through variable, I am trying to Make another http call based on the elements in the Array. However, it seems that the second call (revokeLicense) for some reason is not executed (The problem does not have to do with the If statement, I already checked that). When calling revokeLicense direkt in the requestChain, it is executed correctly.
private def cleanTransactions(methodeName:String, device:String, returnCode:Integer ): ChainBuilder = {
    exec(getLicensesForDevice(methodeName, device, 200))
      .foreach("${getLicensesForDevice_TA}", "deleteLicensesForDevice_TA") {
        exec(session => {
          val gatlingTransactionID = session("deleteLicensesForDevice_TA").as[String].trim
          session.set("gatlingTransactionID", gatlingTransactionID)
        })
        if ("${gatlingTransactionID}".contains("TestTA")){
          exec(revokeLicense(methodeName,"${gatlingTransactionID}",204,false))
        }else{
          exec(session => {
            println("No TA will be executed: ${gatlingTransactionID}" )
            session
          })
        }
      }
  }

A: That can't work. As explained in Gatling's documentation, you can't use Gatling DSL inside Scala functions. Gatling DSL methods are just builders that build components once at boot time.

Gatling DSL components are immutable ActionBuilder(s) that have to be chained altogether and are only built once on startup. The results is a workflow chain of Action(s). These builders don't do anything by themselves, they don't trigger any side effect, they are just definitions. As a result, creating such DSL components at runtime in functions is completely meaningless. If you want conditional paths in your execution flow, use the proper DSL components (doIf, randomSwitch, etc)


text:
Q: IE11 Input type = Number I'm working with angular 4.3, I have an input field with input type number. I'm trying to restrict the user from entering any characters/letters. However, input type number is not fully supported and allows me to enter characters such as "ABCDEFG" within the input field. What would be the best approach to restrict letters?
<input type="number"/>

A: If number doesn't work, I usually suggest to go for <input type="text" pattern="\d+"/>.
You can of course change your pattern to anything number-related (like (\d|[1-5]\d|60) to set min to 0 and max to 60)


text:
Q: How do I set a certain sequence of audio files programmatically? I'm looking to play short WAV files (about 1 second each) in certain sequences. The sequences are one measure of 16th notes, segmented into 4 parts, that are generated randomly. An example random sequence would be the following. Each
"x" is a note and each "-" is a rest : "|x - - - | - x x - | x - x x | x x x x |"
Right now, I can only conceive of doing a similar thing by playing sounds from a MIDI bank with Audio Toolbox. I still don't know how I would make the sounds play in that certain sequence even with the MIDI bank. Also, there are 4 sequences that should play at once. Any pointers or even a small nudge in the right direction is greatly appreciated.

A: I solved it by using the AudioKit framework. You can play your own sampled drum sounds and specify the position that they play within a measure. Too much to write in this answer. But you can go to AudioKit.io and download the playgrounds project. Inside you will see a playground file called Drum Sequencer. It explains the functionality really well!


text:
Q: PHP Switch statement error  <?php
 include 'db.php';
 $mail=$_SESSION['session_u_e_mail'];
if(!isset($_GET['edit']))
{
$_GET['edit']=0;
}
switch($_GET['edit'])
{
 case 1: echo "Value";
         break;

 case 2: echo "Value";
         break;

 default: echo "Value";
         break;

 }

I m facing problem that the values in every case is echoed twice.

A: I've just grabbed the
if(!isset($_GET['edit']))
{
$_GET['edit']=0;
}
switch($_GET['edit'])
{
 case 1: echo "Value";
         break;

 case 2: echo "Value";
         break;

 default: echo "Value";
         break;

 }

this portion and pasted onto codepad and it works fine.
Here is the working version: http://codepad.org/P8bhL5vl
It outputs just "Value".

A: There is nothing in this code that would even output your default value. No matter the input, this outputs Value. Look in db.php or the files included by it for debugging echoes.


text:
Q: How to fetch parameter value from string with linux command I want to value of RequestID parameter from the below string with linux command.
"2019-12-05 07:55:59","3c331c0f-8657-4fae-880d-351c7f41024f","info","Method : {_FLR}     Request  =>{LoginId=>42483357 ,RequestId=>546677 ,BatchId=>6 ,ServiceID=>2  ,Amount=>20000 ,From=>07058717569 ,Email=>admin@n.com ,}"

Above is the string and I need result 546677.
I have series of this kind of string I want value of RequestID parameter(value will be deferent)

A: If I get this right, you are running some shell command? Then you could forward your output into another program's input using the pipe | op.
To filter some text use grep with a regEx and then tee to create a file from the filtered output (if you have multiple strings in your output)
echo "RequestId=>546677" | grep "RequestId=>\d{6}" | tee logfile.txt

At best create your own regEx as I don't have any info about your case here.


text:
Q: Unable to deploy Django app on Bluemix with new cflinuxfs2 stack I am trying to deploy my Django app on Bluemix but I am getting following error:

What will be the solution for this?

A: This was a problem on the system at the time and was not the fault of your application. You should be able to push your code now without that error.


text:
Q: How do I set column range as variable in Excel using a macro? I have a matrix of dates with each one representing a different task, project, planned/actual start/finish. Please see the attached picture:
Screenshot of data
I have left everything in general terms as the actual names are confidential to my company. Anyhow, every row and column tells a different piece of information. Every two rows tells what project a date belongs to, and every row tell whether that date is a start or finish date. Every two columns tells what task the date belongs to, and every column states whether the date is a predicted date or an actual one.
Setting aside, what I am trying to do with this data is create a macro that will search all of these dates within a range set by the user, and list each date with the aforementioned information. So far, I have a code does this for individual rows:
Sub Sort_By_Date()

Dim StartDate As Date
Dim EndDate As Date
Dim i As Integer

StartDate = Range("F61").Value
EndDate = Range("G61").Value

'Clears out cells
Range("Z74:AD200").Value = ""

m = 74

For i = 71 To 200
If Range("C" & i).Value >= StartDate And Range("C" & i).Value <= EndDate Then
Range("Z" & m).Value = Range("C" & i).Value
Range("AA" & m).Value = Range("A" & i).Value
Range("AB" & m).Value = Range("C69")
Range("AC" & m).Value = Range("B" & i)
Range("AD" & m).Value = Range("C70")
m = m + 1
End If

If Range("D" & i).Value >= StartDate And Range("D" & i).Value <= EndDate Then
Range("Z" & m).Value = Range("D" & i).Value
Range("AA" & m).Value = Range("A" & i).Value
Range("AB" & m).Value = Range("D69")
Range("AC" & m).Value = Range("B" & i)
Range("AD" & m).Value = Range("D70")
m = m + 1
End If

If Range("E" & i).Value >= StartDate And Range("E" & i).Value <= EndDate Then
Range("Z" & m).Value = Range("E" & i).Value
Range("AA" & m).Value = Range("A" & i).Value
Range("AB" & m).Value = Range("E69")
Range("AC" & m).Value = Range("B" & i)
Range("AD" & m).Value = Range("E70")
m = m + 1
End If

...
...
...
Hopefully you can see the pattern here.
I can keep copying and pasting that If Then statement for every column, but there has to be a more efficient way to do it. I am fairly new to Excel macros (someone else actually wrote the basis of that code), so I am not sure how to make it do what I want it to. I imagine it will involve making the column letters into numbers, and then into variables, but I just don't know. I have tried looking it up, but I am having trouble applying what I found to my specific application.
So my main question: How do I get that If Then statement to repeat for every column of data I have without having to copy and paste it a million times?

A: Seems like you simply need a nested for loop:
Dim StartDate As Date
Dim EndDate As Date
Dim i As Integer, c as integer

StartDate = Range("F61").Value
EndDate = Range("G61").Value

'Clears out cells
Range("Z74:AD200").Value = ""

m = 74

'From column C to column AD
For c = 3 TO 30
  For i = 71 To 200
    If Range("C" & i).Value >= StartDate And Range("C" & i).Value <= EndDate Then
      Range("Z" & m).Value = cells(i,c).Value
      Range("AA" & m).Value = Range("A" & i).Value
      Range("AB" & m).Value = cells(69,c).value
      Range("AC" & m).Value = Range("B" & i)
      Range("AD" & m).Value = cells(70,c).value
      m = m + 1
    End If
  Next
Next

A: Turns out what I was looking for was this:
Sub Sort_By_Date()

Dim StartDate As Date
Dim EndDate As Date
Dim rwMin As Integer
Dim colMin As Integer
Dim rwMax As Integer
Dim colMax As Integer
Dim rwIndex As Integer
Dim colIndex As Integer

StartDate = Range("F61").Value
EndDate = Range("G61").Value

rwMin = 4
colMin = 3
rwMax = 37
colMax = 68

Range("L44:R2600").Value = ""

m = 44

For colIndex = colMin To colMax

    For rwIndex = rwMin To rwMax

    If Cells(rwIndex, colIndex).Value >= StartDate And Cells(rwIndex, colIndex).Value <= EndDate Then
    Range("L" & m).Value = Cells(rwIndex, colIndex).Value
    Range("M" & m).Value = Cells(rwIndex, 1).Value
    Range("N" & m).Value = Cells(2, colIndex).Value
    Range("O" & m).Value = Cells(1, colIndex).Value
    Range("P" & m).Value = Cells(rwIndex, 2).Value
    Range("Q" & m).Value = Cells(3, colIndex).Value
    m = m + 1
    End If

    Next rwIndex

Next colIndex

End Sub

Basically, I needed to switch from using Range.Value to Cells.Value and then uses indexes. However, I seem to now have a separate issue of causing a runtime error with another function that I want to include, but that's a topic for a different post. It works right now without that function, though. Thanks for your input!


text:
Q: Pan recognizer in Custom View I've added UIImageView in viewController and attached pan gesture recognizer, implemented handler and it works properly.
The problem occurs when trying the same scenario in customView, handler is never called.
UIImage in custom view has user interaction and multiple Touch enabled, as well as the UIView in the main ViewController.
please, help.
CustomView is loaded from xib:
@implementation previewView

-(instancetype)initWithCoder:(NSCoder *)aDecoder {
    DLog(@"Initializing NDGPreviewViewWithCoder - from XIB");
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self commonInit];
    }
    return self;
}

- (void)commonInit {
    //load the interface file from .xib
    [[NSBundle mainBundle] loadNibNamed:@"previewView" owner:self options:nil];

    [self addSubview:self.view];
}


text:
Q: How do you highlight a tkinter button blue on MacOS On MacOS, some buttons are highlighted blue (if they signify something important - usually in confirmation dialogs). How do you achieve this in Tkinter, if at all? I am aware that you cannot set the background of a button in Tkinter for MacOS, but I though that there might be a way to "highlight" certain buttons blue.
This is what I mean:

As you can see, one button is coloured blue.

A: It appears you're trying to change the color of the button to show the default action. In this specific case, you can set the default option to the string "active" to designate the button as the default button.
import tkinter as tk
from tkinter import ttk

root = tk.Tk()
root.geometry("300x100")

button_frame= tk.Frame(root)

save_button = ttk.Button(button_frame, text="Save", default="active")
cancel_button = ttk.Button(button_frame, text="Cancel", default="normal")

button_frame.pack(side="bottom", fill="x", padx=8, pady=8)
save_button.pack(side="right")
cancel_button.pack(side="right", padx=8)

root.mainloop()

This is designed to use the system colors, but oddly it leaves the foreground as black rather than white.

A: I believe tkinter doesn't support colored buttons for MacOS. Here is another package that does add that functionality however, It might be worth it to look at it. https://pypi.org/project/tkmacosx/


text:
Q: Phoenix: Render content_tag as HTML? Following along with this Jose Valim post, I end up with a nested tuple of HTML information from the call to #content_tag.
{:safe,
 [60, "div", " class=\"form-group \"", 62,
  [[60, "label", " class=\"control-label\" for=\"_username\"", 62, "Username",
    60, 47, "label", 62],
   [60, "textarea",
    " class=\"form-control\" id=\"_username\" name=\"[username]\"", 62,
    ["\n", "username"], 60, 47, "textarea", 62], ""], 60, 47, "div", 62]}

I would like to write a test to check the output, but I would rather check the generated HTML than the nested tuples. How can I render this result into HTML?

A: You can use Phoenix.HTML.Safe.to_iodata and IO.iodata_to_binary to convert that to a String:
iex(1)> raw = {:safe,
...(1)>  [60, "div", " class=\"form-group \"", 62,
...(1)>   [[60, "label", " class=\"control-label\" for=\"_username\"", 62, "Username",
...(1)>     60, 47, "label", 62],
...(1)>    [60, "textarea",
...(1)>     " class=\"form-control\" id=\"_username\" name=\"[username]\"", 62,
...(1)>     ["\n", "username"], 60, 47, "textarea", 62], ""], 60, 47, "div", 62]}
iex(2)> raw |> Phoenix.HTML.Safe.to_iodata |> IO.iodata_to_binary |> IO.puts

Username<textarea class="form-control" id="_username" name="[username]">
username</textarea>


text:
Q: using functions as elements in matricies: R I am a new to R and am trying to do my homework in it. I have looked many places and I cannot find any instructions as to how to make matricies that contain functions. I need my matrix [A] to have functions like cos(x) and sin(x) in them, and then I need to be able to calculate [A(o degrees)] or [A(30 degrees)] and so on. Is there any way to do this? Thanks for the help

A: This is another method of storing functions in a matrix:
M <- matrix( c( function(x) {cos(x)},
                function(x) {sin(x)},
                function(x) {tan(x)},
                function(x) {asin(x)}),
             2,2)

 M[1,1]
#-------
[[1]]
function (x)
{
    cos(x)
}

To access the contents of each list (after extracting from the matrix object) you need to use [[, and then it can be used as a function:
 M[1,1][[1]](pi)
#[1] -1

Scriven's suggest works as well and is certainly more economical:
> M2 <- matrix( c(cos, sin, tan, asin), 2,2)
> M2
     [,1] [,2]
[1,] ?    ?
[2,] ?    ?

> M2[1,1][[1]](pi)
[1] -1
> class(M2[1,1])
[1] "list"
> class(M2[1,1][[1]])
[1] "function"


text:
Q: Monte Carlo sampling and Kolmogorov–Smirnov test in practice I have two deterministic algorithms, Algorithm 1 and Algorithm 2. The first has $m$ inputs and one output, and the second has $n$ inputs and one output. The distributions of the inputs of the algorithms are assumed to be uniform distributions on $[0, 1]^m$ and $[0, 1]^n$, respectively.
Algorithm 1 is the ultimate truth, and Algorithm 2 is an approximation to Algorithm 1. I would like to study how close the distributions of the outputs of the algorithms are. To this end, I have decided to use Monte Carlo (MC) sampling and the Kolmogorov–Smirnov (KS) test. So, I draw 10000 or so independent samples from the distributions of the inputs, feed the samples into the algorithms, and apply the KS test to the resulting data.
I have a number of questions in this regard.
Question 1: How sensible it is to discard the binary answer of the KS test and to focus solely on the p-value reported by the test as a measure of the quality of the approximation of Algorithm 1 by Algorithm 2? I would like to have a metric that I can improve gradually (by adjusting Algorithm 2) instead of staring at "Reject" or "Failed to reject." Can the p-value stand on its own and serve as such a metric?
Question 2: Since it is about computer simulation, I can easily generate new sets of samples and apply the KS test over and over again. I am concerned with the consistency of the results that I am getting. More specifically, sometimes it happens that the p-value is very small, and the null hypothesis is firmly rejected. Other times the p-value turns out to be rather large, and the null hypothesis cannot be reject. I understand that MC sampling is behind the scene, and one should expect some fluctuations. However, I am wondering if there is anything one can do to get more consistent results. For example, does it make sense to average a set of p-values computed for a range of datasets?
I would appreciate any ideas, suggestions, or any other kind of thoughts regarding what I am doing. Thank you!
Regards,
Ivan


text:
Q: Rails Development Log I'm in Chapter 6 of the RoR Tutorial and can't seem to get the command 'tail -f log/development.log' to work. Using Mac OS X 10.6.6, Ruby 1.9.2, Rails 3.0.3 with RVM. I'm trying to run it in a sanboxed Rails console, here's the output of what's going on:
Trenton-Scotts-MacBook-Air:sample_app TTS$ rails c --sandbox
Loading development environment in sandbox (Rails 3.0.3)
Any modifications you make will be rolled back on exit
ruby-1.9.2-p136 :001 > tail -f log/development.log
SyntaxError: (irb):1: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
tail -f log/development.log
           ^
    from /Users/TTS/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
    from /Users/TTS/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
    from /Users/TTS/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
ruby-1.9.2-p136 :002 >

Any thoughts?

A: Tail is not a Ruby command. You should run it directly in terminal:
$ tail -f logs/development.log
#=> output
#=> ctrl+c
$ rails c --sandbox

A: You are inside the irb console. exit from irb console and try it in your shell

A: tail is a UNIX command. You need to quit ruby console first and then execute it in shell.
Or you could simply open another shell window.


text:
Q: Setting emoji in string api 22 Hello I display String from resources wtih emoji coded in this way \uD83D\uDE09, on api 25 it works perfectly but on api 22 I got this error
 JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0xf0
when I delete emoji it works perfectly.
How should I code emoji? I don't want to change min api


text:
Q: Are there T4 templates for Visual Studio that handle CRUD for ViewModels like is done for domain models? Visual Studio already has T4 templates to generate the iCRUD pages for the various Razor pages, but these are built around the input of the domain models.
I would like something similar, except input a ViewModel (to start with, all properties are from a single domain model). Default to using AutoMapper or choose to individually map the Domain Model properties to the ViewModel properties.
For instance, I have a Person domain model with 30+ properties. For a simple company phone book lookup, all I need are a few properties.  If I could create a ViewModel that had only these properties and used a T4 template to create the Index (list) razor pages, that would be done.  Then if the Powers That Be decided they wanted another property; Boom! change the ViewModel, regenerate the Razor page and be done.
This would make minor change requests easy, allow easy prevention of overposting, allow quick-and-dirty changes be done by others, elimination of possible spelling errors, etc.
If I was (much) smarter, I am quite sure the existing templates could be easily modified to handle this.
I was wondering if this was something already created.
thank you for your time.
chuck


text:
Q: How do I upload an image to firebase storage using firebase admin sdk? I'm using Next.js here. I need to upload an image to my firebase storage. But it gives me a massive amount of errors. Okay, it gives me 1 error.
Init firebase admin sdk
// firebase.js
import * as admin from "firebase-admin";
import serviceAccount from "./firebase.serviceAccount.json";

if (!admin.apps.length) {
    admin.initializeApp({
        credential: admin.credential.cert(serviceAccount),
        databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL
    });
}

const firestore = admin.firestore();
const storage = admin.storage();

c
export { firestore, storage };

Uploading image
// route.js
import {  storage } from "../../firebase";

const router = async (req, res) => {
    // ...
    // Getting file from api request and so on...
    // ...

    const file = <an instance of File object>;

    const currentTime = Date.now();
    const fileName = file.name;

    const fileTitle = `${currentTime}-${fileName}`;

    const metadata = {
         contentType: file.type
    };

    const task = storage.ref().child(fileTitle).put(file, metadata);

    task.then(snapshot => snapshot.ref.getDownloadURL())
        .then(console.log)
        .catch(console.error);

};

export default router;

error

Failed to import the Cloud Storage client library for Node.js. Make sure to install the "@google-cloud/storage" npm package. Original error: Error: EIO: i/o error, read

Although I've installed @google-cloud/storage in my package list

A: *

*Add storageBucket into your admin.initializeApp({})
if (!admin.apps.length) {
  try {
    admin.initializeApp({
      credential: admin.credential.cert(serviceAccount),
      databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL,
      storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
    });
  } catch (e) {
    console.log("Failed to initialize App: " + e);
  }
}

*Use admin.storage().bucket() instead of admin.storage()
import * as admin from "firebase-admin";
import serviceAccount from "./firebase.serviceAccount.json";

if (!admin.apps.length) {
    admin.initializeApp({
        credential: admin.credential.cert(serviceAccount),
        databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL
    });
}

const firestore = admin.firestore();
const storage = admin.storage().bucket();

export { firestore, storage };


text:
Q: Facebook page tab content width set to 810px, getting cropped horizontally and vertically I'm trying to create a Facebook Page Tab using a custom app and I cant figure out how to set the width correctly. The content is 810px, the page tab width is set to Wide (810px)and I've tried setting the canvas width/height to both fixed and fluid, neither setting seems to change anything:
http://i.stack.imgur.com/ROi0P.png
and yet I'm stuck with a horizontal scroll bar on the page tab:
https://www.facebook.com/NTCLA/app_270240146413176
How can I get rid of the scroll bars?
***UPDATE***
After more scouring, I found the answer. Here it is for anyone that is having the same issue!
http://www.hyperarts.com/blog/facebook-iframe-apps-getting-rid-of-scrollbars/

A: To save some peeps time who might still be having an issue, after the hyperarts code, I was able to get kill that vertical bar on the right by adding the overflow css to both html and body.


text:
Q: Handling exception in Dispose() I have a UnitOfWork class that commits or rolls back transactions depending on errors in the block.
class UnitOfWork: IDispose
{
        public void Dispose()
        {
                if (Marshal.GetExceptionCode() == 0
                   || Marshal.GetExceptionPointers() == IntPtr.Zero)
                {
                       // Commit
                }
                else
                {
                      // Rollback
                }
            }
        }
}

This class is used in the following manner:
try
{
    using (var uow = new UnitOfWork())
    {
        // Do something here that causes an exception
    }
}
catch
{
    using (var uow = new UnitOfWork())
    {
        // Log exception
    }
}

I have gone through this article:
Detecting a Dispose() from an exception inside using block
In the above question, Steven (one of the people who replied) mentions that if I detect an exception inside Dispose() for the "using" block from the "try" section, I can not create another UnitOfWork class in the "catch" block and log errors to the database (since the "Marshal" code in Dispose() will continue to say there is an exception), meaning the ExceptionCode and ExceptionPointers will "float" (?) from the try block to the catch block.
However, in my case, this works correctly - ie. if there is an exception in the "using (var uow = new UOW)" block in the "try" section, it correctly catches the exception and then in the catch block the "if" condition passes, causing a commit to happen and allowing me to log exceptions.
It boils down to me having an incomplete understanding of how Marshal.GetExceptionPointers() work. Can someone please confirm if my usage pattern will work correctly (so far all tests seem to show that it works correctly) and what exactly is Marshal.GetExceptionPointers() doing?

A: IDisposable.Dispose is designed to release resources, putting commit/rollback actions in it is a bad idea. The caller should know how to handle the exception and how to rollback.
using (var unitOfWork = new UnitOfWork())
{
    try
    {
        Prepare();
        Step1();
        Step2();
        unitOfWork.Commit();
    }
    catch(PrepareException e)
    {
        //no necessary to rollback, just log it
    }
    catch(FirstStepException e1)
    {
        //rollback step1
    }
    catch(SecondStepException e2)
    {
        //rollback step1 and step2
    }
}


text:
Q: Changes made to users in ADAC vs ADUC not happening In my organization I have just discovered something: When making certain changes (to users) in the AD Administrative Center (ADAC) GUI, they do not happen, versus making those same changes in ADUC GUI.
For instance, Connect:-ing a Home folder in the GUI for ADUC will create the Home folder as per the server setup. But doing the exact same thing in ADAC (connecting a drive location for the home folder) results in no folder creation. Any idea why?
TL:DR: Why would connecting a Home folder in one Active Directory GUI (the ADAC) not create the folder, while doing the same action in ADUC does create the Home folder? They should just be two GUIs performing the same back-end manipulation.

A:
Why would connecting a Home folder in one Active Directory GUI (the ADAC) not create the folder, while doing the same action in ADUC does create the Home folder?

Because it is the application that is creating the folder, not Active Directory.  This is not strictly just a back-end call to Active Directory to perform a task - this is separate task that is performed by ADUC.  If you perform the same task in PowerShell (assigning a home folder), you will notice the folder is not auto-created.
The ADAC does have some advantages; however, this page has a nice synopsis of four things that can be done in ADAC (2012+)

*

*PowerShell History Viewer

*Active Directory Recycle Bin

*Fine-Grained Password Policy

*Global Search (functionality specific to ADAC)


text:
Q: How do I detect two fingers at touchstart in javascript? I am using .on("touchstart mousedown",function (e) {pTouchDown(e)});
Its working with one finger touch, but I want to do some operation with two-finger touch too.

A: The touch events contain a property, called touches, which contains all the touch points available. You can read more about TouchEvents on MDN.
In your case, you would need to check the length of the touches property:
someElement.addEventListener('touchstart', function (e) {
  if(e.touches.length > 1) {
    // ... do what you like here
  }
});

Or with jQuery:
$someElement.on('touchstart', function (e) {
  if (e.touches.length > 1) {
    // ... do what you like here
  }
});


text:
Q: SQL Where Clause, how do I make it so the 1st condition is dependent to the other condition How can I make it so 2 Where conditions can be dependent
For Example, a condition that has to go through a set of condition, and then find the value set on a condition within the condition prior
Here's the full syntax
SELECT
RIGHT(s.Staff_ID, 3) AS [Staff Number],
Staff_FullName,
[Sales Transaction Date] = CONVERT(VARCHAR(30), SalesDate, 107),
[Total Quantity] = SUM(Quantity)

FROM
STAFF s
JOIN
SalesTransaction st
ON s.Staff_ID = st.Staff_ID

WHERE
Staff_Country = 'China' AND
len(Staff_FullName) = (SELECT max(len(Staff_FullName)) FROM STAFF)

GROUP BY
s.Staff_ID,
Staff_FullName,
SalesDate

ORDER BY SUM (Quantity) ASC ```

How can I make it so it checks the longest value within the USA column?
Thank you in advance.

A: Assuming Your database has the columns:
table STAFF:
id            (an Int)
Staff_Country (an String)
FullName      (an String)
Staff_Name    (an String)
You could use:
SELECT id,Staff_name,MAX(LEN(Full_Name))
FROM STAFF
WHERE Staff_Country = 'USA';

So in the end, is not necessary to use two where's


text:
Q: Cocoa NSOutlineView deselect previous selection I have a NSOutlineView, some of those have children some don't. I would like to deselect, or close the previous selection when a selection is made on other cell.
I hope I can be explanatory with these screen shots.

Here we have Two Parent Folders, Folder 1 and Folder 2. I want to deselect Folder 1 on selecting the disclosure triangle of Folder 2.

Something like this, using the
-(BOOL)outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item;
-(BOOL)outlineView:(NSOutlineView *)outlineView shouldCollapseItem:(id)item;

I haven't found a way out.
Thanks

A: Implement this delegate and use something similar :
- (void)outlineViewItemDidExpand:(NSNotification *)notification{
    for (id parent in list) {
        if ([notification.userInfo objectForKey:@"NSObject"] == parent) {
            continue;
        }
        [notification.object collapseItem:parent];
    }
}

Here parent is the top level item array, as in your example Folder1 and Folder2.
EDIT:
Appdelegate.h
@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;

@property(strong) NSDictionary *firstParent;
@property(strong)  NSDictionary *secondParent;
@property(strong) NSArray *list;

@end

Appdelegate.m
@implementation AppDelegate

@synthesize firstParent;
@synthesize secondParent;
@synthesize list;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
}

- (id)init {
    self = [super init];
    if (self) {

        firstParent = [NSDictionary dictionaryWithObjectsAndKeys:@"A",@"parent",
                       [NSArray arrayWithObjects:@"Apple",@"Aeroplane", nil],@"children", nil];

        secondParent = [NSDictionary dictionaryWithObjectsAndKeys:@"B",@"parent",
                        [NSArray arrayWithObjects:@"Ball",@"Baloon", nil],@"children", nil];
        list = [NSArray arrayWithObjects:firstParent,secondParent, nil];

    }
    return self;
}

- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item{
    if ([item isKindOfClass:[NSDictionary class]]) {
        return YES;
    }
    else {
        return NO;
    }
}

- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item{

    if (item == nil) { //item is nil when the outline view wants to inquire for root level items
        return [list count];
    }

    if ([item isKindOfClass:[NSDictionary class]]) {
        return [[item objectForKey:@"children"] count];
    }

    return 0;
}

- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item{

    if (item == nil) { //item is nil when the outline view wants to inquire for root level items
        return [list objectAtIndex:index];
    }

    if ([item isKindOfClass:[NSDictionary class]]) {
        return [[item objectForKey:@"children"] objectAtIndex:index];
    }

    return nil;
}

- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)theColumn byItem:(id)item
{

    if ([[theColumn identifier] isEqualToString:@"children"]) {
        if ([item isKindOfClass:[NSDictionary class]]) {
            return [NSString stringWithFormat:@"%ld kids",[[item objectForKey:@"children"] count]];
        }
        return item;
    }
    else{
        if ([item isKindOfClass:[NSDictionary class]]) {
            return [item objectForKey:@"parent"];
        }
    }

    return nil;
}

With one more method written on top.
And set the delegate of NSOutlineView to AppDelegate in IB.


text:
Q: Most effective substring of an MD5 checksum If I want a shorter MD5 checksum, should I take the regular one and use the first half or the second half? Or does it even matter?
(obviously it would cease to be an MD5, it would just be a checksum)

A: It doesn't matter, but I'd think very hard about doing this: you'll greatly increase the chance of a collision (two different bits of data with the same checksum).

A: Use some sort of a CNC hashing function if you need a short string. Be aware that it isn't a very safe, but it will be still better than taking the half of a MD5.

A: It shouldn't matter. Generally speaking the entire checksum changes for each input byte. But if you can't decide, why not xor the first half with the second? :-)


text:
Q: Hibernate Eclipse Oxygen: Could not load AnnotationConfiguration I've been tossing and turning to solve this issue but have not been lucky. Searched around and seems to be going back to the same posts and google searches and im not going anywhere near resolving this.
As you can see the screen shot below, its saying "Could not load AnnotationConfiguration" and I do not know why. The error shows up when I add my hibernate.cfg.xml under "Configuration file". Does the DTD something to do with it? I already added annotations in pom.xml. I wanted to do a Reverse Engineering to generate the model classes from the database.
enter image description here
Here is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.cabrera.ebookr</groupId>
    <artifactId>ebookr</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.struts/struts-core -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts-core</artifactId>
            <version>1.3.10</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.struts/struts-taglib -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts-taglib</artifactId>
            <version>1.3.10</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.11</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.3.0.CR2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-annotations -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.6-Final</version>
        </dependency>
    </dependencies>
</project>

my hibernate.cfg.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- <!DOCTYPE hibernate-configuration PUBLIC -->
    <!--        "-//Hibernate/Hibernate Configuration DTD 3.0//EN" -->
    <!--        "http://www.hibernate.org/dtd/hibernate-reverse-engineering-3.0.dtd"> -->
    <!DOCTYPE hibernate-reverse-engineering PUBLIC
        "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" >
    <hibernate-configuration>
        <session-factory>
            <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="hibernate.connection.password">test</property>
            <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ebookr</property>
            <property name="hibernate.connection.username">webuser</property>
            <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        </session-factory>
    </hibernate-configuration>

I don't know if this helps also, maybe some other post, but just to give a bit of details, I was not able to create the hibernate.cfg.xml through eclipse as well because some error occurs, I figured,I'll just create it manually, not much difference right? the error was:
 Unhandled event loop exception .ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

Anyway, hope someone could help.


text:
Q: Making list items style independantly of each other I have a ul with several list items inside made up of h3s and lis with the class id of "close".
I have a hover style that expands the letter spacing on the h3s, the problem is, the items with the close class expand as well. I've tried a few different things before adding the class, like nth child etc (all which are visible in the code). I would like the close classed lis to remain the same size when the h3s are expanded.
Any help is appreciated.
jsfiddle here:
https://jsfiddle.net/snowwhyte/7eLmarnp/7/#&togetherjs=Uq5j49dUG0
CSS:
a {text-decoration:none;
}
li {list-style:none;
}
}
#openClose {
    position:absolute;
    top:200px;
    margin-top:55px;
}

#openClose li{
    list-style-type:none;
    display:block;
    padding-right:-50px;
}

#openClose li:nth-child(2n+2){
    margin:30px 0 100px 0;
    background-color:#000;
    border:2px #fff solid;
    text-align:center;
    letter-spacing:1rem;
    padding:10px 0 10px 0;
}
#openClose li:nth-child(2n+2):hover{
letter-spacing:-0.1rem;
transition:.3s;
}

#openClose li a h3{
font-family:Helvetica, Gotham, Helvetica, Arial, sans-serif;
color:#73a6c2;
}

.close{
}

#openClose li a h3:hover{color:#fff;
text-shadow:2px 1px 2px #000;
transition:.2s;
letter-spacing:1rem;
}

a:visited { text-decoration: none; color:#B8CEDB; }
a:hover { text-decoration: none; color:#D7D8D8; }
a:focus { text-decoration: none; color:#fff;

}
HTML:

Tool Descriptions

Close

Key tools

Close

Adjustment Layers &

Blending modes

Close

A: The thing is that you don't have any element with a defined width, so every elements have the width of the largest element.
To do what you're trying to achive, you have plenty of solutions depending on your needs.
You could define a fix width on one of the parents, like the ul for example and add the white-space: nowrap property to the h3 (see the fiddle) :
ul {
    width: 200px;
}
#openClose li a h3{
    white-space: nowrap;
}

You could also set a fix width on your li with the close button (see the fiddle) :
#openClose li:nth-child(2n+2){
   width: 200px;
}

A: Here is my try. Like you see i changed a little your code joining some things and clean a little, but the point is in the width property of .close
https://jsfiddle.net/7eLmarnp/12/


text:
Q: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference Tenho um fragment que através de um botão ele ira chamar o outro fragment. Mas está aparecendo o seguinte erro.
06-20 19:12:12.075 17971-17971/com.example.gerdaumanagement.gerdaumanagement E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: com.example.gerdaumanagement.gerdaumanagement, PID: 17971
                                                                                java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
                                                                                at com.example.gerdaumanagement.gerdaumanagement.adicionar_usuario.<init>(adicionar_usuario.java:158)
                                                                                at com.example.gerdaumanagement.gerdaumanagement.usuario.adicionarUsuario(usuario.java:42)
                                                                                at com.example.gerdaumanagement.gerdaumanagement.usuario$1.onClick(usuario.java:29)
                                                                                at android.view.View.performClick(View.java:5637)
                                                                                at android.view.View$PerformClick.run(View.java:22429)
                                                                                at android.os.Handler.handleCallback(Handler.java:751)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

sendo que  o fragment que chama o outro fragment é:
public class usuario extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView =  inflater.inflate(R.layout.fragment_usuario, container, false);

       // ListView listaUsuario = (ListView) rootView.findViewById(R.id.listaUsuario);
        Button botao = (Button) rootView.findViewById(R.id.addUser);
        botao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                adicionarUsuario(v);
            }
        });

        // Inflate the layout for this fragment
        return rootView;

    }

    public void adicionarUsuario(View view){

        adicionar_usuario adduser = new adicionar_usuario();

        FragmentManager manager = getFragmentManager();

        manager.beginTransaction().replace(R.id.content,adduser, adduser.getTag()).addToBackStack(null).commit();

    }

}

Segundo o erro mostrado, está com erro na linha 42, que é o trecho:  adicionar_usuario adduser = new adicionar_usuario();
e meu fragment a ser chamado é o seguinte:
public class adicionar_usuario extends Fragment {

    public adicionar_usuario() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        String TAG = "myApp";
        Log.d(TAG, "ENTROU!");
        View rootView =  inflater.inflate(R.layout.fragment_adicionar_usuario, container, false);

        Button botao = (Button) rootView.findViewById(R.id.salvar);
        botao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                salvarUsuario(v);
            }
        });

        //Alterar nome da actionbar
        ((MenuDrawer) getActivity()).setActionBarTitle("Adicionar Usuário");

        //TiPOS
        Spinner spinner = (Spinner) rootView.findViewById(R.id.tipoFunc);
        ArrayAdapter<CharSequence> adapterTiposFunc = ArrayAdapter.createFromResource(getActivity(), R.array.tipoFunc, android.R.layout.select_dialog_item);
        adapterTiposFunc.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapterTiposFunc);

        Intent intent = getActivity().getIntent();
        if(intent != null){
            Bundle bundle = intent.getExtras();
            if(bundle != null){

                usuario.setId(bundle.getInt("id"));
                usuario.setNome(bundle.getString("nome"));
                usuario.setEmail(bundle.getString("email"));
                usuario.setTipoFunc(bundle.getString("tipoFunc"));
                usuario.setNp(bundle.getString("np"));

                //nomeEt.setText(usuario.getNome());
                emailEt.setText(usuario.getEmail());

              //  senhaEt.setVisibility(View.GONE);
                salvarBt.setVisibility(View.GONE);
                //editarBt.setVisibility(View.VISIBLE);
            }
        }

        // Inflate the layout for this fragment

        return rootView;
    }

    public class usuarioData {

        private  String nome;
        private String email;
        private String np;
        private String tipoFunc;
        private String senha;
        private int id;

      /* public usuarioData(){
           this.nome = nome;
           this.email=email;
           this.np=np;
           this.tipoFunc = tipoFunc;
           this.senha = senha;
           this.id = id;
       }*/

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getNome() {
            return nome;
        }

        public void setNome(String nome) {
            this.nome = nome;
        }

        public String getEmail() {
            return email;
        }

        public void setEmail(String email) {
            this.email = email;
        }

        public String getNp() {
            return np;
        }

        public void setNp(String np) {
            this.np = np;
        }

        public String getTipoFunc() {
            return tipoFunc;
        }

        public void setTipoFunc(String tipoFunc) {
            this.tipoFunc = tipoFunc;
        }

        public String getSenha() {
            return senha;
        }

        public void setSenha(String senha) {
            this.senha = senha;
        }

    }

    private usuarioData usuario = new usuarioData();

    private EditText nomeEt = (EditText) getView().findViewById(nome);
    private EditText emailEt = (EditText) getView().findViewById(email);
    private EditText npEt = (EditText) getView().findViewById(np);
    private Spinner tipoFuncSp = (Spinner) getView().findViewById(tipoFunc);
    private  Button salvarBt = (Button) getView().findViewById(salvar);

    public void salvarUsuario(View view){

        //usuario.setNome(nomeEt.getText().toString());
        usuario.setEmail(emailEt.getText().toString());
        usuario.setTipoFunc(tipoFuncSp.toString());
        usuario.setNp(npEt.getText().toString());

        db_funcao bd = new db_funcao(getContext());
        bd.inserir(usuario);

        Toast.makeText(getActivity(), "Usuário inserido com sucesso!", Toast.LENGTH_SHORT).show();
    }

}

e seguindo o erro apresentado no logcat, apresenta erro nessa linha: ` private EditText nomeEt = (EditText) getView().findViewById(nome);
`
Alguém sabe  motivo do problema?

A: o método findViewById deve ser chamado quando sua view já existe, no caso do fragment, a view só é criada no método onCreateView.
Então você poderia fazer assim:
    private EditText nomeEt;
    private EditText emailEt;
    private EditText npEt;
    private Spinner tipoFuncSp;
    private  Button salvarBt;

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        String TAG = "myApp";
        Log.d(TAG, "ENTROU!");
        View rootView =  inflater.inflate(R.layout.fragment_adicionar_usuario, container, false);

nomeEt = (EditText) rootView.findViewById(nome);
emailEt = (EditText) rootView.findViewById(email);
npEt = (EditText) rootView.findViewById(np);
tipoFuncSp = (EditText) rootView.findViewById(tipoFunc);
salvarBt = (EditText) rootView.findViewById(salvar);

}


text:
Q: Conditionally Formatting Rows in VBA dynamically colours the cells incorrectly I recorded a macro to conditionally format some rows in excel using vba, but when I try to run it a second time, or when I try looping it for a dynamic selection of range, it paints the cells the wrong colour and in the wrong direction.  I want the cells to be painted from red to white, high to low, but the code paints the cells orange to white, low to high. Here is my code:
Sub ConForm()

Sheets("Percentage").Activate

Dim lastRow, currRow As Integer
Dim rng As Range

lastRow = Sheets("Percentage").Range("B250").End(xlUp).Row
currRow = 9

For currRow = 9 To (lastRow - 1)
    'Range("F" & currRow & ":AL" & currRow).Select

    Set rng = Sheets("Percentage").Range("F9:AL9") '"rng_ConForm" & currRow)
    rng.Select

    rng.FormatConditions.AddColorScale ColorScaleType:=2
    rng.FormatConditions(1).ColorScaleCriteria(1).Type = _
        xlConditionValueLowestValue
    With rng.FormatConditions(1).ColorScaleCriteria(1).FormatColor
        .Color = RGB(255, 255, 255)
        .TintAndShade = 0
    End With
    rng.FormatConditions(1).ColorScaleCriteria(2).Type = _
        xlConditionValueHighestValue
    With rng.FormatConditions(1).ColorScaleCriteria(2).FormatColor
        .Color = RGB(255, 0, 0)
        .TintAndShade = 0
    End With
    rng.FormatConditions(1).ScopeType = xlSelectionScope

Next currRow
End Sub

Does anyone know what's going on here? Thanks
Edit: Here is the data after running. Before being run for the first time, all conditional formatting is cleared
A) After running once

B) After running twice


text:
Q: How to navigate to the Current location in Google Maps using Android Framework? Can someone help me out in navigating from some location to my current location ?
Actually I was able to see my current location on my application. But if I see another location which is far away from my current location in the Google map then I want to navigate to the current location by clicking on a Button.
I have a Menu Item in my Options menu called My Location. On click this Item I want to navigate to my location from the other location that I am watching on Google Maps.
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.mylocation:
                showCurrentLocation();
                return true;
            case R.id.menuItem1:
                showSatelliteView();
                return true;
            case R.id.menuItem2:
                showTrafficView();
                return true;
            case R.id.menuItem3:
                exitApplication();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    private void showCurrentLocation() {
       mapView.getController().animateTo(myLocationOverlay.getMyLocation());
    }

All the others are working fine. But when I click on My Location(id = mylocation) its giving exception on the Emulator.
It gives the following Error on my LogCat.
09-19 15:04:58.445: ERROR/AndroidRuntime(1634): Uncaught handler: thread main exiting due to uncaught exception
09-19 15:04:58.455: ERROR/AndroidRuntime(1634): java.lang.NullPointerException
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.google.android.maps.MapController.setCenter(MapController.java:345)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.location.mylocation.MyLocation.showCurrentLocation(MyLocation.java:126)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.location.mylocation.MyLocation.onOptionsItemSelected(MyLocation.java:108)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.app.Activity.onMenuItemSelected(Activity.java:2170)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:525)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.view.View.onTouchEvent(View.java:4179)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.widget.TextView.onTouchEvent(TextView.java:6540)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.view.View.dispatchTouchEvent(View.java:3709)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.os.Looper.loop(Looper.java:123)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at android.app.ActivityThread.main(ActivityThread.java:4363)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at java.lang.reflect.Method.invokeNative(Native Method)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at java.lang.reflect.Method.invoke(Method.java:521)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
09-19 15:04:58.455: ERROR/AndroidRuntime(1634):     at dalvik.system.NativeStart.main(Native Method)

A: Use LocationManager to obtain coordinates of current location and pass them to mapView.getController().animateTo(GeoPoint). Be aware when translating obtained Location to GeoPoint: the latitude and longitude obtained from Location should be multiplied by 1,e+6 (1 000 000).


text:
Q: How can you use two WSDLs and maintain a test instance with a C# application? I have created a service that communicates with the SalesForce platform via C#, using their WSDL. It so happens that SalesForce (rather logically) allows for "sandbox" instances of its platform and "production" instances of its platform. My application is designed to work with production, but I have been using the sandbox to integration test and unit test. I am now reaching the point where I need to deploy to production. However, I face a large problem in that if I ever need to build and test new features, I will have to update the WSDL from the production instance to the sandbox instance, then swap back and forth as I add new features. This is because the two WSDLs are entirely different and I have to generate code from them! This is not only sloppy, it's dangerous. I could affect some of my live system data.
I would like to find a way to use a registry key, a text value, or some configuration setting that tells my application which WSDL to use. Trouble is? I can't figure out how one could approach that. The very objects my code is referencing are generated from that WSDL. Any ideas?

A: WSDLs shouldn't be entirely different between the two! Of course unless a lot of new objects and custom fields has been created in the sandbox and not yet pushed to production...
Is there any chance you've mixed the enterprise (strongly typed version) and partner (more generic one) WSDLs? Check this help topic for more info: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_quickstart_intro.htm#choose_wsdl
If you're truly concerned about data model you might decide to use partner version (generated code is bit ugly then because it gives you generic sObjects instead of more specific Account, Contact etc). I was always fine with enterprise version (the stuff from sandboxes eventually made it up to production and once different systems started to rely on the data model teams just started to sync their releases if possible).

Way to distinguish them that worked for me was to examine the endpoints (at the very bottom of the file). I was doing PHP integrations so for me it wasn't a problem to flip the endpoint on the fly but "trust" the same object structure. No idea how it looks like in C# world, where does this piece of information end up in the parsed code... Good luck!
Enterprise - Sandbox
<service name="SforceService">
<documentation>Sforce SOAP API</documentation>
<port binding="tns:SoapBinding" name="Soap">
    <soap:address location="https://test.salesforce.com/services/Soap/c/26.0/(18 char sandbox Id)"/>
</port>
</service>

Enterprise - Production
https://login.salesforce.com/services/Soap/c/26.0/(prod id)

Partner WSDLs have "u" in the URL instead of "c" and they don't carry specific organisation's id: https://test.salesforce.com/services/Soap/u/26.0"/
(my small trick to memorize this is to think about it as "Client" or "Customized" and "Universal")
Edit:
of course if you'll stick to "enterprise" the only endpoint you can really count on is production. Sandbox org ids change every time they're refreshed.


text:
Q: Tag merge request: [address-bar] and [addressbar] On StackOverflow, there are 46 questions tagged addressbar and 23 tagged address-bar. They describe the same thing as far as I can tell. I think they should be merged.

A: All of the questions tagged with addressbar have been merged over into address-bar and I've suggested an edit to the tag wiki to transfer that over, since it didn't have one.


text:
Q: Problems about Vector spaces Show that the set $V = \{p(x):p(x)$ is a polynomial with real coefficients and $p(3)=0\}$ is a vector space.
The p(3)=0 is throwing me off. To show V is closed under vector addition, I would show that for some polynomial f(x) and g(x) f(x)+g(x) would have to be closed under vector addition but how would p(3)=0 fit into f(x)+g(x).

A: We already know that the set of all polynomials is a vector space, so all you have to do is to prove that $V$ is a vector subspace of it using vector subspaces criterion, i.e, $0\in V$ and $\forall P,Q\in V,\forall a,b\in\mathbb{F},\, P+(-Q)\in V$ where $\mathbb{F}$ is the field where we're working (generally $\mathbb{R}$ or $\mathbb{C}$). The way you prove the last thing is similar to how you can show what you're asking for: closure under $+$, i.e:$$\forall P,Q\in V,\,P+Q\in V$$
So let $P,Q\in V$ (they are arbitrary choosen which fits with $\forall P,Q\in V$). Thus $P(3)=Q(3)=0$.
Now, since $V$ equals the set of polynomials for which 3 is a root, we have:$$P+Q\in V\Leftrightarrow(P+Q)(3)=0$$
But we know that $(P+Q)(X)=P(X)+Q(X)$ so in particular $(P+Q)(3)=P(3)+Q(3)$. What can you say?


text:
Q: How to add new child of many to many relation in cakephp parent add form? I'm learning cakephp for some time and it's very nice, I'm using the cake bake to create my classses.
Suppose I have a animal entity and a food entity and they have a many to many relation, and I'm on the add animal view, how can I add the option to add 3 new foods to this animal on this view? and what should the controller code look like in the add funciton?

A: Think of it like a BlogPost with Tags. To enter the tags on the entry form you'll have a text input field.
In the add/edit action of the controller, you need to explode the contents of the text input and save each one separately.
When you come to edit the BlogPost, you must join the tags into a string again so that it can be used to populate the text input field for addition or removal of tags.
This link should help: http://mrphp.com.au/code/working-habtm-form-data-cakephp


text:
Q: Laravel Bootstrapper Tables Chaining Methods I'm trying to work with Laravel and the bootstrapper bundle - frankly I'm not sure whether this is a laravel question or a bootstrapper question.  However, I'm trying to figure out how to generate a table with relational data.
What I want to do is create a table with an added column that displays the roles a user has.  My tables are based on Authority's model so they are all standard with a user, role, and role_user table.
Obviously the method in the chain that is tripping me up is the 'roles' method, I can't figure out how to get the roles for a given user.  The rest of the table works as expected.
 echo Table::striped_open();
 echo Table::headers('ID','Name', 'Email', 'Roles');
 echo Table::body($users)
    ->ignore('password', 'created_at', 'updated_at')
    ->order('id','name','email')
    ->roles(function($users) {
        return $users['id']->roles();
        });
 echo Table::open();

A: You can't do $users['id']->roles() because that doesn't make sense : you fetch an integer and then try to call something on it. What happens if you do $users->roles() ?

A: I'm sure this is academic at this point, given the question is months old, but I figured I'd answer it to help the community at large.
You do it like this:
echo Table::striped_open();
echo Table::headers('ID','Name', 'Email', 'Roles');
echo Table::body($users)
   ->ignore('password', 'created_at', 'updated_at')
   ->order('id','name','email')
   ->roles(function($user) {
       return User::find($user['id'])->roles();
       });
echo Table::open();

You had two issues.
The first is that you were trying to pass the $users object into the closure. You don't want to do that, partially because you could run into variable collision issues, and partially because that closure is executed on each row that's rendered, so using the singular doesn't lead to any confusion.
The second is that you were assuming that the $user argument passed to the closure is an instance of your model. It's not. It's an array of the model's properties. So if roles() is a relationship of your model, then you have to actually retrieve the model that's being converted to an array and passed into the closure.
Hope this helps!


text:
Q: Confusion about auto keyword in C++ I'm confused by the following piece of code:
#include <iostream>
using namespace std;

int *foo()
{
   //Operation
}

int main ()
{
        auto int ret = foo();
}

I compiled the above code under GCC, but I got the following error:
error: two or more data types in declaration of 'ret'
         auto int ret = foo();

But, if I remove int type, like so:
auto ret = foo();

then it runs successfully.
auto is a storage class and int is a data type, then why do I get the error "two or more data types" in the first case?

A: auto is not a storage class. It used to be, before C++11. But it was completely useless, so the keyword was re-purposed to allow automatic type inference. So when you say:
auto int ret = foo();

You are basically declaring the object to have 2 types (or possibly the same type twice), and that is an error. And when you say:
auto ret = foo();

The type of ret is determined by whatever the function foo returns, which is int* in this case.

A: You wrote that:

auto is a storage class

but this is no more true in C++11 (or later). The auto keyword has been reused for something completely different (some limited kind of type inference). The former C++03 or C99 auto storage class is now (in C++11) always implicit and should not use the auto keyword.
(if you like type inference, C++11 is not doing it very well, but C++14 or C++17 have progressed on it; Ocaml has a much more powerful and interesting Hindley-Milner type inference which is more "global"; that is why I wrote "some limited kind")

A:
auto is a storage class

That used to be true before C++11 but not any more.
Starting from C++11, the meaning of the word has been changed. It is now used to automatically deduce types. See http://www.stroustrup.com/C++11FAQ.html#auto.

Why in first case I got an error "two or more data types"?

By using
auto int ret = foo();

you are trying to specify two types for ret -- one deduced and the other explicitly specified.
If you want to use an explicitly specified type, you can use:
int ret = *foo(); // Since foo() returns a pointer.

or
int* ret = foo();

or you can let the compiler deduce the type by using:
auto ret = foo();

A: auto is NOT a storage class (not anymore since C++11) C++11 brings the keyword allowing the compiler to infer what is the type required for the variable you are declaring.
so basically doing auto int myVar is as invalid as string double myVar2 or bool long myVar3... the variable can have only one data type defining it, and in your case the keyword auto does that...
how to get rid off the error:
Remove the int type and just use auto, doing so will let the compiler to *AUTO***matically infer that type of the variable **ret is exactly that  from what foo() returns :) just genial!
auto ret = foo();

from the doc:

For variables, specifies that the type of the variable that is being
  declared will be automatically deduced from its initializer. For
  functions, specifies that the return type is a trailing return type or
  will be deduced from its return statements (since C++14). for non-type
  template parameters, specifies that the type will be deduced from the
  argument


text:
Q: Android - Get thread id - returns always 0 with this SO-approach I am trying to get a threads id.
I use this approach :
How to get Android Thread ID?
But the recommended way always returns 0.
This line does,what it should
Thread.currentThread.getID().
Which is the right one ?

A: Thread.currentThread().getId();
According to Documentation

Returns the thread's identifier. The ID is a positive long generated on thread creation, is unique to the thread, and doesn't change during the lifetime of the thread; the ID may be reused after the thread has been terminated.

android.os.Process.myTid();
According to Documentation

Returns the identifier of the calling thread, which be used with setThreadPriority(int, int).

According to my understanding, Thread.currentThread().getId(); will return the Thread Id by which a user or running program can identify a thread while on the other hand android.os.Process.myTid(); will provide the id by which the processor or running machine identifies a thread and this will be unique and I do not think the same id by this can be assigned to any other thread once it is dead.

A: These are 2 different things.
Thread.currentThread().getID();

returns the thread ID of the Thread within the Virtual machine as long.
android.os.Process.myTid();

returns the "Thread identifier" as an int. "Thread identifier" is a value that can be used to control processes at the Linux level and has nothing to do with the Virtual machine. This value is used in calls to android.os.Process.setThreadPriority() and android.os.Process.getThreadPriority().


text:
Q: Recursion error in Python function Python code
def find(*num):
    i =0
    if num[i] != None:
        print(num[i])
        return find(i+1)

Result
RecursionError: maximum recursion depth exceeded in comparison

How can I stop at the end of index?

A: It looks like you're trying to print the value of the last (positional) argument passed to the function.
This should work:
def find(*num):
    print(num[-1])

A: You end up with error because you did not set "recursion end" condition. Basically what you have to add is something like:
def find(*nums):
    if <your condition>:
        return

    ... logic ...

It is hard to say what exactly should be there, since I don't quite understand what you are trying to accomplish.

A: Your function will throw RecursionError every time when your list is 50 elements or longer because that is default recursion depth in python. Also, it will throw IndexError if your list is shorter than 50 elements because you does not set an end list condition.
If you want to print all numeric elements in list, you could use a single loop:
def find (*num):
    for entry in num:
        if entry is not None:
            print (entry)

if you absolutely wanted a recursion solution, then you need to modify recursion depth and resourse used and add exit condition:
import resource, sys
//be wary, your memory usage could went waaay up
resource.setrlimit(resource.RLIMIT_STACK, (2**29,-1))
sys.setrecursionlimit(10**6)

def find (*num):
    if len(num)==0:
        return None
    current, tail = num[0], num[1:]
    if current is not None:
        print (current)
    find (tail)


text: Q: how to manage system groups with active directory accounts So I have a bunch of Ubuntu 20.04 laptops that are added to a Windows Active Directory using sssd. I don't know the specific usernames of the users that are going to sign in on the laptops, but they all have the format username@domain.grp. I want a way, to have the users automatically added to the following groups as soon as they sign in on the computer (or at least give them the privileges of these groups): adm cdrom sudo dip plugdev lpadmin lxd sambashare, for example by adding this: %domain\ users@DOMAIN.GRP ALL=(ALL:ALL) ALL to /etc/sudoers, I managed to give each user who has that username format sudo privileges.


text:
Q: After raise event control not given to caller immediately I have an asp.net mvc 4.7.2 site.  I have class that raises event and I handle the event in another class.  So my code looks something like:
        RedirectDeleting?.Invoke(this,new RedirectDeletingArgs(contentId,culture));

        _redirectUrlService.Delete(id);

        RedirectDeleted?.Invoke(this,new RedirectDeletedArgs(contentId,culture));

In the handler my code looks like:
RedirectsService.RedirectDeleted += RedirectsService_RedirectDeleted;

        private void RedirectsService_RedirectDeleted(object sender, RedirectDeletedArgs e)
    {
        RemoveRedirectFromStorage(e);
    }

I am expecting the event RedirectDeleting to be raised first, then control going to the handler so in my other class the method RedirectsService_RedirectDeleted should be called.
What is happening is the event is raised execution in class raising event continues then my event gets handled by which time its too late.  My handler needs to execute before the method _redirectUrlService.Delete is called.
I am not doing anything async etc.  Am i missing something or doing something wrong?


text:
Q: Find $x, y\in\mathbb Z$ such that $\frac{x}{2} + \frac{x}{y} - \frac{3}{2} = \frac{10}{y}$ Find $x, y\in\mathbb Z$ such that $\dfrac{x}{2} + \dfrac{x}{y} - \dfrac{3}{2} = \dfrac{10}{y}$
My try
$$\dfrac{x}{2} + \dfrac{x}{y} - \dfrac{3}{2} = \dfrac{10}{y} \iff \dfrac{y}{2} = \dfrac{-x + 10}{x-3} \ \ (x\neq 3,\ 10, \ y\neq 0, \ x, \ y\in\mathbb Z)$$
Let $t = \dfrac{y}{2} = \dfrac{-x + 10}{x-3}.$ We have $y = 2t\neq 0,$ and $x = \dfrac{3t + 10}{t + 1} = 3 + \dfrac{7}{t+1}.$
Then, $x\in\mathbb Z \Leftrightarrow (t+1)|7 \Leftrightarrow t\in \{-8, -2, 6\}.$
Hence, $$x\in \{-4, 2, 4\}, \mbox { and } y\in \{-16, -4, 12\}.$$

A: Note that listing possible values as sets is not concise enough as it suggests that, for example, x=4 and y=-16 work as a solution. Instead you should pair your answers.
Also, the method you used does give correct solutions, but it is not exhaustive. Rather, try a more standard Diophantine decomposition method.
$$ (y+2)(x-3) = 14  $$


text:
Q: How do I organize different Agents together in anylogic? Through my model, I have 3 types of agents. Currently, I can only know the total number of A in Source. But my purpose is to know the number of A, B, and C respectively through Source. So logically, I need to put Agent of A, B and C together and then count their number separately. However, I cannot find a way to achieved it?

A: Depending on how the agents are generated, but a good approach would be to have a separate source for each agent (A, B and C) and count number of agents emitted from each source. This can be done by calling source.out.count(), where source is a Source object, out is the exit port and count() is a counter that shows the number of agents as a small blue number.