All Things Seem Possible In May! Unique Wallpapers To Freshen Up Your Desktop




 


 

We always try our best to challenge your creativity and get you out of your comfort zone. A great occasion to do so is our monthly wallpapers challenge which has been going on for eight years already. It’s an opportunity to let your ideas run wild and try something new, to indulge in a little project just for fun. Whatever technique you fancy, whatever story you want to tell with your wallpaper, the submissions to this challenge make a beautiful, unique bouquet of community artworks each month anew. Artworks that adorn desktops and, who knows, maybe even spark new ideas.

Desktop Wallpaper Calendars May 2017

This post features desktop wallpapers for May 2017, created by designers and artists from all across the globe. Each wallpaper comes in versions with and without a calendar and can be downloaded for free. Time to freshen up your desktop!

The post All Things Seem Possible In May! Unique Wallpapers To Freshen Up Your Desktop appeared first on Smashing Magazine.


Source: Smashing Magazine

Upgrading Sylius the TDD Way: Exploring Behat

Last time, we developed some new features on top of Sylius’ core to indicate which products and their variants are low on stock and need replenishing. Now, we move on to seeing our changes in the UI, which means we will need to do a bit of StoryBDD testing.

When browsing the list of products, we want to see a new column called Inventory which will hold a sum of all available tracked variants’ stock amounts.


Sylius logo

Writing StoryBDD tests

Behat is the tool we want to use here. After making sure Behat is working well by running any feature from the Sylius package, we create a new features/product/managing_products/browsing_products_with_inventory.feature file with the following definition:

@managing_inventory
Feature: Browsing products with inventory
    In order to manage my shop merchandise
    As an Administrator
    I want to be able to browse products

    Background:
        Given the store operates on a single channel in "United States"
        And the store has a product "Kubus"
        And it comes in the following variations:
            | name          | price     |
            | Kubus Banana  | $2.00     |
            | Kubus Carrot  | $2.00     |
        And there are 3 units of "Kubus Banana" variant of product "Kubus" available in the inventory
        And there are 5 units of "Kubus Carrot" variant of product "Kubus" available in the inventory
        And I am logged in as an administrator

    @ui
    Scenario: Browsing defined products with inventory
        Given the "Kubus Banana" product variant is tracked by the inventory
        And the "Kubus Carrot" product variant is tracked by the inventory
        When I want to browse products
        Then I should see that the product "Kubus" has 8 on hand quantity

Again, we describe the make-up of our test product, stating the name, price and available stock of the two variants. If we run this feature, we see a list of paths for available contexts. We aren’t interested in any of them, but we also get a hint, so we select None.

php bin/behat features/product/managing_products/browsing_products_with_inventory.feature
--- Use --snippets-for CLI option to generate snippets for following ui_managing_inventory suite steps:

    When I want to browse products
    Then I should see that the product "Kubus" has 18 on hand quantity

We create our context in src/Sylius/Behat/Context/Ui/Admin/ManagingProductsInventoryContext.php and add this:

<?php

// src/Sylius/Behat/Context/Ui/Admin/ManagingProductsInventoryContext.php

namespace SyliusBehatContextUiAdmin;

use BehatBehatContextContext;

class ManagingProductsInventoryContext implements Context
{
}

Running the feature again doesn’t seem to help as we get the same list of contexts as before. That’s because Sylius doesn’t know anything about our class. We need to configure a service for our context together with what Sylius has in src/Sylius/Behat/Resources/config/services/contexts/ui.xml. We now search for managing_products and add this below it:

<service id="sylius.behat.context.ui.admin.managing_products_inventory" class="SyliusBehatContextUiAdminManagingProductsInventoryContext">
    <argument type="service" id="sylius.behat.page.admin.product.index" />
    <tag name="fob.context_service" />
</service>

Let’s add our sylius.behat.context.ui.admin.managing_products_inventory service (that’s the id in ui.xml) to the context services for ui_managing_inventory suites in src/Sylius/Behat/Resources/config/suites/ui/inventory/managing_inventory.yml.

We may need to clear the cache. If we run the feature, we now get an option to select SyliusBehatContextUiAdminManagingProductsInventoryContext. We then get:

--- SyliusBehatContextUiAdminManagingProductsInventoryContext has missing steps. Define them with these snippets:

    /**
     * @When I want to browse products
     */
    public function iWantToBrowseProducts()
    {
        throw new PendingException();
    }

    /**
     * @Then I should see that the product :arg1 has :arg2 on hand quantity
     */
    public function iShouldSeeThatTheProductHasOnHandQuantity($arg1, $arg2)
    {
        throw new PendingException();
    }

We can just copy and paste the snippets into the context class we created. Out of curiosity we may import PendingException just to see the output. Let’s add use BehatBehatTesterExceptionPendingException; to the top of the class and re-run the feature.

We get an error:

An exception occured in driver: SQLSTATE[HY000] [1049] Unknown database 'xxxx_test' (DoctrineDBALExceptionConnectionException)

That’s because we haven’t created the test database. These two commands will do that for us now.

Continue reading %Upgrading Sylius the TDD Way: Exploring Behat%


Source: Sitepoint

Goodbye Java Channel

As you can tell from the title, I’m writing to say goodbye – to you as well as to the Java channel. It is going on hiatus and this is the last newsletter that goes out. It was a great honor to be your editor! It gave me so many opportunities to interact with interesting […]

Continue reading %Goodbye Java Channel%


Source: Sitepoint

Upgrading Sylius the TDD Way: Exploring PhpSpec

The post on developing and testing new Sylius features was an introduction to the three types of tests that are used in Sylius – PHPUnit, Phpspec and Behat.

In this part, we’ll extend some core classes to indicate color-coded inventory status. First, we’ll deal with the back end part. In a followup post, we’ll use Behat and test the visual changes. Please follow the instructions in the previous post to get a working instance up and running.


Sylius logo

Sylius has an excellent inventory management solution. However, there’s always some room for a tweak or two. If you look at the list of products (admin/products) there’s no information about available stock. Looking at the variants of a product, we see inventory data, whether it’s tracked or not, and the number of total items in stock, if tracked. It would be nice to see that kind of information on the product listing page, too. In addition, the stock level is all or nothing – for example, a green label says “10 Available on hand” or red “0 Available on hand”. How about something in-between, say a yellow label for “3 Available on hand” to indicate that stock is low? Then, the store admin can decide it’s time to replenish.

Extend ProductVariant and Product models

We want to extend the behavior of both the ProductVariant and Product models provided by Sylius, so we can see extra information on stock availability when viewing products.

Create a Bundle

First, we create the src/AppBundle/AppBundle.php file and register it in app/AppKernel.php.

<?php

// src/AppBundle/AppBundle.php

namespace AppBundle;

use SymfonyComponentHttpKernelBundleBundle;

class AppBundle extends Bundle
{
}
<?php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new AppBundleAppBundle(),
    ];
}

Next, we inform the autoloader about the new bundle by adding it to the “autoload” section of composer.json.

Continue reading %Upgrading Sylius the TDD Way: Exploring PhpSpec%


Source: Sitepoint

A Quick Guide to Dependency Management With Bower

 

Web developers use a variety of libraries and frameworks in their sites, jQuery among them, and they need some way to easily manage them. Bower is such a tool, and in this video tutorial from my course, How to Become a Web Developer: jQuery and Bootstrap, you’ll learn the basics of dependency management with Bower.

Bower

Watch the Full Course

The full course, How to Become a Web Developer: jQuery and Bootstrap, will teach you some of the fundamental tools for front-end web development. You’ll get a primer on JavaScript, learn how to use package management tools such as NPM, and then go on to practice using the very powerful and popular jQuery framework for efficient manipulation of HTML. Finally, you’ll learn how to use the Bootstrap CSS framework to jump-start your user interface and build responsive apps.

You can also kick-start your web development by downloading some of the useful JavaScript and jQuery plugins on Envato Market.


Source: Nettuts Web Development

Using the Twitter API to Tweet Repetitive Content

Final product image
What You’ll Be Creating

Welcome back to our coverage of the Twitter API. If you use Twitter, you may have come across a friend sharing tweets from the @infinite_scream bot (shown above). I know it’s mostly a bot because it tweets at ten-minute intervals. But it varies the string length of its virtual screams to avoid being blocked by the Twitter’s API’s infamous undocumented restrictions. Tweet too frequently or repeat the same content and you’ll find your bots hopelessly blocked.

Recently, an online friend asked me to help them write code for a bot that might repeat but provide some intelligent content variation. In today’s tutorial, I’ll write about how to do this with the Twitter API.

In today’s tutorial, I’ll describe how to build a bot that does the basics:

  • random tweet interval
  • random selection of status text
  • random selection of hashtags
  • random inclusion of URLs
  • avoid getting blocked by Twitter

However, if you want to use a Twitter API bot to effectively promote your product or service on your own account without annoying your followers, you need to write code that intelligently varies the topic, contents and frequency of your tweets in an organized way. I’ll be writing about how to do that in future episodes. 

If you have any questions or ideas, please post them in the comments below. If you’d like to see some of my other Envato Tuts+ tutorials, please visit my instructor page, especially my startup series. Let’s get started.

Getting Started

For the bot in episode one, I’m trying to generate fun tweets on a regular basis while avoiding upsetting the great Twitter God of Restricted Access in the Sky.

The tweet content is very simple and can be randomly created by combining previously written status text, hashtags, and URLs.

The bot runs in Yii, a popular PHP-based platform. I’ll keep the guide below fairly simple for straight PHP developers. However, I encourage you to use frameworks. You can learn more in my Yii Series.

Building the Bot

Registering a Twitter App

Basically, the first thing I did was register an app to get my Twitter keys:

Repeating Twitter API - Setting up your Twitter App

If you aren’t familiar with creating an app and authorizing API access with Twitter, please review some of our earlier tutorials:

Authoring Content for a Range of Tweets

I wanted to create a system where my friend (or any approved author) could write variations of tweets and place them in a database for ongoing use. First, I created a database migration to build the table for them.

All of my tables for this project have the prefix norm_. Here is the Tweet table or norm_tweet:

Next, I used Yii’s Gii scaffolding system to create a model and CRUD files for me. Here’s the model:

Repeating Twitter API - Yiis Gii Scaffolding Model Generator

And here’s the CRUD generation:

Repeating Twitter API - Yiis Gii Scaffolding CRUD Generator

So all of this code automatically provides the grid view below and editing capabilities.

Repeating Twitter API - The Authoring Tweets UX

For now, I’m not using the Media ID, which is for images that are uploaded to be used within tweets. I’ll likely address this in the next episode.

Pretty straightforward so far, right? 

Adding a Range of Hashtags

Then, I repeat this process for the other models. Here’s the norm_hash migration for hashtags:

The idea is to randomly include a selected hashtag (or two) in the tweets to make it appear that the bot is human, varying its tweets. 

Here’s the Hashtag UX:

Repeating Twitter API - The Authoring Hashtags UX

I won’t repeat the Yii Gii steps from above, but I repeat them for norm_hash and norm_url as well.

Adding a Variety of URLs

Here’s the database migration for adding URLs:

The bot master may add URLs at different times. It’s probably best for this bot not to use old URLs or to repeat them. The last_used and created_at Unix timestamps allow the tweeting algorithm described below to decide when to use URLs.

Here’s the URL UX page:

Repeating Twitter API - The Adding URLs UX

Now, let’s look at the fun algorithm to combine all of these tables into interesting tweets that aren’t annoying to Twitter’s Master Overlord of Restrictions.

Randomizing the Content of Bot Tweets

It’s fun to have a bot that tweets a variety of content, but the variety is also helpful at preventing it from getting blocked by Twitter. 

You can see the Twitter Rate Limits here, but some of the rules for content repetition don’t appear to be documented:

Repeating Twitter API - Rate Limits Chart

I took directions from my friend as to how they wanted the algorithm to build tweets from the database of tweets, hashtags, and URLs.

Here’s the build algorithm we decided on for now; it’s easy to tweak. I’ll describe it in parts.

In my opinion the algorithm below is low on its use of hashtags and URLs, and if you want a more robust variety of content, change it to your liking.

First, we use yiidbExpression; to properly select a random single tweet text from the table:

Then we decide whether to use a hashtag (currently 1 in 5 or 20% of the time) and how many to use (currently fixed to just one):

Then, we decide if there is a URL available to use. URLs must be less than a week old and they can only be used once every 72 hours (3 days). So any new URL might only be available for use once, twice or possibly three times before expiring.

Finally, we build the tweet based on the selected data (available URLs are added only one in four times or 25% chance):

Choosing When to Tweet

Yii allows you to call console controllers from cron. So I add a call to my /console/DaemonController.php in crontab.

$ sudo crontab -l

Here’s how my tasks are scheduled:

Every hour, daemon/hourly in /console/DaemonController.php is requested. Our bot app only decides whether to tweet or not once every four hours.

First, you’ll see I have a NormLog table which I didn’t describe above, but that tracks all the output and when tweets were made. So my friend didn’t want to tweet more than once a day. 

We didn’t want followers of our bot to get annoyed by high frequency tweeting.

Then, we pick a number, basically the six times a day (every four hours), and tweet if the number is 6 (or a one in 12 chance).

Delivering the Tweet to the Twitter API

Here’s the NormTweet::deliver() method called by the Daemon to post the tweet:

The account’s Twitter application keys are stored in /bot/frontend/config/params-local.php, configured from the bot.ini file I use:

Bots aren’t simple, but they are fun!

Examining the Results

Here are the results of our bot:

Repeating Twitter API - Tom McFarlin Head Editorial Goddess

Just kidding! That’s one of the editorial goddesses, Tom McFarlin. AI scripts aren’t yet capable of replacing his “insights,” but Envato Tuts+ has hired me to work on this. 

Here’s the actual bot, meant to remind my friend and its followers that America’s new politics aren’t exactly normal. I imagine whatever your views you’d agree with that.

Repeating Twitter API - Bot Tweet Stream from Tutorial

I hope you’ve enjoyed this episode.

What’s Next?

Next, I’m going to create a more marketing-driven platform to help you use the Twitter API to promote your startup, services, and business without getting labeled as a bot and blocked.

If you have any questions or suggestions about this tutorial, please post them in the comments. If you’d like to keep up on my future Envato Tuts+ tutorials and other series, please visit my instructor page or follow @reifman

Related Links


Source: Nettuts Web Development

Web Development Reading List #180: DNS Over HTTPS, HAProxy Performance, And Decentralized AI




 


 

We all have fears and doubts. It’s not different for you than for me. Over the last weeks, “well-known” people on Twitter started to share mistakes they made in life or their careers. I think it’s very helpful to read that we all make mistakes.

Web Development Reading List 180

We all have to learn and improve, and people who are on a stage at an event for the 100th time are still known to be extremely nervous. Let’s realign our views, our expectations and, instead of being afraid of making mistakes, try to improve our knowledge and let others learn from the things that didn’t go as expected.

The post Web Development Reading List #180: DNS Over HTTPS, HAProxy Performance, And Decentralized AI appeared first on Smashing Magazine.


Source: Smashing Magazine

5 Technical SEO Traps to Dodge

5 Technical SEO Mistakes to Dodge

This article is part of an SEO series from WooRank. Thank you for supporting the partners who make SitePoint possible.

Search marketing can bring lots of benefits to your business and provide great marketing ROI. If you do it right, organic search provides you with a high-quality source of qualified traffic. However, SEO is much more than keywords and links. There are lots of technical aspects to SEO that, if you’re not careful, can trip you up and keep your site from performing as well as it could.

Here are five of the most common or trickiest to diagnose technical SEO mistakes you should avoid on your website.

Overzealous Robots.txt Files

Your robots.txt file is an important tool for your website’s SEO, and an integral part of making sure your website is properly crawled and indexed by Google. As we’ve explained in the past, there all sorts of reasons you wouldn’t want a page or folder to get indexed by search engines. However, errors in robots.txt files is one of the main culprits behind SEO problems.

A common technique to mitigate duplicate content issues when migrating a website, disallowing entire servers, will cause whole sites not to get indexed. So, if you’re seeing a migrated site failing to get traffic, check your robots.txt file right away. If it looks like this:

User-agent: *
Disallow: /

You’ve got an overzealous file that’s preventing all crawlers from accessing your site.

Fix this by getting more specific with the commands you issue in your file. Stick to specifying specific pages, folders or file types in the disallow lines like so:

User-agent: *
Disallow: /folder/copypage1.html
Disallow: /folder/duplicatepages/
Disallow: *.ppt$

Of course, if you created the original robots.txt file as part of your website migration, wait until you’re done before you start allowing bots to crawl your site.

Inadvertent NoIndex Tags

The meta robots tag goes hand-in-hand with the robots.txt file. In fact, it can be wise to double up by using the meta robots tag on a page you’ve disallowed via robots.txt. The reason is that robots.txt won’t stop search engines from accessing and crawling a page it finds by following a link from another site.

So it could still wind up indexing pages you don’t want crawled.

The solution to this is to add the meta robots noindex tag (also known just as the noindex tag) to pages you really, really don’t want indexed. It’s a simple tag that goes in a page’s <head>:

<meta name="robots” content=”noindex”>

Again, there are plenty of times you’d want to use the meta robots tag to prevent a page from getting indexed. However, if your pages aren’t getting crawled (you can check this using the site: search operator in Google), this should be one of the first things you check.

If you’ve used the site: search operator to check the number of pages you have indexed and it’s way below the number of pages you actually have, it’s time to crawl your site. Use WooRank’s Site Crawl feature to crawl your pages. Then, click on Indexing. Pages that are disallowed via the meta robots tag will be listed here.

WooRank Site Crawl Indexing meta robots URLs

No problems with meta robots here. Nice.

Unoptimized Redirects

No matter how much you try to avoid using them, 301 redirects are sometimes necessary. 301s (and now 302s) enable you to move pages to new locations and still maintain link juice, authority and ranking power for those pages. However, 301s can only help your site’s SEO if you use them correctly. Implementing them incorrectly, or setting them and then forgetting about them completely, will deteriorate your user experience and search optimization.

Continue reading %5 Technical SEO Traps to Dodge%


Source: Sitepoint

How to Set CSS Margins and Padding (And Cool Layout Tricks)

How to Set CSS Margins and Paddings

This article was peer reviewed by Dave Maxwell, Adrian Sandu, and Panayiotis Velisarakos. Thanks to all of SitePoint’s peer reviewers for making SitePoint content the best it can be!

When I was just starting to learn CSS, the margin and padding properties always confused me. They seemed very similar and in some cases appeared to produce the same result.

In this tutorial, you will learn the difference between CSS margins and padding and how these properties affect the space between elements on a webpage. We will also discuss margin collapsing, the effect of using different units while creating responsive websites, and conclude with some layout tricks you can do with CSS margins and padding.

The Box Model

Elements in CSS are represented as a rectangular box. The size of this rectangular box is determined by the element’s:

  • Content
  • Padding
  • Border
  • Margin

The content area of an element lies in the middle of the element. The padding surrounds the element’s content . The borders in turn surround the padding. The margin of the element is its external layer, i.e., it lies outside the element.

The following diagram should make the arrangement clearer.

Visual representation of CSS margins, padding, border and content

As apparent from the diagram, the padding of an element is the layer that extends from the outer edge of the element’s content to the inner edge of its border. This property is used to control the spacing between the element’s border and its main content. The padding applied on an element affects its size on the webpage. It does not affect the distance between different elements on a webpage.

When you want to increase or decrease the amount of space in-between elements, you should use the margin property. The margin applied on an element won’t have any effect on its size.

One important thing related to boxes that you should keep in mind is that the sizes of all the boxes on a webpage depends on the box model being used. There are two different box models:

  • W3C box model
  • Traditional box model

See the Pen Choosing a Box Model by SitePoint (@SitePoint) on CodePen.

The W3C box model considers the width of the element to be equal to the content of the box excluding its padding and border. Padding and border are added on top of whatever dimensions you set for the element, which could have some unpredictable consequences on your page layout.

For example, let’s consider a box with a width of 200px and a height of 200px, padding of 10px on all sides and a border of 2px all round. The browser does not see it simply as a 200px box. Rather, the browser calculates the horizontal space necessary to display the box as being 224px: 200 (width) + 2 (left border) + 10 (left padding) + 10 (right padding) + 2 (right border) = 224px. Given that the element is a perfect square, the height will also compute to 224px.

On the other hand, the traditional box model considers the width of the element to be equal to the sum of the content, padding and the border applied to the box. On the layout front, this means that, if your box is 200px wide, the browser computes the horizontal space it needs to display the box as being 200px wide, including padding and border. This yields more predictable results and it’s easier to work with.

W3C box model and traditional box model

All browsers use the W3C box model by default. You can choose to specify the box model explicitly by setting the value of the box-sizing property to either content-box (W3C box model) or border-box (traditional box model). The traditional box model, being more intuitive, is the most popular approach among web developers.

Here is how you can set the box-sizing property to follow the traditional box model on your web project:

[code language=”css”]
html {
box-sizing: border-box;
}

*, *:before, *:after {
box-sizing: inherit;
}
[/code]

If you learn best by doing, try experimenting with this fun interactive demo by Guy Routledge.

Setting Margins and Paddings

You can control the padding applied to the four sides of an element using the padding-top, padding-right, padding-bottom and padding-left properties. You can also specify the padding using the shorthand padding property.

  • When a single padding value is present, CSS uses this value to determine the padding of all four sides:

    [code language=”css”]
    /* all four sides */
    padding: 10px;
    [/code]

  • When two values are present, the first value determines the top and bottom padding and the second value determines the left and right padding:

    [code language=”css”]
    /* vertical | horizontal */
    padding: 2em 4em;
    [/code]

  • When three values are present, the first value determines the top padding, the second value determines the left and right padding and the third value determines the bottom padding:

    [code language=”css”]
    /* top | horizontal | bottom */
    padding: 1em 20px 2em;
    [/code]

  • When all four values are present, they set the top, right, bottom and left padding in this exact order:

    [code language=”css”]
    /* top | right | bottom | left */
    padding: 10px 10% 2em 15%;
    [/code]

In the following demo, the orange background represents the content area of different elements and the white area between the borders and the content area represents the padding that we applied on each element:

See the Pen Setting Paddings by SitePoint (@SitePoint) on CodePen.

Just like with padding, you can control the margin applied to the four sides of an element using the margin-top, margin-right, margin-bottom and margin-left properties. You can also specify the margin for all the four sides of an element using the shorthand margin property.

[code language=”css”]
/* all four sides */
margin: 10px;

/* vertical | horizontal */
margin: 2em 4em;

/* top | horizontal | bottom */
margin: 2em auto 2em;

/* top | right | bottom | left */
margin: 10px 10% 2em 15%;
[/code]

Things to Keep in Mind

Continue reading %How to Set CSS Margins and Padding (And Cool Layout Tricks)%


Source: Sitepoint

Functional Programming with Phunkie: Parser Combinators in PHP

Phunkie is a library with functional structures for PHP. In this tutorial, Phunkie creator Marcello Duarte, head of training at Inviqa, explains how to create Parser combinators using the functional library. This post first appeared on the Inviqa blog, and was republished here with their permission.

Phunkie logo

Learning functional programming

Functional programming really matters. Pure functions (or functions with no side effect) are the perfect units of behaviour because we can rely on them to build larger and more complex systems. The greatness of functional programming relies on this power of composability.

That’s something I first came to believe back in the days of my licentiate degree on Computing for Management, during a semester in AI with Lisp. My course curriculum was mostly focused on C/C++, therefore I had to stay focused on where the skills demand was.

Thankfully, I’ve been able to reignite my love of studying functional programming here at Inviqa where we’re delivering more and more projects based on Scala, the general purpose programming language.

I’ve read “the red book” about three times (the Chiusano & Bjarnason one, not the Vaughn Vernon’s one). I took all the Martin Odersky’s Coursera courses, and I spent hours of my weekends watching videos and reading papers.

And I set myself a challenge: to do with functional programming what I did when I was learning TDD and created PHPSpec (a BDD testing and design tool for PHP developers) to help me learn; I decided to write my own functional programming dialect in PHP. And so Phunkie was born!

Now over to you. Learning functional programming means immersing yourself in a new paradigm, which can be challenging. It requires a totally different mindset for approaching problems.

So, by the time you can use functional programming to solve real-world problems, you’ll have spent hours grasping the new thinking or getting clued-up on the theory.

In this tutorial, my aim is to help fast-track your journey by going over my implementation of Hutton & Meijer’s Monadic Parser Combinators. Hopefully you will be able to see both the thinking and the usefulness of functional programming.

And, by using Phunkie, you can eliminate the need to learn Haskell to understand the topic. All you should need is some familiarity with PHP.

So let’s get started!

Continue reading %Functional Programming with Phunkie: Parser Combinators in PHP%


Source: Sitepoint