A simple jQuery social sharing plugin, styled with sass for easy customization.
The post Sharetastic : jQuery Share Plugin appeared first on jQuery Rain.
by Admin via jQuery Rain
"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
A simple jQuery social sharing plugin, styled with sass for easy customization.
The post Sharetastic : jQuery Share Plugin appeared first on jQuery Rain.
In this article, we're going to take a look at NativeScript, an open-source framework for building mobile apps with JavaScript. At the end of the article, you should have a pretty good idea of what NativeScript is, how it works, and what technologies it uses. Aside from that, we're also going to answer common questions that you might have when exploring a new technology, such as how it differs from alternatives like Cordova and React Native, and how Telerik is involved in the project.
NativeScript is a framework for building cross-platform native mobile apps. It allows developers to use XML, CSS and JavaScript to build apps for Android, iOS, and even the Windows Universal Platform. Unlike Cordova, which uses WebView for rendering the UI of the app, NativeScript uses the native platform's rendering engine, which means that it provides a truly native user experience.
NativeScript is composed of a JavaScript virtual machine, a runtime, and a bridge module. The JavaScript virtual machine interprets and executes JavaScript code. Then the bridge module translates the calls to the platform-specific API calls and returns the result to the caller. To put it simply, NativeScript provides developers with a way to command the native platform through JavaScript instead of Objective-C on iOS or Java on Android.
Of course, there's a lot more going on behind the scenes, but the developers at Telerik explain it better than I can, so if you want to learn more about the inner workings of NativeScript, you can read the article by Georgi Atanasov on NativeScript - a Technical Overview or TJ VanToll's article on How NativeScript Works.
With NativeScript, you use XML to describe the UI of the app, CSS for styling, and JavaScript to add functionality.
You can use TypeScript with Angular 2 if you prefer to use a framework for authoring your JavaScript code.
For styling, NativeScript only uses a subset of CSS. This means that not all CSS features that are available in a browser environment can be used. For example, you cannot use floats or position attributes. Here's the full list of supported CSS properties. Just like in the browser, you can add styles that apply to the whole app, to specific pages, or to a specific UI component only. If you prefer to use Sass, you can install the NativeScript Dev Sass plugin.
For describing the structure of the user interface, you use XML. Each page in the app should be in its own XML file. NativeScript comes with pre-defined user interface widgets or components which you can use to build the UI of the app. Some of these components are similar to the different HTML elements that you use in the browser.
For example, there's an Image
component, which is the equivalent of the img
element, or the TextField
component, which is equivalent to the input
element with a type of text. Event handlers such as tapping a button are added in the component itself. Here's an example:
<Button tap="doSomething" />
exports.doSomething = function(){ // do something }
Another thing to note is that the components also serve as templates. If you're familiar with templating libraries such as Handlebars or Mustache, you should be at home with the following syntax:
<ListView items=""> <ListView.itemTemplate> <StackLayout class="animal"> <Label text=""/> </StackLayout> </ListView.itemTemplate> </ListView>
The example above uses the ListView
component. As the name suggests, this component allows you to create lists. animals
is an array defined in the JavaScript file and is bound to the animals
variable on page load. This makes the animals
variable available for use inside the XML file.
var animals = ['panda', 'tiger', 'monkey', 'snake', 'mantis']; function pageLoaded(args){ var page = args.object; page.bindingContext = { animals: animals } }
This outputs each item in the array inside the ListView
.
Lastly, there are plugins which allow you to access the device hardware and platform-specific features. NativeScript comes with a camera plugin pre-installed. This allows you to access the camera of the device and take photos. You can then save the local path to the photo in your app for later use. Platform-specific features such as social sharing can also be used by installing plugins such as the NativeScript Social Share Plugin.
Due to the native nature of NativeScript, you can build almost any kind of app with it. Here are a few examples of apps that you can build with NativeScript:
When it comes to the kinds of apps that you can build with NativeScript, the only limiting factors are performance and plugin availability. Writing native mobile apps in JavaScript comes with a price: you can't really expect to build apps that demand high performance. Examples include games with complex graphics and animations, apps with lots of moving parts, and background processes.
Another limitation is plugin availability. Most developers come to NativeScript from a web development background. This means that most of them aren't familiar with or have limited knowledge of the native platform APIs which could be used to create plugins to access the device hardware or platform-specific features such as contacts or messaging.
If you want to learn more about what kinds of apps you can build with NativeScript, you can check out the App Showcases page. Most of the apps that are listed in there are published on both the Google Play Store and Apple Store. This means that you can install it and run it on your device to get a feel of what apps built with NativeScript look like and how they perform.
If you're not new to hybrid mobile app development, you might have come across frameworks such as Cordova and React Native. NativeScript is related to these two frameworks in that they both aim to solve the problem of "Write once, run everywhere" in the field of mobile app development. Now let's look at each framework side by side:
Cordova | React Native | NativeScript | |
---|---|---|---|
Creator | Nitobi; Later purchased by Adobe Systems | Telerik | |
UI | HTML | UI components are translated to their native counterparts | UI components are translated to their native counterparts |
Can test on | Browser, emulator, device | Emulator, device | Emulator, device |
Code with | HTML, CSS, JavaScript | UI components, JavaScript, subset of CSS | UI components, subset of CSS, JavaScript |
Native functionality access | Through plugins | Native modules | Native API access through JavaScript |
Deploys to | Android, iOS, Ubuntu, Windows, OS X, Blackberry 10 | Android and iOS. Windows Universal and Samsung Tizen coming soon | Android and iOS. Windows Universal coming soon |
JavaScript libraries and framework | Any front-end library or framework (e.g. Angular, Ember) | Any library that doesn't depend on the browser | Any library that doesn't depend on the browser |
Coding pattern | Any front-end framework can be used to structure the code | The UI markup, JavaScript and CSS are all lumped together in a single file by default |
MVVM/MVC pattern |
How JavaScript code is executed | WebView | JavaScriptCore Engine to execute app code on both Android and iOS |
Webkit JavaScriptCore engine to execute app code on iOS and Google's V8 JavaScript engine on Android |
To sum it up, Cordova is the old generation of hybrid mobile app frameworks. It uses the WebView to render the UI of the app and accesses native device capabilities by means of plugins. React Native and NativeScript are the new generation because they translate your JavaScript code so that it can be executed by the native platform.
Somebody might come up with a better name for frameworks like React Native and NativeScript in the future. But for now let's classify them as "Native Hybrid Frameworks" because they both use JavaScript for authoring apps and they both offer native-like experience and performance to users.
Telerik is the company that created NativeScript. And, just like any other company, they need to make money in order to survive. So you might ask, if NativeScript is free and open source, how does Telerik make money from it? Well, the answer is through the Telerik Platform and Telerik UI for NativeScript.
The Telerik Platform provides developers with the tools they need to easily design, build, test, deploy, manage and measure the performance of NativeScript apps. Here are a few examples of the tools they offer:
Telerik UI for NativeScript is a set of components for building the UI of the app. NativeScript already comes with free UI components, but there are also paid UI components such as the Chart and Calendar which you can only use when you purchase it from Telerik.
If you want to learn more about NativeScript, I recommend checking out the following resources:
In this article you've learned the very basics of NativeScript. As you have seen, NativeScript is a good option for building mobile apps using the skills you already have as a web developer. I hope this article has provided you with the necessary knowledge to help you decide whether NativeScript is right for you.
|
Python packages allow you to break down large systems and organize their modules in a consistent way that you and other people can use and reuse efficiently. Python's motto of "Batteries Included" means that it comes preloaded with lots of useful packages in the standard library.
But there are also many amazing third-party packages you can take advantage of. In this tutorial you'll learn all you need to know about what packages are exactly, how to import modules from packages, exploring the built-in package in Python's standard library, and installing third-party packages.
Before we can talk about packages, let's talk about modules. Modules are the source files with *.py extension where you (and everyone else) put the functions and classes that comprise your program. Packages are the manifestation of Python's hierarchical namespaces concept. To quote from the Zen of Python:
"Namespaces are one honking great idea -- let's do more of those!"
To view the whole Zen of Python, type import this
in a Python interactive session:
import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
Namespaces help with organizing code and preventing naming conflicts. This is critical when multiple people work together or when using packages developed by other people.
While packages represents a hierarchy of sub-packages and modules, which are files the hierarchy doesn't have to file-system based where packages and sub-packages are directories and sub-directories. It is much more flexible than that.
Let's take a look at a package called "ansible". It is not a package from the standard library. You'll see later how to find and install third-party packages. Now, let's just check out the directory file structure.
The packages will be installed typically into the Python interpreter's site-packages directory, which will be located somewhere (depending on version, OS, and distribution) under the "lib". On the Mac, for Python 2.7 it will be located in "<interpreter root>/lib/python2.7/site-packages". Here is how the "ansible" package is organized:
tree ansible -L 1 ansible ├── __init__.py ├── cli ├── compat ├── config ├── constants.py ├── errors ├── executor ├── galaxy ├── inventory ├── module_utils ├── modules ├── parsing ├── playbook ├── plugins ├── template ├── utils └── vars 15 directories, 2 files
There are two modules and 15 directories. Each directory is a sub-package of the main ansible package. Looking inside the ansible/utils directory, we can see it contains additional modules and even one more sub-package:
tree ansible/utils -L 1 ansible/utils ├── __init__.py ├── boolean.py ├── cmd_functions.py ├── color.py ├── debug.py ├── display.py ├── encrypt.py ├── hashing.py ├── listify.py ├── module_docs.py ├── module_docs_fragments ├── path.py ├── shlex.py ├── unicode.py └── vars.py 1 directory, 14 files
When you import a module, Python will go through a search algorithm based on the search path, which is a list of directories to start the search. The search path is a list of directories available through sys.path
, and you can manipulate it dynamically (add, remove or move around items in the search path). The site-packages directory is always there.
To import the path.py module from ansible/utils, you'll need to use the following command:
import ansible.utils.path
If you also want to use the standard os.oath module, you'll use the following command:
import os.path
Now you can use either or both path modules with no conflicts due to the difference namespace they belong to.
The standard library has a lot of packages. It's worth exploring it whenever you need to accomplish some task and you're not sure how. There is a very high likelihood that for any general-purpose task like math, shell integration, OS integration, string manipulation, networking and common file formats, there is a well-designed, well-performing and well-tested package in the standard library.
You can really trust standard library packages because it is a big deal to get into the standard library. Either the package was designed by Python's core developers or it was heavily reviewed and often heavily used in the field as a third-party library before making it into the standard library.
Here are all the packages in the standard library organized by topic.
The standard library is awesome, but there'll often be some special functionality you need that is not standard. It doesn't mean you have to write it from scratch. Python has a vibrant and active community that develops and shares freely a lot of code. Enter PyPI - the Python Package Index. PyPI hosts all publicly available packages and provides a one-stop shop for browsing through them.
PyPI organizes the packages in a browsable index. You can browse and search by topic, environment, framework, development, status, intended audience, license, natural language, programming language (yes, there are Python packages that support many programming languages), and operating system.
There is also a distinction between Python 2 and Python 3 packages, and you can see how popular a package is by the number of recent downloads. For example, the ansible package is available on PyPI, and here is its metadata:
Downloads (All Versions): 5528 downloads in the last day 72037 downloads in the last week 289967 downloads in the last month Author: Ansible, Inc. Home Page: http://ansible.com/ Bug Tracker: http://ift.tt/29ButON License: GPLv3 Categories Development Status :: 5 - Production/Stable Environment :: Console Intended Audience :: Developers Intended Audience :: Information Technology Intended Audience :: System Administrators License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) Natural Language :: English Operating System :: POSIX Programming Language :: Python :: 2.6 Programming Language :: Python :: 2.7 Topic :: System :: Installation/Setup Topic :: System :: Systems Administration Topic :: Utilities Package Index Owner: James.Laska, jimi, ansible Package Index Maintainer: mpdehaan, badger DOAP record: ansible-2.0.0.2.xml
There are two ways to install packages from PyPI. You can download the package and then run python setup.py install
. But the modern way is to use pip, setuptools and wheel. Pip stands for Pip Installs Packages (yes, it's one of those acronyms) and is your front end for installation. If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setuptools, but will need to upgrade to the latest version: pip install -U pip setuptools
or python -m pip install -U pip setuptools
on Windows.
Use pip to install wheel: pip install wheel
.
If you're using an earlier version of Python, consider upgrading. If you're unable to, you'll need to install pip, setuptools and wheel on your own. Check the instructions.
Python packages are always installed into an environment. A common practice I will not cover here is to use virtual environments to manage multiple independent installations of Python with different interpreters and/or different sets of installed packages.
The Python packaging authority provides a lot of guidance on the best practices around packaging. This is important because it is an area of active development and recommendations evolve quickly.
Also, if you want to do something special like installing packages from alternative repositories instead of PyPI or using pip in a more sophisticated way, you'll find great discussions and practical advice.
When you're a Python beginner, you learn the core language and have fun playing with it. Pretty soon you discover the standard library, and as you gain more experience you benefit more and more from its richness.
The next stage in your evolution as a Pythonista is to incorporate the vast awesomeness the Python community has put on PyPI into your systems. Packages as the deployment unit of reusable Python code enable this ecosystem.
Do you broadcast live video? Have you considered hosting a regular show on Facebook Live? To discover creative ways to use Facebook Live, I interview Lou Mongello. More About This Show The Social Media Marketing podcast is an on-demand talk radio show from Social Media Examiner. It’s designed to help busy marketers and business owners [...]
This post Live Video: Creative Ways to Do a Live Show on Facebook first appeared on .
- Your Guide to the Social Media Jungle