Jumpstarter.io and WordPress, play nice.

Just discovered a great new service, jumpstarter.io

“Hosting websites has never been this easy
Keep your websites up and running. Zero server hassle.”

One great thing is the ability to clone (or duplicate) an installation of WordPress (like a staging sever), but that is _exactly_ what it is, a copy. That means that the clone has the root installation URL, so when you try to log in at your new clone it points back to your root installation, not cool. A feature request is made, but in the meantime this following method is a poor mans solution to the problem.

Open up wp-config.php and paste this:

define('RELOCATE',true);

Then visit http://myclone.xxx/wp-login-php (Not /wp-admin, didn’t work for me at least) (Replace myclone.xxx with your own URL).

You should now be able to access the new (clone) admin.

You should now prob remove the line in wp-config.php

Read more @ WordPress Codex.

Sending mail with Mandrill & PHP (MailChimp)

Hi there

Short post about sending mail through the Mandrill-system.

“Mandrill is a scalable and affordable email infrastructure service, with all the marketing-friendly analytics tools you’ve come to expect from MailChimp.”

Download the latest release (working 2014-16-04). Grab the /src.

Create an API-key @ https://mandrillapp.com/settings/index

Put for example mail.php (code below) in the root folder (with /src).

Full API docs.

<?php

require_once 'src/Mandrill.php'; 

try {
    $mandrill = new Mandrill('YOUR_API_KEY');
    $message = array(
        'html' => '<p>Example HTML content</p>',
        'text' => 'Example text content',
        'subject' => 'example subject',
        'from_email' => 'sender.email@example.com',
        'from_name' => 'Example Name',
        'to' => array(
            array(
                'email' => 'recipient.email@example.com',
                'name' => 'Recipient Name',
                'type' => 'to'
            )
        ),
        'headers' => array('Reply-To' => 'message.reply@example.com'),
        
       
        
    );
    $async = false;
    $result = $mandrill->messages->send($message, $async);
    print_r($result);
    /*
    Array
    (
        [0] => Array
            (
                [email] => recipient.email@example.com
                [status] => sent
                [reject_reason] => hard-bounce
                [_id] => abc123abc123abc123abc123abc123
            )
    
    )
    */
} catch(Mandrill_Error $e) {
    // Mandrill errors are thrown as exceptions
    echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
    // A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
    throw $e;
}
?>

A dead crappy simple node.js chat with telnet

Stolen from http://www.youtube.com/watch?v=jo_B4LTHi3I Prerequisite: node.js installed (http://howtonode.org/how-to-install-nodejs)

Usage:

create chat.js (with the code from down under)

  • type node chat.js in the terminal
  • open a new terminal-window
  • telnet 127.0.0.1 8000
  • chat away

Bonus: on a local company net? get your IP (ifconfig) and telnet into that, share it with your friends.

var net = require('net')

var sockets = [];

var server = net.createServer(function(socket) {
 
  sockets.push(socket); 
    
  socket.on('data', function(d) {
    for (var i = 0; i < sockets.length; i++) {
      if (sockets[i] == socket) continue;
      sockets[i].write(d);   
    }
   
  });
  
  socket.on('end', function(d) {
    var i = sockets.indexOf(socket);
    sockets.splice(i,1);
  });
  
});