Saturday, September 1, 2018

Be Bored Challenge

One of the best ways to help us become happier is by creating:

Creativity Requires Passive Thinking Time

If we want to create something no one else has created before, we need to think of things that no one has thought of before. Thinking of things that no one has thought of before requires thinking time. It would be nice if we can just schedule an hour to invent our new idea, then sit down during that hour and accomplish it. However, our best ideas do not come on a schedule.

Our best ideas usually come during, what I call, passive thinking time. Passive thinking occurs almost subconsciously. We can't plan passive thinking time. It occurs as we let our mind wander, while we are driving, walking, and doing "mundane" tasks like the dishes, showering, etc. It is during this time that our mind can explore new ideas that we haven't thought about before. Then, later, when we get time to work on our project, we can implement the ideas we have created.

In order to be creative, we need this passive thinking time. Most people make a few additions or revisions to a project they are working on, then take a break, and come back to add some more. What most successful problem solvers do while taking a break is passively think about the next problem they need to solve.


However, if our break time only consists of looking at a screen, we won't spend a lot of time thinking about the next task we need to accomplish. Instead, our efforts will be distracted. If we find something that interests us on social media, news sites, or TV shows, our "subconscious" will focus on solving problems we can do little about.  Instead of inventing our next step, we will focus on the distraction and put our passive problem solving effort towards the distraction.

For example, if we read a political news story that upsets us, we will try to come up with a counter argument. If we find a sad story on social media, we will try to come up with a way to fix it. If we see a cool picture of someone's vacation, we will try to figure out how we can go on that vacation.

Now, I am not suggesting that successful problem solvers always think about their projects. But I am saying that a large portion of our efforts need to be focused on our problems and not on distractions. What we need is undistracted time set aside when we can let our creative, subconscious mind work for what we want most.

We also need passive thinking time to hear the whisperings of the spirit, that can help guide us to better solutions. Elder Ballard said (in April 2018), "If we do not find time to unplug, we may miss opportunities to hear the voice of Him who said, “Be still, and know that I am God.” (Palms 46:10) Now, there is nothing wrong with taking advantage of the advances in the technologies inspired by the Lord, but we must be wise in their use." Our challenge is retain our creativity with these devices. 

Intent Driven Device Usage

We need is to be in charge of how we use our devices, and not let our devices control us. In order to achieve maximum effectiveness we need two things: 
  1. When it is time to work, we need to make sure that our devices will not distract us from the task at hand.
  2. We need passive thinking time. We need to be bored so our minds can passively solve the problems we are focusing on.
What that means is that we need to be wise in how we use our devices, as stated by Elder Ballard (above). So here is my "Be Bored Challenge".

The Challenge

  • Set a time limit on how much time you want to spend on social media, news sites, and other distractions. Decide when the best time is to visit these sites, and make rules about not visiting these sites outside of those times. Use apps and settings to enforce these rules if you cannot keep them by yourself.
  • Turn off all notifications that are not urgent so that you will not be pulled in to a  distraction.
  • Make sure you have plenty of passive thinking time.
    • Don't use your device during meals, bathroom trips, while walking to places, etc.
    • Don't use your device while in a conversation with other people.
    • Have defined unplugged time every day.
    • Don't check your device for the first 30 minutes to 1 hour after you have woken up. That way you can passively solve the problems you feel are most important to you.
  • Make sure you find healthy ways to replace the "excitement" (or dopamine) you used to get from your device. Exercise, talk with others, and most importantly - create something.

Tools to Help

  • iOS 12 will come with a new feature that will allow you to set time limits on apps and plan for distraction free time. For Android devices, search for an app that can do the same thing.
  • WasteNoTime is a browser extension that works in Chrome and Safari, and allows you to set time limits on websites you visit. If also has a lockdown mode that will block sites for an adjustable amount of time.
Leave other tools you find in the comments.

Thursday, September 28, 2017

AWS Lambda Functions with DynamoDB and APIGateway

I had a hard time gathering all the information that I needed to be able to deploy a simple API to AWS. I didn't just want to create things in the AWS console because I cannot script it. Scripting allows me to redeploy my work with very little effort.

So, to automate deployment, I can see 2 options. One option is to create a Python script using the Boto3 library. The script would create the DynamoDBs, the lambda functions, and setup the API Gateway. The other options was using CloudFormation. CloudFormation allows organization to automate their deployment. However, CloudFormation is a lot of work and takes a lot of time to learn.

So, I was told about handel. Handel runs on top of CloudFormation and simplifies the deployment setup.  All you need to do is setup an handel.yml file that will generate the CloudFormation template. Of course, since handel is less complex, you do lose some of the functionality of CloudFormation.

You can see all of the setup in this GitHub repo:

It get it to work, I just installed node.js on my machine. Then install handel using npm (according to the handel docs). I also had to setup an account configuration file. The docs say it is hard to configure,  but you should be able to find all of the values you need in the console. You can find the account id in the IAM, and the VPC information in the VPC area. Just look in the sidebar for Your VPC's, and subnets. Once you click on them you should see ids (vpc-XXXX, subnet-XXXXXX). Add them into your config file. For the subnets add all of your subnets into the public, private and data subnets. You can find the ssh_bastion_sq in security groups. You don't need the last 2 lines.

After that I wrote the handel.yml file. This is where I described DynamoDB I wanted to create and connected it to an API Gateway. I described the API Gateway using a swagger.yml file. (I suggest YAML over JSON because it is easier to type.) The swagger file will contain all of your paths, and link each path up to a lambda function. You can also describe your API parameters and responses. Check out the swagger.yml file for an example.

Then you can deploy it by running the command handel -c <path to account config> -e dev -v 1.

If you notice, I added security to my API, so that I can limit who calls my API. Without security, anyone can call your API, (and rake up your bill). I went with simple API_KEYS. I didn't find a way for handel to set that up, so I had to do it in the AWS console. Under API gateway, on the sidebar you can find API_KEYS. Create a key. Then you have to create a usage plan. I limited API calls to 1/second while testing. I can't imagine me being able to send more that one request per second. Finally you have to add the plan onto your API stage. 

You will see that the swagger documents puts security on the API paths, with a security definition section below.

To test it, use curl:
 curl -H "x-api-key: generated-api-key" -d '{"device": "curl", "lat":"1.1", "lon":"2.2"}'

Another thing that took me some time was errors. I started to play with API Gateway integrations. However, since you have a lambda function, it can return what needs to be returned. Look in the python code for the error handling.

Friday, November 4, 2011

Getting delayed_job to Work with Rbenv and Mongoid

Rbenv is another option that we can use besides RVM to be able to manage different Ruby versions.  I have always struggled getting RVM to manage everything right, from gemsets to bundles. Since Bundler manages your gems and dependencies for you, gemsets are just an extra layer that caused me a bunch of problems.  So I switched to Rbenv for my production environment.  All went well except delayed_job. It would work just fine with rake jobs:work, but script/delayed_job start would start just fine, but wouldn't pull anything from the database. I am using Mongoid, so I assumed that the script was defaulting to the sqlite database.

Well, I looked at the script and noticed that their was a shebang at the top mentioning ruby (#!/usr/bin/env ruby). I just changed it from ruby to ruby-local-exec and it started working again! This made the script run in the bundled environment and pick up on that fact that I am using Mongoid instead of sqlite. Hope this helps someone.

Tuesday, October 25, 2011

Another Rails Editor and User Authentication

Just another update for any of my past students following along.  Redcar seems to have won over all of the students as their favorite Rails editor.  To install it, you just type "gem install redcar".  It looks pretty promising.  The students found it on their own, and preferred it to Sublime Text Edit, mostly because it's free and doesn't ask you to pay for it every 10 minutes.

Also, we have been working on developing authentication systems, and the following videos are videos that I have been using for the class.


Migrating from Wordpress to Blogger

Here are some detailed instructions on how I moved my blog from Wordpress to Blogger, including how to get my old Wordpress links to redirect to my new blogger style links.  I would like to thank Jesse Stay for his blog post that convinced me to switch and gave me a head start in the process.  After the switch, I also learned that Google+ will integrate with Blogger, so that is even more of an incentive.

This should work with a self-hosted Wordpress blog and a blog.  If you don't have your own domain, you can transfer your blog to Blogger, but you will not be able to preserve and redirect your old links.

Before you begin, you might want to use OpenDNS for your DNS on your local machine. You can refresh the DNS cache at any time, so you can see your changes immediately instead of waiting up to 2 days for the DNS cache to expire. Plus using OpenDNS has many benefits. Instruction for configuring your local machine to use OpenDNS can be found here.

Also, if you want to redirect your old Wordpress style URL's to your new Blogger style URL's you will need a server somewhere that will handle the redirections.  If you don't have one, you can use Heroku for free.  I will show you how to set it up, but you will need Git, and Ruby installed on your machine.  Mac users already have ruby installed (they might need to install x-code from the app-store), and they can get git from here.  I also recommend installing RVM to install Ruby version 1.9.2. Window's users can get Ruby and Git (and a lot of extras) from You only need Ruby, Git, and Bundler, so you don't have to install all of the packages. I don't have a Windows machine to try it out, so this is just my best guess.

We will be doing the following steps to make the transfer from Wordpress to Blogger:
  1. Exporting the posts and data out of Wordpress and importing them into Blogger.
  2. Configure Blogger to meet our needs.
  3. Set up a redirection server that will redirect Wordpress style links to Blogger style links.
  4. Transfer the domain from Wordpress to Blogger.
  5. Install Disqus comments (if you want to use it) on Blogger and migrate all of the discussions.
I organized the steps to reduce the amount of downtime your blog will face. You should be able to keep the blog up the full time, but your readers might not be able to comment until the DNS changes have fully propagated. Also, you will lose all of your Facebook likes and +1's, except on your main domain.  Facebook/Google will not follow your redirections and combine the old Likes/+1's with your new ones.  If this is unacceptable, then you will need to stay with Wordpress.

Exporting your posts from Wordpress and importing them into Blogger.
To export your Wordpress post and import them into Blogger just follow these instructions. My blog was less than 1MB, but if you have a bigger blog, you will have to download the converters and run them manually. More details on that process can be found here.

You should create a new Blogger blog, and don't worry about the URL if you have your own domain. Once it is up you can change the URL to the right domain. After you import your Blogger file, you should see all of your posts and comments. They will all be drafts, and you can select them all and publish them.

There are a few things that might be a lot of work after you complete this step. First of all, all the pictures will work, but only until you move your domain to Blogger. They are pointing to your Wordpress blog, so once your domain is moved over, they will stop working. You will need to get them off of your old blog and upload them to Blogger, or somehow host them on your redirection server. I didn't have many picutres, so I just uploaded them to Blogger, but I will describe how you can host them on the redirection server. Also, on Blogger, your urls will be missing words like "the", "a", and "with". Which will create a little bit more work down the road, but I'm not sure if you can do anything about that.

Configure Blogger
You can look at all of the settings.  I wouldn't set your domain until after you have the redirections in place. You can also take the time to edit the layout and add widgets to the side.  Make sure your happy with how it looks, so you will know if you want to continue or not. Your Wordpress blog should still be up. You can also add your Facebook like buttons I described in the previous post.  Don't install Disqus until after you have your redirections in place either.

Now is also a good time to follow these instructions to get your author picture in your search results.  You can also see Google's instructions as well.  What I did was create an About page and linked to it with a text widget (not the page's widget) that is included on all pages in my blog. I edited the HTML to include the a link with rel="author" in it. On the About page, I have a picture, short bio, and a link to my Google+ profile with rel="me". Make sure the Google+ link begins or ends with a +, or is a profile button, with rel="me" in the anchor tag (not rel="author").

Set up your redirections
To redirect your Wordpress style URL's to your new Blogger blog, you will need a server to handle the redirections. If you have an Apache server, you can use the rewrite mod to create the redirections. Below is a sample .htaccess file that I used to redirect my links.  You will need to customize it for your domain.  The redirection server needs to be a sub-domain of your domain. So if you host your blog at or, your redirection server needs to be (I used

Here is the .htaccess file I used before I thought about using Heroku.

The .htaccess file includes redirections for my author page, about page, categories, tags, the feed, and the posts.  In Blogger, there are just labels, so both categories and tags redirect to the label pages. I also had to add in some rules to redirect posts where Blogger didn't include words like "the" and "a" in the URL.  You will need to search for these and add in those redirections as well.

If you don't have a server to host the redirections (I migrated to ditch the server), you can use Heroku for free.  When I was trying out different blog solutions, I ran across toto and learned a little about Rack.  Since I develop in Rails, I really wanted to make toto work, but I couldn't easily migrate my posts. But I did learn enough to know that I could use Rack to redirect URL's. I created a simple Rack app that would redirect the URL's, and even host some static assets. You can use this app to redirect your URL's and even host your pictures from Wordpress.

I uploaded my app onto Github.  If you want to use it, just clone it and change the file. Again, you will need Git, Ruby, and Bundler installed on your machine. You can then use Heroku to host your redirection server.  Here is my file that you will need to change:
You should change the root to your domain, and then change the author page. You can remove my specific post redirections and add in your own.

To pull the code to your machine, in the terminal or commad prompt type:
git clone

 Then you should have a wp2blogger-redirector directory.  Change into the directory and edit the file.  You can test it by typing in the terminal or command prompt: rackup.  This will start the server on your local machine.  Then in a browser goto http://localhost:9292. You should see "Nothing Here". You can then type the Wordpress URL after the :9292 (like http://localhost:9292/2011/09/blog-post/) and you should be redirected to the right URL (  As you fix things, remember that your browser will cache the redirections, so you need to clear the browser cache if something goes wrong and you want to retest it.  Also, every time you make a change to, you will have to kill the server and start it up again (Control-C, and then type rackup again), or install the shotgun gem ("gem install shotgun").  Then you can launch the server by typing: shotgun.  It will start the server on 9393 instead of 9292, and you shouldn't need to restart it after changing the file (but if things aren't working you might want to try restarting it before you pull all your hair out).

You can also add in your old pictures by copying the /wp-content/uploads directory into the public directory. You will also need to add in the /wp-content to be served statically. To do this change line 3 in the file to be:
use Rack::Static, :urls => ['/index.html', '/favicon.ico', '/wp-content'], :root => 'public'

You can also test to make sure the server serves your old pictures. Heroku will only let you use 100MB in disk space.  So you might need to delete some pictures. Wordpress does store several sizes of pictures, and you can remove all of the sizes you don't use on your blog.

After you get the redirection server working locally, you can push it to Heroku.

To commit the changes locally, type:
git add -A
git commit -m "some message"

Then create an account on Heroku. You can follow these instructions to launch your server on Heroku.  Don't worry about bootstraping your database, you don't have one. In summary type the following:
heroku create
git push heroku master

If everything worked your redirection server should be live. Test it by typing heroku open, and you should see it in your browser. Remember the URL, because you will need it when changing your DNS.

Migrate your domain to blogger
Now you are ready to migrate your domain.  First create a CNAME record in your DNS to point to Heroku, and follow these instructions for adding the subdomain to your Heroku app (you are probably not on the Cedar stack).  You only need to add one subdomain, not your full site.    While you are at it, you can now point your main domain (or a subdomain) at your new blog and edit your new blog's settings to add your domain.  It's under Settings -> Basic. You will also want to add a missing files host, and put in "old" (if you used for the name of the host.  Blogger has a link with instructions on how to set your domain name to point to Blogger that should appear as your change your settings.

If you are using OpenDNS, you can go here, and check their cache. After you check, you can request a cache refresh and it will update the DNS settings from your registrar. (It might take a couple of hours for your registrar to update it's DNS servers.) You will also have to refresh your local DNS cache by rebooting your machine.  Your domain should be pointing to your new blog. Remember, it takes a couple of days for the DNS changes to propagate to everyone, but with OpenDNS you can try it a lot faster.  You should leave your old blog up for at least a few days, so if your readers haven't gotten the DNS update, they will still see your old blog.  You might want to disable comments, because they will not migrate over to your new blog.

Migrate Disqus comments
You can now install Disqus on your Blogger blog, by going to, logging in, clicking on your blog, and then clicking the install tab.  Click on blogger, and it will install it to your blog. You will then need to edit your layout in Blogger, to add the widget (preferably on the bottom). You should see Disqus take over for your comments, but all of your old comments will be gone.  Now, back in Disqus, go to tools, migrate threads.  You can try the redirect crawler, if your redirects are all set up. You can also upload a URL map.  Once done, your comments should re-appear.

Unfortunately, your likes and +1's will be reset. You should now be up and ready to to go. Hopefully, Google+ integration, and a free hosting solution will make all the work worth it. If you have any questions, just leave them in the comments.