domingo, 14 de fevereiro de 2016

General error: 1364 Field 'id' doesn't have a default value

Hi!

The id you defined for your entity is not identity. It must be!

Good luck!

Error: SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value
If you are using SQL keywords as table column names, you can enable identifier quoting for your database connection in config/app.php.
SQL Query:
INSERT INTO projetos (user_id, nome) VALUES (:c0, :c1)

sexta-feira, 12 de fevereiro de 2016

Transform SELECT INTO HTML / XML / SQL SERVER / td=

Hi!

I have to say this is a little bit too hermetic for me, but it works.
This is an example of how to transform a SELECT into  HTML format.
Notice that it shows how to add color to each cell (td).

This example is priceless.

If you have any doubt, leave a comment.

Good luck!




SET @html = 
cast((
select
      td=NICK,'',
      td=REPLACE(RTRIM(CONVERT(CHAR(15) , CAST(unit AS MONEY) ,1)),'.00',''), '',
      td=RTRIM(CONVERT(CHAR(15) , CAST(sale AS MONEY) ,1)),'',
      td=REPLACE(RTRIM(CONVERT(CHAR(15) , CAST(TICKETS AS MONEY) ,1)),'.00',''), '',
      td=REPLACE(RTRIM(CONVERT(CHAR(15) , CAST(FLUXO AS MONEY) ,1)),'.00',''), '',
      td=PA, '',
      td=TM, '',
      td=CONVER, '',
      cast(case when GOAL_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
      td=GOAL_P, '',
      cast(case when UNIT_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
      td=CONVERT(NUMERIC(11,0),UNIT_LY_DAY_P), '',
      cast(case when SALE_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
      td=CONVERT(NUMERIC(11,0),SALE_LY_DAY_P ),'',
      cast(case when TICKETS_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
      td=CONVERT(NUMERIC(11,0),TICKETS_LY_DAY_P), '',
      cast(case when FLUXO_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
      td=CONVERT(NUMERIC(11,0),FLUXO_LY_DAY_P), '', 
      cast(case when PA_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
      td=CONVERT(NUMERIC(11,0),PA_LY_DAY_P), '', 
      cast(case when TM_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
      td=CONVERT(NUMERIC(11,0),TM_LY_DAY_P), '', 
      cast(case when CONVER_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
      td=CONVERT(NUMERIC(11,1),CONVER_LY_DAY_P),''
FROM [table]
WHERE field LIKE '??%'
ORDER BY convert(numeric(11,1),GOAL_P) DESC
FOR XML path('tr'),type) as nvarchar(max))
+'</table>'

quarta-feira, 10 de fevereiro de 2016

IMPORTANT/ BAD, BAD, REALLY BAD **** COURSERA WIPED ALL ALL MY CERTIFICATES AND MY PREVIOUS ACTIVITIES

Do you know COURSERA?

Well let tell you something. Today, I logged in, and all my certificates were gone, for good.

That's the message I wrote to them.


Hi!
All my certificates are gone.
All my activities were erased.
What are you doing?
Do you have any idea of how many hours I dedicated to earn those certificates?
My account was completed wiped out.
When we start a course, there's a code of honor to follow. Are you following any code of honor?
If you are a honorable organization, you will find out what happened.
Even the certificates that were linked to my linked in account were deleted.
What's wrong with you guys?
I have seen people and organizations loosing face, but you are by far the worst example.
I will not write regards in the end of this message, because I just know how to finish this.

Yes, I know, I was a little bit dramatic. But I'm not overreacting. I did spend a lot of hours of studying to get my certificates. My data science certificates are gone, and they pretty hard to achieve.

This is was my biggest disappointments in years concerning to an institution.

This is sad. Really sad.

terça-feira, 9 de fevereiro de 2016

cakephp 3 installation issue - unexpected T_OBJECT_OPERATOR in config/bootstrap.php on line 107

Hi!

You have just deployed your applicaton and you received this error

unexpected T_OBJECT_OPERATOR
?

Don't worry, it's the version of your PHP.

I changed from 5.3 to 5.5.

Yeah, I have no time keep investigating, so I decided to go to 5.5.

It worked.

Good Luck!



segunda-feira, 8 de fevereiro de 2016

Can't logout on Chrome? Maybe Chrome is not the problem.


Hi!

I was having this issue. Then I found Raffi's answer. Which is perfect.
In my case, only admin was able to logout.
Then he made me understand that I forgot to define that, if you are not admin, you also can logout!

        public function isAuthorized($user)
        {

                $action = $this->request->params['action'];

                if (in_array($action, ['logout']))

                {
                   return true; // If user wants to logout, ok for everyone.
                }
                else
                {
                    // If he or she is not trying to logout, then, if the role of the user is admin, anything goes
                    if (isset($user['role']) && $user['role'] === 'admin')
                    {
                         return true;
                    }                  

                    return false;
                }



                // Default deny
                //return false;
         
        }

Hope it helps!

Good luck!

http://stackoverflow.com/questions/27232679/cakephp-3-users-not-allowed-to-logout

Login, Logout is making you insane? / CakePHP 3.0 / That's how I did.

Hi!

This thing of login, logout is p. in the a.. Well that's how I did mine

        $this->loadComponent('Auth', [
                'authorize' => 'Controller',
                'authenticate' => [
                'Form' => [
                'fields' => [
                'username',
                'password' => 'password'
                ]
                ]
                ],
                'loginAction' => [
                'controller' => 'Users',
                'action' => 'login'
                ],
                'loginRedirect' => [
                                'controller' => 'Users',
                                'action' => 'index'
                            ],
                'logoutRedirect' => [
                                'controller' => 'Users',
                                'action' => 'login'
                            ]                        
                ]);
                // Allow the display action so our pages controller
                // continues to work.
                $this->Auth->allow(['display']);
    }

Hope it helps.

Good Luck!


quarta-feira, 3 de fevereiro de 2016

Does PowerPivot from Microsoft works? Yes!

Hi!

I have been recently working with million of records.
Normal excel worksheets do not support more than 1.000.000 records or lines, as you prefer.
But I still have to work with excel (this is a client compliance).
How did I deal with that?
Using PowerPivot.
It imports 2.600.000 records in less than a minute.
The performance of his pivot table is as well as good.
So, if you are facing the same scenario as I am, PowerPivot can be your solution.

Good luck!


segunda-feira, 1 de fevereiro de 2016

A different way to create temporary table

Hi!

Today somebody teached me a new way to create temporary table and I found it really cool.

This is a way to create a temporary table cloning only the definition of the original table.

SELECT * INTO #TEMP_CLIENT FROM  CLIENT  WHERE 0 = 1

Isn't it cool?

Good luck!