Drupal 7: Converting a text field to a long text (aka textarea) field

Realize later on that text field you created needs to actually be a long text field?  You’re not alone.

After doing some research, I found zero complete solutions.  The ones I found leave problemattic remnants in the database, which can cause hard to diagnose issues such as restricted field length.  See references.

Luckily for you, the drush script below will do a more complete conversion.

Thanks go out to the references though, for getting me started.

 

References:

  1. http://www.pixelite.co.nz/article/convert-existing-textfield-textarea-drupal-7/
  2. http://www.up2technology.com/blog/converting-drupal-fields/

 

Have FTP but no ssh? Web Shell to the rescue!

There are many times a web shell can come in handy, such as  running a non-shell OS or if you have FTP but non SSH.  Web shell to the rescue!  The top three I could find are b374k-shell, ajaxshell, and shellinabox.  b374k-shell is my favorite, because it is all-around better than ajaxshell, and it doesn’t require compilation like shellinabox.  So enter b374k-shell a php web app that emulates some core capabilities of a shell.  Here is my review.

Features:

  1. A web-app that is a self-contained php file
  2. Password protected – stores a hash of your password within the php file
  3. Secure if you have https configured
  4. basic shell
  5. file browser, with options to
    • upload
    • edit
    • download
    • create
    • delete
    • rename
    • hex view
    • compress
    • decompress
    • copy
    • paste
    • chmod
    • limited bulk operations
  6. process manager
  7. system info browser
  8. php/python/ruby/perl/gcc evaluator
  9. db shells

 

Limitations:

  1. Can’t sshfs
  2. Bulk upload/download
  3. Basic editor with no syntax highlighting
  4. Works on mobile, but isn’t optimized for mobile

 

Conclusion:  It isn’t as good as ssh, but it’s super cool and can do everything you need it to for web development.

Best options for SSHFS on Mac OSX

Thank heavens for SSHFS! SSHFS allows me to locally mount remote linux/unix filesystems. This allows me to create and edit remote files using all of my native software! Sadly, the documentation for SSHFS options are weak, and the default options never work well for me. I’ve used SSHFS nearly every day for the past 3 months, and here is my recommendation for options for OSX:

  • nohup – makes the connection more reliable
  • follow_symlinks – optional, but is necessary if you want symlink folders to work
  • allow_other – let’s you assume file priviledges of the remote user
  • no_readahead, noappledouble, nolocalcaches – reduces overhead and makes Finder work MUCH faster

BONUS Want to make SSHFS work beautifully with SSHFS?  Check out this teaser:

If you want this, follow these instructions:

  1. Create a mount folder
  2. In the folder, create a script with the extension “.command”
  3. Add this to the script:

  1. Allow the script to be executable.  I usually do this from the terminal by typing:

  1. Now when you double click the script, the folder will turn into your remote folder.  To go back, simple click the eject icon next to the folder.
  2. Profit.

Making Sketch Animation Gifs 101

Have you ever seen those commercials which feature sketch animation, like the Numbers Never Lie commercial during the Super Bowl?  You may have also heard it called video scribing, fast hand drawing, or sketch cartoon video.  Building on this style of animation, I wondered how hard it would be to do a similar effect on a tablet.  Even cooler, what if I made a sketch animation GIF to use as a loading page animated GIF?

To start, I needed an app that would allow me to draw and turn my strokes into a video.  I started by searching google for sketch animation tablet apps, but the results were just plain old animation apps.  No good.  Digging deeper, I remember that teachers make sketch animations all the time for online classes.  So instead of looking for teaching apps, and voila!  I found two apps:  ScreenChomp and Educreations.  They both appeared to offer what I needed:  video recording of a drawing, aka sketch animation.  Teacher’s have been using sketch animation for years!  Note:  I tried ScreenChomp first and it worked, so I didn’t try Educreations.

Now the next challenge: how to make a GIF from the sketch animation video.  There are web services out there that will do this for a fee, but 1) I wanted to learn how to do it myself and 2) I wanted a transparent background.  I heard you can use Movie Maker some how, but having a Mac I decided to use the iMovie method.

Here is my method:  I used this awesome tutorial to convert the video to gif using iMovie and GIFfun, then used GIMP to make the background transparent.  To make the background transparent, I went through every frame/layer of the GIF to 1) add an alpha channel, 2) Select the background using the color selector tool, then 3) Edit->Clear.  When you save, make sure you set the animation speed to ~20ms.  This is quite tedious, but you could automate it using a GIMP script if you were so inclined.

And that’s it!  Here is my animated sketch GIF with transparent background!

loading...

25

May

jQ.Mobi 1.0 vs. jQuery Mobile

A common complaint about jQuery Mobile is the size and speed. By giving up support of legacy browsers, frameworks like jQ.Mobi (aka jqmobi) and Zepto claim smaller footprints and superior performance.  According to most benchmarks I’ve seen like this one, jQ.Mobi delivers while Zepto falls short of it’s performance claims.  Also, jQ.Mobi claims support for IE9 and IE10.  For these reasons, I decided to give jQ.Mobi a shot.

To create a fair comparison, I recreated last post‘s jQuery Mobile demo using the jQ.Mobi+jQ.Ui framework.  Getting started with jQ.Ui is harder than it should be, especially since being acquired by Intel.  On the bright side though, it’s still open source and the developer is very friendly on GitHub.  The best way to start with jQ.Ui is to pull down the jQ.Mobi git repo and point your browser to the jQ.Ui kitchen sink.  From there, you can explore most of the features jQ.Ui has to offer.  I started this demo with the example project.

My overall impression with jQ.Ui is good and bad.  I confirmed every claim of performance and size.  My demo is footprint is tiny, very noticeably faster on both newer and older devices, and compatibility with mobile phones is superb.  I’d go so far to say that compatibility on phones is even better than jQuery Mobile.  On the other hand, jQuery Mobile is a lot easier to develop on because 1) The documentation is awesome, 2) the library of built in gadgets is much bigger, 3) customizing and theming is much more intuitive, 4) RIB will get you up and running wicked fast.

So for the time being, I’ll prototype with jQuery Mobile and move to jQ.Mobi if the extra work is warranted later.  Check out my jQ.Mobi demo here!

11

Mar

Initial thoughts with the jQuery Mobile Framework

I’ve been meaning to try the jQuery Mobile Framework for a while now, and after discussing with District Karaoke’s Jesse Rauch I felt inspired.

So far, I’m optimistic. The baked in look and feel make for a what appears to be a nice experience. However, JQM animations are a little ahead of the mobile support. The animations will not be smooth on most phones, and will sometimes not come from the correct direction. It seems entirely a performance and browser issue, and I think JQM will look much better in future phones.

So for now, JQM may not be the best choice for lower end phones. Stay tuned, because soon I’m going to report on how JQM compares to alternatives.  In the mean time, check out my demo and offer me your thoughts!

Quick tip: I found the easiest way to get up and running with jQuery Mobile is to use the awesome RIB tool.

28

Feb

How and when to use python’s lambda

There is a long running debate in python land of the usefulness of the lambda function, and I usually air on the side of avoidance.  However, for simple occasions it can make for cleaner code.

The python docs are essential for quick reference, but sometimes they skimp on obscure features.  Lambda is one of those features.

In a nutshell, lambda is the inline function creator for python. In other languages, inline functions often look like this:

myFunction is a function, and myFunction(1,2)=3.  That makes a lot of sense! myFunction can similarly be defined in python using lambda:

myFunction = lambda arg1,arg2:  arg1+arg2

It’s true that this syntax requires less typing, but at the cost of readability.  In case you were wondering, here is a good example of when to use it.

Without lambda:

With lambda:

Head caution though, because readability goes out the window whenever the lambda expression gets to complicated.

When not to use lambda:

25

Feb

Automating Browsers with Selenium

Automating browser actions from an external script is easier than you think.

The answer:  Selenium.

Selenium is a browser automation tool suite which is compatible with several popular browsers, such as Firefox, Chrome, Internet Explorer and Opera. It is primarily written in Java, but it also has extensions for Python and Ruby.

Building on my Python and Javascript experience,  my experience was mostly painless for Firefox and Internet Explorer.  Getting the extensions is fairly easy, and source code was straight forward.  I really like how I can grab html objects by id OR class or xml.  Here is a very simple example of using the Selenium python extension to 1) open Firefox, 2) navigate to google.com, 3) enter text into the search box, then 4) hit enter.

05

Feb

Migrating WordPress the easy way

UPDATE
I now advise using interconnectit’s php script method instead of the method below, because it’s more reliable.

If you search on Google, there are tons of tutorials on migrating WP.  I found all of them hard to follow and overly complicated.  Follow these simple steps to easily move a WordPress (WP) website:

1) Copy the WP root folder to the new location

2) If also migrating the db, use phpMyAdmin to export the WP tables from the old db and import them into the new

3) Point a browser to the new WP location.  It should work, but all of the db is still pointing to the old WP location so we have to fix that

4) Run these sql commands in phpMyAdmin:

5) Last, make sure you setup mod_rewrite on your new web server if you are using mod_rewrite on your old one.

09

Jan

Setting phpMyAdmin to point to an Amazon RDS instance

Isn’t it annoying how you can’t ssh in to Amazon RDS instances?  Don’t you wish there was a way you could use trusty old phpMyAdmin to manage your db?  Here is the easy way to do it:

  1. Find the endpoint link to your RDS server.  It’s found in the instance information section.  It usually looks something like this: xxx.amazonaws.com
  2. Install phpMyAdmin somewhere.  I recommend on a webserver so you can access anywhere.
  3. cd phpMyAdmin
  4. sudo cp -p config.sample.inc.php config.inc.php
  5. Change this line in config.inc.php:

to

 

That’s it!