Cleanflight on Mac OSX

If you’re having problems getting cleanflight to recognise your Naze board and you’re on a Mac, do the following:

  1. Using USB to connect to the Naze32 requires the installation of the SiLabs CP2102 VCP Drivers. The drivers are available for download directly from the SiLabs Website
  2. Force the serial connection to be recognized by running the following line at the command terminal: sudo ln -s /dev/tty.SLAB_USBtoUART /dev/tty.usbserial
  3. Fire up Cleanflight!
Published
Categorized as Drones

How to install Drupal with PostgreSQL on Windows 7

So you want to see this?

Drupal database type

 

 

 

 

No problem, just follow my instructions:

  1. Download the latest version of Drupal and extract into c:\dev\drupal
  2. Download and install Postgres
  3. Download EasyPHP and install in c:\dev
  4. Once installed, double click on EasyPHP task menu icon and stop Apache and MySQL
  5. Add the following to your PATH environment variable: C:\Program Files\PostgreSQL\9.4\lib; (or change the path if thats not where you installed Postgres)
  6. Edit your php.ini file (found here: C:\dev\EasyPHP-DevServer-14.1VC9\binaries\php\php_runningversion) and remove the semicolon prededing “extension=php_pdo_pgsql.dll” and “extension=php_pgsql.dll”
  7. Double click on EasyPHP task menu icon and start Apache
  8. Right-click on EasyPHP task menu icon and choose Administer
  9. On the Admin screen, in the Local Files section, add a new alias (name: your-site, path: C:\dev\drupal\drupal-7.38 <- from step 1)
  10. Visit http://127.0.0.1/your-site/ and follow the Drupal setup wizard
  11. Install standard version of Drupal, on database setup screen you will now have the option to choose “PostgreSQL”
  12. From your Start Menu, find PostgreSQL and open “pgAdmin” tool
  13. Right click and choose Connect
  14. Get the database name (postgres), hostname (localhost), port number (5432) and username (postgres) and password (set this yourself)
  15. Enter the details and you’re all set.

How to patch/hotfix your CQ5 website

You can use a package to patch your javascript, if you find a bug in production and dont want to perform a production deploy. In other words, if you need a quick fix…

  1. Make a package containing the file you wish to patch, perhaps a javascript file in your clientlibs, install it in the package manager in your production author.
  2. Go into CRX/DE, drill down to the file you are patching, click on it, click the replication tab, click replicate
  3. Go to the CQ welcome screen, Tools > Replication > Activate Tree > Drill down, select file, activate
  4. Update cachebreaker which will force clientlibs to recompile
Published
Categorized as Adobe CQ

Parse.com Javascript SDK + Disqus SSO Integration

Universal code:


function enableDisqus(config, sso_config) { 
  console.log("is disqus already loaded: " + enableDisqus.loaded);
  if (enableDisqus.loaded) {
    DISQUS.reset({
      reload: true,
      config: function () {  
        this.page.identifier = config.identifier;
        this.page.url        = config.url;
        this.page.title      = config.title;
      }
    });
    console.log('disqus reset', config.identifier, config.url);
  } else {
    console.log('disqus not loaded');
    var body = "var disqus_shortname  = \"" + config.shortname  + "\";\n" + 
               "var disqus_title      = \"" + config.title      + "\";\n" + 
               "var disqus_identifier = \"" + config.identifier + "\";\n" +
               "var disqus_url        = \"" + config.url        + "\";\n";
    if (config.developer) {
      body +=  "var disqus_developer  = 1;\n"
    }

    appendScriptTagWithBody(body);
 
    (function() {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
 
    if (sso_config) {
      var remote_auth_s3 = sso_config.message + " " + sso_config.sig + " " + sso_config.timestamp;
      var body = "var disqus_config = function() {\n" + 
                 "  this.page.remote_auth_s3 = \"" + remote_auth_s3     + "\";\n" + 
                 "  this.page.api_key        = \"" + sso_config.api_key + "\";\n" + 
                 "  this.sso = {\n" + 
                  "  name:   'SampleNews',\n" +
                  "  button:  'http://example.com/images/logo.png',\n" +
                  "  icon:     'http://example.com/images/favicon-96x96.png',\n" +
                  "  url:        'http://example.com/signin',\n" +
                  "  logout:  'http://example.com/logout',\n" +
                  "  width:   '800',\n" +
                  "  height:  '400'\n" +
                 "  };\n" +
                 "};\n"
      appendScriptTagWithBody(body)
    }
 
    enableDisqus.loaded = true;
  }
}

function appendScriptTagWithBody(body) {
  var dso   = document.createElement("script");
  dso.type  = "text/javascript";
  dso.async = true;
  dso.text  = body;
  console.log(body);
  document.getElementsByTagName('body')[0].appendChild(dso);
}

When your page content changes and you need to load new comments:

        //load the comments
        if (isLoggedIn()) {
          //prepare SSO
          var disqusData = {
            id: Parse.User.current().getSessionToken(),
            username: Parse.User.current().getUsername(),
            email: Parse.User.current().getEmail()
          };

          var disqusStr = JSON.stringify(disqusData);
          var disqussso_timestamp = Math.round(+new Date() / 1000);
          var disqussso_message = Base64.encode(disqusStr);
          var disqussso_result = CryptoJS.HmacSHA1(disqussso_message + " " + disqussso_timestamp, "your disqus api");
          var disqussso_hexsig = CryptoJS.enc.Hex.stringify(disqussso_result);
        }

        enableDisqus(
          { 
            shortname:  "your_shortname",
            title:      "your product name",
            identifier: 'your-' + productId,
            url:        "product page url"
          },
          {
            api_key: "your_disqus_api_key",
            message:   disqussso_message, 
            sig:       disqussso_hexsig, 
            timestamp: disqussso_timestamp
          }
        );

Dependancies:

  • http://code.google.com/p/crypto-js
  • http://stackoverflow.com/questions/246801/how-can-you-encode-a-string-to-base64-in-javascript

Did you find this post useful?

Tip me some bitcoin:

How to get free SSL for your Parse.com hosted app

This tutorial assumes you are using Parse.com hosting (yourapp.parseapp.com) and have applied a custom domain name (yourapp.com) upon which SSL will be used.

  1. Visit startssl.com and signup for a free SSL certificate, save the ssl.key and ssl.cert files when prompted
  2. Visit Settings > Hosting page in your Parse.com dashboard
  3. Upload the file ssl.cert into the SSL Public Certificate field
  4. Go back to startssl.com > Toolbox > Decrypt Private Key, save decrypted file as privatekey.pem
  5. Upload privatekey.pem to Parse.com in the SSL Private Key field

How to use Backgrid.js and the Parse.com Javascript SDK

Create a Backgrid populated with data from Parse.com and have it auto save back to Parse when a field is edited:

//load my Parse.com Class called "parts"
var Part = Parse.Object.extend("parts", {
  //save the data back to parse.com when it changes
  initialize: function() {
    Parse.Object.prototype.initialize.apply(this,arguments); this.on("change", function (model,options) {
     if (options && options.save === false) return;
     model.save()
    });
  }
});

var Parts = Parse.Collection.extend({
  model: Part
});

var columns = [{
    name: "id",
    label: "ID",
    editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
    cell: Backgrid.IntegerCell.extend({
      orderSeparator: ''
    })
}, {
    name: "name",
    label: "Name",
    cell: "string"
}, {
    name: "description",
    label: "description",
    cell: "string"
}];

var parts = new Parts();

// Initialize a new Grid instance
var grid = new Backgrid.Grid({
  columns: columns,
  collection: parts
});

// Render the grid and attach the root to your HTML document
$("#results-grid").append(grid.render().el);

// Fetch some countries from the url
parts.fetch({reset: true});

How to change the orientation of your CC3D flight controller

Normally your CC3D should be mounted with the arrow pointing towards the front of your quadcopter, and the USB towards the back. However, this makes it difficult to plug in the USB cable, so instead you can mount it with the arrow pointing a different direction by using the table below as a guide:

cc3d orientation guide

After you have mounted using a new orientation, launch the OpenPilot GCS software on your computer and connect your CC3D to your USB port. In the configuration tab, click on Attitude. Here you can adjust the values based on the table above, and then click save.

I have my arrow pointing left, so my USB port is easily accessible on the right, therefore the Yaw value is set to 90
I have my arrow pointing left, so my USB port is easily accessible on the right, therefore the Yaw value is set to 90

Important Note:

You must set this value again every time you update or reset the board, or run the calibration wizard (it resets everything)

Published
Categorized as Drones

Lessons learnt from building a quadcopter

ZMR 250
ZMR 250

  • If you’re bad at soldering (like me), make a wiring loom instead of using a power distribution board, it’ll be easier to solder (I’m presuming!).
  • Don’t cut your wires too short
  • Make sure you know which way the motors are going to spin, and which way your flight controller wants them to spin, before you do any soldering. Looking at your motor and ESC from the top,  if you solder the wires straight from the motor to the ESC the motor will spin anti clockwise. To get it to spin clockwise just cross over any two of the wires.
  • If you use the CC3D flight controller, mount it so the USB port is facing sideways for easy access, then inform the Ground Station Software of this change
  • Learn how to bind your Tx to its Rx early in the build, you can use the power from an ESC rather than buying a binding battery
  • Don’t impulse buy, read a lot and learn before making the wrong purchase
  • If your ESC’s have linear BEC’s onboard, then you don’t need to cut the power from any of them before connecting the your flight controller

End result:

My ZMR250
My ZMR250

Published
Categorized as Drones