by Rob Hope via One Page Love
"Mr Branding" is a blog based on RSS for everything related to website branding and website design, it collects its posts from many sites in order to facilitate the updating to the latest technology.
To suggest any source, please contact me: Taha.baba@consultant.com
Monday, November 14, 2016
Martin Legrand
by Rob Hope via One Page Love
UX Talks
by Rob Hope via One Page Love
From Novice to Ninja: How to Master Using Plugins in Rails
[special]This article is an excerpt from "Rails: Novice To Ninja" by Glenn Goodrich and Patrick Lenz. You can purchase the full version of this book here.[/special]
Rails Plugins
While this book is unable to cover all of the built-in functionality that ships with Rails—and there's plenty of functionality for you to discover and experiment with once you're beyond the last chapter— the plugins architecture of Rails warrants our attention.
What is a plugin?
A plugin is a component that you can add to your application to extend its functionality. While you can certainly write your own plugins, we'll limit our discussion here to using existing plugins. Plugins have been developed for various parts of the Rails framework, adding functionality such as:
- extensions to ActiveRecord functionality
- helper methods
- new template engines (for coding a view using an alternate templating language)
The number of existing Rails plugins is enormous and grows every day. Programmers in the Ruby and Rails communities are excellent about sharing code and creating useful plugins based on extensions they need. A good resource of existing Rails plugins can be found by searching for "Rails" on the Rubygems site or on the Ruby Toolbox site.
Plugins are distributed as gems, which we covered in Chapter 2. Plugins can be pulled into an existing Rails application by adding them to the Gemfile
and running bundle install
. You probably remember our discussion about Bundler from Chapter 4, where its job is to manage application dependencies. Bundler makes including existing plugins into our app a breeze.
Finding a plugin that does what you require is usually just a Google or RubyGems search away. As seen in Figure 10-1, searching for "rails tagging" brings up a few gems that have been created, including one called acts-as-taggable-on
.
[caption id="attachment_143334" align="alignnone" width="806"] Figure 10-1. Searching for a plugin on "rails tagging"[/caption]
The overwhelming majority of gems keep their source on GitHub, including acts-as-taggable-on
from the first link in our search above. Following that link leads to the source on GitHub, as shown in Figure 10-2.
[caption id="attachment_143336" align="alignnone" width="1024"] 10-2. The GitHub repository for 'acts-as-taggable-on' [/caption]
Most GitHub source repositories have a README
or README.md
file that explains what the gem does, how to install and use it, and so on. acts-as-taggable-on
follows this convention, which can be seen in Figure 10-3. It explains the object of the gem, the supported versions of Rails, as well as how to install and configure the gem.
[caption id="attachment_143337" align="alignnone" width="1024"] 10-3. A standard README file.[/caption]
After reading through the README.md
, we now know how to pull the gem into our application and use its functionality. You may feel that walking through the topic of "how to find and learn about gems" is a bit tedious, but you will find yourself spending loads of time doing just that–so I figured it was tedium well spent.
No Time for Name-calling
There are many ways to extend Rails; for example, by using a "plugin", "engine", and "railtie", to name a few. While there are technical differences between these items, they are often (incorrectly) used interchangeably. Defining these terms and their differences is beyond the scope of this book, so I'm going to stick to the word "plugin" for now. As you grow in your Rails-fu, you'll no doubt want to do some research around Rails extensibility. Boom–I just turned this note into an EXTRA CREDIT!
Okay, enough theory! Let's go ahead and install our first plugin.
Continue reading %From Novice to Ninja: How to Master Using Plugins in Rails%
by Glenn Goodrich via SitePoint
Let's Go: Golang Code Organization
Go is a special language among modern languages. It is very opinionated. For example, there is one true formatting. Go will tell you how to space your code and where to put your curly braces. But it goes much deeper than that.
Go will also tell you how to capitalize your functions and variables to make them public or private. It will dictate the directory structure of your code. This may come as a surprise for developers coming to Go from more liberal programming languages.
In this article, I'll explore some of Go's restrictions, discuss their merits, and suggest options for common situations.
Project Euler
When I started learning Go, I created a solution to Problem #6 and just put it in a sub-directory alongside solutions to other problems in other languages. See Project Euler.
The issue is that Go doesn't want you to just scatter Go files randomly all over the place. I later realized that while it works in very simple cases where you don't import other packages, it is not proper.
Dependencies
Every non-trivial program is composed of multiple files or modules or components or classes. I'll just use "file" as a general term. They are often grouped in libraries or packages or assemblies. I'll just use "package" as a general term. The code you write depends on code in other files and packages.
You need to tell your code how to find those packages and files in order to use their functionality. Each language has its own term: import, include, require. I'll just use "import" as a general term.
Some languages (or language specific tools) also allow you to install dependencies from a remote package repository and install them into a standard local location you can import from.
In most common programming languages, you have a lot of freedom. In C/C++, you tell the compiler/linker where the files and static libraries are (using command-line switches or environment variables like INCLUDE_DIR). In Python, you can install packages from PyPI using setup.py or with pip from PyPI and remote source control repositories. You then import based on the sys.path package search path.
The Go Way
Go, as always, is more prescriptive. It may offend your creativity that you don't get as much say about where to place things, but at the end of the day it doesn't really matter, and there is enough flexibility to accommodate various situations.
Go requires that you put your code in a workspace. A workspace is just a directory with three sub-directories: src, pkg, and bin. It is recommended that you keep all your projects under a single workspace. This way they can depend on each other and share common third-party packages.
Note: I currently work on Windows and use PowerShell for many of the interactive examples. For the following section, I wanted to show the directory structure of my workspace using the tree
command. Windows has its own tree.exe command, but it is very limited (no levels). There is allegedly a full-fledged tree command for Windows here.
But the site was unreachable. I ended up firing a Docker container running Ubuntu, mounting my Go workspace as /docs/Go, and using the Linux tree command to show it. So don't be confused if you see a Linux environment showing Windows directories and files with .exe suffixes.
Here is my current Go workspace. The bin
directory contains various Go commands/tools, and the delve debugger. The pkg
dir has a sub-directory with the platform (Win 64) that contains the packages organized by their origin (github.com, golang.com, etc.). The src
directory has similar sub-directories for the origin repository or website (github.com, golang.org, etc.).
root@67bd4824f9d5:/docs/Go# tree -n -L 3 |-- bin | |-- dlv.exe | |-- go-outline.exe | |-- go-symbols.exe | |-- gocode.exe | |-- godef.exe | |-- golint.exe | |-- gometalinter.exe | |-- gopkgs.exe | |-- gorename.exe | |-- goreturns.exe | `-- guru.exe |-- pkg | `-- windows_amd64 | |-- github.com | |-- golang.org | |-- gopkg.in | `-- sourcegraph.com `-- src |-- github.com | |-- alecthomas | |-- derekparker | |-- go-web-crawler | |-- golang | |-- google | |-- lukehoban | |-- multi-git | |-- newhook | |-- nsf | |-- rogpeppe | |-- tpng | `-- x |-- golang.org | `-- x |-- gopkg.in | `-- alecthomas `-- sourcegraph.com `-- sqs 27 directories, 11 files
Let's take a look inside one of the source projects I created under src
: the go-web-crawler. It is pretty simple here: just a flat list of Go files, a license, and a README file.
root@67bd4824f9d5:/docs/Go# tree src/http://ift.tt/2fRNh06 -n src/http://ift.tt/2fRNh06 |-- LICENSE |-- README.md |-- channel_crawl.go |-- main.go `-- sync_map_crawl.go 0 directories, 5 files
GOROOT and GOPATH
Two environment variables control your destiny in the land of Go. GOROOT
is where the Go installation is:
09:21:26 C:\Users\the_g\Documents\Go> ls Env:\GOROOT Name Value ---- ----- GOROOT C:\Go\ 09:21:35 C:\Users\the_g\Documents\Go> ls c:\go Directory: C:\go Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 8/16/2016 10:38 AM api d----- 8/16/2016 10:38 AM bin d----- 8/16/2016 10:38 AM blog d----- 8/16/2016 10:38 AM doc d----- 8/16/2016 10:38 AM lib d----- 8/16/2016 10:38 AM misc d----- 8/16/2016 10:38 AM pkg d----- 8/16/2016 10:38 AM src d----- 8/16/2016 10:38 AM test -a---- 8/16/2016 1:48 PM 29041 AUTHORS -a---- 8/16/2016 1:48 PM 1168 CONTRIBUT -a---- 8/16/2016 1:48 PM 40192 CONTRIBUT -a---- 8/16/2016 1:48 PM 1150 favicon.i -a---- 8/16/2016 1:48 PM 1479 LICENSE -a---- 8/16/2016 1:48 PM 1303 PATENTS -a---- 8/16/2016 1:48 PM 1638 README.md -a---- 8/16/2016 1:48 PM 26 robots.tx -a---- 8/16/2016 1:48 PM 5 VERSION
Note that the Go root directory looks like a superset of a workspace with the src, bin, and pkg directories.
GOPATH
points to your workspace. That's how Go finds your code.
09:21:53 C:\Users\the_g\Documents\Go> ls Env:\GOPATH Name Value ---- ----- GOPATH c:\Users\the_g\Documents\Go
There are a bunch of other Go related environment variables, many of which you were required to set in the past (e.g. GOOS
and GOARCH
). Now, they are optional, and you should not mess with them unless you really need to (e.g. when cross-compiling). To see all the Go environment variables, type: go env
.
09:51:10 C:\Users\the_g> go env set GOARCH=amd64 set GOBIN= set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=c:\Users\the_g\Documents\Go set GORACE= set GOROOT=C:\Go set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set CC=gcc set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 set CXX=g++ set CGO_ENABLED=1
Installs and Imports
When you create a Go program or a library, you can install it. Programs go to your workspace's bin
directory, and libraries go to the workspace's pkg
directory. On Windows, I discovered that your %GOPATH%/bin
is not in the %PATH%
directory, so Windows couldn't find my executable. I added it to the Windows PATH and everything worked. Here is how to check in PowerShell that your PATH contains your workspace bin directory:
10:56:19 C:\Users\the_g> $env:path.split(";") | grep go C:\Go\bin c:\Users\the_g\Documents\Go\bin
Let's see all that in action.
If I go to my go-web-crawler directory and type go install
then go-web-crawler.exe is created in c:\Users\the_g\Documents\Go\bin
:
11:09:18 C:\Users\the_g> ls $env:GOPATH/bin Directory: C:\Users\the_g\Documents\Go\bin Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 8/15/2016 11:05 AM 15891456 dlv.exe -a---- 8/15/2016 10:08 AM 3972608 go-outline.exe -a---- 8/15/2016 10:10 AM 4502528 go-symbols.exe -a---- 9/18/2016 10:14 AM 1849856 go-web-crawler.exe -a---- 8/15/2016 10:08 AM 12097024 gocode.exe -a---- 8/15/2016 10:17 AM 6642688 godef.exe -a---- 8/15/2016 9:32 AM 6625792 golint.exe -a---- 8/15/2016 10:14 AM 6352896 gometalinter.exe -a---- 8/15/2016 10:10 AM 2738688 gopkgs.exe -a---- 8/15/2016 10:10 AM 6961152 gorename.exe -a---- 8/15/2016 10:09 AM 7291904 goreturns.exe -a---- 8/15/2016 10:11 AM 9722368 guru.exe
I can now run it from my Go web crawler from anywhere.
11:10:32 C:\Users\the_g> go-web-crawler.exe found: http://golang.org/ "The Go Programming Language" found: http://golang.org/cmd/ "" not found: http://golang.org/cmd/ found: http://golang.org/pkg/ "Packages" found: http://ift.tt/SYJMCr "Package os" found: http://ift.tt/1i4Ho7x "Package fmt" found: http://golang.org/ "The Go Programming Language"
Multiple Go Environments
That's all fine, but sometimes life is not so simple. You may want to have multiple separate workspaces. What's more, you may want to have multiple installations of Go (e.g. different versions) and multiple workspaces for each one. You can do this by dynamically setting GOPATH
for changing the workspace and setting GOROOT
for changing the active Go installation.
There are various open-source projects for vendoring, package management, and virtual environments. For some reason, most don't support Windows. I'm not sure why such tools have to be platform-specific. I may write a cross-platform Go environment manager myself one of these days.
Conclusion
Go is all about eliminating incidental complexity. Sometimes it comes off as very strict and prescriptive. But if you get into the mindset of the Go designers, you start to understand that avoiding, forbidding or mandating certain things really makes everything simpler.
by Gigi Sayfan via Envato Tuts+ Code
The “Most Loved” One Page Websites from October 2016
Octobers “Most Loved” One Page website round-up is brought to you by hosting provider, Bluehost.
Bluehost is the most affordable hosting option to host your One Page websites. They have an incredible $2.95/month deal exclusive to One Page Readers where you can host your website with 50GB diskspace and unlimited bandwidth. They also throw in a free domain!
If you want to receive these “Most Loved” awards in your inbox each month, subscribe to our Inspiration Newsletter.
Below are the 7 One Page websites we awarded “Most Loved” in October – hope you enjoy!
Best Friends Forever (Portfolio)
Gorgeous big imagery in this parallax scrolling One Pager for Melbourne-based design studio, Best Friends Forever. The awesome SVG illustrations and animations (by Sean Morris) bring so much character to the portfolio. Also a great references to a quality team section – especially the additional founder section further down that animates. We forget how important building trust is for when potential clients browse our portfolios.
ScrollReveal (Download)
Slick One Pager for ‘ScrollReveal’ – a tiny JS library by Julian Lloyd that allows easy scroll animations for web and mobile browsers. What a beautiful way to showcase a JS library – tons of color, gorgeous animation and of course a perfect demonstration of the product.
NewActon (Accommodation, Informational, Landing Page, Restaurant)
AJAX loading One Pager that forms a visual directory for Canberra’s arts and cultural precinct, NewActon. The Single Page website features lovely illustrations representing each category of residency/service within the location. What a special x-factor how the site uses a dynamic weather driven color palette to reflect the mood of the precinct in the website itself (you can demo this by changing the day of weather bottom-left).
Luca (Restaurant)
Spacious, colorful One Pager for London-based Italian restaurant, Luca. The Single Page site fills a big screen well and the food photography is gorgeous on all resolutions. Final shout out to the clean mobile adaption of the food menu – so many restaurant sites get lazy at this point in the build. Great work.
Hire the Donald (Résumé)
‘Hire the Donald’ is a hilarious One Pager acting as Donald Trump’s job application for commander in chief. Genuine laughs at that loading icon in the qualifications section and lovely touch with the angled CV intro (with links in the copy). Other features include references, interactive endorsement section, skills, accomplishments and ends with a big wall covering the whole Single Page site (promoting Hillary’s campaign of course). Excellent work by Hum Creative.
BIGSOUND Buzz (Experimental, Informational, Music Related)
Unique and impressive One Pager providing real-time stats of the most talked about artists from BIGSOUND festival 2016 based on social media. What an awesome interactive Vinyl illustration that hosts recent activity about each of the Top 10 artists. Also lovely touch with the infographic switcher from pie (vinyl) to bar graph views.
Nuage (App, Landing Page, Startup)
Vibrant, clean design with gorgeous load transitions in this AJAX loading Landing Page for new domain management tool, Nuage. Lovely touch – when hovering over the mini header logo – that “flashes” all the brands colors.
Hope you enjoyed these beautiful One Pagers from October! Big love to hosting provider Bluehost for sponsoring the round up:)
by Rob Hope via One Page Love