text:
Q: Ant + start copying from one folder inside the source directory I have a source directory with the following structure.
D:\Files\temporaryname\my_files_to_be_copied
The directory name "temporaryname" may vary from time to time. I need an ant script to copy the files "my_file_to_be_copied" to some other destination.
Simply I need to go one folder inside the source directory and start copying all. Please assist. Thanks in advance.

A: Lots of ways to do this here's one example, demonstrating filesets and mappers.
Example
├── build.xml
├── build
│   └── destination
│       ├── file1.txt
│       ├── file2.txt
│       ├── file3.txt
│       └── file4.txt
└── src
    ├── dir1
    │   └── my_files_to_be_copied
    │       ├── file1.txt
    │       └── file2.txt
    └── dir2
        └── my_files_to_be_copied
            ├── file3.txt
            └── file4.txt

build.xml
<project name="demo" default="copy">

   <target name="copy" description="Copy files">
      <copy todir="build/destination">
         <fileset dir="src" includes="**/my_files_to_be_copied/**"/>
         <cutdirsmapper dirs="2"/>
      </copy>
   </target>

   <target name="clean" description="Additionally purge ivy cache">
      <delete dir="build"/>
   </target>

</project>


text:
Q: Android :switch between Layouts dynamically every 10 seconds android beginner here. any help is much appreciated .
I am working on an app that can do a simple experiment.
the app displays images and asks users to rate it from 1 to 10.
I have 1 activity and two layouts experiment begins.
I have two layouts merged under FrameLayout.
what I want to achieve is :
'====>start experiment >show first image for 10 seconds >change layout to ratings layout>after user selects rating>loopback with different image>finish() when imagelist is empty. '
here is what I tried
I have tried viewflipper but shownext() and showprevious() methods dont update values.
now i am trying using layout visibility ,showing and hiding the layouts
class Presenter : AppCompatActivity() {
    //val currentTime = Calendar.getInstance().time
    private lateinit var binding: ActivityPresenterBinding
    lateinit var layout1:View
    lateinit var layout2:View
    val imgList=Constants.getImages()

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    //setContentView(R.layout.activity_presenter)

    binding = ActivityPresenterBinding.inflate(layoutInflater)
    setContentView(binding.root)

    layout1 = binding.imageView
    layout2=binding.ratingView

    startSlider()

}

private fun startSlider() {
    Handler(Looper.getMainLooper()).apply {
        //arr.shuffle()
        var index = 0
        var imageView = binding.imgPresenter
        val runnable = object : Runnable {
            override fun run() {
                imageView.setImageResource(imgList[index].image)
                layout1.visibility= View.VISIBLE
                Log.i("number ","${index}")
                postDelayed(this, 5000)
                index++
                layout1.visibility=View.GONE
                layout2.visibility=View.VISIBLE
                binding.sbSeekbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
                    override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {

                        Toast.makeText(applicationContext, "$p1", Toast.LENGTH_LONG).show()
                        //save rating (1-10)

                    }

                    override fun onStartTrackingTouch(p0: SeekBar?) {

                    }

                    override fun onStopTrackingTouch(p0: SeekBar?) {

                    }

                })

            }

        }

        postDelayed(runnable, 1000)
    }
}

here my layout file
<FrameLayout android:id="@+id/viewFliper"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/img_presenter"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/ic_bg"
        />

</LinearLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/ratingView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp"

    >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="how do you feel about this image from one to 10"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_marginBottom="20dp"
        />

    <SeekBar
        android:id="@+id/sb_seekbar"
        style="@style/Widget.AppCompat.SeekBar.Discrete"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:max="10"
        android:paddingStart="6dp"
        android:paddingEnd="6dp"
        android:progress="3"
        android:stepSize="1" />

</LinearLayout>

this is not hiding the views after the second image
what am I doing wrong?

A: try this and apply viewbinding
    lateinit var  runnable: Runnable

private fun startSlider() {
    Handler(Looper.getMainLooper()).apply {

        var flag = 0
        var index = 0

        runnable = Runnable {
            if (flag == 0) {

                img_presenter.setImageResource(imgList[index])
                layout1.visibility = View.VISIBLE
                layout2.visibility = View.GONE

                postDelayed(runnable, 5000)

                flag = 1

                index++
            } else {

                layout1.visibility = View.GONE
                layout2.visibility = View.VISIBLE

                sb_seekbar.setOnSeekBarChangeListener(object :
                    SeekBar.OnSeekBarChangeListener {
                    override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {

                        //                                Toast.makeText(applicationContext, "$p1", Toast.LENGTH_LONG).show()
                        //save rating (1-10)

                    }

                    override fun onStartTrackingTouch(p0: SeekBar?) {

                    }

                    override fun onStopTrackingTouch(p0: SeekBar?) {
                        index++

                        flag = 0

                        postDelayed(runnable, 1000)
                    }
                })
            }
        }

        postDelayed(runnable, 1000)
    }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: ACL feed for the document Since there is no api to retrieve the ACL feed for a document in Google Drive, I am using Google Document Api to get it done. I tried the protocol method which is mentioned here https://developers.google.com/google-apps/documents-list/#retrieving_the_acl_for_a_document_file_or_collection, but I get an error Invalid Request URI even though I am following same method mentioned in the above link with correct access token...Am I missing something??

A: You have to replace resource_id in the URI below with the id of the resource you want to retrieve ACL for:
GET https://docs.google.com/feeds/default/private/full/resource_id/acl

If you are doing so and it still doesn't work, please show us the URI you are using.


text:
Q: Setupping memcache as default only for doctrine queries in symfony I am trying to setup memcache for my doctrine queries by default in my prod environment, not going really well can't really find how to do that in the doc..
Is there a simple setting to do that ?
Thanks!

A: There are two kinds of cache you might want to use: query cache and results cache. You can read more about it in the doctrine docs.
In the examples you'll find Doctrine_Cache_Apc driver. Using other kinds of drivers, like memcache, is dead simple. Just use appropriate class name (for memcache it's Doctrine_Cache_Memcache).
Example (in ProjectConfiguration.class.php):
public function configureDoctrine(Doctrine_Manager $manager)
{
    $cacheDriver = new Doctrine_Cache_Memcache( $options ); // insert your options!
    $manager->setAttribute( Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver );
}

My article about cache in symfony+doctrine might be helpful as well: http://www.zalas.eu/symfony-meets-apc-alternative-php-cache
I mention APC but it'll work for memcache too.


text:
Q: Wildfly 9 SSL/HTTPS: What certificates are needed? I am trying to get SSL working on a Wildfly 9.0.1 standalone server, but am unsure what certificates if any should be in the keystore created. I have ran the following command from the Wildfly 9 admin guide:
keytool -genkey -alias server -keyalg RSA -keystore server.keystore -validity 365
However, this server exists behind a corporate proxy for which many client applications require us to set certifications. I've done this in the past by saving them with Certificate Export Wizard through Google Chrome, then importing them using keytool.
The Certification path contains a root cert, a sub cert below root, another sub cert for the local URL used by some of our applications, and finally a cert for the URL of the site being accessed.
So, my questions are thus: Which if any of the above certs are necessary for SSL/HTTPS on Wildfly? Do they belong in the same "server.keystore" created by that command, or should the exist separately? And would additional information beyond the certs and the steps outlined in the Admin Guide be necessary to enable SSL/HTTPS on Wildfly 9 when operating within a proxy?


text:
Q: Algebraic property of Riemann-Stieltjes integral I have to prove the following property:
If $f \in R(\alpha)$ in $[a,b]$ and $f \in R(\beta)$ in $[a,b]$, then $f \in R(\alpha +c \beta)$ in $[a,b]$ and
$$ \int_a^b f \, d(\alpha + c\beta) = \int_a^b f \, d\alpha + c\int_a^b f \, d\beta $$
And what I tried to do is:
First let $$S(P,f,g)=\left\vert\sum_{k=1}^n f(t_k)  (g(x_k)-g(x_{k-1}))-A \right\vert< \epsilon$$
By hypothesis, as $f \in R(\alpha)$ in $[a,b]$, then exist $A_1 \in \mathbb R$ such that for every $\epsilon>0$, exist $P_1 \in P([a,b])$ and for all $t_k \in[x_{k-1},x_k]$, $\vert S(f,P_1,\alpha)-A_1 \vert< \frac{\epsilon}{2}$.  (The definition of Riemann-stieltjes)
Also we have for $f \in R(\beta)$ in $[a,b]$, then exist $A_2 \in \mathbb R$ such that for every $\epsilon>0$, exist $P_2 \in P([a,b])$ and for all $t_k' \in [x_{k-1},x_k]$, $\vert S(f,P_2,\beta)-A_2 \vert< \frac{\epsilon}{2}$.
Then I tried to analyze $\left\vert S(P,f,\alpha - c\beta)-\int_a^b f \, d\alpha + c\int_a^b f \, d\beta
\right\vert$. (1)
The problem is that I don't know how to take the new partition (to then conclude that (1) is less than epsilon), maybe the intersection of $P_1$ and $P_2$? idk .

A: I am also doing analysis this semester. I think the proof is similar to the case where $f = f_1 + f_2$. Also, I think we need the condition $c > 0$ since we demand $a+c\beta$ to be increasing.

(1) $f \in \mathscr{R}(\alpha+c\beta)$ on $[a,b]$.

Pick any $\epsilon >0$. We construct a partition $P$ such that $U(P,f,\alpha+c\beta)- L(P,f,\alpha+c\beta) < \epsilon$.
There is a partition $P_1$ such that $U(P_1,f,\alpha)- L(P_1,f,\alpha) < \epsilon/2$.
There is a partition $P_2$ such that $U(P_2,f,\beta)- L(P_2,f,\beta) < \epsilon/(2c)$.
Let $P=P_1\cup P_2$. Then
$$L(P_1,f,\alpha) \leq L(P,f,\alpha) \leq U(P,f,\alpha) \leq  U(P_1,f,\alpha)$$
$$L(P_2,f,\beta) \leq L(P,f,\beta) \leq U(P,f,\beta) \leq  U(P_2,f,\beta)$$
$$L(P,f,\alpha)+cL(P,f,\beta) =\sum m_i[\alpha(x_i)-\alpha(x_{i-1})]+c\sum m_i[\beta(x_i)-\beta(x_{i-1})]=\sum m_i[(\alpha+c\beta)(x_i)-(\alpha+c\beta)(x_{i-1})]=L(P,f,\alpha+c\beta)$$
$$\implies L(P_1,f,\alpha)+cL(P_2,f,\beta)\leq L(P,f,\alpha+c\beta)\leq U(P,f,\alpha+c\beta) \leq U(P_1,f,\alpha)+ cU(P_2,f,\beta)$$
$$\implies U(P,f,\alpha+c\beta)- L(P,f,\alpha+c\beta)\leq [U(P_1,f,\alpha)+ cU(P_2,f,\beta)]-[L(P_1,f,\alpha)+cL(P_2,f,\beta)]<\epsilon/2 + c(\epsilon/(2c))=\epsilon $$
Thus (1) is done.

(2)
  $$\int_a^b f d(\alpha+c\beta) = \int_a^b f d\alpha+ c \int_a^b f d\beta $$

Suppose
$$\int_a^b f d(\alpha+c\beta) > \int_a^b f d\alpha+ c \int_a^b f d\beta$$
Then let $\epsilon =\int_a^b f d(\alpha+c\beta) - \int_a^b f d\alpha+ c \int_a^b f d\beta$.
For $f \in \mathscr{R}(\alpha)$, there is a partition $P_1$ such that $U(P_1,f,\alpha) - L(P_1,f,\alpha) < \epsilon/2$
For $f \in \mathscr{R}(\beta)$, there is a partition $P_2$ such that $ U(P_2,f,\beta) - L(P_2,f,\beta) < \epsilon/(2c)$
Again, take $P = P_1\cup P_2$.
Since we have
$$\int_a^b f d(\alpha+c\beta)  \leq U(P,f,\alpha+c\beta),\  L(P_1,f,\alpha) \leq \int_a^b f d\alpha,   L(P_2,f,\beta)\leq\int_a^b f d\beta  ,$$
$$U(P_1,f,\alpha)  -\int_a^b f d\alpha \leq U(P_1,f,\alpha) - L(P_1,f,\alpha)  < \epsilon/2 $$
$$  U(P_2,f,\beta)  -\int_a^b f d\beta \leq U(P_2,f,\beta) - L(P_2,f,\beta) < \epsilon/(2c) $$
$$\implies \int_a^b f d(\alpha+c\beta) -\int_a^b f d\alpha-c \int_a^b f d\beta \leq  U(P,f,\alpha+c\beta)-\int_a^b f d\alpha-c \int_a^b f d\beta < \epsilon $$
$$\implies  \int_a^b f d(\alpha+c\beta) < \int_a^b f d(\alpha+c\beta) $$
Contradiction arises. Similar for the other side...


text:
Q: Vanity URLs without trailing slashes on Nginx With some help from @jon-lin, we figured out how to remove trailing slashes on Apache (Vanity URLs without trailing slashes on Apache); now, as we plan to run our site on Nginx, we'd like to do the same. We tried several suggestions we found on stackoverflow and elsewhere, but all result in an infinite loop (probably because browsers try to put the slashes back in). Our current configuration (with three of our attempts -- rewrite ^/(.*)/$ https://www.example.com/$1 permanent; rewrite ^/(.*)/$ https://www.example.com/$1; and rewrite ^/(.*)/$ /$1 permanent; -- commented out) is:
server {
        listen 80;
        server_name  example.com;
        return 301 https://www.example.com$request_uri;
}
server {
        listen 80;
        server_name  www.example.com;
        return 301 https://www.example.com$request_uri;
}
server {
        listen 443;
        server_name  example.com;
        return 301 https://www.example.com$request_uri;
}

server {
        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;
        server_name www.example.com;

        #rewrite ^/(.*)/$ https://www.example.com/$1 permanent;
        #rewrite ^/(.*)/$ https://www.example.com/$1;
        #rewrite ^/(.*)/$ /$1 permanent;

        root /var/www/example.com/html;
        index index.php index.html index.htm;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
        }

        ssl on;
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:10m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECD$
        add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
        ssl_dhparam /etc/ssl/certs/dhparam.pem;

}

How can this be done?
In our particular case, we needed all URLs to be stripped of their trailing slashes; we accomplished that by adding the following to Apache's httpd.conf:
DirectorySlash Off

RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*[^/])$ /$1/

Then, rewriting all entries in /profiles/ was accomplished with this:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /profiles/$1 [NC,L]

A: If your no longer use the /profiles/ directory, this should work:
server {
  ...
  root /var/www/example.com/html;
  index index.php index.html index.htm;

  location / {
    try_files $uri @rewrite;
  }
  location @rewrite {
    rewrite ^(.*[^/])$ $1/;
  }
  location ~ \.php$ { ... }
}

In the above configuration we avoid the $uri/ element on the try_files as it triggers a redirect that adds a trailing / to the current URL.
If you want a configuration similar to your previous Apache configuration, then this should work:
server {
  ...
  root /var/www/example.com/html;
  index index.php index.html index.htm;

  location / {
    try_files $uri $uri/ @rewrite;
  }
  location @rewrite {
    rewrite ^(.*[^/])$ /profiles$1/;
  }
  location ~ \.php$ { ... }
}

As you can see, the $uri/ element does no harm in this situation.
Following your comments and recent edit, this third (less elegant) configuration combines features from the other two, and is a close (but not exact) implementation of your Apache configuration:
server {
  ...
  root /var/www/example.com/html;
  index index.php index.html index.htm;

  location = / { rewrite ^ /index.php; }
  location / {
    try_files $uri @rewrite;
  }
  location @rewrite {
    if (-d $document_root/profile$uri) { rewrite ^ /profiles$uri/ last; }
    if (-d $request_filename) { rewrite ^(.*[^/])$ $uri/ last; }
  }
  location ~ \.php$ { ... }
}

And finally, this version deviates slightly from the brief. The php execution block is replaced by a named location. But is does allow the use of cascaded try_files directives, removing the nasty if directives, and discarding index in the process. Enjoy:
server {
  ...
  root /var/www/example.com/html;

  location / {
    try_files $uri $uri.html $uri/index.html /profiles$uri/index.html @php;
  }
  location @php {
    try_files $uri.php $uri/index.php /profiles$uri/index.php =404;
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
  }
  location ~ \.php$ { rewrite ^(.*)\.php$ $1 permanent; }
}

It's a hybrid of slash-less and extension-less php, with your profiles tweak.

A: Combining @richard-smith's first option in his answer here with the "evil" if, we made it work:
    location / {
        if (!-e $request_filename) {
        rewrite ^(.*)$ /profiles$1/ break;
        }
        try_files $uri @rewrite;
    }

    location @rewrite {
        rewrite ^(.*[^/])$ $1/;
    }

Now all trailing slashes are gone and profiles in example.com/profiles/profile/ are rewritten to example.com/profile


text:
Q: Is it possible to create a photo sharing app like Instagram using Smartface Is it possible to create a photo sharing app like Instagram using Smartface?
I've tried cloning Instagram using another software however it wasn't successful.
Thankyou
I really appreciate this

A: It is possible to create photo sharing app.If you do backend anyway that you can do, you can do front end of application by using Smartface

A: To get and display an image is simple. If you want to implement the "filters" part, then the story is different. SmartFace doesn't have a image processing option/library built in. So you need to implement this feature yourself.
A good option for beginners might be another product like: B4A https://www.b4x.com/b4a.html .. where the community have already created a lot of libraries/resources.


text:
Q: How to make background div not count in scrollable area I have a situation where I need to create a div element which is wider a viewport defined by another div. If tried changing border, padding, and margin of the various divs without much luck.
Here's the CSS:
#page_content {
    width:200px;
}

#content_container {
    overflow-y: auto;
    background-color:#999999;
}

#content_inner {
    padding:20px;
}

and the html

JSFiddle
What I would like is for the scrollable area to be limited to 20px past the red div, but the yellow div needs to be a fair bit wider than the viewport

A: I figured it out :)
css
#page_content {
    width: 200px;
    height: 200px;
    margin:auto;
}

#content_container {
    overflow-y: auto;
    overflow-x: auto;
    background-color:#ffffff;
}

#content_inner {
    width: 200px;
    height: 200px;
}

.hex-row {
    margin-left: 17px;
    height: 50px;
    clear: left;
}

.hex-wrapper {
    text-align: center;
    float: left;
    position: relative;
    width: 30px;
    height: 50px;
    line-height: 50px;
    margin-right: 17px;
    margin-bottom: -24px;
}

.hex-wrapper.even {
    margin-top: 27px;
}

.hex {
    vertical-align: middle;
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 50px;
    background: #114781;
}

.hex:before,  .hex:after{
    vertical-align: middle;
    content: " ";
    position: absolute;
    border-top: 25px solid transparent;
    border-bottom: 25px solid transparent;
}

.hex:before {
    left: -15px;
    border-right: 15px solid #114781;
}

.hex:after {
    right: -15px;
    border-left: 15px solid #114781;
}

html

Fiddle
The trick was to create a viewport div with hidden overflow with a larger content div inside with visible overflow

A: i'm using this in my project, i created a css like this
div.scrolled {
  width: 1150px;
  height: 620px;
  overflow-y: scroll;
}

and in my html file i only identify what area i want to introduce into my div and i do this
div class="scrolled">

and you will have your scroll in 'y' align, hope i helped you


text:
Q: Using socat and openssl as DTLS/PSK tunnel I want to combine openssl and socat to add encryption to plain-text UDP sockets. Specifically,
My app opens an UDP socket and sends plain-text data to 127.0.0.1:8032. I want socat to establish a DTLS session with a remote openssl server and encrypt the plain-text data sent by me app, as well as decrypt and relay back the response.
I've managed to handshake using openssl s_client:
openssl s_client -dtls1_2 -psk <KEY> -psk_identity <ID> -connect <IP>:<PORT>

but I can't get the socat tunnel to work:
socat -x -vvvvvvv SYSTEM:'openssl s_client -dtls1_2 -psk <KEY> -psk_identity <ID> -connect <IP>:<PORT>' UDP-LISTEN:8032

It seems that socat relays the plain-text data, but
I'm not sure the handshake ever gets done, and I'm not sure socat will relay the response correctly anyway with this setup. Help?

A: I managed to get it work with the following modification. Instead of -connect <IP>:<PORT>, use -connect <IP> -port <PORT>. Not particularily intuitive imo, but dumping the traffic with wireshark made it fairly easy to figure out. Yay wireshark.


text:
Q: Is this an incorrect way to get datetime? I get datetime from this way:
class DB_Functions extends DB_Connect{

    private $dbConnect = "";
    public $dtime;

    public function __construct() {
        $this->dbConnect = $this->pdo_connect();
        $this->dtime = new DateTime();
    }

    public function destruct() {
        $this->dbConnect = null;
    }

    public function exampleInsert() {
        .
        .
        .
        $result->bindParam(':dateCreation',$this->dtime->format("Y-m-d H:i:s"),PDO::PARAM_STR);
    }
}

Then when I use dtime to insert in a table, like this:
Line 1708: $result->bindParam(':dateCreation',$this->dtime->format("Y-m-d H:i:s"),PDO::PARAM_STR);

Display this error:
Strict Standards:  Only variables should be passed by reference in include\DB_Functions.php on line 1708

My declaration to get datetime is wrong?

A: The problem is that you are using bindParam() which actually binds a variable to the parameter in the query.  This must be a variable, not a method call that returns a value.
This allows for usage like:
$value = 'somevalue';
$result->bindParam(':some_field', $value);
$value = 'someothervalue';
$result->execute(); // executes query with 'someothervalue' passed as parameter.

In your case you might want to use bindValue(). Which actually binds the value to the parameter in an immutable fashion.  Either that or store your formatted datetime into a different class variable and continue to use bindParam() with that new variable.


text:
Q: Change class for selected div only I would like it to only change the class for the clicked div. Currently it will change the class for all divs. I have written this as a Blazor component.
@for (int i = 0; i < 5; i++)
{

 ChangeDivClass()">@i

}

@code
{
    String divClass;

    private void ChangeDivClass()
    {
        if (divClass == "red")
        {
            divClass = String.Empty;
        }
        else
        {
            divClass = "red";
        }
    }
}

A: You can use an array instead of one variable.
@for (int i = 0; i < divClass.Length; i++)
 {
   var index = i;

 ChangeDivClass(index)">@i

 }

@code
 {
   string[] divClass= new string[5];

   private void ChangeDivClass(int i)
    {
     if (divClass[i] == "red")
      {
        divClass[i] = String.Empty;
      }
     else
      {
        divClass[i] = "red";
      }
  }
}

A: try below code:
@if (items != null)
{
    @foreach (var item in items)
    {

 ChangeColor(item.Id)">@item.Id

    }
}

@functions{
    //Instead of these Mock data you should load your own data
    IList<Foo> items = new List<Foo>()
         {
            new Foo { Id =1, DomClasses=new List<string>(){string.Empty}},
            new Foo { Id =2, DomClasses=new List<string>(){string.Empty}},
            new Foo { Id =3, DomClasses=new List<string>(){string.Empty}},
            new Foo { Id =4, DomClasses=new List<string>(){string.Empty}},
            new Foo { Id =5, DomClasses=new List<string>(){string.Empty}},
            new Foo { Id =6, DomClasses=new List<string>(){string.Empty}},

        };

private void ChangeColor(int id)
{
    var domClasses = items.SingleOrDefault(item => item.Id == id).DomClasses;
    if (domClasses.Contains("red"))
    {
        domClasses.Remove("red");
    }
    else
    {
        domClasses.Add("red");
    }

    RenderDomClass(id);
}

private string RenderDomClass(int id)
{
    var domClass = string.Empty;
    var domClasses = items.SingleOrDefault(item => item.Id == id).DomClasses;
    if (domClasses.Count > 0)
    {
        foreach (var item in domClasses)
        {
            domClass += $" {item}";
        }
    }

    return domClass;
}

public class Foo
{
    public int Id { get; set; }
    public List<string> DomClasses { get; set; }
}
}

The result of the above code is:

Fell free to ask question. Good Luck.

A: Create a component for this behavior :
CustomComponent.razor

@Value

@code
{
    [Parameter]
    public int Value;

    string divClass;

    private void ChangeDivClass()
    {
        if (divClass == "red")
        {
            divClass = string.Empty;
        }
        else
        {
            divClass = "red";
        }
    }
}

Your parent component become:
ParentComponent.razor
@for (int i = 0; i < 5; i++)
{
    <CustomComponet Value="@i" />
}


text:
Q: FIFO Class Implemenation Not Working I created a simple FIFO class below:
class Queue:

    # Constructor, which creates a new empty queue:
    def __init__(self):
        self.items = []
        # TODO: You must implement this constructor!

    # Adds a new item to the back of the queue, and returns nothing:
    def queue(self, item):
        return self.items.append(item)
        # TODO: You must implement this method!

    # Removes and returns the front-most item in the queue.
    # Returns nothing if the queue is empty.
    def dequeue(self):
        if len(self.items)==0:
            return None
        else:
            return self.items.pop(0)
        # TODO: You must implement this method!

    # Returns the front-most item in the queue, and DOES NOT change the queue.
    def peek(self):
        if len(self.items)==0:
            return None

        else:

            return self.items[0]
        # TODO: You must implement this method!

    # Returns True if the queue is empty, and False otherwise:
    def is_empty(self):
        return self.items == []
        # TODO: You must implement this method!

    # Returns the number of items in the queue:
    def size(self):
        return len(self.items)
        # TODO: You must implement this method!

    # Removes all items from thq queue, and sets the size to 0:
    def clear(self):
        while len(self.items) > 0:
            self.items.pop()
        # TODO: You must implement this method!

    # Returns a string representation of the queue:
    def __str__(self):
        return repr(self.items)
        # TODO: You must implement this method!

However, when using the class in another file, the dequeue() method does not seem to work, I am trying to implement a grocery store lineup where the demands are as follows:
The program should never allow more than 3 people in the lineup at
once. If the user tries to add another person to the lineup when
there are already 3 people, the program should print an error
message and continue.
If the user tries to serve the next person when there is no one in the
lineup, the program should inform the user that the lineup is empty.
When a person is served, the program should print the name of that
person.
This is my other file when I try to implement and use the class:
from queue import Queue
q=Queue()
exit==False

ase=input("Add, Serve, or Exit: ")
while ase=="Serve"  and q.is_empty()== True and exit==False:
    print("The lineup is already empty.")
    ase=input("Add, Serve, or Exit: ")
    if ase=="Exit":
        exit==True

while (q.size()<3 and ase== "Add") or (q.size()<3 and ase== "Serve"):
    add=input("Enter the name of the person to add: ")
    ase=input("Add, Serve, or Exit: ")

    q.queue(add)
    print(q.__str__())
    while q.size()==3 and ase=="Add":
        print("You cannot add more people, the lineup is full!")
        ase=input("Add, Serve, or Exit: ")

    while ase=="Serve" and q.is_empty()==False and exit==False:
        print(q.dequeue(), "has been served")

I know that it actually adds the names to the list but I do not know why it does nothing when the input is "Serve"
Also at the begging when I want it to print ("line up empty") it just doesn't even get to that line. Thoughts?

A: It seems to me that you have a problem with your exit variable: it is set to True at the end of the first loop. But your Serve loop expect it to be False to enter...
while ase=="Serve"  and q.is_empty()== True and exit==False:
    print("The lineup is already empty.")
    ase=input("Add, Serve, or Exit: ")
    if ase=="Exit":
        exit==True
#       ^^^^^^^^^^

...

    while ase=="Serve" and q.is_empty()==False and exit==False:
#                                                  ^^^^^^^^^^^
        print(q.dequeue(), "has been served")

A: Instead of using multiple while (with some imbricated), you should use only one with conditional branching to manage the different commands (add/server/exit, etc.). It would be much more clear and easy to modify.
I suggest something like this:
ase = raw_input("Add, Serve, or Exit: ")
while ase != "Exit":
  if ase == "Serve":
    if q.is_empty():
      print("The lineup is already empty.")
    else:
      # dequeue + message
  elif ase == "Add":
    if q.size() == 3:
      print("You cannot add more people, the lineup is full!")
    else:
      add = raw_input("Enter the name of the person to add: ")
      # enqueue add + message
  else:
    print("invalid command...")

  ase = raw_input("Add, Serve, or Exit: ")

A: I solved it! Here is my final code on using the class:
from queue import Queue
q=Queue()
exit==False

ase=input("Add, Serve, or Exit: ")
while ase=="Serve" and q.is_empty()==True:
    print("The lineup is already empty.")
    ase=input("Add, Serve, or Exit: ")
    if ase=="Exit":
        break

while (q.size()<3 and ase== "Add"):
    add=input("Enter the name of the person to add: ")
    ase=input("Add, Serve, or Exit: ")

    q.queue(add)
    print(q.__str__())
    while q.size()==3 and ase=="Add":
        print("You cannot add more people, the lineup is full!")
        ase=input("Add, Serve, or Exit: ")

    while ase=="Serve":
        print(q.dequeue(), "has been served")
        ase=input("Add, Serve, or Exit: ")


text:
Q: Real, mathematical "modulo" operation in Postgres? In Ruby:
-2 % 24
=> 22

In Postgres:
SELECT -2 % 24;
 ?column?
----------
      -2

SELECT mod(-2,24);
 mod
-----
  -2

I can easily write one myself, but I'm curious whether Postgres has a real modulus operation, as opposed to remainder after division.

A: SELECT MOD(24 + MOD(-2, 24), 24);

will return 22 instead of -2

A: It seems that I won't find anything easier than:
CREATE OR REPLACE FUNCTION modulus(dividend numeric, divisor numeric) RETURNS numeric AS $$
DECLARE
  result numeric;
BEGIN
  divisor := ABS(divisor);
  result  := MOD(dividend, divisor);
  IF result < 0 THEN
    result := result + divisor;
  END IF;
  RETURN result;
END;
$$ LANGUAGE plpgsql;

A: Just a belated answer to the side question that a_horse_with_no_name asked:
Yes this is specified in the SQL standard. And the mentioned vendors comply.


text:
Q: Chart.js horizontal bar size I'm trying to create a page showing multiple horizontal bar graphs using Chart.js.
As you can see in the picture below, this looks weird because the graphs are all the same height (I'm only setting the width and maintainAspectRatio = false) and so the size of the bars are all different

Is there a way to make all bars the same size?
I tried barThickness but that just distributes the values the bars in the available space.
What I wanted was for the bars to be all the same size and graphs with more bars should grow vertically.


text:
Q: Why do we use exponential distribution to model duration of constant rate events? I have partially understood why. The two major reasons stated are:

*

*Time elapsed cannot be negative

*The cumulative distribution $P(X \leq x)$ increases monotonically and asymptotically approaches 1.
Point 1 implies that the probability density function $p(x)$ should be 0 for all $x < 0$. Point 2 makes sense that as time increases, it is more likely the event will come to an end. But are there no other distributions that satisfy these criteria?
Is there a way to check the validity of this assumption in some real cases. Say, I have some duration data of a process, how can I check if it is drawn from an exponential distribution?
I hope I am not asking two different questions or something.

A: The exponential distribution satisfies the memoryless property, which is sometimes a reasonable modeling assumption. Also, often a situation where rare events are happening at random can be modeled as a Poisson process, and you can show that the waiting times between events in a Poisson process are exponentially distributed.


text:
Q: Android MediaCodec, decoding MJPEG frames EDIT:
Nevermind, I solved my problem.
//------------------------------------------------------------------------------
I'm having some problems trying to do MJPEG stream decoding using Android MediaCodec API. What I'm trying to do is to stream jpeg frames from my webcam and display them using hardware accelerated decoding on my android device (currently I'm using Nvidia Shield Tablet, Android 6.0).
Right now I'm at the point where I receive a jpeg frame and I can display it on the screen by using BitmapFactory.decodeStream() function. However, what I want to do is to decode the image on a dedicated hardware so I can get a better performance and better battery life. In order to do so I want to use MediaCodec API with a 'video/mjpeg' deocoder which I'm pretty sure is available on my device (I checked the MediaCodecList and it's right under the name 'OMX.Nvidia.mjpeg.decoder').
I'm using my MediaCodec with a SurfaceView, pretty much in the same way it's done in 'Grafika' repo. (https://github.com/google/grafika)
This is the decoder initialization code, called in surfaceCreated() callback, completes without any exceptions:
private Surface testSurface;
private MediaCodec decoder;

//....

private void initMediaApi() throws IOException {
    decoder = MediaCodec.createDecoderByType("video/mjpeg");

    MediaFormat mediaFormat = MediaFormat.createVideoFormat("video/mjpeg", 720, 480);
    mediaFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 25);

    decoder.configure(mediaFormat, testSurface, null, 0);
    decoder.start();
}

After that I have a function that is called every time a new jpeg frame is received. It takes two parameters: a byte array with jpeg image and the size in bytes of this image:
private void testMediaApi(final byte[] frameBuffer, final int length) throws IOException {

    final int TIMEOUT_USEC = 10000;

    long firstInputTimeNsec = System.nanoTime();

    int inputBufIndex = decoder.dequeueInputBuffer(TIMEOUT_USEC);
    if (inputBufIndex < 0) {
        return;
    }

    ByteBuffer inputBuffer = decoder.getInputBuffer(inputBufIndex);
    inputBuffer.clear();
    inputBuffer.put(frameBuffer, 0, length);

    decoder.queueInputBuffer(inputBufIndex, 0, length, 0, 0);

    boolean outputDone = false;

    while (!outputDone) {
        outputDone = true;

        MediaCodec.BufferInfo mBufferInfo = new MediaCodec.BufferInfo();
        int decoderStatus = decoder.dequeueOutputBuffer(mBufferInfo, 1000000);
        Log.d(LOG_TAG, "decoderStatus: " + decoderStatus);

        if (decoderStatus == MediaCodec.INFO_TRY_AGAIN_LATER) {
            // no output available yet
            Log.d(TAG, "no output from decoder available");
        } else if (decoderStatus == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
            // not important for us, since we're using Surface
            Log.d(TAG, "decoder output buffers changed");
        } else if (decoderStatus == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
            MediaFormat newFormat = decoder.getOutputFormat();
            Log.d(TAG, "decoder output format changed: " + newFormat);
        } else if (decoderStatus < 0) {
            throw new RuntimeException("unexpected result from decoder.dequeueOutputBuffer: " + decoderStatus);
        } else { // decoderStatus >= 0
            if (firstInputTimeNsec != 0) {
                // Log the delay from the first buffer of input to the first buffer
                // of output.
                long nowNsec = System.nanoTime();
                Log.d(TAG, "startup lag " + ((nowNsec - firstInputTimeNsec) / 1000000.0) + " ms");
                firstInputTimeNsec = 0;
            }

            Log.d(TAG, "surface decoder given buffer " + decoderStatus + " (size=" + mBufferInfo.size + ")");
            if ((mBufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
                Log.d(TAG, "output EOS");
                outputDone = true;
            }

            boolean doRender = (mBufferInfo.size != 0);

            // As soon as we call releaseOutputBuffer, the buffer will be forwarded
            // to SurfaceTexture to convert to a texture.  We can't control when it
            // appears on-screen, but we can manage the pace at which we release
            // the buffers.
            decoder.releaseOutputBuffer(decoderStatus, doRender);
            Log.d(TAG, "Reached EOS, looping");
            decoder.flush();    // reset decoder state
        }
    }
}

As you can see I'm waiting 1 second to complete one frame decoding, which should be plenty. Unfortunately, after the first call I receive decoder status code -1, which means output data is still not available. After the second frame is queued I get status -3 'decoder output buffers changed' and then the whole thing crashes giving me this exception:
07-20 21:21:25.512 10096-10109/piotrek.androidfpvtest W/MediaCodec: ResourceManagerService died.
07-20 21:21:25.513 10096-10127/piotrek.androidfpvtest E/ACodec: OMX/mediaserver died, signalling error!
07-20 21:21:25.513 10096-10127/piotrek.androidfpvtest E/ACodec: signalError(omxError 0x8000100d, internalError -32)
07-20 21:21:25.513 10096-10126/piotrek.androidfpvtest E/MediaCodec: Codec reported err 0xffffffe0, actionCode 0, while in state 6
07-20 21:21:25.513 10096-10125/piotrek.androidfpvtest W/System.err: java.lang.IllegalStateException
07-20 21:21:25.514 10096-10125/piotrek.androidfpvtest W/System.err:     at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
07-20 21:21:25.514 10096-10125/piotrek.androidfpvtest W/System.err:     at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2622)
07-20 21:21:25.514 10096-10125/piotrek.androidfpvtest W/System.err:     at piotrek.androidfpvtest.MainActivity.testMediaApi(MainActivity.java:226)
07-20 21:21:25.514 10096-10125/piotrek.androidfpvtest W/System.err:     at piotrek.androidfpvtest.MainActivity.doReceive(MainActivity.java:161)
07-20 21:21:25.514 10096-10125/piotrek.androidfpvtest W/System.err:     at piotrek.androidfpvtest.MainActivity.access$000(MainActivity.java:29)
07-20 21:21:25.514 10096-10125/piotrek.androidfpvtest W/System.err:     at piotrek.androidfpvtest.MainActivity$1.run(MainActivity.java:54)
07-20 21:21:25.514 10096-10125/piotrek.androidfpvtest W/System.err:     at java.lang.Thread.run(Thread.java:818)

If instead of continuously queuing frames I wait for the first one to be decoded the program gets into infinite loop with output looking like this:
07-20 21:58:29.970 10577-10641/piotrek.androidfpvtest I/OMXClient: Using client-side OMX mux.
07-20 21:58:30.110 10577-10640/piotrek.androidfpvtest I/MediaCodec: [OMX.Nvidia.mjpeg.decoder] setting surface generation to 10830849
07-20 21:58:30.115 10577-10641/piotrek.androidfpvtest I/ACodec: Enable timestamp filtering for Video Decoder
07-20 21:58:30.126 10577-10641/piotrek.androidfpvtest D/SurfaceUtils: set up nativeWindow 0xae47c708 for 720x480, color 0x106, rotation 0, usage 0x2b00
07-20 21:58:56.719 10577-10641/piotrek.androidfpvtest D/SurfaceUtils: set up nativeWindow 0xae47c708 for 720x480, color 0x147, rotation 0, usage 0x2b00
07-20 21:58:56.720 10577-10641/piotrek.androidfpvtest W/ACodec: [OMX.Nvidia.mjpeg.decoder] setting nBufferCountActual to 11 failed: -1010
07-20 21:58:56.720 10577-10641/piotrek.androidfpvtest W/ACodec: [OMX.Nvidia.mjpeg.decoder] setting nBufferCountActual to 10 failed: -1010
07-20 21:58:57.713 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:58:57.713 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available
07-20 21:58:57.714 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -3
07-20 21:58:57.714 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoder output buffers changed
07-20 21:58:58.714 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:58:58.715 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available
07-20 21:58:59.717 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:58:59.718 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available
07-20 21:59:00.720 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:59:00.720 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available
07-20 21:59:01.721 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:59:01.721 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available
07-20 21:59:02.723 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:59:02.723 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available
07-20 21:59:03.724 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:59:03.724 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available
07-20 21:59:04.724 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:59:04.724 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available
07-20 21:59:05.726 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:59:05.726 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available
07-20 21:59:06.727 10577-10639/piotrek.androidfpvtest D/MediaAPITest: decoderStatus: -1
07-20 21:59:06.727 10577-10639/piotrek.androidfpvtest D/MediaAPITest: no output from decoder available

If anyone has any experience with this API I would be very thankful for any help!

A: I solved my problem myself. It turns out that this particular decoder doesn't support output to surface, so the solution is to get raw ByteBuffer and then use GLES to do YUV->RGB conversion and display it on the screen.


text:
Q: How to load a file in each executor once? I define  the following code in order to load a pretrained embedding model:
import gensim

from gensim.models.fasttext import FastText as FT_gensim
import numpy as np

class Loader(object):
    cache = {}
    emb_dic = {}
    count = 0
    def __init__(self, filename):
        print("|-------------------------------------|")
        print ("Welcome to Loader class in python")
        print("|-------------------------------------|")
        self.fn = filename

    @property
    def fasttext(self):
        if Loader.count == 1:
                print("already loaded")
        if self.fn not in Loader.cache:
            Loader.cache[self.fn] =  FT_gensim.load_fasttext_format(self.fn)
            Loader.count = Loader.count + 1
        return Loader.cache[self.fn]

    def map(self, word):
        if word not in self.fasttext:
            Loader.emb_dic[word] = np.random.uniform(low = 0.0, high = 1.0, size = 300)
            return Loader.emb_dic[word]
        return self.fasttext[word]

i call this class like :
inputRaw = sc.textFile(inputFile, 3).map(lambda line: (line.split("\t")[0], line.split("\t")[1])).map(Loader(modelpath).map)

*

*Im confusing on How many times the modelpath file will be loaded? I want to be one time loaded per executor and used by all of its cores. My answer for this question is the modelpath will be loades 3 times (=number of partition.). If my answer is right, the disadvantage of such modeling is related to size of file modelpath. Suppose this file is 10 gb and suppose i have 200 partitions. Thus in this case we will need 10*200gb = 2000 with is huge (This solution can only work with low number of partitions.)

Suppose i have an
rdd =(id, sentence) =[(id1, u'patina californian'), (id2, u'virgil american'), (id3', u'frensh'), (id4, u'american')]
and i want to sumup the embedding word vectors for each sentence:
def test(document):
    print("document is = {}".format(document))
    documentWords = document.split(" ")
    features = np.zeros(300)
    for word in documentWords:
        features = np.add(features, Loader(modelpath).fasttext[word])
    return features

def calltest(inputRawSource):

    my_rdd = inputRawSource.map(lambda line: (line[0], test(line[1]))).cache()
    return my_rdd

In this case how many times the modelpath file will be loaded? Note that i set spark.executor.instances" to 3

A: By default, the number of partitions is set to the total number of cores on all the executer nodes in the Spark cluster. Suppose you are processing 10 GB on a Spark cluster (or supercomputing executor) that contains a total of 200 CPU cores, that means Spark might use 200 partitions, by default, to process your data.
Also, to make all your CPU cores work per each executer this can be solved in python (using 100% of all cores with the multiprocessing module).


text:
Q: Shoud the total energy of a particle increase when work is done on that particle? Shoud the total energy of a particle$($kinetic energy $+$ potential energy$)$ increase when positive work is done on that particle?
If the answer is yes, then why the total energy does not increase when work is done on a falling object by gravitational force?

A: Positive work done on a particle by a non-conservative force does increase the total energy of the particle & work done by it depends on the path followed by the particle. On the other hand, gravitational force is a conservative force work done by which doesn't depend on the path followed by the particle & doesn't increase total energy ($KE+PE$) of particle.

A: I love this question. This is the gist: gravity is a conservative force. What it means is gravity trades one form of "energy" for another. When an object is falling, gravity trades the initial potential energy of the object(due to it's elevation) for speed(kinetic energy). Hence, the same energy takes on different forms and the sum stays the same. With a non-conservative force like a pull from you, the kinetic energy of the body increases in the direction of the applied force. The object that is pulled doesn't convert it's own energy to another form like the ball that is falling from an elevation. Rather, energy is added to the object as positive work is done on it. With gravity however, work is still done on the object as it falls except gravity uses the potential of the object to speed up the same object. Gravity cheats the object into believing it is adding to it's energy when in actual sense it is just using up it's initial energy (potential) to speed it up(kinetic energy). So it doesn't add or remove to the energy of the object. And this is why the total mechanical energy of the body stays the same.


text:
Q: set new file name when using google drive.files.copy I'm using google drive apiv3 to copy a spreadsheet into a folder on google drive. The documentation states the "name" property should be used to set the title of the new sheet. I'm using this, but newly created sheets are named "Copy of {titleOfSheetToCopy}".
request:
app.get('/new', function (req, res)
{
    var drive = google.drive({version:'v3', auth: jwt_client});

    var copyRequest = {
        name: 'im a copy',
        fileId: 'idOfSheetToClone',
        parents: ['idOfDestinationFolder'],
    }

    drive.files.copy(copyRequest,  function(err, response){
        if(err){
            console.log(err);
            res.send('error');
            return;
        }
        res.send(response);
    });
});

response:
{
"config": {
    "url": "https://www.googleapis.com/drive/v3/files/-----/copy?name=im%20a%20copy&parents=---",
    "method": "POST",
    "headers": {
        "Accept-Encoding": "gzip",
        "User-Agent": "google-api-nodejs-client/0.7.2 (gzip)",
        "Authorization": "---",
        "Accept": "application/json"
    },
    "params": {
        "name": "im a copy",
        "parents": [
            "---"
        ]
    },
    "responseType": "json"
},
"data": {
    "kind": "drive#file",
    "id": "---",
    "name": "Copy of _template",
    "mimeType": "application/vnd.google-apps.spreadsheet"
},
"headers": {
    "alt-svc": "quic=\":443\"; ma=2592000; v=\"46,43\",h3-Q050=\":443\"; ma=2592000,h3-Q049=\":443\"; ma=2592000,h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000",
    "cache-control": "no-cache, no-store, max-age=0, must-revalidate",
    "connection": "close",
    "content-encoding": "gzip",
    "content-type": "application/json; charset=UTF-8",
    "date": "Mon, 25 Nov 2019 05:37:01 GMT",
    "expires": "Mon, 01 Jan 1990 00:00:00 GMT",
    "pragma": "no-cache",
    "server": "GSE",
    "transfer-encoding": "chunked",
    "vary": "Origin, X-Origin",
    "x-content-type-options": "nosniff",
    "x-frame-options": "SAMEORIGIN",
    "x-xss-protection": "1; mode=block"
},
"status": 200,
"statusText": "OK"
}

can see that response.data.name shows the default naming instead of "i'm a copy".
Any direction would be appreciated. Thanks
https://developers.google.com/drive/api/v3/reference/files/copy

A: *

*You want to copy a file using the method of Files: copy in Drive API v3.

*You want to achieve this using googleapis with Node.js.

*You have already been able to use Drive API.

If my understanding is correct, how about this answer?
Modified script:
In this modification, copyRequest and drive.files.copy() were modified as follows.
var copyRequest = {  // Modified
  name: "im a copy",
  parents: ["idOfDestinationFolder"]
};

drive.files.copy(
  {  // Modified
    fileId: "idOfSheetToClone",
    requestBody: copyRequest  // or resource: copyRequest
  },
  function(err, response) {
    if (err) {
      console.log(err);
      res.send("error");
      return;
    }
    res.send(response);
  }
);

Note:

*

*If an error occurs, please use the latest version of googleapis.

Reference:

*

*Files: copy
If I misunderstood your question and this was not the result you want, I apologize.

A: You have to pass the new file name as the name property of a resource attribute. The documentation says, that name property is to be passed as a property of a requestBody attribute, but that did not work in my case.
Solution:
drive.files.copy(
  {
    fileId: "idOfSheetToClone",
    resource: { name: "filename"}
  },
  function(err, response) {
    if (err) {
      console.log(err);
      res.send("error");
      return;
    }
    res.send(response);
  }
);


text:
Q: Stuck in the Night Mother's coffing during "Death Incarnate" I'm having this problem with Skyrim that after I entered the Night Mother's coffin when the sanctuary was on fire, after waking up by Babette and Nazir I'm suck inside the coffin facing the Night Mother.
I can't move and do a single thing. I have reloaded my save several times hoping it would fix it to no avail.
UESP.net claims that this bug is fixed by version 1.9.26.0.8 of the Official Skyrim Patch and since I have Version 1.9.32.0.8 it seems not to be fixed.
I have looked for a way to fix this bug for many hours but failed to find any. I'd be immensely grateful for any solution.
UPDATE
I am playing on PC and I also have tried many console commands such as tfc, tcl, player.moveto, setstage, etc.
The problem is I have no control over my character.
I event tried moving my character to Astrid's location which she noticed my arrival by saying a line of dialogue but I still can't move a muscle!

A: If you can't control your character, use the enableplayercontrols console command to regain control.

A: I had this to. I had a mask that conceals your character. So i took it off and I unlocked the door that was closed with the unlock cheat. I did them both so i don't know wich one fixed it but now it works just fine.


text:
Q: .NET Core with Autofac DI I want to integrate Autofac to my API. Solution is split on several projects so that everything stays decoupled. I have set up my configure services like this:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    ...
    ...

    // Autofac
    var builder = new ContainerBuilder();

    builder.RegisterType<RouteRepository>().As<IRouteRepository>();

    builder.Populate(services);
    ApplicationContainer = builder.Build();
    return new AutofacServiceProvider(ApplicationContainer);
}

However now with this code integrated, my API won't start anymore. If I start it in debug mode, I get no errors, but I don't get response either.
API landing route is pretty straightforward:
public IActionResult GetIndex()
{
    return Ok("You are seeing this because controller is working!");
}

Also, what might be connected to the problem is that RouteRepository takes one variable as an argument in the constructor and I don't know where can I define what will be passed through? There is no config file by default.

A: If you're saying that you have one dependency for your RouteRepository, then you have to notify Autofac container how to resolve that:
// singletone
builder.RegisterInstance(new TaskRepository())
   .As<ITaskRepository>();
// or instance based creation
builder.Register(c => new LogManager(DateTime.Now))
   .As<ILogger>();

Or Autofac couldn't resolve your type.


text:
Q: angular js ng-include not linking to scope/controller function need some guru advice. I have created a simple off-menu canvas as you can see in the code found in the following plnkr. The issue is I have used ng-include for navbar, which has the toggle switch that interacts with the main scope.
The problem is the navbar is shown but when I try to click on the toggle button it does not work. Please plnkr http://plnkr.co/edit/QF5rEv
If I replace the navbar.html contents and put it in the main page it works fine.
I appreciate if anyone can tell me what is going on? And the work around? Thanks in advance!
This is my code found in plnkr:

  <meta charset="utf-8" />
  <title>AngularJS Plunker</title>

  <link rel="stylesheet" href="style.css" />

  <link data-require="bootstrap-css" data-semver="3.3.1" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
  <link data-require="bootstrap@*" data-semver="3.3.1" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />

Nav goes here

      hi

      Content goes here

A: ng-include creating new scope so to access MainCtrl scope you can use $parent in your navbar.html
ng-click="$parent.navLeft=!$parent.navLeft"

please see here http://plnkr.co/edit/vRoBPzjDSjbE7om5zAKn?p=preview
or change create new object
  $scope.nav = {

    navLeft:false,//default navLeft menu off
    navRight:false//default navRight menu off

  };

and after that you can use nav.navLeft in your navbar

please see here
http://plnkr.co/edit/PQOeT61mjZdDWwSbjlyQ?p=preview
but you should consider to split your controller into smaller parts ie: content, navbar and communicate between them using service


text:
Q: Rigorous justification for this formal solution to $f(x+1)+f(x)=g(x)$ Let $g\in C(\Bbb R)$ be given, we want to find a solution $f\in C(\Bbb R)$ of the equation

$$
f(x+1) + f(x) = g(x).
$$

We may rewrite the equation using the right-shift operator $(Tf)(x) = f(x+1)$ as
$$
(I+ T)f=g.
$$
Formally, I can say that the solution of this equation is

$$
f= (I+ T)^{-1} g.
$$

Of course, I am aware that there are infinitely many solutions to the equation since the kernel of $(I+T)$ consists of all $h\in C(\Bbb R)$ such that $h(x+1)=-h(x)$, e.g. $\sin(\pi x)$, but please bear with me for a moment here.
By the theory of operator algebra, if $f,g$ are from some nice Banach space $X$ and our linear operator $T:X\to X$ satisfies $\|T\|<1$, then we have
$$
f = \left(\sum_{n=0}^\infty (-T)^n \right)g.
$$
However, it is not unreasonable to expect that we should have $\|T\|=1$ for a right-shift operator in most reasonable function spaces so let's try to solve the equation
$$
f= (I+\lambda T)^{-1} g.
$$
for $|\lambda| <1$ first then we'll take $\lambda\to 1$. Note that all the steps until now is purely formal since $C(\Bbb R)$ is not a normed space.

To illustrate what I meant, let's say we take $g(x) = (x+2)^2$. We now try to implement the above method (for $|\lambda|<1$) to get
$$\begin{align}
f(x) &= \left(I - \lambda T + \lambda^2 T^2 - \dots \right) g(x) \\
&= (x+2)^2 -\lambda (x+3)^2 + \lambda^2 (x+4)^2 + \dots \\
&= \left(1-\lambda+\lambda^2-\dots \right)x^2 + \left(2-3\lambda+4\lambda^2-\dots \right)2x + \left(2^2-3^2\lambda+4^2\lambda^2-\dots \right) \\
&=  \frac{1}{1+\lambda} x^2 + 2 \frac{2+\lambda}{(1+\lambda)^2} x +  \frac{4+3\lambda + \lambda^2}{(1+\lambda)^3}.
\end{align}$$
We shall be brave here and substitute $\lambda=1$ even though the series doesn't converge there. This gives
$$
f(x) = \frac 12 x^2 + \frac 32 x + 1
$$
but voilà, for some mysterious reasons unknown to me, this $f$ actually solves our original equation $f(x+1) + f(x) = (x+2)^2$ !

My question is simply:

What are the hidden theories behind the miracle we observe here? How can we justify all these seemingly unjustifiable steps?

I can't give you a reference to this method because I just conjured it up, thinking that it wouldn't work. To my greatest surprise, the answer actually makes sense. I am sure that similar method is probably practiced somewhere, probably by physicists.
Remark: I posted an isomorphic question on MSE earlier and one of the commenters mentioned that this could be related to the holomorphic functional calculus (HFC), specifically the part where I let $\lambda \to 1$. I once learned HFC just for an exam and don't have much memory of it so I don't immediately see if we can make the above method fully rigorous using merely the standard HFC or not.

A: If $g(x)$ grows slower than any exponential as $x$ goes to $\infty$, then $ \sum_n (-\lambda)^n T^n g$ clearly converges (absolutely) pointwise for any $\lambda <1$, and when $(I + \lambda T)$ is applied, recovers $g$.
If this sequence happens to converge pointwise as $\lambda$ goes to $1$, then it will recover $g$ when $I+ T$ is applied. I don't know a great perfectly general criterion for this to converge pointwise, but it will for instance when $g$ is polynomial (or a sum of polynomials times exponential phases $e^{ \pi i t x}$ where $t$ is not an odd integer.)
In general, when there is not a unique solution, you can't expect these formal inverses to give a unique solution. But if anything that's even more reason to expect them to give you at least one solution.
From an analytic perspective, the proof that a formal solutions solves the equation by a telescoping sum is much simpler than the proof that it is the unique solution, and we should expect it to hold in more general settings.

A: The "miracle" is just that $T$ is also defined $\mathbb{R}_n[X]\rightarrow \mathbb{R}_n[X]$, a elementary linear operator on finite dimensional space of polynomes. And on this set we have
$$T=\begin{pmatrix} 1 & 1 & 1 & & \\ 0 & 1 & 2 & &\vdots \\ 0 & 0 & 1 & & \\ 0 & 0 & 0 & \ddots  \\  0 & 0 & 0 & 0 & 1 \end{pmatrix} $$
with $T_{ij}=\begin{pmatrix}i \\ j\end{pmatrix}$ if $i\geq j$ and $0$ otherwise. So $\det(I+\lambda T)=(1+\lambda)^{n+1}$ and then $(I+\lambda T)^{-1}$ is analytic on $\lambda\in \mathbb{C}/\{-1\}$.

A: A direct and precise way to arrive at your answer is to appeal to the theory of Fourier transforms of distributions. If I define the Fourier transform as
$$F(k)=\frac{1}{\sqrt{2\pi}}\int_{-\infty}^\infty f(x)e^{ikx}\,dx,$$
then the equation $f(x+1)+f(x)=g(x)$ becomes upon Fourier transformation
$$e^{-ik}F(k)+F(k)=G(K)\Rightarrow F(k)=\frac{G(k)}{1+e^{-ik}}.$$
Inverse Fourier transformation gives the desired $f(x)$,
$$f(x)=\frac{1}{\sqrt{2\pi}}\int_{-\infty}^\infty \frac{G(k)}{1+e^{-ik}}e^{-ikx}\,dk.$$
The Fourier transform of $g(x)=(x+2)^2$ is given in the distributional sense by derivatives of the Dirac delta function $\delta(k)$,
$$(2\pi)^{-1/2}G(k)=4  \delta (k)-4 i \delta '(k)-\delta ''(k).$$
These distributions are well defined upon integration, giving the inverse Fourier transform $f(x)=\frac{1}{2} \left(x^2+3 x+2\right)$.
More general cases follow readily:
$$g(x)=(x+a)^2\Rightarrow f(x)=\tfrac{1}{2} (a+x-1) (a+x),$$
$$g(x)=(x+a)^3\Rightarrow f(x)=\tfrac{1}{8} (2 a+2 x-1) \left(2 a^2+a (4 x-2)+2 (x-1) x-1\right),$$
$$g(x)=(x+a)^4\Rightarrow f(x)=\tfrac{1}{2} (a+x-1) (a+x) \left(a^2+a (2 x-1)+(x-1) x-1\right).$$

A: Here is another approach, which like yours is not entirely rigorous, but I think gives a bit more insight into the situation.
If you are willing to assume that $f$ is not just smooth but also analytic, then by writing the $f(x+1)$ term as a Taylor expansion you can write the equation in the form
$$
(e^D+I) f = g
$$
where $D$ is the differentiation operator. It is then natural to apply the (formal) inverse operator and get that
$$
f = (e^D+I)^{-1} g.
$$
Now note that the function $t\mapsto (e^t+1)^{-1}$ itself has the Taylor expansion
$$
\frac{1}{e^t+1}
=\frac{1}{2}-\frac{t}{4}+\frac{t^3}{48}-\frac{t^5}{480}+\frac{17 t^7}{80640}+...
$$
This suggests that the solution to our equation can be expressed as
$$
f = \left(\frac{1}{2}I - \frac{1}{4}D + \frac{1}{48}D^3 - \frac{1}{480}D^5 +... \right)g.
$$
The nice thing about this expansion is that if $g$ is a polynomial then this is in fact a finite sum, so you get an expression for $f$ as a finite linear combination of $g$ and its derivatives. In your example of $g(x)=(x+2)^2$ we have
$$
f(x) = \frac12 g(x) - \frac14 g'(x) + \frac{1}{48} g'''(x)
$$
which indeed comes out to $f(x)=\frac12 x^2+\frac32 x + 1$.
So what is going on here? The situation is very analogous to the formal derivation of the Euler-Maclaurin summation formula, in which the reason for the appearance of the Bernoulli numbers in the formula can be explained by the fact that one is essentially inverting the operator $e^D-I$ (instead of $e^D+I$ in the current discussion). See this comment of Terry Tao's from his blog. Note that in that case as well the derivation is purely formal and one needs to do more careful work to verify that the resulting formula makes sense.
Ultimately, I think what all of this illustrates is the principle that formal manipulations using operators involving infinite series, Taylor expansions etc (I think this goes under the name of operator calculus, loosely speaking, but perhaps someone else can give more precise terminology) often lead to correct results without there necessarily being some unifying principle at work that explains why this is happening (which is not to say that one shouldn't look for good explanations of course). I can't think of specific examples, but I think one runs into this phenomenon in lots of places in analysis, mathematical physics, probability and other places.

A: Just to add another answer to the pile...
I suspect that the 'magic' observed here may be related to so-called local spectral theory. It is possible to do quite a lot (at least in the Banach space setting) with the notion of a local resolvent $\rho_T(x)$ of a bounded Banach space operator $T:X\to X$; for $x\in X$, this is defined as the union of all open $U\subset\mathbb{C}$ for which there is some $f\in \mathscr{O}(U,X)$ such that $(T-\lambda)f(\lambda)=x$ for all $\lambda \in U$. The standard reference for this sort of stuff (at least for the Banach space setting) is the book of Neumann and Laursen. I don't know of a corresponding reference, but it wouldn't surprise me if versions of local spectral theory have been studied in the Frechet/barrelled settings as well.


text:
Q: Trying to get String from ListView My current problem is I have a ListView I'm using to display my contacts now I'd like to set the onItemClick to grab the name of the contact and set that to a TextView called p2 the code I currently have is:
protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setp2);

        cursor = managedQuery(ContactsContract.Contacts.CONTENT_URI,null,null,null,null);

        String[] from = new String[]{ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME};
        int[] to = new int[]{R.id.id_text,R.id.name_text};

        final SimpleCursorAdapter adapter = new SimpleCursorAdapter(setp2.this,R.layout.setp2_layout,cursor,from,to);

        ListView list = (ListView)findViewById(R.id.contact_list);
        list.setAdapter(adapter);

        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position,
                    long id) {
            }
        });

}

So basically I'm unsure of what I need to do in the onItemClick, any help appreciated!

A: In your onItemClick, you will get the instance of the view associated with that list item.From that view you can get the text associated with it and set it to the p2 TextView. If my understanding of your requirement is correct, the code will be something like this:
 list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                long id) {
               CharSequence name = ((TextView)view.findViewById(R.id.name_text)).getText();
               //Set this to your textview in P2
               tvP2.setText(name);

        }
    });

A: Set up a SimpleCursorAdapter.CursorToStringConverter and set it on the adapter, then use convertToString(Cursor cursor) to get the text in on item click :
(Cursor) simple.getItem(position)

A: @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                long id) {
            cursor.moveToPosition(position);
            String name = cursor.getString(cursor.getColumnIndex(
                            ContactsContract.Contacts.DISPLAY_NAME));
             p2.setText(name);
        }
    });


text:
Q: Java memory management Objects vs Primitive Types I am getting a bit confused regarding few points regarding Java memory management.
Understood what is the difference between Stacks and Heap and I went to see a proper example on what is those memories when we execute some code.
I took for example this few lines
public static void main(String[] args)
{
    int a = 5;
    calculate(a);
    System.out.println(a); //will print 5 not 50
}
private static void calculatee(int a)
{
    a = a * 10;
}

I understood what is happening in the stack and in the heap. The variable is not getting returned and there is no reference to the Heap in this case.
while in this example:
public static void maina(String[] args)
{
    Customer customer = new Customer("John");
    setAName(customer);
    System.out.println(customer.getName()); // this will return Philip
}

private static void setAName(Customer c)
{
    c.setName("Philip");
}

I can see the state of the object changed this time!
Stacks are not shared thought threads, but heap is shared! Which make sense to me that the object customer has changed its value from Jhon to Philip when I am printing it!
Great! all make sense!
However, I was expecting that if I will do this
public static void main(String[] args)
{
    Integer i = new Integer(5);
    calculate(i);
    System.out.println(i); // printing 5 and not 50
}
private static void calculate(Integer i)
{
    i = i * 10;
}

I would get 50 and not 5!
In this case Integer is an object and I am assuming it is created in the heap!
Funny thing is that if I will wrap the Integer inside Customer I will get 50 instead of 5.
Why is this happening? Isn't the Integer type getting created in the Heap?

A: This is a problem of references and not of heaps and stacks.
When calling the method calculate, you pass a reference (in your case, i from main).
The trick is, that Java will create a new reference inside of calculate. So i inside of calculate and i inside of main might initially "point" to the same object, but they are not the "same".
So, if you change i inside of calculate to the object resulting from your multiplication, you don't automatically change the reference of the i inside of main.
With Customer, it's different. You never change where c in setAName points to. You change one reference inside of the object, but both customer inside of main and c in setAName still point to that one object!
Here two shitty Paint drawings to explain what I mean (numbers prefixed with 0x are references):
For the Integer example:

For the Customer example:

Don't hesitate to come back with any questions.
I hope this helps.


text:
Q: How to mix diffuse value (Kd) with texture (map_Kd) while loading wavefront file? I'm just trying to write wavefront files loader in c++. I followed the tutorial at www.opengl-tutorial.org. It doesn't say how to handle mtl files, so I decided to do it myself. I know that Kd is responsible for the color of the diffuse property. On the other hand, map_Kd is responsible for the texture that describes this property. There is always Kd in the mtl file and could be map_Kd. My file look like this:
.
.
.
newmtl Material.001
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd cubetex.bmp
.
.
.

Should I multiply the values of map_Kd by Kd? Or should I only use map_Kd?
EDIT:
Here's my fragment shader:
#version 430 core

in vec2 uv;
in vec3 Position_worldspace;
in vec3 Normal_cameraspace;
in vec3 EyeDirection_cameraspace;
in vec3 LightDirection_cameraspace;

out vec3 color;

uniform sampler2D tex;
uniform vec3 LightPosition_worldspace;

void main()
{

  vec3 LightColor = vec3(1,1,1);
  float LightPower = 50.0f;

  vec3 MaterialDiffuseColor = texture( tex, uv ).rgb;
    vec3 MaterialAmbientColor = vec3(0.1,0.1,0.1) * MaterialDiffuseColor;
    vec3 MaterialSpecularColor = vec3(0.3,0.3,0.3);

  float distance = length( LightPosition_worldspace - Position_worldspace );

  vec3 n = normalize( Normal_cameraspace );
  vec3 l = normalize( LightDirection_cameraspace );

  float cosTheta = clamp( dot( n,l ), 0,1 );

  vec3 E = normalize(EyeDirection_cameraspace);
    vec3 R = reflect(-l,n);

    float cosAlpha = clamp( dot( E,R ), 0,1 );

  color = MaterialAmbientColor + MaterialDiffuseColor * LightColor * LightPower * cosTheta / (distance*distance) + MaterialSpecularColor * LightColor * LightPower * pow(cosAlpha,5) / (distance*distance);

}

I don't know how to compute MaterialDiffuseColor


text:
Q: EntityFramework detecting complex type with database first We are using EntityFramework and have already gone through a long journey with Database First.  We have multiple contexts and many, many entities. While we entertain the notion of undergoing a project of code first, we want to explore the alternate possibilities available with EF.
We are using the latest version of EF as of current, 6.0.2
We have quite a few tables with common fields such as Auditing fields "CreatedBy", "CreatedDate", "UpdatedBy" and "UpdatedDate" and we thought that it would be perfect to use a ComplexType here.
In a table that uses those fields, when we generate the code from the database, it pulls the fields in raw. We then delete it in the model browser, add the complex type and then maps the complex properties to the field names in the DB.
In this experiment, we ran the "Generate database from model" without mapping the fields to see what were the resulting column names and if any convention or auto-magic would allow that behavior bi-directionally(Turning complex type into columns and recognizing columns as complex types).
This resulted in column names with the complex type suffixed with an '_' and the field name. We tested and it didn't pull the complex type back from the database in the model when we regenerated the model.
Is there a proper way to have EF detect Complex types in tables with database first?
Is there some code factory, builder, strategy or template that I can write?
Our main motivation is that we have quite a number of tables to support, we embrace frequent changes and we want to prevent people on our team neglecting this step and breaking the code base.
Much appreciation for your time StackOverflowians!
-- Edit --
While this doesn't solve the problem using the auto-detection of complex types, this has resolve the issues of Developer's breaking the model each time they run the T4 template updates.
http://www.ninjacrab.com/2015/02/07/update-entityframework-detecting-complex-type-with-database-first/

A: What I did was a Generic semi-Repository pattern over EF. I also used intefaces to allow identification and automatic use of methods if they match.
Auditable Interface:
public interface IDbAuditable : IDbEntity
{
    Guid CreatedById { get; set; }
    DateTime CreatedOn { get; set; }
    Guid ModifiedById { get; set; }
    DateTime ModifiedOn { get; set; }
    Guid? DeletedById { get; set; }
    DateTime? DeletedOn { get; set; }
}

(I personally like the idea that if CreatedOn == ModifiedOn then it's never been modified, some people like DateTime?, doesn't really matter they serve the same purpose.)
Since this example is in a small project, I simply wrapped the EF Context and didn't use any IoC/DI.  This is a small subset of all the actual code (some methods are missing and some interfaces are missing, but it should make perfect sense).
public sealed class MyDb : IDisposable
{
    private MyContext _context;

    public MyDb(string connectionString, Lazy<Guid?> currentUserIdFunc)
    {
        this._context = new MyContext(connectionString);

        Database.SetInitializer<MyContext>(new DatabaseInitializer());
        this._context.Database.Initialize(true);

        this._currentUserIdFunc = currentUserIdFunc;
    }

    public async Task<T> GetEntityAsync<T>(Func<IQueryable<T>, IQueryable<T>> entityQuery) where T : class, IDbEntity
    {
        var query = entityQuery(this._context.Set<T>());

        if (typeof(T) is IDbAuditable)
        {
            query = query.Cast<IDbAuditable>()
                 .Where(a => !a.DeletedById.HasValue)
                 .Cast<T>();
        }

        return await query.FirstOrDefaultAsync();
    }

    public async Task<int> UpdateAsync<T>(T entity) where T : class, IDbEntity
    {
        if (entity is IDbDoNotModify)
        {
            throw new DoNotModifyException("Entity cannot be Modified (IDoNotModify).");
        }

        this._context.Set<T>().Attach(entity);
        var entry = this._context.Entry<T>(entity);
        entry.State = EntityState.Unchanged;

        var entityType = entity.GetType();

        var metadata = entityType.GetCustomAttributes(typeof(MetadataTypeAttribute)).FirstOrDefault() as MetadataTypeAttribute;
        if (metadata != null)
        {

            var type = metadata.MetadataClassType;

            var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
                 .Select(p => new
                 {
                     Name = p.Name,
                     ScaffoldColumn = p.GetCustomAttributes(typeof(ScaffoldColumnAttribute), true).FirstOrDefault() as ScaffoldColumnAttribute,
                     Readonly = entityType.GetProperty(p.Name).GetCustomAttributes(typeof(ReadOnlyAttribute), true).FirstOrDefault() as ReadOnlyAttribute
                 })
                 .Where(p => (p.ScaffoldColumn == null || p.ScaffoldColumn.Scaffold)
                     && (p.Readonly == null || !p.Readonly.IsReadOnly))
                 .ToList();

            foreach (var property in properties)
            {
                entry.Property(property.Name).IsModified = true;
            }

        }
        else
        {
            entry.State = EntityState.Modified;
        }

        var auditable = entity as IDbAuditable;
        if (auditable != null)
        {
            this.Modified(auditable, this._currentUserIdFunc.Value);
            entry.Property("ModifiedOn").IsModified = true;
            entry.Property("ModifiedById").IsModified = true;
        }

        return await this._context.SaveChangesAsync();
    }

    private void Modified(IDbAuditable instance, Guid? currentUserId)
    {
        instance.ModifiedById = currentUserId.Value;
        instance.ModifiedOn = DateTime.Now;
    }
}

Here is how I would use it:
// returns the first car with a model of ford
var car = MyDb.EntityAsync<Car>((query) = query
  .Where(c => c.Model.Equals("ford")
);

// returns the first dog with an ownerId of id
var car = MyDb.EntityAsync<Dog>((query) => query
  .Where(d => d.OwnerId == Id)
);

UpdateAsync(car);

This example application is very small so I didn't implement any UnitOfWork but it could be easily modified for such a case.  Additionally, the MyDb class could be turned into a MyDb<T> if you have multiple Contexts pretty easily. I allow heavy use of DataAnnotations.


text:
Q: Problem updating linux image 3.2.0-26 generic to 3.2.0-26.41 Here are the details of failed package operation.

installArchives() failed:
Extracting templates from packages: 50%%
Extracting templates from packages: 100%%

Extracting templates from packages: 50%%
Extracting templates from packages: 100%%

Extracting templates from packages: 50%%
Extracting templates from packages: 100%%

Extracting templates from packages: 50%%
Extracting templates from packages: 100%%
(Reading database ...
(Reading database ... 5%%
(Reading database ... 10%%
(Reading database ... 15%%
(Reading database ... 20%%
(Reading database ... 25%%
(Reading database ... 30%%
(Reading database ... 35%%
(Reading database ... 40%%
(Reading database ... 45%%
(Reading database ... 50%%
(Reading database ... 55%%
(Reading database ... 60%%
(Reading database ... 65%%
(Reading database ... 70%%
(Reading database ... 75%%
(Reading database ... 80%%
(Reading database ... 85%%
(Reading database ... 90%%
(Reading database ... 95%%
(Reading database ... 100%%
(Reading database ... 280864 files and directories currently installed.)
Preparing to replace cron 3.0pl1-120ubuntu3 (using .../cron_3.0pl1-120ubuntu4_amd64.deb) ...
cron stop/waiting
Unpacking replacement cron ...
Preparing to replace libgnutls26:i386 2.12.14-5ubuntu3 (using .../libgnutls26_2.12.14-5ubuntu3.1_i386.deb) ...
De-configuring libgnutls26 ...
Unpacking replacement libgnutls26:i386 ...
Preparing to replace libgnutls26 2.12.14-5ubuntu3 (using .../libgnutls26_2.12.14-5ubuntu3.1_amd64.deb) ...
Unpacking replacement libgnutls26 ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up libgnutls26:i386 (2.12.14-5ubuntu3.1) ...
Setting up libgnutls26 (2.12.14-5ubuntu3.1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
(Reading database ...
(Reading database ... 5%%
(Reading database ... 10%%
(Reading database ... 15%%
(Reading database ... 20%%
(Reading database ... 25%%
(Reading database ... 30%%
(Reading database ... 35%%
(Reading database ... 40%%
(Reading database ... 45%%
(Reading database ... 50%%
(Reading database ... 55%%
(Reading database ... 60%%
(Reading database ... 65%%
(Reading database ... 70%%
(Reading database ... 75%%
(Reading database ... 80%%
(Reading database ... 85%%
(Reading database ... 90%%
(Reading database ... 95%%
(Reading database ... 100%%
(Reading database ... 280864 files and directories currently installed.)
Preparing to replace gir1.2-dbusmenu-gtk-0.4 0.6.1-0ubuntu3 (using .../gir1.2-dbusmenu-gtk-0.4_0.6.2-0ubuntu0.1_amd64.deb) ...
Unpacking replacement gir1.2-dbusmenu-gtk-0.4 ...
Preparing to replace libdbusmenu-gtk4 0.6.1-0ubuntu3 (using .../libdbusmenu-gtk4_0.6.2-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libdbusmenu-gtk4 ...
Preparing to replace gir1.2-dbusmenu-glib-0.4 0.6.1-0ubuntu3 (using .../gir1.2-dbusmenu-glib-0.4_0.6.2-0ubuntu0.1_amd64.deb) ...
Unpacking replacement gir1.2-dbusmenu-glib-0.4 ...
Preparing to replace libdbusmenu-glib4 0.6.1-0ubuntu3 (using .../libdbusmenu-glib4_0.6.2-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libdbusmenu-glib4 ...
Preparing to replace libdbusmenu-gtk3-4 0.6.1-0ubuntu3 (using .../libdbusmenu-gtk3-4_0.6.2-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libdbusmenu-gtk3-4 ...
Preparing to replace libmtp-common 1.1.3-1 (using .../libmtp-common_1.1.3-1ubuntu0.1_all.deb) ...
Unpacking replacement libmtp-common ...
Preparing to replace libmtp-runtime 1.1.3-1 (using .../libmtp-runtime_1.1.3-1ubuntu0.1_amd64.deb) ...
Unpacking replacement libmtp-runtime ...
Preparing to replace libmtp9 1.1.3-1 (using .../libmtp9_1.1.3-1ubuntu0.1_amd64.deb) ...
Unpacking replacement libmtp9 ...
Preparing to replace libxkbfile1 1:1.0.7-1 (using .../libxkbfile1_1%%3a1.0.7-1ubuntu0.1_amd64.deb) ...
Unpacking replacement libxkbfile1 ...
Preparing to replace desktop-file-utils 0.20-0ubuntu2 (using .../desktop-file-utils_0.20-0ubuntu3_amd64.deb) ...
Unpacking replacement desktop-file-utils ...
Preparing to replace nautilus-sendto-empathy 3.4.2-0ubuntu1 (using .../nautilus-sendto-empathy_3.4.2.1-0ubuntu1_amd64.deb) ...
Unpacking replacement nautilus-sendto-empathy ...
Preparing to replace empathy 3.4.2-0ubuntu1 (using .../empathy_3.4.2.1-0ubuntu1_amd64.deb) ...
Unpacking replacement empathy ...
Preparing to replace empathy-common 3.4.2-0ubuntu1 (using .../empathy-common_3.4.2.1-0ubuntu1_all.deb) ...
Unpacking replacement empathy-common ...
Preparing to replace kate-data 4:4.8.3-0ubuntu0.1 (using .../kate-data_4%%3a4.8.4-0ubuntu0.1_all.deb) ...
Unpacking replacement kate-data ...
Preparing to replace libkdeclarative5 4:4.8.3-0ubuntu0.1 (using .../libkdeclarative5_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkdeclarative5 ...
Preparing to replace libnepomuksync4 4:4.8.3-0ubuntu0.1 (using .../libnepomuksync4_4%%3a4.8.4-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libnepomuksync4 ...
Preparing to replace kde-runtime 4:4.8.3-0ubuntu0.1 (using .../kde-runtime_4%%3a4.8.4-0ubuntu0.1_amd64.deb) ...
Unpacking replacement kde-runtime ...
Preparing to replace kdoctools 4:4.8.3-0ubuntu0.1 (using .../kdoctools_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement kdoctools ...
Preparing to replace kdelibs-bin 4:4.8.3-0ubuntu0.1 (using .../kdelibs-bin_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement kdelibs-bin ...
Preparing to replace libkjsembed4 4:4.8.3-0ubuntu0.1 (using .../libkjsembed4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkjsembed4 ...
Preparing to replace libkemoticons4 4:4.8.3-0ubuntu0.1 (using .../libkemoticons4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkemoticons4 ...
Preparing to replace libkdesu5 4:4.8.3-0ubuntu0.1 (using .../libkdesu5_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkdesu5 ...
Preparing to replace libplasma3 4:4.8.3-0ubuntu0.1 (using .../libplasma3_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libplasma3 ...
Preparing to replace libkrosscore4 4:4.8.3-0ubuntu0.1 (using .../libkrosscore4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkrosscore4 ...
Preparing to replace libkcmutils4 4:4.8.3-0ubuntu0.1 (using .../libkcmutils4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkcmutils4 ...
Preparing to replace libkde3support4 4:4.8.3-0ubuntu0.1 (using .../libkde3support4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkde3support4 ...
Preparing to replace libkmediaplayer4 4:4.8.3-0ubuntu0.1 (using .../libkmediaplayer4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkmediaplayer4 ...
Preparing to replace libkdewebkit5 4:4.8.3-0ubuntu0.1 (using .../libkdewebkit5_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkdewebkit5 ...
Preparing to replace libkparts4 4:4.8.3-0ubuntu0.1 (using .../libkparts4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkparts4 ...
Preparing to replace libknewstuff3-4 4:4.8.3-0ubuntu0.1 (using .../libknewstuff3-4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libknewstuff3-4 ...
Preparing to replace libknotifyconfig4 4:4.8.3-0ubuntu0.1 (using .../libknotifyconfig4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libknotifyconfig4 ...
Preparing to replace libnepomukutils4 4:4.8.3-0ubuntu0.1 (using .../libnepomukutils4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libnepomukutils4 ...
Preparing to replace libnepomukquery4a 4:4.8.3-0ubuntu0.1 (using .../libnepomukquery4a_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libnepomukquery4a ...
Preparing to replace libkpty4 4:4.8.3-0ubuntu0.1 (using .../libkpty4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkpty4 ...
Preparing to replace libkfile4 4:4.8.3-0ubuntu0.1 (using .../libkfile4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkfile4 ...
Preparing to replace libkio5 4:4.8.3-0ubuntu0.1 (using .../libkio5_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkio5 ...
Preparing to replace libnepomuk4 4:4.8.3-0ubuntu0.1 (using .../libnepomuk4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libnepomuk4 ...
Preparing to replace libkntlm4 4:4.8.3-0ubuntu0.1 (using .../libkntlm4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkntlm4 ...
Preparing to replace libkjsapi4 4:4.8.3-0ubuntu0.1 (using .../libkjsapi4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkjsapi4 ...
Preparing to replace libkdnssd4 4:4.8.3-0ubuntu0.1 (using .../libkdnssd4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkdnssd4 ...
Preparing to replace libkidletime4 4:4.8.3-0ubuntu0.1 (using .../libkidletime4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkidletime4 ...
Preparing to replace libkdeui5 4:4.8.3-0ubuntu0.1 (using .../libkdeui5_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkdeui5 ...
Preparing to replace libkdecore5 4:4.8.3-0ubuntu0.1 (using .../libkdecore5_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkdecore5 ...
Preparing to replace kde-runtime-data 4:4.8.3-0ubuntu0.1 (using .../kde-runtime-data_4%%3a4.8.4-0ubuntu0.1_all.deb) ...
Unpacking replacement kde-runtime-data ...
Preparing to replace katepart 4:4.8.3-0ubuntu0.1 (using .../katepart_4%%3a4.8.4-0ubuntu0.1_amd64.deb) ...
Unpacking replacement katepart ...
Preparing to replace kdelibs5-data 4:4.8.3-0ubuntu0.1 (using .../kdelibs5-data_4%%3a4.8.4a-0ubuntu0.1_all.deb) ...
Unpacking replacement kdelibs5-data ...
Preparing to replace kdelibs5-plugins 4:4.8.3-0ubuntu0.1 (using .../kdelibs5-plugins_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement kdelibs5-plugins ...
Preparing to replace libkhtml5 4:4.8.3-0ubuntu0.1 (using .../libkhtml5_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkhtml5 ...
Preparing to replace libktexteditor4 4:4.8.3-0ubuntu0.1 (using .../libktexteditor4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libktexteditor4 ...
Preparing to replace libsolid4 4:4.8.3-0ubuntu0.1 (using .../libsolid4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libsolid4 ...
Preparing to replace libnepomukdatamanagement4 4:4.8.3-0ubuntu0.1 (using .../libnepomukdatamanagement4_4%%3a4.8.4-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libnepomukdatamanagement4 ...
Preparing to replace plasma-scriptengine-javascript 4:4.8.3-0ubuntu0.1 (using .../plasma-scriptengine-javascript_4%%3a4.8.4-0ubuntu0.1_amd64.deb) ...
Unpacking replacement plasma-scriptengine-javascript ...
Preparing to replace libthreadweaver4 4:4.8.3-0ubuntu0.1 (using .../libthreadweaver4_4%%3a4.8.4a-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libthreadweaver4 ...
Preparing to replace libkatepartinterfaces4 4:4.8.3-0ubuntu0.1 (using .../libkatepartinterfaces4_4%%3a4.8.4-0ubuntu0.1_amd64.deb) ...
Unpacking replacement libkatepartinterfaces4 ...
Preparing to replace xserver-common 2:1.11.4-0ubuntu10.2 (using .../xserver-common_2%%3a1.11.4-0ubuntu10.3_all.deb) ...
Unpacking replacement xserver-common ...
Preparing to replace xserver-xorg-core 2:1.11.4-0ubuntu10.2 (using .../xserver-xorg-core_2%%3a1.11.4-0ubuntu10.3_amd64.deb) ...
Unpacking replacement xserver-xorg-core ...
Processing triggers for hal ...
Regenerating hal fdi cache ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf.index...
Processing triggers for gnome-menus ...
Processing triggers for man-db ...
Processing triggers for gconf2 ...
Processing triggers for libglib2.0-0:i386 ...
Processing triggers for libglib2.0-0 ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for shared-mime-info ...
Unknown media type in type 'all/all'
Unknown media type in type 'all/allfiles'
Unknown media type in type 'uri/mms'
Unknown media type in type 'uri/mmst'
Unknown media type in type 'uri/mmsu'
Unknown media type in type 'uri/pnm'
Unknown media type in type 'uri/rtspt'
Unknown media type in type 'uri/rtspu'
Setting up linux-image-3.2.0-26-generic (3.2.0-26.41) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/dkms 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-26-generic
Warning: No support for locale: en_US.utf8
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
/usr/sbin/grub-mkconfig: 33: /etc/default/grub: tmpfs: not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-26-generic.postinst line 1010.
dpkg: error processing linux-image-3.2.0-26-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
No apport report written because MaxReports is reached already
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.2.0-26-generic; however:
  Package linux-image-3.2.0-26-generic is not configured yet.
dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.2.0.26.28); however:
  Package linux-image-generic is not configured yet.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
Setting up cron (3.0pl1-120ubuntu4) ...
Installing new version of config file /etc/default/cron ...
cron start/running, process 1768
Setting up libdbusmenu-glib4 (0.6.2-0ubuntu0.1) ...
Setting up libdbusmenu-gtk4 (0.6.2-0ubuntu0.1) ...
Setting up gir1.2-dbusmenu-glib-0.4 (0.6.2-0ubuntu0.1) ...
Setting up gir1.2-dbusmenu-gtk-0.4 (0.6.2-0ubuntu0.1) ...
Setting up libdbusmenu-gtk3-4 (0.6.2-0ubuntu0.1) ...
Setting up libmtp-common (1.1.3-1ubuntu0.1) ...
Setting up libmtp9 (1.1.3-1ubuntu0.1) ...
Setting up libmtp-runtime (1.1.3-1ubuntu0.1) ...
Setting up libxkbfile1 (1:1.0.7-1ubuntu0.1) ...
Setting up desktop-file-utils (0.20-0ubuntu3) ...

Configuration file `/etc/gnome/defaults.list'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** defaults.list (Y/I/N/O/D/Z) [default=N] ? y
Installing new version of config file /etc/gnome/defaults.list ...
Setting up empathy-common (3.4.2.1-0ubuntu1) ...
Setting up nautilus-sendto-empathy (3.4.2.1-0ubuntu1) ...
Setting up empathy (3.4.2.1-0ubuntu1) ...
Setting up kate-data (4:4.8.4-0ubuntu0.1) ...
Setting up libkdecore5 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkdeui5 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkdeclarative5 (4:4.8.4a-0ubuntu0.1) ...
Setting up libnepomuk4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libnepomuksync4 (4:4.8.4-0ubuntu0.1) ...
Setting up libkcmutils4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkpty4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkdesu5 (4:4.8.4a-0ubuntu0.1) ...
Setting up libsolid4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkio5 (4:4.8.4a-0ubuntu0.1) ...
Setting up libnepomukquery4a (4:4.8.4a-0ubuntu0.1) ...
Setting up libnepomukutils4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkparts4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkdewebkit5 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkdnssd4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkemoticons4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkfile4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkjsapi4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libktexteditor4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkhtml5 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkidletime4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkmediaplayer4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libknewstuff3-4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libknotifyconfig4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libnepomukdatamanagement4 (4:4.8.4-0ubuntu0.1) ...
Setting up libthreadweaver4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libplasma3 (4:4.8.4a-0ubuntu0.1) ...
Setting up kde-runtime-data (4:4.8.4-0ubuntu0.1) ...
Setting up libkde3support4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkjsembed4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkntlm4 (4:4.8.4a-0ubuntu0.1) ...
Setting up libkrosscore4 (4:4.8.4a-0ubuntu0.1) ...
Setting up kdelibs5-data (4:4.8.4a-0ubuntu0.1) ...
Setting up kdoctools (4:4.8.4a-0ubuntu0.1) ...
Setting up kdelibs-bin (4:4.8.4a-0ubuntu0.1) ...
Setting up libkatepartinterfaces4 (4:4.8.4-0ubuntu0.1) ...
Setting up katepart (4:4.8.4-0ubuntu0.1) ...
Setting up kdelibs5-plugins (4:4.8.4a-0ubuntu0.1) ...
Setting up plasma-scriptengine-javascript (4:4.8.4-0ubuntu0.1) ...
Setting up kde-runtime (4:4.8.4-0ubuntu0.1) ...
Setting up xserver-common (2:1.11.4-0ubuntu10.3) ...
Setting up xserver-xorg-core (2:1.11.4-0ubuntu10.3) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Errors were encountered while processing:
 linux-image-3.2.0-26-generic
 linux-image-generic
 linux-generic
Error in function:
Setting up linux-image-3.2.0-26-generic (3.2.0-26.41) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/dkms 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-26-generic
Warning: No support for locale: en_US.utf8
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
/usr/sbin/grub-mkconfig: 33: /etc/default/grub: tmpfs: not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-26-generic.postinst line 1010.
dpkg: error processing linux-image-3.2.0-26-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.2.0-26-generic; however:
  Package linux-image-3.2.0-26-generic is not configured yet.
dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.2.0.26.28); however:
  Package linux-image-generic is not configured yet.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured

A: Check if you have any space left under /boot partition, i.e.:
df -h /boot

Typically this is a problem if there is no space left on boot partition.

A: Running this has a good chance of cleaning up your problems:
sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get install -f