NoSleep Command Line Tool

The NoSleep utility for Mac OSX ( Mavericks et. all) that allows you to keep your computer from going to sleep even when the lid / clamshell is shut. It is accessed via a System Preferences pane and when running also shows up in the menu bar.

To use the command line tool you need to choose that option when installing NoSleep:

NoSleep Command Line Tool

It will be installed as /usr/local/bin/NoSleepCtrl and you should be able to type in NoSleepCtrl in your Terminal.app to run it ( or use the full path if that doesn’t work )

Here are the options for using it:

Usage: NoSleepCtrl [OPTIONS] ...

Options:
  -h         Show this usage guide
  -v VRBLVL  Verbose level. Default value is 1.
             0 - minimal output,
             1 - normal output,
             2 - include driver output.
  -a         Mode qualifier. Used to select AC-Adapter mode
  -b         Mode qualifier. Used to select Battery mode
             Modes can be combined (-a -b).
             Use no qualifiers to select a current mode
  -g         Get status for selected mode
  -s NVAL    Set status for selected mode
             NVAL should have (%d) or (%d,%d) format, depending
             on the specified mode (without parentheses)
Posted in Tech Tips | Tagged , | 2 Comments

ShareThis Asynchronous Javascript Loading

Unfortunately the ShareThis service has a lot of known issues, like loading a lot of data from their tracking site, b.scorecardresearch.com and other types of bloat when initializing their icons.

Because calling stLight.options depends on having the buttons.js script already loaded, it is not really feasible to initialize the code like this:

<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "6beba854-ee6d-4ae1-a4f3-b69815c8ef63"});</script>

However, you could use an onload function to do the stLight.options, and then wrap the entire thing inside of a function that won’t interfere with the global namespace, like this:

<script>
// ShareThis Asynchronous Javascript Loading
// from https://techblog.willshouse.com/?p=5265
(function(){
    // window.switchTo5x=false; // (optional)
    var e=document.createElement("script");
    e.type="text/javascript";
    e.async=true;
    e.onload=function(){
        try{
            stLight.options({publisher: "6beba854-ee6d-4ae1-a4f3-b69815c8ef63", doNotHash: true, doNotCopy: true, hashAddressBar: false});
        }catch(e){ /* optionally do something to handle errors here */ }
    }
    e.src=('https:' == document.location.protocol ? 'https://ws' : 'http://w') + '.sharethis.com/button/buttons.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(e, s);
})();
</script>

Make sure to update your publisher ID in the code above if you copy / paste it.

Posted in Social Media, Tech Tips | Tagged | 2 Comments

Gravity Forms – Disable and Remove the “Map It” Link

In the Gravity Forms generated emails, if your form has a “address” field the email notification generated by using something like {all_fields} will have a “Map It” link associated with the address, which will open Google Maps.

Add this code to your theme’s functions.php file to disable / remove the “Map It” link from the email notification.

// code courtesy of https://techblog.willshouse.com/?p=5249
add_filter("gform_pre_send_email", array($this,'gform_pre_send_email'));
function gform_pre_send_email($email)
{

    // attempt to match the link using a regular expression
    $test = preg_replace("#\<a [^>]+?\>Map It[^>]+\>#i", '', $email["message"]);
    // if the result is not empty / blank, use it to replace the original html
    if(trim($test))
    {
        $email["message"] = $test;
    }

    return $email;

}

If you want to hide the “map it” link from the HTML that is displayed on a webpage ( if you confirmation has the {all_fields} merge replacement in it ) then you can add some CSS like this:

<style>
a.map-it-link
{
    display: none;
}
</style></a>
Posted in Tech Tips, Web Development | Tagged , | 2 Comments

CPanel / WHM – Change “Default Website” Page

You may have noticed that when visiting a CPanel Server ( running WHM ) if you don’t have a site configured for the hostname that you are accessing ( or possibly if you are accessing the server via the IP address ) you will end up seeing the “default website” page, and your browser’s URL will redirect to defaultwebpage.cgi ( or /cgi-sys/defaultwebpage.cgi )

CPanel / WHM – Change “Default Website” Page

You may have searched your system and ended up finding something like this file:

/usr/local/cpanel/cgi-sys/defaultwebpage.cgi

However, that’s not just a plain HTML file – it’s a beefy binary cgi script. No editing is going to take place there! (nor should it)

You may have also found the file that actually loads / redirects to the cgi script, which lives here:

/usr/local/apache/htdocs/index.html

However, I would not recommend customizing that file because it will get overwritten during a cPanel upgrade.

So, what is the right way?

Well it just so happens that in WHM there is a Web Template Editor that is meant for this very purpose:

CPanel / WHM – Change “Default Website” Page

The Web Template Editor allows you to create placeholder web pages. These pages will appear to visitors who navigate to a site on your server that:

  • Has not yet been configured by the domain owner (see the Default Website Page tab)
  • Has moved (see the Account Move tab)
  • Is experiencing a connection or firewall problem (see the Connection Selection tab)
  • Has been suspended (see the Account Suspended tab)

Info for the Default Website Template:

You are editing the Default Website Template.

This page appears to visitors who navigate to a site that has not been configured by the domain owner and sites that have been deleted.

If you have created /usr/local/apache/htdocs/index.php, index.cgi, or index.pl this page will be overridden by these scripts

This template file will be saved as /var/cpanel/webtemplates/root/english/default.tmpl

How to use a scriptable index ( like index.php or index.pl )

You can make changes to index.html, but during apache rebuilds and/or cpanel upgrades changes may be lost as the file is reverted to the system version. According to WHM, another file in that location may take precedence – like index.php – however to get index.php to load you may need to move or delete index.html in order to have a file like index.php or index.pl – load as the default. But again, during upgrades or rebuilds the index.html file will come back.

Also, please note when using php files that the permissions should probably be set to 644 and the owner and group of the file should be the apache user – most likely nobody:nobody

The other way to keep a file like index.php available even during upgrades and rebuilds is to set the DirectoryIndex priority setting in WHM so that .php files are prioritized:

CPanel / WHM – Change “Default Website” Page

Posted in Tech Tips | Tagged , | 2 Comments

Adium – Use Notification Center

Notification Center support Adium 1.5.4 now supports Mountain Lion’s Notification Center. By default, notifications are shown for a couple of events. You can add and remove notifications in Adium’s “Events” preferences (see our documentation on Events and Visual Notifications for details.)

People have asked us how Adium decides between Notification Center and Growl on OS X 10.8 “Mountain Lion” (especially with Growl.app installed) so here is an explanation from our very own Stephen Holt:

1. Growl.app is installed, and the user has configured it to NOT use Notification Center: Notifications work as before. Notification tickets are sent to Growl.app which performs actions and displays notifications as configured by the user 2. Growl.app is installed, and the user has configured it to use Notification Center: Growl.framework detects this state from within the app and notifications are sent directly to NC. Additionally, notification tickets are sent to Growl which performs any associated actions. Growl.app displays nothing. 3. Growl.app is not installed: Growl.framework detects this state from within the app and notifications are sent directly to NC. Nothing else is done.

Please note that only Growl.app version 2 or newer can be set to use Notification Center.

Posted in Tech Tips | Tagged | Leave a comment

Heroku pg migration error “PG:DataCorrupted: Error”

Heroku’s database system is having issues at the moment, if you use a command like this:

heroku rake db:migrate

You’ll see some details saying:

Heroku pg migration error “PG:DataCorrupted: Error”

This looks like a system-wide error on Heroku’s side.

The complete error is something like:

One option may be to try this:

heroku run rake

Although at this time the Heroku dashboard does not report any issues officially:

Heroku pg migration error “PG:DataCorrupted: Error”

Now one day later we see the results from the Heroku Support Bot:

Your database HEROKU_POSTGRESQL_CRIMSON_URL on yourapp requires maintenance. During this period, your database credentials will become read-only. Once it has completed, your database URL will have changed, but we will update your app’s config variables accordingly.

This automated maintenance is a necessary part of our Starter tier plans, Dev and Basic. Should you need more control over maintenance windows, a production database (Crane or higher) offers more control over database maintenance, as we are able to schedule them in advance and provide better tools for self-served maintenance. We expect maintenance to last just a few moments. We will update this ticket when maintenance begins, and again once it’s complete.

Posted in Linux, Server Admin | Leave a comment

Black Studio TinyMCE plugin and WordPress 3.9

If your Black Studio TinyMCE widget seems to have disappeared after upgrading to WordPress 3.9 you’re not alone.

Many users are looking for the missing widget after the most recent upgrade.

According to the plugin page, the plugin lists that it is compatible up to WordPress 3.9 ( as of April 2014 ) – however you may still be having a hard time finding the editor on the widgets page ( widgets.php )

Black Studio TinyMCE plugin and WordPress 3.9

The issues is that the plugin has had some name / title changes. While still called Black Studio TinyMCE plugin the name of the widget is just called “Visual Editor”

Posted in Uncategorized | Leave a comment

Wireshark GUI on Mac OS X with Homebrew

To get the GUI of wireshark running on Mac OS X please note that the latest version requires QT and uses this for it’s GUI.

They are no longer using X / X11 (because it is no longer free?) so the with-x option is not a good solution.

You have probably already installed Wireshark with brew install wireshark so what you need to do to get the GUI working is run:

brew reinstall wireshark --with-qt

From their blog:

Today I released the next development version of Wireshark, 1.11.0. This marks a major change in the direction of the project. We’re switching our user interface library from GTK+ to Qt. Both libraries make it easy for developers write applications that will run on different platforms without having to rewrite a lot of code. GTK+ has had a huge impact on the way Wireshark looks and feels and on its popularity but it doesn’t cover our supported platforms as effectively as it should and the situation is getting worse as time goes on.

Also note:

If you’re a power user you should probably keep using the GTK+ flavor for the time being. You should also test the Qt flavor from time to time to see how your workflow will change. Both are installed by default on Windows and Linux.

Posted in Uncategorized | Leave a comment

Syntax Specific Key Bindings in Sublime Text

I wanted to remap one of the key bindings for selecting a paragraph / expanding the current selection – but just in the Ruby syntax. Here’s what I added to my Default (OSX).sublime-keymap file:

// when using ruby syntax, set cmd+shift+b to run "expand selection to indentation (or paragraph)"
{

"keys": ["super+shift+b"],
"command": "expand_selection",
"context": [ { "key": "selector", "operator": "equal", "operand": "source.ruby" } ],
"args": {"to": "indentation"}
// "args": {"to": "paragraph"}

},

// when not using ruby, set that shortcut to "expand selection"
{

"keys": ["super+shift+b"],
"command": "expand_selection",
"context": [ { "key": "selector", "operator": "not_equal", "operand": "source.ruby" } ],
"args": {"to": "scope"}

},
Posted in Uncategorized | Leave a comment

Select a Ruby Block (scope) in Sublime Text

Coming from PHP to Ruby you may wonder if there is a way to select Ruby ( or Ruby on Rails ) block scope that starts with things like begin or def and finishes with end

In PHP it was possible using the commands like

Expand Selection to Scope

or

Expand Selection to Block

and in PHP it works nicely:

Select a Ruby Block (scope) in Sublime Text

But in the Ruby syntax neither of these items work. So how can you select a ruby block scope in Sublime Text 2 / 3 ?

Easier than you might imagine: just use “Expand Selection to Paragraph” instead

Posted in Tech Tips | Tagged , | Leave a comment