Tuesday, April 11, 2017

Building a Python Code Review Scheduler: Sending Review Requests

Essentials by Grooow

Essentials

Smart long-scrolling Landing Page promoting the 'Essentials' template pack for Cornerstone page builder. The Single Page website is build using Cornerstone of course;) Lovely little touch with the animation within the Pro tier of the pricing table.

by Rob Hope via One Page Love

Uploading With Rails and Paperclip

This is the last article in the "Uploading with Rails" series. In the past couple of months we have already discussed the Shrine, Dragonfly, and Carrierwave gems. Today's guest is Paperclip by Thoughtbot, a company which manages gems such as FactoryGirl and Bourbon.

Paperclip is probably the most popular attachment management solution for Rails (more than 13 million downloads), and for a good reason: it has lots of features, a great community, and thorough documentation. So hopefully you are eager to learn more about this gem!

In this article you will learn how to:

  • Prepare for Paperclip installation
  • Integrate Paperclip into a Rails application
  • Add attachment validations
  • Generate thumbnails and process images
  • Obfuscate URLs
  • Store attachments on Amazon S3
  • Secure files in the cloud by introducing authorization logic

The source code for this article is available on GitHub.

Preparations

Before we dive into the code, let's firstly discuss some caveats that you need to know about in order to successfully work with Paperclip:

  • The latest version of Paperclip supports Rails 4.2+ and Ruby 2.1+. This gem can also be used without Rails.
  • ImageMagick must be installed on your PC (it is available for all major platforms), and Paperclip should be able to access it.
  • The file command should be available from the command line. For Windows it is available via Development Kit, so follow these instructions if you don't have DevKit installed yet.

When you are ready, go ahead and create a new Rails application (I will be using Rails 5.0.2) without the default testing suite:

Integrating Paperclip

Drop in the Paperclip gem:

Gemfile

Install it:

Suppose we are creating a bookshelf application that presents a list of books. Each book will have a title, a description, an author's name, and a cover image. To start off, generate and apply the following migration:

Note the attachment type that is presented for us by Paperclip. Under the hood, it is going to create four fields for us:

  • image_file_name
  • image_file_size
  • image_content_type
  • image_updated_at

In contrast to the Shrine and Carrierwave gems, Paperclip does not have a separate file with configurations. All settings are defined inside the model itself using the has_attached_file method, so add it now:

models/book.rb

Before proceeding to the main part, let's also create a controller along with some views and routes.

Creating the Controller, Views, and Routes

Our controller will be very basic:

books_controller.rb

Here is an index view and a partial:

views/books/index.html.erb

views/books/_book.html.erb

Now the routes:

config/routes.rb

Nice! Now let's proceed to the main section and code the new action and a form.

Uploading Files

All in all, doing uploads with Paperclip is easy. You only need to permit the corresponding attribute (in our case that's the image attribute, and we've already permitted it) and present a file field in your form. Let's do it now:

views/books/new.html.erb

views/books/_form.html.erb

With this setup, you can already start performing uploads, but it's a good idea to introduce some validations as well.

Adding Validations

Validations in Paperclip can be written using old helpers like validates_attachment_presence and validates_attachment_content_type or by employing the validates_attachment method to define multiple rules at once. Let's stick with the latter option:

models/book.rb

The code is really simple, as you can see. We require the file to be an image less than 1 megabyte in size. Note that if the validation fails, no post-processing will be performed. Paperclip already has some errors messages set for the English language, but if you want to support other languages, include the paperclip-i18n gem into your Gemfile.

Another important thing to mention is that Paperclip requires you to validate content type or filename of all attachments, otherwise it will raise an error. If you are 100% sure you don't need such validations (which is a rare case), use do_not_validate_attachment_file_type to explicitly say which fields shouldn't be checked.

Having added validations, let's also display error messages in our form:

views/shared/_errors.html.erb

views/books/_form.html.erb

Displaying Images

Okay, so now the uploaded images should be displayed somehow. This is done by using the image_tag helper and a url method. Create a show view:

views/books/show.html.erb

We are displaying an image only if it really exists on the drive. Moreover, if you are using cloud storage, then Paperclip will perform a network request and check the file's existence. Of course, this operation may take some time, so you might use the present? or file? methods instead: they will simply make sure that the image_file_name field is populated with some content.

URI Obfuscation

By default, all attachments are stored inside the public/system folder, so you will probably want to exclude it from the version control system: 

.gitignore

However, displaying a full URI to the file may not always be a good idea, and you might need to obfuscate it somehow. The easiest way to enable obfuscation is by providing two parameters to the has_attached_file method:

models/book.rb

The proper values will be interpolated into the url automatically. hash_secret is a required field, and the easiest way to generate it is by using:

Working With Styles

In many cases, it is preferred to display an image's thumbnail with some predefined width and height to save bandwidth. Paperclip solves this by using styles: each style has a name and a set of rules, like dimensions, format, quality, etc.

Suppose that we want the original image and its thumbnail to be converted to JPEG format. The thumbnail should be cropped to 300x300px:

models/book.rb

# is a geometry setting meaning: "Crop if necessary while maintaining aspect ratio."

We can also provide additional conversion options for each style. For example, let's provide 70% quality for thumbs while removing all metadata and 90% quality for the original image to make it a bit smaller:

models/book.rb

Nice! Display the thumbnail and provide the link to the original image:

views/books/show.html.erb

Note that unlike Carrierwave, for example, Paperclip does not allow you to write @book.image.thumb.url.

If, for some reason, you wish to manually update uploaded images, then you may use the following commands to refresh only thumbnails, add missing styles, or refresh all images:

  • rake paperclip:refresh:thumbnails CLASS=Book
  • rake paperclip:refresh:missing_styles CLASS=Book
  • rake paperclip:refresh CLASS=Book

Storing Files in the Cloud

Like all similar solutions, Paperclip allows you to upload files to the cloud. Out of the box, it has support for the S3 and Fog adapters, but there are third-party gems for Azure and Dropbox as well. In this section, I will show you how to integrate Paperclip with Amazon S3. First, drop in the aws-sdk gem:

Install it:

Next, provide a new set of options to the has_attached_file method:

models/book.rb

Here I am sticking to the dotenv-rails gem to set environment variables. You may provide all values directly inside the model, but do not make it publicly available.

What's interesting is that s3_credentials also accepts a path to a YAML file containing your keys and a bucket name. Moreover, you can set different values for different environments like this: 

That's it! All the files you upload will now be located in your S3 bucket.

Securing Files in the Cloud

Suppose you don't want your uploaded files to be available to everyone. By default, all uploads into the cloud are marked as public, meaning that anyone can open the file via the direct link. If you wish to introduce some authorization logic and check who is able to view the file, set the s3_permissions option to :private like this:

Now, however, no one except for you will be able to see the files. Therefore, let's create a new download action for the BooksController:

books_controller.rb

This action will simply redirect users to the image via an expiring link. Using this approach, you can now introduce any authorization logic using gems like CanCanCan or Pundit.

Don't forget to set the member route:

config/routes.rb

The helper should be used like this:

Conclusion

We've come to the end of this article! Today we have seen Paperclip, an attachment management solution for Rails, in action and discussed its main concepts. There is much more to this gem, so be sure to view its documentation.

Also, I recommend visiting Paperclip's wiki page as it presents a list of "how to" tutorials and a bunch of links to third-party gems supporting Azure and Cloudinary and allowing you to easily minify uploaded files.

Thank you for staying with me, and see you soon!


by Ilya Bodrov via Envato Tuts+ Code

5 Free Instagram Analytics Tools for Marketers

Do you want a better way to analyze your Instagram marketing efforts? Looking for free tools to help? The right Instagram tools can provide analytics to inform your social media strategy and content scheduling. In this article, you’ll discover five free Instagram analytics tools for marketers. #1: Instagram Insights If you’ve set up your Instagram [...]

This post 5 Free Instagram Analytics Tools for Marketers first appeared on .
- Your Guide to the Social Media Jungle


by Jill Holtz via

15 Inspiring Talks on Inclusive Design

Inclusive design is about so much more than designing for people with disability. You never know the exact context of how a user interacts with your product.

As highlighted in this example, the reasons a person could be using your product with only one arm could vary from permanent injury, a temporary condition, to a new parent who only has one arm free while nursing a newborn.

Everyone is different, and we all have a role to play in creating inclusive (digital) experiences.

These talks and videos provide the foundations for what makes accessible and inclusive design, and will help you see the world through another’s eyes.

UX Mastery: Everyone is Different!

Duration: 3:56

Produced by us in partnership with the team from Accessibility Bytes (http://a11ybytes.org) for Global Accessibility Awareness Day, this video is an introduction to accessibility for creators of digital experiences.

More: http://ift.tt/11mHqGx

Microsoft Design: Introduction to Inclusive Design

Duration: 3:15

Learn how inclusivity informs design in the best ways, and how we can start to imagine more mindful solutions.

Jinsop Lee: Design for All 5 Senses

Duration: 9:03

Good design looks great, yes — but why shouldn’t it also feel great, smell great and sound great? Designer Jinsop Lee shares his theory of 5-sense design, with a handy graph and examples. His hope: to inspire you to notice great multisensory experiences.

Michael Nesmith: Why We Need Universal Design

Duration: 10:29

Michael is a deaf and native American Sign Language speaker working as a creative designer for Amazon. Throughout his career, Michael’s visual/conceptual way of thinking and problem solving have served him both as an asset and a challenge. He finds solutions around his disability through Universal Design.

Microsoft: Inclusive Design Sprint: Team Xbox

Duration: 4:55

In an intensive one-week design sprint, team Xbox came together to re-imagine the possibilities in social gaming through the lens of inclusive design.

More: http://ift.tt/1VFRzsY

Derek Featherstone: Accessibility is a Design Tool

Duration: 29:32
Designing for extreme use cases—outliers—results in a design process that leads to greater success in developing products that are more easily used by everyone. By systematically factoring these extremes into our designs we spark creativity and behaviours that encourage divergent thinking and help to ensure that what we create can be used by everyone, including people with disabilities.

More: http://ift.tt/2olGL60

Elle Waters: Lean Accessibility – Building inclusive design into your agile workflow

Duration: 53:42

Accessibility has a brand problem. But just as agile-minded thinking can transform your company’s culture, accessibility integration can actually serve as a catalyst for innovation and continuous improvement within your agile process. Learn how agile and accessibility make excellent partners in building a lean, cost-effective practice of user-centered, value-based design and development.

Sara Wachter Boettcher: Design for Real life at Delight Conference

Duration: 42:18

We can’t always predict who will use our products, or what emotional state they’ll be in when they do. But we have the power—and the responsibility—to build compassion into every aspect of our products, and to advocate for experiences that support more of our users, more of the time. Sara will share principles and practical approaches from Design for Real Life, her new book with coauthor Eric Meyer.

More: http://ift.tt/2ouLrbR

Neil Harbisson: I listen to colour

Duration: 9:35

Artist Neil Harbisson was born completely color blind, but these days a device attached to his head turns color into audible frequencies. Instead of seeing a world in grayscale, Harbisson can hear a symphony of color — and yes, even listen to faces and paintings.

Elise Roy: When we design for disability, we all benefit

Duration: 13:17

“I believe that losing my hearing was one of the greatest gifts I’ve ever received,” says Elise Roy. As a disability rights lawyer and design thinker, she knows that being Deaf gives her a unique way of experiencing and reframing the world — a perspective that could solve some of our largest problems. As she says: “When we design for disability first, you often stumble upon solutions that are better than those when we design for the norm.”

Kevin Shaw: Design the Inclusive Experience

Duration: 19:00

Kevin Shaw’s talk is structured around the reality that a person isn’t disabled, rather the environment is. Kevin talks about his visual impairment and the work he has been doing with Zagga entertainment while emphasizing on the purpose of inclusive technology. Kevin tells the story of how he developed this service and discuss how tomorrow’s leaders can create inclusive experiences in media and other disciplines.

Microsoft Design: Inclusive the Film

Duration: 21:07

Learn how human-led design makes a deep and connecting impact, leading to innovative and inclusive solutions.

Ron McCallum: How technology allowed me to read

Duration: 15:44

Months after he was born, in 1948, Ron McCallum became blind. In this charming, moving talk, he shows how he reads — and celebrates the progression of clever tools and adaptive computer technologies that make it possible. With their help, and the help of volunteers, he’s become a lawyer, an academic, and, most of all, a voracious reader. Welcome to the blind reading revolution.

David Eagleman: Can we create new senses for humans?

Duration: 20:34

As humans, we can perceive less than a ten-trillionth of all light waves. “Our experience of reality,” says neuroscientist David Eagleman, “is constrained by our biology.” He wants to change that. His research into our brain processes has led him to create new interfaces — such as a sensory vest — to take in previously unseen information about the world around us.

Chieko Asakawa: How new technology helps blind people explore the world

Duration: 9:29

How can technology help improve our quality of life? How can we navigate the world without using the sense of vision? Inventor and IBM Fellow Chieko Asakawa, who’s been blind since the age of fourteen, is working on answering these questions. In a charming demo, she shows off some new technology that’s helping blind people explore the world ever more independently … because, she suggests, when we design for greater accessibility, everyone benefits.

The post 15 Inspiring Talks on Inclusive Design appeared first on UX Mastery.


by Natassja Hoogstad Hay via UX Mastery

Radioaktive Film

Ukrainebased film production company offering a complete range of services in Ukraine
by via Awwwards - Sites of the day

Monday, April 10, 2017

How To Access Free AdWords Advertising For Charities

You want to increase exposure for your charity in 2017 and beyond? Advertising can be fiendishly expensive and ultimately the more money that can go to the cause rather than the administration the better. Fortunately, Google want to give you some free advertising!

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

by Guest Author via Digital Information World