text:
Q: Installing Xcode via command line I am a Linux user and have never used OSX before. Someone asked me for help with installing some software on an OSX "Lion" server. I asked him to give me an SSH shell, assuming that would be sufficient. However things are more tricky than I thought.
I wanted to install homebrew, but it didn't install because there was no cc on the system. After some google, I suppose I need to install Xcode. I just downloaded xcode 4.5 from the apple developer site, and mounted it on the system. It contains a dir Xcode.app with a bunch of stuff in it. How do I go from here?
Can I install Xcode without physical access to the machine? All I really want is get homebrew running at this point.

A: # Install Command-line tools as dependency for Homebrew
xcode-select --install # Sets the development directory path to /Library/Developer/CommandLineTools

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Mas (command-line interface for Mac App Store)
brew install mas

# Search for Xcode showing only the first 5 results
mas search xcode | head -5
# Install Xcode using App ID
mas install 497799835 # The appid for Xcode shown when doing search

sudo xcode-select -r  # Reset the development directory path to put to Xcode /Applications/Xcode.app/Contents/Developer

#sudo xcodebuild -license

# Updaate all Apple software and auto agree to any licenses and restart if necessary
sudo softwareupdate --install --agree-to-license -aR

A: 2018 answer: There is xcode-install vom KrauseFX https://github.com/KrauseFx/xcode-install

A: I found out that Homebrew install the Xcode Command Line Tools as well.
The big benefit is for me that I can do it from a terminal (even ssh) and the installer do not show a UI-Pop-Window, which blocks me from use with remote terminal.
Tested with Homebrew version 2.1.10 (git revision b7d38f; last commit 2019-08-12).
For me that steps was much easier, then downloading dmg package from apple and copy it by ssh to the target machine.
The installer command will generate (copied from the website)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

the following output:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/bin
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/sbin
/usr/local/share
/usr/local/var
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew
/usr/local/var/homebrew/linked
/usr/local/Cellar
/usr/local/Caskroom
/usr/local/Homebrew
/usr/local/Frameworks
==> The Xcode Command Line Tools will be installed.

and
...
Downloading Command Line Tools (macOS Mojave version 10.14) for Xcode
Downloaded Command Line Tools (macOS Mojave version 10.14) for Xcode
Installing Command Line Tools (macOS Mojave version 10.14) for Xcode
Done with Command Line Tools (macOS Mojave version 10.14) for Xcode
...

A: You might be better off just installing the standalone Developer Command Line Tools (which includes gcc and other standard developer toolchain items). You can get it from Apple's Developer Downloads (which requires a free developer account). Unfortunately there's no direct link, but just search for command line tools and you'll find it (note that there are different downloads for Lion and Mountain Lion).
The download is a DMG. Mount that, and you'll find a .mpkg file, which you can install via the command line: sudo installer -pkg "Command Line Tools.mpkg" -target /.

A: The tools you need are all in Xcode.app/Contents/Developer and if you have that folder, you are done installing since OS X applications can run from anywhere.
If you want to use Xcode, just click on the icon or open -a the path to the folder Xcode.app and you will launch the app. Most people move the Xcode.app folder into /Applications (or ~/Applications) to "install it"
Oh - when you fire up Xcode you will want to open the preferences, go to the Downloads pane and install the stand alone command line tools. This places the compilation toolchain in /usr/bin so you don't have to use xcrun --find gcc and xcrun --find make to locate the path to the tools relative to wherever you dropped the Xcode.app folder.

A: I recently had to install Xcode command line tools on Mountain Lion over SSH. Here's how I did it.

*

*If you don't have a free Apple developer account, register for one

*Login to https://developer.apple.com/downloads

*Download the "Command Line Tools for Xcode" appropriate for your version of OSX
For me, that was "Command Line Tools (OS X Mountain Lion) for Xcode - April 2014"

*Copy the dmg file to your remote
In the following command, I'm using scp to securely copy the file from my local computer to the remote named remote
$ scp ~/Downloads/command_line_tools_for_osx_mountain_lion_april_2014.dmg remote:Downloads/

*ssh to your remote
$ ssh remote

*mount the dmg file on the remote
Here, I'm using hdiutil to mount the image
$ hdiutil attach ~/Downloads/command_line_tools_for_osx_mountain_lion_april_2014.dmg

*install the package contained in the dmg
Here, installer must be run with sudo because this package needs to be installed on the root file system
$ cd /Volumes/Command\ Line\ Tools\ \(Mountain\ Lion\)
$ sudo installer -pkg Command\ Line\ Tools\ \(Mountain\ Lion\).mpkg -target /

*unmount the dmg file
$ hdiutil detach /Volumes/Command\ Line\ Tools\ \(Mountain\ Lion\)

*delete the dmg file from the remote; optional
I see no purpose keeping it around, but you can if you want.
$ rm ~/Downloads/command_line_tools_for_osx_mountain_lion_april_2014.dmg

A: This is pretty old, but for anyone who comes by this, there is a simple, built-in, one-liner to install the Command Line Tools without the need to download any .dmg or .pkgs. This is available even on a fresh install of macOS.
The command is:
xcode-select --install

According to the man page:
Opens a user interface dialog to request automatic installation of the command line developer tools.

It seems to have been available since Xcode 3.0 was around (OS X 10.5).

A: MOUNT XCODE DMG
tell application "Finder" to open ("Macintosh HD")
tell application "Finder"
    activate
    set target of Finder window 1 to folder "Downloads" of folder "vagrant" of folder "Users" of startup disk
    open document file "{{ osx_xcode_file }}" of folder "Downloads" of folder "vagrant" of folder "Users" of startup disk
end tell

Replace Xcode "{{ osx_xcode_file }}" with the version/filename you have downloaded.
Install XCODE
tell application "Finder"
    activate "Xcode"
    with timeout of 1000000 seconds
        copy file "Xcode:Xcode.app" to folder "Macintosh HD:Applications"
    end timeout
end tell

Optionally Delete a previous XCODE
rm /Applications/Xcode.app causes unforsean issues
tell application "Finder"
    activate "Applications"
    considering case
        with timeout of 1000000 seconds
            set sourceFolder to POSIX file "/Applications/Xcode.app"
            try
                delete sourceFolder
            on error errorMessage number errorNumber
                set _error to errorMessage
                set _errorNum to errorNumber
            end try
        end timeout
    end considering
end tell

Save each file as an scriptname.scpt
run: /usr/bin/osascript scriptname.scpt
Run as a console user (NOT ROOT)


text:
Q: Display fixed minimum price in php search results We're using an API to display a list of properties in search results and we need to apply a fixed minimum price of £300 for short stays at properties.
Currently, it is possible to input a stay of 1 or 2 nights and for the price for a particular property to display less than £300.
We need (I presume) an if statement to display £300 in these scenarios.
The below is what we have in place to set the price...
<?php echo money_format('£%i', $property_price / ( $nights )) ?>

Variables are based on attributes from the API.
Please could anyone advise how we can convert this to include something similar to 'display £300 if price returned is less than this amount'?
The suggested edit of the title is incorrect. I don't want to display the right price (?) - that's why I didn't say that... I want to display a fixed price of £300 even if the results from the API return a price less than this amount.

A: Just use the max function:
<?php echo money_format('£%i', max(300, $property_price / ( $nights ))) ?>

A: The answer comes from a long chat talk with the author and a careful reading of what he was trying to do.
Answer
I see that there is something wrong in your code.
This is right:
<?php if ($property_price < 300) $property_price = 300; ?>
<?php echo money_format('£%i', $property_price / ( $nights )) ?>

(that of course is equivalent to a max...)

redpajama_set_name: RedPajamaStackExchange


text:
Q: getting first letters of full name in angular typescript *ngFor I'm new in angular and don't know much about it yet. I am showing a list of people in my angular app. And I want to show first letters of their first name and last name as DP if no picture found for that person. My code looks like below:

        {{user.full_name}}

Well I know I can use *ngIf on user.picture to check if picture is empty? But I don't know how to get first letters of name. For example:
 if user.full_name contains Mary Johnson name and user.picture is empty then in place of picture, it should show MJ in place of picture. I can design the circle to show letters, just wanted to know how can I get first letters inside loop. Please help me

A: You can create a method in your component or create custom angular pipe for this
create a method to get short name
getShortName(fullName) {
  return fullName.split(' ').map(n => n[0]).join('');
}

template

        {{getShortName(user.full_name)}}

Updated
the answer above is consider a bad practices because the method will run in every change detection cycle so the best approch is to create a pipe to get the short name
shortName.pipe.ts
import { Pipe, PipeTransform } from "@angular/core";

@Pipe({
  name: "shortName"
})
export class ShortNamePipe implements PipeTransform {
  transform(fullName: string): any {
    return fullName
      .split(" ")
      .map(n => n[0])
      .join("");
  }
}

template
{{'My Name' | shortName}}

demo

A: The most direct approach would be to write a custom pipe for this: https://angular.io/guide/pipes
Pipes act as one-way converters, some model value in, some display value out. Once you've written your pipe your template would just be:

    {{user.full_name | myCustomNamePipe }}

You could also just bind to a method on the component; but this can be inefficient due to the way change detection works:

    {{ getNamePieces(user) }}

Finally, if you just had a user view model and selected into it (using map) before display; you could bind directly to a calculated property.

A: I've made some improvements to the solution by @malbarmavi https://stackoverflow.com/a/51621024/3954417
Just added to the pipe a parameter, so you can set a number of chars to show.
shortName.pipe.ts
import { Pipe, PipeTransform } from "@angular/core";

@Pipe({
  name: "shortName"
})
export class ShortNamePipe implements PipeTransform {
  transform(fullName: string, numChars: number = 2): any {
    return fullName
    .split(" ").slice(0,numChars)
      .map(n => n[0].toUpperCase())
      .join("");
  }
}

template
{{'My Name' | shortName:2}}

demo


text:
Q: Integration by parts - hint I'm stuck on a passage on my textbook:
$$ \int \frac{1}{(1+t^2)^3} dt = \frac{t}{4(t^2+1)^2}+\frac{3}{4} \int \frac{1}{(t^2+1)^2} dt$$
I know that it should be easy but I just can't figure out what is the product of functions considered in this integration by parts..
can you help me?
thanks a lot

A: Notice, in general, use integration by parts as follows $$\int\frac{1}{(1+x^2)^{n-1}}\ dx=\int \underbrace{\frac{1}{(1+x^2)^{n-1}}}_{I}\cdot \underbrace{1}_{II}\ dx$$
$$=\frac{1}{(1+x^2)^{n-1}}\int 1\ dx-\int\left(\frac{d}{dx}\frac{1}{(1+x^2)^{n-1}}\cdot \int 1\ dx\right)\ dx$$
$$=\frac{x}{(1+x^2)^{n-1}}-\int\left(-\frac{2(n-1)x^2}{(1+x^2)^{n}}\right)\ dx$$
$$=\frac{x}{(1+x^2)^{n-1}}+2(n-1)\int\left(\frac{1+x^2-1}{(1+x^2)^{n}}\right)\ dx$$
$$=\frac{x}{(1+x^2)^{n-1}}+2(n-1)\int \frac{1}{(1+x^2)^{n-1}}\ dx-2(n-1)\int \frac{1}{(1+x^2)^{n}}\ dx$$
$$\int \frac{1}{(1+x^2)^{n}}\ dx=\frac{x}{2(n-1)(1+x^2)^{n-1}}+\frac{2n-3}{2(n-1)}\int\frac{1}{(1+x^2)^{n-1}}\ dx$$
Above reduction formula which can be easily applied to find
$\int\frac{1}{(1+x^2)^{3}}\ dx$ as follows
$$\int\frac{1}{(1+x^2)^{3}}\ dx=\frac{x}{4(1+x^2)^{2}}+\frac 34\int \frac{1}{(1+x^2)^{2}}\ dx$$
$$=\frac{x}{4(1+x^2)^{2}}+\frac 34\left(\frac{x}{2(1+x^2)}+\frac 12\int \frac{1}{1+x^2}\ dx\right)$$
$$=\frac{x}{4(1+x^2)^{2}}+\frac{3x}{8(1+x^2)}+\frac{3}{8}\tan^{-1}(x)+C$$

A: Alternatively you can make use of Lebnitz Integral formula since you already know  $\int \frac{1}{x^2+1}\, dx= \arctan x$
Consider $$I(x) = \int \frac{dt}{x^2+t^2}=\frac{\arctan x}{x}+C$$
Note that $$I''(x)=8 x^2\int \frac{dt}{(x^2+t^2)^3}$$
Guess you can figure out the rest

A: $$
\int \frac{1}{(1+t^2)^3} \, dt = \overbrace{\int u\,dt = tu - \int t\,du}^\text{integration by parts}.
$$
$$
u = \frac 1 {(1+t^2)^3}, \qquad du = \Big(\cdots\cdots{?}\cdots\cdots\Big)\, dt
$$
Fill in the blank and go on from there.

A: $$\int \dfrac {1}{(t^2+1)^3}\,dt = \int \dfrac {(1+t^2) - t^2}{(t^2+1)^3}\, dt = \int \dfrac {1}{(t^2+1)^2}\,dt + \dfrac{1}{4}\int t\, d(t^2+1)^{-2}$$$$ = \int \dfrac {1}{(t^2+1)^2}\,dt + \dfrac{1}{4}\dfrac {t}{(t^2+1)^2} - \dfrac{1}{4}\int  \dfrac{1}{(t^2+1)^2}\,dt $$$$ = \dfrac{1}{4}\dfrac {t}{(t^2+1)^2} + \dfrac{3}{4}\int  \dfrac{1}{(t^2+1)^2}\,dt  $$


text:
Q: how to detect grid view in edit mode at row data bound i just want to detect that grid view in row editing mode and i just want to bind drop down list at this moment. i found many article and i make this code :
 protected void GV_ViewCustomers_RowDataBound(object sender, GridViewRowEventArgs e)
{
     if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
        {
            using (DataClassesDataContext db = new DataClassesDataContext())
            {
                DropDownList dl = (DropDownList)e.Row.FindControl("DDL_Types1");
                dl.DataSource = db.PartyTypes.Select(t => t).ToList();
                dl.DataBind();
                dl.SelectedValue = DataBinder.Eval(e.Row.DataItem, "type_id").ToString();
                DropDownList dl1 = (DropDownList)e.Row.FindControl("DDL_CountryNames1");
                dl1.DataSource = db.Countries.Select(c => c).ToList();
                if (!string.IsNullOrEmpty(DataBinder.Eval(e.Row.DataItem, "country_id").ToString()))
                {
                    dl1.SelectedValue = DataBinder.Eval(e.Row.DataItem, "country_id").ToString();
                    DropDownList dl2 = (DropDownList)e.Row.FindControl("DDL_StateNames1");
                    dl2.DataSource = db.States.Where(s => s.country_id.Equals(int.Parse(DataBinder.Eval(e.Row.DataItem, "country_id").ToString()))).Select(s => s).ToList();
                    dl2.DataBind();
                }
                DataRowView rowView1 = (DataRowView)e.Row.DataItem;
                if (rowView1["UserOFC"] != null)
                {
                    (e.Row.FindControl("chk_UserOFC1") as CheckBox).Checked = Convert.ToBoolean(e.Row.DataItem.Equals("UserOFC").ToString());
                }
                if (rowView1["UserVAT"] != null)
                {
                    (e.Row.FindControl("chk_UserVAT1") as CheckBox).Checked = Convert.ToBoolean(e.Row.DataItem.Equals("UserVAT").ToString());
                }
                if (rowView1["UserINV"] != null)
                {
                    (e.Row.FindControl("chk_UserINV1") as CheckBox).Checked = Convert.ToBoolean(e.Row.DataItem.Equals("UserINV").ToString());
                }
                if (rowView1["UserNone"] != null)
                {
                    (e.Row.FindControl("chk_UserNone1") as CheckBox).Checked = Convert.ToBoolean(e.Row.DataItem.Equals("UserNone").ToString());
                }
            }
            UpdatePanel10.Update();
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            using (DataClassesDataContext db = new DataClassesDataContext())
            {
                DropDownList ddl1 = (DropDownList)e.Row.FindControl("DDL_Types");
                ddl1.DataSource = db.PartyTypes.Select(p => p).ToList();
                ddl1.DataBind();
                DropDownList ddl2 = (DropDownList)e.Row.FindControl("DDL_CountryNames");
                ddl2.DataSource = db.Countries.Select(c => c).ToList();
                ddl2.DataBind();
            }
        }
}

how ever footer drop down list successfully binds up but in edit item template not.
please help me...
protected void GV_ViewCustomers_RowEditing(object sender, GridViewEditEventArgs e)
    {
       GV_ViewCustomers.EditIndex = e.NewEditIndex;
       this.FillGrid((String)Session["StartAlpha"] ?? null, (int)Session["GroupByENTYPE"] , (String)Session["ColumnName"] ?? null, (String)Session["SearchText"] ?? null);
       UpdatePanel10.Update();
       MPE.Show();
    }

A: Not sure what your issue actually is, but you need to check for  RowState=Edit also in the footer.
So instead of:
protected void GV_ViewCustomers_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
    {
        // ...
    }
    if (e.Row.RowType == DataControlRowType.Footer)
    {
        // ...
    }
}

this:
protected void GV_ViewCustomers_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow
        && e.Row.RowState == DataControlRowState.Edit)
    {
        // ...
    }
    else if (e.Row.RowType == DataControlRowType.Footer
        && e.Row.RowState == DataControlRowState.Edit)
    {
        // ...
    }
}

A: if (e.Row.RowState == DataControlRowState.Edit || e.Row.RowState ==
(DataControlRowState.Edit | DataControlRowState.Alternate))
{
  // write your statement that you want to fire in Edit mode
}

http://www.dotnetfunda.com/codes/show/123/how-to-check-for-edit-mode-of-the-gridview-row-irrespective-of-it-is-n


text:
Q: trying to avoid duplicates using inner joins (mysql) SELECT T.instnum, T.batchnum, T.recdate,
       T.operator, T.booknum, T.bpagenum,
       T.epagenum, T.nonstandarddoc,
       E.returntoname, S.receivedfrom
FROM TBL_Transactions T
inner join TBL_TransEfile S on S.instnum = T.instnum
inner join EFL_Trans E on E.batchnum = S.mosbatchnum
where T.nonstandarddoc = 'y'
  and T.`year` = '2017'
  and T.efiledocument = 'y'
order by instnum asc

When i ran this query it does display the information i need but since i am pulling the information from 2 tables it seems that is not excluding the duplicates, i have tried distinct which does lower the amount of entries but not to the real one, the instrument number (instnum) is what dictates the results and if there was a way to make the tables avoid duplicates by using the instnum as a guide would be perfect
example of a result:
'2017007122', 1001071, '20170208', 'JSCHULTZ', '7902', 1226, 1230, 'Y', '', 'simplifile'
'2017007122', 1001071, '20170208', 'JSCHULTZ', '7902', 1226, 1230, 'Y', 'Orion Financial Group, Inc.', 'simplifile'

as you can see it is returning the same information except for a vendor name, if we can make the query avoid the duplicates that would be great, thanks in advance for anyone's help.


text:
Q: Connect to different repository url depending on being in home network or not I have a subversion working copy on my laptop, and the corresponding repository on my NAS.
When I am away from home, I update and commit over the internet over an encrypted connection to an domain name which resolves to my external IP.
When I am at home and connected through my home network, I would like to update and commit over an unencrypted connection to my internal (home network) IP.
I would prefer not to use encryption or my external IP address when I at home, because both slow down the connection speed (10 MB/s without encryption and with internal IP, 1 MB/s with encryption and internal IP, and 0.5 MB/s with or without encryption and with external IP).
Is there any way I can let my working copy refer to a different URL depending on whether I am or not connected to my home network? Or is there another way to solve the speed problem?

A: Some options:

*

*If this is through ssh (svn+ssh://...), then you can edit your .ssh/config to specify aliases for hosts. You could then write a script that edits this configuration file on network change so that the alias points to the right hostname.

*If it isn't (through http or something), you could run a local DNS server that resolves a special domain name that you can make up to the IP of the correct domain name depending on which network the computer is on

*(Probably less insane than the previous one) Run a TCP relay on your local computer on some port, and have it point to either server depending on the network you are on. For example, you could make it bind to localhost:8080 and have that be forwarded to myserver:80 when on network 1, publicserver:80 when on network 2. Then you could need to do a checkout from that address (svn checkout http://localhost:8080/...).

Just some random ideas, all of them feel like workarounds though. Maybe there's an easier way.
Or you may want to switch to a distributed version control system like git, which will allow you to push to the remote you want (git push -u someremote branchname, where someremote refers to one of the servers).

A: I solved a similar problem yesterday, so git repos on my laptop can be synced with a remote on my desktop machine, without having to use a different remote depending whether I'm on the LAN or away from home.
I ran dnsmasq on my desktop, with this config:
domain-needed
bogus-priv
no-poll
local=/localdomain/
addn-hosts=/etc/extra_hosts

/etc/extra_hosts contains a single entry with the IP of my desktop on the LAN and the domain name that resolves to my external IP e.g.
192.168.0.72 jwakely.example.com

Then on my laptop edit the NetworkManager config for my LAN wifi connection to "DHCP Addresses Only" and set 192.168.0.72 as the primary DNS server, and my router as the secondary (to do that without the NetworkManager GUI just set DNS1 and DNS2 and PEERDNS=no, or put the nameservers in /etc/resolv.conf manually)
It worked perfectly once I remembered to allow DNS queries (port 53) though my desktop's firewall.
When I'm on my home LAN the laptop uses the desktop for DNS queries, so gets the internal IP for jwakely.example.com, and all other DNS queries get forwarded to my desktop's usual DNS server (which happens to be my ADSL router.)  Only the laptop uses the dnsmasq instance, all other hosts on the LAN still use the router for DNS as normal.  If my laptop is on the LAN but my desktop's not running then the laptop uses its secondary DNS server and can't get the internal IP for jwakely.example.com but that's OK because the machine isn't running anyway.

A: I hope, you know about Subversion's relocate command. You can use it by hand. If you'll use hostnames for internal and external access, which resolve only one in one location respectively, svn error on any repo-related operation remind to to relocate
Another (dirty) idea is to use VPN-connection in external nets for securing access to server and use common insecure protocol for repository access - in home net you just doesn't up VPN-link. Advantages of this way are: single URL, security on demand, error-proof simplicity


text:
Q: How to save files in my server with ScriptCam plugin I want the users of my website to stream video in the website and preview it.
then they can click save and the file is saved in the website's server. I found this plugin
It seem to work fine, but the problem is that after it makes the file conversion it gives me a link to download the file whis supposedely is kept in ScriptCam's own server. I also noticed that their server URL is pre appended to the "fileName" variable. i don't know where it's coming from.
Any help is welcome,
Mike

A: Actually You can save the video file in your server. In that case you have to go to the code from where the link is generated. Then send the video url to a php page via ajax $.post method.Then in the php page write a php "copy" function. See the code below :-
First go to the fileReady() in the index.php page to get the video url:-
function fileReady(fileName) {
    $('#recorder').hide();
    $('#message').html('This file is now dowloadable for five minutes over
                here.');
    var x=fileName;

    if (x != null){
    $.post('ack.php', {x: x}, function(){
        //successful ajax request
    }).error(function(){
        alert('error... ohh no!');
    });

}

var fileNameNoExtension=fileName.replace(".mp4", "");
    jwplayer("mediaplayer").setup({
        width:320,
        height:240,
        file: fileName,
        image: fileNameNoExtension+"_0000.jpg"
    });

    $('#mediaplayer').show();
}

the create a php page as I have created as ack.php. then write the following code:-
ack.php
$val=$_POST['x'];

$file = $val;
$newfile = 'video/output.mp4';

if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}

This works fine but the problem is that the video quality is not very good. If anyone can give me solution that how can I increase the video quality in scriptcam then that will be very helpful for me.

A: Sorry,  I found out I had to register and set up the ftp options and also  allow incoming connections on my server.


text:
Q: No logro agrupar comprobantes con group by Tengo una tabla ticket en MySQL, el cliente puede pagar un poco en tarjeta y otra parte en efectivo. Para eso tengo una tabla movimientos con el idtipomovimiento que lleva a otra tabla (tarjeta, efectivo,cuenta corriente,etc).Pero cuando quiero consultar con group by me devuelve los ticket una vez pero solo me muestra el efectivo entregado:
   $query="SELECT * from ticket left join tipocomprobante on
   tipocomprobante.idtipocomp=ticket.idtipocomp left join cliente on
   ticket.idc=cliente.idcliente left join movimiento on movimiento.idticket=ticket.idticket
    WHERE cajero=".$idcajero." AND sesion=".$idsesion." group by ticket.idticket;";

He probado la consulta en phpMyAdmin y no devuelve los movimientos de tarjeta:
  CREATE TABLE `movimiento` (
  `idmov` int(11) NOT NULL,
  `tipomov` int(11) DEFAULT NULL,
  `importe` decimal(10,2) DEFAULT NULL,
  `idticket` int(11) NOT NULL,
  `idcliente` int(11) DEFAULT NULL,
  `idsesion` int(11) DEFAULT NULL,
  `fecha` varchar(255) COLLATE utf8_spanish_ci DEFAULT NULL
)

CREATE TABLE `ticket` (
  `idticket` int(11) NOT NULL,
  `fecha` varchar(11) COLLATE utf8_spanish_ci DEFAULT NULL,
  `total` decimal(10,2) DEFAULT NULL,
  `vuelto` decimal(10,2) DEFAULT NULL,
  `hora` varchar(10) COLLATE utf8_spanish_ci DEFAULT NULL,
  `idtipocomp` int(11) DEFAULT NULL,
  `idc` int(11) NOT NULL,
  `cae` varchar(255) COLLATE utf8_spanish_ci DEFAULT NULL,
  `fechavto` date DEFAULT NULL,
  `cajero` int(11) DEFAULT NULL,
  `sesion` int(11) DEFAULT NULL,
  `pago` varchar(11) COLLATE utf8_spanish_ci DEFAULT NULL
)

CREATE TABLE `tipomov` (
  `idtipomov` int(11) NOT NULL,
  `nombre` varchar(100) COLLATE utf8_spanish_ci DEFAULT NULL
)

Edito la pregunta.:

Tengo esa tabla donde muestro los movimiento de la sesión. Ahi la idea es que aparezcan todos los tickets, con el monto abonado en efectivo, y el monto con tarjeta de débito o crédito.
Como veran genera 2 renglones en la tabla para un mismo ticket, yop quisiera tener cada ticket en un solo renglon.
De lo contrario tendria que modificar la estructura de la tabla ticket y agregar directamente el monto de efectivo y tarjeta. Y luego comprobar si son distintos de 0.

A: El group by te va a ocultar info porque agrupas por el ticket sin usar funciones de agregación en los demás datos; el motor no sabe qué debe mostrarte, así que te muestra la primera fila de cada ticket en el conjunto.
Digamos que estas son las tablas y datos de ejemplo:
CREATE TABLE `movimiento` (
  `idmov` int(11) NOT NULL,
  `tipomov` int(11) DEFAULT NULL,
  `importe` decimal(10,2) DEFAULT NULL,
  `idticket` int(11) NOT NULL,
  `idcliente` int(11) DEFAULT NULL,
  `idsesion` int(11) DEFAULT NULL,
  `fecha` varchar(255) COLLATE utf8_spanish_ci DEFAULT NULL
);
insert into movimiento
values
(1, 1, 123.45, 1, 1, 1, now() ),
(2, 2, 22.44, 1, 1, 1, now());

CREATE TABLE `ticket` (
  `idticket` int(11) NOT NULL,
  `fecha` varchar(11) COLLATE utf8_spanish_ci DEFAULT NULL,
  `total` decimal(10,2) DEFAULT NULL,
  `vuelto` decimal(10,2) DEFAULT NULL,
  `hora` varchar(10) COLLATE utf8_spanish_ci DEFAULT NULL,
  `idtipocomp` int(11) DEFAULT NULL,
  `idc` int(11) NOT NULL,
  `cae` varchar(255) COLLATE utf8_spanish_ci DEFAULT NULL,
  `fechavto` date DEFAULT NULL,
  `cajero` int(11) DEFAULT NULL,
  `sesion` int(11) DEFAULT NULL,
  `pago` varchar(11) COLLATE utf8_spanish_ci DEFAULT NULL
);
insert into ticket
values
(1, 'fecha', 145.89, 0.0, 'hora', 1, 123, 'cae', now(), 333, 1, 'pago');

CREATE TABLE `tipomov` (
  `idtipomov` int(11) NOT NULL,
  `nombre` varchar(100) COLLATE utf8_spanish_ci DEFAULT NULL
);
insert into tipomov
values
(1, 'efectivo'),
(2, 'cheque');

Tengo un ticket, dos movimientos, cada uno de un tipo. Quité los join con los clientes y comprobantes porque parecen no ser relevantes y tampoco tengo datos.
Si yo uso una consulta sin agrupar:
SELECT *
from movimiento
left join ticket on movimiento.idticket=ticket.idticket
WHERE
cajero=333 AND sesion=1

Obtengo dos filas, cada una con la info del movimiento y con el dato del ticket asociado:
idmov   tipomov     importe     idticket    idcliente   idsesion    fecha   idticket    fecha   total   vuelto  hora    idtipocomp  idc     cae     fechavto    cajero  sesion  pago
1   1   123.45  1   1   1   2020-09-07 12:10:18     1   fecha   145.89  0   hora    1   123     cae     2020-09-07  333     1   pago
2   2   22.44   1   1   1   2020-09-07 12:10:18     1   fecha   145.89  0   hora    1   123     cae     2020-09-07  333     1   pago

Entendería que eso es lo que buscas. Ahora bien, nos comentas que quieres hacer el group by en el ticket. Podrías hacer un
SELECT ticket.*, sum(movimiento.importe)
from movimiento
left join ticket on movimiento.idticket=ticket.idticket
WHERE
cajero=333 AND sesion=1

Y obtendrías una única fila con el ticket Y el monto total de los movimientos.
idticket    fecha   total   vuelto  hora    idtipocomp  idc     cae     fechavto    cajero  sesion  pago    sum(movimiento.importe)
1   fecha   145.89  0   hora    1   123     cae     2020-09-07  333     1   pago    145.89

Lo raro es: ya tienes ese valor en la fila total del ticket porque la normalización no está muy bien que digamos (o bueh, necesitas tener el dato ahí por algún requerimiento no funcional). Por eso no es claro por qué dices que quieres agrupar por ticket Y mostrar todos los movimientos. Es excluyente.


text:
Q: select command not working in R even after installing the library dplyr Error message : could not find function "select"
After installing the package dplyr which contains the select function for R,
this error isn't expected but still i am getting this error.
I want to select a particular column of the dataset but the dollar sign operator is also not working.

A: I think I've had this problem as well and I'm not sure what causes it. However, I can usually solve the problem by specifying the package before the command as in the code below.
dplyr::select()

Hope this helps.

A: @THATguy nailed it! That will solve your problems. The cause of this error is often due to multiple libraries with the same function. In this case specifically, the function "select" exists in the package 'dplyr' and 'MASS'. If you type in select in your code it's likely going to pull the MASS library, and if your intention is select only certain columns out of a data frame then, you want to the select from 'dplyr'. For example:
df <- read.csv("df.csv") %>% #bring in the data frame
      dplyr::select(-x, -y, -z) # remove the x, y, and z columns from the data frame

Or if you want to keep certain columns then drop the '-' in front of the variable.

A: There are various ways you can try to solve this problem.

*

*Restart the R session with ctrl + shift + F10

*You can use dplyr::select() if that's the select function you want


text:
Q: How to get with custom-columns resource limits and requests of all containers in namespace in kubernetes I tried this:
k get po -n myns -o=custom-columns=NAME:.spec.containers.name,MEMREQ:.spec.containers.resources.requests.memory,MEMLIM:.spec.containers.resources.limits.memory,CPUREQ:.spec.containers.resources.requests.cpu,CPULIM:.spec.containers.resources.limits.cpu

but it returned me this:
    NAME     MEMREQ   MEMLIM   CPUREQ   CPULIM
    <none>   <none>   <none>   <none>   <none>
    <none>   <none>   <none>   <none>   <none>
    <none>   <none>   <none>   <none>   <none>
    <none>   <none>   <none>   <none>   <none>
    <none>   <none>   <none>   <none>   <none>
    <none>   <none>   <none>   <none>   <none>
    <none>   <none>   <none>   <none>   <none>

A: Note that containers is a list, so you would have to either supply the index or * for all containers.
Here is an example from my environment, you can tweak your rest of the command.
kubectl get po -o=custom-columns=NAME:.spec.containers[*].name
NAME
nginx
nginx

kubectl get po -o=custom-columns=NAME:.spec.containers.name
NAME
<none>
<none>

To visualize the structure, here is an example with one pod, notice that a list is returned in the output of this command:
kubectl get pod my-nginx-66b6c48dd5-gq6vd  -o jsonpath='{.spec.containers}'
[{"image":"nginx:1.14.2","imagePullPolicy":"IfNotPresent","name":"nginx","ports":[{"containerPort":80,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","volumeMounts":[{"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount","name":"default-token-cbmr2","readOnly":true}]}]


text:
Q: How to generate all the leaf to leaf path in an AST? Given a JS snippet, how to generate all the leaf-to-leaf path from the AST?
Let's say the code snippet is:
var answer = 6 * 7;
Example AST: https://esprima.org/demo/parse.html
For this code snippet, I have to generate all the paths from leaf to leaf. I can use any parser like esprima, acorn or any other parser.
I am happy to use the python parser as well https://github.com/Kronuz/esprima-python
Any idea, pointers to open source project is welcome.


text:
Q: Magento 2 - How to add custom response header to every page? I am new to Magento 2 and found no information how to add a simple response header to every page like
header("header name: value")

So how and where must a response header be set in Magento to every page?

A: You can do it within your .htaccess file, adding the line:
Header add Header-Name "header value"

This way you don't need to change Magento code


text:
Q: Automatically correct Lingua::LinkParser include lib path I'm building a script that will run on an EC2 instance that will automatically install our required packages and modules.
I'm having an issue with Perl module Lingua::LinkParser.
During compile it complains
LinkParser.xs:5:27: error: link-includes.h: No such file or directory

On Ubuntu link-includes.h is provided by package link-grammar and is installed in /usr/include/link-grammar/.
However Lingua::LinkParser's Makefile.PL is hard-coded(?) to look in /usr/local/include/link-grammar/.
Is there simple-ish way to resolve this issue?

A: Distroprefs

*

*Best practice for using slightly modifying module from CPAN?

*Install Perl modules that require customized options via CPAN

A: mob's suggestion above to just symlink /usr/include/link-grammar to /usr/local/include/link-grammar is the simplest way of handling this situation and this is what I'll use.


text:
Q: Delete , Add, Edit stringList This is a bit confusing but will try best to explain it. please ask if you need more details.
First i have a class called TPlayers Like so..
TPlayers = class
   Private
      p : array[1..20] of TStringList;
      function GetPlayer(i:integer): TStringList;

    Public
      Property player[i : integer] : TStringList read GetPlayer;

           constructor Create;   virtual;
    implementation

    uses
    main;
    {constructor}
       constructor TPlayers.Create;
       begin
         p[1] := TStringList.Create;
         p[2] := TStringList.Create;
         p[3] := TStringList.Create;
         p[4] := TStringList.Create;
         p[5] := TStringList.Create;
         p[6] := TStringList.Create;
       end;

     function TPlayers.GetPlayer(i: integer): TStringList;
    begin
      Result := p[i];
    end;

I now have FTherePlayers := TPlayers.Create to create the class.
First time i add to the stringlist like so
FTherePlayers.Player[strtoint(name2)].Add('posx='+inttostr(posL.x));

or with variables taken out
FTherePlayers.Player[1].Add('posx=15');

This seems to be fine, but next i try to update it like so
FTherePlayers.Player[strtoint(ID)].Values['posx='] := xpos;

or with variables taken out
FTherePlayers.Player[1].Values['posx='] := 12;

but then i check that value after changing it and it still says 15, thus when i do
showmessage(fthereplayers.player[1].Values['posx']);

it returns 15 but it should be 12.  Any idea why its not changeing?
thanks
Glen

A: You have an extra equals sign at the end of the Name index value of the Values property. You need to use only the name portion of a name value pair without the equals sign. So, in your code just replace the following lines:
// here is an extra equals sign in 'posx=' index value
FTherePlayers.Player[1].Values['posx='] := 12;
FTherePlayers.Player[strtoint(ID)].Values['posx='] := xpos;

with this:
FTherePlayers.Player[1].Values['posx'] := 12;
FTherePlayers.Player[strtoint(ID)].Values['posx'] := xpos;


text:
Q: expandablelistview is not getting expanded when checkbox is added in parent xml I have developed the sample code of ExpandableListView in android. Data is being populated in Adapter and displaying in the ExpandableListView properly. but i am facing one severe issue of not expanding child view after tapping on Groupview.
The problem is when i add check box to the xml(parent xml) that is inflated in getgroupView() method child view does not get expanded after tapping Groupview.But, if checkbox is removed from the xml all works well.
Similar question has been posted in StackOverflow, but nothing seems to work.

A: If you place an item that is focusable in a list, then the list items no longer respond to clicks
Try to set the CheckBox android:focusable attribute to false.

A: In groupView layout set android:focusable="true" , android:clickable="true".
For checkbox set android:focusable="false"


text:
Q: How to export the table of a database in a container using a bash script? I want to export a table from a database in a container 8beb34269697, here is my procedure
$ docker exec -it 8beb34269697 bash
root@8beb34269697:/# mysqldump -u user -h localhost -p password database_name table_name > table.sql
Enter password:
root@8beb34269697:/# exit
exit
$ docker cp 8beb34269697:/table.sql .

I want to write a bash script run.sh, every time I run ./run.sh on local machine, then ta-da, table.sql is produced. Any help is appreciated.

A: You can run mysqldump command without having to enter in the container in two steps:
docker exec -ti 8beb34269697 /usr/bin/mysqldump -u user -h localhost -ppassword database_name table_name > table.sql

EDIT: changed from -p password to -ppassword because in the first case the string "password" will be taken as the database name instead of the password itself.


text:
Q: gmap3 not showing map I'm using gmap3 to show a simple desaturated map of a single location. I've searched for a few hours to get it to work, but can't seem to find the problem.
non working page : http://omnibus.teunis.be/school/contact
based on : http://demo.owwwlab.com/wp-toranj/contact/
I'm getting the following errors in the console :
jquery-3.1.1.min.js:2
Uncaught TypeError: $gmap.gmap3(...).setMapTypeId is not a function
at HTMLDivElement.<anonymous> (custom.js:398)
at Function.each (jquery-3.1.1.min.js:2)
at a.fn.init.each (jquery-3.1.1.min.js:2)
at HTMLDocument.<anonymous> (custom.js:358)
at j (jquery-3.1.1.min.js:2)
at k (jquery-3.1.1.min.js:2)

The page (scripts and css) itself is too complex for me to find the problem. Hoping to get someone to help me out on this.
I've tried using jquery 1.11.0 and 1.12.4 but the last one breaks my calendar page (based on fullcalendar.io)

A: Please remember google map provides some security feature.
When we create key for map we can restrict the use for the given URL/Domain.
So when you copy code, please remember to change the map key also if map not works.
You can create map key at the below url:-
https://developers.google.com/maps/documentation/javascript/
This will resole your problem.


text:
Q: How to fit table which is having a tick mark inside beamer slide I am preparing my presentation using a beamer. I want to insert a table with a tick mark inside, I used $\checkmark$. How to do achieve this
\documentclass{beamer}

\usepackage{multirow}

\begin{document}

\begin{frame}{Time-line}
\begin{table}[]
\begin{tabular}{|c|c|l|c|l|c|l|c|}
\hline
                                                                          & \multicolumn{7}{c|}{Status}                                                                                \\ \cline{2-8}
\multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Assigned\\ Task\end{tabular}} & \multicolumn{2}{c|}{{\color[HTML]{000000} Work partially completed}} & \multicolumn{2}{c|}{Work fully completed} & \multicolumn{2}{c|}{Work yet to start} & Documentation \\ \hline
Task 1                                                                    & \multicolumn{2}{c|}{{\color[HTML]{000000} $\Checkmark$}}             & \multicolumn{2}{c|}{}                     & \multicolumn{2}{c|}{}                  &               \\ \hline
Task 2                                                                    & \multicolumn{2}{c|}{}                                                & \multicolumn{2}{c|}{}                     & \multicolumn{2}{c|}{}                  & $\Checkmark$  \\ \hline
Task 3                                                                    & \multicolumn{2}{c|}{}                                                & \multicolumn{2}{c|}{}                     & \multicolumn{2}{c|}{}                  & $\Checkmark$  \\ \hline
Task 4                                                                    & \multicolumn{2}{c|}{}                                                & \multicolumn{2}{c|}{$\Checkmark$}         & \multicolumn{2}{c|}{}                  &               \\ \hline
Task 5                                                                    & \multicolumn{2}{c|}{}                                                & \multicolumn{2}{c|}{}                     & \multicolumn{2}{c|}{$\Checkmark$}      &               \\ \hline
\end{tabular}
\end{table}
\end{frame}
\end{document}

A: I have replaced $\Checkmark$ with \checkmark and removed the superfluous \multicolumn commands as well as the unnecessary columns. To make the table narrower, I have introduced linebreaks in the column headers. In the following MWE I have also included some alternative layouts for the table.
In order to change the color of the checkmark, use \textcolor{red}{\checkmark} or any other color of your choice.

\documentclass{beamer}
\usepackage{makecell}
\usepackage{multirow}

\usepackage{calc} % used in third example
\usepackage{booktabs} % Used in fourth example

\begin{document}
\begin{frame}{Time-line}
\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
& \multicolumn{4}{c|}{\thead{Status}}                                                                                \\ \cline{2-5}
\multirow{-2}{*}{\thead{Assigned\\ Task}}
    &  \thead{Work\\ partially\\ completed}
        & \thead{Work\\ fully\\ completed}
            & \thead{Work\\ yet to\\ start}
                & \thead{Documentation}    \\ \hline
Task 1  & \checkmark &            &            &            \\ \hline
Task 2  &            &            & \checkmark &            \\ \hline
Task 3  &            &            &            & \checkmark \\ \hline
Task 4  &            & \checkmark &            &            \\ \hline
Task 5  &            &            & \checkmark &            \\ \hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}{Time-line}
\renewcommand{\theadfont}{\normalsize}
\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
& \multicolumn{4}{c|}{\thead{Status}}                                                                                \\ \cline{2-5}
\multirow{-2}{*}{\thead{Assigned\\ Task}}
    &  \thead{Work\\ partially\\ completed}
        & \thead{Work\\ fully\\ completed}
            & \thead{Work\\ yet to\\ start}
                & \thead{Documentation}    \\ \hline
Task 1  & \checkmark &            &            &            \\ \hline
Task 2  &            &            & \checkmark &            \\ \hline
Task 3  &            &            &            & \checkmark \\ \hline
Task 4  &            & \checkmark &            &            \\ \hline
Task 5  &            &            & \checkmark &            \\ \hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}{Time-line}
\begin{table}
\centering
\begin{tabular}{|c|*{3}{>{\centering\arraybackslash}p{\widthof{completed}}|}c|}
\hline
\multirow{4}{*}{\thead{Assigned\\ Task}}
    & \multicolumn{4}{c|}{\thead{Status}}                                                                                \\ \cline{2-5}
    &  \thead{Work\\ partially\\ completed}
        & \thead{Work\\ fully\\ completed}
            & \thead{Work\\ yet to\\ start}
                & \thead{Documentation}    \\ \hline
Task 1  & \checkmark &            &            &            \\ \hline
Task 2  &            &            & \checkmark &            \\ \hline
Task 3  &            &            &            & \checkmark \\ \hline
Task 4  &            & \checkmark &            &            \\ \hline
Task 5  &            &            & \checkmark &            \\ \hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}{Time-line}
\begin{table}
\centering
\begin{tabular}{*{5}{c}}
\toprule
    & \multicolumn{4}{c}{\thead{Status}}                                                                                \\ \cmidrule{2-5}
\thead{Assigned\\ Task}
    &  \thead{Work\\ partially\\ completed}
        & \thead{Work\\ fully\\ completed}
            & \thead{Work\\ yet to\\ start}
                & \thead{Documentation}    \\ \midrule
Task 1  & \checkmark &            &            &            \\
Task 2  &            &            & \checkmark &            \\
Task 3  &            &            &            & \checkmark \\
Task 4  &            & \checkmark &            &            \\
Task 5  &            &            & \checkmark &            \\
\bottomrule
\end{tabular}
\end{table}
\end{frame}
\end{document}

A: With use of the tabularx package:

\documentclass{beamer}
\usepackage{makecell, multirow, tabularx}
\usepackage{amssymb}
\newcommand\Checkmark{\textcolor{blue}{\checkmark}}

\begin{document}
\begin{frame}
\frametitle{Time-line}
    \begin{table}
    \setcellgapes{3pt}
    \makegapedcells
    \linespread{0.84}\selectfont
\begin{tabularx}{\linewidth}{|X| *{4}{>{\centering\arraybackslash}X|}}
\hline
\multirow{3.2}{=}{\centering    Assigned Task}
    & \multicolumn{4}{c|}{Status of Work}           \\ \cline{2-5}
        &   partially completed
            &   fully completed
                &   yet to start
                    &   Documen\-tation     \\ \hline
Task 1  &   $\Checkmark$
            &   &   &                               \\ \hline
Task 2  &   &   &   & $\Checkmark$                  \\ \hline
Task 3  &   &   &   & $\Checkmark$                  \\ \hline
Task 4  &   &   $\Checkmark$
                &   &                               \\ \hline
Task 5  &   &   &   $\Checkmark$    &               \\ \hline
\end{tabularx}
    \end{table}
\end{frame}
\end{document}


text:
Q: Featureless Desktop on login
Possible Duplicate:
Unity doesn't load, no Launcher, no Dash appears

I'm pretty unfamiliar with Linux, and I've installed Ubuntu 12.04.
The install seems to have gone smoothly and everything, but I'm having troubles when I log in.
The computer boots up normally and takes me to the login screen, and once I login it takes me to a featureless desktop.  There's no list of programs on the left and no menu bar on the top.  The wallpaper is there, and I get the standard context menu when I right click the background.  I can create folders and search through them and run programs, but everything runs really slowly and windows are pinned in the upper left corner.
I tried logging into a guest account and after about a minute of a black screen with a cursor, it loaded up the normal desktop screen.  Programs are running faster, I can move windows around, I've got my list of programs on the left and my menu bar up top.


text:
Q: jquery lightbox 0.5 top margin adjust (element.style) I know this is simple action but I can't seem to find what to adjust the code.
I simply want the top margin of the lightbox to move closer to the top of the browers window (just a nudge up 10-20px).
Upon using deve tools i can do this on the jquery-lightbox div:
element.style {
top: 46.9px;
left: 0px;
}

Where in the code do i change that? it's not in the lightbox css so i'm assuming it's in the .js but what do i change?
thanks,
J


text:
Q: Run something that requires root from a system application I'm trying to run fuse from an app that runs under the system user.
using the following code in Android.mk:
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true

and the following in AndroidManifest.xml:
<manifest ...
    coreApp="true"
    android:sharedUserId="android.uid.system">

The app is located inside the AOSP code, under /packages/apps/.
When I run it, I get:

fuse: bad mount point `/path/to/folder': Permission denied

so, I figured that I need root access in order for it to work, because it works when it is run from init.rc, which can run with root credentials.
Is there a way for me to gain root access in a system app? or somehow make it work without really granting it root privileges? given that I have a full access to the AOSP code.
I tried running:
Process p = Runtime.getRuntime().exec("su");

but I get:

System.err: java.io.IOException: Error running exec(). Command: [su] Working Directory: null Environment: null


text:
Q: Dragging Ellipse over an image, storing and retrieving position values Good morning
I am trying to store/retrieve a draggable ellipse over an image.
Here is the code snippet:
https://codepen.io/lbrettsinclair/pen/RwMPwVO
Let's say I retrieve from the db the 2 values for top and left for 106 and 202, the ellipse is not set at the proper location.
Whenever I drag the ellipse and move it , my 2 input are updated with what I think are the proper values.
<div>
<input type="text" asp-for="@Model.Player_Injury.Injury_PosX" id="postop" class="form-control" value=106>
<input type="text" asp-for="@Model.Player_Injury.Injury_PosY" id="posleft" class="form-control" value=202>
</div>

could you please help me find what's wrong with either the sets of the top/left or the storing or the javascript provided.
Thank you


text:
Q: Tips for developing a mobile app with a team I am currently a high school student, I've been assigned to manage a group in my school to develop a mobile app and the problem is that all of us have no experience in making a project in a team and the greater problem is that we have only till the end of the month to submit the app.
Can I have some tips to overcome these problem?
Also we decided to do the app in Python with Kivy, we know Python.

A: *

*Sit down together and make a planning.

*Have 1 meeting (not more) on a regular base (every week) all together to be always updated on the status.

*Split the application in different subtask and assign a task to everyone. If everyone starts putting hands everywhere it will be a mess.

*Decide incremental "deliverables": Example: "by day x part y should be completed"

*Review the code -> I write something, you review my code and the opposite

*Decide upfront how to interface the different components among each other (This is very important in python since you don't have a compiler check for this like in Java...)

*Don't put the target to high! Do something easy!

A: I did some research on this a year and a half ago, so this info might be a little stale.  The way to go seemed to be to make an HTML5 application.  What this gets you is this:  It'll run on Android, iPhones, and any other phone with an HTML5 compliant browser.  If you were to focus on Android, you'd be writing in Java.  iPhone, Objective C.  It's out of your realm in either case, but HTML5 should be fairly straight-forward in comparison.

A: If you had more time i'd say do some research on agile/scrum but heres a cut down version:
1)  Initially you want to sit down together and very carefully plan out your application and all of its features. You also want to sketch out(wireframe) the user interfaces remember that their are a huge variety screen sizes, try and keep them minimalist.
Remember features are for the benefit of the end user, always remember if someone wants to add something, ask what the benefit is!
2) You absolutely should have more than one meeting a week, you should be meeting every day even if for only 15 minutes either face to face or on skype. The reason being you can discuss problems, find solutions together and most importantly adjust timescales and resources accordingly
3) You should then assign priority to each of these features along with the amount of time it will take you as a team, we use the MoSCoW scale for prioritization. You should then see if your specification can be feasibly finished in the time required, if it doesn't you may need to either redesign some features or drop low priority ones.
4) Start working as a team on the high priority items working your way down the list.
5) As you complete each item you need to go back to you original specification and check you've actually achieved the goal.
I can't stress enough how important you're daily conversations are, don't ever let anyone not attend unless they are on their death bed! If you're going to manage the project you need to know about issues very quickly.


text:
Q: I made this set of functions but I don't know why I get this error: Uncaught ReferenceError: username is not defined
I don't know why I get this error: Uncaught ReferenceError: username is not defined

The idea behind the functions is to create input elements and then append them to a form and overlay

         const signup_nav = document.querySelector(".signUp");
         //create elements
        //The first function create an element input type
         function createInput(variableNames, inputType, inputClass, inputPlaceholder) {
       let variableNames = document.createElement("input");
       variableNames.type = " ' " + inputType + " ' ";
       variableNames.placeholder = " ' " + inputPlaceholder + " ' ";
       variableNames.className = inputClass;
       return variableNames;
        }

        //The second one create the inputs
        //create inputs

        function createForm() {
       createInput(username, text, username_input, Username);
       createInput(email, email, email_input, Email);
       createInput(password, password, password_input, Password1);
       createInput(retype_password, password, retype_passwordInput, Password2);
       createInput(submit_signup, submit, submit_signup, Submit);
       return createInput();
        }

         //And the last one append everything to a form and finally to an overlay
        //append element to parent element
        function createFull() {
       //create overlay div
       const overlay = document.createElement("div");
       overlay.className = "overlay";
       document.querySelector("body").appendChild(overlay);
      //create div element
      //append it to the main overlay
       const overlayWrapper = document.createElement("div");
       overlayWrapper.className = "overlayWrapper";
       overlay.appendChild(overlayWrapper);
         //create form
         //append it to wrapper div
       const form_signup = document.createElement("form");
       form_signup.className = "form_signup";
       overlayWrapper.appendChild(form_signup);
         //append inputs to the form
       form_signup.appendChild(createForm());
       return overlay;
        }
        //click event - display overlay
        //call the last function on click event
        signup_nav.addEventListener("click", (ev) => {
     let evObject = ev.target;
     ev.preventDefault();
       if(evObject.className === "signUp" && evObject.tagName === "A") {
      console.log(evObject);
      createFull();
       }
        });

The functions are really easy, but I have no idea what is wrong

A: In
 function createForm() {
          createInput(username, text, username_input, Username);

You are using Username with capital "U", in other places you only seen to reference lowercase only for fields AND variables. Maybe it's a typo?


text:
Q: Unable to install Apache in Ubuntu 16.04 server Before I install Apache2 in Ubuntu 16.04 execute command sudo apt-get update but there is error (please see below):
Err:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://ph.archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'ph.archive.ubuntu.com'
Err:3 http://ph.archive.ubuntu.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'ph.archive.ubuntu.com'
Err:4 http://ph.archive.ubuntu.com/ubuntu xenial-backports InRelease
  Temporary failure resolving 'ph.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'ph.archive.ubuntu.com'
W: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'ph.archive.ubuntu.com'
W: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Temporary failure resolving 'ph.archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

Hoping for your immediate response with this concern.
Thank you.

A: This is now OK; I just put a DNS and restarted my network. After that, I can execute command sudo apt-get update and sudo apt-get install apache2 with out error encounter.


text:
Q: mysql procedure loop with increment Please, know I'm learning MySQL as my application continues to grow. Please keep that in mind should you be kind enough to answer my question.
I'm trying to achieve the following
I added a new row to my table, keeping track of the game number in the round, thus it will have values 1,2,3,4.... when round ends it will be reset to 1 etc
I read in the MySQL manual about loops and came up with this, however it says my syntax is wrong, I would appreciate it if a more experienced user may look this over for me.
CREATE PROCEDURE inc()
    BEGIN
      DECLARE v1 INT

      WHILE `round` ='1'

        SET v1 = v1 + 1;
    update events set `round_game_nr` ='v1'
      END WHILE;
    END;

I'm trying to achieve this

where 1st column is round and 2nd column is nr of games

A: CREATE PROCEDURE inc()
BEGIN
  DECLARE v1 INT;    --semicolon missing

  WHILE `round` ='1' DO    --Do missing

    SET v1 = v1 + 1;
    UPDATE events SET `round_game_nr` =v1;   --semicolon missing, v1 should not with ``
  END WHILE;
END;


text:
Q: Jackson: serialize only a given instance variable of a given class Note that by serialization, I mean serializing to JSON (either a JsonNode, or the String representation of it).
This is Jackson 2.2.3. My class looks like this:
public final class Foo
{
    // the one and only instance variable
    private final List<Bar> l;

    // Allows deserialization with no problem at all
    @JsonCreator
    public Foo(final List<Bar> l)
    {
        this.l = ImmutableList.copyOf(l);
    }
}

I already know how to serialize all Bar instances (tested). Now I need to be able to serialize a Foo instance.
The only thing I have been able to do at the moment is to "decorate" l with a @JsonSerialize annotation but this gives:
{ "l": [ { "serializedForm": "of bar1"}, { "serializedForm": "of bar2"} ] }

And I want:
[ { "serializedForm": "of bar1"}, { "serializedForm": "of bar2"} ]

How do I achieve that? Note: I can use jackson-annotations
Note also that I can perfectly deserialize the second form to a valid, functional, Foo instance.

A: This
{ "l": [ { "serializedForm": "of bar1"}, { serializedForm": "of bar2"} ] }

is the correct serialization of
public final class Foo
{
    // the one and only instance variable
    private final List<Bar> l;
}

The JSON is a JSON object that contains a JSON array named l that contains two other JSON objects. From a Java perspective, this is also true. You have a a Foo object, which contains a List (corresponding to the JSON array) named l, that contains x Bar objects.
If you really want that JSON, annotate your field's getter with @JsonValue. Read the javadoc carefully, because there are restrictions. For example

At most one method of a Class can be annotated with this annotation;
  if more than one is found, an exception may be thrown.


text:
Q: Why are some css elements not working on iphones? I have an issue with some css elements that are breaking on iphone browsers (safari & chrome) when it's working totally fine on desktop and android devices.
I've attached 2 images of the sign in screens as one of the examples, the code for this screen is as follows:

@font-face {
    font-family: 'Gidole Regular';
    font-style: normal;
    font-weight: normal;
    src: local('Gidole Regular'), url('../fonts/Gidole-Regular.woff') format('woff');
    }

body {
    max-width: 1920px;
    max-height: 1920px;
    background: #eee;
}

.Title {
    margin-left: 20px;
    margin-right: 20px;
    font-family: industry-inc-3d, sans-serif;
    height: 128px;
    font-weight: normal;
    font-size: 45px;
    line-height: 60px;
    text-align: center;
    color: #f05d5b;
}

.flashed-messages
{
    font-family: industry-inc-3d, sans-serif;
    height: 24px;
    font-weight: normal;
    font-size: 15px;
    text-align: center;
    color: #f05d5b;
    /* border: 1.5px solid #f05d5b;
    box-shadow: 4px 4px 0px #f05d5b;
    margin-top: 10px; */
}

.form {
    margin: 0 auto;
    display: table;
}

.email-box {
    width: 300px;
    height: 50px;
    background: #f6f7f7;
    border: 1.5px solid #f05d5b;
    box-shadow: 4px 4px 0px #f05d5b;
    position: relative;
}

.email {
    width: 299px;
    height: 24px;
    font-family: industry-inc-base, sans-serif;
    font-weight: normal;
    font-size: 20px;
    line-height: 26px;
    text-align: left;
    color: #707070;
}

.password-box {
    width: 300px;
    height: 50px;
    background: #f6f7f7;
    border: 1.5px solid #f05d5b;
    box-shadow: 4px 4px 0px #f05d5b;
    position: center;

}

.password {
    width: 299px;
    height: 24px;
    font-family: industry-inc-base, sans-serif;
    font-weight: normal;
    font-size: 20px;
    line-height: 26px;
    text-align: left;
    color: #707070;
}

.button-signin {
    margin: 0 auto;
    width: 143px;
    height: 27px;
    font-family: industry-inc-3d, sans-serif;
    font-weight: normal;
    font-size: 21px;
    text-align: center;
    color: #f05d5b;
    width: 150px;
    height: 50px;
    background: #f6f7f7;
    border: 1.5px solid #f05d5b;
    box-shadow: 4px 4px 0px #f05d5b;
}

.button {
    text-align: center;
}

.signup-text{
    font-family: "Gidole Regular";
    width: 218px;
    height: 18px;
    font-weight: normal;
    font-size: 16px;
    line-height: 26px;
    color: #707070;
    opacity: 0.5;
    text-align: center;
    position: relative;

}

.signup-link{
    font-family: "Gidole Regular";
    width: 218px;
    height: 18px;
    font-weight: normal;
    font-size: 16px;
    line-height: 26px;
    color: #707070;
    opacity: 0.5;
    text-align: center;
    position: relative;

}

.signup {
    margin-top: 30px;
    text-align: center;
}
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Sign in</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/sign_in.css') }}">
    <link rel="stylesheet" href="../static/css/sign_in.css">

    <link rel="stylesheet" href="https://use.typekit.net/oaq5uou.css">

Welcome To Precious

        {% with messages = get_flashed_messages() %}
            {% if messages %}
                {% for message in messages %}
                    {{ message }}
                {% endfor %}
            {% endif %}
        {% endwith %}

        <form class="form-signin" method="POST">

Email

<input class="email-box" type="email" name="email">

Password

<input class="password-box" type="password" name="password">

                <input type="submit" name="submit" value="Sign In" class="button-signin" >

        </form>

            No account?
            sign up

Dektop or adroid browser
Iphone browser
Anyone has an idea why that could be happening?

A: I guess you need prefixer.
Here is a good website:
https://autoprefixer.github.io/
Copy / Paste your code into the formatter and copy the formatted CSS code.
Try this CSS code:
/*
* Prefixed by https://autoprefixer.github.io
* PostCSS: v7.0.29,
* Autoprefixer: v9.7.6
* Browsers: last 4 version
*/

@font-face {
    font-family: 'Gidole Regular';
    font-style: normal;
    font-weight: normal;
    src: local('Gidole Regular'), url('../fonts/Gidole-Regular.woff') format('woff');
    }

body {
    max-width: 1920px;
    max-height: 1920px;
    background: #eee;
}

.Title {
    margin-left: 20px;
    margin-right: 20px;
    font-family: industry-inc-3d, sans-serif;
    height: 128px;
    font-weight: normal;
    font-size: 45px;
    line-height: 60px;
    text-align: center;
    color: #f05d5b;
}

.flashed-messages
{
    font-family: industry-inc-3d, sans-serif;
    height: 24px;
    font-weight: normal;
    font-size: 15px;
    text-align: center;
    color: #f05d5b;
    /* border: 1.5px solid #f05d5b;
    box-shadow: 4px 4px 0px #f05d5b;
    margin-top: 10px; */
}

.form {
    margin: 0 auto;
    display: table;
}

.email-box {
    width: 300px;
    height: 50px;
    background: #f6f7f7;
    border: 1.5px solid #f05d5b;
    -webkit-box-shadow: 4px 4px 0px #f05d5b;
            box-shadow: 4px 4px 0px #f05d5b;
    position: relative;
}

.email {
    width: 299px;
    height: 24px;
    font-family: industry-inc-base, sans-serif;
    font-weight: normal;
    font-size: 20px;
    line-height: 26px;
    text-align: left;
    color: #707070;
}

.password-box {
    width: 300px;
    height: 50px;
    background: #f6f7f7;
    border: 1.5px solid #f05d5b;
    -webkit-box-shadow: 4px 4px 0px #f05d5b;
            box-shadow: 4px 4px 0px #f05d5b;
    position: center;

}

.password {
    width: 299px;
    height: 24px;
    font-family: industry-inc-base, sans-serif;
    font-weight: normal;
    font-size: 20px;
    line-height: 26px;
    text-align: left;
    color: #707070;
}

.button-signin {
    margin: 0 auto;
    width: 143px;
    height: 27px;
    font-family: industry-inc-3d, sans-serif;
    font-weight: normal;
    font-size: 21px;
    text-align: center;
    color: #f05d5b;
    width: 150px;
    height: 50px;
    background: #f6f7f7;
    border: 1.5px solid #f05d5b;
    -webkit-box-shadow: 4px 4px 0px #f05d5b;
            box-shadow: 4px 4px 0px #f05d5b;
}

.button {
    text-align: center;
}

.signup-text{
    font-family: "Gidole Regular";
    width: 218px;
    height: 18px;
    font-weight: normal;
    font-size: 16px;
    line-height: 26px;
    color: #707070;
    opacity: 0.5;
    text-align: center;
    position: relative;

}

.signup-link{
    font-family: "Gidole Regular";
    width: 218px;
    height: 18px;
    font-weight: normal;
    font-size: 16px;
    line-height: 26px;
    color: #707070;
    opacity: 0.5;
    text-align: center;
    position: relative;

}

.signup {
    margin-top: 30px;
    text-align: center;
}

A: Some browsers add their own styling for form elements. You need to remove it by using:
.thing {
   -webkit-appearance: value;
   -moz-appearance:    value;
   appearance:         value;
}

https://css-tricks.com/almanac/properties/a/appearance/

A: Welcome to SO, Maher.
Try removing the height properties on on Title and flashed-messages. On Small screens the copy will break on multiple lines but the height is still the same. In this case the text will overlap with the content from bellow. You might experience this only on iPhone if the particular device you use has smaller screen width than the Android you use.


text:
Q: Zener diode forward voltage I'm trying to learn how Zener diodes work and I think I get the overall concept (regulating voltage to the zener voltage level), but there's one thing I don't understand.  I'm looking at this diode and see that it's zener voltage is 3.3V, but it's max forward voltage is 0.9V.
Why is the forward voltage so much lower than the zener voltage?  Is it because the diode is generally never placed in a forward biased direction (i.e. current should only generally travel in a reverse biased direction)?
Update
I was originally under the assumption that the max forward voltage was the maximum voltage the diode could handle in a forward biased direction.  Thanks to @SomeHardwareGuy for setting me straight.  The max forward voltage is the voltage required to have current flow through the diode in a forward direction.

A: It's just the basic operating principle of a diode.  An ideal diode would allow current to flow in one direction but block current flow in the other direction.  This is based on how it's made, with a p-type region, an n-type region, and a depletion zone in between.  Like the bottom diode in this picture:

When you apply a some voltage, in your case 0.9V  then the p-type holes and the n-type electrons move into the depletion region because they are repelled by their respective battery terminal.  With enough voltage (0.9V in your case) the free electrons in the depletion region get moving and current begins to flow like this:

Now in the ideal case if you were to reverse that battery the opposite will happen and you'll get no current flowing:

In the real world though you can only apply so much reverse voltage or push before you hit the breakdown voltage and current begins to flow freely in the reverse direction.   Zener diodes take advantage of this fact and are constructed to breakdown at lower voltages such as your 3.3V.
Sources:
You can read more about how zeners are made here
Or see the article I got all the pictures from here

A: Zener diodes (most are actually breakdown diodes and don't use the Zener effect) are always reverse-biased.

A: http://hyperphysics.phy-astr.gsu.edu/hbase/solids/zener.html Forward drop varies with ESR and current but standard drops for a given chemistry and doping level exist for Germanium, Silicon, hot-carrier, LED's and Schottky diodes.
The reverse breakdown <5.6V is mainly the "zener effect" which has an NTC and > 5.6V is usually the "avalanche effect" with a PTC.
Side comment
There are more precise low-voltage references using bandgap and floating gate analog cell that is essentially unaffected by external influences such as variation in temperature, input voltage, and time. ( but affected by airport X-RAY machines)


text:
Q: CKEditor Stylesheet in document We are offering our customers a HTML editor to adjust their email templates. However some email templates have a custom stylesheet at the top.
Something linke this:
<style type="text/css">

div, p, a, li, td { -webkit-text-size-adjust:none; text-decoration:none;}
@font-face {font-family: 'elegible_nova_rgbold_italic';src: url('http://sub.example.com/mailing/defaultFiles/elegiblenova-boldit-webfont.eot');src: url('http://sub.example.com/mailing/defaultFiles/elegiblenova-boldit-webfont.eot?#iefix') format('embedded-opentype'),url('http://sub.example.com/mailing/defaultFiles/elegiblenova-boldit-webfont.woff') format('woff'),url('http://sub.example.com/mailing/defaultFiles/elegiblenova-boldit-webfont.ttf') format('truetype');font-weight: normal;font-style: normal;}
</style>

However, when this is loaded into the CKEditor the CSS isn't in the source of the document. How can make sure the CSS is in the "text area" and will outputted as well?
I'm using creditor 3.0

A: I'm not certain because I haven't used CKEditor for several years, but I believe you need to allow this content specifically. CKEditor 4 goes further and strips even more stuff out and requires an additional setting to be configured.

A: Use config.contentsCss to insert additional styles into CKEditor editing area. Classic CKEditor is based on <iframe> and it won't apply global styles of the web page to the content, unless you specify them that way.

*

*More about styles

*Even more about styles


text:
Q: Hibernate Query, how to use like or = on where clause depend on value passed I have the following code and query :
String kodeCustomer, kodeDropship, kodeSales, kodePengirim;

kodeCustomer = kodeCustomerTextField.getText().trim();
kodeDropship = kodeDropshipTextField.getText().trim();
kodeSales    = kodeSalesTextField.getText().trim();
kodePengirim = pengirimTextField.getText().trim();

... some other code ...
      record = session.createQuery("from PenjualanTableDb where"
    + " dtanggalpenjualan >= :dawalParm"
        + " and dtanggalpenjualan < :dakhirParm"
        + " and coalesce(ckodecustomer,'') like :custParm"
        + " and coalesce(ckodedropship,'') like :dropshipParm"
        + " and coalesce(ckodesalesperson,'') like :salesParm"
        + " and coalesce(ckodepengirim,'') like :pengirimParm")
    .setParameter("dawalParm", tanggalMulaiTrx)
        .setParameter("dakhirParm", tanggalAkhirTrx)
        .setParameter("custParm", kodeCustomer + "%")
        .setParameter("dropshipParm", kodeDropship + "%")
        .setParameter("salesParm", kodeSales + "%")
        .setParameter("pengirimParm", kodePengirim + "%")
    .list();

how to modify the query so it can give the correct output based on user input.
if textfield empty then the query using like, but if textfield not empty then query using =
Is there an easy way to handle that?
Thanks in advance

A: I think you should construct the hql query (including parameters) dynamically according to the parameters present instead of using "a like%".

A: record = session.createQuery("from PenjualanTableDb where"
    + " dtanggalpenjualan >= :dawalParm"
        + " and dtanggalpenjualan < :dakhirParm"
        + " and coalesce(ckodecustomer,'') like '%:custParm%'"
        + " and coalesce(ckodedropship,'') like '%:dropshipParm%'"
        + " and coalesce(ckodesalesperson,'') like '%:salesParm%'"
        + " and coalesce(ckodepengirim,'') like '%:pengirimParm%'")
    .setParameter("dawalParm", tanggalMulaiTrx)
        .setParameter("dakhirParm", tanggalAkhirTrx)
        .setParameter("custParm", kodeCustomer)
        .setParameter("dropshipParm", kodeDropship)
        .setParameter("salesParm", kodeSales)
        .setParameter("pengirimParm", kodePengirim)
    .list();


text:
Q: How to check what prevents an object from being eligble for garbage collection? I am using Memory Analyzer to profile my program memory consumption. I have some big objects that i want to make eligble to GC after certain conditions hold, In practice, when those conditions occure, i was expecting to see a line on console that says that any of those bjects got finalized since i added a log line in an override of finalize method of object. so it seems like those objects never GC, I want to trace what objects holds reference to those specific objects preventing their GC. how is it done?

A: Quoting the documentation:

When you see something suspicious, right-click on the item and select Path To GC Roots > exclude weak references. This opens a new tab that traces the references to that object which is causing the alleged leak.

You may also be interested in Patrick Duboy's Google I|O 2011 presentation on this topic. Here are the slides and the video.


text:
Q: How to add new property in existing constructor as a parameter I have created two constructor Person and Employee. Employee construct inheriting the property of Person. This working fine. Now I want to add new property in Person constructor with prototype. But getting blank string. Please help.
JS Code
function Person (age, weight) {
        this.age = age;
        this.weight = weight;
    }

    Person.prototype.name = name;

    //we will give Person the ability to share their information.
    Person.prototype.getInfo = function () {
        return "I am " + this.age + " year old and weight " + this.weight + " kg.";
    };

    function Employee (age, weight, salary, name) {

        //Person.call(this, age, weight);  // by call parameters as arguments
        Person.apply(this, arguments);  // by apply arguments as array
        this.salary = salary;
    }

    Employee.prototype = new Person();
    Employee.prototype.constructor = Employee;

    Employee.prototype.getInfo = function () {
        return "I am "+this.name+" " + this.age + " year old and weight " + this.weight + " kg having $" + this.salary +" pm salary";
    }

    var person = new Employee(30, 70, 4000, "Manish");
    console.log(person.getInfo());

    document.write(person.getInfo());

Demo Fiddle

A: You could try this implementation:
function Person (age, weight, name) {
    var  proto = this.getProto(this);
    this.age = age;
    this.weight = weight;
    if (proto) {
        proto.name = name;
    }
}

Person.prototype.getProto = function (instance) {
    var proto;
    if (Object.getPrototypeOf) {
        proto = Object.getPrototypeOf(instance);
    } else {
        proto = instance.__proto__;
    }
    return proto;
}

//we will give Person the ability to share their information.
Person.prototype.getInfo = function () {
    return "I am " + this.age + " year old and weight " + this.weight + " kg.";
};

function Employee (age, weight, salary, name) {

    Person.call(this, age, weight, name);  // by call parameters as arguments
    //Person.apply(this, arguments);  // by apply arguments as array
    this.salary = salary;
}

Employee.prototype = Object.create(Person.prototype);
Employee.prototype.constructor = Employee;

Employee.prototype.getInfo = function () {
    return "I am "+this.name+" " + this.age + " year old and weight " +
        this.weight + " kg having $" + this.salary +" pm salary";
}

var person = new Employee(30, 70, 4000, "Manish");
console.log(person.getInfo());

document.write(person.getInfo());

Also better using Object.create for inheritance instead of instance more details about that please read in answer
More different approached for getting prototype in answer

A: I have used below approach to accomplish my requirement with Object.create as suggested by Pencroff.
function Person () {};
function Employee(){};

// helper function for Object.create()
Function.prototype.extends = function(superclass){
    this.prototype = Object.create(superclass.prototype);
    this.prototype.constructor = this;
}

Employee.extends(Person);

//Helper function for add methods in consturctor.
Function.prototype.methods = function(name, func){
    this.prototype[name] = func;
    return this;
}

Person
    .methods("name", function(name){ return name; })
    .methods("age", function(age){ return age;})
    .methods("weight", function(weight){ return weight;})
    .methods("getPersInfo", function(age, weight){
        var persAge = this.age(age),
            persWeight = this.weight(weight);
        return "I am " + persAge + " year old and weight " + persWeight + " kg.";
    });

Employee
    .methods("salary", function(salary){return salary;})
    .methods("getInfo", function(name, age, weight, salary){
        var empAge = this.age(age),
            empWeight = this.weight(weight),
            empName = this.salary(name),
            empSalary = this.salary(salary);

        return "Empoyee name is "+empName+ " age " + empAge + " year old and weight " + empWeight + "kg. having $"+empSalary+" in hand.";
    });

var person = new Person();
var employee = new Employee();

console.log(employee.getInfo("Mahesh", 30, 70, 4000));
document.write(employee.getInfo("Mahesh", 30, 70, 4000));


text:
Q: Problem with google maps on IE + pop up layer I'm using a jQuery plug-in "Boxy" (http://onehackoranother.com/projects/jquery/boxy/) to open a pop-up layer and show a map on it. It works perfectly on all browsers except IE (7 & 8). Some elements like shadow of the marker & infoWindow are transparent, so that you can see
background of the page.
Here's the test page: http://kostik.de/maps/create.html (click "edit" to open pop up, then watch Marker and InfoWindow-shadow).
any idea anyone?...

A: The border around the infoWindow is an issue with Boxy, it doesn't work on IE8 from their demos either.  Maybe you can try a different lightbox plugin - Facebox looks like one that is similar to the style you're after and it works in IE.  You might want to look at this StackOverflow post for info about the transparent PNGs in IE.


text:
Q: Operator notation for arbitrary fields I'm trying to come up with a bijection between $\mathbb{R}$ and a complete totally ordered field $F$. Bearing in mind that $F$ is arbitrary, is it still OK to use operators such as $+$, $-$, $\cdot$, $/$ and $\sum$ on elements of $F$, and have it be understood from context that these are supposed to be $F$'s operators?

A: Provided that it's clear from context whenever you write $x+y$ which field $x$ and $y$ come from, then it's clear which field $+$ belongs to, so it's fine. (And similar for other operators.)


text:
Q: Critical points of an integral function Can anyone help me in this exercise?

Be $f: \mathbb{R}^2 \to \mathbb{R}$
$$f(x, y) = \int_x^y \dfrac{t-1}{1+t^6}\ \text{d}t$$
Determine the critical point(s) of $f$ and classify it/them.

Be then $A = \{(x, y)\in\mathbb{R}^2: |x| \leq 1, |y| \leq 1\}$. Determine $f(A)$

I tried to solve the integral but there is no simple way to do it, I think. I tried to see the denominator as a sum of cubes
$$t^6+1 = (t^2)^3 + 1^3 = ((t^2+1)(t^4-t^2+1)$$ but it did not lead me to a suitable solution. Partial fractions seem no the case either. How could I do it?
Also the second request: can someone explain what does it mean $f(A)$? I really cannot understand how to proceed for this. How can I write the "function of a set"?
EDIT
My first question was really silly. Thanks to the two people who commented, I really remembered the differentiating under the integral sign theorem!
Yet I need some help for the second point...


text:
Q: AJAX call in backend results in empty update_option In the admin backend pages I get some settings saved in a multidimensional array, update them and then save them again in an AJAX callback function. The problem is that the saved settings are empty, but if I save the array to a different option it works. I boil it down to the code below.
public function my_ajax_callback() {

    $options = get_option('user_manager_options');

    // Saves the multidimensional array returned above. Excellent.
    update_option('test_option', $options);

    // Has a completely blank value in the database. Terrible and illogical.
    update_option('user_manager_options', $options);

    die();
}

This makes no sense and I've spent hours on it now. I have serialised the array with maybe_serialize which did not work.

A: I figured it out, when registering with register_setting the second parameter is the name of the settings you will be saving and updating, the parameter is pass in here to whitelist it against being updated outside of the plugin. The AJAX callback is deemed outside of the plugin.
My register settings is below and the second option is the same as the one in get_option in my question. For the settings that I will be changing I will simply use a different name.
register_setting(
    'user_manager_group',
     'user_manager_options',
     array($this, 'sanitize')
);


text:
Q: CV::Mat causing runtime error - OpenCV Error - Assertion failed I am working on a image processing project and i am encountering a crash in the system. This is the error that keeps popping:

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si
  ze.p[0] && (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channel
  s()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3
  ) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file d:\libs\opencv-249\build\i
  nclude\opencv2\core\mat.hpp, line 537

I was able to find that the following bit of code is making the problem
samples = (src.size(), src.type());
imshow ("source" , src);
for( int y = 0; y < src.rows; y++ )
for( int x = 0; x < src.cols; x++ )
  for( int z = 0; z < 3; z++){

      samples.at<float>((y + (x*src.rows)), z) = src.at<Vec3b>(y,x)[z];}

samples is a Mat object that is declared in the header file of this class.
I also referred to this link but even though the error is the same the code that is causing the crash is not the same as mine. But the awkward thing is that this exact piece of code works fine within another function, but when i try to include the same code within a method that belongs to a class it is making this error.
I am clueless. Can anyone help me out?

A: In the call samples.at<float>((y + (x*src.rows)), z) you access the image at a point where x = z and y = (y + (x*src.rows).
The highest value for y you can get is (y + (x*src.rows)) = (src.rows-1 + ((src.cols-1)*src.rows)) = src.rows*src.cols-1. This is much higher than the maximum allowed value of src.cols-1, so OpenCV throws an assertion telling you that this is out of the range of the image.
I don't know why it works in one part of the code and not in another, but this is clearly an issue.
Also, whats src.type()? Why do you access samples as "floats" and src as "Vec3b", when they both have the same type? This seems to be very dangerous to do, as well.

A: It seems that you want samples to be a matrix with:
# rows     : src.rows * src.cols
# cols     : src.channels() // it's probably 3,
type       : CV_32F (float)
# channels : 1 (single channel matrix)

You than access the rows of samples using the index of the position (r,c) in src:
int index = r * src.cols + c;

For example, if src is a 2x4 3 channel image (with random values):

You want samples to be a 8x3 single channel float matrix:

Code:
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;

int main()
{
    // Init src image
    Mat src(2, 4, CV_8UC3);
    randu(src, Scalar(0, 0, 0), Scalar(255, 255, 255));

    // Init samples image
    // # rows = src.rows * src.cols
    // # cols = src.channels()
    // type   =  CV_32FC1 (single channel float, while src type is 3 channel CV_8U)
    Mat samples(src.rows * src.cols, src.channels(), CV_32FC1);

    for (int r = 0; r < src.rows; ++r)
    {
        for (int c = 0; c < src.cols; ++c)
        {
            int index = r * src.cols + c;
            for (int channel = 0; channel < src.channels(); ++channel)
            {
                samples.at<float>(index, channel) = src.at<Vec3b>(r, c)[channel];
            }
        }
    }

    cout << "SRC: " << endl << src << endl << endl;
    cout << "SAMPLES: " << endl << samples << endl << endl;

    return 0;
}


text:
Q: gustil change part of all files names' in multiple folders I have folder on GCS which contains 4 folders: 'fold1','fold2','fold3','fold4' .
each of these folders contains GeoTiff files, but accidently, I gave wrong prefix to all the files. All the images should end with '.tif' ,' but accidently I generated files ends with '.tif.tif' .
I want to change all the names of the files in all the folders, to have only '.tif' in the name.
For example,
Image name "basel.tif.tif" will be changed into "basel.tif" .
My first step was to create "test" folder for the naming by copying the original file:
gsutil cp -r gs://bucket/folders/more_folders/even_more_folders/here_4_folders gs://bucket/folders/more_folders/even_more_folders/here_4_folders_COPY

Than I have tried to rename it using the following command:
$ gsutil -m mv gs://bucket/folders/more_folders/even_more_folders/here_4_folders_COPY/**/*.tif.tif gs://bucket/folders/more_folders/even_more_folders/here_4_folders_COPY/**/\1.tif

but I get with this error:

CommandException: Destination (gs://bucket/folders/more_folders/even_more_folders/here_4_folders_COPY//\1.tif)
must match exactly 1 URL**

I understand that I don't really "catch" the correct urls with this line, but not sure what is the mistake.
My gosl it to change names from 'name.tif.tif' to 'name.tif'

A: I have tried to rename the file extensions on my environment, you can use the gsutil mv command + sed to place the file extension and rewrite the file as desired on your Cloud Shell or local machine
IFS=$'\n'
gsutil ls gs://bucket-name/folder/*.txt| while read x; do gsutil mv $x $(echo $x | sed "s/.txt/.doc/g"); done


text:
Q: I²C level shifter pulls low side up I am using the well-known I²C level shifter from that appnote from Philips.

The 3V side is supplied by an LP2950-3.0 regulator and is loaded only moderate (a few quite lazy 74's).
The problem I'm obserivng is that the 3V side is being pulled to 5V.
I loaded the 3V side with a resistor and calculated that the level shifter presents a resistance of only 2.7 kOhms. I consider this rather low and I wonder:

*

*Is that normal behaviour or did I make some mistake?

*Isn't this harmful for the devices on the 3V side? There are several ICs that according to the datasheet are explicitly not 5V tolerant, not to forget the regulator.

A: I've just checked quickly, but your diagram looks good to me. I suspect it might be some other problem, maybe assembly of the parts or something along that line. Could you please check the following for both the SCL and the SDA line, using an ordinary Multimeter:

*

*Are you able to measure one diode drop (approx. 0.5-0.75V) across the parasitic diode in the MOSFETs from the 3V side to the 5V side?

*Do you get a reading of nearly infinite resistance (or at least some kOhms) when connecting the Multimeter's test leads the other way round, i.e. from SCL's or SDA's 5V end to their 3V ends?
Please note that these single MOSFET transistors are very (!) sensitive to ESD discharge, so even if you assembled the right parts the right way, they may have some hidden type of damage.

A: OMG, epic fail. I just found out that I grabbed from the wrong box and placed all BC857 where there should be BSN20.
However, it could be that I was right (and the BSN20 wrong) in the first place and made the mistake not before I replaced them. I don't know, because I am out of BSN20 and put in BSH108 (which have better specs anyway). Now it works fine.

A: The gate threshold of these parts can be as low as 0.4V at 25C according to the NXP datasheet.
I would guess that loading on the +3V side of the MOSFETs is creating enough Vgs to turn the FETs on in the linear region. What is the measured gate-source voltage? If it's too high you'll have to adjust your pull-ups or choose a MOSFET with a higher Vgs threshold.


text:
Q: Derivative of a function with respect to another function Can somebody explain what we are really doing when we are differentiating a function with respect to another function?(Not the formula just an intuitive explanation)
For derivatives with respect to x(or any other variable), I used the idea of a slope but this idea doesn't really make sense when talking about functional derivatives.
Can somebody help me out?

A: I can try to provide some intuition for it, confident that more competent fellow Mathstackexchangers will sort your issue out.
The expression "to differentiate with respect to another function" might be misleading. Moreover, I do not believe this is "functional derivation", which relates to functionals, a map from functions to scalars, not functions.
What is being done really, is to differentiate with respect to a transformed variable, very similar to variables change for integration.
Let me clarify with an example, $f(x) = x^2$, $f'(x) = 2x$.
The derivative with respect to a transformed variable $w(x)$ is given by the chain rule
$$ \frac{\mathrm{d}f}{\mathrm{d}w} = \frac{\mathrm{d}f}{\mathrm{d}x} \frac{\mathrm{d}x}{\mathrm{d}w}= \frac{f'}{w'}$$
A simple yet revealing case is maybe $w(x) = x^2$, so that $f = w$.
The formula above tells us it is $1$. It sounds reasonable, like the derivative of $z(x) = x$ $$\frac{\mathrm{d}z}{\mathrm{d}x}=\frac{\mathrm{d}x}{\mathrm{d}x}.$$
This can be interpreted by taking the graph of $f(x) = x^2$, and transforming the horizontal axis according to the transformation $w(x)$.
One then gets a straight line, of unitary slope, in accordance with the value of the derivative given by the formula above, or the derivative of $z$.
One more example, differentiate $f(x) = x^3$ with respect to $w(x)=x^2$.
The formula above yields $ \frac{3}{2}x$.
Let us check directly by transforming the $x$-axis to the new variable $x' = x^2$, and hence $x^3 = x' \cdot \sqrt{x'} $, now we derive with respect to $x'$ and obtain
$$ \frac{\mathrm{d}f}{\mathrm{d}x'} = \frac{3}{2} \sqrt{x'},$$ and once we transform back from $x'$ to $x$ we confirm the result given by the formula.
Hope it gives some hints. One can perfectly think about it in terms of slopes, once the correct "stretching" of the $x$-axis is made.


text:
Q: Accuracy Classification Result of Multiclass SVM We recently trained our dataset which consists of 18 classes (basic and compound facial emotions). Each class has a minimum of 100 and a maximum of 300 images. The images are also grayscale and the size is 100x100. The kernel that we used is RBF and the value for C and Gamma are 10 and 0.001 respectively. The model achieved an accuracy of 31%. How are we going to increase the accuracy of our model? As of now, we cannot change our classifier and we cannot decrease the number of classes, because it is already stated in our documentation.

A: It is hard to give a qualified answer without the data, so I'll have to speculate:
$100 \times 100$ is a $10,000$-dimensional feature space (and that's if we're taking greyscale only). You have no more than $300 \cdot 18 = 5400$ vectors in that space, which is terribly few. Classification based on raw pixels values only is likely close to impossible. Again, it depends on your data: It might work if the images are highly standardised, like the handwritten letters in the MNIST dataset, but unlikely for natural photographs.
So, the first thing I'd do would be preprocessing: Ensuring that the faces in the images occupy the same positions, are of the same size, in the same dynamic range etc. Next, I'd identify (actually, train a segmentation algorithm to identify) relevant parts of the image---eyes, mouth, nose, cheek...---to use as the features. I'd try to radically reduce the dimensionality of these features, e.g. represent the mouth as a curve or two, defined by its/their starting and ending points and the curvature.
The final classifier (SVM) should work on these features, not on directly on the pixels.


text:
Q: How to make material ui icon clickable and redirect to url I want to make GitHub icon <GitHubIcon /> clickable and make it redirect to external url, looking in the api it doesn't seem to have link prop ... https://material-ui.com/api/svg-icon/

  <AppBar position="static">
    <Toolbar>
      <Typography variant="h6" className={classes.title}>
        Made with <FavoriteIcon /> by
        <GitHubIcon />  //Not working
      </Typography>
    </Toolbar>
  </AppBar>

How is it done usually ??

A: Add this:
<GitHubIcon onClick={handlePageChange} />

and on the function definition:
const handlePageChange() {
window.location.href="pagelink"
}

or directly using an arrow function:
<GitHubIcon onClick={event =>  window.location.href='pagelink'} />

If looking to add effects on hover with material-ui styles:

How to add stlyes on Material-UI:
Import makeStyles:
import { makeStyles } from '@material-ui/core/styles';

Create the class:
const useStyles = makeStyles(theme => ({
  clickableIcon: {
    color: 'green',
    '&:hover': {
    color: 'yellow',
    },
  },
}));

Add the API call on your function declaration:
  const classes = useStyles();

And add this class to your element:
<GitHubIcon
onClick={event =>  window.location.href='pagelink'}
className={classes.clickableIcon}
/>

You could also use directly a css file.
I'm not really happy with css styling over material-ui api, specially because this horrible CSS-in-JS syntaxi, but it works well, here you'll find some documentation: Material-ui Styles