Monday, June 22, 2015

Windows, Nginx, MariaDB...and sometimes SQLServer

I have a couple projects at work that are quite different.

All are using PHP.

Some projects require connecting to MSSql (SQL Server).

Other projects are Drupal based.

I had been using XAMPP for awhile now, but knew I wanted to use Nginx on Windows, so I finally took the leap and got it running.


Here's a great stack to use for Windows, PHP, Nginx, XDebug, and MariaDB:  http://wpn-xm.org/


Now, in my case I needed to interface with a SQL Server database for other projects. The Microsoft Drivers for PHP for SQL Server are located here: https://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx

BUT (at the time of this writing) PHP 32-bit is required for these SQL Server drivers, so make sure you download the correct package from WPN-XM. This was my "gotcha" that took awhile for me to get this running. I was getting "could not find driver" even though the correct versions were available.


I've got some more learning to do, but so far I've got multiple projects running with some accessing MSSQL and others MariaDB, all using Nginx and PHP. The speed difference compared to Apache is remarkably noticeable.

Also for my Drupal projects, I was able to do a simple export from MySQL and then an import into MariaDB. My Drupal sites needed no changes in-order-to run, other than a server config in the nginx.conf file.





Wednesday, May 20, 2015

Python example to Add task in Todoist

A simple script that will prompt you for a task description and date, then add it to the project in Todoist.


Requires:
* https://github.com/Doist/todoist-python  - View the Readme for installing the todoist-python library
* Python 2.7+
* PIP: https://pypi.python.org/pypi/pip


Code:

import todoist

api = todoist.TodoistAPI('HERE_IS_MY_API_KEY')
task_desc = input('Enter the task: ')
task_time = input('When (optional): ')  
item = api.items.add(task_desc, MY_PROJECT_ID, date_string=task_time)
api.commit()



I just created a simple shortcut in my taskbar and it easily adds tasks to the project ID. I used the Inbox project Id from my account so everything goes in there. I can sort it later.

The "When" parameter recognizes the Todoist date/times such as:
  • today
  • tomorrow
  • 2 weeks
  • 1 month
If you press Enter, instead of adding a date, then the task is still added, but with no date.

Tuesday, April 21, 2015

Multifield - Add value using web service

One little checkbox...that's all it took. Something I didn't understand, but now do just a little better.

Here we are:

  1. Using Multifield module
    1. Multifield is defined as Unlimited Number of values
  2. Using Services with REST server to update a node - adding a value in the list of Multifields
  3. Using Postman to PUT to update that node
  4. Content type name: test_multi
  5. Multifield field name: field_jarod_multi
  6. Multifield subfield name: field_jarod_note, Integer
Here's what the Multifield config looks like by default for jarod_multi:
Note the checkbox is on for "Hide blank items". So when editing a node we see this:
That's fine. If I want to add another, I just use the button and we're good.
BUT it doesn't work when adding another through web services. Doing a PUT will give me a return code of 200, but the value is never added.

To do that, uncheck the "Hide blank items" button which gives a view like this when editing a node:
Now in my web services I do a PUT:

The full value for the Key is 
node[field_jarod_multi][und][2][field_jarod_note][und][0][value]

After the PUT, I get the new multifield value added to the node:

Lots of headaches over this one. I just missed the checkbox.  So glad this one is solved.



Wednesday, February 4, 2015

SMTP Auth Support - Drupal module Gotcha!

In using the SMTP module, I found an error that I really did not expect.

Using the Debug mode of SMTP Auth, I found that the email/password combination I was using was working ok. Auth was always successful. When sending the message, I continued to get "553 Relaying disallowed".

The options for "E-MAIL OPTIONS -> E-mail from address" in the SMTP auth config page were all correct. It should be using this from address to send emails. Nope!

I don't know what made me check the next thing, but I went to "System -> Site Information" and changed the From email address to the one I was using in SMTP auth. Abracadabra, email sending worked.