First WordPress plugin: Add Basic Authentication support to Contact Form 7 API calls

So, I got into WordPress development. Truth is I’ve been working with WordPress for a long time already. What fascinates me about WordPress is leverage. You can quickly turn around new ideas in hours – not days or weeks.

My first WordPress plugin: Add Basic Auth to Contact Form 7 API calls

I hear people having had bad experiences with WordPress when they tried it like years ago… if you’re reading this: give it another shot. It has come a long way.

I’ve picked a client project which if I had needed to do it with Rails it would have taken me at least a week to get it to a stable state. With WordPress I delivered that same day.

PHP really seems very inefficient for building anything a little of larger scope, but people are getting things done.

First steps towards Blockchain development

I’m probably late already to the game, but nonetheless I do want to understand the technology behind Blockchain better, and so I picked Ethereum for my studies as it provides you with tools to build programs that run on top of the blockchain.

My goal is to be able to apply the acquired knowledge to future projects.

I’m taking this awesome course on Udemy called “Ethereum Blockchain Developer: Build Projects Using Solidity”.

What I’ve learned so far:

  • How to create your own local Ethereum network.
  • How I mined my first Ethers. (Kind of feeling rich, except I’m not haha as they’re worth nothing)
  • How to write, test, deploy smart contracts and how to interact with them.
  • How to interact with the Blockchain in the console
  • How to use TestRPC to write smart contracts.
  • Understanding how Ethereum and Blockchain works underneath.

What I still need to learn:

All-in-all a very practical course – I already recommended it to my buddy Cesar Rodas, who also seems to have liked it.

November 27

Today I started taking a course about ReactJS on Udemy. I am serious
about it, because ReactJS presents a new way to write better and faster web
applications.

I also purchased a course about React Native, which is also very
intrigueing because it promises unified and native app development for
Android and iOS with JavaScript only.

I can’t wait to report on both of them.

Oculus Rift app ideas for 2020 or earlier

  1. Bycle riding gamification

    Riding a bicycle is boring. Riding down pretty much the same old ways to work every day?
    What about chasing objectives while you’re riding with your Oculus Rift turning
    routine into a new adventure every day?

    Combine this together with a fitness tracker to automatically adjust distance
    to work depending on your current fitness level.

    A mashup of Google light radar system + Oculus Rift. Pure awesomeness.

  2. Running on steroids

    The Oculus Rift could also make running essentially so much more interesting, as bicycle riding.

    Are you tried of those same walks in the park every day, and need a little extra motivation? No problem!
    Imagine escaping a fire behind you, and the only way to escape it before it burns you to death is, you guessed it, to run…

    Again, this would imply using an additional device for mapping your surroundings, which bring me back to Google’s light radar.

  3. Deep-ocean diving in your backyard

    Do you own a swimming pool? Congratulations, you are now allowed to join our experimental, naval elite team for deep-diving missions.

    Don’t forget to charge your oxygen bottles though…

If you could build anything want to make life more interesting with technology, what would it be?

Debugging delayed_job jobs from within the console

Did you ever want to step in with the Ruby debugger to fix or inspect
a background job? Here’s how:

DISCLAIMER: Tested with delayed_job 2.14. Should work with recent
versions, too.

Open a rails console within your project

$ rails c
Loading development environment (Rails 3.2.13)

Initialise a delayed_job worker, and make it output to console by
passing {quiet: false} to its initialiser.

1.9.2p325 :001 > worker = Delayed::Worker.new({quiet: false})
 => #

Start the worker

1.9.2p325 :002 > worker.start

Now you can put a debugger statement into your jobs and debug nicely
without using loggers.

Where am I now?

It has been two year since my Google Code-In participation in 2010, and today the 2012 grand-prize winners were announced.

That event help me as a milestone my life. I look back to it, to remember what I achieved when I hardly had any programming skills.

What happened in 2 years professionally?

  • I am proficient now in Ruby and JavaScript, and learned a dozen different programming languages.
  • I worked with start-ups, companies and awesome clients, gathering the important social skills I hadn’t had before, and getting to know the frustrations working with bad clients, freaky time-schedules and bad pay, so-called “experience”.
  • Launched various projects.
  • Continuous contributions to Open-Source.
  • I write better code, but it still sucks, just less than before.

Still I feel mediocre. I feel like I could have contributed more, learned more languages, met more cultures, played less games, studied more for college, done more ambitious projects.

Though, I firmly believe, fighting mediocrity has been the most important challenge I have picked up ever since I know that I am just as any other guy, and that I am fully motivated to kick ass.

Byte for Byte.

Show latest commit ID in Rails

I find it useful to display the current git commit ID of my application:

In your application’s Gemfile add the grit gem, which is a Ruby wrapper for git, and run Bundler.

If you deploy your web application via Capistrano and git, then you can put the following in your app/helpers/application_helper.rb:

[gist id=3679774]

Make sure the repo you are deploying to is non-bare. If you are not sure about that, in the project’s directory run:

[gist id=”3679892”]

If you see a SHA-1 Hash, life is good.

Now in your template you can add the helper anywhere you like – most people prefer to put that info in the footer:

[gist id=”3679825”]

How easy was that!

Sencha Touch 2 JSONP response with Ruby on Rails

I had a hard time how to make JSONP response data render in a Sencha Touch 2 list view, but I made it. WOOT.

Maybe, truth to be spoken, I had a harder time figuring out how JSONP actually worked. I had to understand that I had to wrap the JSON object into a JavaScript callback function and change the content type of the response to “text/javascript”. ( I still don’t get it. ;) )

So, here’s the code:

The last line of the the index method will be clear when you understand read the query string parameters which Sencha sends to the server:

and, ultimately the Sencha Store object:

I wonder if you can write a more elegant method?

Why Evernote sucks

I love Evernote, and I hate it for taking notes. Seriously, the concept is great, but the editor does not fit my needs.

I am not very picky, there are just a few things about Evernote that need to be fixed:

  • Documents have no semantical structure. There are no sections. Plain text is as intelligent as an Evernote note.
  • Outline support. Even headlines would be acceptable.
  • Table of contents. Notes get large and messy; scrolling and searching (and not finding) will be unavoidable.
  • Export notes. I want to create a spreadsheet whenever I feel like doing so.
  • No one needs fonts (at least I never needed them); I just want to write down notes and capture ideas.

Obviously, there are some things Evernote got right:

  • Cross-device. Don’t want to take out your laptop? No prob. Just take a note from your iPhone.
  • Developer API. There are some awesome 3rd party services built on top of Evernote. Lastly I have discovered Hello which keeps track of people you meet and automatically syncs to Evernote.
  • Voice memos.
  • Image scanning

I am feeling so dirty…

I am aware of a premium version, but it doesn’t fix any of the current issues. Awkwaaard. So, I am still waiting for a miracle, (or for a person who joins me on the next Evernote-killer project).

If you know something similar to Evernote tell me about it.

In the next post I will compare Evernote with org-mode, and talk about why it’s so much better, and should be far more popular than Evernote.

Facebook Puzzle #4 Solution – Breathalyzer

After reading this part of the the puzzle’s description:

A change is defined as replacing a single letter with another letter, adding a letter in any position, or removing a letter from any position. The total score for the wall post is the minimum number of changes necessary to make all words in the post acceptable.

I was immediately reminded of the Levenshtein algorithm I read earlier in the PHP documentation.

Ironically, I didn’t come up with a solution in PHP, but Python:

[gist id=1377213]

Here are some sample benchmarks:

$ time python breathalyzer.py "hello world"
0 0 real 0m0.235s user 0m0.170s sys 0m0.020s

The program processes all the words quite fast if they are found identically written in the list.

Here is the the levenshtein algorithm in action:

$ time python breathalyzer.py "hellofdsf worldtra"
3 3 real 0m1.121s user 0m1.110s sys 0m0.007s

Just above a second… passable.

I want it to actually do some work, so let’s throw the phrase found at the puzzle’s page to the program: “tihs sententcnes iss nout varrry goud”

$ time python breathalyzer.py "tihs sententcnes iss nout varrry goud"
1 2 1 1 2 1 real 0m4.092s user 0m4.013s sys 0m0.070s

 

4 seconds! I haven’t benchmarked other solutions, so I cannot say if my implementation is one of the faster or slower ones… so leave your comments about your solution (and also some rocking benchmarks).