Friday, March 31, 2017

Your 2017 Guide To Email Etiquette (infographic)

Working in digital marketing, your job requires you to send countless emails every day as you negotiate with clients and attempt to spread the good word. Yet, if the public-facing aspect of your work is mostly made up of social media, online ads, and bulk emailing, you may be neglecting to tune up...

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Irfan Ahmad via Digital Information World

How to Synchronize WordPress Live and Development Databases

Developing WordPress themes is considerably easier with real content. Unexpected situations begin to arise when people add pages, posts, media and comments. Your beautiful template can break when:

  • editors use assets which are too big or small for your breakpoints to handle
  • managers introduce a new menu item which doesn't fit at lower screen sizes
  • your theme implements a two-level menu hierarchy which fails to cater for the inevitable third-level page
  • long or deeply-nested comments become unreadable.

Ideally, your development server should have a snapshot of your live production server's database. Your workflow can be improved further if content is automatically synchronized when changes occur.

Synchronization Snags

One-way WordPress database replication can be more challenging than you expect. There are good reasons why few coders live in this development dreamland…

Continue reading %How to Synchronize WordPress Live and Development Databases%


by Craig Buckler via SitePoint

19 Best Mobile App Templates With AdMob Integration

How to create a long-scrolling Landing Page using Squarespace [video]

In this video tutorial I cover exactly how to create a long-scrolling Landing Page, for any business, using Squarespace. I go through adding page sections, content creation and fine tuning styles. Hope you find value in the video!


One Page Love Exclusive Coupon

OPL10

Squarespace has been kind enough to give One Page Love readers the exclusive coupon OPL10 for 10% Off your first website or domain purchase. (There is a free 14-day trial with no credit card needed, so you can try risk free.)


Chapters:

  1. Intro
  2. Starting with the Pacific Template
  3. Adding an intro header with centered logo
  4. Section: About
  5. Section: Image Gallery
  6. Section: Team
  7. Section: Testimonials
  8. Section: Contact & Map
  9. Design Tweaks
  10. Bonus: creating the logo

by Rob Hope via One Page Love

Top Resources to Get Started with Java 9

You can tell that Java 9 draws near because the number of posts and talks about it skyrocketed in the recent months. I want to recommend existing talks and articles where you can learn about Java 9 but also further resources, where new, high-quality content will pop up.

Talks

If you're the kind of person who likes to watch talks, there are quite a few I can recommend. For a great high-level overview and conceptual intro to the module system, watch Java 9: Make Way for Modules! (Mark Reinhold; 40 min). Going deeper into the module system, the JDK team has an entire series of talks:

As a follow-up, there was an Ask the Architect session at JFokus where Mark Reinhold answers all kinds of questions, among them some about Java 9 (transitive dependencies, version conflicts, state of JavaFX, ahead-of-time compilation; 23 min).

With Java 9 coming closer, people started presenting on non-modularity features that Java 9 has to offer. This is me talking a little bit about the module system before going into the new language features, a few new APIs (collection factories, reactive streams aka Flow API, stack-walking, multi-release JARs) and performance (50 min). If you want to dive deeper, there is a talk by Aleksey Shipilëv on compact strings and indified string concatenation, which I highly recommend (60 min). Monica Beckwith explains about G1 but be warned, you better have your GC expertise down before giving this a try (55 min).

There are also a number of great talks that are much more practical. To learn about how Maven deals with with Java 9, watch Robert Scholte talk about Unicode encoding, version strings, cross compilation, multi-release JARS, and then of course Jigsaw with its impact on how Maven works but also what it has to offer (50 min). Don't miss live-coding queen Trisha Gee working on a Java 9 project with IntelliJ, where she demonstrates various features of both the JVM and the IDE (30 min). If you're interested to see what a migration to Java 9 modules might look like, watch Rabea Gransberger live-refactor a small demo project (15 min). Of course there is no way to talk about live-coding without mentioning Venkat Subramaniam, who shows off modules and JShell in a mammoth 150 minute live session.

For shorter bits there are a couple of interviews the Voxxed folks recorded:

Articles

Continue reading %Top Resources to Get Started with Java 9%


by Nicolai Parlog via SitePoint

The Ultimate Guide to Choosing a Hosting Provider

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.

You need a website. You have a clear idea of what you want, and have carefully considered the type of hosting you need. Now, with credit card in hand, it’s time to decide which company to sign up with.

Choosing a hosting provider is one of the most crucial decisions you’ll make. The future of your website depends on it.

If you were looking for a babysitting service for your children, you wouldn’t just pick the cheapest option that came along. “Leave your kids with us for just 50c a day. Pick them up whenever.” Your kids mean more to you than that. You’d want to make sure they were safe, and being looked after by people who know what they’re doing. Saving money isn’t your priority; investing in their well-being is.

Invest some time up front in the future well-being of your website. Who should you pay to host your website? What are the qualities you need in a hosting company?

Here are six key criteria to consider when weighing up the options.

1. Speed & Performance

Do you remember the last time you bought a new laptop? You immediately noticed the improvement in performance, and the old one suddenly felt surprisingly slow. Fast is good. You want a hosting company with the equivalent of a new laptop.

First impressions are everything. You don’t want new visitors to your site to leave before your home page loads. How committed is the hosting company to performance? It requires an ongoing investment in both hardware and software.

It’s not always easy to tell how often a company upgrades its hardware, or how much money they invest in it. Here are some ways you might find out:

Continue reading %The Ultimate Guide to Choosing a Hosting Provider%


by Adrian Try via SitePoint

Procedurally Generated Game Terrain with ReactJS, PHP, and Websockets

Last time, I began telling you the story of how I wanted to make a game. I described how I set up the async PHP server, the Laravel Mix build chain, the ReactJS front-end, and the Web Sockets connecting all this together. Now, let me tell you about what happened when I starting building the game mechanics with this mix of ReactJS, PHP, and Websockets...

The code for this part can be found at: http://ift.tt/2mVNk1y. I've tested it with PHP 7.1 and in a recent version of Google Chrome.

Final image

Making A Farm

"Let's start simple. We have a 10 by 10 grid of tiles, filled with randomly generated stuff."

I decided to represent the farm as a Farm, and each tile as a Patch:

namespace App\Model;

class Farm
{
    private $width
    {
        get { return $this->width; }
    }

    private $height
    {
        get { return $this->height; }
    }

    public function __construct(int $width = 10,
        int $height = 10)
    {
        $this->width = $width;
        $this->height = $height;
    }
}

This is from app/Model/FarmModel.pre

I thought it would be a fun time to try out the class accessors macro by declaring private properties with public getters. For this I had to install pre/class-accessors (via composer require).

I then changed the socket code to allow for new farms to be created on request:

namespace App\Socket;

use Aerys\Request;
use Aerys\Response;
use Aerys\Websocket;
use Aerys\Websocket\Endpoint;
use Aerys\Websocket\Message;
use App\Model\FarmModel;

class GameSocket implements Websocket
{
    private $farms = [];

    public function onData(int $clientId,
        Message $message)
    {
        $body = yield $message;

        if ($body === "new-farm") {
            $farm = new FarmModel();

            $payload = json_encode([
                "farm" => [
                    "width" => $farm->width,
                    "height" => $farm->height,
                ],
            ]);

            yield $this->endpoint->send(
                $payload, $clientId
            );

            $this->farms[$clientId] = $farm;
        }
    }

    public function onClose(int $clientId,
        int $code, string $reason)
    {
        unset($this->connections[$clientId]);
        unset($this->farms[$clientId]);
    }

    // ...
}

This is from app/Socket/GameSocket.pre

I noticed how similar this GameSocket was to the previous one I had; except instead of broadcasting an echo I was checking for new-farm and sending a message back only to the client that had asked.

"Perhaps it's a good time to get less generic with the ReactJS code. I'm going to rename component.jsx to farm.jsx."

import React from "react"

class Farm extends React.Component
{
    componentWillMount()
    {
        this.socket = new WebSocket(
            "ws://127.0.0.1:8080/ws"
        )

        this.socket.addEventListener(
            "message", this.onMessage
        )

        // DEBUG

        this.socket.addEventListener("open", () => {
            this.socket.send("new-farm")
        })
    }
}

export default Farm

This is from assets/js/farm.jsx

In fact, the only other thing I changed was sending new-farm instead of hello world. Everything else was the same. I did have to change the app.jsx code though:

import React from "react"
import ReactDOM from "react-dom"
import Farm from "./farm"

ReactDOM.render(
    <Farm />,
    document.querySelector(".app")
)

This is from assets/js/app.jsx

It was far from where I needed to be, but using these changes I could see the class accessors in action, as well as prototype a kind of request/response pattern for future Web Socket interactions. I opened the console, and saw {"farm":{"width":10,"height":10}}.

"Great!"

Then I created a Patch class to represent each tile. I figured this was where a lot of the game's logic would happen:

namespace App\Model;

class PatchModel
{
    private $x
    {
        get { return $this->x; }
    }

    private $y
    {
        get { return $this->y; }
    }

    public function __construct(int $x, int $y)
    {
        $this->x = $x;
        $this->y = $y;
    }
}

This is from app/Model/PatchModel.pre

I'd need to create as many patches as there are spaces in a new Farm. I could do this as part of FarmModel construction:

namespace App\Model;

class FarmModel
{
    private $width
    {
        get { return $this->width; }
    }

    private $height
    {
        get { return $this->height; }
    }

    private $patches
    {
        get { return $this->patches; }
    }

    public function __construct($width = 10, $height = 10)
    {
        $this->width = $width;
        $this->height = $height;

        $this->createPatches();
    }

    private function createPatches()
    {
        for ($i = 0; $i < $this->width; $i++) {
            $this->patches[$i] = [];

            for ($j = 0; $j < $this->height; $j++) {
                $this->patches[$i][$j] =
                    new PatchModel($i, $j);
            }
        }
    }
}

This is from app/Model/FarmModel.pre

For each cell I created a new PatchModel object. These were pretty simple to begin with, but they needed an element of randomness. A way to grow trees, weeds, flowers; at least to begin with:

public function start(int $width, int $height,
    array $patches)
{
    if (!$this->started && random_int(0, 10) > 7) {
        $this->started = true;
        return true;
    }

    return false;
}

This is from app/Model/PatchModel.pre

I thought I'd begin just by randomly growing a patch. This didn't change the external state of the patch, but it did give me a way to test how they were started by the farm:

namespace App\Model;

use Amp;
use Amp\Coroutine;
use Closure;

class FarmModel
{
    private $onGrowth
    {
        get { return $this->onGrowth; }
    }

    private $patches
    {
        get { return $this->patches; }
    }

    public function __construct(int $width = 10,
        int $height = 10, Closure $onGrowth)
    {
        $this->width = $width;
        $this->height = $height;
        $this->onGrowth = $onGrowth;
    }

    public async function createPatches()
    {
        $patches = [];

        for ($i = 0; $i < $this->width; $i++) {
            $this->patches[$i] = [];

            for ($j = 0; $j < $this->height; $j++) {
                $this->patches[$i][$j] = $patches[] =
                    new PatchModel($i, $j);
            }
        }

        foreach ($patches as $patch) {
            $growth = $patch->start(
                $this->width,
                $this->height,
                $this->patches
            );

            if ($growth) {
                $closure = $this->onGrowth;
                $result = $closure($patch);

                if ($result instanceof Coroutine) {
                    yield $result;
                }
            }
        }
    }

    // ...
}

This is from app/Model/FarmModel.pre

There was a lot going on here. For starters, I introduced an async function keyword using a macro. You see, Amp handles the yield keyword by resolving Promises. More to the point: when Amp sees the yield keyword, it assumes what is being yielded is a Coroutine (in most cases).

Continue reading %Procedurally Generated Game Terrain with ReactJS, PHP, and Websockets%


by Christopher Pitt via SitePoint