text:
Q: Transaction doesn't work when instantiating eloquant from a class I try to use transactions OUTSIDE laravel. it works when I include the db instantiation right in my index file as is:
use Illuminate\Database\Capsule\Manager as Db;

$db = new Db;

$db->addConnection( [
    'driver'    => Settings::DATABASE_DRIVER,
    'host'      => Settings::DATABASE_HOST,
    'database'  => Settings::DATABASE_NAME,
    'username'  => Settings::DATABASE_USERNAME,
    'password'  => Settings::DATABASE_PASSWORD,
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => ''
] );

# Make this Capsule instance available globally via static methods... (optional)
$db->setAsGlobal();

I can then elsewhere use code like this:
Db::connection()->beginTransaction();

# Create blog post in the database and return its id
$blogPostRecordId = ( new BlogDbModel() )->create( $_POST );
Db::connection()-> rollBack();

it will correctly work and rollback: no row is created in db.
However, If I get an instance of the db from a class, it won't work:
class DbSql
{

    /**
     * Use the eloquent query builder and orm. Bypass PDO interface.
     * @return Capsule
     */
    public function db()
    {
        $capsule = new Capsule;

        $capsule->addConnection( [
            'driver'    => Settings::DATABASE_DRIVER,
            'host'      => Settings::DATABASE_HOST,
            'database'  => Settings::DATABASE_NAME,
            'username'  => Settings::DATABASE_USERNAME,
            'password'  => Settings::DATABASE_PASSWORD,
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => ''
        ] );

        # Make this Capsule instance available globally via static methods... (optional)
        $capsule->setAsGlobal();

        // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
        //$capsule->bootEloquent();

        return $capsule;
    }
}

and then use
( new DbSql() )->db()->getConnection()->beginTransaction();

# Create blog post in the database and return its id
$blogPostRecordId = ( new BlogDbModel() )->create( $_POST );
( new DbSql() )->db()->getConnection()->rollBack();

it simply won't work and the transaction is ignored. Why does getting the db instance from a class instantiation make the process fail ? I would prefer to use an instance as needed.

A: Solution: the db instance must be exactly the same everywhere the transaction is needed:
$dbInstance = ( new DbSql() )->db();

Then use $dbInstance wherever the transaction is to be followed:
$dbInstance->connection()->beginTransaction();

as well as with any db eloquent operation. So pass the $dbInstance as needed. The good thing is that it can be anywhere in you code: in your models, controllers....
Then finish:
 $dbInstance->connection()->commit();

If the system is not able to reach this last line, nothing will be committed to the db.


text:
Q: Toggle div visibility with cookie remember I'm a serious newbie in JS, and I have this function that changes div style from none to block and reverse, and I need it to set a cookie and remember state, so when I navigate off the page and return it hides or shows the div as previously selected. Can anyone help me with that?
This is the simple code I have for now:
function toggle(id) {
var e = document.getElementById(id);
e.style.display = ((e.style.display!='none') ? 'none' : 'block');
}

How do i make it save and use the cookie in browsers? Thanks.

A: you should set the cookie when user leaves the page This done in body tag's "onunload" event. Like:
onunload="setCookie(c_name,value,exdays)";

c_name is a name for your cookie. Such as "divVisibility". value is your cookie's value, such as "visible". exdays is the number of days your cookie will expire in.
on page load, check the value of cookie with getCookie(c_name). Set div's visibility according its value.
Functions i told to use and information about cookies: http://www.w3schools.com/js/js_cookies.asp

redpajama_set_name: RedPajamaStackExchange


text:
Q: Is there a limit to how many cells I can assign to an array? I am trying to assign all the values from a column to an array using VBA.
Dim all_datapoints() As Variant

With ActiveSheet
    'get number of datapoints in the desired column
    n = .Cells(1, 4).End(xlDown).Row

    'assign column values to array
    all_datapoints = Application.Transpose(.Range(.Cells(1, 4), .Cells(n, 4)))

End With

The value of n is about 240,000 but the array all_datapoints() only contains 42,783 datapoints. I looked over my datasheet and there are no N/A, Error, or missing values in this column (should just be a column of strings). I am not sure why it refuses to get the rest of the data.
Even if I include ReDim all_act_molecules(1 to n) before assigning the range, it limits to only grab the first 42,783 values. Help!


text:
Q: An answer includes too much noise before getting to the point. Should it be edited or removed? This is the post in question.
The answer first describes a "bad" process, and that description is at least half of the answer. The way the answer is presented (in steps) makes it seem like a step-by-step process for solving the problem described in the question. However, most of these steps are irrelevant.
In this case, should the answer be edited, or is that too significant an edit to be made?

A: If I found an answer with too much noise before the actual answer, I would edit it to have the solution up top as a tldr; and maintain the original content of the answer below it.
It may read like "noise" to you, but I often find that longer answers contain some valuable information and are usually worth reading if you are really trying to understand the problem. In addition, the person posting the answer probably put a lot of time and thought into what they were going to say, and simply removing all that seems like an unconstructive or even hostile action, and will likely be rolled back
So don't remove this information, but do edit the answer to provide a tldr summary at the top for people who don't have time to read through the rest of the answer.
As for the specific question you linked, I don't think it contains too much "noise", as it's only 6 bullet points. And about your concern that it looked like the bullet points were listing what you should do, the very first line is

The steps people usually go through when facing these problems are:

which I think clearly state that these are not the steps you should take, but are the steps usually taken by people in this situation. And honestly if someone follows a set of bullet points found online without actually taking the time to read any of the other text, I think they deserve whatever they get ;)
But anyways, I suppose you could also edit that answer to add the solution to the very top of the answer so there are no mistakes, but I wouldn't remove any of the existing answer.

A: I would edit the post. You're not really changing the nature of the post at all, you simply want to put it in a format that will increase clarity.
Edits of this nature are always allowed, as long as they maintain the original intent of the author.
And by intent, I mean the actual meat of the answer, not the authors intent of bulleting certain items or of formatting something in bold).


text:
Q: How can I configurate CMakeLists.txt on CLion when startup? I use Clion. When i create new project, this files are being created:

*

*CMakeLists.txt

*main.cpp
But i wanna main.c file. Every new project i have to create manualy. I dont know cmake usage. Anyone help, how set the startup files, variables and conditions?
For example, i will guess clearly:

*

*In the generated CMakeLists.txt contain this:
cmake_minimum_required(VERSION 3.5)
project(test)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES "main.cpp")
add_executable(test ${SOURCE_FILES})

*but i wanna like this when startup:
cmake_minimum_required(VERSION 3.5)
project(test)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES "main.c")
add_executable(test ${SOURCE_FILES})

And like this i want add another initial conditions. How can edit this?

A: C project template is not yet supported. Should be added when this is implemented: CPP-860


text:
Q: Unpickling a dictionary produces sticky values To familiarize myself with Python data structures and popular modules, I'm designing an RPG (yes, at the time I thought it was a novel idea). My 'hero' class has two attributes specifically that aren't behaving consistently before and after saving and loading my gamefile via Pickle. I've carefully verified correct syntax in my code against several examples, and now feel confident that there must be some underlying behavior at work that I don't understand.
The first attribute of my 'hero' class is inventory, which initializes as an empty list. The second attribute is equipment, which is a dictionary of the form
{'Mainhand': '', 'Offhand': '', ... etc.}

I can equip and unequip instances of my Gear class by assigning the object as the value of the equipment slot in this dictionary, and everything works beautifully until I try these things from a loaded savefile. If I try to unequip something, the line of code
hero.equipment[k] = ''

is completely ignored with no error message or crash. I can swap gear, but cannot simply unequip any slot, as I could before saving/loading.
What am I not understanding about how Pickle unpacks saved dictionaries of objects? What is making my values feel so... sticky?
EDIT::
These are the functions that save and load my files based on the hero's name given at startup.
def save_game():
    filename = str(hero.name) + ".pkl"
    with open(filename, 'wb') as outfile:
        pickle.dump(hero, outfile)
        print("Progress saved.")
        outfile.close()

def load_game():
    global hero
    filename = input("What did they call you?\n")
    filename = str(filename) + ".pkl"
    if os.path.exists(filename):
        with open(filename, 'rb') as infile:
            hero = pickle.load(infile)
            print("Previous progress loaded.")
            infile.close()
    else:
        print("You have no saved progress.")

And this is the function that unequips my items (works on new files, not on loaded files)
def unequip(self, equipping_str, unequipping_obj):
        if unequipping_obj not in hero.inventory:
            hero.inventory.append(unequipping_obj)
        ohAtkPenalty = 1
        if equipping_str == 'Offhand':
            ohAtkPenalty = 0.70
        hero.melee_boost -= unequipping_obj.melee_atk * ohAtkPenalty
        hero.magic_boost -= unequipping_obj.magic_atk * ohAtkPenalty
        hero.health_regen -= unequipping_obj.health_regen
        hero.mana_regen -= unequipping_obj.mana_regen
        hero.equipment[equipping_str] = ''
        print("You unequip your ", unequipping_obj.item_name, '.', sep='')
        unequipping_obj.quantity += 1

A: Because unequip() is a method of the hero class, all references to hero attributes should be written as 'self. ...', not 'hero. ...'
The solution is much less exciting than I anticipated, but I greatly appreciate the extra eyes on it.


text:
Q: How to spread an object into a classes properties in JavaScript Basically here's what I'm trying to accomplish.

class Person {
  constructor (obj) {
    this.first = ''
    this.last = ''
    this.age = ''

    if (obj) {
      Object.assign(this, ...obj)
    }
  }
}

const a = new Person()
console.log('Not spreading: ', a)

const b = new Person({ first: 'Alex', last: 'Cory', age: 27 })
console.log('Spreading: ', b)

Is there a way to spread an object like this to populate a class?

A: You could use deconstruction and take only the properties, you need.

class Person {
    constructor ({ first = '', last = '', age = '' } = {}) {
        Object.assign(this, { first, last, age });
    }
}

const a = new Person()
console.log('Not spreading: ', a)

const b = new Person({ first: 'Alex', last: 'Cory', age: 27, foo: 42 })
console.log('Spreading: ', b)

A: Is this what you're looking for?

class Person {
  constructor (obj) {
    this.firstName = ''
    this.lastName = ''
    this.age = ''
    if (obj) {
      Object.assign(this, obj)
    }
  }
}

const a = new Person()
console.log('Not spreading: ', a)

const b = new Person({ firstName: 'Alex', lastName: 'Cory', age: 27 })
console.log('Spreading: ', b)

A: If you're using Object.assign, you don't use spread notation; just remove the ...:

class Person {
  constructor (obj) {
    this.first = ''
    this.last = ''
    this.age = ''

    if (obj) {
      Object.assign(this, obj)     // <============ No ...
    }
  }
}

const a = new Person()
console.log('Not spreading: ', a)

const b = new Person({ first: 'Alex', last: 'Cory', age: 27 })
console.log('Spreading: ', b)

There is a proposal (currently at Stage 3, so likely to be in ES2018, and widely supported by transpilers) that does object property spread in object initializers, but that wouldn't apply to your situation where the object already exists.

A: I would personally prefer to use a seperate method as it is not possible to have multiple constructors in JS. In the following example I create new objects using a static fromObject() method which returns a new object. Therefore you can keep your normal constructor and create new objects using spread syntax as well.
Note: I am using typescript here.
export class Point {
    readonly x: number
    readonly y: number

    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
    }

    static fromObject({x, y}: {x: number, y: number}) {
        return new Point(x, y)
    }
}


text:
Q: Proving that the Laguerre polynomials do indeed solve the differential equation I am trying to show that the Laguerre differential equation, given in my homework problem as
$xL''_n(x)+(1−x)L'_n(x)+ nL_n(x) = 0$,
is indeed solved by the Laguerre polynomials in their closed sum form:
$L_n(x)=\sum_{k=0}^n \binom{n}{k}\frac{(-1)^k}{k!} x^k$
I've tried substituting the sum into the equation but I haven't been able to resolve it:
$xL''_n(x)+(1−x)L'_n(x)+ nL_n(x)$
$ = x \sum_{k=0}^n \binom{n}{k}\frac{(-1)^k}{k!}k(k-1) x^{k-2} + (1-x)\sum_{k=0}^n \binom{n}{k}\frac{(-1)^k}{k!}k x^{k-1} +n\sum_{k=0}^n \binom{n}{k}\frac{(-1)^k}{k!} x^k$
$=\sum_{k=0}^n \binom{n}{k}\frac{(-1)^k}{k!} [xk(k-1)x^{k-2}+(1-x)kx^{k-1}+nx^k]$
$=\sum_{k=0}^n \binom{n}{k}\frac{(-1)^k}{k!} [(k^2-k)x^{k-1}+kx^{k-1}-kx^k+nx^k]$
$=\sum_{k=0}^n \binom{n}{k}\frac{(-1)^k}{k!} [k^2 x^{k-1}+(n-k)x^k]$
$=\sum_{k=0}^n \binom{n}{k}\frac{(-1)^k}{k!} [x^{k-1}(k^2+(n-k)x)]$
What am I doing wrong? How would I show that this equals zero? Or is this the completely wrong approach? I've seen various similar questions here but they always either work with a different version of the differential equation, or with recurrence relations - which I am hesitant to use, since my homework problem has not introduced the recurrence properties of the Laguerre polynomials so I'd have to derive and prove them before being allowed to use it in my proof.
Beyond the closed sum form I am also given the Rodrigues form of the polynomials:
${\displaystyle L_{n}(x)={\frac {\mathrm {e} ^{x}}{n!}}{\frac {\mathrm {d} ^{n}}{\mathrm {d} x^{n}}}{\bigg (}x^{n}\mathrm {e} ^{-x}{\bigg )}}$
But substituting those into the differential equation only leads me to terms with $L_{n+1}$ and $L_{n+2}$.
Can anybody tell me how to approach this? Is there any way to prove that the polynomials in either of these two forms satisfy the above differential equation? Or is there no way around the recurrence relations and shall I prove these first, even though they were mentioned neither in my lecture nor the homework problem?

A: We have
$$x{{L}_{n}}''\left( x \right)+\left( 1-x \right){{L}_{n}}'\left( x \right)+n{{L}_{n}}\left( x \right)=0$$
where
$${{L}_{n}}\left( x \right)=\sum\limits_{k=0}^{n}{\left( \begin{matrix}
   n  \\
   k  \\
\end{matrix} \right)\frac{{{\left( -1 \right)}^{k}}}{k!}{{x}^{k}}}$$
As you have done, substitute to get
$$\sum\limits_{k=0}^{n}{\left( \begin{matrix}
   n  \\
   k  \\
\end{matrix} \right)\frac{{{\left( -1 \right)}^{k}}k\left( k-1 \right)}{k!}{{x}^{k-1}}}+\left( 1-x \right)\sum\limits_{k=0}^{n}{\left( \begin{matrix}
   n  \\
   k  \\
\end{matrix} \right)\frac{{{\left( -1 \right)}^{k}}k}{k!}{{x}^{k-1}}}+n\sum\limits_{k=0}^{n}{\left( \begin{matrix}
   n  \\
   k  \\
\end{matrix} \right)\frac{{{\left( -1 \right)}^{k}}}{k!}{{x}^{k}}}=0$$
Then cancel terms and collect
$$\sum\limits_{k=0}^{n}{\left( \begin{matrix}
   n  \\
   k  \\
\end{matrix} \right)\frac{{{\left( -1 \right)}^{k}}{{k}^{2}}}{k!}{{x}^{k-1}}}+\sum\limits_{k=0}^{n}{\left( \begin{matrix}
   n  \\
   k  \\
\end{matrix} \right)\left( n-k \right)\frac{{{\left( -1 \right)}^{k}}}{k!}{{x}^{k}}}=0$$
Note that the first term in the first sum is zero so re-index, and collect terms
$$\sum\limits_{k=0}^{n}{\left\{ \left( \begin{matrix}
   n  \\
   k+1  \\
\end{matrix} \right)\frac{{{\left( k+1 \right)}^{2}}}{\left( k+1 \right)!}-\left( \begin{matrix}
   n  \\
   k  \\
\end{matrix} \right)\left( n-k \right)\frac{1}{k!} \right\}{{\left( -1 \right)}^{k}}{{x}^{k}}}=0$$
It's very easy using the definition of the binomial coefficients to show
$$\left( \begin{matrix}
   n  \\
   k+1  \\
\end{matrix} \right)\left( k+1 \right)-\left( \begin{matrix}
   n  \\
   k  \\
\end{matrix} \right)\left( n-k \right)=0$$

A: I shouldn't do your homework for you, but I'll  verify it the fast way, which your teacher appears to hint at: the Sheffer sequence. See wikipedia.
The point is it's much easier to use operator (Heaviside) calculus, and the tasteful Rodrigues representation
$$  L_{n}(x)={\frac { e  ^{x}}{n!}} \partial^n   (  e  ^{-x} x^n )=
{\frac { (\partial-1)^n } {n!}}~~  x^n.
$$
The equality holds by virtue of (NB operators acting on everything to their right),
$$
 \partial ~~  e^{-x} f(x) = e^{-x} (\partial-1) f(x) ~,
$$
hence,
$$
e^x \partial ~  e^{-x} = \partial-1, ~~~\leadsto ~~~ e^x \partial^n ~  e^{-x} = (\partial-1)^n~,
$$
by intercalating $e^{-x} e^x=1$s among powers of the gradient.
Now, likewise, easily show the identity (recall the commutator of quantum mechanics!)
$$
\bbox[yellow]{x(\partial-1)^k = (\partial-1)^k x - k(\partial-1)^{k-1}}.
$$
We then, for $n>1$, plug this representation into Laguerre's second order linear equation, multiplied by $(n-1)!$,
$$
{1\over n} x (\partial -1)^n (\partial^2 x^n -\partial x^n) + {1\over n} (\partial -1)^n  (\partial x^n + n x^n )\\
= x (\partial -1)^{n+1}  x^{n-1}    +  (\partial -1)^n  (x^{n-1}+ x^n) \\ = (\partial -1)^{n+1}(x   x^{n-1}) -(n+1) (\partial -1)^{n} x^{n-1} +  (\partial -1)^n  (x^{n-1}+ x^n) \\ =
(\partial -1)^{n} \Bigl((\partial -1) x^n -(n+1) x^{n-1} +x^{n-1}+ x^n\Bigr )=0.
$$
In the penultimate line, we used the above identity for $k=n+1$.
So, the Rodrigues expression satisfies the Laguerre equation, alright. Heaviside calculus is something effective you should be able to use, anyway.


text: Q: How to add a placeholder in an ActiveX textbox in an excel sheet? In an excel worksheet, I have an ActiveX textbox (not from a UserForm) where I want to put placeholders in it, and when the user types his data down, the placeholder goes away.


text:
Q: PHP String to Int Conversion Losing Value (using simple_html_dom) so I'm using simple_html_dom to parse a page for elements with a particular class. I successfully retrieve those elements but cannot seem to get them converted into usable variables (ie an integer so I can do an 'if' statement).
It seems they are an object of some kind, and I've searched everywhere for hours, but no luck. There doesn't seem to be much support for simple_html_dom.
Here's my code:
///////////////
$html = new simple_html_dom();

// Load a file
$html->load_file($getURL);
$getName = $html -> find('.ddlabel', 0);
$getSeats = $html->find('.dddefault', 3);
///////////////

$scraped_name = "$getName";
$scraped_seats = "$getSeats";

$seats = intval($scraped_seats);

echo $scraped_name . "
" . $scraped_seats . "

";
echo gettype($seats) . "
" . $seats . "
";

// If seats are avavilable, send a message
if ($seats !== 0) { ... }

Some of the echos are just for purposes of me trying to figure this out. Also I might add that all this code in in a foreach() loop, not sure if that matters. I'm reading a csv file of things to append to a url and that's what the foreach() loop is for. But I don't think that's messing with the problem I have.
Thanks for any help!

A: According to the documentation you would have to extract the content:
$scraped_seats = (int)$getSeats->plaintext;


text:
Q: Plank not starting: cannot find libwnck-3.so.0 I'm running Ubuntu 21.04 and Gnome40.
Two days ago I read (on reddit) about gnome 40 and how to install it on Ubuntu. Since I have some issues with the stock desktop environment, I thought "why not give it a try". So I installed it and everything works fine.
While searching how to get the application-menu on the left hand side of the screen back, like it is in the stock environment, I came across plank (and the dash to plank gnome extension) which caught my eye. So I installed both and again it worked fine and looked awesome.
Today, however an update notifcation popped up and I updated and restarted my system. After that I noticed, that my docker / plank bar was gone. So I looked around and searchend and via terminal I found out, that plank wouldn't start because of following error:
plank: error while loading shared libraries: libwnck-3.so.0: cannot open shared object file: No such file or directory

After unsuccessfully searching the internet for some hours and trying different "solutions" like removing and installing again, forcing a reinstall, trying to install libwnck-3-0 and so on, I finally completely removed ubuntu from my pc, wiped both disks and did a fresh install. (Was overdue anyway).
But even with this fresh install, plank won't start due to the same error.
So if someone knows a solution to this problem I would highly appreciate it. :)
If you have further questions, please feel free to ask.
Thanks in advance.

Output of apt-cache policy gnome-shell plank libwnck-3-0:
gnome-shell:
  Installiert:           40.1-0shemgpubuntu2
  Installationskandidat: 40.1-0shemgpubuntu2
  Versionstabelle:
 *** 40.1-0shemgpubuntu2 500
        500 http://ppa.launchpad.net/shemgp/gnome-40/ubuntu hirsute/main amd64 Packages
        100 /var/lib/dpkg/status
     3.38.4-1ubuntu2 500
        500 http://de.archive.ubuntu.com/ubuntu hirsute/main amd64 Packages
plank:
  Installiert:           0.11.89-3
  Installationskandidat: 0.11.89-3
  Versionstabelle:
 *** 0.11.89-3 500
        500 http://de.archive.ubuntu.com/ubuntu hirsute/universe amd64 Packages
        100 /var/lib/dpkg/status
libwnck-3-0:
  Installiert:           1:40.0-1shemgpubuntu5
  Installationskandidat: 1:40.0-1shemgpubuntu5
  Versionstabelle:
 *** 1:40.0-1shemgpubuntu5 500
        500 http://ppa.launchpad.net/shemgp/gnome-40/ubuntu hirsute/main amd64 Packages
        100 /var/lib/dpkg/status
     3.36.0-1 500
        500 http://de.archive.ubuntu.com/ubuntu hirsute/main amd64 Packages

A: You have to reinstall the packages:
sudo apt-get install --reinstall plank libwnck-3-0=3.36.0-1

A: Raffa states that: "Ubuntu 21.04 chooses Wayland by default and this can happen after an upgrade. Plank runs on X11."
you can check this answer in: Plank is not working after upgrade to Hirsuite Hippo


text:
Q: comparing string gone wrong I got the output as unequal can you please explain me why
#include <stdio.h>

int main()
{
    char str1[] = "hello";
    char str2[] = "hello";

    if (str1 == str2)
        printf("equal");
    else
        printf("unequal");

    return 0;
}

A: That's because == is comparing the addresses of str1 and str2 and not the
contents of the string. You have to use strcmp for this:
#include <stdio.h>
#include <string.h>
int main()
{
    char str1[]="hello";
    char str2[]="hello";
    if(strcmp(str1, str2) == 0)
        puts("equal");
    else
        puts("unequal");
    return 0;
}

would be the correct version. See https://ideone.com/wJpL2I
Note that in C a string is just a sequence of characters that end with the
'\0'-terminating byte. str1 and str2 are both arrays, but when you do
str1 == str2 they decay into pointers and what you are comparing is the memory
location of where the arrays are stored in memory. They are two different arrays
(although they have the same content), so they memory address will be of course different, that's why you get unequal. That's why you need the
strcmp function in order to compare the contents of the char arrays.

A: You are comparing the data container's address which are str1 and str2, if you know java then there is that equals method and contentEquals method, if you use equals method it compares the object references, but if you do contentEquals it compares the content(data) resides in the objects.
In c as you should have already known that that the name of the string has the base address in it. That's the reason you don't need to put &(address of operator) while using the scanf this is the soul reason when you do the str1==str2 it compares the address not the data inside the string.
In c str1 and str2 are simply 2 character array which has the \0 at the end. Now when you do
if(str1==str2) //it compares the address of
//variables not the content as
//you are comparing the base address
//of the strings str1 and str2.

The right version should be:
#include <stdio.h>
#include <string.h>
int main()
{
char str1[]="hello";
char str2[]="hello";
if(strcmp(str1, str2) == 0)
    puts("equal");
else
    puts("unequal");
return 0;
}

If you want to verify that you can use this, printf("%d", &str1); printf("%d", &str2); they both will not be equal.

A: When you want to compare two strings, you actually want to see if each character in one string is in the corresponding position of the other string.
The strings variables used here (str1 and str 2) are just pointers to the base addresses of those strings.
Hence, str1 == str2 means you are just comparing if both strings have the same base addresses, which, of course, is incorrect.
Here, you can make use of the string.h file which has the strcmp() or string compare function.
It works like this:
It iterates through the string, and checks the difference in the ascii values of individual characters in corresponding positions(same index value). If all characters are the same, it will return 0.
Otherwise, a positive or negative value is encountered based on the order of passing the strings to strcmp.
But in this case, it is of little importance if you get a positive or a negative value.
usage:
if (!strcmp(str1, str2))
     puts("equal");
 else
     puts("unequal");


text:
Q: blueprint css rails 3.1 help My blueprint css works on my local machine, but when I push to heroku I get an error.
I have blueprint stored in my app/assets/stylesheets folder and here are the stylesheet tags I'm using:
<%= stylesheet_link_tag    "application" %>
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
<%= stylesheet_link_tag 'blueprint/print',  :media => 'print' %>

In my heroku logs, it says application.css isnt precompiled and I think that might be the error, but I don't know how to fix it.
Here is my heroku logs:
2011-09-04T07:35:59+00:00 heroku[web.1]: Idling
2011-09-04T07:36:00+00:00 heroku[web.1]: State changed from up to down
2011-09-04T07:36:00+00:00 heroku[web.1]: State changed from down to created
2011-09-04T07:36:00+00:00 heroku[web.1]: State changed from created to starting
2011-09-04T07:36:01+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-04T07:36:01+00:00 app[web.1]: >> Stopping ...
2011-09-04T07:36:01+00:00 heroku[web.1]: Process exited
2011-09-04T07:36:04+00:00 heroku[web.1]: Starting process with command `thin -p 44288 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-04T07:36:07+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-04T07:36:07+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-04T07:36:07+00:00 app[web.1]: >> Listening on 0.0.0.0:44288, CTRL+C to stop
2011-09-04T07:36:08+00:00 heroku[web.1]: State changed from starting to up
2011-09-04T08:41:45+00:00 heroku[web.1]: Idling
2011-09-04T08:41:46+00:00 heroku[web.1]: State changed from up to down
2011-09-04T08:41:46+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-04T08:41:46+00:00 app[web.1]: >> Stopping ...
2011-09-04T08:41:47+00:00 heroku[web.1]: Process exited
2011-09-04T16:05:59+00:00 heroku[slugc]: Slug compilation started
2011-09-04T16:06:10+00:00 heroku[api]: Deploy 9ec665f by XXXXXXXX@yahoo.com
2011-09-04T16:06:10+00:00 heroku[api]: Release v9 created by XXXXXXXX@yahoo.com
2011-09-04T16:06:11+00:00 heroku[slugc]: Slug compilation finished
2011-09-04T16:06:19+00:00 heroku[web.1]: Unidling
2011-09-04T16:06:19+00:00 heroku[web.1]: State changed from down to created
2011-09-04T16:06:19+00:00 heroku[web.1]: State changed from created to starting
2011-09-04T16:06:21+00:00 heroku[web.1]: Starting process with command `thin -p 32066 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-04T16:06:25+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-04T16:06:25+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-04T16:06:25+00:00 app[web.1]: >> Listening on 0.0.0.0:32066, CTRL+C to stop
2011-09-04T16:06:26+00:00 heroku[web.1]: State changed from starting to up
2011-09-04T16:06:27+00:00 app[web.1]:
2011-09-04T16:06:27+00:00 app[web.1]:
2011-09-04T16:06:27+00:00 app[web.1]: Started GET "/" for 65.7.186.42 at 2011-09-04 09:06:27 -0700
2011-09-04T16:06:28+00:00 app[web.1]:
2011-09-04T16:06:28+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"):
2011-09-04T16:06:28+00:00 app[web.1]:
2011-09-04T16:06:28+00:00 app[web.1]:
2011-09-04T16:06:28+00:00 app[web.1]:
2011-09-04T16:06:28+00:00 app[web.1]: cache: [GET /] miss
2011-09-04T16:06:28+00:00 heroku[router]: GET corporatefox.heroku.com/ dyno=web.1 queue=0 wait=0ms service=754ms status=404 bytes=728
2011-09-04T16:06:28+00:00 heroku[nginx]: 65.7.186.42 - - [04/Sep/2011:09:06:28 -0700] "GET / HTTP/1.1" 404 728 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30" corporatefox.heroku.com
2011-09-04T16:06:35+00:00 app[web.1]:
2011-09-04T16:06:35+00:00 app[web.1]:
2011-09-04T16:06:35+00:00 app[web.1]: Started GET "/pages/home" for 65.7.186.42 at 2011-09-04 09:06:35 -0700
2011-09-04T16:06:35+00:00 app[web.1]:   Processing by PagesController#home as HTML
2011-09-04T16:06:35+00:00 app[web.1]: Rendered pages/home.html.erb within layouts/application (17.0ms)
2011-09-04T16:06:35+00:00 app[web.1]: Rendered layouts/_stylesheets.html.erb (25.3ms)
2011-09-04T16:06:35+00:00 app[web.1]: Completed 500 Internal Server Error in 92ms
2011-09-04T16:06:35+00:00 app[web.1]:
2011-09-04T16:06:35+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
2011-09-04T16:06:35+00:00 app[web.1]:     1: <%= stylesheet_link_tag 'application' %>
2011-09-04T16:06:35+00:00 app[web.1]:     2: <%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
2011-09-04T16:06:35+00:00 app[web.1]:     3: <%= stylesheet_link_tag 'blueprint/print',  :media => 'print' %>
2011-09-04T16:06:35+00:00 app[web.1]:   app/views/layouts/_stylesheets.html.erb:1:in `_app_views_layouts__stylesheets_html_erb__1720273165801032019_31408840'
2011-09-04T16:06:35+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___1444640675865794326_32133320'
2011-09-04T16:06:35+00:00 app[web.1]:
2011-09-04T16:06:35+00:00 app[web.1]:
2011-09-04T16:06:35+00:00 app[web.1]: cache: [GET /pages/home] miss
2011-09-04T16:06:35+00:00 heroku[router]: GET corporatefox.heroku.com/pages/home dyno=web.1 queue=0 wait=0ms service=120ms status=500 bytes=728
2011-09-04T16:06:35+00:00 heroku[nginx]: 65.7.186.42 - - [04/Sep/2011:09:06:35 -0700] "GET /pages/home HTTP/1.1" 500 728 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30" corporatefox.heroku.com
2011-09-04T16:06:42+00:00 app[web.1]:
2011-09-04T16:06:42+00:00 app[web.1]:
2011-09-04T16:06:42+00:00 app[web.1]: Started GET "/" for 65.7.186.42 at 2011-09-04 09:06:42 -0700
2011-09-04T16:06:42+00:00 app[web.1]:
2011-09-04T16:06:42+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"):
2011-09-04T16:06:42+00:00 app[web.1]:
2011-09-04T16:06:42+00:00 app[web.1]:
2011-09-04T16:06:42+00:00 app[web.1]:
2011-09-04T16:06:42+00:00 app[web.1]: cache: [GET /] miss
2011-09-04T16:06:42+00:00 heroku[nginx]: 65.7.186.42 - - [04/Sep/2011:09:06:42 -0700] "GET / HTTP/1.1" 404 728 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30" corporatefox.heroku.com
2011-09-04T16:14:42+00:00 heroku[slugc]: Slug compilation started
2011-09-04T16:14:53+00:00 heroku[api]: Deploy 2fed989 by foxgrade@yahoo.com
2011-09-04T16:14:53+00:00 heroku[api]: Release v10 created by foxgrade@yahoo.com
2011-09-04T16:14:54+00:00 heroku[web.1]: State changed from up to bouncing
2011-09-04T16:14:54+00:00 heroku[web.1]: State changed from bouncing to created
2011-09-04T16:14:54+00:00 heroku[web.1]: State changed from created to starting
2011-09-04T16:14:54+00:00 heroku[slugc]: Slug compilation finished
2011-09-04T16:14:56+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-04T16:14:56+00:00 app[web.1]: >> Stopping ...
2011-09-04T16:14:57+00:00 heroku[web.1]: Process exited
2011-09-04T16:14:57+00:00 heroku[web.1]: Starting process with command `thin -p 48112 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-04T16:15:01+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-04T16:15:01+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-04T16:15:01+00:00 app[web.1]: >> Listening on 0.0.0.0:48112, CTRL+C to stop
2011-09-04T16:15:01+00:00 heroku[web.1]: State changed from starting to up
2011-09-04T16:15:02+00:00 app[web.1]:   Processing by PagesController#home as HTML
2011-09-04T16:15:02+00:00 app[web.1]: Rendered pages/home.html.erb within layouts/application (13.2ms)
2011-09-04T16:15:02+00:00 app[web.1]: Rendered layouts/_stylesheets.html.erb (24.1ms)
2011-09-04T16:15:02+00:00 app[web.1]: Completed 500 Internal Server Error in 86ms
2011-09-04T16:15:02+00:00 app[web.1]:
2011-09-04T16:15:02+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
2011-09-04T16:15:02+00:00 app[web.1]:     1: <%= stylesheet_link_tag    "application" %>
2011-09-04T16:15:02+00:00 app[web.1]:     2: <%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
2011-09-04T16:15:02+00:00 app[web.1]:     3: <%= stylesheet_link_tag 'blueprint/print',  :media => 'print' %>
2011-09-04T16:15:02+00:00 heroku[router]: GET corporatefox.heroku.com/pages/home dyno=web.1 queue=0 wait=0ms service=755ms status=500 bytes=728
2011-09-04T16:15:02+00:00 app[web.1]:   app/views/layouts/_stylesheets.html.erb:1:in `_app_views_layouts__stylesheets_html_erb__4527639971944011061_33003340'
2011-09-04T16:15:02+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__2040511387187567951_33642800'
2011-09-04T16:15:02+00:00 app[web.1]:
2011-09-04T16:15:02+00:00 app[web.1]:
2011-09-04T16:15:02+00:00 app[web.1]: cache: [GET /pages/home] miss
2011-09-04T16:15:02+00:00 heroku[nginx]: 65.7.186.42 - - [04/Sep/2011:09:15:02 -0700] "GET /pages/home HTTP/1.1" 500 728 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30" corporatefox.heroku.com

A: I just had the same problem. I solved it by setting config.assets.compile = true in config/environments/production.rb
EDIT: This works fine while developing, but has a performance penalty as compilation is performed in run-time. See the answer below for a better solution

A: Try setting your:
config.assets.precompile += %w( blueprint/screen.css blueprint/print.css )

in
    config/environments/production.rb
I'm sure someone with more experience than me can tell us why all css files aren't pre-compiled as standard.  I'm only just starting out too!
Here's at least one discussion:
Rails 3.1 asset pipeline - missing files from public/assets - why isn't this the default?

A: One way to fix this is to precompile the assets by running rake assets:precompile. You have to include a javascript runtime for this by adding
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'therubyracer'
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"a
  gem 'uglifier'
end

to the Gemfile and run bundle install.

A: I tried to run rake assets:precompile and couldn't get it to work. I have the assets group in my Gemfile. I read somewhere that I should make sure to precompile the production env:
RAILS_ENV=production bundle exec rake assets:precompile
That didn't help either. I ended up doing the config.assets.compile = true, which worked fine, but I would love to get the real solution to work.
I never get the -----> Preparing Rails asset pipeline when pushing to heroku that they say one should get.


text:
Q: How to extract emails from a list of folders where the email is into the folder name in windows? I have a list of folders that has those names variations:
(there are around 700 folders, so manually is not an option)
 name name name - email@email.com
 name name name - email@email.com + email@email.com + email@email.com + email@email.com

take care about this: between the name and the email always exists:
 " - "

between emails, when exists always exists:
 " + "

I would like to take the
"name name name" and assign all the emails for each name in an excel sheet.
I think I need a batch to loop all folders, get the folder name, extract the name, extract the emails and write down in a text file. For repeted email I would like to have a another row, so each name has a single email. The names might be repeated but they refer to different emails.
Then from the text file I have to convert to a excel file.
Thanks for your help

A: Run these two command from the commandline in the directory where your direxctory tre starts.
for /D   %a in (*.*) do @echo %a >> dlist.txt

for /F "tokens=1,2* delims=-" %a in (dlist.txt) do @echo "%a" ; "%b" >> emails.csv

A: In VBA for the Excel paste this:
Option Explicit

Sub GetFileNames()
Dim i As Integer
Dim fso As Object, folder As Object, subfolder As Object
i = 0

Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("C:\Users\****\Desktop\****")

For Each subfolder In folder.SubFolders
    ActiveCell.Offset(i) = subfolder.Name
    i = i + 1
Next subfolder

End Sub

*

*Select the first col, first row

*Then click run, to run the VBA command

*This will create all the rows with the name of the folders

*Then in the B, use this formula: "=LOCALIZAR(" - ";A2)"

*In C: "=NÚM.CARACT(A2)"

*In D: "=SEG.TEXTO(A2;1;B2)"

*In E: "=SEG.TEXTO(A2;B2 + 3;C2)"

*In F: "=SUBST(E2;" + ";", ")"

In D you will get the name, and in F you will get all the emails separated by ", ".
That's all!


text:
Q: Update Carthage: Building universal frameworks with common architectures is not possible I am trying to update the carthage but I getting the following error.
.... have the same architectures (arm64) and can't be in the same fat output file

Building universal frameworks with common architectures is not possible. The device and simulator slices for "XXXX" both build for: arm64
Rebuild with --use-xcframeworks to create an xcframework bundle instead.

I have tried many ways but unable to resolve this issue. Clearing the Derived Data, restarting the XCode, switching to latest version of framework, set the Architecture to arm64 also and tried running the carthage again and again but there is no solution I found. I am running app on XCode 14.2. How it can be reesolved.


text:
Q: Log4j's ThreadContext clears the automatically I am inserting a key into ThreadContext map at the start of the application like so,
protected void doFilterWrapped(ContentCachingRequestWrapper request,
      ContentCachingResponseWrapper response, FilterChain filterChain)
      throws ServletException, IOException {
    // some code...
    ThreadContext.put(Constants.REQUEST_ID, requestID);
    ThreadContext.put(requestID + Constants.HASH + "retryCount", "-1");
    // some more code...
  }

Now in someother class I am trying to update the value of key requestID + Constants.HASH + "retryCount" like so,
String key = ThreadContext.get(Constants.REQUEST_ID) + Constants.HASH + "retryCount";
      if (ThreadContext.containsKey(key)) {
        ThreadContext.put(key, String.valueOf(Integer.valueOf(ThreadContext.get(key)) + 1));
      } else {
        ThreadContext.put(key, "-1");
      }
      System.out.println("\n\n  " + ThreadContext.get(key) + " \n\n");

But it only works once and after that it is not able to find the key, i.e ThreadContext.containsKey(key) is false.
Can someone explain me what the problem is.

A: Have you tried setting the thead context inheritable system property?  In your app startup, add this line:
System.setProperty("isThreadContextMapInheritable", "true");

With this property enabled, child threads will inherit the thread context.


text:
Q: TLS1.2 still used despite forcing use of TLS1.0 I have a customer who is trying to connect to my company's FTP server and we have asked him to force the use of TLS1.0, which he has done through a curl request (curl version : 7.29.0). However, despite the latest version of curl and the forcing of tls1.0, the connection is still using tls1.2.
Do you know why this is happening? I was wondering if maybe this was due to both protocols using different ports? Our last solution would be to ask our security or system team to review the FTP server's configuration to allow connection from tls1.0 but we would like to avoid it.
Thank you in advance for your help and let me know if something remains unclear, I can potentially provide with the output

A: The curl manpage states:

--tlsv1.0
(TLS) Forces curl to use TLS version 1.0 or later when connecting to a remote TLS server.
In old versions of curl this option was documented to allow only TLS 1.0. That behavior was inconsistent depending on the TLS library. Use --tls-max if you want to set a maximum TLS version.

--tls-max
(SSL) VERSION defines maximum supported TLS version. The minimum acceptable version is set by tlsv1.0, tlsv1.1, tlsv1.2 or tlsv1.3.
If the connection is done without TLS, this option has no effect. This includes QUIC-using (HTTP/3) transfers.
See also --tlsv1.0, --tlsv1.1, --tlsv1.2 and --tlsv1.3. --tls-max requires that the underlying libcurl was built to support TLS. Added in 7.54.0.

If that customer is really using such an outdated CURL version it might just not have support to force TLS 1.0.


text:
Q: How to factorize (decompose) the sum of matrix powers and its transpose? Suppose I have a matrix $M$, such that:
$$M = \sum_{k=0}^{\infty} c^{k}(A^{k})^{\top}DA^{k} = D + cA^{\top}DA + c^{2}A^{2\top}DA^{2} + \cdots,$$
where $c \in [0,1]$ is a scalar, D is a diagonal matrix with $(1-c)<D_{ii}<1$,
$A$ is a column stochastic matrix (sum of elements of each column is 1).
(This guarantee that this series would converge).
How can I get a facorization(decomposition) of M by $A$, such that:
$$M = R^{\top}R.$$
where $R$ is some matrix. We know that such a decomposition must exist, since $M$ is symmetric.
The problem is that I want this decomposition is expressed by $A$, i.e., $R = f(A)$, $f$ is some function work on $A$.
How can I get this decomposition (factorization) of $M$?
Thanks.


text:
Q: Optimization with LINGO The Dynamic Programming Problem
I have one optimization problem I am trying to solve with LINGO, I am a beginner with LINGO and I need some help. The question can be accessed by cliking on the 'The Dynamic Programming Problem' link above. Sorry I cant embedd images yet.
I tried to script some code to solve the problem but get syntax errors all the time. Could you give me some hint? Thanks
    sets:

    people/a,b,c,d/: pb;
    trip(people, people): time;

    endsets

    data:

    pb = 1, 2, 5, 10;

    time =

    0   2   5   10
    0   0   5   10
    0   0   0   10
    0   0   0   0;

    enddata

    min = @sum(trip(i,j): time);

I also tried this but didnt work
   trip/ab, ac, ad, bc, cd/: time;
   solo/a, b, c/: time2;
   link(trip,solo,trip,solo,trip);
   endsets

   data:
   time = 2, 5, 10, 5, 10;
   time2 = 1, 2, 5;

   enddata

   t1 = @sum(trip:solo:trip:solo:trip);

   Min = @sum(link(i));

A: Your first program runs without any syntax errors on my machine.
The only things missing are: "MODEL:" as the first line of the file, and "END" as the last line.


text:
Q: Find out the sum of the null values for an attributes depending upon class values in pandas The dataset looks like
 class       subject   computer_buy(class)
 Junior      Science   Yes
 Sophomore   Science   Yes
 Senior      Economics No
 Junior       ?        No
 Senior      Arts      No

Suppose the name of the dataset is toy_data. I want to know the how many ? values are there for the class value No
I wrote a query like that
   toy_data['subject'].isnull().sum()[toy_data['computer_buy']=='No']

The error for the above query

IndexError: invalid index to scalar variable.

What should be the right approach towards the query?
Thank you.

A: toy_data['subject'].isnull().sum() returns a scalar value like 3, 1 so you can't indexing it with [].
IIUC, you can use
out = ((toy_data['computer_buy']=='No') & (toy_data['subject'] == '?')).sum()

print(out)

1


text:
Q: Numpy not fond on pycharm but works on spyder This python code
import numpy as np

from scipy.spatial.distance import euclidean

a = np.array([5,3,4,-1,0]);
b = np.array([2,4,0,-5,-2]);

dist = euclidean(a,b);

print ("Distancia = "+ str(dist) );

simil = 1/(1+dist);

print ('Similitud = '+ str(simil) );

In spyder runs without a  problem but in pycharm I get this error message
/home/user/anaconda3/envs/prueba2/bin/python /home/user/PycharmProjects/prueba2/prueba2.py
Traceback (most recent call last):
  File "/home/user/PycharmProjects/prueba2/prueba2.py", line 1, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

and this is the project interpreter

A: pip3 install numpy
pip install numpy

use above command in terminal and install numpy for python 3.6 then
  try again.


text:
Q: Heapify a Vector in C++ I am trying to heapify a given vector passed by reference to a function. The function takes a reference to a vector as an argument and heapifies it. I'm also trying to calculate how many positions in the vector changed value as compared to the starting point. I'd like to update this difference variable inside the function.
For each position in the new and old vector: if the positions have a different value: diff++
Here's What I Have:
void heapify(std::vector<int> &v, int &diff)
{
    int max = diff;
    int l = 2 * diff + 1;
    int r = 2 * diff + 2;

    if (l < (int)v.size() && v[l] > v[diff])
        diff = l;

    if (r < (int)v.size() && v[r] > v[diff])
        diff = r;

    if (max != diff) {
       swap(v[max], v[diff]);
       heapify(v, diff);
    }
}

int main()
{
    vector<int> v = {20, 19, 100, 2};
    int diff = 0;
    heapify(v, diff);
    cout << "Different in " << diff << " positions. Heap: ";
    for(int i: v)
    cout << i << ", ";
    cout << endl;
    return 0;
}

It is really close. A couple of glitches: for a one item vector, the contents shouldn't change. For a vector that's smallest to largest from 1 to 10, the difference is off by 2. For a really large random vector, the difference is off by 1.

A: Using std::make_heap
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    std::vector<int> v = {20, 19, 100, 2};
    std::make_heap(v.begin(), v.end());

    for(int i: v)
        std::cout << i << ", ";

    std::cout << std::endl;

    return 0;
}

prints:
100, 19, 20, 2,


text:
Q: Subtract previous row value to current row and order by date Data as follows in my table
SELECT ID, VALUE, acc_no, adate
FROM TB_DailyStatement

   id    value   acc_no       adate
    ---------------------------------------------
    1     12     1      2019-01-01 07:40:38.250
    2     14     1      2019-01-02 07:41:05.883
    3     15     1      2019-01-13 07:41:22.377
    4     10     2      2019-01-14 08:15:53.403
    5     16     2      2019-01-03 13:52:47.347
    6     19     1      2019-01-09 13:53:56.317
    7      7     3      2019-01-17 00:00:00.000
    8     24     2      2019-01-17 00:00:00.000
    9     19     2      2019-01-02 00:00:00.000
    10     7     1      2019-01-07 00:00:00.000
    11    24     1      2019-01-05 14:12:47.080
    12    20     3      2019-01-28 00:00:00.000

Expected result
    id     value   acc_no       aDATE                   result
    ------------------------------------------------------------------------
    1     12     1        2019-01-01 07:40:38.250        12 (current row values of acc_no=1)
    2     14     1        2019-01-02 07:41:05.883         2 (14 (current row values)-12(previous row value of acc_no=1))
   11     24     1        2019-01-05 14:12:47.080        10 (24 (current row values)-14(previous date  value of acc_no=1))
   10      7     1        2019-01-07 00:00:00.000       -17 (7 (current row values)-24(previous date  value of acc_no=1))
    6     19     1        2019-01-09 13:53:56.317        12 (19 (current row values)-7(previous date  value of acc_no=1))
    3     15     1        2019-01-13 07:41:22.377        -4 (15 (current row values)-19(previous date  value of acc_no=1))
    9     19     2        2019-01-02 00:00:00.000        19 (12 (current row values of acc_no=2)
    5     16     2        2019-01-03 13:52:47.347        -3 (16 (current row values)-14(previous date  value of acc_no=2))
    4     10     2        2019-01-14 08:15:53.403        -6 (10 (current row values)-16(previous date  value of acc_no=2))
    8     24     2        2019-01-17 00:00:00.000        14 (24 (current row values)-10(previous date  value of acc_no=2))
    7      7     3        2019-01-17 00:00:00.000         7 (12(current row values of acc_no=3)
   12     20     3        2019-01-28 00:00:00.000        13 (20 (current row values)-7(previous date  value of acc_no=3))

I have tried the following query
SELECT
    id, t.value, acc_no, adate,
    t.value - ISNULL(v.value, 0) AS result
FROM
    TB_DailyStatementt
OUTER APPLY
    (SELECT TOP (1) value
     FROM TB_DailyStatement
     WHERE id < t.id
       AND acc_no = t.acc_no
     ORDER by id DESC) v

This returns some output, but I am not able to use order by clause i.e. adate and acc_no

A: If you want to get this result just simple order by acc_no asc you can get simple your expected result,
For example
Select * from table order by acc_no acs

A: In SQL Server 2008, you can't use LEAD & LAG, for this you can use query like following using OUTER APPLY.
select *
from  TB_DailyStatementt tout
       outer apply (select top 1 value Prev
                    from   TB_DailyStatementt t1
                    where  t1.acc_no = tout.acc_no
                           AND t1.adate < tout.adate
                    order  by t1.adate desc)t1
       outer apply (select top 1 value Next
                    from   TB_DailyStatementt  t1
                    where  t1.acc_no = tout.acc_no
                           AND t1.adate > tout.adate
                    order by t1.adate asc)t2
       order by tout.adate,acc_no

This will give you the required previous and next values depending on acc_no. Now you can apply switch case to format the string.
Check this Demo

A: Declare @ds TABLE (id int, value int, acc_no int, dt datetime)
INSERT INTO @ds
SELECT  1, 12, 1, '2019-01-01 07:40:38.250' UNION
SELECT  2, 14, 1, '2019-01-02 07:41:05.883' UNION
SELECT  3, 15, 1, '2019-01-13 07:41:22.377' UNION
SELECT  4, 10, 2, '2019-01-14 08:15:53.403' UNION
SELECT  5, 16, 2, '2019-01-03 13:52:47.347' UNION
SELECT  6, 19, 1, '2019-01-09 13:53:56.317' UNION
SELECT  7,  7, 3, '2019-01-17 00:00:00.000' UNION
SELECT  8, 24, 2, '2019-01-17 00:00:00.000' UNION
SELECT  9, 19, 2, '2019-01-02 00:00:00.000' UNION
SELECT 10,  7, 1, '2019-01-07 00:00:00.000' UNION
SELECT 11, 24, 1, '2019-01-05 14:12:47.080' UNION
SELECT 12, 20, 3, '2019-01-28 00:00:00.000'

SELECT id, value, acc_no, dt, value - previous AS result
FROM (
  SELECT ROW_NUMBER() OVER (PARTITION BY DS1.id
                            ORDER BY     DS2.dt DESC) AS rn
  ,DS1.*, COALESCE(DS2.value,0) AS previous
  FROM      @ds DS1
  LEFT JOIN @ds DS2
    ON      DS2.acc_no = DS1.acc_no
    AND     DS2.dt     < DS1.dt
) AS dt
WHERE rn = 1

In your original query, you are joining on ID, the your comments in the desired results show that you want to use the date for ordering, not the id.
So you could fix your original query by changing "id < t.id" with "adate < t.adate"

A: I think you are on the right track.  You need an order by in the outer query and to fix the table aliases:
SELECT ds.id, ds.value, ds.acc_no, ds.adate,
       (t.value - COALESCE(prev.value, 0)) AS result
FROM TB_DailyStatementt ds OUTER APPLY
    (SELECT TOP (1) ds2.value
     FROM TB_DailyStatement ds2
     WHERE ds2.id < ds.t.id AND ds2.acc_no = ds.acc_no
     ORDER by ds2.id DESC
    ) prev
ORDER BY ds.acc_no, ds.adate

A: Try this:
    Select  *, CASE WHEN LAG(value) OVER(partition by acc_no order by adate) IS NULL THEN value
    ELSE value - LAG(value) OVER(partition by acc_no order by adate) END  result from TB_DailyStatement


text:
Q: initrd /casper/initrd: verbose output In my previous question:
grub2: error: can't allocate initrd - chainload an NTFS partition from FAT32 without errors on initial ramdisk (initrd) file
I posted the error output:
error: can't allocate initrd.
Press any key to continue...

This output says nothing.
The question is:
How do I get the full output of the command: initrd /casper/initrd out, to see what generated the error?
I have tried
linux   /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed nosplash debug ignore_loglevel ---
initrd  /casper/initrd

but the error output is still the same, no rows added.
The grub.cfg file is the default.


text:
Q: Server-side debugging for Meteor App on Nitrous.io I've got a simple Meteor app running on a Nitrous box. I'd like to be able to use node-inspector for server-side debugging (as described here), but I'm unable to get to the console.
My Meteor app is running locally on the box at http://0.0.0.0:3000/, and I can view it in Chrome by following the guide here. When I then run node-inspector, I get this message:
Node Inspector v0.8.3
Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.

How can I get to this address? I've tried:

*

*Navigating to https://example-name.example-region.nitrous.io:8080/debug?port=5858

*Running: node-inspector --web-host 0.0.0.0

*Running: node-inspector --web-host https://example-name.example-region.nitrous.io
Thoughts? Is there a way I can get to this console?

A: You should change the url on the box,
usually you just run the box running the meteor command
cd workspace
cd myAPP
meteor

and it works, but now you should run this commands.
cd workspace
cd myApp
ROOT_URL=http://machinename.abc1-2.nitrousbox.com meteor

Now run again node-inspector
you should get something like
Visit http://machinename.abc1-2.nitrousbox.com:8080/debug?port=5858 to start debugging.


text:
Q: where cluase not working after security rule in google cloud this is my security rule for firebase, it throwing permission for query :
app.firestore().collection('users').where('email', '==' ,'test@gmail.com').get().then(snap => console.log(snap.docs[0].data())).catch(err => console.log("err",err));

the above query is throwing permission error!!
service cloud.firestore {
  match /databases/{database}/documents {
    // Make sure the uid of the requesting user matches name of the user
    // document. The wildcard expression {userId} makes the userId variable
    // available in rules.
    match /users/{userId} {
      allow read, update, delete: if request.auth.uid == userId;
      allow create: if request.auth.uid != null;
    }
  }
}

why ?

A: Your security rule is saying that a user can only read the document in users with an id that's the same as their authenticated UID.  But your query is trying to read any document where the email field has some value.  Since that query could possibly try to read documents other than the one that matches the UID, the query will fail every time.  With the rules you have now, the client is only allowed to get() their own specific document, with no other queries allowed.

A: You have to remember that security rules are not filters.
Example:
my uid: 123123
doc1:
   email: test@gmail.com, id: 123123
The securtiy rule will pass for doc1.
doc2: email: test@gmail.com, id: 321321
The security rule will fail for doc2.
That is because your security rule is saying that if ALL documents have the uid in then it should pass, but because it is not, it fails.
To fix this, you would need to provide some further information on how your db is setup and what you are querying. Ie, you are finding all emails which match a criteria, or something else.


text:
Q: CSV to php array separated by an empty line i am trying to pass a csv into a php array like this
Suleman Ayy
abc.com

Engr. cison
abxc@yahoo.com

Akin ABCD
abcd@gmail.com

so i can have an array in php..
this is my code, but it doesn't seem to work
$file = fopen($target_file, 'r');
$csvfile = fgetcsv($file);

$data = explode("\n", $csvfile);

foreach ($data as $line)
{
   $arr = explode("\t", $line);

// $arr[0] will have every first field of every row, $arr[1] the 2nd, ...
// Usually this is what I want when working with a csv file

// But if you rather want a multidimensional array, you can simply add
// $arr to a different array and after this loop you are good to go.
}

A: You can try this:
$csv = file_get_contents('yourfile.csv');

$newDelimiter = " ";
$arr = array();
foreach(preg_split('~\R\R~',$csv) as $line){
  $line = preg_replace('~\R~',$newDelimiter,$line);
  $arr[] = str_getcsv($line, $newDelimiter);
}

//test output
echo "<pre>";
var_dump($arr);

Output:
array(3) {
  [0]=>
  array(3) {
    [0]=>
    string(7) "Suleman"
    [1]=>
    string(3) "Ayy"
    [2]=>
    string(7) "abc.com"
  }
  [1]=>
  array(3) {
    [0]=>
    string(5) "Engr."
    [1]=>
    string(5) "cison"
    [2]=>
    string(14) "abxc@yahoo.com"
  }
  [2]=>
  array(3) {
    [0]=>
    string(4) "Akin"
    [1]=>
    string(4) "ABCD"
    [2]=>
    string(14) "abcd@gmail.com"
  }
}


text:
Q: Searching a Custom ListView with ImageView not fitlering image I am working on a project where there is a custom listview with imageview and a textview on top of the imageview.I have done the following code for filtering.
The main Fragment:
CategoriesAdapter adapter;
edt_SearchBar.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                adapter.getFilter().filter(s);

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

The CategoriesAdapter class:
public class CategoriesAdapter extends BaseAdapter {
    List<CategoryDataModel> category_list,category_filter_list;
    Context context;
    LayoutInflater inflater;
    ImageLoader imageLoader;
    ViewHolder vh;
    ValueFilter filter;
    int counter=0;
    String[] images_array;

    public CategoriesAdapter(List<CategoryDataModel> category_list, Context context) {
        this.category_list=category_list;
        this.category_filter_list=category_list;
        this.context=context;
        inflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader= AppController.getInstance().getImageLoader();
        images_array=new String[]{"kochi_cinepolis.png","kochi_padma.png"};
    }

    @Override
    public int getCount() {
        return category_list.size();
    }

    @Override
    public Object getItem(int position) {
        return category_list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView==null)
        {
            convertView=inflater.inflate(R.layout.category_view_style, null);
            vh=new ViewHolder();
            if (imageLoader == null)
                imageLoader = AppController.getInstance().getImageLoader();
            vh.imageView = (NetworkImageView) convertView .findViewById(R.id.imageView_grid);
            vh.categoryName= (TextView) convertView.findViewById(R.id.tvcategory);
            convertView.setTag(vh);
        }
        else
        {
            vh=(ViewHolder) convertView.getTag();
        }

        vh.imageView.setImageUrl(AppConstant.IMAGE_FOLDER +images_array[position], imageLoader);

        vh.imageView.setDefaultImageResId(R.drawable.default_category_loading);

        vh.categoryName.setText(category_list.get(position).getCategory_name().toUpperCase());

        return convertView;
    }
    public class ViewHolder
    {
        NetworkImageView imageView;
        TextView categoryName;
    }
    public ValueFilter getFilter() {
        if(filter==null) {

            filter=new ValueFilter();
        }

        return filter;
    }

    public class ValueFilter extends Filter {

        @Override
        protected FilterResults performFiltering(CharSequence constraint) {

            FilterResults results=new FilterResults();
            if(constraint!=null && constraint.length()>0){
                String cons_value=constraint.toString();

                List<CategoryDataModel> filterList=new ArrayList<>();

                for(int i=0;i<category_filter_list.size();i++){

                    if(category_filter_list.get(i).getCategory_name().toLowerCase().contains(cons_value.toLowerCase())) {

                        filterList.add(category_filter_list.get(i));

                    }
                }

                results.count=filterList.size();

                results.values=filterList;

            }else{

                results.count=category_filter_list.size();

                results.values=category_filter_list;

            }

            return results;
        }

        @Override
        protected void publishResults(CharSequence constraint, FilterResults results) {
            category_list=(List<CategoryDataModel>) results.values;
            notifyDataSetChanged();

        }
    }
}

The issue is the following.Now i have two items in the listview.I am searching the listview based on the text in the textview.But when the search results are returned the corresponding image of the row of the listview is shown wrongly.The image of the first row is what that is shown instead of the correct row.Please help at the earliest.

A: Your Adapter needs to implement Filterable interface and it has to implement getFilter() and than you need to override getFilter() in your custom adapter and filter the data source accordingly and notify the listview that the dataset has changed.


text:
Q: Nagios core High availability setup Is there any solution available for master and slave steup in nagios, if master fails nagios must survey. Please suggest your ideas or links. Thanks in advance

A: Nagios Core doesn't natively support HA (XI does so). You need to constantly check your master/slave and synchronize (e.g. rsync, puppet, ...) your retention.dat between them if one host fails.

A: I have a master and slave  setup ,we use a script which will run from crontab  and basically do the below tasks
1) do a custome plugin check
/usr/lib/nagios/plugins/check_nrpe -t 30 -H  $MASTER -c check_nagios &>/dev/null
2) copy the data via rsync
rsync -ae ssh $MASTER:/var/log/nagios/status.* /var/log/nagios/
3) enable notifications and event handlers on slave server.


text:
Q: Drop the duplicate of a certain column when there are many duplicate columns I have a dataframe with multiple duplicate columns but I would like to drop the duplicate of the "class" column while keeping other duplicate columns intact. Below you can see there are many duplicate columns. However, I am only interested in dropping the "class" column and keep one copy of it only. The other columns should stay intact and row number should not change.
Dataframe:
train = pd.DataFrame({'class': {0: 1,
  1: 2,
  2: 3,
  3: 4,
  4: 5,
  5: 6,
  6: 7,
  7: 8,
  8: 1,
  9: 2,
  10: 3,
  11: 4,
  12: 5,
  13: 6,
  14: 7,
  15: 8},
 'class.1': {0: 1,
  1: 2,
  2: 3,
  3: 4,
  4: 5,
  5: 6,
  6: 7,
  7: 8,
  8: 1,
  9: 2,
  10: 3,
  11: 4,
  12: 5,
  13: 6,
  14: 7,
  15: 8},
 'class.2': {0: 1,
  1: 2,
  2: 3,
  3: 4,
  4: 5,
  5: 6,
  6: 7,
  7: 8,
  8: 1,
  9: 2,
  10: 3,
  11: 4,
  12: 5,
  13: 6,
  14: 7,
  15: 8},
 'x_feature_1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'x_feature_1.1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'x_feature_2': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'y_feature_1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'y_feature_2': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'y_feature_2.1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'z_feature_1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'z_feature_1.1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'z_feature_2': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296}})

expected:
expected = pd.DataFrame({'class': {0: 1,
  1: 2,
  2: 3,
  3: 4,
  4: 5,
  5: 6,
  6: 7,
  7: 8,
  8: 1,
  9: 2,
  10: 3,
  11: 4,
  12: 5,
  13: 6,
  14: 7,
  15: 8},
 'x_feature_1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'x_feature_1.1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'x_feature_2': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'y_feature_1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'y_feature_2': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'y_feature_2.1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'z_feature_1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'z_feature_1.1': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296},
 'z_feature_2': {0: -0.30424321,
  1: 1.6273111,
  2: 0.66127653,
  3: 0.0051847840000000004,
  4: 1.2861978,
  5: -0.47925246,
  6: 1.4743277,
  7: 0.30530296,
  8: -0.30424321,
  9: 1.6273111,
  10: 0.66127653,
  11: 0.0051847840000000004,
  12: 1.2861978,
  13: -0.47925246,
  14: 1.4743277,
  15: 0.30530296}})

[in]:
train = train.loc[:,~(train["class"].duplicated())]

[out]:
IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).

Edit: Added example dataframe and expected output dataframe.

A: You can match not duplicated column with values before . with split and chaining mask by select columns starting by class:
m1 = train.columns.str.startswith('class')
m2 = train.columns.str.split('.').str[0].duplicated()
train = train.loc[:, ~m1 | ~m2]
print (train)


text:
Q: Shared variable from subreport showing wrong values on crystal report I have like 3 subreports that have running total values refer RunningTotal. There are evaluated so that it only pick unique values and sums those together. So the problem is that on the subreport the value will display for example 205 but when i create a shared formula and add it to the main report i get a value of 206.
This is the formula i used on the subreport:
WhilePrintingRecords;
Shared NumberVar GrandTotal;
GrandTotal := GrandTotal + {#RTotal1}
and below is the one i placed in the main report
WhilePrintingRecords;
Shared NumberVar GrandTotal;

Please assist.


text:
Q: Getting all embed/object elements, including those inside iframes (js/python) Trying to find all instances of flash objects on a given page, including those inside iframe elements.
Is there a way in javascript that'll account for those found inside iframes besides just
document.getElementsByTagName("embed")
document.getElementsByTagName("objects")

I'm also working with python and can grab the full source of a page, could that provide an avenue for this to work?

A: Depending on your goals, it would probably be easiest with jQuery, as Sibi suggests. However, if you have access to Python, you could use BeautifulSoup. This would be especially useful if you wish to get data behind those links in any way.
If that is the route you wish to pursue, you could do something like:
from bs4 import BeautifulSoup
soup = BeautifulSoup(page_source)

objects = []
objects.extend(soup.find_all('object'))
objects.extend(soup.find_all('embed'))

And if that misses the objects inside iframes you could add:
iframes = soup.find_all('iframe')
for iframe in iframes:
    objects.extend(iframe.find_all('object'))
    objects.extend(iframe.find_all('embed'))


text:
Q: BroadcastReceiver on Android P Since Android 9 is online and I am having a troubles to send a notification with my JobIntentService, which launched using the BroadcastReceiver .
It works great on other devices with Android <= 8.1 and I can get the notification in no time .
Sometimes It works on Android P too, but sometimes the System doesn't fire the registered services with the AlarmManager ! OR I am not able to receive it.
What is going wrong ?
AlarmReceiver.java
public class AlarmReceiver extends BroadcastReceiver {
    private static final String TAG = "AlarmReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
            onBoot(context);
        }
        Log.d("action", "i recieved an action");

        try {
            Bundle bundle = intent.getExtras();
            String message = bundle.getString("Push_Message", "No Content");
            int type = bundle.getInt("Push_Type", -1);

            Intent newIntent = new Intent(context, AppJobService.class);
            newIntent.putExtra("Push_Message", message);
            newIntent.putExtra("Push_Type", type);
            newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            AppJobService.enqueueWork(context, AppJobService.class, AppJobService.JOB_ID, newIntent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

Here I've added the Receiver to the AndroidManifest.xml
<receiver
            android:name=".notifications.AlarmReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

And I am registering the Service with the AlarmManager in this way inside a class, that inherits from JobIntentService
AppJobService.java
    public void sendTimedNotification(String message, int type, long timeInMillis) {
        Intent intent = new Intent(this, AlarmReceiver.class);
        intent.putExtra("Push_Message", message);
        intent.putExtra("Push_Type", type);

        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(timeInMillis);

        PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
        am.set(AlarmManager.RTC_WAKEUP, timeInMillis, sender);

    }

A: As Per Document:

Alarms do not fire when the device is idle in Doze mode. Any scheduled
  alarms will be deferred until the device exits Doze. If you need to
  ensure that your work completes even when the device is idle there are
  several options available. You can use setAndAllowWhileIdle() or
  setExactAndAllowWhileIdle() to guarantee that the alarms will execute.
  Another option is to use the new WorkManager API, which is built to
  perform background work either once or periodically. For more
  information, see Schedule tasks with WorkManager.

Take a look at https://developer.android.com/training/scheduling/alarms


text:
Q: Segmented control segment images In my project I am using segmented control with 3 segments. I have picture for every segment and pressed/unpressed state. Here is image:
Image link
If picture size is not matching segment size then it not fits. Is there any solution for this problem?
Thanks

A: Use - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets method of UIImage for setting image to your button. It will return you resized image for your button. Available in iOS 5.0 and later.

A: If you're using iOS 5 or later, you can use UIImage's resizableImageWithCapInsets: method to create resizable buttons for your segmented control and then just render your text on top of it. A good tutorial on this is available here.
Essentially, all you have to do is create versions of your button images that have distinct ends and centers that can be resized.


text:
Q: Show that $B \setminus C$ is connected. Let A and B be connected sets and $ A\subset B$. If C is a component of $B \setminus A$, prove that $B \setminus C$ is connected.
I have tried to solve this problem but I am really having a hard time proving it.
I hope someone can help me. Thanks a lot.

A: If $A = B$ then $C = \emptyset$ and $B \setminus C = B$ is connected. If $A = \emptyset$, then $C = B$ and $B \setminus C = \emptyset$ is connected. Assume that $A$ is a proper subset of $B$.
Let $C_i$ denote the connected components of $B \setminus A$ with $i \in I$ in some index set $I$. By definition, each connected component $C_i$ is a connected subset of $B \setminus A$ which is maximal in the inclusion order. Therefore, each $C_i$ is closed in $B \setminus A$.
Fix $k$ and assume $B \setminus C_k$ is not connected, i.e.
$$
B \setminus C_k = D_1 \cup D_2
$$
for $D_1$ and $D_2$ disjoint non-empty sets that are open in $B \setminus C_k$. We will derive a contradiction by showing that $B$ is not connected.
First, note that every $X \subset B \setminus C_k$ can be written as
$$
X = (X \cap D_1) \cup (X \cap D_2)
$$
where $X \cap D_i$ is open in $X$ for $i = 1, 2$. Therefore, every connected subset $X \subset B \setminus C_k$ is either contained in $D_1$ or in $D_2$. In particular, $A$ is contained in $D_1$ or in $D_2$ and for each $i \in I, i \ne k$, $C_i$ is contained in $D_1$ or in $D_2$.
Assume, without loss of generality, that $A \subset D_1$. Define
$$
E_1 = D_1 \cup C_k \\
E_2 = D_2
$$
and note that $E_1$ and $E_2$ are disjoint non-empty sets and $E_1 \cup E_2 = B$. We will show that both are open in $B$ by demonstrating that $E_2$ is clopen in $B$.
Recall that $E_2$ is open in $B \setminus C_k$, so there is an open set $G$ in $B$ such that $E_2 = G \cap (B \setminus C_k)$. Let $X'$ denote the closure of $X$ in $B$. Noting that $C_k' \subset C_k \cup A$ and $G \cap A = \emptyset$, we can write $E_2$ as the intersection of two sets open in $B$
$$
E_2 = G \cap (B \setminus C_k')
$$
so $E_2$ is open in $B$.
Similarly, recall that $E_2$ is closed in $B \setminus C_k$ so there is a closed set $F$ in $B$ such that $E_2 = F \cap (B \setminus C_k)$. Noting that $E_2' \subset E_2 \cup A$ and $F \cap A = \emptyset$, we can write $E_2$ as the intersection of two sets closed in $B$
$$
E_2 = F \cap E_2'
$$
so $E_2$ is closed in $B$.
Thus, $E_2$ is both open and closed in $B$ and consequently $B = E_1 \cup E_2$ is the union of two disjoint non-empty open sets contradicting the fact that $B$ is connected. Therefore, the assumption  that $B \setminus C_k$ can be written as the union of two disjoint non-empty open sets is false and thus $B \setminus C_k$ is connected.


text:
Q: Why does my IntegerField, used to create a dropdown menu, not work? I cannot seem to make my Django model work properly. The thing is, that my dropdown menu returns a number instead of "ja" or "nej" (meaning yes or no in Danish). However, when I create the model inside of the admin-panel, everything works perfectly fine. But as soon as I try to display the data on the front-end, stuff goes wrong.
I have provided the code, in case you wanted to have a look.
YESNO_CHOICES = (
    (0, 'Ja'),
    (1, 'Nej')
    )

class Client(models.Model):
    fulde_navn = models.CharField(max_length=75)
    adresse = models.CharField(max_length=100)
    tidligere_klient = models.IntegerField(choices=YESNO_CHOICES, null=True, blank=True)
    beskrivelse = models.TextField(null=True, blank=True)
    arbejde = models.CharField(max_length=200)
    relateret_til_andre_klienter = models.IntegerField(choices=YESNO_CHOICES, null=True, blank=True)
    vurder_sidste_session = models.IntegerField(choices=SESSION_CHOICES, null=True, blank=True)
    profilbillede = models.ImageField('Profile picture',
                                upload_to='profile_pics/%Y-%m-%d/',
                                null=True,
                                blank=True)

Front-end part:

Adresse: {{ client.adresse }}

Tidligere klient: {{ client.tidligere_klient }}

Adresse: {{ client.adresse }}

Adresse: {{ client.adresse }}

Adresse: {{ client.adresse }}

A: The data is stored in the database as integers. To display the Yes/No value, you need to use this:
{{ get_tidligere_klient_display }}

This will match the value stored in database and display the proper word. Like:
{% for client in client_list %}

    {{ client.get_tidligere_klient_display }}

{% endfor %}


text:
Q: "message": "cURL error 60: SSL: no alternative certificate subject name matches target host name 'api-.pusher.com' We are implementing a custom chat in a web application using Laravel and pusher. The basic functionalities like sending and receiving messages with file-sharing were working perfectly fine for few days but all of a sudden we encountered an error as follows:

"message": "cURL error 60: SSL: no alternative certificate subject
name matches target host name 'api-.pusher.com' (see
https://curl.haxx.se/libcurl/c/libcurl-errors.html) for
https://api-.pusher.com/apps//events?auth_key=&auth_timestamp=1622911129&auth_version=1.0&body_md5=994999b61168dbbbb9172e79341131b8&auth_signature=51992f8acbe3f6943163bb358399f30b7d8020d30a5d121e1650953480642397",
"exception": "GuzzleHttp\Exception\RequestException",
"file": "/home/techfin/public_html/testtest.com/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php",
"line": 211

It works perfectly fine on the local machine but causes problems on the server.

A: I think you should install the CURL extension as below (on Linux):
sudo apt-get install php-curl

This will install a dependency package, which depends on the default PHP version. After that restart apache
sudo service apache2 restart

on windows:
read this article

A: You're missing the cluster ID from the curl. Normally you'd have an API URL like https://api-mt1.pusher.com. You can find the cluster for your app in the Pusher dashboard.


text:
Q: How to find if the exception is occurred from web client and from httpwebrequest? Lets say i have a method in which I perform following operation its just a test method just to show what i actually need.
 public void ExceptionOccured()
        {
            try
            {
                WebClient client = new WebClient();
                client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
                Stream _data = client.OpenRead(_apiCallArgs);
                // if exception occurs in Open read method

                WebRequest request = WebRequest.Create("http://www.contoso.com/default.html");
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                // if exception occurs in get response method

                int a = Convert.ToInt32("anyvariable");
                // if exception occurs here
            }
            catch (Exception ex)
            {
                // how can i find that who occurred the exception either its is occurred by webclient or httprequest or by coversion ?
            }

        }

how can i find out that who occurred the exception either its is occurred by webclient or httprequest or by coversion ?

A:     public void ExceptionOccured()
    {
        try
        {
            WebClient client = new WebClient();
            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            Stream _data = client.OpenRead(_apiCallArgs);
            // if exception occurs in Open read method

            WebRequest request = WebRequest.Create("http://www.contoso.com/default.html");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            // if exception occurs in get response method

            int a = Convert.ToInt32("anyvariable");
            // if exception occurs here
        }
        catch (Exception ex)
        {
           Type exType = ex.GetBaseException().GetType();
        }

    }

OR
    public void ExceptionOccured()
    {
        try
        {
            WebClient client = new WebClient();
            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            Stream _data = client.OpenRead(_apiCallArgs);
            // if exception occurs in Open read method

            WebRequest request = WebRequest.Create("http://www.contoso.com/default.html");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            // if exception occurs in get response method

            int a = Convert.ToInt32("anyvariable");
            // if exception occurs here
        }
        catch (WebException exhttp)
        {
             //Web exception directally catch by this block
        }
        catch (Exception ex)
        {

        }

    }


text:
Q: Modeling hierarchical data using enums in Java I have multiple clients returning same data to me in different formats, for which I want to write an abstraction.
Client A: {
    Category_A1:
        Sub_Category_A1_1,
        Sub_Category_A1_2

    Category_B1:
        Sub_Category_B1_1,
        Sub_Category_B1_2
}

Client B: {
    Category_A2:
        Sub_Category_A2_1,
        Sub_Category_A2_2

    Category_B2:
        Sub_Category_B2_1,
        Sub_Category_B2_2
}

Here both clients A and B are returning the same categories 'A' and 'B', but are using different strings in their response.
I want abstractions Category_A and Category_B such that Category_A1, Category_A2 would map to Category_A and Category_B1, Category_B2 would map to Category_B.
The same is applicable to Sub_Categories as well - A category can only have a specific list of sub categories associated to it. I want to abstract the sub-categories as well while keeping the information that which category it belongs to.
I thought of using enums for mapping multiple categories to one:
public enum MyCategory {

MY_CATEGORY_A(new String[]{ CATEGORY_A1, CATEGORY_A2 }),

MY_CATEGORY_B(new String[]{ CATEGORY_B1, CATEGORY_B2 });

private String[] categories;

Category(String[] categories) {
   this.categories = categories;
}

public MyCategory getMyCategoryFromExternalCategory(final String externalCategory) {
}
};

What I'm finding difficult is mapping subcategories the same way while maintaining association between the category and the list of its subcategories.
What could be a clean way for achieving this using enums - as I do not have state or any other information related to categories and subcategories I do not want to use explicit classes for doing this.

A: I feel you need something like Map<\Category, List<\SubCategory>>, where Category is an enum taking Category_A, Category_B.
public enum Category {
   CATEGORY_A, CATEGORY_B
}

And SubCategory would just be another object to keep track of Sub-categories

A: it should work for u.
import java.util.Arrays;
import java.util.Objects;

public enum Category {

MY_CATEGORY_A(new String[]{ "CATEGORY_A1", "CATEGORY_A2" }),

MY_CATEGORY_B(new String[]{ "CATEGORY_B1", "CATEGORY_B2" });

private final String[] categories;

Category(String[] categories) {
    this.categories = categories;
}

public static Category getMyCategoryFromExternalCategory(String externalCategory) {

    Objects.requireNonNull(externalCategory);

    externalCategory = externalCategory.toUpperCase();

    {
        String[] categories = MY_CATEGORY_A.categories;

        if (Arrays.asList(categories).contains(externalCategory)) return MY_CATEGORY_A;
    }

    {
        String[] categories = MY_CATEGORY_B.categories;

        if (Arrays.asList(categories).contains(externalCategory)) return MY_CATEGORY_B;
    }

    throw new IllegalArgumentException("no such suitable category");
}

public static void main(String[] args) {

    System.out.println(getMyCategoryFromExternalCategory("category_a1"));

}


text:
Q: How to add some html between LI generated by Yii cmenu widget? I wish to add something like this:
menuitem1 / menuitem2 / menuitem3

I need to add that slash / between the LI generated elements.
Any clue how to make it?
I've tried this:
array('label'=>'About us', 'url'=>array('/about/index'), 'template'=> '/'),

But I get this generated:

/

Am I miss placing the template attribute?
Any other way, because, / is not a template?
UPDATE
Got it:
array('label'=>'About us', 'url'=>array('/about/index'), 'template'=> '{menu} /'),

This will generate a span after the li elements.
If anyone has a better way of doing this, please share.
UPDATE TWO:
While this works, the markup generated with be invalid. So a pseudo-element could be an option.

A: That's bad HTML.  There shouldn't be any markup in between
 elements.  If you would like to have slashes in between your menu items, I would recommend you either use another widget to display your menu items (something that doesn't use list items), or that you play with the css pseudo classes, :after and :before, to include slashes where you want them.
http://www.w3schools.com/cssref/sel_before.asp
http://www.w3schools.com/cssref/sel_after.asp
Of course, another option would be to add an image of a slash as the background of your element.  I just wouldn't call that the best option.


text:
Q: Align an anchor to the right Consider the following:
ab

How can I align the second anchor (b) to the right?
PS: float is an abuse in this situation. It's not made for this and it causes some problems, so I need other more reasonable solution.

A: You'd need separate containers.

        Left

        Right

p {font-size:0; /* Fixes inline block spacing */  }
span { width:50%; display:inline-block; }
span.align-right { text-align:right; }

span a { font-size:16px; }

JSFiddle example.

A: Try this CSS,
Using CSS3 nth-child()
a:nth-child(2) {
   display: inline-block;
   text-align: right;
   width: 100%;
}

Demo: http://jsbin.com/opexim/3/edit
Note: nth-child is a CSS3 and won't work on older browsers like IE6, 7 and 8
Support for old browsers
Set class to second  anchor element and apply the CSS.
ab

a.right {
   display: inline-block;
   text-align: right;
   width: 100%;
}

A: Maybe you can make something like this: ab
And CSS like this:
a.right {
    position: absolute;
    right: 0;
}

A: Just do this:
style="float:right"

Like:

   Equipment
   Model

http://jsfiddle.net/umerqureshi/0jx7kf1L/

A: Try and use :nth-child():
a:nth-child(2) {
   display: inline-block;
   text-align: right;
   width: 100%;
}

I don't know if this works for the older browsers.

A: You may try the below code:
ab

  ab

A: Assign a class or id to the 'b' containing anchor and give margin-left:100% to it.
For example:
.second{margin-left:100%;}

or else
a:nth-child(2){margin-left:100%;}

or else
you can also do like mentioned below:
css
a:nth-child(1){display:inline-block;width:50%;text-align:left;float:left;}
a:nth-child(2), .second{display:inline-block;width:50%;text-align:right;}

Working Fiddle

A:

     test

.mydiv {
    text-align: left;
}

You must enter your styles for the 'a' tag algin give to 'div'.


text:
Q: Golang MongoDB Update Query Using Operator IN Achievement that I want got is query like this in MySQL
UPDATE FROM inbox
SET unread = unread + 1
WHERE
projectID = ? AND
userID IN ("A", "B, "C")

Is MongoDB have query IN like that in MySQL?
I have tried this in Go using https://github.com/mongodb/mongo-go-driver
_, err = m.db.Collection("inbox_counter").UpdateMany(ctx, bson.M{
     "userID":    bson.D{{"$in", userIDs}},
     "projectID": e[0].ProjectID,
}, bson.D{
     {"$inc", bson.D{{"unread", 1}}},
}, options.Update().SetUpsert(true))

But it have no effect to my collections

A: Use bson.M{"$in": userIDs} instead of bson.D{{"$in", userIDs}} in filter and
for update use bson.M{"$inc": bson.M{"unread": 1}} instead bson.D{{"$inc", bson.D{{"unread", 1}}}}
_, err = m.db.Collection("inbox_counter").UpdateMany(ctx, bson.M{
     "userID":    bson.M{"$in": userIDs},
     "projectID": e[0].ProjectID,
},bson.M{"$inc": bson.M{"unread": 1}}, options.Update().SetUpsert(true))


text:
Q: How to delete a commit in remote pushed by mistake but keep local code I pushed to a branch called dev_feature_1 for example, but I'm not supposed to because I'm already finished with feature-1 and I should push to another branch called dev_feature_2 instead.
So I already did push my work to dev_feature_2 successfully, but I want to remove the commit in branch dev_feature_1 as it didn't exist, but I still want my local code to stay the same.
I tried to use revert {hash of the unwanted commit} but it removed everything from local but the remote remained the same! I had to use reset --hard to retrieve back my local code.
All I want is like a delete button on the last commit inside the commits list in GitHub.?

A: Use git revert command to revert the commit
git revert commit_hash_to_reset

git checkout -b your_new_branch

then push the code in your both branch. Remember to add force push flag in your dev_feature_1 branch


text:
Q: Templates for nested attributes with Backbone I have an Appointment model, each instance of which has a Client. Here's my template for editing an appointment:
<form id="edit-appointment" name="appointment" class="mobile_friendly">

    <input type="text" name="start_time_ymd" id="start_time_ymd" value="<%= start_time_ymd %>" placeholder="Start Date">
    <input type="text" name="start_time_time" id="start_time_time" value="<%= start_time_time %>" placeholder="Start Time">

    <input type="text" name="client_name" id="client_name" value="<%= client.name %>" placeholder="Client">
    <input type="hidden" name="client_id" id="client_id" value="<%= client.id %>" placeholder="Client ID">

    <input type="text" name="client_phone" id="client_phone" value="<%= client.phone %>" placeholder="Phone">

    <input type="text" name="notes" id="notes" value="<%= notes %>" placeholder="Notes">

    <input type="submit" value="Update Appointment" />

</form>

<a href="#/index/<%= stylist_id %>">Back

My problem is that my Client attributes aren't being passed to the server correctly. The JSON object that gets passed to the server on save looks something like the following. Let's pretend I have a client with phone number 555-555-5555 but I change it to 555-555-1234 and then submit the form:
{"appointment":
  {"start_time_ymd":"1/1/2000",
   "client_phone":"555-555-1234",
   "client":{"phone":"555-555-5555"}}

I've omitted a lot of irrelevant fields, but hopefully you see what I mean. I've changed client_phone from 555-555-5555 to 555-555-1234, but the client object in the JSON object has its phone number unchanged. I need to somehow change that phone number.
How do I make these fields - like the phone number field - actually "take" so they get passed to the server as part of the client object under appointment and not directly under appointment? I'm using Backbone-relational, if that makes a difference.

A: if after you change the form text your model is not being updated then you need to update the data explicitly
SampleView = Backbone.View.extend({
el: '#formEl',
events : {
    "change input" :"changed",
    "change select" :"changed"
},

initialize: function () {
    _.bindAll(this, "changed");
},
changed:function(evt) {
   var changed = evt.currentTarget;
   var value = $("#"+changed.id).val();
   var obj = "{\""+changed.id +"\":\""+value+"\"";

   // Add Logic to change the client phone
   if (changed.id === 'client_phone') {
          obj = obj + "client\":{\"phone\":\""+value+"\""};
   }
   obj = obj + "}";
   var objInst = JSON.parse(obj);
   this.model.set(objInst);
}
});

Reference :
Can I bind form inputs to models in Backbone.js without manually tracking blur events?
You can also bind to model change event
    model.on('change:client_phone',
       function () {
           //Set client value here
       });

A: I was able to get it to work like this:
class Snip.Views.Appointments.EditView extends Backbone.View
  template : JST["backbone/templates/appointments/edit"]

  events :
    "submit #edit-appointment" : "update"

  update : (e) ->
    e.preventDefault()
    e.stopPropagation()

    # THE ONLY CHANGE I MADE WAS TO ADD THIS LINE
    @model.attributes.client.phone = $("#client_phone").val()

    @model.save(null,
      success : (appointment) =>
        @model = appointment
        window.location.hash = "/#index/" + @model.attributes.stylist_id
    )