01/19/2017

How do I turn off the flymake, or alternativly find way to fix the warnings it shows me?

Here’s what I found about

  • Flymake to check format of the code, and make sure it adhears to python standards
  • Yapf is a package that reformat the code according to the standard.

To get Flymake to work, I needed to enable flymake-mode Then run C-c C-v to get the list of errors. I can go error by error and fix. But I can also do C-c C-r f to run auto refactoring. In this case Elpy is using the refactoring package (Yapf) to reformat the code.

At first I had an error, and although I had Yapf installed, Emacs kept telling me that it’s not. I found the solution in this issue: Elpy error: yapf not installed

I needed to restart the RPC process, by running M-x elpy-rpc-restart

Ok, with that out of the way, I need to get back to the code.

Advertisements

Accepting, merging and deploying a pull request

Checklist for merging a push request and deploying to heroku:
1. Accept the PR request
2. Merge PR request into master
3. Pull the version to my local:
~/path/to/project(master)$ git pull [remote] master

This will override my local with the current version in the remote (either GitHub or bitbucket).

  1. Push master to heroku:
    ~/path/to/project(master)$ git push heroku master

01/12/2017

Back to working on the project. I want to add simple db support, so when I get a request from Alexa, I’ll check if the user is new or returned. If new – store the uuid in the db. If returning, give a returned user message.

Later I can also add context to the db, so I can manage contexts and states not only within session, but also accross sessions.

So, connecting to db – that’s something I did in the “My Clipboard” skill. I’ll go and look there how I did it.

Ok, I copied the set of functions from the clipboard app, but I now get an error when trying to call from Alexa – the entries table isn’t exsit… I remember that I had to do some manual creation of tables, but I don’t recall what exactly I needed to do.

Oh, I see what I’ve missed. I needed to create a schema.sql file, that defines the table I would like to create.

Here’s an article that is a good reference: Intro to Flask: Creating and Writing to Databases

And by the way, I’m moving to use Sublime for now… I spend too much time tinkering with Emacs, and not doing productive work… I will keep writing this in Emacs though, because it’s an org file.

Ok, back to Emacs. I guesse I’m more used to it than I thought…

I added the db support. I now want to check if a user is new or return. First time I see a user, I add the user to the db. Then I fetch from the db to check new or return. I had a problem with checking if I get a row from the db. Used this stack-overflow answer. The gist:

  • Excecute the query with count(*)
  • Grab the fetchone() with index 0
  • Test if I get 1 or 0. If 0, then there was no result from the query.
@ask.launch
def launched():
    # check if the user is new or return
    db = get_db()    
    c = db.execute('select count(*) from users where user_id = ?',
                 [format(session.user.userId)])


    data = c.fetchone()[0]
    if data == 0:
        # new user - insert to db and play new user welcome
        db.execute('insert into users (user_id) values (?)',
                  [format(session.user.userId)])
        db.commit()
        return question('Welcome to out brain! I will be your personal editor. To start, say headlines, sites, topics or categories')
    else:
        return question('Welcome back! What do topic are you interested in today?')

Many times I need to…

Many times I need to suggest times when I’m available. What I then need to do is go to my calendar, see what slots are available and manually get the dates and times and put it together in a reply. Very often I’m making a mistake, getting the date or the time wrong.

I want to be able to see my calendar, click on a certain time slot, and have it ready in my clipboard, so I can paste it wherever I want.

I would like to be able to do it in Python.

There’s a workflow in the workflows app, called “share availability”, that’s doing something similar. I might be able to use it as reference.