Monday, November 16, 2015

Basic User Management in Symfony2 with FOSUserBundle

Symfony has a very powerful authentication and authorization system, which can cater to a lot of our needs out of the box. FOSUserBundle is a library built on top of Symfony’s security system, which provides functionality such as registration, login, password resets, etc. It has built in support for MongoDB, as well as ORMs such as Doctrine, Propel, etc.

Users networked graphic

We will use Homestead Improved for our demo.

Add a new site in the Homestead.yml file.

sites:
    - map: symfonylogin.app
      to: /home/vagrant/Code/SymfonyLogin/web
      type: symfony
databases:
    - symfony

This will set up a new site in the VM that points to the web folder of the Symfony application. When type: symfony is specified, it will pick an Nginx configuration that is specifically created for Symfony applications.

We should also add 192.168.10.10 symfonylogin.app into the main operating system’s /etc/hosts file. Now we can boot the VM with vagrant up.

Before we begin, let’s quickly set up the Symfony application using Symfony’s installer, a command line tool for installing Symfony projects. To install the installer, enter the VM using vagrant ssh and run the following commands.

curl -LsS http://ift.tt/1vcjPAo > symfony
sudo mv symfony /usr/local/bin/symfony
chmod a+x /usr/local/bin/symfony

The first command downloads the installer from the Symfony website to the current directory. Then we move it to the bin directory and make it executable.

Now let’s create a Symfony application inside the VM.

cd Code
symfony new SymfonyLogin

This will create a Symfony skeleton application and install all the dependencies from Packagist. Once it’s finished, go to the app/config folder and update parameters.yml with the database and email configuration.

Continue reading %Basic User Management in Symfony2 with FOSUserBundle%


by Shameer C via SitePoint

Nicolas Tarier

opl-small

Gorgeous load transitions when browsing between projects in this AJAX loading One Pager for Art Director, Nicolas Tarier. Lovely touch too with the zoom background when viewing his About section.

by Rob Hope via One Page Love

Le Mugs

opl-small

Parallax scrolling One Pager that comes to life as you scroll for 'Le Mugs' - a hip canteen in Saint-Raphaƫl, France.

by Rob Hope via One Page Love

Sketch App: 10 New Enhancements that Will Make You Giddy

Despite the fact that the latest updates to Sketch don't include any new major features releases, they are otherwise a brilliant string of improvements that I thought it was worth pulling together a short article ticking the off. There really is no better time to be a Sketch user.

While the Sketch team has always taken a simplified, minimalist approach to the Sketch application, bugs are a normal part of all software design, and I have to applaud the Bohemian Coding team for their hard work and transparency in regards to updates and bug fixes.

Sketch 3.4x

So, let's take a look at 10 of the app's best enhancements that will surely speed up your workflow, some of which will reduce tears and some others that improve team collaboration in a big way.

1. Improved, More Predictable Copy and Paste

Pretty much everybody uses Copy and Paste, especially me because I'm lazy and I usually begin styling new layers by copy-duplicating similar layers. Anyone that has ever experienced the rage-inducing issue where you cmd+v a copied layer and it appears in the netherworld of the canvas will rejoice at this beautiful news.

 IMPROVED, MORE PREDICTABLE COPY AND PASTE

Back in Sketch 3.2, Bohemian Coding introduced the "Paste Here" feature to the context menu and at the time it was the only sane way to to copy layers, but as many of you will know, a quick, handy keyboard shortcut is a much better solution. Now you can use the much-loved cmd+c and cmd+v shortcuts as normal.

Version 3.4 also improves the user experience of the layer list too. If you right-click on a layer from the list and open the context menu you'll see the option to "Paste Over", which is especially useful for when you need to be very specific.

Paste Over Context Menu

2. Smart Guide Functionality Now Extends to the Layer List

[author_more]

[/author_more]

By selecting a layer, holding option and hovering over another layer (also known as option-hover), we can measure the distance between them both. Any regular Sketch App user will know this as a Smart Guide, and although it's arguably Sketch's most useful feature, it can be a hassle to use it on nested layers.

With the new Sketch App update you can activate Smart Guides by option-hovering layers from inside the layer list - this helps Sketch understand exactly which layers you'd like to compare.

Smart Guides in Layer List

Alternatively, you can now use the well-known command shortcut while option-hovering to click-through to the nested layers, saving us bundles of time when repositioning layouts.

3. Artboards Can Be Shared on the Local Network

If you're working in a team, click "Share" (in the menu bar, next to "Mirror") to let your collaborators see what you're working on from their browsers. As long as you're all on the same network, this works instantly, and for anybody - no setup required.

Local Network Sharing

Most importantly, it updates on-the-fly; sort of like a live Sketch feed! Before version 3.4 we had to rely on collaborative tools like InVision App, Sketch Plugins such as Easier.cc and Slack, or even old-school e-mail, however if you're working remotely with your team you will still have to use those tools.

Local network artboard sharing is the closest thing to a new feature in any of the Sketch 3.4.x updates. Personally, I'm rather thankful that Bohemian Coding is focusing on the user experience of current features before bringing out any new ones.

4. Fresh Artboard Presets and Template Files

Sketch is admired for its variety of artboard presets and template files, so not only have they updated the app with new Android icon templates, but Sketch 3.4.2 is expected to include both iPad Pro and Apple tvOS goodies. At the time of writing, Sketch App 3.4.2 is only available as a beta, but that could change in a matter of days.

New Android Icon Templates

5. Improved Undo/Redo reliability

Both undoing (command+z) and redoing (command+shift+z) could quickly become a nightmare and I don't think anybody ever really figured out why. If you tried to undo a change on a Shared Style or Symbol it would only work on the layer that's currently being edited, messing up your entire document.

Problems would also arise when undo wouldn't let you revert back to the last step, and so you would unknowingly undo all of your steps (or however many times you frustratingly tried to undo).

6. Plugins Can Now Be Managed Inside the Preferences Pane

Plugins can now be turned on and off - all you have to do is navigate to File → Preferences and untick the undesirables. Performance can be hindered by installing too many extras and that could result in application crashes. On top of that, there's a handy link to Bohemian Coding's own curation of recommend Sketch Plugin's.

Plugin Preferences

For those worried about Sketch App 3.4's incompatibility with certain plugins, don't worry, this was swiftly fixed in 3.4.1.

7. Symbols Now Play Nice with Multiple Font Styles in Text Layers

We don't always need to specify margins between different blocks of text; sometimes a simple line break is fine – and that allows us to keep various blocks of text inside a single text layer.

Symbols however would assume only the first font style used in the text layer and apply it to the entire layer. You could change it manually but it was a real hassle if you had lots of symbols!

8. "Replace Image…" Option When Right-Clicking Images

Replace Image might be one of the most underrated new features of Sketch App because you won't need it (probably) until the very end. Let's say that you're using a watermarked stock image because the client hasn't signed off on it yet, and you then need to replace it with the higher-quality, licensed version later on.

"Replace Image" makes that task insanely easy.

Replace Image

If this concept sounds a little familiar to you, it's because Photoshop began rolling out a similar feature in Adobe Creative Cloud 2015, called Adobe Stock.

9. New Gradients Are Based on the Fill Colour By Default

Gradient tuners are one of those finicky interfaces that are unpleasant to fiddle with, which is especially annoying when all we want to achieve is a slight amount of depth to a button.

Sketch App's famous intuition improves the user experience once again by subtly suggesting gradients based on the colour you've chosen for the Fill. Before, the style would default to an abhorrent black-to-white gradient that made no one happy.

Continue reading %Sketch App: 10 New Enhancements that Will Make You Giddy%


by Daniel Schwarz via SitePoint

Up and Running With Realm for Android

Introduction

If you have been keeping up with the latest trends in Android development, you’ve probably heard of Realm. Realm is a lightweight database that can replace both SQLite and ORM libraries in your Android projects.

Compared to SQLite, Realm is faster and has lots of modern features, such as JSON support, a fluent API, data change notifications, and encryption support, all of which make life easier for Android developers.

In this quick tip, you are going to learn the basics of Realm for Android. In this tutorial, I will be useing Realm v0.84.1.

1. Adding Realm to a Project

To use Realm in an Android project, you need to add it as a compile dependency in the app module’s build.gradle file.

2. Creating a Realm

A Realm is similar to a SQLite database. It has a file associated with it, which, once created, will persist on Android’s file system.

To create a new Realm, you can call the static Realm.getInstance method from inside any Activity.

Note that calling Realm.getInstance, without passing a RealmConfiguration to it, results in the creation of a Realm file called default.realm.

If you want to add another Realm to your app, you must use a RealmConfiguration.Builder object and give the Realm file a unique name.

3. Creating a RealmObject

Any JavaBean can be stored in a Realm once it extends the RealmObject class. If you are wondering what a JavaBean is, it is simply a Java class that is serializable, has a default constructor, and has getter/setter methods for its member variables. For example, instances of the following class can be easily stored in a Realm:

If you want to use a member variable of a RealmObject as a primary key, you can use the @PrimaryKey annotation. For example, here’s how you would add a primary key called code to the Country class:

4. Creating Transactions

While reading data from a Realm is very simple, as you will see in the next step, writing data to it is slightly more complex. Realm is ACID compliant and to ensure atomicity and consistency, Realm forces you to execute all write operations inside a transaction.

To start a new transaction, use the beginTransaction method. Similarly, to end the transaction, use the commitTransaction method.

Here’s how you would create and save an instance of the Country class:

You might have noticed that country1 was not created using the constructor of the Country class. For a Realm to manage an instance of a RealmObject, the instance must be created using the createObject method.

If you must use the constructor, don’t forget to use the copyToRealm method of the relevant Realm object before you commit the transaction. Here’s an example:

5. Writing Queries

Realm offers a very intuitive and fluent API for creating queries. To create a query, use the where method of the relevant Realm object and pass the class of the objects you are interested in. After creating the query, you can fetch all results using the findAll method, which returns a RealmResults object. In the following example, we fetch and print all objects of type Country:

Realm offers several aptly named methods, such as beginsWith, endsWith, lesserThan and greaterThan, you can use to filter the results. The following code shows you how you can use the greaterThan method to fetch only those Country objects whose population is greater than 100 million:

If you want the results of the query to be sorted, you can use the findAllSorted method. As its arguments, it takes a String specifying the name of the field to sort by and a boolean specifying the sort order.

Conclusion

In this quick tip, you learned how to use Realm in an Android project. You saw how easy it is to create a Realm database, store data in it, and query it. To learn more about Realm for Android, you can go through its Java documentation.


by Ashraff Hathibelagal via Envato Tuts+ Code

Slayer

opl-small

Excellent to see Slayer turn their official website into a One Pager to promote their eleventh studio album, Repentless.

by Rob Hope via One Page Love

Jigsaw Landing Page Kit (71% off)

opl-small

A quick heads up on this Landing Page Kit promo (71% off) happening on MightyDeals for the next day or so. Simply put this is a "builder" that allows you to build a One Pager using a drag-n-drop interface builder. Once you have put together a good Landing Page you simply export the HTML and upload the files to your hosting. The kit has 117 components and 30 pre-built templates - all for $17 - hilarious actually. There is also a live demo to play with, so you can try before you buy too.

by Rob Hope via One Page Love