text:
Q: how to Echo $var as variable name and not value in php? I have my line of code
textinjector("/var/www/html/uploadTest/test2.php", 26,  "'test' => array('$this', 'getTestData'),");

i need the $this variable to be printed as:
"$this"
and not as the value stored in $this.
my complete code:
$PageTitle = "shop";

$PageTitleCaps =  ucfirst($PageTitle);
echo "Caps is $PageTitleCaps";
// this function injects the injTesxt into the line number in the document directory
function textinjector($file, $linerNumber, $injText ) {

$content = file($file); //Read the file into an array. Line number => line content
foreach($content as $lineNumber => &$lineContent) { //Loop through the array (the "lines")
    if($lineNumber == $linerNumber) { //Remember we start at line 0.
        $lineContent .= $injText . PHP_EOL; //Modify the line. (We're adding another line by using PHP_EOL)

    }
}

$allContent = implode("", $content); //Put the array back into one string
file_put_contents($file, $allContent); //Overwrite the file with the new content
echo "$injText was injected to $file at line number $lineNumber";
}

textinjector("$fileDirectory", 26,  '"test" => array("$this", "getTestData"),');

Any sugestions?

A: Ok found out how to do this on my own.
Just created a seperate variabele i.e. $thisVar
then added
$thisVar ='$this';

echo $thisVar;

will now echo
$this

yay.
Thank you to all thwe helpers out there.
AT


text:
Q: Set custom master pages in sharepoint-hosted apps I want to use custom master pages in SharePoint-Hosted apps.
I followed this article: http://anthony-verschraegen.blogspot.fi/2013/03/sharepoint-2013-apps-custom-app-master.html
But after my solution deployment to site collection (Myportal/sites/apps) i get File Not Found error. How to solve this problem?

A: Specify your solution structure and URL details will help your question get answer correctly.
Sometime the mismatching, typo in some path will lead you to this error. Within your provided information, I suggest that you should perform the following check:
Check the Module element.xml file: Module Name, File Path, File Url
<Module Name="MasterPage">
             <File Path="MasterPage\appNew.master" Url="_catalogs/masterpage/appNew.master" ReplaceContent="TRUE" /></Module>

Check the .aspx file:
Remember the path: "~site/_catalogs/masterpage/"
<%@ Page Language="C#" MasterPageFile="~site/_catalogs/masterpage/appNew.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Check the package.package file: Does the MasterPage module added to any of your features ?
After make sure the above correct, please let me know if you're still facing this problem.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Queries too long(1-3 seconds), show a loading process icon What should I do with long data processing?
When a new activity is opened we get a black screen for 3 seconds.
I need a way to properly handle this.

A: Use AsyncTask to do the processing in the background and communicate the information back to the UI on completion. Quoting the documentation,

AsyncTask enables proper and easy use of the UI thread. This class
  allows to perform background operations and publish results on the UI
  thread without having to manipulate threads and/or handlers.

There's a basic example of subclassing AsyncTask in the documentation.


text:
Q: C1xx: fatal error C1083 because of spaces in file path (while building Qt 4.8 for MS VS) I'm trying to build Qt 4.8.6 for MS Visual Studio 2015 following this instruction by trig-ger. On the stage #5 (configure) I've got multiple errors c1xx : fatal error C1083: Cannot open source file", related to spaces in file pathD:\Program Files (x86)\Microsoft Visual Studio 14.0`:
Files
c1xx: fatal error C1083: Cannot open source file: Files: No such file or directory
Microsoft
c1xx: fatal error C1083: Cannot open source file: (x86)\Microsoft: No such file or directory
Visual
c1xx: fatal error C1083: Cannot open source file: Visual: No such file or directory
Studio
c1xx: fatal error C1083: Cannot open source file: Studio: No such file or directory
include
c1xx: fatal error C1083: Cannot open source file: 14.0\VC\include: No such file or directory
Files
c1xx: fatal error C1083: Cannot open source file: Files: No such file or directory
Microsoft
c1xx: fatal error C1083: Cannot open source file: (x86)\Microsoft: No such file or directory
Visual
c1xx: fatal error C1083: Cannot open source file: Visual: No such file or directory
Studio
c1xx: fatal error C1083: Cannot open source file: Studio: No such file or directory
QtCore
c1xx: fatal error C1083: Cannot open source file: 14.0\VC\include\QtCore: No such file or directory
Files
c1xx: fatal error C1083: Cannot open source file: Files: No such file or directory
Microsoft
c1xx: fatal error C1083: Cannot open source file: (x86)\Microsoft: No such file or directory
Visual
c1xx: fatal error C1083: Cannot open source file: Visual: No such file or directory
Studio
c1xx: fatal error C1083: Cannot open source file: Studio: No such file or directory
global
c1xx: fatal error C1083: Cannot open source file: 14.0\VC\src\corelib\global: No such file or directory
Files
c1xx: fatal error C1083: Cannot open source file: Files: No such file or directory
Microsoft
c1xx: fatal error C1083: Cannot open source file: (x86)\Microsoft: No such file or directory
Visual
c1xx: fatal error C1083: Cannot open source file: Visual: No such file or directory
Studio
c1xx: fatal error C1083: Cannot open source file: Studio: No such file or directory
xml
c1xx: fatal error C1083: Cannot open source file: 14.0\VC\src\corelib\xml: No such file or directory

Here is my configure command:
D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>D:\Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6\configure -make nmake -platform win32-msvc2015 -prefix D:\Soft\Qt\4.8\msvc2015 -opensource -confirm-license -opengl desktop -nomake examples -nomake tests

Do you have any ideas how I can fix this problem? I don't know if this is a typical Qt's problem with spaces in file path (caused by configure) or error related to Visual Studio (caused by c1xx).
Upd. I changed command line root directory to just D:> and run configure again. It started work at last (header created for [...]) but eventually produced another error after Creating qmake.... At first I got multiple lines such as:
cl : Command line warning D9024 : unrecognized source file type 'SOURCE_PATH', object file assumed
cl : Command line warning D9027 : source file 'SOURCE_PATH' ignored
cl : Command line warning D9024 : unrecognized source file type '=', object file assumed
cl : Command line warning D9027 : source file '=' ignored
cl : Command line warning D9024 : unrecognized source file type 'D:\Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6\src\corelib\xml', object file assumed
cl : Command line warning D9027 : source file 'D:\Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6\src\corelib\xml' ignored

And finally:
SOURCE_PATH
c1xx: fatal error C1083: Cannot open source file: SOURCE_PATH: No such file or directory
=
c1xx: fatal error C1083: Cannot open source file: =: No such file or directory
include
c1xx: fatal error C1083: Cannot open source file: D:\Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6\include: No such file or directory
SOURCE_PATH
c1xx: fatal error C1083: Cannot open source file: SOURCE_PATH: No such file or directory
=
c1xx: fatal error C1083: Cannot open source file: =: No such file or directory
QtCore
c1xx: fatal error C1083: Cannot open source file: D:\Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6\include\QtCore: No such file or directory
SOURCE_PATH
c1xx: fatal error C1083: Cannot open source file: SOURCE_PATH: No such file or directory
=
c1xx: fatal error C1083: Cannot open source file: =: No such file or directory
global
c1xx: fatal error C1083: Cannot open source file: D:\Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6\src\corelib\global: No such file or directory
SOURCE_PATH
c1xx: fatal error C1083: Cannot open source file: SOURCE_PATH: No such file or directory
=
c1xx: fatal error C1083: Cannot open source file: =: No such file or directory
xml
c1xx: fatal error C1083: Cannot open source file: D:\Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6\src\corelib\xml: No such file or directory

A: For me it was setting an env var CL to the path of the exe. This is not a great idea.

A: I solved the problem by switching command line root directory. Instead of
D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>D:\Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6\configure [options]

or
D:>Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6\configure [options]

it should be just
D:\Soft\Qt\4.8\msvc2015\qt-everywhere-opensource-src-4.8.6>configure [options]


text:
Q: cannot connect to sql server 2012 with java jdbc I am learning SQL/SQL Server 2012. I am also learning how to make forms with java using NetBeans. I am trying to link java to my SQL Server 2012 Express so I can make a form that uses/updates data in a SQL database but have not been successful.
I have done lots of research trying to find a solution and made changes that I found I needed to make. I have set up SQL Server to use TCP port 1433 on my computer. I have also made an exception in my firewall to allow that incoming connection. I have created a user "admin" and given that user sysadmin role. I have also set up SQL Server to allow remote connections with a time out of 60 seconds.
When I try to connect to the SQL Server from MS SQL Server Management Studio and put my computers static IP and port 1433, I get the attached error:

When I try to connect to the SQL Server database from NetBeans I get this:

Cannot establish a connection to
  jdbc:sqlserver://DEVINSPC\SQLEXPRESS;databaseName=Test using
  com.microsoft.sqlserver.jdbc.SQLServerDriver (The TCP/IP connection to
  the host DEVINSPC, port 1433 has failed. Error: "connect timed out.
  Verify the connection properties. Make sure that an instance of SQL
  Server is running on the host and accepting TCP/IP connections at the
  port. Make sure that TCP connections to the port are not blocked by a
  firewall.".)

I am using jdbc4.2.jar file. I have set SQL Server to use both SQL Server and Windows Authentication. Hopefully this all makes sense.
If you need anymore info let me know. Any help is appreciated!


text:
Q: saveAll doesn't save associated data in cakephp 2.0 after processing the form with multiple select I have a model and hasMany relation to another model.
The single fields data is saved to the main model, and the data from dropdown select input should be saved to the associated model.
When I'm trying to manually create an array and use saveAll, everything works fine and the data is saved. But the issue with the select input is inside its name. The correct format is:
array(
    'Article' => array('title' => 'My first article'),
    'Comment' => array(
        array('body' => 'Comment 1', 'user_id' => 1),
        array('body' => 'Comment 2', 'user_id' => 12),
        array('body' => 'Comment 3', 'user_id' => 40),
    ),
)

When creating the select list and passing the options array, we can only setone tag name like Comment.body, but we have to use Comment.0.body, Comment.1.body, etc.
So the format of the post data is unreadable for Cake to successfully use saveAll.
Has anybody encountered this issue - generating multiple select input with correct names and values?

A: The issue was resolved by switching to a $hasAndBelongsToMany relation.

A: How are you generating your form? The correct format is the second you said, Comment.0.body. For this you need something like this:
echo $this->Form->input('Comment.0.body');
echo $this->Form->input('Comment.1.body');

Will generate:
<input type='text' id='Comment0Body' name="data[Comment][0][body]" />
<input type='text' id='Comment1Body' name="data[Comment][1][body]" />


text:
Q: EC2 Linux AMI with ffmpeg (no yasm?) I'm running a Basic 64-bit Amazon Linux AMI 2011.09 (AMI Id: ami-953b06e1) and I want to install ffmpeg into it so I can use it convert video.
These are the commands I run after firing up a new instance:
sudo -i
yum update
yum install gcc
yum install gcc-c++
yum install make

Then for yasm I get "No package yasm available." so I do this:
cd /usr/local/src/
wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.0.tar.gz
tar zfvx yasm-0.7.0.tar.gz
cd yasm-0.7.0
./configure && make && make install

Followed by
yum install git
yum install subversion
yum install check-devel
yum groupinstall "Development Tools" -y

I'm trying to follow the instructions from http://pitchpublish.com/?p=158 and this is the point where it all fails.
cd /usr/local/src
wget http://webm.googlecode.com/files/libvpx-v0.9.6.tar.bz2
tar -xvf libvpx-v0.9.6.tar.bz2
cd libvpx-v0.9.6
./configure
make
make install

But at the point that I run ./configure it runs a few lines then "Neither yasm nor nasm have been found". Despite the fact that when I ran ./configure when setting up yasm there were no errors.
As you can see setting all this up confuses me, a lot. At the end of the day I want a PHP environment in which I can convert video to h264, webm, and get some video screenshots.


text:
Q: What's a reverse of a set? say I have  $C = \{\epsilon, aa, aab, bba\}$, what would be the reverse of set C?
Is it $C^R = \{bba, aab, aa, \epsilon\}$? but I think the order in a set doesn't matter. Or it is $C^R = \{\epsilon, aa, baa, abb\}$?

A: Not sure what you mean by "reverse" of a set, but you might want $X$ \ $C$ where $X$ is the domain of $C$. In this case, it's called the complement of the set and consists of all elements in $X$ but not in $C$. So if your domain $X$ is $\{\epsilon,a,b,aa,ab,bb,aaa,aab,aba,abb,baa,bab,bba,bbb\}$, then the complement of $C$, $X$ \ $C$, is $\{a,b,ab,bb,aaa,aba,abb,baa,bab,bbb\}$.


text:
Q: Does asp.net timer clear Cache? I have a page that I've been using that pulls a lot of data for people to see. The data updates about every minute... So to decrease server load I cache the page for 60 seconds:
    '-----Set Cache
    Response.Cache.SetExpires(DateTime.Now.AddSeconds(60))
    Response.Cache.SetCacheability(HttpCacheability.Server)
    Response.Cache.SetValidUntilExpires(True)
    '---------------

That was working great... but now I added an asp.net Timer and set the interval to 30 seconds for testing.
I have a timestamp on the page and when the timer.tick event happens and updates the updatepanel, the timestamps are changing.
Protected Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
    updatePanel.Update()
End Sub

Prior to the timer, the timestamps would stay the same on a browser refresh because the cache. Now it appears they're updating on each tick event (eliminating the purpose of caching).
Even in 2 browsers side-by-side, the timestamps are updating on EVERY update by each browser...
So it appears that the timer loses the cache and defeats the purpose.
Does anyone know how to solve this issue?
The page does not have any controls (buttons, dropdowns, etc) it just displays data in grids (multiple instances of user controls inserted programatically).

A: What you've added - basically caches the GET request for the page.  The POST (when the timer fires) typically isn't cached.  I'd suggest that you not cache the actual page, but the results of your 'a lot of data'.   Please take a look into HttpRuntime.Cache
Should I use HttpRuntime.Cache?


text:
Q: Cannot create a new thread because the task queue has reached it maximum limit 5000 I'm using quite a few cfthreads in a scheduled task (because cf runs out of memory otherwise), and now I'm getting the following error:

Cannot create a new thread because the task queue has reached it maximum
  limit 5000.

So here are my questions:

*

*what is the "task queue" exactly, and where are the docs?

*how do I increase this limit?

*how can I determine what the limit is dynamically? and how many threads are already in the queue?

A: Why not use the run-join idiom I provided as an answer to another question of yours: many queries in a task to generate json? You could alter that code example to create several threads and then join if you're looking for things work asynchronously. In addition, having as many threads as your question describes actually slow things down because the server spends too much time context switching between threads.

A: It looks like the limit is a built-in limit that cannot be changed.
The message above is an error message though, so you could wrap the cfthread in a cftry to find out when the limit is reached.


text:
Q: Setting a global variable at the end of a generator, persistence of loop variables I want to know the number of items that a generator has generated.
I'm trying to do this by using the output of enumerate to set a global variable. It works on simple tests but goes wrong once I try to adapt the technique to my real application case.
The following script tests first a generator based on an iteration over the lines of a file, then a generator based on the parsing of a file using a bioinformatics library I want to use:
#!/usr/bin/env python3

def test1(delete=False):
    # I have to comment the following otherwise I get:
    # $ ./test.py
    # Traceback (most recent call last):
    #   File "./test.py", line 60, in <module>
    #     test1()
    #   File "./test.py", line 31, in test1
    #     print(nb_things)
    # UnboundLocalError: local variable 'nb_things' referenced before assignment
    # if delete:
    #     try:
    #         del nb_things
    #         print("deleted nb_things")
    #     except NameError:
    #         pass
    with open("test.py") as this_file:
        def my_gen():
            for i, thing in enumerate(this_file, start=1):
                yield "just_to_test"
            global nb_things
            nb_things = i
            return

        g = my_gen()
        for _ in g:
            pass

        print(nb_things)
    return 0

import pysam

def test2(delete=False):
    if delete:
        try:
            del nb_things
            print("deleted nb_things")
        except NameError:
            pass
    with pysam.AlignmentFile("/path/to/a/bam/file", "rb") as bamfile:
        def my_gen():
            for i, thing in enumerate(bamfile.fetch(), start=1):
                yield "just_to_test"
            global nb_things
            nb_things = i
            return

        g = my_gen()
        for _ in g:
            pass

        print(nb_things)
    return 0

if __name__ == "__main__":
    test1()
    print("end of test 1")
    test2()
    print("end of test 2")

(As you can see in the comment in the above script, very strange things happen if I include code that mention my global variable without even being executed.)
When I execute the above code, the first test succeeds, but not the second, despite a very similar code structure:
$ ./test.py
63
end of test 1
Traceback (most recent call last):
  File "./test.py", line 62, in <module>
    test2()
  File "./test.py", line 53, in test2
    for _ in g:
  File "./test.py", line 49, in my_gen
    nb_things = i
UnboundLocalError: local variable 'i' referenced before assignment

My main question is:
Why does the enumeration counter still exist after the end of the for loop in the first case and not in the second?
I suspect that this has to do with the way the iteration is stopped. In the second case the generator somehow causes the enumerate result to cease to exist after the internal iterator gets stops.
What could cause such a difference?
A second question that occurred to me while designing the above test script is the following:
Why is the global variable nb_things considered local if I put code referencing it but not even executed? (note the delete=False, and the absence of a message mentioning the deletion)
I'm using python 3.6 and pysam version 0.10.0.

For an earlier version of the real code (but the essential approach is there), and clues regarding why I ended up defining my generator in the main function, see this question. (Essentially, the reason is that the generator actually uses a function that is defined depending on command-line options.)


text:
Q: Android Error inflating class EditText I encountered a strange problem. My Android app would crash whenever I add an EditText in an Activity. To test, I open a new clean project, and the new project will crash if there is an EditText as well. Therefore, I think the problem is caused from Android Studio or other environment setting.
Following is the activity_main.xml
 <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    android:id="@+id/activity_main"
    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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="yichun.myapplication.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:id="@+id/textView"
        app:layout_constraintLeft_toLeftOf="@+id/activity_main"
        app:layout_constraintTop_toTopOf="@+id/activity_main"
        app:layout_constraintRight_toRightOf="@+id/activity_main"
        app:layout_constraintBottom_toBottomOf="@+id/activity_main"/>
    <EditText
        android:layout_width="218dp"
        android:layout_height="45dp"
        android:inputType="textPersonName"
        android:text="Name"
        android:ems="10"
        tools:layout_editor_absoluteX="90dp"
        android:id="@+id/editText"
        app:layout_constraintBottom_toTopOf="@+id/textView" android:layout_marginBottom="40dp"/>
</android.support.constraint.ConstraintLayout>

MainActivity.java
    public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

Error message
E/AndroidRuntime: FATAL EXCEPTION: main
              Process: yichun.myapplication, PID: 3239
              java.lang.RuntimeException: Unable to start activity ComponentInfo{yichun.myapplication/yichun.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #20: Error inflating class EditText
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
                  at android.app.ActivityThread.access$800(ActivityThread.java:144)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:135)
                  at android.app.ActivityThread.main(ActivityThread.java:5221)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:372)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
               Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class EditText
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                  at yichun.myapplication.MainActivity.onCreate(MainActivity.java:11)
                  at android.app.Activity.performCreate(Activity.java:5937)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
                  at android.app.ActivityThread.access$800(ActivityThread.java:144)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:135)
                  at android.app.ActivityThread.main(ActivityThread.java:5221)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:372)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
               Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v21/abc_edit_text_material.xml from drawable resource ID #0x7f020015
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:2428)
                  at android.content.res.Resources.loadDrawable(Resources.java:2330)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                  at android.view.View.<init>(View.java:3730)
                  at android.widget.TextView.<init>(TextView.java:634)
                  at android.widget.EditText.<init>(EditText.java:65)
                  at android.widget.EditText.<init>(EditText.java:61)
                  at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:60)
                  at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:56)
                  at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:112)
                  at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:980)
                  at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1039)
                  at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                  at yichun.myapplication.MainActivity.onCreate(MainActivity.java:11)
                  at android.app.Activity.performCreate(Activity.java:5937)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
                  at android.app.ActivityThread.access$800(ActivityThread.java:144)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:135)
                  at android.app.ActivityThread.main(ActivityThread.java:5221)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:372)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
               Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #24: <nine-patch> requires a valid 9-patch source image
                  at android.graphics.drawable.NinePatchDrawable.updateStateFromTypedArray(NinePatchDrawable.java:445)
                  at android.graphics.drawable.NinePatchDrawable.inflate(NinePatchDrawable.java:401)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1095)
                  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:185)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1095)
                  at android.graphics.drawable.InsetDrawable.inflate(InsetDrawable.java:104)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1095)
                  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1017)
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:2418)
                  at android.content.res.Resources.loadDrawable(Resources.java:2330)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                  at android.view.View.<init>(View.java:3730)
                  at android.widget.TextView.<init>(TextView.java:634)
                  at android.widget.EditText.<init>(EditText.java:65)
                  at android.widget.EditText.<init>(EditText.java:61)
                  at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:60)
                  at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:56)
                  at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:112)
                  at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:980)
                  at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1039)
                  at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                  at yichun.myapplication.MainActivity.onCreate(MainActivity.java:11)
                  at android.app.Activity.performCreate(Activity.java:5937)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
                  at android.app.ActivityThread.access$800(ActivityThread.java:144)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:135)
                  at android.app.ActivityThread.main(ActivityThread.java:5221)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:372)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

A: Using 2.2.x version of the gradle plugin could cause this.
Bug tracker link
Downgrading might worth a try:
// project level build.gradle
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
}

I suppose it will be fixed eventually, so future readers can try upgrading instead of downgrading :)

A: Same issue: Solved.
My image files were in the "drawable-v24" folder. Move them to the "drawable" folder too.
Problem solved.


text:
Q: SQL Server SPID doesnt change for every connection We are building an ERP system, and sometimes we need to see the SQL statement in SQL Server Profiler for debuging purposes. I can catch my ERP's queries by the SPID on Profiler. My ERP doesnt keep an open connection, it opens a connection everytime it needs it.
I have been thinking that everytime my ERP opens a connection, it should get a new SPID. How does it give the same SPID?

A: SPIDs are recycled, they are guaranteed to be unique at any one time, but if a connection drops, its SPID can be reused by a new connection.


text:
Q: how to make np.where work in this example I want the variable b, when the b is between (-2,2) , the output is b; when is beyond the domain (-2 ,2),the output is 0. I try a lot of times. The problem is it can not work continuously, for the first few lines, 0 is output. However, there still some value smaller than- 2, and the output is b itself, it should be 0.
for k in range (nz):
    b = xg- nl*z[k]
    c = xg- nt*z[k]
    b = np.array(b)
    c = np.array(c)
    np.where((b > -2)&(b<2) ,b,0)
    np.where(( c >-2) & (c < 2),c,0)

A: What about if you multiply the masking arrays?
import numpy as np

a = np.arange(-5,5)
# [-5 -4 -3 -2 -1  0  1  2  3  4]

cond = (a>-2)*(a<2)
b = np.where(cond,a,0)
# [ 0  0  0  0 -1  0  1  0  0  0]


text:
Q: Launching activity on long press of volume button I want to launch app when we press the volume button long time up or down button.When activity is not visible and app is present in background i.e in recent apps.Is there any solution for that. I am new to android so please help me to resolve this problem.

A: Just look for broadcast receiver on android developer site. You will get goo explanation with example.


text:
Q: Adding rubberband zoom to ChartView via MouseArea I have a ChartView item declared in QML and I need a rubberband-like zoom functionality. This can be achieved with semi-transparent rectangle and MouseArea item. The problem is with one rectangle it's only possible to select area from top-left to bottom-right due to the fact that Rectangle item with negative dim-s is either invisible or disabled. Although it's possible to apply transform to Rectangle
transform: Scale { origin.x: 0; origin.y: 0; xScale: -1}

I failed to find how to manipulate xScale/yScale properties from the outside.
Right now I draw 4 rectangles, one per each quadrant, with correct xScale/yScale and dims (code in the end).
So I wonder is there more elegant/easy solution to the problem?
ChartView {
    id: chartViewTop
    ...

    Rectangle{
        id: rubberBandRec1
        border.color: "black"
        border.width: 1
        opacity: 0.3
        visible: false
        transform: Scale { origin.x: 0; origin.y: 0; yScale: -1}
    }

    Rectangle{
        id: rubberBandRec2
        border.color: "black"
        border.width: 1
        opacity: 0.3
        visible: false
        transform: Scale { origin.x: 0; origin.y: 0; yScale: -1; xScale: -1}
    }

    Rectangle{
        id: rubberBandRec3
        border.color: "black"
        border.width: 1
        opacity: 0.3
        visible: false
        transform: Scale { origin.x: 0; origin.y: 0; xScale: -1}
    }

    Rectangle{
        id: rubberBandRec4
        border.color: "black"
        border.width: 1
        opacity: 0.3
        visible: false
    }

    MouseArea {
        anchors.fill: parent
        hoverEnabled: true
        onPressed: {
            rubberBandRec1.x = mouseX; rubberBandRec1.y = mouseY; rubberBandRec1.visible = true;
            rubberBandRec2.x = mouseX; rubberBandRec2.y = mouseY; rubberBandRec2.visible = true;
            rubberBandRec3.x = mouseX; rubberBandRec3.y = mouseY; rubberBandRec3.visible = true;
            rubberBandRec4.x = mouseX; rubberBandRec4.y = mouseY; rubberBandRec4.visible = true;
        }
        onMouseXChanged: {
            rubberBandRec1.width = mouseX - rubberBandRec1.x;
            rubberBandRec2.width = rubberBandRec2.x-mouseX;
            rubberBandRec3.width = rubberBandRec3.x-mouseX;
            rubberBandRec4.width = mouseX - rubberBandRec4.x;
        }
        onMouseYChanged: {
            rubberBandRec1.height = rubberBandRec1.y - mouseY;
            rubberBandRec2.height = rubberBandRec2.y - mouseY;
            rubberBandRec3.height = mouseY - rubberBandRec3.y;
            rubberBandRec4.height = mouseY - rubberBandRec4.y;
        }
        onReleased: {
            var x = rubberBandRec4.x-(rubberBandRec4.width<0)*Math.abs(rubberBandRec4.width);
            var y = rubberBandRec4.y-(rubberBandRec4.height<0)*Math.abs(rubberBandRec4.height);

            if (Math.abs(rubberBandRec4.width*rubberBandRec4.height)>100)
                chartViewTop.zoomIn(Qt.rect(x, y, Math.abs(rubberBandRec4.width),
                                            Math.abs(rubberBandRec4.height)));
            rubberBandRec1.visible = false;
            rubberBandRec2.visible = false;
            rubberBandRec3.visible = false;
            rubberBandRec4.visible = false;
        }
    }
}

A: Set external properties for the scaling, and then just change these in the onMouseXChanged and onMouseYChanged events as follows.  This appears to be working for me:
property int xScaleZoom: 0
property int yScaleZoom: 0

Rectangle{
    id: recZoom
    border.color: "steelblue"
    border.width: 1
    color: "steelblue"
    opacity: 0.3
    visible: false
    transform: Scale { origin.x: 0; origin.y: 0; xScale: xScaleZoom; yScale: yScaleZoom}
}
MouseArea {
    anchors.fill: parent
    hoverEnabled: true
    onPressed: {
        recZoom.x = mouseX;
        recZoom.y = mouseY;
        recZoom.visible = true;
    }
    onMouseXChanged: {
        if (mouseX - recZoom.x >= 0) {
            xScaleZoom = 1;
            recZoom.width = mouseX - recZoom.x;
        } else {
            xScaleZoom = -1;
            recZoom.width = recZoom.x - mouseX;
        }
    }
    onMouseYChanged: {
        if (mouseY - recZoom.y >= 0) {
            yScaleZoom = 1;
            recZoom.height = mouseY - recZoom.y;
        } else {
            yScaleZoom = -1;
            recZoom.height = recZoom.y - mouseY;
        }
    }
    onReleased: {
        var x = (mouseX >= recZoom.x) ? recZoom.x : mouseX
        var y = (mouseY >= recZoom.y) ? recZoom.y : mouseY
        chartView.zoomIn(Qt.rect(x, y, recZoom.width, recZoom.height));
        recZoom.visible = false;
    }
}


text:
Q: Autodesk forge viewer js dependencies storing in local project I am working with Autodesk viewer using angular and typescript. I am using https://developer.api.autodesk.com/modelderivative/v2/viewers/style.css - (For CSS) and https://developer.api.autodesk.com/modelderivative/v2/viewers/viewer3D.js - (For JS).
But I want to download these files to store and use from the project folder. It seems like downloading and adding only these files won't do the job as viewer3D.js references more online js files.
Can I get all the files which are needed to view locally.
Please help.

A: There are actually a few other files required by the Viewer, but per license, you should use them from Autodesk server:
// Autodesk Forge Viewer Usage Limitations:
//
// The Autodesk Forge viewer can only be used to view files generated by
// Autodesk Forge services. The Autodesk Forge Viewer JavaScript must be
// delivered from an Autodesk hosted URL.


text:
Q: Transparent background on page 1 I try to include a 'Watermark' in some documents. To achieve that I use eso-pic and tikz. The problem is, that I don't get transparancy in one-paged documents. As soon as the document has more than one page everything is fine.
My MWE demonstrates that. Uncomment %\newpage and the background is transparent (even on page 1).
What is wrong with my code? What do I have to change to achieve a transparent background even on one-page documents?
\documentclass{article}
\usepackage{eso-pic}
\usepackage{tikz}

\ClearShipoutPicture
\AddToShipoutPicture{
\begin{tikzpicture}[remember picture, overlay, opacity=0.08]%
  \node [rotate=60,scale=10,text opacity=0.2] at (current page.center) {Example};
\end{tikzpicture}
}

\begin{document}
   \null
   %\newpage
\end{document}

A: You could use the background package (which is based on TikZ). Note that you have to compile twice to get it working correctly.
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{background}
\usepackage{lipsum}

\SetBgContents{water free water mark}
\SetBgScale{7}
\SetBgColor{black!40!white}

\begin{document}
\lipsum[1-7]
\end{document}


text:
Q: PHP: How to match all occurences of a regex pattern in a document I am doing some data munging on documents which may (or may not - as the case may be) have ocurrence(s) of a regular expression pattern in their content.
I would like to write a PHP function to use to process the documents - the job of the function is to return an array of all matching patterns sound in the document (if they exist), or to return an empty array if no matches were found.
I am sure that this involves using the PHP function preg_match_all, however, I do not understand the format of the array returned by preg_match_all. I simply want to return a 1 dimensional (i.e. non-nested array) of the strings that match as follows:
<?php

   $pattern = "^[h].[a-z]{3,4}";
   $doc = file_get_contents('some_pathname');

   function get_matching_patterns($pattern, $doc){
     $out = array();

     if (strlen($doc) && strlen($pattern)){
        // not sure about this - I don't like the complicated nested array returned
        // by preg_match-all
        preg_match_all($pattern, $doc, $out);
     }

     return out;
   }
?>

A: *

*You're missing a $

*In your case you can simply return $out[0]


text:
Q: Field Extension $E/F$ algebraic iff every subring $R$ of $E$ which contains $F$ is a field Let $E/F$ be a field extension and $F\subset R\subset E$ where $R$ is a subring of $E$. I want to show that: $E/F$ is algebraic iff every subring $R$ of $E$ which contains $F$ is a field.
I already proved that if $E/F$ is algebraic then $R$ is a field. (Note that $R$ is completely arbitrary).
Now I am stuck at the converse, namely, if for every subring $R$ it holds that it is a field ($R$ given as above), then $E/F$ is algebraic.
My strategy would be that I choose an arbitrary $r\in R$ and look at $F[r]=F(r)$ where I have used that every subring is a field. But now I have trouble proceeding, because I can not work with finite polynomials to show anything.

A: If $E$ is not an algebraic extension of $F$, then there's some $\omega\in E$ which is transcendental over $F$. Take $R=F[\omega]$. It is a ring, but not a field ($\omega$ has no inverse there).


text:
Q: Question on members in derived classes (new vs override) I'm working through the Head First Design Patterns book and am currently on the Decorator Pattern chapter. Since the book examples are written in Java, I'm adapting the, to C# as I go.
This example simulates a coffee shop ordering system. There is an abstract base class for Beverage and subclasses for specific beverages (ex: Espresso). The decorator classes are used to add condiments and drink modifications. There is an abstract class CondimentDecorator that derives from Beverage and then subclasses like Mocha for the individual decorators. Gist with all files: https://gist.github.com/anonymous/67e4fe5fe0477d34b24125f741ad0b3a
My question - in the base Beverage class, the description string is set to "Unknown beverage". The constructor for a specific drink sets this to the drink name - so if I use:
Beverage espresso = new Espresso();
Console.WriteLine($"{espresso.GetDescription()}");

It responds with "Espresso". Now, when using the decorator, the GetDescription method is overridden, in the Mocha class it adds "Mocha" after the beverage's description.
public override string GetDescription()
{
    return beverage.GetDescription() + " Mocha";
}

If I use the override modifier in CondimentDecorator.cs:
public abstract override string GetDescription();

This works as expected. I run:
Beverage espresso = new Espresso();
Console.WriteLine($"{espresso.GetDescription()}"); // Espresso
espresso = new Mocha(espresso);
Console.WriteLine($"{espresso.GetDescription()}"); // Espresso Mocha

However, if I change the modifier to new in CondimentDecorator.cs like this:
public abstract new string GetDescription();

And run the same code, I get the below results:
Beverage espresso = new Espresso();
Console.WriteLine($"{espresso.GetDescription()}"); // Espresso
espresso = new Mocha(espresso);
Console.WriteLine($"{espresso.GetDescription()}"); // Unknown beverage

I'm a little confused why this happens...since GetDescription is being called in Mocha like this...
public override string GetDescription()
{
    return beverage.GetDescription() + " Mocha";
}

...and beverage is a reference back to the original espresso object, why doesn't the code pick up on the description that was set when Espresso was instantiated? The way I understand this, new would hide the original GetDescription method in the base class while override would extend that method. I'm not sure why that would effect which description the program reads -- the "unknown beverage" of Mocha, which gets that value from the Beverage class it derives from, or the "Espresso" of the beverage object I created that had the description set in the constructor.
I'm sure I'm just misunderstanding something basic about inheritance and how the new and override keywords work, if anyone can shed a little light on this I'd appreciate it!
Thanks!

A: I think this article explains it:
https://msdn.microsoft.com/en-us/library/ms173153.aspx
Basically it depends on whether your beverage is being accessed as a Mocha or and Expresso vs what it actually is.
Assume you have a simple case where
Mocha : Espresso
then
((Espresso)mocha).GetDescription()  == "espresso" if you 'new' rather than 'override'
so if you want to do
foreach(Beverage b in List)
{
    //print description
}

then you should override
Now your particular example is complicated by your decorator. which also inherits from beverage.
you have
Espresso : Beverage
and
Mocha : Decorator : Beverage
so when you use 'new' on Mocha but call
((Beverage)mocha).GetDescription()
you get the Beverage result "unknown beverage"

A: The confusing thing about new is that it creates a second method with the same name as an existing method.
Let's talk about this line of code:
public abstract new string GetDescription();

Thanks to this code, CondimentDecorator now has two GetDescription methods: it has

*

*GetDescription, inherited from Beverage, and also

*GetDescription, newly declared in CondimentDecorator.

Now, whenever you call GetDescription, the compiler has to decide which GetDescription method to call. It does this by looking at the declared type of the variable that you're calling the method on (not the runtime type). If the declared type is Beverage, it calls the method which is inherited from Beverage; if the declared type is CondimentDecorator, it calls the method that's newly declared in CondimentDecorator.
Let's look at your calling code now:
Beverage espresso = new Espresso();
Console.WriteLine($"{espresso.GetDescription()}"); // Espresso
espresso = new Mocha(espresso);
Console.WriteLine($"{espresso.GetDescription()}"); // Unknown beverage

What is happening is that since the declared type of the espresso variable is Beverage, the compiler always interprets this as a call to the GetDescription method which is inherited from Beverage. The fact that the runtime type of espresso is Mocha doesn't matter.


text:
Q: Please make pending edit suggesters be @reply-able in comments When reviewing suggested edits, it often happens that I'd like to say something to the edit suggester, but I can't. The ability to reply to them would be a way to solve edit problems much more amicably, rather than rejecting possibly approvable edits without giving them a reason.
Commenting on unrelated posts is clearly not okay. Rejecting the edit with a custom "causes harm" reasoning is also not a good solution, because:

*

*This doesn't notify the edit suggester; they would need to dig out the review for that, which rarely happens.

*It can only happen when rejecting the suggestion, which is often not my intent.

Besides that:

*

*past approved and binding editors of posts are already reply-able1,

*there is already an ongoing feature request to allow replying to rejected editors in comments

*it's possible for users with pending edit suggestions to edit their edit proposals, so that those edits are also incorporated into the same review (i.e. an unlimited grace period while the edit is still pending)

*the "Improve Edit" option may not be the right option, as the reviewer may not be entirely aware of what the edit proposer is on to in some cases, or they may need further clarification of the edit before making a decision

I am asking to allow @reply-ing to users who have a pending suggested edit on the post.
Note, this does not mean the overloading of their inbox - they won't be notified of all comments, only ones that @-mention their name. Only the post owner would get a notification from all the comments on their post, as normal.
Another use case of this feature would be in case someone who has accidentally created a second account or has lost access to their original account suggests an edit to one of their own posts; since the user won't (be able to) see notifications on the first account, one can mention to their second account with the fact that they have another account and instructions to have their account merged.
1As @Glorfindel mentions, they are already pingable. But pending and rejected suggested editors are still not.


text:
Q: Как смержить ветку в другой проект? Есть два проекта, модули для работы с бд у них идентичные и поэтому хочу слить их в один проект. Как можно смержить ветку с одного проекта с веткой из другого в gitlab?

A: Нельзя просто так взять и с одного проекта в другой влить кусок кода. Нужно, что бы у них было что то общее. К примеру, один является форком другого. Тогда pull request и готово.
Но как всегда есть много вариантов решить проблему.

*

*Самый простой и наивный - просто скопипасть нужные файлы в другой проект и закоммитить. Готово. Для однократного переноса - ок, но для каждодневного - нет.

*Более сложный способ - подготовить diff нужных файлов и перенести diff. в принципе, ничем не отличается от предыдущего по результату. Но есть дифф, поможно понять, что именно переноситься. Если изменений немного, то может это и более оптимальный способ.

*Более красивый, но сложный. Модуль работы с базой выделить в отдельный репозиторий и подключить к обоим проектам как сабмодуль.  Это достаточно гибкий метод - сабмодуль можно будет отдельно развивать, тестить. Но если пойдете этим путем, не делайте сабмодуль с сохранением дерева. Перенесите в другую папку. Иначе при любых действиях, которые затрагивают коммиты из "досабмодульного состояния", постоянно будут вылезать разные "проблемы с репой".


text:
Q: how to load .dat file to hive or hdfs? how to load  .dat file to hive or cloudera or hdfs?
is it necessary to convert this format to structured format by using pig?
if it is yes can someone gives pig script to convert this to structure data?
My data looks like this when i open .dat file in notepad++
Americas¤AME  ¤ZONE¤ ¤¤¤Active¤
Asia-Pacific¤APA  ¤ZONE¤ ¤¤¤Active¤
Europe¤EUR  ¤ZONE¤ ¤¤¤Active¤
Middle East, India and Africa¤MAI  ¤ZONE¤ ¤¤¤Active¤
Unidentified¤999  ¤ZONE¤ ¤¤¤Active¤
Afghanistan¤AF   ¤COUNTRY¤ ¤MAI  ¤ZONE¤Active¤3
Albania¤AL   ¤COUNTRY¤ ¤EUR  ¤ZONE¤Active¤1
Algeria¤DZ   ¤COUNTRY¤ ¤MAI  ¤ZONE¤Active¤3
American Samoa¤AS   ¤COUNTRY¤ ¤APA  ¤ZONE¤Active¤3
Andorra¤AD   ¤COUNTRY¤ ¤EUR  ¤ZONE¤Active¤1
Angola¤AO   ¤COUNTRY¤ ¤MAI  ¤ZONE¤Active¤1

A: Do you just want to load the data in hdfs ?
hadoop fs -put ./myfile.dat /home/hadoop/dir
Now your file is in hdfs and you can use it in your code using the delimiter in your data.
Just checked the data with '¤'
   cat spch.dat | awk -F'¤' '{print $1,$2,$3,$4,$5}'

Americas AME   ZONE
  Asia-Pacific APA   ZONE
  Europe EUR   ZONE
  Middle East, India and Africa MAI   ZONE

// Pig
A = LOAD '/hadoop/dir/myfile.dat' usig PigStorage('¤') as (field1,filed2 ..);
// use the fields


text:
Q: Excel - How to split semi-colon separated values in multiple columns into rows I have a table in Excel with following format

Col1
Col2
Col3
Col4

alpha
A;B;C;D
1;2;3;4
a;b;c;d

beta
E;F
0;5
x;y

How do I split each corresponding values in columns to rows?

Col1
Col2
Col3
Col4

alpha
A
1
a

alpha
B
2
b

alpha
C
3
c

alpha
D
4
d

beta
E
0
x

beta
F
5
y

I tried power query (from Table/Range) -> Split column by delimiter (Advanced -> into rows). But I quickly get a lot of duplicated values and removing duplicates can be challenging.
Any suggestions on how to achieve this without a macro?
EDIT: Added new column (Col1) to understand repetition of single values in a column is handled when splitting values in other columns into rows.

A: In powerquery
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes (Source,List.Transform(Table.ColumnNames(Source), each {_, type text})),
TableTransform = Table.Combine(List.Transform(List.Transform(Table.ToRecords(#"Changed Type"), (x) => List.Transform(Record.ToList(x), each Text.Split(_,";"))), each Table.FromColumns(_, Table.ColumnNames(#"Changed Type"))))
in  TableTransform

Update for changed requirements:  right click and fill down a static column

A: If you have the data in the following range: B1:D3 (including the header). You can achieve it for each column as follows in F2;
=TEXTSPLIT(TEXTJOIN(";",,B2:B3),,";")

For the first column and then to extend the formula to the following columns.
A more concise way to achieve it for a large number of columns is to use the following formula (Formula 1):
=TRANSPOSE(
  TEXTSPLIT(REDUCE("",
  BYCOL(B2:D3, LAMBDA(x, TEXTJOIN(";",,x))),
  LAMBDA(a,b,IF(a="", b, a&","&b))),";",",",,,""))

Notes:

*

*Added more values to Col1 and Col2, to validate it works when we have different number of rows in the table.

*We use pad_with input argument from TEXTSPLIT to consider columns with different number of elements and to pad is as blank.

*REDUCE is used to convert the entire input to a single string, adding a column delimiter (,). The result will be a string delimited rows with ; and columns with ,.

*Finally TEXTSPLIT converts it back to an array format, we need to transpose the result because this function populates the information by row.

Update for the new column added in the question
After the modification of the original question:

EDIT: Added new column (Col1) to understand repetition of single
values in a column is handled when splitting values in other columns
into rows

Now we need to consider how to handle the first column. Let's say we have the new data set on the following range: B13:D14. This is just a modification of previous solution to consider the special case of the first column. Now we can replace the input range (B2:D3) in (Formula 1) with the following (Formula 2):
HSTACK(MAP(BYROW(MAP(A13:D14, LAMBDA(item,
 (LEN(item)-LEN(SUBSTITUTE(item,";",""))))),
 LAMBDA(xx, MAX(xx)+1)), A13:A14, LAMBDA(maxRows,value,
 LET(yy,REPT(value&";",maxRows),
 LEFT(yy, LEN(yy)-1)))), B13:D14)

The above formula produces the following output:

Col1
Col2
Col3
Col4

alpha;alpha;alpha;alpha
A;B;C;D
1;2;3;4
a;b;c;d

beta;beta
E;F.
0;5;
x;y

The final formula in F13 will be:
=TRANSPOSE(TEXTSPLIT(REDUCE("", BYCOL(HSTACK(MAP(BYROW(MAP(A13:D14,
  LAMBDA(item,(LEN(item)-LEN(SUBSTITUTE(item,";",""))))),
  LAMBDA(xx, MAX(xx)+1)), A13:A14,
  LAMBDA(maxRows,value, LET(yy,REPT(value&";",maxRows),
  LEFT(yy, LEN(yy)-1)))), B13:D14),
  LAMBDA(x, TEXTJOIN(";",,x))),
  LAMBDA(a,b,IF(a="", b, a&","&b))),";",",",,,""))

Here is the final result:

Explanation of Formula 2
HSTACK function is used to combine the following arrays: [Col1*, B13:D14] where Col1* represents the modified Col1, in a way we add the repetition of the first column based on the maximum number of rows we are going to generate per each row of the input dataset.
To calculate Col1* we need to determine the maximum number of rows and then repeat the original value as many time as rows we are going to generate.
Let's start with the calculation of the maximum number of rows: we do it by counting the number of ; plus one. The idea for counting the number of occurrences of a specific character in a string was taken from here: How to Count Characters in Excel, so in our case we use:
LEN(item)-LEN(SUBSTITUTE(item,";",""))

The MAP function with two input arguments: maxRows,value in the LAMBDA function is used to build a new range, where the first argument represents an array with the maximum number of rows. It uses a inner MAP to do this calculation:
=BYROW(MAP(A13:D14, LAMBDA(item,
  (LEN(item)-LEN(SUBSTITUTE(item,";",""))))),
  LAMBDA(xx, MAX(xx)+1))

it returns:
| 4 |
| 2 |

The second argument (value) represents the cells from Col1: A13:A14.The outher MAP now repeats the Col1 values based on the maximum number of rows (maxRows) calculated before and remove the ; at the end.
=LET(yy,REPT(value&";",maxRows),
 LEFT(yy, LEN(yy)-1))

you can test it separately with the following formula (hard coded the number of repetitions to 4 for testing purpose):
=BYROW(A13:A14, LAMBDA(value,
  LET(yy,REPT(value&";",4), LEFT(yy, LEN(yy)-1))))

it produce the following output:
|alpha;alpha;alpha;alpha |
|beta;beta;beta;beta     |


text:
Q: Where to put same code? mixin? I've created a class Formular in my lib-folder that is extend by a module, that is also allocated in my lib-folder:
It looks something like this: formular.rb
class Formular
  extend Userfield
  def self.ueberweisung
    ..................
    pdf = Prawn::Document.new(:page_size => [width,height], :margin => 0 )
    pdf.image image_path, :at  => [w, height], :fit => [width,height]

    create_userfield

    pdf.stroke_line [w + 9.1.mm, h - 60.mm], [w + 14.2.mm, h - 65.mm]
    ..................

create_personenfeld is defined in userfield.rb
module Userfield
  def create_userfield
      pdf.font("Courier", :size => 12) do
        pdf.draw_text "Thanks for your help", :at => [w + 11.mm, h - 13.mm]
        ..........

As supposed i become a error because pdf is not defined in the def create_userfield!
 undefined local variable or method `pdf' for Formular:Class

Now my question is where should i put such a method? So that i dont have to pass each variable to it?
Thanks

A: You can also add an class variable called pdf:
attr_accessor :pdf

It will be shared between all methods of the class and you will be able to call you pdf as @pdf.
Example:
> module Animal
>   def say
      @word
>   end
> end
> class Doge
>   include Animal
>   attr_accessor :word
>   def initialize
>     @word = 'such cool feature'
>   end
> end

> dog = Doge.new
> dog.say
=> 'such cool feature'


text:
Q: IBM Analytics Workspace - Report/Query data download using REST API Is there a possibility to download data from IBM Analytics Workspace report/query using REST API ?
I would like to download sych data directly to the program variable using PowerShell/C#.
I have been looking for the answer online for a while but I cannot find satisfying answer leaving alone some code examples.
I would be grateful to get some code examples or links to such.
Best regards.

A: Pipe Invoke-RestMethod to ConvertTo-Json and then pipe to Out-File. That's a typical workflow for interacting with APIs, if you want to download data to disk.
Presumably there's some authentication needed and presumably you have an API key. So your script would look something like
$Headers = @{
    api_key = $MyApiKey
}
$Uri = 'https://cloud.ibm.com/some_service/some_resource_type'
$Result = Invoke-RestMethod $Uri -Headers $Headers
$Result | ConvertTo-Json | Out-File my_data.json

Without knowing what API you want to query, no-one can give you a more specific example.
A better way to submit a question would be "How can I download data with powershell from the Foo API - the docs for this endpoint are at ibm.com/api_docs/how_to_foo"


text:
Q: How to correctly call this method? For my assignment, I have been asked to complete the following:
1. Create a second method called eat in the Animal class. This method should take a Food object and an Integer as parameters.
2. Use an appropriate loop in the new eat method to feed the Food object to the Animal, the number of times specified in the Integer parameter.
I have created the while lop that I think is correct but I'm having problems calling it, this is what the for loop looks like:
public void eat(Food food, int count) {
    while (count > 0) {
        addFood(food);
        count--;
    }
}

This is declared in a class called Wolf which extends a method called Carnivore which is extended from an abstract Animal method. Given the specification, how would I print this while loop out in my main method and make it output something along the lines of Wolf has eaten " + //value of loop iteration + " times? Any help on how to correctly call this method is appreciated, thanks.

A: You need the following steps in your main():
(1) Create an object for Food called food
(2) Create an object for Wolf called wolf
(3) invoke wolf.eat(food, count); //pass the food object and count & print the result inside

A: public void main()
{
    Food food = new Food();
    Animal wolf = new Wolf();
    int count = 10;
    wolf.eat(food,count);
    System.out.println("Wolf has eaten" + count + "times");
}

//make reference of base class to access the eat method from base class..


text:
Q: Javascript Combination Inheritance - Unexpected Result So I've read up and down on the topic of combination inheritance in JavaScript. I get that the intent is to use prototype chaining for to inherit properties and methods-- and use constructor stealing to inherit instance properties.
I've provided an example that is boggling me and preventing me from fully understanding this concept.
In a nutshell, I create a SuperColors parent function that passes along its properties to SubColors by a call() execution in the SubColors constructor method. As I understand it, this should allow the instance (instance1) to have its own color properties as I've demonstrated.
Here's the quirky part. I delete the instance1's property of colors. This should mean that when I push new colors they should manipulate SuperColors color property to the full rainbow. Then when I create a new instance (instance2) of SubColors they should inherit the rainbow.
They don't though. If we look at the instance2 in console.log() the colors were instantiated with "Red,Orange,Yellow", even though we can clearly see that SuperColor's color property has the entire rainbow.
This doesn't make sense to me-- am I understanding prototype inheritance incorrectly or is this a weird quirk of the language that is unexpected?
function SuperColors() {
    this.colors = ["red", "orange", "yellow"];
}

SuperColors.prototype.sayColors = function () {
    alert("SuperColors " + this.colors);
};

function SubColors() {
    //inherit properties
    SuperColors.call(this);
}

// inherit methods
SubColors.prototype = new SuperColors();

SubColors.prototype.sayRainbow = function () {
    alert(this.colors + "a whole rainbow!");
};

// create an instance of SubColors
var instance1 = new SubColors();

// push colors to colors property on instance
instance1.colors.push("green", "blue", "purple");
alert(instance1.colors); // "red, orange, yellow, green, blue, purple"
instance1.sayColors(); // "SuperColors red,orange,yellow,green,blue,purple";

// delete instance of colors
delete(instance1.colors);
console.log(instance1);

// this should manipulate SuperColor's constructor of colors
instance1.colors.push("green", "blue", "purple");

// instantiate a new SubColor object that should inherit SuperColor's entire rainbow
var instance2 = new SubColors();

alert(instance1.colors);
alert(instance2.colors); // WHY ISN'T THIS THE ENTIRE RAINBOW? It should have been instantiated with SuperColor's modified colors.

console.log(instance2); // Shows that SuperColors.colors has the rainbow, but the instance has only 3 colors?

http://jsfiddle.net/ZKAZf/

A:
// this should manipulate SuperColor's constructor of colors
delete instance1.colors;
instance1.colors.push("green", "blue", "purple");

Not exactly. It doesn't manipulate the SuperColor constructor, but the SubColor.prototype (a SuperColor instance), from which the instance1 inherits its .colors property (now that it has no own one any more).

// instantiate a new SubColor object that should inherit SuperColor's entire rainbow
var instance2 = new SubColors();

No, nothing changed in the inheritance process. instance2 still inherits from SubColor.prototype just as instance1 does. And the SuperColor constructor is still called on the new instance…

alert(instance2.colors); // WHY ISN'T THIS THE ENTIRE RAINBOW?

…where it creates a brand new array which is assigned to a new, own .colors property of the new instance! That new array is the one you're accessing, and it was never modified by anything.
If you would
delete instance2.colors;

then you could see the SubColor.prototype.colors as well when doing
alert(instance2.colors);

A: Delete instance2.colors. Then you'll get the entire rainbow:
delete instance2.colors;
alert(instance2.colors);

See the demo: http://jsfiddle.net/ZKAZf/1/
You should read the following posts on inheritance in JavaScript:

*

*Aadit M Shah | Why Prototypal Inheritance Matters

*JavaScript inheritance and the constructor property

*Benefits of prototypal inheritance over classical?

*No ways to have class-based objects in javascript?

A: I think it's down to this:
function SubColors() {
    //inherit properties
    SuperColors.call(this);
}

What you are doing here is executing SuperColors but making this refer to the SubColors instance you're creating.  Inside SuperColors the SubColors instance then gets given its own colors property - this hides the colors attribute on prototype.
So, when something tries to look up colors on your SubColours instance it finds something on that instance and doesn't look up the prototype chain any further.  When you delete colors on instance1 subsequent lookups of instance1.colors now have to look up the prototype chain to find the SuperColors version, but when you create instance2, you are again creating colors on the SubColors instance which hides the version on SuperColors.
If you delete instance2.colors you will see that instance2.colors now resolves to the version of colors with teh whole rainbow.


text:
Q: Azure function how to use DefaultAzureCredential for development using Visual studio I creating an Azure Function app with ServiceBusTrigger. I am running Visual Studio under an account which is also used to logging into Visual Studio.
I have added this user account under Service Bus Access Control & assigned Azure Service Bus Data Receiver and Azure Service Bus Data Sender roles.
[FunctionName("Function1")]
        public void Run([ServiceBusTrigger("topic-one", "sub-one", Connection = "ServiceBusConnString")]string mySbMsg)
        {
            var credentail = new DefaultAzureCredential();
            _logger.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
        }

This is how local.settings.json file look:
{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "ServiceBusConnString__serviceUri": "https://sb-test-three.servicebus.windows.net/",
    "ServiceBusConnString__fullyQualifiedNamespace": "https://sb-test-three.servicebus.windows.net/",
    "ServiceBusConnString": "https://sb-test-three.servicebus.windows.net/ManagedIdentity",
    "ConnectionString": "https://sb-test-three.servicebus.windows.net/"
  }
}

I am getting below error when running the app locally using Visual Studio.

How can I run Azure function from Visual Studio using managed identity? I am not sure how to use DefaultAzureCredential class

A: Looks like you only need ServiceBusConnString__fullyQualifiedNamespace for the managed identity and you can remove the below configs
 "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "ServiceBusConnString__serviceUri": "https://sb-test-three.servicebus.windows.net/",
    "ConnectionString": "https://sb-test-three.servicebus.windows.net/"

You only need the below
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "ServiceBusConnString__fullyQualifiedNamespace": "sb-test-three.servicebus.windows.net",

And make sure you identity is having the below Roles

*

*Azure Service Bus Data Receiver

*Azure Service Bus Data Owner

Refer the official docs


text:
Q: SwiftyJSON not working / Swift 1.2 SwiftyJSON file When I added my SwiftyJSON file to my project, it had like 45 errors where about 44 of them were changing as to as!. Now I'm stuck at the last one on line 238 before I'm good to go. The error says:
Cannot assign a value of type 'AnyObject' to a value of type 'AnyObject!'
and the code looks like this:
    set {
            if self.type == .Array {
                var array_: AnyObject = self.object as![AnyObject]
                if array_.count > index {
                    array_[index] = newValue.object
                    self.object = array_
                }
            }
        }

The error is in the line with array_[index] = newValue.object.
Please help me figure this one out, thanks in advance.

A: There's a branch named 'xcode6.3' which seems to be compatible. If using Cocoapods, you can change the Podfile to point at the branch as follows:
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git', :branch => 'xcode6.3'


text:
Q: 14.04 USBs powered off at login screen I'm using Ubuntu 14.04 LTS with a Dell normal desktop PC. I've been suffering this issue from the very beggining.
Randomly, the USBs ports seem disconnected/powered off at the login screen, before any access to the system. Sometimes the machines boots properly and everything works as expected. But others, the mouse and keyboards turn off (lights off) and I have to perform a hard power off and power on again.
I tried to plug other USB devices and they showed no power input.
I guess it is some kernel configuration that presents some problem with the hardware, and tried to set the autosuspend and autosuspend_delay_ms to -1, but this didn't fix my problem.

A: Are you sure this is not because of inactivity. What I would try to do would be to install the powertop package in software-center or by sudo apt-get install powertop then run sudo powertop and for all usb devices in tunables set it so it says bad while this may use a tiny bit more power it will stop the power managment from switching off usb devices. This questoin could provide more insight on this but this sounds like a usb power managemnt problem. Also since this happens at the login screen this could be it is at inactivity which is why you see no reason for it and appears random to you but it is not. How can I disable usb-autosuspend for a specific device? is also likely to help you.


text:
Q: Allow To Only Input A Number - C# I'm fairly new to C#.
I'm trying to make a basic program that converts Degrees in Celsius to Fahrenheit.
But here's the catch, I want to make sure that the user inputs only a valid number and no characters or symbols. And if the user inputs, for example 39a,23, the Console asks him to enter the number again.
 Console.WriteLine("Please enter the temperature in Celsius: ");
 double x = Convert.ToDouble(Console.ReadLine());

Also, I've been making other programs, and I've been wondering - do I always have to use "Convert.ToInt/Convert.ToDouble"? or is there a faster way?

A: It would be better you use the method Double.TryParse. This way you will check if the string that user provided can be parsed to a double.
// This is the variable, in which will be stored the temperature.
double temperature;

// Ask the  user input the temperature.
Console.WriteLine("Please enter the temperature in Celsius: ");

// If the given temperature hasn't the right format,
// ask the user to input it again.
while(!Double.TryParse(Console.ReadLine(), out temperature))
{
    Console.WriteLine("The temperature has not the right format, please enter again the temperature: ");
}

The method Double.TryParse(inputString, out temperature) will return true , if the parsing is successful and false if it isn't.
For more information about the method Double.TryParse please have a look here.


text:
Q: Regex works on .NET test site but not in C# environment Referring to this stackoverflow question:
- Regex Pattern help: finding HTML pattern when nested ASP.NET Eval?
I received an answer to the problem here:
- regexstorm link
The .NET answer that works on the regex .NET testing site does NOT work in my C# Visual Studio environment. Here is the Unit Test for it:
[Test]
public void GetAllHtmlSubsectionsWorksAsExpected()
{
    var regPattern = new Regex(@"(?'o'<)(.*)(?'-o'>)+");

    var html =
        "<%@ Page Language=\"C#\" %>" +
        "" +
        "lorem ipsum" +
        "<div class=\"d1\" id=\"div2\" attrid=\"<%# Eval(\"CategoryID\") %>\">" +
        "testing 123" +
        "
" +
        "asdf" +
        "	";

    List<string> results = new List<string>();

    MatchCollection matches = regPattern.Matches(html);
    for (int mnum = 0; mnum < matches.Count; mnum++)
    {
        Match match = matches[mnum];
        results.Add("Match #" + (mnum + 1) + " - Value: " + match.Value);
    }

    Assert.AreEqual(5, results.Count()); //Fails: results.Count() == 1
}

Why does this work on the regexstorm website but not in my unit test?

A: NOTE that parsing HTML with regex is not a best practice, you should use a dedicated parser.
Now, as for the question itself, the pattern you use will work only with lines having 1 single substring starting with < and ending with corresponding >. However, your input string has no newline characters! It looks like:
<%@ Page Language="C#" %>lorem ipsum<div class="d1" id="div2" attrid="<%# Eval("CategoryID") %>">testing 123
asdf

The .* subpattern is called a greedy dot matching pattern, and it matches as many characters other than a newline as possible (because it grabs the whole line and then backtracks to see if the next subpattern (here, >) is found, thus you get the last possible >).
To fix that, you need a proper balanced construct matching pattern:
<((?>[^<>]+|<(?<c>)|>(?<-c>))*(?(c)(?!)))>

See regex demo
C#:
var r = new Regex(@"
    <                      # First '<'
      (                    # Capturing group 1
        (?>                # Atomic group start
        [^<>]              # Match all characters other than `<` or `>`
        |
         < (?<c>)          # Match '<', and add a capture into group 'c'
        |
         > (?<-c>)         # Match '>', and delete 1 value from capture stack
        )*
        (?(c)(?!))         # Fails if 'c' stack isn't empty!
      )
    >                      # Last closing `>`
"; RegexOptions.IgnoreWhitespace);

DISCLAIMER: Even this regex will fail if you have unpaired < or > in your element nodes, that is why do not use regex to parse HTML.

A: There are two different things in regex: Matching and capturing.
What you want here is the capturing group 1.
So you need to use this:
results.Add("Match #" + (mnum + 1) + " - Value: " + match.Groups[1].Value);

Also, as the other answer pointed, you are missing new lines, and regex captures it all in first match.


text:
Q: Combining subgroups within categorical variable (ggplo2) I have a data structured as follows:
The first variable refers to the sentiment expressed in a given Reddit post. The second column is a categorical variable with three possible values and it tells us whether the post was directed at different Gov't agencies (e.g. MoL and MoE) or private employers.
sentiment_human_coded   directed_to_whom
negative                MoL
negative                MoL
positive                MoE
negative                Private employers

I am interested in visualizing changes throughout time in terms of the negative posts directed at each entity (i.e. MoL, MoE, etc) as follows:
both_group |>
  mutate(month = lubridate::ymd(date) |>
           lubridate::month()) |>
  count(month, sentiment_human_coded, directed_to_whom)|>
  group_by(month, directed_to_whom) |>
  mutate(freq = n/sum(n)) |>
    filter(sentiment_human_coded != "neutral" & sentiment_human_coded != "positive") |>
      filter(directed_to_whom != "Non-critical") |>
  unite(grp, sentiment_human_coded, directed_to_whom, sep = " & " ) |>
  ggplot(aes(x = as.Date(month_year), freq, color = grp))+
  geom_point()+
  scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
  scale_x_date(date_breaks = "months" , date_labels = "%b-%y") +
  geom_line() +
  theme_classic()

Output:

However, for visualization purposes, I am only interested in showing total posts directed at government agencies (i.e. MoL and MoE), versus total posts at private employers. Is it possible to combine two subgroups (MoL and MoE) in the "directed_to_whom" variable under one category called "Govt" while keeping the third group as "private employers" without changing the entire dataset, but rather doing this in the same code as the graph above?
For instance, if 10% of negative posts in a given month were directed at MoL, 30% towards MoE, and 60% on private employers, I would like to visualize it as 40% towards government and 60% towards private employers.
Solved with the solution by Stefan as follows:
both_group |>
  mutate(month = lubridate::ymd(date) |>
           lubridate::month()) |>
  mutate(directed_to_whom = recode(directed_to_whom, MoE = "Govt", MoL = "Govt")) |>
  count(month, sentiment_human_coded, directed_to_whom)|>
  group_by(month, directed_to_whom) |>
  mutate(freq = n/sum(n)) |>
    filter(sentiment_human_coded != "neutral" & sentiment_human_coded != "positive") |>
      filter(directed_to_whom != "Non-critical") |>
  unite(grp, sentiment_human_coded, directed_to_whom, sep = " & " ) |>
  ggplot(aes(x = as.Date(month_year), freq, color = grp))+
  geom_point()+
  scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
  scale_x_date(date_breaks = "months" , date_labels = "%b-%y") +
  geom_line() +
  theme_classic()


text:
Q: Why is Hibernate/JPA reporting null pointer exception in query? I'm using Hibernate's JPA and Java 8 to execute what should be a simple query and store the results in a list of class instances. However, when I execute the code, Java gives me a null pointer exception on the .createQuery line.
I've checked the variables being passed to the method, and they both contain valid, non-null data. The rows retrieved when I run the query manually on the database show no null entries in any of the received columns. All columns in the query are members of the GradeSummary class and the Board class.
I'm at a loss. Why is this query not working?
public List<GradeSummary> getGradeSummaryList(VdtsSysDB vdtsSysDB, BoardLoad boardLoad) {
    List<GradeSummary> gradeSummaries = vdtsSysDB
            .getEntityManager()
            .createQuery(
            "select new ca.vdts.grading.model.GradeSummary(grade, " +
            "count(*), " +
            "sum(footBoardMeasure)) " +
            "from Board " +
            "where boardLoad = :load " +
            "group by grade", GradeSummary.class)
            .setParameter("load", boardLoad)
            .getResultList();
    gradeSummaries.sort(Comparator.comparing(gradeSummary -> gradeSummary.getGrade().getName()));
    return gradeSummaries;
}

The exception is:
18-08-18 13:28:50.701 ERROR java.lang.Throwable - Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
18-08-18 13:28:50.702 ERROR java.lang.Throwable -   at org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.determineJdbcTypeCode(StandardAnsiSqlAggregationFunctions.java:200)
18-08-18 13:28:50.702 ERROR java.lang.Throwable -   at org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.getReturnType(StandardAnsiSqlAggregationFunctions.java:158)
18-08-18 13:28:50.702 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.findFunctionReturnType(SessionFactoryHelper.java:414)
18-08-18 13:28:50.703 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.ast.tree.AggregateNode.getDataType(AggregateNode.java:68)
18-08-18 13:28:50.703 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.ast.tree.ConstructorNode.resolveConstructorArgumentTypes(ConstructorNode.java:158)
18-08-18 13:28:50.703 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.ast.tree.ConstructorNode.prepare(ConstructorNode.java:133)
18-08-18 13:28:50.703 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:1190)
18-08-18 13:28:50.704 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2366)
18-08-18 13:28:50.704 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:2232)
18-08-18 13:28:50.704 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1503)
18-08-18 13:28:50.704 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:585)
18-08-18 13:28:50.704 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:313)
18-08-18 13:28:50.705 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:261)
18-08-18 13:28:50.705 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:266)
18-08-18 13:28:50.705 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:189)
18-08-18 13:28:50.705 ERROR java.lang.Throwable -   at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:141)
18-08-18 13:28:50.706 ERROR java.lang.Throwable -   at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
18-08-18 13:28:50.706 ERROR java.lang.Throwable -   at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
18-08-18 13:28:50.706 ERROR java.lang.Throwable -   at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153)
18-08-18 13:28:50.707 ERROR java.lang.Throwable -   at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:553)
18-08-18 13:28:50.707 ERROR java.lang.Throwable -   at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:662)
18-08-18 13:28:50.707 ERROR java.lang.Throwable -   at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:686)
18-08-18 13:28:50.707 ERROR java.lang.Throwable -   at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23)
18-08-18 13:28:50.707 ERROR java.lang.Throwable -   at ca.vdts.grading.model.Progress.getGradeSummaryList(Progress.java:18)
18-08-18 13:28:50.708 ERROR java.lang.Throwable -   at ca.vdts.grading.controllers.ProgressController.updateDisplay(ProgressController.java:155)
18-08-18 13:28:50.708 ERROR java.lang.Throwable -   at ca.vdts.grading.controllers.ProgressController.monitorSelected(ProgressController.java:125)
18-08-18 13:28:50.708 ERROR java.lang.Throwable -   at ca.vdts.grading.controllers.ProgressController.lambda$initialize$3(ProgressController.java:88)
18-08-18 13:28:50.708 ERROR java.lang.Throwable -   at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361)
18-08-18 13:28:50.708 ERROR java.lang.Throwable -   at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
18-08-18 13:28:50.709 ERROR java.lang.Throwable -   at javafx.beans.property.ReadOnlyObjectPropertyBase.fireValueChangedEvent(ReadOnlyObjectPropertyBase.java:74)
18-08-18 13:28:50.709 ERROR java.lang.Throwable -   at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:102)
18-08-18 13:28:50.709 ERROR java.lang.Throwable -   at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
18-08-18 13:28:50.709 ERROR java.lang.Throwable -   at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
18-08-18 13:28:50.709 ERROR java.lang.Throwable -   at javafx.scene.control.SelectionModel.setSelectedItem(SelectionModel.java:102)
18-08-18 13:28:50.710 ERROR java.lang.Throwable -   at javafx.scene.control.ComboBox$ComboBoxSelectionModel.lambda$new$154(ComboBox.java:494)
18-08-18 13:28:50.710 ERROR java.lang.Throwable -   at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
18-08-18 13:28:50.710 ERROR java.lang.Throwable -   at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
18-08-18 13:28:50.711 ERROR java.lang.Throwable -   at javafx.beans.property.ReadOnlyIntegerPropertyBase.fireValueChangedEvent(ReadOnlyIntegerPropertyBase.java:72)
18-08-18 13:28:50.711 ERROR java.lang.Throwable -   at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:102)
18-08-18 13:28:50.711 ERROR java.lang.Throwable -   at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:113)
18-08-18 13:28:50.711 ERROR java.lang.Throwable -   at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:147)
18-08-18 13:28:50.711 ERROR java.lang.Throwable -   at javafx.scene.control.SelectionModel.setSelectedIndex(SelectionModel.java:68)
18-08-18 13:28:50.712 ERROR java.lang.Throwable -   at javafx.scene.control.SingleSelectionModel.updateSelectedIndex(SingleSelectionModel.java:215)
18-08-18 13:28:50.712 ERROR java.lang.Throwable -   at javafx.scene.control.SingleSelectionModel.select(SingleSelectionModel.java:149)
18-08-18 13:28:50.712 ERROR java.lang.Throwable -   at com.sun.javafx.scene.control.skin.ComboBoxListViewSkin.lambda$createListView$323(ComboBoxListViewSkin.java:484)
18-08-18 13:28:50.712 ERROR java.lang.Throwable -   at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:349)
18-08-18 13:28:50.713 ERROR java.lang.Throwable -   at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
18-08-18 13:28:50.713 ERROR java.lang.Throwable -   at javafx.beans.property.ReadOnlyIntegerPropertyBase.fireValueChangedEvent(ReadOnlyIntegerPropertyBase.java:72)
18-08-18 13:28:50.713 ERROR java.lang.Throwable -   at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:102)
18-08-18 13:28:50.713 ERROR java.lang.Throwable -   at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:113)
18-08-18 13:28:50.714 ERROR java.lang.Throwable -   at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:147)
18-08-18 13:28:50.714 ERROR java.lang.Throwable -   at javafx.scene.control.SelectionModel.setSelectedIndex(SelectionModel.java:68)
18-08-18 13:28:50.714 ERROR java.lang.Throwable -   at javafx.scene.control.MultipleSelectionModelBase.select(MultipleSelectionModelBase.java:404)
18-08-18 13:28:50.714 ERROR java.lang.Throwable -   at javafx.scene.control.MultipleSelectionModelBase.clearAndSelect(MultipleSelectionModelBase.java:356)
18-08-18 13:28:50.714 ERROR java.lang.Throwable -   at javafx.scene.control.ListView$ListViewBitSetSelectionModel.clearAndSelect(ListView.java:1403)
18-08-18 13:28:50.715 ERROR java.lang.Throwable -   at com.sun.javafx.scene.control.behavior.CellBehaviorBase.simpleSelect(CellBehaviorBase.java:256)
18-08-18 13:28:50.715 ERROR java.lang.Throwable -   at com.sun.javafx.scene.control.behavior.CellBehaviorBase.doSelect(CellBehaviorBase.java:220)
18-08-18 13:28:50.716 ERROR java.lang.Throwable -   at com.sun.javafx.scene.control.behavior.CellBehaviorBase.mousePressed(CellBehaviorBase.java:150)
18-08-18 13:28:50.716 ERROR java.lang.Throwable -   at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:95)
18-08-18 13:28:50.716 ERROR java.lang.Throwable -   at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
18-08-18 13:28:50.717 ERROR java.lang.Throwable -   at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
18-08-18 13:28:50.717 ERROR java.lang.Throwable -   at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
18-08-18 13:28:50.717 ERROR java.lang.Throwable -   at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
18-08-18 13:28:50.717 ERROR java.lang.Throwable -   at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
18-08-18 13:28:50.718 ERROR java.lang.Throwable -   at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
18-08-18 13:28:50.718 ERROR java.lang.Throwable -   at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
18-08-18 13:28:50.718 ERROR java.lang.Throwable -   at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
18-08-18 13:28:50.719 ERROR java.lang.Throwable -   at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
18-08-18 13:28:50.719 ERROR java.lang.Throwable -   at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
18-08-18 13:28:50.719 ERROR java.lang.Throwable -   at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
18-08-18 13:28:50.720 ERROR java.lang.Throwable -   at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
18-08-18 13:28:50.720 ERROR java.lang.Throwable -   at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
18-08-18 13:28:50.720 ERROR java.lang.Throwable -   at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
18-08-18 13:28:50.721 ERROR java.lang.Throwable -   at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
18-08-18 13:28:50.721 ERROR java.lang.Throwable -   at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
18-08-18 13:28:50.721 ERROR java.lang.Throwable -   at javafx.event.Event.fireEvent(Event.java:198)
18-08-18 13:28:50.721 ERROR java.lang.Throwable -   at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
18-08-18 13:28:50.722 ERROR java.lang.Throwable -   at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
18-08-18 13:28:50.722 ERROR java.lang.Throwable -   at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
18-08-18 13:28:50.722 ERROR java.lang.Throwable -   at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
18-08-18 13:28:50.722 ERROR java.lang.Throwable -   at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
18-08-18 13:28:50.723 ERROR java.lang.Throwable -   at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
18-08-18 13:28:50.723 ERROR java.lang.Throwable -   at java.security.AccessController.doPrivileged(Native Method)
18-08-18 13:28:50.723 ERROR java.lang.Throwable -   at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:417)
18-08-18 13:28:50.723 ERROR java.lang.Throwable -   at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
18-08-18 13:28:50.723 ERROR java.lang.Throwable -   at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
18-08-18 13:28:50.724 ERROR java.lang.Throwable -   at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
18-08-18 13:28:50.724 ERROR java.lang.Throwable -   at com.sun.glass.ui.View.notifyMouse(View.java:937)
18-08-18 13:28:50.724 ERROR java.lang.Throwable -   at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
18-08-18 13:28:50.724 ERROR java.lang.Throwable -   at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
18-08-18 13:28:50.725 ERROR java.lang.Throwable -   at java.lang.Thread.run(Thread.java:748)

The gradeSummary class:
public class GradeSummary {
    private BoardGrade grade;
    private Integer pieceCount;
    private Integer footage;

    public GradeSummary(BoardGrade grade, Long pieceCount, Long footage) {
        this.grade = grade;
        this.pieceCount = pieceCount.intValue();
        this.footage = footage.intValue();
    }

    public BoardGrade getGrade() {
        return grade;
    }

    public Integer getPieceCount() {
        return pieceCount;
    }

    public Integer getFootage() {
        return footage;
    }
}

And the field names for Board:
private LocalDateTime timeStamp;
private User grader;
private Species species;
private Integer length;
private Integer width;
private Integer surfaceMeasure;
private Integer thickness;
private Integer footBoardMeasure;
private BoardGrade grade;
private BoardModifier modifier;
private BigDecimal price;
private BigDecimal rate;
private Pack pack;
private Batch batch;
private PackDescriptor packDescriptor;
private BoardLoad boardLoad;

A: GradeSummary needs a no-arg constructor.  By providing your own, you removed the default one.
The reason for this is that JPA needs to create an instance of your object, and then hydrate it.  It must start this by calling newInstance() on your class, and has not a clue about parameters.


text:
Q: Pull / Push to Gitlab Error Deploy in Progress I'm trying to do Pull / Push to GitLab and get this error in my local git at push / pull:
10:08:14.426: [themes] git -c core.quotepath=false pull --progress --no-stat -v --progress origin master
remote: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: connection refused
fatal: unable to access 'https://user@gitlab.com/AAA/BBBB.git/': The requested URL returned error: 502
10:08:53.791: [themes] git -c core.quotepath=false fetch origin --progress --prune
remote: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: resource temporarily unavailable
fatal: unable to access 'https://user@gitlab.com/AAA/BBBB.git/': The requested URL returned error: 502

On gitlab I get this screen on my browser:

This work for me always and today I get the last error.

A: GitLab is currently down for maintenance.
See: https://twitter.com/gitlabstatus/status/800714390441967616


text:
Q: Symfony Authentification Error at login_check Intro
I've been following these two documentation tutorials for Symfony2 Security:
http://symfony.com/doc/current/book/security.html
http://symfony.com/doc/current/book/security.html#loading-users-from-the-database
Problem
Now when I try to login at localhost/login, it either brings me back to /login (which is fine) with "bad credentials" or it brings me to /login_check and an error occurs (I haven't found a pattern of when it does what).
Error
SCREAM: Error suppression ignored for

Fatal error: Wrong parameters for Exception([string $exception [, long
  $code [, Exception $previous = NULL]]]) in
  C:\wamp\www\minimumCrayon\vendor\symfony\symfony\src\Symfony\Component\Security\Core\Exception\AuthenticationException.php
  on line 25

I've tried looking around for anyone with a similar error, but I'm pretty darn lost.
Edit: Here is my security.yml file
jms_security_extra:
    secure_all_services: false
    expressions: true

security:
    encoders:
        WikiRoster\MainBundle\Entity\Account:
            algorithm:        sha1
            encode_as_base64: false
            iterations:       1

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        administartors:
            entity: { class: AcmeMainBundle:Account}

    firewalls:
        secured_area:
            pattern:    ^/
            anonymous: ~
            form_login:
            login_path: /login
            check_path: /login_check
        admin_area:
            pattern:    ^/admin
            http_basic: ~

    access_control:
        - { path: ^/admin, roles: ROLE_ADMIN }