text:
Q: How to prevent TypeScript code blocks from being compiled by the Angular AOT Webpack plugin I want to exclude some code from being compiled by Angular's AOT compiler. For example, the webpack-strip-block loader can be used to remove code between comments in production.
export class SomeComponent implements OnInit {
  ngOnInit() {
    /* develblock:start */
    alert("Show in development only"); // Oops. This still appears in production.
    /* develblock:end */
  }
}

More specifically, I'm trying to exclude an entire NgModule (e.g. TestModule) from being compiled. One way to do this would be to remove the line(s) in the app-routing.module that create the route. For example:
// app-routing.module
const routes: Routes = [
 {
    /* develblock:start */
    path: 'test', loadChildren: './test/test.module#TestModule'
    /* develblock:end */
 }
]

// webpack.config.js
{
    test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
    use: [
      { loader: '@ngtools/webpack' },
      { loader: 'webpack-strip-block' }
    ]
}

Note: This isn't a specific question about the webpack-strip-block plugin. I'm just using the plugin as an example because it makes my intent clear. The plugin's author has already stated that he doesn't expect the plugin to work with the AngularCompilerPlugin. The plugin does work with my CSS files, but that's beside the point.
Here are some other things that I've tried:
1. Using Webpack exclude (or include). Nope. Excluding the folder throws compiler errors because the application code still depends on TestModule.

{
  test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
  loader: '@ngtools/webpack',
  exclude: path.resolve(__dirname, 'src/app/test')
},

2. Using NODE_ENV to conditionally load the route. Nope. Compiler errors galore because an if statement is (obviously) not allowed inside an array of objects.

const routes: Routes = [{
  if (process.env.NODE_ENV !== 'production') {
    path: 'test', loadChildren: './test/test.module#TestModule'
  }
}];

3. Using Webpack Externals. I've tried it, but it doesn't seem appropriate for this use case.
Here's my dependency list:
Angular 6.1.7
TypeScript 2.9.2
Webpack 4.19.1

A: You can use DefinePlugin to create a global replacement for var NODE_ENV (for example):
// inside webpack.config
plugins: [
    new webpack.DefinePlugin({
        NODE_ENV: JSON.stringify(process.env.NODE_ENV)
    })
]

Then you can use this var like this:
declare const NODE_ENV: string;

if (NODE_ENV !== 'production') {
    routes.push({ path: 'test', loadChildren: './test/test.module#TestModule' });
}

Webpack will replace NODE_ENV with the actual value. In production it will be 'production' so the code inside the if ('production' !== 'production') will be unreachable and AOT will remove it.

A: In Webpack 4 you can conditionally add a route in app-routing.module using NODE_ENV:
if (process.env.NODE_ENV === 'development') {
  routes.push({ path: 'test', loadChildren: './test/test.module#TestModule' });
}

This prevents TestModule from being compiled in production. Thanks to Pavel Agarkov for the suggestion to push the route object onto the array.


text: Q: Request for Guidance on Implementing Success/Failure Callback Method for SharePoint List Item Creation/Update using CSOM in C# I am currently using CSOM in C# (dotnet core) to create or update SharePoint list items, and I am wondering if there is a way to receive a success or failure callback method when performing these actions. I have not been able to find any information on this and would greatly appreciate any guidance or solutions

redpajama_set_name: RedPajamaStackExchange


text:
Q: Gnuplot contour plot without dots I am trying to plot a contour plot with labels with the following code.
reset
set terminal qt
set pm3d map
set contour base
set cntrparam levels incremental 0, 10, 100
set cntrlabel onecolor
set palette rgbformulae 33,13,10

# No key appears
# splot 'temperature.dat' with pm3d title "Heated 2D plate"

# Key appears
splot 'temperature.dat' with pm3d, \
   'temperature.dat' with labels title "Heated 2D plate"

The outputs are shown below:
No labels (first splot command) and without key

With labels and key (2nd splot command), but with dots.

My questions:

*

*Why is the key not appearing in the first splot command?

*How to remove the dots when plotting with labels (2nd splot command)?

Will attach the data file if required.

A: *

*key

The key for the "with pm3d" plot is probably covered by the pm3d surface. You can move it to the front and make it distinct from the surface coloring using set key box opaque.  This will label the contours in the key as well as on the plot. To remove the redundant contour labels in the key
  set pm3d explicit
  set key box opaque
  splot 'temperature.dat' with pm3d notitle,\
        'temperature.dat' with labels title "Heated 2D plate"

*dots

I am not sure why the dots appear. I do not see them when I try to reproduce the plot. Try set pm3d noborder


text:
Q: Include sql file into a SQL Database project programmatically I am using t4 templates to generate code.
One of the parts I am generating is sql code and I would like to add it to a SQL DB project in my solution.
What I tried so far is:
var p = new Project($@"..\..\..\{projectName}\{projectName}.sqlproj");
p.AddItem("Compile", $@"..\..\..\{projectName}\{folderName}\{fileName}");
        p.Save();

However it fails on the new Project part already. Error:

Microsoft.Build.Exceptions.InvalidProjectFileException: 'The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the  declaration is correct, and that the file exists on disk.

However the .sqlproj is there.
What I am trying to achieve is not only adding the file itself to the project, but make it included as well in the build.
Is there another way or am I doing something wrong? I am using .net Framework.

A: If you want just add a file, try the overloaded constructor with IgnoreMissingImport flag, it worked for me:
Project p = new Project($@"..\..\..\{projectName}\{projectName}.sqlproj", null, null, new ProjectCollection(), ProjectLoadSettings.IgnoreMissingImports);

You can find more information about Project Constructors here


text:
Q: Openpyxl removes sorts that are already part of the excel file Right now, I am sorting data with pandas and then adding those values into the excel file and it works great. The problem is that the excel file already has the sort coded in and when I write data to the xlsx it will remove the sort. My colleagues want to be able to use the built-in excel sort and I can't figure out why openpyxl will remove that sort when I write data to the file.
Is there a parameter I'm missing or is this just how openpyxl operates? I can include code if it is needed.
Using the latest version of python and openpyxl.

A: This happens to me on mac. Here is the code for writing from a dataframe to a sheet. Afterwards, the sheet will delete the pre-formatted sort in the .xlsx
def add_sheet(self, df, sheet, min_col, max_col, sheet_dim):
    index_positions = list(df.index.values)
    r = 1
    for x in index_positions:
        _row = df.loc[x].values
        c = min_col
        r += 1
        for val in _row:
            if c <= max_col:
                sheet.cell(row=r, column=c).value = val
                c += 1

Maybe it's how I save the excel file? Some parameter I'm missing?
test.save("test.xlsx")

Nevermind, here is code that will strip all sorts from my excel file on Mac.
test = test.load_workbook("test.xlsx")
test.save("test_save.xlsx")

The file goes from 376KBs to 259KBs. This doesn't make any sense.


text:
Q: ASP.NET MVC Web application vs ASP.NET Web Application Other than the fact that ASP.NET MVC Web Application has more clarity in its implementation of the MVC pattern and that it strictly follows the MVC pattern, how is it different from ASP.NET Web Application?
If you make your ASP.NET Web Application have a Business Logic Layer, Data Access Layer and strictly make all data queries using them, then does'nt it completely follow the MVC pattern?
My logic here is: the BLL & DLL together is the Model, the ASPX page is the View and the code-behind (ASPX.CS) page is the Controller.
Thanks in advance to anyone who can confirm the above and/or shed more light on the subject.

A: This recent question may address your concerns: How does the MVC pattern differ, if at all, from the DAL / BLL design pattern?

A: It takes a bit more experience, discipline and work to design an ASP.NET MVP Web Application so that your application supports test automation. When you can slap an advanced GridView onto a page along with a SqlDataSource and bind it directly to a stored procedure you throw your test automation out the window.
A lot of MVP applications are written using 3rd party toolkits that encapsulate a lot of the  codebehind logic. That tends to muck up your clean separation of responsibilities in a MVP design.
On the plus side I can write an ASP.NET Web Application with a rich UI using a 3rd party toolkit in a 10th of the time I can with MVC in it's current state. For a simple admin tool that's exactly what I would do today. For a large scale n-tier application I would lean towards MVC.


text:
Q: $(A\text{ and } B)\Rightarrow (A\text{ or } C)$ implies $A\Rightarrow B$ I used the logic in the title in this answer. Is this implication true and is there a simple explanation of why it is true?

A: No, this is not a valid implication.
$(A\land B)\Rightarrow (A\lor C)$ is a tautology, and $A\Rightarrow B$ is not. So the former cannot imply the latter.
For example, if $A$ is true but $B$ and $C$ are false, then $(A\land B)\Rightarrow (A\lor C)$ is true, but $A\Rightarrow B$ is false.


text:
Q: Joomla, component, run script on deletion of record from backend i have developed a component for Joomla 3, and i know that i can perform operations of the table form on save with the prepareTable function in the /administrator/components/com_edm/models/edm.php class
however now i need to manipulate the DB for when users delete a record of my component in the backend.
essentially i am asking if there is a function like prepareTable but for deletion
Thanks in advance

A: OK...after much research i have found a way to achieve what i want.
alter the
administrator/components/com_edm/views/newsletterss/view.html.php
file to register your new button function like so
JToolBarHelper::trash('newsletterss.Mytrash', 'JTOOLBAR_TRASH');
and then extend the controller for the component list
administrator/components/com_edm/controllers/newsletterss.php
where you can set your own function like so
public function Mytrash(){
    // Check for request forgeries
    JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));

    // Get items to remove from the request.
    $cid = JRequest::getVar('cid', array(), '', 'array');

    if (!is_array($cid) || count($cid) < 1)
    {
        JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
    }
    else
    {
        // Get the model.
        $model = $this->getModel();

        // Make sure the item ids are integers
        jimport('joomla.utilities.arrayhelper');
        JArrayHelper::toInteger($cid);

        // Remove the items.
        if ($model->delete($cid))
        {
            $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
        }
        else
        {
            $this->setMessage($model->getError());
        }
    }

    $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
}


text:
Q: Why I'm getting this error? The bot is supposed to assign the role with ID=899279907216031744 , I'm getting error when I'm giving this type of Inputs I'm getting this error below when My Message is something like 003-UG-CSE-2023 or 123-PG-CSE-2024
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\ACER\AppData\Roaming\Python\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\ACER\Desktop\pika bot\pika.py", line 52, in on_message
if cont:
UnboundLocalError: local variable 'cont' referenced before assignment
import os
import discord
import discord.ext.commands as commands
import dotenv
import random

dotenv.load_dotenv()

bot = commands.Bot(command_prefix='$')

@bot.event
async def on_ready():
    print('I am online')
    print(bot.user.name)
    print(bot.user.id)
    print('-----')

@bot.event
async def on_message(message):
    member = message.author
    role = discord.utils.get(member.guild.roles, id="899279907216031744")
    splits = message.content.split("-")

    # it's not in the wanted format
    if len(splits) != 4:
        # return or something else
        cont = False

    # check if first is a number within range <1, 999>
    try:
        if int(splits[0]) <= 0 and int(splits[0]) >= 1000:
            cont = True
    except ValueError:
        cont = False

    # check if second is one of the options
    if splits[1] not in ["UG", "PG", "D"]:
        cont = False

    # check if third is one of the options
    if splits[2] not in ["CSAI","CSE","ECAI","ECE","IT","MAE","EEE","CE","PD","AE","CH","CE","EE","ME","ED","MV","ER","QT","RAS","AI","CS","CP","BE","CHE","CHEM","CG","CC","VLSI","EV","DES"]:
        cont = False

    # check if fourth is a number from range <2022 ...>
    try:
        if int(splits[3]) <= 2022:
            cont = False
    except ValueError:
        cont = False

    # it fits all the criteria
    if cont:
        await discord.Member.add_roles(member, role)

bot.run(os.getenv('TOKEN'))

Please lemme know if you found the mistake so I can fix the issue

A: Try/except blocks have their own scope for variables. To use variables set inside a try/except block, you need to add an 'else' or 'finally' after except (where else runs only if there is no error and finally runs either way)

A: The Error definitely shows, that the problem is laying on "if cont:", I would try to add cont to a global.
@bot.event
async def on_message(message):
    global cont #Added cont to global
    member = message.author
    role = discord.utils.get(member.guild.roles, id="899279907216031744")
    splits = message.content.split("-")


text:
Q: How to add email validation at attribute inspector of arcgis web appbuilder I want to add validation in smart editor email attribute. To make it work as the required field validation, paint the field red and show the tooltip below the field.

I want it like this but with email validation:


text:
Q: To which (logical) language belongs $\{p\} \Rightarrow q$? According to my book, the essential difference between a logical implication $\{p\} \Rightarrow q$ and the statement $p \to q$ is  that $p \to q$ is part of the propositional language, and $\{p\} \Rightarrow q$ is not. My question is, to which language does the logical implication $\{p\} \Rightarrow q$ belong?

A: The authors clarify the matter in the next sentence:

Schrijven we $\varphi\Rightarrow\psi$, dan stelt dit dat $\psi$ inderdaad volgt uit $\varphi$, terwijl als we $\varphi\to\psi$ opschrijven, deze formule best onwaar kan zijn.

In other words, $\varphi\Rightarrow\psi$ is the assertion that $\psi$ really is a logical consequence of $\varphi$, while $\varphi\to\psi$ is a proposition that may be true or false.
The connective $\to$ is part of the language in which we build propositions; $\Rightarrow$ is part of the language in which we talk about these propositions. Thus, if $A$ is a set of propositions, $A\Rightarrow\varphi$ is the assertion that if every proposition in the set $A$ has the truth value TRUE, then so must $\varphi$: $\varphi$ is a logical consequence of the propositions in $A$. In particular, $\{\varphi\}\Rightarrow\psi$ is synonymous with $\varphi\Rightarrow\psi$: it's the assertion that if $\varphi$ has the truth value TRUE, then so must $\psi$.
In contrast, $\varphi\to\psi$ is just a proposition that may be true or false; the formula does not in itself make any assertion about the truth or falsity of any proposition.

A: The way that this book appears to be using the notation, if $A$ is a set of formulas and $\phi$ is a formula, the relation $A \Rightarrow \phi$ means that in the appropriate truth table, every row that makes all formulas in $A$ true also makes $\phi$ true.
So, for example, $p \land q \Rightarrow q$ holds because every row that makes $p \land q$ true also makes $q$ true. This is different than $p \land q \to q$, which is not true or false on its own, but only true or false for each row in the truth table. The logical implication arrow $\Rightarrow$ has the effect of quantifying over all the rows. So $p \land q \to q$ has "4 separate truth values", one for each row of a 2 variable truth table, while $p \land q \Rightarrow q$ is simply true.
Similarly, $\{p, p \to q\} \Rightarrow q$ holds, but this is not even of the right syntactic form to be true or false in each row.
The language of formulas is called the object language; the language of $\Rightarrow$ is called the metalanguage, which is another language used to study the object language. The need to keep these distinct is not obvious at first, but the distinction turns out to be vital for many aspects of logic.


text:
Q: Cannot create a model segue by dragging in Xcode I am new for Xcode , I am trying to build my first easy project by following this video:
https://www.youtube.com/watch?v=v9bsZvHuQYI
However , between 2:23 to 2:25 , the way he try to create a segue from home to another view controller is not working , I try to drag by holding ctrl and left mouse to another view controller there is nothing response (usually it will appear a blue window to tell you can link with it) , is that cause by the new version of Xcode?
I'm appreciate for any advice, thanks!

A: It may have to do with the version of your editor, but you can always create a segue that's not associated with a button click or a table row click by control dragging from the View Controller icon on the controller. I had trouble making a screenshot so please excuse my drawn in mouse.


text:
Q: Adding numbers inside array of arrays Here I'm trying to add number of array separately, but I'm not able to achieve the expected output. If I want to add total I would do flatMap and add them togeather. But I want add them separately for each array.
Below is the snippet for what I have tried

const data = [{
    "itemDetails": [{
      "sizeOfBag": 1,
      "numberOfBags": 1,
      "quantityInBag": 1.0
    }]
  },
  {

    "itemDetails": [{
        "sizeOfBag": 1,
        "numberOfBags": 1,
        "quantityInBag": 1.0
      },
      {
        "sizeOfBag": 10,
        "numberOfBags": 1,
        "quantityInBag": 1.0
      }
    ],

  }
]
const newData = data.map(f => f.itemDetails);
console.log(newData);

for (let i = 0; i <= newData.length; i++) {
  const addData = newData.reduce((acc, newData) => acc + newData[i].sizeOfBag, 0);
}
console.log(addData);

Expected Output: [1,11]

A: You can use map and reduce.
const res = newData.map(arr=>arr.reduce((acc,curr)=>acc+curr.sizeOfBag,0));

Your attempt with the for loop is close, but you are looping past the last index and mixing up your index with property names.
for (let i = 0; i < newData.length; i++) {
  newData[i] = newData[i].reduce((acc, newData) => acc + newData.sizeOfBag, 0);
}

A: You need to call reduce on the nested arrays, not the top-level newData array. You can combine all these calls using map to get an array of the results.

const data = [{
    "itemDetails": [{
      "sizeOfBag": 1,
      "numberOfBags": 1,
      "quantityInBag": 1.0
    }]
  },
  {

    "itemDetails": [{
        "sizeOfBag": 1,
        "numberOfBags": 1,
        "quantityInBag": 1.0
      },
      {
        "sizeOfBag": 10,
        "numberOfBags": 1,
        "quantityInBag": 1.0
      }
    ],

  }
]
const newData = data.map(f => f.itemDetails);
console.log(newData);

const addData = newData.map(d => d.reduce((acc, x) => acc + x.sizeOfBag, 0));

console.log(addData);

A: Do it like this, run the reduce function inside your map:
data.map(f => f.itemDetails.reduce((acc, i) => acc + i.sizeOfBag, 0));


text:
Q: PHP | array multisort can't make it work i have multidimentional array which i want to sort by both employeeID's and Dates also.
i have tried multisort, but due to lack of knowedge and experience in mulisort array can't use it properly..
Here is the Array
Array
(
    [1::2014-02-01] => Array
        (
            [EmployeeID] => 1
            [InTime] => 15:44:16
            [InDate] => 2014-02-01
            [OutTime] => 17:36:19
            [OutDate] => 2014-03-06
            [YearID] => 16
            [MonthID] => 2
            [AttendanceStatus] => 2
        )

    [5::2014-02-05] => Array
        (
            [EmployeeID] => 5
            [InTime] => 16:26:49
            [InDate] => 2014-02-05
            [OutTime] => 11:08:46
            [OutDate] => 2014-10-23
            [YearID] => 16
            [MonthID] => 2
            [AttendanceStatus] => 2
        )

    [8::2014-02-09] => Array
        (
            [EmployeeID] => 8
            [InTime] => 20:39:15
            [InDate] => 2014-02-09
            [OutTime] => 02:56:07
            [OutDate] => 2015-02-17
            [YearID] => 16
            [MonthID] => 2
            [AttendanceStatus] => 2
        )

    [6::2014-02-22] => Array
        (
            [EmployeeID] => 6
            [InTime] => 08:25:34
            [InDate] => 2014-02-22
            [OutTime] => 15:23:28
            [OutDate] => 2014-04-28
            [YearID] => 16
            [MonthID] => 2
            [AttendanceStatus] => 2
        )

    [1::2014-04-11] => Array
        (
            [EmployeeID] => 1
            [InTime] => 06:50:13
            [InDate] => 2014-04-11
            [OutTime] => 05:11:56
            [OutDate] => 2014-05-24
            [YearID] => 16
            [MonthID] => 4
            [AttendanceStatus] => 2
        )

    [9::2014-05-07] => Array
        (
            [EmployeeID] => 9
            [InTime] => 07:24:11
            [InDate] => 2014-05-07
            [OutTime] => 11:21:32
            [OutDate] => 2014-07-23
            [YearID] => 16
            [MonthID] => 5
            [AttendanceStatus] => 2
        )

    [9::2014-05-17] => Array
        (
            [EmployeeID] => 9
            [InTime] => 21:45:48
            [InDate] => 2014-05-17
            [OutTime] => 09:33:54
            [OutDate] => 2015-02-27
            [YearID] => 16
            [MonthID] => 5
            [AttendanceStatus] => 2
        )

    [11::2014-06-03] => Array
        (
            [EmployeeID] => 11
            [InTime] => 13:58:48
            [InDate] => 2014-06-03
            [OutTime] => 16:01:42
            [OutDate] => 2014-06-18
            [YearID] => 16
            [MonthID] => 6
            [AttendanceStatus] => 2
        )

    [8::2014-07-21] => Array
        (
            [EmployeeID] => 8
            [InTime] => 15:40:51
            [InDate] => 2014-07-21
            [OutTime] => 03:54:36
            [OutDate] => 2014-07-14
            [YearID] => 16
            [MonthID] => 7
            [AttendanceStatus] => 2
        )

    [9::2014-08-16] => Array
        (
            [EmployeeID] => 9
            [InTime] => 06:23:50
            [InDate] => 2014-08-16
            [OutTime] => 06:21:06
            [OutDate] => 2014-04-10
            [YearID] => 16
            [MonthID] => 8
            [AttendanceStatus] => 2
        )

    [1::2014-09-23] => Array
        (
            [EmployeeID] => 1
            [InTime] => 06:19:24
            [InDate] => 2014-09-23
            [OutTime] => 23:10:20
            [OutDate] => 2015-09-26
            [YearID] => 16
            [MonthID] => 9
            [AttendanceStatus] => 2
        )

    [3::2014-10-03] => Array
        (
            [EmployeeID] => 3
            [InTime] => 04:15:26
            [InDate] => 2014-10-03
            [OutTime] => 11:55:38
            [OutDate] => 2015-07-31
            [YearID] => 16
            [MonthID] => 10
            [AttendanceStatus] => 2
        )

    [1::2014-10-19] => Array
        (
            [EmployeeID] => 1
            [InTime] => 09:43:12
            [InDate] => 2014-10-19
            [OutTime] => 02:51:56
            [OutDate] => 2015-05-03
            [YearID] => 16
            [MonthID] => 10
            [AttendanceStatus] => 2
        )

    [8::2014-11-08] => Array
        (
            [EmployeeID] => 8
            [InTime] => 11:54:25
            [InDate] => 2014-11-08
            [OutTime] => 06:55:01
            [OutDate] => 2014-12-25
            [YearID] => 16
            [MonthID] => 11
            [AttendanceStatus] => 2
        )

    [1::2014-11-28] => Array
        (
            [EmployeeID] => 1
            [InTime] => 20:25:13
            [InDate] => 2014-11-28
            [OutTime] => 21:46:02
            [OutDate] => 2015-07-31
            [YearID] => 16
            [MonthID] => 11
            [AttendanceStatus] => 2
        )

    [8::2015-01-30] => Array
        (
            [EmployeeID] => 8
            [InTime] => 01:19:49
            [InDate] => 2015-01-30
            [OutTime] => 09:20:37
            [OutDate] => 2014-06-03
            [YearID] => 17
            [MonthID] => 1
            [AttendanceStatus] => 2
        )

    [11::2015-02-17] => Array
        (
            [EmployeeID] => 11
            [InTime] => 03:59:12
            [InDate] => 2015-02-17
            [OutTime] => 01:49:12
            [OutDate] => 2015-06-05
            [YearID] => 17
            [MonthID] => 2
            [AttendanceStatus] => 2
        )

    [6::2015-02-27] => Array
        (
            [EmployeeID] => 6
            [InTime] => 06:45:15
            [InDate] => 2015-02-27
            [OutTime] => 22:49:19
            [OutDate] => 2014-04-17
            [YearID] => 17
            [MonthID] => 2
            [AttendanceStatus] => 2
        )

    [3::2015-05-18] => Array
        (
            [EmployeeID] => 3
            [InTime] => 10:55:10
            [InDate] => 2015-05-18
            [OutTime] => 18:59:54
            [OutDate] => 2015-04-02
            [YearID] => 17
            [MonthID] => 5
            [AttendanceStatus] => 2
        )

    [5::2015-09-16] => Array
        (
            [EmployeeID] => 5
            [InTime] => 19:46:53
            [InDate] => 2015-09-16
            [OutTime] => 07:52:40
            [OutDate] => 2014-04-08
            [YearID] => 17
            [MonthID] => 9
            [AttendanceStatus] => 2
        )

    [11::2015-10-16] => Array
        (
            [EmployeeID] => 11
            [InTime] => 01:03:57
            [InDate] => 2015-10-16
            [OutTime] => 20:52:36
            [OutDate] => 2014-11-25
            [YearID] => 17
            [MonthID] => 10
            [AttendanceStatus] => 2
        )

    [6::2015-12-29] => Array
        (
            [EmployeeID] => 6
            [InTime] => 04:29:13
            [InDate] => 2015-12-29
            [OutTime] => 21:02:34
            [OutDate] => 2014-05-10
            [YearID] => 17
            [MonthID] => 12
            [AttendanceStatus] => 2
        )

    [1::2014-09-20] => Array
        (
            [EmployeeID] => 1
            [InTime] => 00:00:00
            [InDate] => 2014-09-20
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [1::2014-09-21] => Array
        (
            [EmployeeID] => 1
            [InTime] => 00:00:00
            [InDate] => 2014-09-21
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [1::2014-09-22] => Array
        (
            [EmployeeID] => 1
            [InTime] => 00:00:00
            [InDate] => 2014-09-22
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [1::2014-09-24] => Array
        (
            [EmployeeID] => 1
            [InTime] => 00:00:00
            [InDate] => 2014-09-24
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [1::2014-09-25] => Array
        (
            [EmployeeID] => 1
            [InTime] => 00:00:00
            [InDate] => 2014-09-25
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [1::2014-09-26] => Array
        (
            [EmployeeID] => 1
            [InTime] => 00:00:00
            [InDate] => 2014-09-26
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [5::2014-09-20] => Array
        (
            [EmployeeID] => 5
            [InTime] => 00:00:00
            [InDate] => 2014-09-20
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [5::2014-09-21] => Array
        (
            [EmployeeID] => 5
            [InTime] => 00:00:00
            [InDate] => 2014-09-21
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [5::2014-09-22] => Array
        (
            [EmployeeID] => 5
            [InTime] => 00:00:00
            [InDate] => 2014-09-22
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [5::2014-09-23] => Array
        (
            [EmployeeID] => 5
            [InTime] => 00:00:00
            [InDate] => 2014-09-23
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [5::2014-09-24] => Array
        (
            [EmployeeID] => 5
            [InTime] => 00:00:00
            [InDate] => 2014-09-24
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [5::2014-09-25] => Array
        (
            [EmployeeID] => 5
            [InTime] => 00:00:00
            [InDate] => 2014-09-25
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [5::2014-09-26] => Array
        (
            [EmployeeID] => 5
            [InTime] => 00:00:00
            [InDate] => 2014-09-26
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [8::2014-09-20] => Array
        (
            [EmployeeID] => 8
            [InTime] => 00:00:00
            [InDate] => 2014-09-20
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [8::2014-09-21] => Array
        (
            [EmployeeID] => 8
            [InTime] => 00:00:00
            [InDate] => 2014-09-21
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [8::2014-09-22] => Array
        (
            [EmployeeID] => 8
            [InTime] => 00:00:00
            [InDate] => 2014-09-22
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [8::2014-09-23] => Array
        (
            [EmployeeID] => 8
            [InTime] => 00:00:00
            [InDate] => 2014-09-23
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [8::2014-09-24] => Array
        (
            [EmployeeID] => 8
            [InTime] => 00:00:00
            [InDate] => 2014-09-24
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [8::2014-09-25] => Array
        (
            [EmployeeID] => 8
            [InTime] => 00:00:00
            [InDate] => 2014-09-25
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [8::2014-09-26] => Array
        (
            [EmployeeID] => 8
            [InTime] => 00:00:00
            [InDate] => 2014-09-26
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [6::2014-09-20] => Array
        (
            [EmployeeID] => 6
            [InTime] => 00:00:00
            [InDate] => 2014-09-20
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [6::2014-09-21] => Array
        (
            [EmployeeID] => 6
            [InTime] => 00:00:00
            [InDate] => 2014-09-21
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [6::2014-09-22] => Array
        (
            [EmployeeID] => 6
            [InTime] => 00:00:00
            [InDate] => 2014-09-22
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [6::2014-09-23] => Array
        (
            [EmployeeID] => 6
            [InTime] => 00:00:00
            [InDate] => 2014-09-23
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [6::2014-09-24] => Array
        (
            [EmployeeID] => 6
            [InTime] => 00:00:00
            [InDate] => 2014-09-24
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [6::2014-09-25] => Array
        (
            [EmployeeID] => 6
            [InTime] => 00:00:00
            [InDate] => 2014-09-25
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [6::2014-09-26] => Array
        (
            [EmployeeID] => 6
            [InTime] => 00:00:00
            [InDate] => 2014-09-26
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [9::2014-09-20] => Array
        (
            [EmployeeID] => 9
            [InTime] => 00:00:00
            [InDate] => 2014-09-20
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [9::2014-09-21] => Array
        (
            [EmployeeID] => 9
            [InTime] => 00:00:00
            [InDate] => 2014-09-21
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [9::2014-09-22] => Array
        (
            [EmployeeID] => 9
            [InTime] => 00:00:00
            [InDate] => 2014-09-22
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [9::2014-09-23] => Array
        (
            [EmployeeID] => 9
            [InTime] => 00:00:00
            [InDate] => 2014-09-23
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [9::2014-09-24] => Array
        (
            [EmployeeID] => 9
            [InTime] => 00:00:00
            [InDate] => 2014-09-24
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [9::2014-09-25] => Array
        (
            [EmployeeID] => 9
            [InTime] => 00:00:00
            [InDate] => 2014-09-25
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [9::2014-09-26] => Array
        (
            [EmployeeID] => 9
            [InTime] => 00:00:00
            [InDate] => 2014-09-26
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [11::2014-09-20] => Array
        (
            [EmployeeID] => 11
            [InTime] => 00:00:00
            [InDate] => 2014-09-20
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [11::2014-09-21] => Array
        (
            [EmployeeID] => 11
            [InTime] => 00:00:00
            [InDate] => 2014-09-21
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [11::2014-09-22] => Array
        (
            [EmployeeID] => 11
            [InTime] => 00:00:00
            [InDate] => 2014-09-22
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [11::2014-09-23] => Array
        (
            [EmployeeID] => 11
            [InTime] => 00:00:00
            [InDate] => 2014-09-23
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [11::2014-09-24] => Array
        (
            [EmployeeID] => 11
            [InTime] => 00:00:00
            [InDate] => 2014-09-24
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [11::2014-09-25] => Array
        (
            [EmployeeID] => 11
            [InTime] => 00:00:00
            [InDate] => 2014-09-25
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [11::2014-09-26] => Array
        (
            [EmployeeID] => 11
            [InTime] => 00:00:00
            [InDate] => 2014-09-26
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [3::2014-09-20] => Array
        (
            [EmployeeID] => 3
            [InTime] => 00:00:00
            [InDate] => 2014-09-20
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [3::2014-09-21] => Array
        (
            [EmployeeID] => 3
            [InTime] => 00:00:00
            [InDate] => 2014-09-21
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [3::2014-09-22] => Array
        (
            [EmployeeID] => 3
            [InTime] => 00:00:00
            [InDate] => 2014-09-22
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [3::2014-09-23] => Array
        (
            [EmployeeID] => 3
            [InTime] => 00:00:00
            [InDate] => 2014-09-23
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [3::2014-09-24] => Array
        (
            [EmployeeID] => 3
            [InTime] => 00:00:00
            [InDate] => 2014-09-24
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [3::2014-09-25] => Array
        (
            [EmployeeID] => 3
            [InTime] => 00:00:00
            [InDate] => 2014-09-25
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

    [3::2014-09-26] => Array
        (
            [EmployeeID] => 3
            [InTime] => 00:00:00
            [InDate] => 2014-09-26
            [OutTime] => 00:00:00
            [OutDate] => 0000-00-00
            [AttendanceStatus] => 2
            [YearID] => 16
            [MonthID] => 9
        )

)

Here There Are Two Keys EmployeeID and InDate inside inner arrays if you see.
I want to sort this array using both columns.. How can i make it possible??
-=-=-=-=-=--=--=
I tried PHP function http://php.net/manual/en/function.array-multisort.php
But couldn't Figure Out How to work with it..

A: You can use usort or uasort . It expects the array and a callback which sorts 2 elements. It has to return an integer greater/equal/lower zero to map the first element as greater/equal/lower than the second element.
$arr = ...; // your array

// the callback has to return integer greater/equal/lower zero
uasort($arr, function($e1, $e2){

    return $el1['EmployeeID'] != $el2['EmployeeID'] ? // not equal
        $el1['EmployeeID'] - $el2['EmployeeID'] :  // return the difference (which maps to greater or lower)
        strtotime($el1['InDate']) - strtotime($el2['InDate']) // When both IDs equal use InDate for sorting

});


text:
Q: How to preserve DataGridView color information (both cell and text) when using column filters? I use AdvancedDataGridView in my project. I can change my desired cells (and text) color using right click menu, but when I use column filters, all those color information got lost. Even when I remove filters, those color information don't get back to its place.
I have designed a class for saving/loading DGV color information when opening/exiting the application:
      public static void WriteDataGridViewSettings(System.Windows.Forms.DataGridView dgv)
    {
        XmlTextWriter writer = new XmlTextWriter(Application.StartupPath + @"\MyGridColor.xml", null);
        writer.WriteStartDocument();
        writer.WriteStartElement(dgv.Name);
        int LastRow = dgv.Rows.Count;
        for (int i = 0; i < LastRow; i++)
        {
            writer.WriteStartElement("Row");
            writer.WriteStartElement("CellColor");
            writer.WriteString(dgv.Rows[i].DefaultCellStyle.BackColor.ToArgb().ToString());
            writer.WriteEndElement();
            writer.WriteStartElement("TextColor");
            writer.WriteString(dgv.Rows[i].DefaultCellStyle.ForeColor.ToArgb().ToString());
            writer.WriteEndElement();
            writer.WriteEndElement();
        }
        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Close();
    }

    public static void ReadDataGridViewSettings(System.Windows.Forms.DataGridView dgv)
    {
        XmlDocument xmldoc = new XmlDocument();
        XmlNodeList xmlnode;
        FileStream fs = new FileStream(Application.StartupPath + @"\MyGridColor.xml", FileMode.Open, FileAccess.Read);
        xmldoc.Load(fs);
        xmlnode = xmldoc.GetElementsByTagName("Row");
            for (int i = 0; i <= xmlnode.Count-1; i++)
            {
                int cellcolor = int.Parse(xmlnode[i].ChildNodes.Item(0).InnerText.Trim());
                int textcolor = int.Parse(xmlnode[i].ChildNodes.Item(1).InnerText.Trim());
                if (cellcolor != 0)
                {
                    dgv.Rows[i].DefaultCellStyle.BackColor = Color.FromArgb(Convert.ToInt32(cellcolor));
                    dgv.Rows[i].DefaultCellStyle.ForeColor = Color.FromArgb(Convert.ToInt32(textcolor));
                }
                else
                {
                    dgv.Rows[i].DefaultCellStyle.BackColor = Color.White;
                    dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Black;
                }
            }
        fs.Close();
    }

Because of the problem mentioned above, I have accidentally lost my color information after using the filter and exiting the application.

A: Okay, so here is a working solution. You will need to adapt it to meet your exact requirements, but it should give you an idea of how you can persist colours across at datagridview when the rows get redrawn.
The idea is we store some unique identifier for each row in a list and then we use that identifier to decide if (or what) colour the row should be, and apply that in the RowPrePaint event.
public partial class Form1 : Form
{
    BindingSource _bs = new BindingSource();

    //If you want to store associated colours for each row
    //expand this to whatever data structure you prefer
    List<int> _colourRows = new List<int>();

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        //This is the normal data from, for example, a database
        DataTable table = ExampleData();

        //Now add an extra column and put some unique numbers in the datatable
        //We do it to the underlying data
        //If your data already has a unique index or sequence you don't need to do this
        table.Columns.Add("sequenceColumn", typeof(int));
        for (int i = 0; i <= table.Rows.Count - 1; i++)
        {
            table.Rows[i]["sequenceColumn"] = i;
        }

        //Bind data to the UI
        _bs.DataSource = table;
        dgv.DataSource = _bs;

        //Hide this column from UI
        dgv.Columns["sequenceColumn"].Visible = false;
        dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    }

    private void setColourToolStripMenuItem_Click(object sender, EventArgs e)
    {
        foreach (DataGridViewRow dr in dgv.SelectedRows)
        {
            //Add it to the list and also update it immediately
            _colourRows.Add((int)dr.Cells["sequenceColumn"].Value);
            dr.DefaultCellStyle.BackColor = Color.Red;
        }
    }

    private void dgv_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
    {
        //The key is that this isn't the rows position index (which could change with filtering sorting)
        //It is just a value we've added to a new column for each row
        int rowColourSequence = (int)dgv.Rows[e.RowIndex].Cells["sequenceColumn"].Value;

        if (_colourRows.Contains(rowColourSequence))
        {
            dgv.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
        }
    }

    private DataTable ExampleData()
    {
        DataTable table = new DataTable();
        table.Columns.Add("Animal", typeof(string));
        table.Columns.Add("Count", typeof(int));

        table.Rows.Add("Cat", 15);
        table.Rows.Add("Dog", 10);
        table.Rows.Add("Ferret", 2);
        table.Rows.Add("Mouse", 0);

        return table;
    }
}

Here you can see if I change the sorting or filtering the row colour is persisted:


text:
Q: MS Access backend database deleted data restored on its own I'm not sure if this is a MS Access or SharePoint issue, I have a MS Access backend database sitting on SharePoint drive and the database stores some test data. As I approaching the end of the test, I tried to delete the test data from the backend database file.
I used the navigation pane initially, open the DB table, select all the test data and delete using Access interface. After an hour or so, the data restored on its own. I thought it was maybe some other DB users are logged in and interacting with the data so I tried again, this time using SQL action query to delete the data. After sometime, the deleted data got restored on its own again.
I'm the only DB administrator for my DB and there should be no one else meddling with the data, restoring it, etc. Finally, I tried deleting the data when all users have logged out, supposedly there should be no one else having access to the data at the backend. Yet the next day, the deleted data again got restored on its own.
Anyone have any clue why this is happening? Could it be SharePoint's file restore mechanism? But no one has requested for such restore.


text:
Q: How do I use JMockit with Gradle on the IBM J9 JVM? I'm using Gradle (Milestone 8a) to run JUnit tests on my project with the IBM J9 JVM, which according to "Running tests with JMockit" requires that I pass the argument -javaagent:jmockit.jar to the JVM. However, JMockit isn't injecting mocked parameters which is causing my tests to fail with "Method (foo) should have no parameters)". The tests run fine in Eclipse on the HotSpot JVM.
I've extended the test task to find the JAR and add the argument to jvmArgs like this:
test {
   doFirst {
     // Don't do this until the task is actually being executed, because
     // as soon as we call testCompile.find the configuration is resolved and
     // can't be modified anymore.
     jMockit = project.configurations.testCompile.find {
       it.name.startsWith("jmockit-")
     }
     jvmArgs "-javaagent:${jMockit}"
   }
}

I've also added JMockit and JUnit to the testCompile configuration, making sure that JMockit is first, and verified this by running gradle dependencies:
dependencies {
  testCompile 'com.googlecode.jmockit:jmockit:0.999.13'
  testCompile 'junit:junit:4.10'
}

The output of gradle check --debug confirms that the -javaagent parameter is being used:
12:44:14.788 [DEBUG] [org.gradle.process.internal.ProcessBuilderFactory] creating process builder for Gradle Worker 1
12:44:14.788 [DEBUG] [org.gradle.process.internal.ProcessBuilderFactory] in directory /home/bbobby/webapp
12:44:14.788 [DEBUG] [org.gradle.process.internal.ProcessBuilderFactory] with argument#0 = -javaagent:/home/bbobby/.gradle/caches/artifacts-8/filestore/com.googlecode.jmockit/jmockit/0.999.13/jar/a6
ba457e09361f37e386edea176c5ce4fa9ee110/jmockit-0.999.13.jar
12:44:14.789 [DEBUG] [org.gradle.process.internal.ProcessBuilderFactory] with argument#1 = -ea
12:44:14.789 [DEBUG] [org.gradle.process.internal.ProcessBuilderFactory] with argument#2 = -cp
12:44:14.789 [DEBUG] [org.gradle.process.internal.ProcessBuilderFactory] with argument#3 = /home/bbobby/.gradle/caches/1.0-milestone-8a/workerMain/classes
12:44:14.789 [DEBUG] [org.gradle.process.internal.ProcessBuilderFactory] with argument#4 = org.gradle.process.internal.launcher.GradleWorkerMain
12:44:14.816 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Started Gradle Worker 1.

I'm pretty sure I've done everything I'm supposed to. Why are my tests failing to run?

A: This is http://issues.gradle.org/browse/GRADLE-2189, which is already fixed for the upcoming 1.0-rc-1. You can try out the release candidate today.


text:
Q: How to align textview below and right of imageview? I am working on a UI in which i want to align my Textview to right of ImageView as well as below of that same ImageView. I want this because, if i align the TextView Right of the ImageView, its leaving some empty space below the ImageView.
Below are the screenshots:
Current Situtaion:
https://drive.google.com/open?id=0B6J8T8u_aeWrWWptZTJqTzVMTkk
Requirement:
https://drive.google.com/open?id=0B6J8T8u_aeWrbXVnNVJEd0g2dWM
XML:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.meg7.widget.RectangleImageView
            android:id="@+id/ivUserProfilePictureWOQ"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:scaleType="centerCrop"
            android:src="@drawable/splash_image" />

        <LinearLayout
            android:id="@+id/ll_woq_quote_name"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="wrap_content"
            android:layout_toEndOf="@+id/ivUserProfilePictureWOQ">

            <TextView
                android:id="@+id/tv_woq_user_name"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Name"/>

        <TextView
            android:id="@+id/tv_woq_user_quotes"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="Qoute"
            android:textSize="20dp"
            android:textIsSelectable="true" />

        </LinearLayout>

    </RelativeLayout>

    <LinearLayout
        android:id="@+id/ll_woq_tags"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ivUserProfilePictureWOQ"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tv_woq_tags"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textSize="18dp"
            android:padding="5dp"
            android:text="tags" />

        <TextView
            android:id="@+id/tv_woq_likes"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textSize="14dp"
            android:padding="5dp"
            android:text="likes" />

    </LinearLayout>

</LinearLayout>

A: So i just created a xml as u require  , Just use this in your project
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="1">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".2"
                android:gravity="center"
                android:padding="7dp">

                <com.meg7.widget.RectangleImageView
                    android:id="@+id/ivUserProfilePictureWOQ"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/splash_image" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/ll_woq_quote_name"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".8"
                android:orientation="vertical"
                android:padding="5dp"
                android:weightSum="1">

                <TextView
                    android:id="@+id/tv_woq_user_name"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight=".2"
                    android:text="Einstien" />

                <TextView
                    android:id="@+id/tv_woq_user_quotes"
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_weight=".8"
                    android:maxLines="2"
                    android:text="This is dummy text and check use this in project , do tell me if its working fine or not ......."
                    android:textIsSelectable="true"
                    android:textSize="16sp" />

            </LinearLayout>

        </LinearLayout>

        <TextView
            android:id="@+id/tv_desciption"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:text="ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample"
            android:textSize="18dp" />

        <LinearLayout
            android:id="@+id/ll_woq_tags"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/tv_woq_tags"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="5dp"
                android:text="tags"
                android:textSize="18dp" />

            <TextView
                android:id="@+id/tv_woq_likes"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="5dp"
                android:text="likes"
                android:textSize="14dp" />

        </LinearLayout>

    </LinearLayout>
</RelativeLayout>

A: Don't reinventing the wheel, use library if you can: http://deano2390.github.io/FlowTextView/


text:
Q: how to intercept gesture for a sibling view? if there are three views:

view1
    ---subview1
    ---subview2

normally, subview2 will handle every gesture, however, in my case, I just need the subview2 to handle pinch gesture, and other gestures like pan and rotate will pass to subview1, is there any way to do it?

A: implement this method from the UIGestureRecognizerDelegate-Protocol:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return true;
}


text:
Q: Paypal IPN listener not hearing I have some sample IPNs in Paypal and am trying to set up the listener but regardless of what I try it is simply not talking to it, although it says it is.
Here's the listener code:
$debug=true;

//Put together postback info
$postback = 'cmd=_notify-validate';

foreach($_POST as $key =>$value){
     $postback .= "&$key=$value";
}

// build the header string to post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host: www.sandbox.paypal.com\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($postback) . "\r\n\r\n";

$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);//open the connection

if(!$fp){ //no conn
    die();
}

//post data back
fputs($fp, $header . $postback);

$res=stream_get_contents($fp, 1024);

if((strcmp($res, "VERIFIED")) == 0){ //verified!
    if($debug){
        $filename = 'debug/verify.txt'; //create a file telling me we're verified
        $filehandle=fopen($filename, 'w');
        fwrite($filehandle,'VERIFIED!');
        fclose($filehandle);
    }
} else {
    if($debug){
        $filename = 'debug/verify.txt'; //create a file telling me we're NOT verified
        $filehandle=fopen($filename, 'w');
        fwrite($filehandle,'NOT VERIFIED!');
        fclose($filehandle);
    }
}

if($debug){
    $filename = 'debug/alive.txt'; //create a file telling me we're alive at least
    $filehandle=fopen($filename, 'w');
    fwrite($filehandle,'NOT VERIFIED!');
    fclose($filehandle);
}

Very simple, and here's a screenshot of a IPN i'm sending which is doing nothing:

I added the code at the end of the listener file to at least let me know its been hit but it doesn't do anything.
Is there anything obvious I've missed? Tearing my hair out with this stuff. Is there any more debugging I can do?

A: I don't know about your code, but try the code I'm currently using in my IPN listener, it works absolutely fine:
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
    $keyval = explode ('=', $keyval);
    if (count($keyval) == 2)
        $myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
    $get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
    if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
        $value = urlencode(stripslashes($value));
    } else {
        $value = urlencode($value);
    }
    $req .= "&$key=$value";
}

// Post IPN data back to PayPal to validate the IPN data is genuine
// Without this step anyone can fake IPN data

$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
if ($ch == FALSE) {
    return FALSE;
}

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);

// CONFIG: Optional proxy configuration
//curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);

// Set TCP timeout to 30 seconds
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));

// CONFIG: Please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
// of the certificate as shown below. Ensure the file is readable by the webserver.
// This is mandatory for some environments.
// $cert = __DIR__ . "./cacert.pem";
// curl_setopt($ch, CURLOPT_CAINFO, $cert);
$res = curl_exec($ch);
if (curl_errno($ch) != 0) {
    error_log(date('[Y-m-d H:i:s] '). "Couldn't connect to PayPal to validate IPN message: " . curl_error($ch) . PHP_EOL, 3, LOG_FILE);
    curl_close($ch);
    exit;

} else {
        curl_close($ch);
}

// Inspect IPN validation result and act accordingly
if (strcmp($res, 'VERIFIED') == 0) {
    // do something...
} elseif (strcmp($res, 'INVALID') == 0) {
    // do something...
}


text:
Q: Initialize weight in pytorch neural net I have created this  neural net:
class _netD(nn.Module):
    def __init__(self, num_classes=1, nc=1, ndf=64):
        super(_netD, self).__init__()
        self.num_classes = num_classes
        # nc is number of channels
        # num_classes is number of classes
        # ndf is the number of output channel at the first layer
        self.main = nn.Sequential(
            # input is (nc) x 28 x 28
            # conv2D(in_channels, out_channels, kernelsize, stride, padding)
            nn.Conv2d(nc, ndf , 4, 2, 1, bias=False),
            nn.LeakyReLU(0.2, inplace=True),
            # state size. (ndf) x 14 x 14
            nn.Conv2d(ndf, ndf * 2, 4, 2, 1, bias=False),
            nn.BatchNorm2d(ndf * 2),
            nn.LeakyReLU(0.2, inplace=True),
            # state size. (ndf*2) x 7 x 7
            nn.Conv2d(ndf * 2, ndf * 4, 4, 2, 1, bias=False),
            nn.BatchNorm2d(ndf * 4),
            nn.LeakyReLU(0.2, inplace=True),
            # state size. (ndf*4) x 3 x 3
            nn.Conv2d(ndf * 4, ndf * 8, 3, 2, 1, bias=False),
            nn.BatchNorm2d(ndf * 8),
            nn.LeakyReLU(0.2, inplace=True),
            # state size. (ndf*8) x 2 x 2
            nn.Conv2d(ndf * 8, num_classes, 2, 1, 0, bias=False),
            # out size = batch x num_classes x 1 x 1
        )

        if self.num_classes == 1:
            self.main.add_module('prob', nn.Sigmoid())
            # output = probability
        else:
            pass
            # output = scores

    def forward(self, input):

        output = self.main(input)
        return output.view(input.size(0), self.num_classes).squeeze(1)

I want to loop through the different layers and apply a weight initialization depending on the type of layer. I am trying to do the following:
D = _netD()

for name, param in D.named_parameters():
    if type(param) == nn.Conv2d:
      param.weight.normal_(...)

But that is not working. Can you please help me?
Thanks

A: type(param) will only return the actual datatype called a parameter for any type of weight or data in the model. Because named_parameters() doesn't return anything useful in the name either when used on an nn.sequential-based model, you need to look at the modules to see which layers are specifically related to the nn.Conv2d class using isinstance as such:
for layer in D.modules():
    if isinstance(layer, nn.Conv2d):
         layer.weight.data.normal_(...)

Or, the way that is recommended by Soumith Chintala himself, actually just loop through your main module itself:
for L,layer in D.main:
    if isisntance(layer,nn.Conv2d):
         layer.weight.data.normal_(..)

I actually prefer the first because you don't have to specify the exact nn.sequential module itself, and will search all possible modules in the model, but either one should do the job for you.


text:
Q: Retrieving the Slug from URL for function (Laravel 5) I'm making an App where a group is created by a user. This user can go to the group page (automated unique slug is created for the groups).
My goal is for the member who created the group, to be able to make a invite code for that specific group.
Currently the code generator is hardcoded to create one for the group with id=8.
Here is the code:
public function createInviteCode()
    {
        $group = Group::find(8); // Group ID you want to manage
        $code = Invite::generateCode();
        $invite = $group->invites()->create([
            'code' => $code,
            'expires_at' => Carbon::now()->addDays(7) // invite expires in 7 days
        ]);

        return redirect()->back();
    }

The code is generated on through a submit button on my showgroup.blade.php:
{!! Form::open(['route' => 'invite.create']) !!}
{!! Form::submit('Generate invite code', ['class' =>  'btn btn-primary']) !!}
{!! Form::close() !!}

What I am trying to do, is retrieve the slug that I'm surfing to, to show this group:
function to retrieve the slug:
public function search()
{
    $group = Group::whereSlug($slug)->first();

    return view('pages.groups.showgroup')->withSlug($group);
}

Also these are my Routes.php:
$router->post('invites', ['as' => 'invite.create', 'uses' => 'GroupController@createInviteCode']);
$router->get('group/{slug}', ['as' => 'group.search', 'uses' => 'GroupController@search']);

So a small recap:
Currently I'm simply creating a invite code for the group with ID=8.
What I want to do is change my function so it creates a invite code for the group that I'm surfing to (aka through the slug)
How do I code this exactly?

A: Fixed it:
Route:
$router->post('invites/{slug}', ['as' => 'invite.create', 'uses' => 'GroupController@createInviteCode']);

My form:
{!! Form::open(['route' => ['invite.create', $group->slug]]) !!}
{!! Form::submit('Generate invite code', ['class' =>  'btn btn-primary']) !!}
{!! Form::close() !!}

The function:
public function createInviteCode($slug)
{
    $group = Group::where('slug', $slug)->firstOrFail();

    // ...
}


text:
Q: How to store a user object for your Polymer app and make it accessible everywhere I was wondering what are the best practices to store an user object and make it accessible through my whole Polymer app. Since I'm using a lot of template imports, I'm getting a little bit lost on how to access my user object retrieved from my <x-login id="xlogin" user="{{user}}"></x-login>  template imported by my my-app template. I'm using <firebase-auth> for authentication.
Let's say I'm five template levels deep and I want to access my refreshToken which is in my {{user}} object, what is the best way to get this?

*

*Do I have to do a querySelector for my element with id #login?

*Or do I have to pass the user object through all my nested elements?

*Or do I have to include <firebase-auth app-name="projectMeta"
id="auth" user="{{user}}"></firebase-auth> in all my pages where I
want to get my userdata?

*Or are there better/cleaner ways to achieve this?


text:
Q: Should I just move the file or create a class which moves it? Okay, I got this small program which tags (as in ID3v2.4 etc.) some music files. Now I want the user to have the option to move and/or rename those tagged files if he/she wishes to.
Considering that I am trying to keep a fairly clean and loosely coupled design in this system (even though extensibility is not really important here, it's just fun), would you just call someFileInfoObject.Move(someWhere) where someWhere is the applied pattern or would it be wise to implement some classes - maybe MoveFileStrategy, RenameFileStrategy (I know that moving/renaming can be considered the same in some systems, but I want them to be enabled separately) - which figure out the destination and whether the strategy should be applied when an Apply(FileInfo file) method or so is called.
If you think that some strategy classes may be useful, do you have any suggestion on a good implementation strategy?
As already said, over-engineering is not really an issue here, because it is a fun project mainly targeted at getting some programming and engineering practice. :)

A: You can make the case that you have a virtually unlimited number of commands for your files.  Think of this class hierarchy.
Command
    CopyCommand
    RenameCommand
    MoveCommand
    DiffCommand
    CompressCommand

These aren't really strategies.  They're just ordinary classes with a simple "execute" method.  You provide the options and arguments through ordinary setters.  Then you execute the method.
This borrows from Ant's design pattern for Tasks that can be plugged in.

A: Off the top of my head, building on @S.Lott, keep the commands themselves simple and atomic, and create a command queue. The UI add's commands to the queue, and the program executes the commands sequentially.
Additionally, you could hang onto (memento's) of executed commands and provide an undo facility.


text:
Q: How to fix this try/guard error in swift Trying to learn swift 2.0. Got this code, but it fails with the error can throw and error, not marked try and does not handle error. On line device.lock ...
func focusTo(value : Float) {
    if let device = captureDevice {
        if(device.lockForConfiguration()) {
            device.setFocusModeLockedWithLensPosition(value, completionHandler: { (time) -> Void in
                //
            })
            device.unlockForConfiguration()
        }
    }
}

Which I am sure is quite simple, but could somebody outline exactly how the syntax would look. Thinking I should use the swift "guard" instruction ideally and not try.

A: Edit: guard only makes sure device.lockForConfiguration() doesn't return false. If it throws errors then it must be wrapped by do - try - catch:
In this case, lockForConfiguration() does not return Bool, so there's nothing to do with guard.
do {
    try device.lockForConfiguration()

    device.setFocusModeLockedWithLensPosition(...)
    device.unlockForConfiguration()

} catch let error as NSError {
    if error.code == 0 {
        print("Error code: 0")
    }
}

The syntax is:
guard device.lockForConfiguration() else {
    print("Lock configuration failed!!1")
    return
}

device.setFocusModeLockedWithLensPosition()
device.unlockForConfiguration()

You can even use it to replace if:
guard let device = captureDevice else {
    print("Device is nil!")
    return
}

// Do things with device


text:
Q: Attaching debugger to multiple processes Very simple question from new user of multiple processes debugging.
Whenever I read MSDN articles regarding this topic, I read:
"You can attach to multiple processes when you are debugging, but only one process is active in the debugger at any given time"
If you can debug only single process actively, seemingly attaching multiple processes is not very useful if I can only activate a single process in the debugger.
Please correct me if I am not understanding the statement correct.

A: It means that while debugging, VS studio will switch between processes being debugged to gather information needed for debugging, otherwise would be a mess to understand what is happening to a process if multiple processes information are shown together.
An example to see it happening is creating a solution with two web applications and start debugging, VS itself will run both and attach to then, if you put a breakpoint in one endpoint of each app and call one endpoint, let's say here on app1, VS will stop on that breakpoint, and then call the endpoint on app2 before continuing the debugging on app1, visual Studio Will only switch to the other breakpoint when the first one gets released, than VS Will switch to app2 breakpoint.


text:
Q: chess game - error in abstract class #pragma once
#include <string>
#include <iostream>
using namespace std;

class Chess_tool
{
public:
    Chess_tool(string color, char name);
    virtual bool legal_movement(int source[], int dest[]) const = 0;

private:
    string _color;
    char _name;
};

Im trying to create chess game, so I create abstract class for chess tool (queen, king, rook...)
I also created king tool to check my code:
#pragma once

#include "Chess_tool.h"

class King : Chess_tool
{
public:
    King(string color, char name);
    virtual bool legal_movement(int source[], int dest[]);
};

and I create game_board class:
#pragma once
#include "Game_board.h"
#include "Chess_tool.h"
#include <iostream>

#define BOARD_SIZE 8
using namespace std;

class Chess_tool;
class Game_board
{
public:
    Game_board();
    ~Game_board();
    void move(string panel);

protected:
    Chess_tool* _board[BOARD_SIZE][BOARD_SIZE];
};

the problem is here, when i try to add object to the matrix its show me error  :
    1   IntelliSense: object of abstract class type "King" is not allowed:
            pure virtual function "Chess_tool::legal_movement" has no overrider
#pragma once
#include "Chess_tool.h"
#include "Game_board.h"
#include "King.h"
using namespace std;

enum Turn { WIHTE, BLACK };

class Manager : Game_board
{
public:
    Manager();
    ~Manager();
    virtual bool legal_movement(int source[], int dest[]) const = 0;
};

....
#include "Manager.h"
Manager::Manager()
{
    _board[0][0] = new King();
}

A: The member function in the base class is const-qualified, not in the derived class.
So these are not the same functions through inheritance. You've declared a new virtual function, not overriden the first one.
Add const to the second one so that it actually override the base class function.
Remember that for virtual function overriding to kick in, there are a few condition to actually satisfy. They must have:

*

*the same name

*the same return type

*the same parameters count and type

*the same const-qualification (our case here)

*a few other minor things (for example, compatible exceptions specifications)

If any condition isn't satisfied, you create a very similar, but different, function for the compiler.
With C++11, you should use override for the functions you want to override, so the compiler knows your intention and tells you that you've made a mistake. E.g.:
virtual bool legal_movement(int source[], int dest[]) override;
//                                                    ^^^^^^^^


text:
Q: Angular 2 pipe, using observable correctly, my pipe does not return a poster path I'm trying to call my service to get a poster Url for all my movies (Want to show the poster of them). I'm using Angular2 and have for now created a pipe that should do the job.
I have this code:

        {{movie.MovieYear}}

        {{movie.MovieTitle}}

Here you see the let movie of MoviesOnNas , it will show all movies there is in the MoviesOnNas object.
In the line:

I'm trying to use a custom pipe I have created. It looks like this.
@Pipe({ name: 'poster' })
export class PosterPipe implements PipeTransform {

constructor(public movieService: MovieService) {

}

transform(value: string, args: string[]): any {
    if (value) {
        // Go call api to get poster.
        this.movieService.getMoviePoster(value).subscribe((data) => {
            console.log("http://image.tmdb.org/t/p/w500" + data);
            var poster = "http://image.tmdb.org/t/p/w500" + data;
            return poster;
        });
    }
    else {
        // Insert could not find movie poster.
        return "../../assets/img/poster.png";
    }
}
}

The pipe should return the poster url. The problem is that The code I have provided does not work. It won't load the url and show the picture. In the console.log, I can see that the url path is actually working if I use it in the browser.
If I do something like this:
if (value) {

    return "http://image.tmdb.org/t/p/w500/bqLlWZJdhrS0knfEJRkquW7L8z2.jpg"
}

Then it shows the picture correctly. So the problem must be the observable subscribe?
Can any see what could be wrong here?

A: You should use the async pipe when dealing with async operations.
Remember to return a promise or an observable.
@Pipe({
  name: 'poster'
})
class PosterPipe {
  apiCall;
  constructor() {
    // simulate http call
    this.apiCall = Observable.create(observer => {
      observer.next("http://lorempixel.com/400/200/sports/");
    });
  }

  transform(value: string) {
    if(value) {
      return this.apiCall.first();
    }

    return Observable.of("../../assets/img/poster.png");

  }
}

@Component({
  selector: 'my-app',
  template: `

  `,
})
export class App {
   MovieId:string;
   constructor() {
    this.MovieId = 'Exists'
   }
}

Working Plunker


text:
Q: BackboneJs: Uncaught TypeError: undefined is not a function I am having a problem that there are a lot of others posts here in Stack. But no one solves the problem so I am taking this problem back.
A quick reference:
Uncaught TypeError: undefined is not a function rails3/backbone/js

I am writing my first app with backBoneJs. This is the example that I am following:
http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/
When I execute the code:
1 - Uncaught TypeError: Cannot call method 'extend' of undefined (Controller 1ºline)

2 - Uncaught TypeError: undefined is not a function              (app 6º line)
App.initapp.js:6
(anonymous function)/backbone/#:32
f.extend._Deferred.e.resolveWithjquery-1.6.4.min.js:2
e.extend.readyjquery-1.6.4.min.js:2
c.addEventListener.C

Check my code:
Index.html

        <title></title>
        <link href="css/style.css" media="all" rel="stylesheet" type="text/css" />

Editor de Documentos

Backbone + PHP by Lqdi

Collections:
App.Collections.Documents = Backbone.Collection.extend({
    model: Document,
    url: '/documents'
});

Controllers:
App.Controllers.Documents = Backbone.Controller.extend({
    routes: {
        "documents/:id":            "edit",
        "":                         "index",
        "new":                      "newDoc"
    },

    edit: function(id) {
        var doc = new Document({ id: id });
        doc.fetch({
            success: function(model, resp) {
                new App.Views.Edit({ model: doc });
            },
            error: function() {
                new Error({ message: 'Could not find that document.' });
                window.location.hash = '#';
            }
        });
    },

    index: function() {
        var documents = new App.Collections.Documents();
        documents.fetch({
            success: function() {
                new App.Views.Index({ collection: documents });
            },
            error: function() {
                new Error({ message: "Error loading documents." });
            }
        });
    },

    newDoc: function() {
        new App.Views.Edit({ model: new Document() });
    }
});

Models:
var Document = Backbone.Model.extend({
    url : function() {
      var base = 'documents';
      if (this.isNew()) return base;
      return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + this.id;
    }
});

Views:
edit.js
App.Views.Edit = Backbone.View.extend({
    events: {
        "submit form": "save"
    },

    initialize: function() {
        _.bindAll(this, 'render');
        this.model.bind('change', this.render);
        this.render();
    },

    save: function() {
        var self = this;
        var msg = this.model.isNew() ? 'Successfully created!' : "Saved!";

        this.model.save({ title: this.$('[name=title]').val(), body: this.$('[name=body]').val() }, {
            success: function(model, resp) {
                new App.Views.Notice({ message: msg });
                Backbone.history.saveLocation('documents/' + model.id);
            },
            error: function() {
                new App.Views.Error();
            }
        });

        return false;
    },

    render: function() {
        $(this.el).html(JST.document({ model: this.model }));
        $('#app').html(this.el);

        // use val to fill in title, for security reasons
        this.$('[name=title]').val(this.model.get('title'));

        this.delegateEvents();
    }
});

index.js
App.Views.Index = Backbone.View.extend({
    initialize: function() {
        this.render();
    },

    render: function() {
        $(this.el).html(JST.documents_collection({ collection: this.collection }));
        $('#app').html(this.el);
    }
});

notice.js
 App.Views.Notice = Backbone.View.extend({
        className: "success",
        displayLength: 5000,
        defaultMessage: '',

        initialize: function() {
            _.bindAll(this, 'render');
            this.message = this.options.message || this.defaultMessage;
            this.render();
        },

        render: function() {
            var view = this;

            $(this.el).html(this.message);
            $(this.el).hide();
            $('#notice').html(this.el);
            $(this.el).slideDown();
            $.doTimeout(this.displayLength, function() {
                $(view.el).slideUp();
                $.doTimeout(2000, function() {
                    view.remove();
                });
            });

            return this;
        }
    });

    App.Views.Error = App.Views.Notice.extend({
        className: "error",
        defaultMessage: 'Uh oh! Something went wrong. Please try again.'
    });

The app:
var App = {
    Views: {},
    Controllers: {},
    Collections: {},
    init: function() {
        new App.Controllers.Documents();
        Backbone.history.start();
    }
};

A: If you are using backbone 0.5.x the Backbone.Controller was renamed to Backbone.Router
From the documentation:

Upgrading to 0.5.0+
We've taken the opportunity to clarify some naming with the 0.5.0 release. Controller is now Router, and refresh is now reset. The previous saveLocation and setLocation functions have been replaced by navigate. Backbone.sync's method signature has changed to allow the passing of arbitrary options to jQuery.ajax. Be sure to opt-in to pushState support, if you want to use it.


text:
Q: Autenticação Spring Security PROBLEMA
Como faço para que o spring security redirecione para a página personalizada do meu projeto?
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@EnableWebSecurity
public class WebSecurityConfig implements WebMvcConfigurer{

    @Bean
    public UserDetailsService userDetailsService() {
        InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
        manager.createUser(User.withDefaultPasswordEncoder().username("user").password("pass").roles("USER").build());
        return manager;
    }

    protected void configure(HttpSecurity http) {
        try {
            http.authorizeRequests().anyRequest().authenticated().and().formLogin().loginPage("/page").permitAll();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

page.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:url value="/" var="url" />
<!DOCTYPE html>

<meta charset="ISO-8859-1">
<link rel="stylesheet" href="${url}assets/css/style.css">
<link rel="stylesheet" href="${url}assets/css/grade.css">
<title>ERP - LOGIN</title>

                            <form action="login" method="Post">

                                        Usuário
                                        <input type="text" name="username" class="form-campo" placeholder="Usuário" />

                                        Senha
                                        <input type="text" name="password" class="form-campo" placeholder="Senha" />

                                    <button type="submit" class="btn btn-azul d-block m-auto">Entrar</button>

                            </form>

A: Para resolver o problema tive que utilizar a classe WebSecurityConfigurerAdapter.
Segue como ficou a classe de autenticação do projeto de uma forma simples.
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Bean
    public UserDetailsService userDetailsService() {
        InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
        manager.createUser(User.withDefaultPasswordEncoder().username("user").password("pass").roles("USER").build());
        return manager;
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().anyRequest().authenticated().and().formLogin().loginPage("/autenticacao/login").permitAll();
        super.configure(http);
    }

}

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/autenticacao")
public class AutenticacaoController {

    @GetMapping("/login")
    public String formLogin() {
        return "login";
    }

}

    <form action="login" method="Post">

          Usuário
          <input type="text" name="username" class="form-campo" placeholder="Usuário" />

          Senha
          <input type="text" name="password" class="form-campo" placeholder="Senha" />

        <button type="submit" class="btn btn-azul d-block m-auto">Entrar</button>

</form>


text:
Q: Multiple SQL statements in SQL Developer with DB2 I'm using Oracle SQL Developer v4.1.2.20 with an IBM DB2 v10.5 database.
Why can I select and run multiple statements like this:
drop trigger T_MyTab1;
drop trigger T_MyTab2;

But If I select these 2 statements it fails:
create trigger T_MyTab1 after insert on MyTab1 referencing new as n for each row mode db2sql insert into MyAuditTab1 values (n.col1);
create trigger T_MyTab2 after insert on MyTab2 referencing new as n for each row mode db2sql insert into MyAuditTab2 values (n.col1);

The error is:
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=create trigger T_MyTab1 after inse;BEGIN-OF-STATEMENT;<space>, DRIVER=3.69.24

The same SQL works fine in SquirrelSQL, so I think it's to do with the line delimiter in SQL Developer...


text:
Q: PIL encoder jpeg not available
Possible Duplicate:
pip install PIL -E TICKETS-1 - No JPEG/PNG support

I'm working on a picture cropper, and I'm having trouble with my form validation. The form is validated when uploading a GIF picture, but any other format I try raises the following exception:
Upload a valid image. The file you uploaded was either not an image or a corrupted image.

Form
<form enctype="multipart/form-data" method="post" action="/pic/">{% csrf_token %}
    {{ form.as_p }}

<input type="submit" value="View uploaded image">

    <input type="hidden" name="stage" value="crop">
</form>

View
if request.method == 'POST':
        form = ProfilePicForm(request.POST, request.FILES)
        if form.is_valid():
            *do stuff*
        else:
            logger.debug('Form errors == [%s]' % form.errors)

I have installed libjpeg-dev(using apt-get) before installing PIL(using easy_install). At first, I thought this might be due to an incorrect installation of either libjpeg-dev or PIL, but would the problem persists for other formats like png? This problem does in fact occur for png images as well. I'm not getting a jpeg decoder problem, so I'm thinking it's not that, but I'm not sure. Also, I'm using the django development server.

Update
I decided to try a reinstall of PIL. I deleted my PIL install folder
/usr/local/lib/python2.7/dist-packages/PIL
 and my PIL.pth file (in the same dist-packages folder). I ran the setup.py script using sudo python setup.py install. I then ran the selftest.py script, and it fails on the first test:
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from ./PIL
--------------------------------------------------------------------
--- PIL CORE support ok
*** TKINTER support not installed
*** JPEG support not installed
*** ZLIB (PNG/ZIP) support not installed
*** FREETYPE2 support not installed
--- LITTLECMS support ok
--------------------------------------------------------------------
Running selftest:
*****************************************************************
Failure in example:
try:
 _info(Image.open(os.path.join(ROOT, "Images/lena.jpg")))
except IOError, v:
 print v
from line #24 of selftest.testimage
Expected: ('JPEG', 'RGB', (128, 128))
Got: decoder jpeg not available
1 items had failures:
   1 of  57 in selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.

I'm not sure how to get PIL to work with the unsupported modules listed above. I can verify that I have zlib1g-dev, libfreetype6-dev, liblcms1-dev and libjpeg62-dev, and the libraries themselves installed on my system because when I try to install them with apt-get, it says I already have the latest version.

A: Try downloading PIL from source, then edit setup.py adding this line:
add_directory(library_dirs, "/usr/lib/i386-linux-gnu")

before this line (214):
add_directory(library_dirs, "/usr/lib")

then
sudo python setup.py install

It should work now


text:
Q: How do I create a footer that is fixed at the bottom of the screen but when the user scrolls down it is no longer fixed footer? This is what I am trying to do:
I want to create a footer that sticks to the bottom of the user's screen regardless of the screen size.  But when the user scrolls I want to be able to change the header from being fixed to going down as part of the page when the user scrolls down.  I am new to JS but i've tried a few things such as this:
 $(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function (e) {

                var theEvent = e.originalEvent.wheelDelta || e.originalEvent.detail * -1;
                if (theEvent / 120 > 0) {
                    if ($(window).scrollTop() == 0) {
                        $("#content_under_fixed_footer").hide();
                    }
                }
                else {
                    if ($(window).scrollTop() < $(document).height() - $(window).height()) {
                        $("#content_under_fixed_footer").fadeIn(2000);
                        $(".fixed_header").css("position", "relative");
                    }
                }
            });

If I use the script above, the trigger is not right.  If the user has a large screen there is no scroll but if the window is shortened it relatively works well.  Please help i need to submit this today and I'll try any solution.  Thanks!

A: Have a look at this:
<title>Test</title>

This way you can use the screen.width and screen.height directly, and calculate everything based on that.

A: HTML:

footer

Style:
.footer {
    position: fixed;
    bottom: 0;
}

Jquery:
$(window).scroll(function(){
if($(window).scrollTop('0'){
} else {
   $('.footer').css('position', 'relative');
}
});

This should work

A: You mean something like this? (jsFiddle)
HTML

    Something

CSS
body
{
    margin: 0;
}

#content
{
    position: absolute;
    height: 1000px;
    background-color: red;
    width: 300px;
}

#wrapper
{
    position: absolute;
    height: 100%;
}

footer
{
    position: absolute;
    bottom: 0px;
    width: 300px;
    text-align: center;
    background-color: darkred;
}

A: Important: height of footer, padding below content, margin 0 for html and body
Copy and paste the content inside the content to make it longer than height of window
HTML

HEADER

CONTENT

CONTENT

CONTENT

CONTENT

FOOTER

CSS
html, body {
    height: 100%;
    padding: 0;
    margin: 0;
}

.wrapper {
    min-height: 100%;
}

.content {
    padding-bottom: 50px;
}

.footer {
    height: 50px;
    background: #f00;
    margin-top: -50px;
}

jsFiddle: http://jsfiddle.net/8QrGm/


text:
Q: Как указать бинарный файл браузера в Selenium WebDriver Java? Или как решить ошибку, описанную ниже? Selenium-java 4.7.2
Java 19.0.1
при выполнении кода
public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver", "C:\\Users\\Username\\IdeaProjects\\project\\drivers\\geckodriver.exe");
        FirefoxDriver driver = new FirefoxDriver();
        driver.get("https://google.com");

появляется ошибка

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

Насколько я понял, FireFox у меня установлен не в стандартный каталог, поэтому нужно вручную указать путь к firefox.exe. Как это сделать? Пробовал
public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver", "C:\\Users\\username\\IdeaProjects\\project\\drivers\\geckodriver.exe");
        FirefoxBinary binpath = new FirefoxBinary(new File("C:\\Program Files\\Mozilla Firefox\\firefox.exe"));
        FirefoxDriver driver = new FirefoxDriver();
        driver.get("https://google.com");
    }

Та же самая ошибка, полный текст ошибки:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
1672419301824   geckodriver INFO    Listening on 127.0.0.1:14274
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
Host info: host: 'DESKTOP-3NVOT8O', ip: '192.168.100.7'
Build info: version: '4.7.2', revision: '4d4020c3b7'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '19.0.1'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}}], desiredCapabilities=Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}}}]
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:148)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:106)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:535)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:228)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:156)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:130)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:111)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:101)
at Main.main(Main.java:14)

Process finished with exit code 1