Professional Documents
Culture Documents
I built C++
primarily for myself
and my colleagues
Sharpen Your
Programming
SkillS
Programming With
Shell Scripts
A Guide To Programming In
Perl, PHP And Python
Admin
24 Handling Large Files
Using Open Source Tools
29 DevOps: Using Ansible to
Deploy Cacti for Monitoring
36 The Basics of Vulnerability
Assessment and Penetration
Testing
Developers
38 Exploring Sinatra
41 Scala: The Powerhouse of
Apache Spark
44 An Introduction to gRPC
50 Qt Programming for HTTP
Programming the Internet of
58
REST Clients
54 A Quick Look at
Programming with Shell Things Using Contiki and Cooja
Scripts
62 A Guide to Programming in
Perl, PHP and Python
69 Python: The User Friendly
Language for Coding
73 An Introduction to HTML5
78 Top IDEs for Raspberry Pi
83 Using State Machines
to Build Better Software
85 Qt: The Cross-Platform
Development Toolkit
87 Creating the Sliding Number
Game in App Inventor 2
Dart: An Easy, Scalable and Multi-
91 Searching Text Strings from
Files Using Python purpose Programming Language 65
Open Gurus
94 Hack the Bootsector
and Write Your Own! R EGUL AR FEATURES
102 Beaglebone Black: Flashing 06 FOSSBytes 14 New Products 104 Tips & Tricks
eMMC through an SD Card
MiSSing iSSuES
e-mail: support@efy.in
back iSSuES
Kits n Spares
new delhi 110020
ph: (011) 26371661, 26371662
E-mail: info@kitsnspares.com
nEwSStand diStribution
ph: 011-40596600
E-mail: efycirc@efy.in
advErtiSEMEntS
mumbai
ph: (022) 24950047, 24928520
E-mail: efymum@efy.in
beNGaluRu
ph: (080) 25260394, 25260023
E-mail: efyblr@efy.in
PuNe
ph: 08800295610/ 09870682995
E-mail: efypune@efy.in
GuJaRaT
ph: (079) 61344948
E-mail: efyahd@efy.in
JaPaN
tandem inc., ph: 81-3-3541-4166
E-mail: tandem@efy.in
Columns
20
SiNGaPORe
publicitas Singapore pte ltd
16 CodeSport
ph: +65-6836 2272
E-mail: publicitas@efy.in
Distributed Social
myself and my
Network
uNiTeD STaTeS
Reco
mm
end
ed
Sys printed, published and owned by ramesh chopra. printed at tara
te m
Re
qu
ire
art printers pvt ltd, a-46,47, Sec-5, noida, on 28th of the previous
me
nt
. nts month, and published from d-87/1, okhla industrial area, phase i, new
e
em
delhi 110020. copyright 2017. all articles in this issue, except for
:P
lac
4,
1G
ep
Live
er
BR
AM
a
,
or
D-R
efy.
OM
Driv
ppo
bility whatsoever is taken for any loss due to publishing errors. articles
that cannot be used are returned to the authors if accompanied by a
May 2017
self-addressed and sufficiently stamped envelope. but no responsibility
is taken for any loss or delay in returning the material. disputes, if any,
106
CD Team
e-mail: cdteam@efy.in
It was all about the future of Red Hat Gluster Storage 3.2
containers at the Bangalore lowers data integrity costs
Container Conference
Red Hat has announced the new
version of Gluster Storage 3.2. The
update comes preloaded with several
Bangalore Container performance improvements as well
Conference (BCC), held as deeper integration with Red Hat
on April 7 at Bengaluru, OpenShift Container Platform.
was Indias first conference Focusing on performance
focused on container improvements, Red Hat Gluster
technologies, and attracted Storage 3.2 provides data integrity
more than 250 delegates. at a lower cost. There is enhanced
Containers are eating integration with OpenShift Container
the world. It has been Platform that brings native support for
Docker, Docker, everywhere advanced storage services like geo-
for the last few years, said replication and in-flight encryption for
Hari Kiran, one of the organisers of the Bangalore Container Conference (BCC) applications deployed in containers.
and co-founder of CodeOps Technologies. Red Hat Gluster Storage 3.2
When asked about what prompted him to conduct an event like BCC, Kiran marks a milestone in the life of the
told Open Source For You, Given the fact that there is substantial interest in product. It brings together a number
container technologies among developers in India, we realised that the time is ripe of innovations that are relevant to the
for organising Indias first conference on this topic. modern CIO, said Ranga Rangachari,
All the tickets for BCC 2017 were sold out a month before the conference vice president and general manager of
date. The conference hosted Evan Powell, chairman of OpenEBS, and Ian Lewis, storage, Red Hat.
developer advocate at Google, who travelled from the US and Japan, respectively. Red Hat claims that the upgraded
Both the experts were featured at the keynote sessions. OpenShift Container Platform
In his opening address, Powell spoke about the relationship between support can enable three times as
DevOps and containers. He explained how the DevOps industry is expected to many persistent volumes per cluster.
significantly benefit from the container ecosystem and its technologies. The newly added improvements also
Lewis began his keynote on standards-based containerisation with offer a smaller hardware footprint
Kubernetes and explained why standards are important. He elaborated on how through arbiter volumes and shrink
they allow interoperability between systems and the right level of abstraction at infrastructure costs while maintaining
each part of the stack. data integrity. They also fix the
Organisations are increasingly adopting containers and related technologies in problem of data mismatch between
production and want to learn from others successes, failures and best practices. two nodes.
Hence, the theme chosen for the conference was Containers in production. Customers running traditional NAS
Following the talks by the experts, there was a panel discussion on using use cases for backup/restore can achieve
containers in production. The conference also featured two workshops. Open data integrity, while hyper-converged
Source For You was the media partner for the event. configurations in branch offices can
save on hardware costs, power and data
Microsoft fixes OneDrive performance issue on Linux centre space. The software package also
Microsoft has finally fixed the infamous OneDrive performance issue that was comes with the Nagios framework to
widely reported by Linux users. The monitor storage operations.
slow access to OneDrive on Linux-based The latest Gluster Storage version
distros had downgraded the experience has also fixed to scale metadata-
for many on the open source platform. intensive operations for large files.
The performance issue was due to a Red Hat believes that faster metadata-
forced Windows user-agent string on intensive operations can improve daily
Chrome and Firefox based browsers operations by 8x. The new release
on Linux. Some users even felt that is focused on the software-defined
Microsoft was deliberately causing performance hiccups for Linux users. storage industry.
Microsoft has responded to a thread in Hacker News announcing the fix. Infosys embraces open source,
According to Edgar Hernandez from the OneDrive team, the StaticLoad.aspx page joins network community
that pre-fetches resources in the background for Office apps was a less efficient Indian IT services giant, Infosys, has
technique causing the earlier-mentioned issue. He also clarified that the issue was joined the Open Invention Network (OIN)
not intentional. as a community member. The new move
The pre-fetching optimisation was disabled, and it will be enabled again soon will enable the Bengaluru-headquartered
after an update for StaticLoad.aspx has been tested on Linux and released. We company to share its developments with
apologise for the inconvenience this may have caused, Hernandez wrote. over 2,000 member companies in the OIN
Alongside announcing the fix, Hernandez promised thorough Linux testing in community, which is funded by Google,
the future. Microsoft apparently wants to make sure that OneDrive is a productive IBM, NEC, Philips, Red Hat and SUSE.
service for as many users as possible. We appreciate Infosys leadership
in joining OIN and believe that those
SAP joins Hyperledger Project to embrace open source who look to the company for inspiration,
blockchain developments both in and outside of India, will see
SAP SE, the company known for its proprietary enterprise software offerings, is the wisdom it has demonstrated by
finally moving on the open source path and has joined the Hyperledger Project as supporting patent non-aggression
a premier member. The new development will allow SAP to utilise the advanced in Linux and adjacent open source
blockchain technology driven by open source collaboration. technologies, said Keith Bergelt, CEO of
As a part of the new collaboration, Dominik Heere, vice president of innovation Open Invention Network.
engineering, SAP Innovation Centre Network, will represent SAPs content on the Infosys considers open source software
Hyperledger governing board. Based in Walldorf, Germany, SAP is set to enable as the primary engine of innovation
blockchain technology in existing and new business scenarios for its enterprise that will help boost areas such as cloud
clients through the Hyperledger computing, Big Data, artificial intelligence,
Project. The community-driven DevOps and modern Web frameworks.
blockchain developments will be Joining OIN will be vital for the company
implemented across SAPs entire to expand its IT presence by not just sharing
portfolio, including the SAP Ariba its developments with other community
network. members but also enabling it access to the
In joining Hyperledger, we intellectual property of member companies
plan to share our expertise and without paying a royalty fee.
knowledge to help bring open Infosys is actively taking open source
distributed ledger technology and open source based products to all our
to all businesses, said Juergen Mueller, chief innovation officer, SAP, in a joint enterprise customers, so we are extremely
statement. We believe blockchain is a transformative technology for enterprise excited to become a part of OIN. We
businesses. We are committed to advancing its adoption via the creation of new encourage others to join it as well and
standards, use cases, platforms and open applications, he added. support this very important initiative,
Led by the Linux Foundation, the Hyperledger Project aims to develop a model said Navin Budhiraja, SVP and head,
of a commonly distributed ledger that lets organisations build and run industry- architecture and technology, Infosys.
specific applications, platforms and hardware systems to support their industrys North Carolina-based OIN is the
business transactions. More than 122 members have already joined the project, leading patent non-aggression community
which is what seems to have persuaded SAP to also do so. to promote the deployments of Linux and
Having support from an enterprise software and cloud leader like SAP is an other related open source technologies.
important step in the right direction. The diversity of our members is a real strength, Patents owned by the OIN community are
as we look to advance open blockchain technology POCs, pilots and production licensed royalty-free to help companies
deployments across many industries this year, said Brian Behlendorf, executive expand and enhance their existing
director, Hyperledger. offerings and promote open source.
SAP is planning to enable use cases like provenance scenarios, digital object Prior to Infosys, German automaker
representations and collaborative transaction executions. Daimler had joined OIN. The parent
IBM also recently joined the Hyperledger Project to enter the growing company of Mercedes-Benz is aiming
blockchain space. The IT giant has announced its own blockchain ecosystem called to leverage open patents to upgrade
the IBM Blockchain that is backed by the collaborative consortium. intelligent vehicle technologies.
Google set to speed up Huaweis KunLun server to run SUSE Linux Enterprise Server
Android security update Huawei has announced its partnership with SUSE to bring SUSE Linux Enterprise
releases Server as the preferred standard OS for its KunLun RAS 2.0. The open source
Google is working on upgrading the platform supposedly comes with reliability, availability and serviceability features
security update system for Android. for the server, and the combination brings an always online offering for enterprises.
The search giant has started working At CeBIT 2016, Huawei and SUSE jointly launched KunLun as the worlds
with third-party manufacturers and first 32-socket mission critical server. That tie-up influenced both the companies
cell phone carriers to improve the to move a step ahead and ultimately made SUSE Linux Enterprise Server the
speed of security updates and make preferred standard operating system.
the open source platform more secure. Now we bring our partnership to a new level by releasing the industrys first
Almost half of Android users standard Linux OS that supports KunLun RAS 2.0. The OS will help KunLun
do not receive important security deliver reliability that is parallel to, and even surpasses that of traditional high-end
updates. Google pushed updates to UNIX servers. These benefits will translate into a better return on investment for our
735 million devices last year, but customers, said Wang Zhen, vice president for IT, server product line, Huawei.
half of them did not receive the The operating system for KunLun is based on SUSE Linux Enterprise Server
patch from device manufacturers. 12 Service Pack 2. It supports RAS 2.0 features that allow customers to add or
Therefore, the company is aiming to remove CPU and memory resources without shutting down the system.
push the updates within just a few SUSE leads the industry by releasing the preferred standard OS that supports
days from release by working with KunLun RAS 2.0 features, including CPU and memory hot swap, said Ralf Flaxa,
carriers and manufacturers. president of engineering at SUSE. The SUSE team led by Flaxa is also developing
an in-service kernel upgrade feature in order to deliver all the latest updates to the
Linux-backed platform.
Huawei has designed KunLun to address the high reliability, performance and
scalability requirements of mission-critical environments by leveraging the x86
ecosystem. The company claims that the server can overcome the longstanding
restrictions of enclosed architectures.
We provided monthly security Google releases Android O and aims to improve battery life
updates for all supported Pixel and While you might be waiting to test your apps on Android Nougat, Google has
Nexus devices throughout 2016, and moved a step ahead and released the first developer preview of Android O. The
we are thrilled to see our partners focus of the new open source project is supposedly to improve battery life and
invest significantly in regular enhance performance on compatible devices.
updates as well. There is still a lot of Battery life is one big concern on Android devices. Though Android engineers
room for improvement, however, at Google had tried to fix various bugs on its Lollipop, Marshmallow and the recent
Googles Android security team Nougat versions, the issue persists on almost all the smartphones and tablets.
members Adrian Ludwig and Mel But with Android O, the Sunder Pichai-led team is planning to deliver a better
Miller, wrote in a blog post. experience by enabling some automatic limits on apps running in the background.
Pushing the updates to Android This advances the power optimisation that was a part of the Nougat release last year.
devices, except the Nexus and Pixel Building on the work we began in Nougat, Android O places a big priority
models, is a complex process. Device on improving a users battery life and a devices interactive performance. To
manufacturers and carriers have make this possible, we have put additional automatic limits on what apps can
to compile the patch to match the do in the background, in three main areas implicit broadcasts, background
devices requirements. services and location updates, explains Dave Burke, vice president of
Working with manufacturers engineering at Google, in a blog post.
and carriers to restructure the The latest changes supposedly enable apps to have minimal impact on the
updates release system can certainly hardware and this enhances the battery life.
speed up the delivery schedule Developers are recommended to learn the tweaks to make their apps
of security updates for Android. compatible with the new background limits. Google has already got documentation
However, it is impossible to ensure ready on background execution limits and background location limits to make
the protection of the over 1.4 billion things easier for app makers.
Android users worldwide. Alongside the enhancements to improve battery life, Android O is all about an
upgraded experience. There are new notification channels that work to enable app- LibreELEC adds support for
defined categories for notification content. The operating system also works with auto- Raspberry Pi Zero W
fill APIs to add login details and repetitive information automatically to certain forms. The Linux community has received
The Android O additionally includes some root-level changes to improve the a new LibreELEC update that comes
existing user experience. There are font resources in XML as well as adaptive icons with native support for Raspberry Pi
and a wide gamut of colour capabilities for apps. Zero W. The latest release also comes
Google has also provided a large number of Java 8 language APIs and runtime with a new Kodi version.
optimisations to take on other mobile platforms including iOS. You can download Dubbed as LibreELEC 8.0.1, the
the very first Android O Developer Preview on your Nexus or Pixel device. The new new version is specifically designed
version comes with an updated SDK to make development even easier. Moreover, an to upgrade the experience across a
emulator has been specifically designed to test Android Wear 2.0 apps on Android O. variety of hardware. The very first
A manual download and Flash is currently the only available channel to install the noticeable change in the update is
O release on compatible devices. But you should only install the preview to test your the support for Raspberry Pi Zero W,
development skills, as some hidden bugs can affect the performance of your device. which was recently launched with
wireless connectivity options.
Orgs, the team collaboration software from npm, becomes free
for open source developers
npm Inc., the parent company of Node.js, has announced that it has made its
developer collaboration tool free for open source projects. Called Orgs, the tool is
popular among JavaScript and Node.js developers.
The free version is only available for open source projects. But those using
Orgs for private packages still need to
opt for the premium subscription of US$
7 per month/per user.
npm has decided to offer the free
version to support development in open
source. Making it easier to collaborate
on open source projects benefits the
whole community, because anything Additionally, the LibreELEC
that reduces friction in software development makes it easier for everyone to build team has provided improvements for
amazing things, said Isaac Z. Schlueter, CEO of npm Inc., in a statement. the Raspberry Pi 3 board. You can
With this development, open source teams can now use advanced capabilities experience the improved software
like role-based access control, package search and semantic versioning for free. HEVC decoding, as well as support
npm can simplify the particular kind of dependency between two software packages for Fe Pi audio cards and Cirrus
or modules in any project. Besides, Orgs can help users share and manage code Logic DAC. Users opting for the
packages among team members. Kodi media player can also enjoy the
advantage of the new maintenance
Netflix debuts on Linux with HTML5 video playback release and receive its fresh build
A long time after its arrival on proprietary platforms, media streaming service with fixes to upgrade the user
Netflix has finally arrived on Linux. Mozillas Firefox browser has received experience.
Netflixs official support to play premium HTML5 content. The LibreELEC 8.0.1 release
While Google Chrome had enabled Netflix video playback support on Linux includes Linux 4.9.13 on generic,
back in 2014, Firefox has become the first Web browser to deliver premium video Raspberry Pi and Raspberry Pi 2
content in HTML5 on the open source operating system. devices. However, on the Amlogic
Starting today, users of Firefox can also enjoy Netflix on Linux. This marks aarch64, the update comes with the
a huge milestone for us and our partners, including Google, Microsoft, Apple and dated Linux 3.14 kernel.
Mozilla, that helped make it possible, the Netflix team, comprising engineers You can download LibreELEC
Nicholas Eddy, Matt Trunnell and Kevin Gallagher, reported in a recent blog post. 8.0.1 directly from the official
In 2013, Netflix added HTML5 support for premium videos to deliver an LibreELEC website. It can be
improved experience over the previously supported Silverlight. It also omitted the installed through an SD card or a
need for plugins to enable video playback. USB drive.
Our excitement about HTML5 video has remained strong over the past four
years. Plugin-free playback that works seamlessly on all major platforms helps us
deliver compelling experiences no matter how you choose to watch, the Netflix
engineering team reported.
Going forward, Netflix is aiming to enhance video streaming using 4K (Ultra-
HD) resolution as well as HDR support. Hardware such as Netflix-supported
televisions and Google Chromecast are already supporting Dolby Vision and
HDR10 formats. These features are likely to reach Linux systems following their
debut on Windows and Mac machines.
In the meantime, you can start watching Netflix videos on your Linux OS by
installing at least Firefox 47. The update is initially bringing out content in 720p
(HD), though it would be expanded to 1080p at a later stage.
Likewise, as open source software is dominating the cloud space, IBM aims
Asttecs launches open to succeed in the market by partnering with its market leaders. Hybrid cloud
source CRM suite application management company, Cloudsoft, is already using the combined service
Months after delivering a community- by deploying its Red Hat Enterprise Linux workloads in IBMs cloud solution. This
backed communication solution, use case is likely to be expanded over time.
Asttecs has launched its open A cloud-first strategy has become the new normal for a majority of our
source CRM application suite. The enterprise clients worldwide who are leveraging IBM Cloud as a key driver for
new development, called AstCRM, digital transformation, Adam said.
is designed to enable enterprises
to manage all their customer Microsofts Project Olympus enlightens open source cloud path
engagement needs using the power of About four months after its official launch, Project Olympus by Microsoft has
open source. finalised its future moves and expanded open source hardware development by
Leveraging expertise in open adding semiconductor manufacturers like
source, our objective is to provide NVIDIA, Intel, Qualcomm, AMD and
customers with best-of-breed Cavium. The new development is aimed at
enterprise-grade applications, while bringing full-fledged cloud hardware closer
focusing mainly on the must-have to the open source community.
features of a customer relationship Microsoft had announced Project
management solution and major Olympus in October last year to deliver a
workflows, said Manjunath R.J., next-generation cloud hardware design, based on the companys massive belief
CEO of AstCRM. in the success of open source. While the initial model is yet to be finalised, the
Asttecs is targeting the CRM Redmond company now plans to make open source cloud hardware a reality.
package at large enterprises and SMEs Microsoft is working closely with the Open Compute Project (OCP) team
(small and medium enterprises). to enable its Project Olympus as an open source cooperative standard for server
The solution can be used to improve hardware that will provide both cloud and enterprise services. At the 2017 OCP US
prospect and customer experiences Summit, the software giant announced that Project Olympus had attracted the latest
by automating sales, marketing in silicon innovation offering an advanced model for emerging cloud workloads
and support tasks, while delivering such as Big Data analytics, machine learning and artificial intelligence.
business-enhancing insights. To reach a large number of projects, Project Olympus standards will be seen
in next generation Intel Zeon and AMD processors. The hardware standard will
also support ARM processors by Qualcomm and Cavium. Interestingly, this
will open up new verticals since ARM-based chips have till now never been
associated with Microsoft software.
This is a significant moment as we usher in a new era of open source
hardware development with the OCP community. We intend Project Olympus to
provide a blueprint for future hardware development and collaboration at cloud
speed, said Kushagra Vaid, general manager for Azure hardware infrastructure,
Microsoft, in a statement.
To accomplish the customer Microsoft aims to build hardware that is robust, flexible as well as scalable in
relationship process, AstCRM terms of capacity. The best part is, this standard is CPU independent. Moreover,
includes major applications for tasks the collaborative agreement between Project Olympus and the chipmakers will
such as lead management, contact ensure this independence.
management, account management, Apart from supporting advanced hardware, Microsoft is projecting a strong
ticket management, role management and quantifiable foundation for cloud software development with Project Olympus.
and activity management. Azure is expected to enable this software foundation through some of the recent
The suite allows users to access open source projects.
customer data via a Web browser. The rapid rate of cloud adoption is already indicative of the fact that the
There are integrated plugins for future of computing is on the cloud. Therefore, a universal standard like Project
Outlook, Thunderbird, Firefox and Olympus is likely to help software makers be less dependent on hardware
Gmail to let users configure the CRM drivers and CPU specifications.
using their email accounts.
For more news, visit www.opensourceforu.com
Bluetooth
music pauses automatically once the inadvertently left on.
headphones are removed and resumes The Backbeat Pro 2 comes with
speakers from when they are put on again. additional features like multi-device
Ultimate Ears The headphones come with on- connectivity to connect up to two devices
demand active-noise cancellation, 24- simultaneously and to switch between
Custom in-ear headphones manufacturer hour battery life, along with Plantronics them easily. Built-in dual microphones
and Logitech brand Ultimate Ears has signature audio technologies like rich enable the user to switch into a phone call
launched its latest Bluetooth portable bass, crisp highs and natural mid- while using the headphones.
speaker, the UE Wonderboom. The tones. They are equipped with Class 1 The Plantronics headphones are
device is said to offer 360-degree Bluetooth, which gives an impressive travel-friendly as they are designed with
sound for up to 10 hours on a single 100 metre range when paired with any fold-flat ear-cups and a protective sleeve.
charge. It enables users to enjoy non- Class 1 Bluetooth device. They are available via online retail stores.
stop music and can be fully charged in The headphones smart power
less than three hours. management technologies offer up Address: Plantronics India Pvt Ltd,
Company sources claim that the to 24 hours of non-stop playback 608, 6th Floor, Vipul Square, Sushant
speaker can withstand a drop from on a single charge, up to 21 days Lok, Phase 1, Gurugram 122002;
a height of up to 1.52m (5 feet). It of standby power and up to six Ph: 91-124 4105192/93
features a hanging loop on top, through
which it can be attached to a bag, cycle,
etc. The music can be controlled via Server SSDs from
the speaker itself, which lets the user Kingston
control the volume and skip a song. The
speaker comes with IP67 certification, Kingston, the multinational computer
making it dust- and water-resistant. It technology corporation that develops
can be immersed in up to 1 metre of and manufactures Flash memory Price:
liquid for 30 minutes, making it perfect products and other memory devices, has ` 19,999 for 480GB
for poolsides, beaches or rainy days. unveiled its latest cloud based storage ` 35,000 for 960GB and
Supporting a mobile range of device the DC400 SSD. ` 36,000 for 1.6TB
up to 33 metres, the device can be Ideal for read-intensive applications
paired with approximately eight other such as boot, Web servers and lower data of 400GB, 480GB, 800GB, 960GB,
Bluetooth enabled Wonderboom rate, operational databases and analytics, 1.6TB and 1.8TB. The 400GB, 800GB
speakers, and can be connected to two the DC 400 SSD offers good quality of and 1.6TB capacities are performance
source devices. service for data centre customers. optimised with greater IOPS for faster
The UE Wonderboom speakers are The device features enterprise-class application performance.
available in grey, black, red, blue and reliability with end-to-end data path The SSDs are available online and
pink via online and retail stores. protection and firmware implemented at retail stores.
power-loss-protection (pFAIL). The SSD
Address: Logitech Electronics India is a good front-loading server storage Address: Kingston India, Liaison
Pvt Ltd, 601, Raja House, 30-31, option, being a combination of high Office, 808, Palm Spring Centre,
Nehru Place, New Delhi 110019; IOPS, low latency and advanced data Above Croma, Link Road, Malad West,
Ph: 011- 47306600 protection. It is available in capacities Mumbai 400064; Ph: 91-22-42230300
Karbonns pocket-friendly
4G smartphones
Mobile device manufacturer, Karbonn Sleek comes with a 5 megapixel rear
Mobiles, has introduced two new 4G and 2 megapixel front camera.
enabled smartphones the Karbonn The Karbonn Aura Note 4G is the
Aura Sleek 4G and Aura Note 4G, first fingerprint sensor device from the
both offering the latest features at an company. It comes with a 13.9cm (5.5
affordable price, making them quite inch) HD screen, 720x1280 display and
popular among the youth. IPS full lamination. With a 1.25GHz
The Aura Sleek 4G comes with quad core processor, the device is
a 12.7cm (5 inch) FWVGA IPS full backed with a huge 2800mAh battery, a
lamination display, perfect for video flashlight, 2GB RAM and 16GB ROM.
Price:
streaming and games. It is powered It runs on Android 6.0 Marshmallow
by a 1.1GHz quad-core processor and has an SD card port with memory ` 5,290 for Aura
with an internal memory of 1GB expandable up to 32GB. It offers front Sleek and ` 6,890
RAM and 8GB ROM. Backed and rear 5 megapixel cameras. for Aura Note
with a 2000mAh battery, the device The Aura Sleek is available in
runs on Android 6.0 Marshmallow, champagne white, black and grey, while Address: Karbonn Mobiles Pvt Ltd,
comes with a microSD card port the Aura Note 4G is available in premium D-170, Okhla Industrial Area, Phase 1,
and supports up to 32GB of external finishes of matte black and metallic New Delhi-110020;
memory. As for the camera, the Aura champagne via online and retail stores. Website: support@jainaindia.com
The prices, features and specifications are based on information provided to us, or as available on various
websites and portals. OSFY cannot vouch for their accuracy. Compiled by: Aashima Sharma
W
hile we have been discussing deep 4. Regularisation techniques are widely used
learning in the last few columns, a few to avoid over-fitting of the neural network
readers asked me to share interview parameters to training data so that the
questions on this topic as well as on general machine constructed network can still generalise well for
learning. So, in this months column, we focus on unseen test data. Can you explain the differences
some of the common interview questions, and I between L1 regularisation and L2 regularisation
request readers to send me your email replies to these methods? When would you use the first option
questions. I will feature them in our next column instead of the second? If you change the network
when we discuss the answers to these questions. learning rate, does it impact the choice of your
1. In last months column, we had discussed regularisation parameter lambda?
auto encoders and how they can be used for 5. You have been given a neural network and
dimensionality reduction. I had mentioned that it training data of size N. How would you
is possible to achieve a dimensionality reduction determine whether the constructed network
of the input representation by having a hidden suffers from the problem of over-fitting?
layer of smaller dimensions compared to the input 6. One of the several other techniques used to avoid
representation dimensions. Now the question to over-fitting is employing drop-out while training a
our readers is the following: Is it always necessary neural network. In simple terms, drop-out implies
to have a hidden layer of smaller dimensions in having a percentage of neurons inactive while
an auto-encoder? If you build an auto-encoder training the network for a fixed number of mini-
in which you have the hidden layer whose epochs and then repeating this process a number
dimensions are larger than the input layer, can you of times, having a different set of neurons inactive
justify why you chose to do so? each time. After completing training, the learnt
2. Continuing on the subject of auto-encoders, why do weights of the neurons are scaled down. Can you
we really need them for dimensionality reduction? explain why this is needed? Also, can you explain
Most of you would be familiar with dimensionality the intuition behind drop-out in terms of why it
reduction techniques such as Principal Components can help avoid over-fitting?
Analysis (PCA). What is the advantage of using 7. One way of thinking about the drop-out technique
auto-encoders for dimensionality reduction of data is that by having a certain percentage of neurons
compared to a PCA based approach? (Clue: Think inactive for each learning phase, we actually train
of linear vs non-linear.) a different neural network and then combine these
3. Given that deep neural networks need large different networks to obtain the final network.
amounts of training data to generalise well, Can you think of any other technique in machine
can you explain methods by which you can learning whereby you can combine different weak
artificially increase the size of your training data? learners to build a strong learner?
(Clue: Think of transformations such as scaling, 8. Different activation functions can be employed
rotation and translation. While it may be obvious for the neurons such as rectilinear, tan-h,
in the case of image data sets to employ these sigmoid, etc. Can you explain the factors
transformations to increase the size of training involved in the choice of activation functions?
data, what kind of transformations can you Are there any criteria that a function needs to
employ in the case of text data?) satisfy, for it to be considered as an activation
function in a neural network trained using back of these hyper-parameters and how they impact the
propagation? classification test accuracy? How would you choose the
9. In a neural network built for classification problems, appropriate values for the hyper-parameters?
the output layer typically has neurons whose activation One of the best resources for learning about the
function is a softmax activation function. Can you explain basic concepts of neural networks is the free online book
why you should use a softmax function for the output layer from Michael Nielsen available at http://neuralnetwork
of a classification network? (Clue: Think about how the sanddeeplearning.com/index.html. I would suggest that our
softmax function is defined and how it can be interpreted readers go through this short book before they attempt to read
as a probability.) through the voluminous deep learning text book from Prof.
10. The back-propagation algorithm is the anchor behind the Bengio et al, available at http://www.deeplearningbook.org/. I
ability to train very large and deep neural networks. Can like Nielsens book, especially because he has provided short
you explain the intuition behind the back-propagation Python code snippets for different concepts and you can try
algorithm? Instead of using back-propagation, I design a them out quickly as you read through the chapters. Another
method wherein I disturb the weight of one of the arbitrary great resource to get familiar with deep learning concepts
neurons in the network and measure its impact on the cost is the repository of articles and tutorials available at https://
function, to determine the gradient of the cost function with deeplearning4j.org/tutorials.
respect to that weight. While this approach certainly seems Given the enormous number of papers and articles
simple compared to the complicated back-propagation available in this space, it can be very confusing for a novice
algorithm, explain why this is not a scalable approach? computer science student who wants to gain expertise in
11. Recall the fact that back-propagation is built on the deep learning. While there are online courses available
premise of computing the gradient of the cost function with from Coursera (Prof. Hintons course on neural networks)
respect to each of the weights, and using the computed and Udacity (a deep learning nano-degree), I would suggest
gradient to update the weights for the next pass. What are that you also read through one of the above-mentioned
the criteria a reasonable cost function needs to satisfy for text books in order to get the mathematical concepts clear,
back-propagation to be applied? instead of just viewing neural networks as a black-box
12. Different cost functions can be applied for a neural network machine learning algorithm. This would allow you to
such as the quadratic cost function, the cross entropy cost understand and appreciate the application of different neural
function, etc. Can you explain why you may prefer a cross- networks to different problems. For instance, you may want
entropy cost function over a quadratic cost function? (Clue: to dig deeper into why convolutional networks, which were
Think of the slowdown in learning for a quadratic cost originally envisaged for image recognition, are also useful
function when a neuron is near saturation.) in text processing tasks such as sentence classification or
13. Continuing the question of cost functions, very often people document classification. More importantly, as you use some
use a sigmoid activation function for the output layer along of the standard neural net architectures for specific text
with a cross-entropy cost function; or a softmax output layer processing problems such as sentiment analysis or topic
with log likelihood cost function. Can you use a softmax modelling, you will understand how different architectures
layer with the cross-entropy cost function? Explain the need to be tuned for different tasks. We will discuss more
reasons behind your choice. (Clue: Think of interpreting the about this in our next column.
softmax layer output as a probability distribution.) If you have any favourite programming questions/
14. How can you compare the performance of two different software topics that you would like to discuss on this forum,
machine learning algorithms? For example, consider that please send them to me, along with your solutions and
you have been given two learners one based on support feedback, at sandyasm_AT_yahoo_DOT_com. Till we meet
vector machines and another that uses neural networks for again next month, wishing all our readers a wonderful and
classifying documents. Let us also assume that the SVM productive month ahead!
based learner performs better than the neural network based
learner when the training data size is M, whereas the neural
By: Sandya Mannarswamy
network performs better than SVM when the training data
The author is an expert in systems software and is currently
size is much less than M, but is poorer in performance by working as a research scientist at Xerox India Research
a few points when comparing training data sizes of M and Centre. Her interests include compilers, programming
above. Which training algorithm would you prefer in that languages, file systems and natural language processing.
If you are preparing for systems software interviews, you
case, and can you explain the rationale behind your choice?
may find it useful to visit Sandyas LinkedIn group Computer
15. When we discussed neural networks in our previous Science Interview Training India at http://www.linkedin.com/
column, I did not go into much detail about the hyper- groups?home=HYPERLINK http://www.linkedin.com/group
parameters of the learning framework such as the learning s?home=&gid=2339182&HYPERLINK http://www.linkedin.
com/groups?home=&gid=2339182gid=2339182
rate, number of mini-epochs, etc. Can you explain some
D
iaspora (wiki.diasporafoundation.org) is a Ruby on BalancerMember unix:///home/diaspora/diaspora/tmp/
Rails application for social networking, designed diaspora.sock|http://
to run as a federated system. Each Diaspora server </Proxy>
is called a pod, and you can join one of the public pods. # SSLEngine On
There are a few with the in domain as well. You can select SSLCertificateFile /etc/pki/tls/certs/localhost.crt
a pod using the guidelines on the Diaspora wiki or use the SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
site https://podupti.me/. SSLCertificateKeyFile /etc/pki/tls/certs/localhost.key
In this article, we will explore how to set up a personal
pod. This may be useful in an organisation or a group, as it Once the installation is successful, you can start the
can encourage sharing and networking between colleagues. browser and explore further.
An additional advantage is that, as it is open source, code
can be added to make it more useful for any special needs Usage
of the common interest group. Sharing concepts are very similar to how it is done on G+
(Google Plus). Relationships are asymmetric. You create
Installation aspects, which are identical to circles in G+. You add
The installation of Diaspora is complex but not very people you know to one or more aspects. They will be
difficult. Instructions are available on the wiki for various notified that you are sharing posts with them. However, it
Linux distributions as well as for MacOS and for Windows. is up to them to decide whether to include you in an aspect
The instructions for Fedora 22 are fine for Fedora 25 as or not. If they dont, the posts you share with them will not
well, with some minor differences. show up in their stream.
The following line created a little confusion: You can share your posts with one or more aspects, or
the public. However, your post will go to a users stream,
curl -L https://s.diaspora.software/1t | bash provided this user is following you. This means that you
need to be one of this users aspects.
I misread 1 in 1t as the letter L and not the Re-sharing of posts is tighter. Only public posts can be
number 1! re-shared. You need to keep in mind that someone may re-
For testing, you can use a dummy URL and self-signed share your private post by using copy-paste.
certificates. However, for production, you will need valid In addition to seeing posts from people you follow, you
certificates and a valid domain. The dummy URL should be may also view posts based on your interests. This is similar
in the /etc/hosts file so that the browser can find it. to the micro-blogging sites. You can specify your interests
The configuration files are in .yml and, hence, by selecting a list of hashtags. A public post that contains
indentation is as critical as in Python code. one of the hashtags in your list of interests will also be
To get the Apache reverse proxy to work, you need shown on your stream.
to make sure that mod_ssl is installed. Modification
of the sample configuration file for Apache is fairly Networking
straightforward. You need to take care of the file names, Diaspora pods do not synchronise, which is fine. There is
e.g., for the proxy and SSL settings, as follows: no reason for a pod to keep track of all the traffic. If a user
on one pod is following a user on another pod, then the
<Proxy balancer://upstream> relevant posts will be forwarded. However, if the receiving
I built C++
primarily for myself and
my colleagues
When we think about programming, its C++ that first comes to mind. Thats because of
the immense popularity and broad applicability of the general-purpose programming
language that debuted back in 1983. Since then, it has influenced many modern
languages, including C#, D and even Java. But what makes C++ important in the world
of generation-next computers and devices like smartphones and embedded hardware?
Jagmeet Singh of OSFY tries to get the answer to this question in a conversation
with none other than the creator of C++, Bjarne Stroustrup. Edited excerpts...
Bjarne Stroustrup,
creator of C++
For U & Me Interview
Q
of the period length while handling
Some of us in the committee try, though. Spending hours on the code tools like IDEs and, of course, hope for
this value. In general, circuit simu-
is not an easy task for young helpful colleagues who will spend time
lation speed is measured in steps
Q What are all the scheduled
per second.
features in the C++17
standarddown
that will
programmers. What valuable tips
can they get from you that will
introducing you to the code base and
its associated tools (debuggers, build
Getting to advance
actual help them work comfortably on systems and test suites).
the present programming
simulation new projects? If you want to use C++, take care to
experience? The code is where ideas turn into learn it well. In particular, learn to use
Simulating with SimulIDE is easy
Compared to C++11 and C++14, practical results. We cannot just write modern C++ well. Do not just repeat the
a power button is your control key.
C++17 does not offer anything that papers or manuals. In fact, we must errors of the past. You can write so much
Simply click on it and you will
will fundamentally change the way you produce code that actually works. better C++11 than you could write in the
see the circuit getting into action.
program. It does not change the way Before adding to a code base, you styles of the 1990s.
Observe the outputs you defined
you think about constructing a program. have to understand some of it. You can
to learn how the changes you Fig. 4: Working with Arduino Uno
Thus, by
made
minor
to my
new results.
littleOn
theusual
update. It
forinstalling
everybody.
definition,
schematic
does, however,
it is a in
resulted
Importantly,
offer a
most
get a general understanding of some
code
so
a
ontop-down,
change
but toJust
are provided.
(such as to
be able
fix a bug)
to make
import the
yousee
Q
near
Finally, where do you see the
with programming
other examples.world
future?
May in
be the
you
SimulIDE package, files into the tool and you will could try your hand at some new
an exclusive folder is created. Thisin
C++17 features are already shipping needsimulation
the to understand
for the code inside-out,
yourself. Hopefully,
fun game. it will be easier to read, write
the major
should beimplementations; I suspect
used as your workspace particularly what affects
Being a hobbyist-oriented this line tool,
of and maintain code. I do not want to
these implementations will
for all further designs with this all be tool. code and in turn, what this
users of SimulIDE have developed line of code write science fiction, so I will not go into
feature-complete before 2017 is out. affects? Anything that helps read the Priya Ravindran
details. is M.Sc
But I expect that (electronics) from
C++ and I will
The folder also contains an exclu- many games like the once-popular VIT University, Vellore, Tamil Nadu. She loves
siveWhat matters
folder, with the new
for example, where features
files code and
Snake navigate
and Flappythrough it, helps.
Bird, samples make a significant positive contribution
to explore new avenues and is passionate
is how
for they can
designs likebe used to DACs
op-amp, write better
and Linear
of which reading or trying
are also to understand
provided along to thatwriting
about future.
Would You
Like More
DIY Circuits?
Notepad
OK
Figure 1: Error with Notepad for a file size greater than 1GB
(Image source: www.google.com)
Figure 2: Notepad++ text editor logo (Image source: www.google.com)
common applications that generate a large amount of data
could be more than 1GB in size and we may need to read Has the multi-document and multi-view feature.
them. As the file size increases, handling them becomes Regular expression and the multiple file search, mark and
a tedious task. Generally, we come across the following replace feature is supported.
issues while attempting to handle large files: Full drag-and-drop support.
The system may hang while attempting to open large Support for a multi-language environment support.
(GB) log files. Being built for the Windows platform, it can also run on
The system will slow down due to full RAM usage by the Linux, UNIX and Mac OS X (using Wine).
opened large text file while the editor is in use. Macro recording and playback.
While attempting to open some 1GB sized text files, the Zooming for those afflicted with sore eyes from staring at
built-in text editor of the Windows application, Notepad, computer screens.
can show some serious error messages like The file is too Comes in both installer and zipped versions for people
large for Notepad. In such cases, we need to use another who don't have admin rights on their work computers.
editor to edit the file.
To interpret the information of these files carefully Disadvantages
without facing such issues, we need some good editors that Third party program (Wine) needed to run the application
allow us to open, read and edit the files. So lets discuss some on Mac OS X.
basic editor tools, which could be handy for these tasks. Remote file editing does not support HTTP, SSH or
WebDAV.
Open source tools to handle large files
Glogg
Notepad++ Glogg is a multi-platform, open source GUI application
Notepad++ is an advanced and feature-rich sibling of the tool for viewing and searching large, complex log and
Notepad text editor that you find in the Windows OS. It is data files. It is a very quick tool as it reads data directly
for those who want a very simple and easy UI with a great from disk and does not load it entirely into memory, which
feature set, as it is clean, very fast and an excellent way to
get work done. It is a lightweight replacement for Notepad,
and is better than Microsoft Notepad in every possible way.
It supports multiple tabs to open different files in a single
window. It also supports multiple programming languages.
Some of the languages supported by Notepad++ are C, C++,
Java, C#, XML, HTML, PHP, JavaScript, VB/VBS, SQL,
Perl, Python, UNIX shell script, etc.
Notepad++ is commonly known as the best HTML editor.
It supports coloured lines and reports code error at the same
instant. Besides, its functionality can be extended by using
the hundreds of available plugins.
Key features
WYSIWYG (What You See Is What You Get).
User defined syntax highlighting and auto-completion. Figure 3: Log file opened with Glogg (Image source: www.google.com)
Key features
It is very quick while handling large files as it directly
reads from the disk without loading into memory.
Runs on UNIX-like systems, Windows and Mac (using
the Qt software development framework).
It automatically updates the log with auto-refresh features
in real-time.
Lines in a file can be marked while reading and they can
be combined later.
It supports keyboard commands like vim/less to move
around the file. Figure 5: Tool options with ConTEXT editor (Image source: www.google.com)
Do-it-yourself
EditPad Lite
EditPad Lite is a general-purpose text editor. It can
be used to easily edit any kind of plain text file. It
displays content instantly because it uses pointers to
access the file directly, rather than to read the entire
file into memory at once. EditPad Lite has all the
essential features to make text editing easy.
Key features
Fig.Full Unicode
7: Start support,
Simulation windowincluding complex scripts
and right-to-left scripts.
It does editing of files directly in Windows,
UNIX and Mac with text encoding (code pages)
and line breaks.
Working with multiple files is very easy using
the tabbed interface.
You can undo and redo all open files infinitely,
even after you save the file.
It supports large files and long lines very well.
It prevents any data loss by automatic backup and
Fig. 8: sim-Default window
saves working copies of files.
Its powerful search-and-replace option with
literal search terms is a worthy feature.
Regular expressions that can span multiple lines.
Disadvantages
It supports Windows only.
It is only free for personal use.
EmEditor
This is a powerful editor with some very great features
like
Fig.Unicode
9: Adding support and
wave to the coloured syntax highlighting.
project
It supports multi-platform files, and many files can
be sumptions into consideration
opened concurrently. for easing
It uses an effective the operations
approach
to read large files as it spills the content onto the disk pin
of the circuit. While data input pin and address
may have any value depending on the specifications of
memory used and your need, clock used in the circuit
is active high.
Enable pin triggers the circuit when it is active
high, and read operation is performed when read/
write pin is high, while write operation is performed www.lulu.com
when read/write pin is active low. www.magzter.com
Software Createspace.com
Verilog has been used for register-transfer logic cod- www.readwhere.com
Figure
ing7: and
EmEditor tool logo (Image
verification. Thesource: www.google.com)
bottom-up design has been
rather than loading it to memory. This helps it to open very supports C++, HTML, CSS, and JavaScript.
large files with ease. One major feature of EmEditor is that Visual Studio Code: This is another free text editor
it auto-detects if the CSV file has an uneven number of created by Microsoft under the MIT licence.
columns, and it tries to fix it at the same time. Its large file GNU Emacs: This is a very popular text editor
controller helps it to read large files at once. derivative of the Emacs family, created by Richard
Stallman for the GNU projects.
Key features
Easily handles files up to 248 GB. Tips to handle large files
It can split large files and can also Do not close large files immediately after viewing
combine files into one. them. You will be dealing with a lot of information
Syntax highlighting and regular expressions are some and you wouldnt want to close a file only to realise
of its main coding features. that you need it open again. And besides, large files
Customisable interface and quick launch makes the take time to open but, after that, its all fine.
user experience better. It is good to have complete documentation of all the
Various free plugins make this tool more productive. findings of large log files, as we may forget these later
Powerful and scriptable macros. when we need to use them and end up wasting time in
The word count plug-in allows you to count reopening the same large file.
specific terms or characters. It is a good practice to keep your RAM as free as
Split window (up to four panes). possible as most text editors load the files into the
Has the auto-save and auto-indent features. RAM to read them.
Support for external tools includes launching external More than a text editor, it's a RAM issue. If you want
programs via keyboard shortcuts or toolbar buttons. to edit a 5GB file and you do not have enough free
RAM, then you will have to close any other open
Disadvantages application to handle the opening of the large file,
Some of its features are available only on the pro carefully.
edition, which is not free. Instead of using a text editor tool, you may go ahead
with the good old Grep command, or you could use
LogExpert the split function to split the large file into multiple
This is a Windows tail program, which serves as a GUI files of smaller sizes, which are easy to handle.
replacement for the UNIX tail command. It is very good You can use cmd to open large files in Windows.
at reading large files, and is free for commercial as well as First, open cmd with Start>Run. Navigate to your file
non-commercial use. location and then type the following command:
C
acti is written in PHP and uses the MySQL database ansible_user=root ansible_password=password
as a backend. It uses the RRDtool (Round-Robin
Database tool) to handle time series data and has built- Add an entry for centos in the /etc/hosts file as
in SNMP support. Cacti has been released under the GNU indicated below:
General Public License.
192.168.122.98 centos
Setting up Cacti
We will use a CentOS 6.8 virtual machine (VM) running on The contents of the all.yml for use with the playbook are
KVM to set up Cacti. Just for this demonstration, we will as follows:
disable SELinux. You will need to set the following in /etc/ ---
selinux/config and reboot the VM: mysql_cacti_password_hash: "{{ vault_mysql_cacti_password_
hash }}"
SELINUX=disabled
mysql_username: "{{ vault_mysql_user }}"
When used in production, it is essential that you enable mysql_password: "{{ vault_mysql_password }}"
SELinux. You should then test for Internet connectivity from
within the VM. The Cacti.yml playbook is located in the ansible/
The Ansible version used on the host Parabola GNU/ playbooks/configuration folder.
Linux-libre x86_64 is 2.2.1.0. The ansible/inventory/kvm/
directory structure is shown below: Vault
Ansible provides the Vault feature, which allows you to store
ansible/inventory/kvm/inventory sensitive information like passwords in encrypted files. You
ansible/inventory/kvm/group_vars/all/all.yml can set the EDITOR environment variable to the text editor of
your choice, as shown below:
The IP address of the guest CentOS 6.8 VM is provided in
the inventory file as shown below: $ export EDITOR=nano
centos ansible_host=192.168.122.98 ansible_connection=ssh In order to store our MySQL database credentials, we will
port: 3306 sql file needs to be imported and the cacti user needs to be
given the SELECT privilege to do this.
Cacti
Cacti is available in the EPEL repository for CentOS. The - name: For bug https://github.com/Cacti/cacti/issues/242
GPG key for the CentOS repositories is enabled before hosts: centos
installing the EPEL repository. Ayum update is performed become: yes
and the Cacti package is installed. A Cacti user is then created become_method: sudo
in the MySQL database. gather_facts: true
tags: [bug]
- name: Install Cacti
hosts: centos tasks:
become: yes - name: Import mysql_test_data_timezone.sql
become_method: sudo mysql_db:
gather_facts: true state: import
tags: [cacti] name: mysql
target: /usr/share/mysql/mysql_test_data_timezone.sql
tasks:
- name: Import EPEL GPG key - name: Grant privileges
rpm_key: mysql_user:
key: http://dl.fedoraproject.org/pub/epel/RPM-GPG- name: cacti
KEY-EPEL-6 append_privs: true
state: present priv: 'mysql.time_zone_name:SELECT'
state: present
- name: Add YUM repo
yum_repository: It is a good practice to have a separate playbook for such
name: epel exceptional cases. In future, when you upgrade to newer
description: EPEL YUM repo versions that have bug fixes, you can simply skip this step.
baseurl: https://dl.fedoraproject.org/pub/
epel/$releasever/$basearch/ Configuration
gpgcheck: yes The last step involves configuring Cacti.
- lineinfile:
dest: /etc/cron.d/cacti
regexp: ^#(.*)$
line: \1
backrefs: yes
configuration/cacti.yml --ask-vault-pass
The Basics of
Vulnerability Assessment and
Penetration Testing
In these days of widespread Internet usage, security is of prime importance. The almost
universal use of mobile and Web applications makes systems vulnerable to cyber attacks.
Vulnerability assessment can help identify the loopholes in a system while penetration
testing is a proof-of-concept approach to actually explore and exploit a vulnerability.
C
yber attacks are increasing every day with the Helps identify programming errors that can lead
increased use of mobile and Web applications. to cyber attacks
Globally, statistics show that more than 70 per Provides a methodical approach to risk management
cent of the applications either have vulnerabilities which Secures IT networks from internal and external attacks
could potentially be exploited by a hacker, or worse, they Secures applications from business logic flaws
have already been exploited. The data losses due to this Increased ROI on IT security
are typically of two types. Either the data is confidential to Protects the organisation from loss of reputation
the organisation or it is private to an individual. Regardless and money
of the category, data losses result in the loss of money or
reputation. This article explores a technical process that can Why are systems vulnerable?
be adopted by industries and organisations to protect their There are primarily two main reasons for systems being
intellectual property, and if implemented correctly, will vulnerablemisconfiguration and incorrect programming
result in better risk management. practices. In the case of networks, devices such as routers,
For those who are new to Vulnerability Assessment and switches and servers, as well as firewalls and IPS systems
Penetration Testing (VAPT), this is a technical assessment are either misconfigured or, in some cases, not configured
process to find security bugs in a software program or a at all, thus running default settings. As an example, almost
computer network. The network may be a LAN or WAN, all firewalls have a default built-in user account with the
while the software program can be a .exe running on a name,admin. Typically, the password for it is also set
server or desktop, a Web/cloud application or a mobile to admin, by default, or something even easier to guess.
application. Before we get into the technical aspects of Looking at the example of servers, installing a database server
VAPT, lets look at a few of its benefits. leaves us with an sa account, which has a blank password.
Exploring Sinatra
This basic introduction to Sinatra can be used by interested readers as a starting
point, from where they can move on to the vast resources online.
R
uby, a mature language, is used in many applications of which let you manage and install multiple Ruby versions.
but Web development is what it is mostly used for. Installing it is as easy as using the following command:
Whenever someone recommends Ruby for Web
development, the first thing that comes to mind is Ruby gem install sinatra
on Rails. Granted, its a great Web framework for rapid
prototyping, and has excellent documentation, tooling and Basic use cases
community, but there are times when using Rails is an Sinatra is a DSL (domain specific language), which helps in
overkilllike when you want a simple solution without reducing the effort to churn out a Web application. To run
having to navigate between files and directories and just Sinatra locally, there is no configuration needed.
want the work done. Or, when you want a quick solution to a
problem but dont want to fiddle through configurations. For require sinatra
such cases, Sinatra might be the right tool for you.
Sinatra is named after the famous American singer and # Associates Root of the website with following code block
actor, Frank Sinatra. It was designed and developed by Blake when a get request is processed
Mizerany, with a huge list of contributors and backing from
many companies like Travis CI. Sinatra is a library and not a get / do
framework, which means it doesnt do many things under the Hello World
hood and lets you handle the logic, which is a great thing if End
you want control.
Sinatra executes a code block by matching it with an
Installation HTTP verb like GET, POST and a URL location like /user, /
Sinatra is easy to install. The only obvious requirement is important. In the above example, when some program makes
Ruby. If you dont have Ruby installed, try rbenv or rvm, both a GET request to the root /, it will execute the code block and
Hello World will be returned by the server to the user, because the trailing slash, so that both http://localhost:4567/42
in Ruby, the last statement is treated as the return statement. and http://localhost:456/42/ are legal.
To run the code, type the following command:
curl --request GET --url http://localhost:4567/send/42/
ruby hello.rb
Sending message to room no 42
The following output should be visible with some variation,
depending on your version of Ruby and the backend server: Splat (*), or what is commonly known as the
wildcard operator, will allow anything and is accessible
== Sinatra (v1.4.8) has taken the stage on 4567 for via a special parameter named splat which is an array of
development with backup from Puma all the values captured by splat against *.
This time we dont need to pass the parameter explicitly; The output may vary depending on the system and
it has become a part of the URL itself and it will just configuration:
work, and like in the previous instance, the parameters are
available via params hash. The interesting bit in the route is {
/?; it is used so that the route will work with and without "PWD": "/home/jatin/Area_51/sinatra_example",
T
he world is being flooded with data from a wide range for distributed/concurrent programming, it is popularly
of sources. The hottest trends in technology currently used for data streaming, batch processing, AWS Lambda
are Big Data and data science, both of which offer Expression and analysis in Apache Spark. It is one of the
ways to cope with this data deluge. Many platforms have most widely used languages by data scientists, and its
emerged in this space, but Apache Spark and Scala work in popularity will soar in the future due to the boom in the
synergy to address the various challenges this humongous Big Data and data science domains.
data throws up. They are being used on Facebook, Pinterest,
NetFlix, Conviva and TripAdvisor, among others, for Big What is Apache Spark?
Data and machine learning applications. Apache Spark is a cluster computing framework based on
Hadoops MapReduce framework. Spark has in-memory
So what is Scala? cluster computing, which helps speed up computation by
Scala stands for Scalable Language. It was developed as reducing the IO transfer time. It is widely used to deal with
an object-oriented and functional programming language. Big Data problems because of its distributed architectural
Everything in Scala is an object, even its primitive data support and parallel processing capabilities. It is preferred to
types. If you write a snippet of code in Scala, you will Hadoop due to its stream processing and interactive query
see that the style is similar to a scripting language. It is features. To provide a wide range of services, it has built-in
very powerful, yet compact, and requires only a fraction libraries like GraphX, SparkSQL and MLlib. Spark supports
of the lines of code compared to other commercially Python, Scala, Java and R as programming languages, of
used languages. Due to its characteristics and support which Scala is the most preferred.
operation will trigger all the lined up transformations on compliant. The following code will explore some basic functions:
the base RDD and then execute the action operation on
the last RDD. val sc = new SparkContext(conf)
Map transformation: Map applies a function to each val sqlContext = new SQLContext(sc)
element of the RDD. The following code checks the length import sqlContext.implicits._
of each line. val sampleData: Seq[ScalaPerson] = ScalaData.sampleData()
val dataset = sqlContext.createDataset(sampleData)
val Length = lines.map(s => s.length)
Length.collect() The Scala vs Python debate
Scala and Python are both powerful and popular among data
Reduce action: Reduce aggregates the elements scientists, many of whom learn and work with both languages.
according to key value. It is applied to the output of the Scala is faster and moderately easy to use, while Python is slower
Map function. The following code calculates the sum total but very easy to use. But Python usually ranks second because of
of characters in the file. the following reasons:
1. Scala is usually 10 times faster than Python for processing.
val totalLength = Length.reduce((a, b) => a + b) Python code needs a lot of translation and converting, which
makes the program a bit slow. Hence, there is a performance
The DataFrame API overhead. Scala has an edge in performance when there are
DataFrame is a distributed data collection organised into fewer processor cores.
columns that are similar to a relational database system. 2. Scala is better for concurrency due to its ability to easily
DataFrame can be created from Hive tables, structured data integrate across several databases and services. It has
files, external databases or existing RDDs. The DataFrame asynchronous libraries and reactive cores. Python doesnt
API uses a schema to describe the data, allowing Spark provide heavyweight processes to fork for multi-threading or
to manage the schema and only pass data between nodes. parallel computing.
This is more efficient than using Java serialisation. It is 3. The Scala programming language has several existential
helpful when performing computations in a single process, types, macros and implicits. Its advantages are evident when
as Spark can serialise the data into off-heap storage in a using these powerful features in important frameworks and
binary format and then perform many transformations libraries. Scala is the best choice for the Spark streaming
directly on this, reducing the garbage-collection costs of feature because Python Spark streaming support is not
constructing individual objects for each row in the data advanced and mature like Scala.
set. Because Spark understands the schema, we dont need Scala has slightly fewer machine learning and natural
to use Java serialisation to encode the data. The following language processing libraries than Python. The library has
code will explore some functions related to DataFrames. only a few algorithms but they are sufficient for Big Data
First, create a sparkcontext object, as follows: applications. Scala lacks good visualisation and local data
transformations. Nevertheless, it is preferred since Python
val sqlcontext = new org.apache.spark.sql.SQLContext(sc) increases portability for more issues and bugs, as translation is
tough. That Scala is the winning combination of both object-
Then, read an external JSON object and store it oriented and functional programming paradigms might be
in DataFrame dfs. Next, show and print it, using the surprising to beginners and they could take some time to pick
following code: up the new syntax. Scala programming might be a difficult
language to master for Apache Spark, but the time spent on
val dfs = sqlContext.read.json(employee.json) learning it is worth the investment.
dfs.show()
dfs.printSchema() References
[1] spark.apache.org/
DataSet API [2] www.tutorialspoint.com/apache_spark/
DataSet API has encoders that translate between JVM [3] www.kdnuggets.com/2015/06/introduction-big-data-
representations (objects) and Sparks internal binary format. apache-spark.html
Spark has built-in encoders, which are powerful as they [4] www.tutorialspoint.com/scala/
generate byte code to mix with off-heap data, and provide
on-demand access to individual attributes without having By: Preet Gandhi
to de-serialise an entire object. Moreover, the DataSet API
The author is an avid Big Data and data science enthusiast. She
is designed to work well with Scala. When working with can be reached at gandhipreet1995@gmail.com
Java objects, it is important that they are fully JavaBean-
An Introduction to
Remote Procedure Call (RPC) has been around for decades as a mechanism for inter-
process communication in applications. The client making a call talks to a stub that works
behind the scenes to handle the marshalling/unmarshalling of the request/response data.
To the client it appears that the service is residing locally.
T
he last decade has seen the rise of public APIs supported languages. Most modern programming languages
and standards like REST for building HTTP based like Java, Python, C#, Node.js and others are supported. You
services. Both XML and JSON are frequently used can either generate the server bindings via the tools provided
as the data format for these service methods request and or even dynamically provide the implementation.
response data. With the proliferation of these services and On the client side, you can generate the gRPC stub in a
the emerging trend towards micro-services, latency becomes client language of your choice, and use that stub directly in
an important consideration when creating high performance your client to invoke the service.
and efficient services.
To address this, Google had been working for a while Why use gRPC?
to come up with a specification that defines both service gRPC has several advantages that are worth considering in
interfaces and efficient communication protocols, along with your application. Some of them are:
bindings in multiple languages for both the client and server It is built on HTTP/2, which provides us with a high
sides. The company later made this available as open source speed communication protocol that can take advantage of
to the general public and the gRPC Project was born. The bi-directional streaming, multiplexing and more.
project helps to implement services in multiple languages The latest version of ProtocolBuffer, i.e., version 3,
with pluggable support for load balancing, health checking supports many more languages.
and authentication. The ProtocolBuffer data has a binary format and,
The gRPC model is shown in Figure 1. hence, provides a much smaller footprint than JSON/
The service, its methods and the messages are defined XML payloads that are currently the most popular.
via a separate specification known as ProtocolBuffers. This This can make a big difference when latency is an
specification is then implemented by the server in one of the issue in your API.
package osfy_stats;
//Service. define the methods that the grpc server can expose
to the client.
service OSFYStatsService {
rpc toparticles (TopArticlesRequest) returns
(TopArticlesResponse);
rpc articleStats (ArticleStatsRequest) returns
(ArticleStatsResponse);
}
that you see, i.e., 1, 2, 3, etc, are used by the binary format }
while encoding and decoding the messages. },
The toparticles method takes in the number of top
articles that we want as input and returns an array of articleStats(call, callback) {
articles, where each article contains fields like the ID, let article_id = call.request.id;
title and a URL. //make some calls to actual API
The articleStats method takes the articles ID as input,
and returns a message containing stats like the number of let numViews = 1000;
views, likes and comments. let numLikes = 30;
let numComments = 5;
Implementing our server
Now that we have defined the service, we can implement callback(null, {
our server. We will be using Node.js for the task, and it is id:article_id,
assumed that you have a Node.js environment set up and numViews,
available on your machine. numLikes,
We will need a few node libraries to be installed numComments
and you can use npm install: });
}
$ npm install grpc });
$ npm install grpcli
//Specify the IP and and port to start the grpc Server, no
Now, let us look at the implementation on the server side. SSL in test environment
The file server.js is shown below: server.bind('0.0.0.0:50000', grpc.ServerCredentials.
createInsecure());
const grpc = require('grpc');
//Start the server
const proto = grpc.load('osfy_stats.proto'); server.start();
const server = new grpc.Server(); console.log('OSFY Stats GRPC Server is now running on port-
>', '0.0.0.0:50000');
let top_articles = [
{ id:20000 , title: 'T1', url: 'URL1' }, Let us go through the code in brief:
{ id:20001 , title: 'T2', url: 'URL2' }, We load the proto definition file and create a server instance.
{ id:20002 , title: 'T3', url: 'URL3' }, For the server instance, we simply bind the service proto.
{ id:20003 , title: 'T4', url: 'URL4' }, osfy_stats.OSFYStatsService.service and provide the
{ id:20004 , title: 'T5', url: 'URL5' } implementations for the two methods: articleStats and
]; toparticles.
We use mock implementations for the two methods and,
//define the callable methods that correspond to the methods in reality, you would have connected to your analytics API
defined in the protofile for this purpose.
server.addProtoService(proto.osfy_stats.OSFYStatsService. To start the server, all we need to do is the following,
service, { and it will display that the server is running, via the message
toparticles(call, callback) { shown below:
callback(null, { articles:topresults }); This will initiate the connection, and we can then use the
rpc list and call methods to test out the service. The sample client.articleStats({"id":2}, (error, response) => {
calls are shown below: if (!error) {
console.log("Article ID : " + response.id + " Views :
$ grpcli -f osfy_stats.proto --ip=127.0.0.1 --port=50000 -i " + response.numViews + " Likes : " + response.numLikes + "
Package: osfy_stats Comments : " + response.numComments );
Service: OSFYStatsService } else {
Host: 127.0.0.1 console.log("Error:", error.message);
Port: 50000 }
Secure: No });
[grpc+insecure://127.0.0.1:50000]# rpc list
toparticles(TopArticlesRequest) { You can execute the client and see that the two actions
return TopArticlesResponse; available by the service are invoked. The output is shown below:
}
articleStats(ArticleStatsRequest) { $ node client.js
return ArticleStatsResponse; Article ID : 2 Views : 1000 Likes : 30 Comments : 5
} Total Articles: 2
[grpc+insecure://127.0.0.1:50000]# rpc call articleStats 20000 T1 URL1
{"id":1} 20001 T2 URL2
Info: Calling articleStats on OSFYStatsService
Response: Other language bindings
{ We have seen how we can define the service interface via the
"id": 1, ProtocolBuffers format, and then used Node.js to develop both
"numViews": 1000, the server side and client side bindings. The advantage of gRPC
"numLikes": 30, is that your server side could be implemented in a specific
"numComments": 5 language, say Node.js, but the client bindings could be in another
} language, like Python, Java or other supported bindings.
[grpc+insecure://127.0.0.1:50000]# To see the list of languages supported, check out the
documentation page (http://www.grpc.io/docs/) and select a
Consuming the gRPC service language of your choice.
Now that we have tested our service, we can write our client Modern architectures suggest breaking up monolithic
code as shown below. The code is similar in the sense that we applications into multiple micro-services and to compose your
load the proto file first and then create a client to the server applications via those services. This results in an explosion of
that is running. Once the client is connected, we can directly inter-service calls and it is important that latency, which is one
invoke the service methods as shown below: of the key factors to consider in providing a high performance
system, is addressed. gRPC provides both an efficient wire
const grpc = require('grpc'); transfer protocol and multiple language bindings that make
this a possibility. With the recent adoption of gRPC as a top
const proto = grpc.load('osfy_stats.proto'); level project in the Cloud Native Computing Foundation, we
are likely to see an increase in developers exploring and using
const client = new proto.osfy_stats.OSFYStatsService('localho this across a wide range of projects.
st:50000', grpc.credentials.createInsecure());
References
client.toparticles({"numResults":2}, (error, response) => {
if (!error) { [1] gRPC.io home page: www.grpc.io
[2] gRPC Documentation: http://www.grpc.io/docs/
console.log("Total Articles: " + response.articles. [3] Protocol Buffers Documentation: https://developers.google.
length); com/protocol-buffers/docs/overview
for (article of response.articles) { [4] gRPC Community: http://www.grpc.io/community/
console.log(article.id + " " + article.title + " " + [5] Cloud Native Computing Foundation: https://www.cncf.io/
article.url);
} By: Romin Irani
} else { The author has been working in the software industry for
console.log("Error:", error.message); more than 20 years. His passion is to read, write and teach
about technology, in order to help developers succeed. He
}
blogs at www.rominirani.com.
});
Qt Programming
for HTTP REST Clients
This article discusses Qt support for connectivity to IoT platforms like ThingSpeak
using HTTP REST APIs. It also focuses on handling JSON data in terms of encoding,
parsing, URL encoding, forming query strings, etc.
Q
t is a cross-platform development framework with a request payload or the GET method with a query
designed to provide eye candy GUI features and string, and retrieve data in JSON or XML formats using
to give rich API support for Web communication, the GET method. Recently, support for sending data using
graph plotting, data exchange, 3D visualisation, multimedia MQTT Publish has also been added. ThingSpeak has good
handling, location tracking, sensor interfacing, etc. Qt integration support for MATLAB from Mathworks, which
applications can be built for various desktop platforms like helps it to offer better analysis and visualisation of data.
Linux, Mac OS and Windows; for embedded platforms like It provides SDKs in various languages for connectivity
Raspberry Pi and QNX, and also for mobile platforms like or one can try to connect using any HTTP client of the
Android, iOS and Windows Mobile. preferred language.
This article explores Qt support for connectivity to IoT In ThingSpeak, data is stored in terms of channels, and
platforms like ThingSpeak using HTTP REST APIs, and each channel is associated with an ID, name, description
also focuses on handling JSON data in terms of encoding, and various applicable fields along with some tags, geo-
parsing, URL encoding, forming query strings, etc. The location, etc. For simple and better authentication, API
assumption is that readers have basic familiarity with Qt keys are provided for read/write operations and a channel
and RESTful operations using HTTP support. If you are key for meta operations. The API keys of a specific
new to the Qt environment, do refer to some of the previous channel can be embedded in a query string or post data
articles published in earlier editions of OSFY, as listed in the for authentication. Secure HTTP (https) is preferred to
References, before proceeding. prevent unauthorised access of API keys by eavesdroppers.
A channel can also be made public during the creation or
About HTTP REST and ThingSpeak by changing the settings later, in which case no read key is
ThingSpeak is an open source platform for building IoT required for viewing the data.
applications, which supports connectivity using HTTP One can log in to ThingSpeak using a Mathworks account,
REST APIs. One can send data using the POST method which is free of cost, and create any number of channels
To send a feed, we need to perform the POST method QNetworkAccessManager *restclient; //in class
with the steps that follow, using the URL https://api. restclient = new QNetworkAccessManager(this); //constructor
thingspeak.com/update.json and the following JSON data QNetworkReply *reply = restclient->post(request,payload);
as request payload: qDebug() << reply->readAll();
QVariantMap feed;
feed.insert(api_key,WRKey);
feed.insert(field1,QVariant(tval).toString());
feed.insert(field2,QVariant(hval).toString()); Figure 1: Sending a feed using POST
QUrlQuery querystr; To process the responses holding all feeds in the JSON
querystr.addQueryItem(api_key,WRKey); format, connect the finished signal of restclient to a suitable
querystr.addQueryItem(field1,25); custom slot.
querystr.addQueryItem(field2,72);
querystr.addQueryItem(field3,900); QObject::connect(restclient, SIGNAL(finished(QNetworkReply*)),
myurl.setScheme(https); this, SLOT(replyFinished(QNetworkReply *)));
myurl.setHost(api.thingspeak.com);
myurl.setPath(/update); Parsing JSON data
myurl.setQuery(querystr); The returned JSON data has two primary fields with the
request.setUrl(myurl); names channel and feeds, and the value of feeds is an array
reply = restclient->get(myurl); of all feeds, where each array element consists of fields like
qDebug() << reply->readAll(); entry_id, field1, field2, field3, created_at, etc.
To traverse all array elements and retrieve the specific
fields in each, you can use the following code to parse the
JSON data in the replyFinished slot:
QJsonDocument jsdoc;
jsdoc = QJsonDocument::fromJson(reply->readAll());
QJsonObject jsobj = jsdoc.object();
QJsonArray jsarr = jsobj[feeds].toArray();
foreach (const QJsonValue &value, jsarr) {
QJsonObject jsob = value.toObject();
qDebug() << jsob[entry_id].toInt();
qDebug() << jsob[field1].toString();
qDebug() << jsob[field2].toString();
qDebug() << jsob[field3].toString();
Figure 2: Sending a feed using GET qDebug() << jsob[created_at].toString();
}
Alternatively, data encoded in the URL query string reply->deleteLater();
format can be used to perform the POST operation using the
same URL api.thingspeak.com/update.json: Rendering data in tabular form
To display the data in tabular form, create a TableWidget
//Prepare querystr similar to above steps through TableView with the name tableFeeds and add
request.setHeader(QNetworkRequest::ContentTypeHeader, the following code in the slot connected to the Retrieve
application/x-www-form-urlencoded); PushButton click.
QByteArray postdata = Qvariant(querystr).toByteArray();
restclient->post(myurl,postdata); ui->tableFeeds->clearContents();
ui->tableFeeds->setColumnCount(5);
Retrieving data from ThingSpeak ui->tableFeeds->setRowCount(jsarr.count());
To retrieve the feeds from ThingSpeak, we need to perform the foreach (const QJsonValue &value, jsarr) {
GET operation on http://api.thingspeak.com/channels/xxxxxx/ QJsonObject jsob = value.toObject();
feeds.json and api_key=XXX..XX as the query string. For this ui->tableFeeds->setItem(k,0,
purpose, use the following code in the slot connected to the new QTableWidgetItem(jsob[entry_id].
Retrieve PushButton click. You can append results=10 to the toString()));
query string to limit the number of results to the last 10 feeds. ui->tableFeeds->setItem(k,1,
new QTableWidgetItem(jsob[field1].toString()));
QUrl url; ui->tableFeeds->setItem(k,2,
url.setScheme(http); new QTableWidgetItem(jsob[field2].toString()));
You can also plot the graph with the above feeds using By: Rajesh Sola
the third party library, QCustomPlot (http://www.qcustomplot. The author is a faculty member of C-DACs Advanced
com) or with the help of Qt Charts introduced in version 5.7.0. Computing Training School, and an evangelist in the
As an example, we have discussed connectivity to embedded systems and IoT domains. You can reach him at
rajeshsola@gmail.com.
ThingSpeak in this article. You can apply these concepts
A Quick Look at
Programming with Shell Scripts
The power of scripting lies in the fact that you get to program with commands you
already know, from various computer languages. Scripting provides a means to
substitute really complicated and convoluted commands and if there is something
repetitive, then a script can probably remove the tedium in your work.
#!/bin/bash
I
magine that you are doing some important task on your different command line interfaces (CLI) or in a graphical
computer system and, suddenly, you get a black screen with manner (using the GUI). A shell takes input from us in the
something being automatically typed on it. I am sure many form of commands, processes it and then gives an output.
of us have experienced such system reboots that take place It can be accessed by a terminal, which runs it. Whenever
on their own due to some hardware or software issues. When we run the terminal, the shell actually issues a command
this happens, our pulse rate shoots up, and we hope and pray prompt, where we can type our own input, which is then
that the task that was being performed has been saved, or else, executed when we hit the Enter key. The output is thereafter
everything will have to be started afresh. displayed on the terminal. The shell basically wraps around
Have we ever given a thought to how all this happens on the delicate interior of an operating system, protecting it
its own? Well, its shell scripting that drives such processes from any accidental damage and, hence, the name. There are
automatically. A newbie in the computer programming arena different types of a shell, such as Korn shell (ksh), Bourne
generally gets anxious just seeing the black screen on the shell (sh), C shell (csh), Bourne Again shell (bash), a remote
computer, assuming the programming involved is quite difficult. shell (rsh), etc. A script written in any such environment is
In shell scripts, the term shell defines the interface referred to as a shell script.
between the user and the different services of an operating The different operations that can be performed by shell
system such as Linux, UNIX, Windows (to some extent) scripts include file manipulation, execution of programs, and
or Mac. Apart from the shell, the kernel is the other main printing text. A script that sets up the specific environment,
component of an operating system. Its the kernel that makes runs the program, does clean-ups if necessary, does logging,
the communication between the hardware and software etc, is basically called a wrapper, which refers to the
possible. The interface can be created by a shell through automated mode of running a specific operating system shell.
SHELL UNIX tools, Awk and Sed, provide extra capabilities for shell
programming. Perl can also be embedded in different shell
environment
control
I/O
redirection scripts as can other scripting languages such as Tcl, etc.
Verisimilitude: A key trait of different shell scripts
pipeline
hookup
is that the invocation of their interpreter is considered as
a core operating system feature. So, instead of a user's
Figure 2: The different functions of a shell Figure 3: Path shortcuts in shell scripting shell only being able to run different scripts in that shell's
(Image credits: googleimages.com) (Image credits: googleimages.com) language or a shell script only having directives of its
environment and the command line environment. Here is a the program is located. That would really take a long time.
list of a few: You will have noticed that we don't usually have to specify
1. Vi or Vim the complete path name to the program we want to run; the
2. Emacs shell just seems to know that. The shell maintains a list of
3. Nano different directories where executable files are kept, and it just
4. Gedit searches for the directories in that list. If its not able to find
5. kwrite the program after searching each of the directories in the list,
Now, we can type in the first script using any of the it will throw up the error: Command not found.
above text editors, as follows: This list of directories is called the path. Let us look
at some of the commands related to this along with their
#!/bin/bash possible output.
# My first script The command for viewing the list of directories
echo "Hello World!" is as follows:
The above script has three lines. [me@linuxbox me]$ echo $PATH
The first line is a special clue given to the shell in order
to indicate what program is used to interpret this script. The output: A colon-separated list of directories which
In this case, its /bin/bash. Other scripting languages will be searched if a specific path is not given when a
such as Awk, Perl, Tcl, Tk, and Python can also use this command is attempted.
type of mechanism.
The second line is just a comment. Everything that The command for adding directories to the path, where
comes after a # symbol is all ignored by bash. As directory_name is the name of directory we want to add, is:
our scripts become larger and more complicated,
comments become important. They are basically used [me@linuxbox me]$ export PATH=$PATH:directory_name
by programmers to explain whats going on, so that
others can understand. The output: directory_name will be added to the path.
The last line is the echo command, which just prints The command for creating a bin directory, which is a sub-
whatever is given on the display. Once we have written directory of our home directory, is as follows:
the above script, we can save this file using any name.
Here, we save it as First_Shell_Script. [me@linuxbox me]$ mkdir bin
2. Give the shell permission to execute it
The next thing we need to do is to give the shell The output: The bin directory will be created.
permission to execute our script. This is done using the Shell scripting can be used in the following cases:
chmod command, as follows: 1. To create our own command or tool.
2. To monitor several tasks like disk usage, etc.
[me@linuxbox me]$ chmod 755 my_script 3. To take data backup and snapshots.
4. For automatic system booting.
The 755 will give us permission to read, write and to 5. For automatic installation of different application packages.
execute. Everybody else will just have read and execute 6. To automate different aspects of computer maintenance
permission. If we want our script to be private (so that only and user account creation.
we can read and execute), we use 700 instead. 7. To create startup scripts for different unattended applications.
8. To kill or start multiple applications together.
3. Put it at the location where the shell can find it
We now need to run our script by typing the
following command: References
[1] http://www.wikipedia.org/
[me@linuxbox me]$ ./First_Shell_Script [2] http://www.guru99.com/
[3] http://linuxcommand.org
Now, you should see Hello World! displayed. If we
dont, then we need to check what directory we saved our
By: Vivek Ratan
script in, so that we can go there and try again.
Before we go further, lets discuss paths a little bit. The author currently works as an automation test
engineer at Infosys, Pune. He can be reached at
When we type in the name of a command, our system
ratanvivek14@gmail.com for any suggestions or queries.
does not search the entire computer in order to find where
W
e are all surrounded by a number of gadgets, mobile help them communicate with distant objects.
devices, smartphones, wireless nodes and many other As per reports from Forbes.com, the market for the
objects that are digitally connected in real-time. The Internet of Things is expected to reach around US$ 267
Internet of Things (IoT) enables real world objects to interact billion by 2020. Analysis from Gartner underlines that around
with each other. These objects can share information and 8.4 billion objects, with investments amounting to US$ 273
communicate in real-time to deliver better performance as well as billion, will be interconnected with each other in the current
security. IoT works by developing and integrating smart objects year (2017-18). This represents a 31 per cent increase over the
that can be controlled using remote network infrastructure. figures of 2016-17.
The term, the Internet of Things, was coined by Some of the key applications of IoT include:
Kevin Ashton in 1999. The implementation of IoT is Smart cities, retail points, smart grids, agriculture and
now widespread because of high performance wireless farming, homes and offices
technologies. Radio frequency identification (RFID) tags The Internet of Vehicles (IoV)
and sensors are the most important components of IoT. Connected cars
The RFID tags can be embedded in real world devices and Connected railways infrastructure
objects, which can be monitored remotely using software Wearable devices
based applications. RFID readers can be used to locate, read Software defined networking
and sense RFID implanted objects. Very small, micro-sized The industrial Internet
transmitting and receiving chips are integrated with RFID to Energy management
Figure 6: Invoking wireless and RFID motes in the Cooja simulator Figure 9: Viewing wireless motes with positions in Cooja
A Guide to Programming in
Perl, PHP and Python
Perl, PHP and Python are three very popular and easy-to-learn programming
languages, each with their own advantages and disadvantages. Newbies venturing
into the field of programming will find this guide interesting and instructive.
T
o be a good programmer, mastering one programming Perl code is very short and there is a whole set of one-
language is not enough. In fact, it is very important to line code available, which shows the power of Perl.
understand a customers requirements and choose the It should be used, depending upon the use case. It can
best available language for the task. Its easy to shift from one be used as a functional language, sometimes object-
programming language to another language if you know them oriented, procedural or imperative. How you want to use
very well. But there are so many programming languages in it depends on you. It handles almost every use case.
the world. Each has its own advantages and disadvantages. Perls CPAN provides a huge number of modules and
By leveraging all the advantages of different languages, a tested code, and most of them are completely free.
programmer can build a robust application. There are different Since Perl is a very old language, it has vast
factors which need to be considered, such as the functionality community support.
of the application, support for new features, the platform on Perl is portable and available for all platforms.
which the application will run, performance, security, code
size, community and support. Disadvantages
Today, lets examine the three Ps: Perl, PHP and Python. All Since Perls syntax is complex, sometimes new
these three languages are dynamic and powerful in their own programmers find it difficult to understand it, because
way and can be used in different scenarios, but they are most the same code can be written in many different ways. For
commonly used to build Web applications and for scripting. example, print 11 + 12 + 13 != print (11 + 12) + 13
It has poor documentation for object-oriented paradigms
Perl compared to Python.
Perl is a general-purpose, high-level, dynamic programming In Perl, there are many ways to do the same things.
language. Currently, Perl 5 is the most popular version of it, Sometimes, this creates a problem.
while the latest version is Perl 6. Perl is derived from different It is slow compared to other scripting languages.
languages like C, AWK, Sed and Shell Script.
Perl is most powerful in string manipulation and regular Popularity
expressions. It is very useful while parsing huge amounts of Though Perl has been around for a long time, its growth has
data, line by line or based on specific regex. It is also useful been slow compared to some other languages and, yet, it has
for Web development, systems administration, network survived. Huge community support and built-in modules
programming and game development. make it very popular.
The biggest advantage of Perl is that there are many ways
to do the same thing. But, sometimes, this advantage creates Popular frameworks
problems in terms of resulting in non-structural or bad code style. Catalyst, Dancer, Mojolicious, etc, are some
frameworks that use Perl.
Advantages
Perl is very good at handling regular expressions. Hence, Syntax
it is preferred when there is a lot of work on regex. Shown below is the basic syntax for Perl. The extension for
Perl files is .pl or .pm, which is based on a file or module: popular frameworks.
#!/usr/bin/perl Syntax
$abc = 10; PHP scripting code is written using the <?php start tag and
print Value of abc = $abc\n; ?> end tag. The file extension is .php, and usually contains
print program is over; PHP scripts and HTML code.
D
art is a programming language developed at Google. Dart targets
The primary developers behind it are Lark Bak and The Dart code can be executed in four different
Kasper Lund. Dart was first released in October 2011, ways (see Figure 2):
and the latest stable release is version 1.22, which came out The code can be trans-compiled into JavaScript using
in February 2017. The consistent updates to Dart indicate its source-to-source compilation. This is done with the
active development. help of the dart2js compiler. As it can be converted to
Dart is cross-platform and supports all major operating JavaScript, all major browsers support it.
systems. It is open source and available with a BSD licence. It The Dart SDK includes a virtual machine called Dart VM.
is recognised as an ECMA standard. This mode is for standalone execution. The Dart code can
be executed in command line interface mode. The Dart
Objectives of Dart SDK includes a powerful package manager called pub.
According to the official documentation, Dart is a long- The Dart code can be executed in another mode through
term project with ambitious objectives. The core objectives, the Dartium browser. This is a customised Chromium
illustrated in Figure 1, are: Web browser that includes the Dart VM. As this browser
Dart has a strong support base with many libraries and has direct support for Dart code, there is no need to
tools, which enable very large applications. convert it into JavaScript.
One of the major objectives of Dart is to simplify Dart can also be executed in AOT mode. AOT stands for
programming tasks. It is designed to make common Ahead-Of-Time compilation. In this mode, the Dart code
programming tasks simpler. can be directly converted into native machine code.
Dart is very stable and it can be used to build production
quality real-time applications. It is an object-oriented DartPad
programming language with support for inheritance, If you prefer to start writing your first Dart program without
interfaces and optional typing features. any installation or configuration, then DartPad is the right
Dart execution
modes
dart:web_sql - This provides an API for storing the data, tools such as pub build (for building a Web app) and pub
which can be manipulated with SQL. serve (for serving a Web app) can also be used.
There are a few other important Dart tools such as:
Dart pub Dartanalyzer - This tool is used to evaluate and report
The package manager of Dart is called pub. The potential errors in your Dart code.
Dart applications specify the pubspec, which lists the Dartfmt - This tool is for formatting the Dart code.
dependencies for that application. For example: The official Dart style guide is followed while
formatting the code.
name: my_app To summarise, Dart is an interesting programming
dependencies: language with features to facilitate Web, mobile and
js: ^0.3.0 command line apps. Its major advantages are its stability
intl: ^0.12.4 and support base. The SDK is constantly updated and,
at the same time, is very stable. In the case of Web
After the specification of pubspec, navigate to that applications, the combination with AngularDart makes it
directory and execute pub get as shown below: a very powerful tool. The mobile application development
platform, Flutter, enables the building of apps for both
cd <path-to-app> Android and iOS from the same codebase. Overall, Dart is
pub get a programming language that is easy to learn, and it enables
the developer to build various types of apps.
The dependencies can be upgraded later with the
following command:
References
$ pub upgrade
[1] DartPad: https://dartpad.dartlang.org/
[2] Dart Language basics: https://www.dartlang.org/guides/
The Dart tools language/language-tour
In this article, the code written in Dart is executed using [3] Dart SDK: https://api.dartlang.org/stable/1.22.1/index.html
[4] Dart Package Manager Pub: https://www.dartlang.org/
DartPad. However, as stated earlier, for advanced tasks,
tools/pub/get-started
it would be better to have an IDE installed in the local
machine. The official documentation has recommended the
By: Dr K.S. Kuppusamy
WebStorm IDE.
In the case of Web app development, the Dartium browser The author is an assistant professor of computer science at
the Pondicherry Central University, with more than 11 years of
can be used. The Dartium browser download is available in teaching and research experience in academia and industry.
the link: https://webdev.dartlang.org/tools/dartium. He can be reached via mail at kskuppu@gmail.com.
Apart from the Dartium browser, the other command line
ent distributors
Indias leading compon
ry
onics components indust
Growth of Indian electr INDUSTRY IS AT A
components for LEDs
The latest launches of
ics
components for electron
The latest launches of
Log on to www.electronicsb2b.com and be in touch with the Electronics B2B Fraternity 24x7
This article will delight newbies who want to get a foothold in the
programming world. It introduces readers to the fascinating world of
Python, which is a very versatile programming language.
C
omputers, today, come with immense disk space, of hardware with the same user interface; it is scalable,
multi-core processors and high speed Internet supporting very large programs; and it has user interfaces
connectivity. And they use computer languages that for UNIX, Windows and Mac. It also has efficient high-
interact with the operating system and execute processes at level data structures and extensive standards-free libraries,
a high speed. One such language is Python, which is used as which make programming easy; hence, it is considered the
a high level programming language. It was first released in language for beginners.
1991 by Guido van Rossum, an ex-employee of Google. It In this article, we will learn how to install, set up and use
is quite easy to learn, as it uses English keywords frequently, Python. The cool thing about learning Python is that there are
unlike the heavy syntaxes of other languages. Moreover, no prerequisites. Even if you are a novice to programming
programmers can code the logic using fewer lines of code you can become a pro coder within a month. To start with,
than what is required in other programming languages like download and install Python from https://www.python.org/
C or Java. The unique design, notably, using white space downloads/release/python-2712/. For this article, we are using
indentation to delimit code blocks, makes Python more Python 2.7. The above link also contains Python for Windows
readable and clean. and Mac. On most Linux boxes, Python is pre-installed.
Python is an interpreted, interactive and object-oriented For Windows, download Python and run the .msi file. Upon
scripting language. The Python code is processed by the completion, add the environment variable named 'PYTHON'
processor at run time, i.e., it does not need to be compiled and its value as the directory where Python is (in this case,'C:\
as in Java, which is compiled to get the .class file. The term Python27'), as shown in Figure 1. We can verify whether
interactive implies that you can use the Python prompt to Python has been installed correctly by running the python -
write the code, which interacts with the interpreter, and version command in the command line. This will give you
by encapsulating the code within objects, it follows the the current version of Python running on your computer, as
OOPS principle. The other features that make Python cool shown in Figure 2. To create Python files, use any text editor
are that it is extendable, i.e., it can run on a wide range of your choice. For this article, we will be using the Sublime
Class, def, if, else, elif, etc. Unlike Java or C, which use
braces to wrap lines of code, Python uses indentation
to denote the block of code that is tightly mapped. In
Python, statements usually end with a new line, but if the
statement gets carried to the new line, then one uses the
\ backslash to show the continuation of the line. A single
line comment is denoted by # and a multi-line comment
can be wrapped in triple quotes.
The data types used in Python are numbers, strings, lists,
tuples and the dictionary. The number data type stores the
numeric value and is immutable in nature, i.e., upon changing
Figure 1: Setting the environment variable the value, a new object is created and the older one is kept
for automatic garbage collection. For example, variable =
10. The single quote or double quotes are used to denote the
string. For example, varA = Hello World, varB = Python
is cool. Python does not support character types, but treats
the characters as strings of length one. Coming to the list, it
consists of comma-separated values which could be of any
Figure 2: Checking the correct installation of Python and its version type and it is represented as [,,,,]. All values are enclosed
between '[' and ']'. A list object is a mutable data type, which
text editor, which can be downloaded from https://www. means it can't be hashed, and modifying an existing list
sublimetext.com/3. will not result in a new list objectthe memory address
The clich of programming languages is Hello World; so will not be changed either. For example: def_list = [1,
lets get started by printing it in the console. Open the command 2,"1","100","Python","Anne"].
prompt, type Python and execute it. Now run the command: The next is a tuple, which has comma-separated
values that could be of any type, enclosed between '('
print (Hello world). and ')'. This, too, is an immutable data type and can be
used as the key in a dictionary. For example: def_tuple =
This will print Hello World in the console as shown (1,2,"1","100","Python","Anne"). The dictionary in Python
in Figure 3. Python, being a scripting language, can also be contains the key value pair in which the key is immutable,
executed by writing a group of individual statements, which and the value can be anything; the key value is separated by
make a single code block called a suite in a file, and can be a colon :. Dictionaries work on the hashing principle. For
saved with the .py extension. example: dictB = dict(). Let us now create a new file in the
Now lets learn about the building blocks of Python, like Sublime text editor with the following commands:
the identifiers, keywords, user input processes, comments, etc.
Identifiers are the names given to classes, variables, functions, # An Empty Dict
etc. These are case sensitive and start with the letters A-Z, dictA = dict() # same as dictA = {}
a-z or an underscore. There are some naming conventions in dictB = dict() # same as dictB = {}
Python, which are listed below: # Adding values to it
An identifier starting with an underscore means that its for i in [1,3,2,4,8,9,5,6,7]:
private, and a double underscore means it is strongly private. dictB[i] = i
The class name must start with upper case. Python # Adding values to a dict
has some reserved words called keywords which have
special meanings. Examples of keywords are and, finally, # Let us use a simple for loop to add values to a dict
for i in xrange(10):
dictA[i] = i + 10
print dictA,'\n\n',dictB,'\n\n'
'''
Define a simple list with multiple datatypes
'''
def_list = [1,2,"1","100","Python","Anne","A!@345<>_()",True,
False,{1:100,2:200,3:300},range(10)]
Figure 3: Getting started with printing Hello World
OpenSourceForU.com
Follow us on Twitter@LinuxForYou
An Introduction to HTML5
HTML5, the fifth and current version of the HTML standard, is a markup
language used to structure and present content on the World Wide Web.
This article will help readers get acquainted with it.
H
TML5 has evolved through the cooperation between like Silverlight and Flash.
the W3C and the Web Hypertext Application
Technology Working Group. It is a higher version of New tags and elements
HTML, and its many new elements make your pages more Semantic elements: Figure 1 displays a few useful
semantic and dynamic. It was developed to provide a greater semantic elements.
Web experience for everyone. HTML5 offers great features Form elements: The form elements present in HTML5
that make the Web more dynamic and interactive. are shown in Figure 2.
The new features of HTML5 are: Graphic elements: The graphic elements in HTML5 can
New sets of tags such as <header> and <section> be seen in Figure 3.
<canvas> element for 2D drawing Media elements: The new media elements in HTML5 are
Local storage listed in Figure 4.
New form controls like calendar, date and time
New media functionality Advanced features of HTML5
Geo-location
HTML5 is not an official standard as yet; hence, not all Geo-location
browsers support it or some of its features. One of the most It is an HTML5 API that is used to get the geographical
important reasons behind developing HTML5 was to prevent location of a websites user, who has to first permit the site
users from having to download and install multiple plugins to fetch his or her location. This usually happens via a button
if (navigator.geolocation) {
// do stuff
}
Figure 1: Semantic elements
The getCurrentPosition API is the main method for using
geo-location. It retrieves the current geographic location
of the users device. The location is described as a set of
geographic coordinates along with the heading and speed. The
location information is returned as a position object.
The syntax is:
As shown in Table 1, each attribute/parameter has both Results in less load for servers
a geodetic representation and a civic representation. The cache manifest file is a simple text file that lists the
resources the browser should cache for offline access. The
Table 1 manifest attribute can be included on the documents HTML
Attribute Geodetic Civic tag, as follows:
Position 59.3, 18.6 Stockholm
Elevation 8 metres Third floor <html manifest=test.appcache>
Heading 142 degrees To the city ...
Speed 12 km/h Running </html>
Orientation 55 degrees North-West
It should be on all the pages that you want to cache.
Web storage
In HTML, to store user data on a local machine, we were The application pages that are cached will remain unless:
using JavaScript cookies. To avoid that, HTML5 has 1. The user clears them out.
introduced Web storage, with which websites themselves 2. The manifest has been modified.
store user data on a local machine. 3. The cache is updated.
The advantages of Web storage, as compared to
cookies, are: Video
More secure Until HTML5 was launched, there was no uniform standard
Faster for showing video on Web pages. Most of the videos were
Stores a larger amount of data shown through different plugins like Flash. But HTML5
The stored data is not sent with every server request. specifies a standard way to show the video on a Web page by
It is only included when asked for. This is a big using a video element.
advantage of HTML5 Web storage over cookies. Currently, it supports three video formats for the video
There are two types of Web storage objects: element, as shown in Table 2.
1) Local this stores data with no expiration date.
2) Session this stores data for one session only. Table 2
How it works: The localStorage and sessionStorage Format IE Firefox Opera Chrome Safari
objects create a key = value pair. Ogg No 3.5+ 10.5+ 5.0+ No
An example is: key=Name, value=Palak MPEG4 No No No 5.0+ 3.0+
These are stored as strings but can be converted, if
WebM No No 10.6+ 6.0+ No
required, by using JavaScript functions like parseInt() and
parseFloat().
Given below is the syntax for using Web The example given below shows the use of this video
storage objects: element:
The video element allows multiple source elements. <source src=song.mp3 type=audio/mpeg />
Source elements can link to different video files. The browser
will use the first recognised format, as follows: This browser does not support the audio element.
</video>
</body>
</html>
designers should use HTML5 tools, which are a great help Adobe Edge Animate: This is a useful tool for HTML5
when one needs to set up workflows/websites or perform developers who have to deal with interactive HTML
repetitive tasks. They improve the usability of Web animations. It is used in digital publishing, the Web and in
designs. Featured below are some essential tools which the advertising fields. This tool allows users to create flawless
help in creating amazing websites. animations, which run across multiple devices.
HTML5 Maker: This is used to interact with content in Video.js: This is a HTML5 video player based on JavaScript.
websites with the help of HTML, JavaScript and CSS. It is If you want to add videos to your website, you should use this
very easy to use. It also allows us to develop slide shows, tool. It makes videos look good and a part of the website.
sliders, HTML5 animation and more. The W3 Validator: The W3 Validator tests the validity of
Liveweave: This is used to test the code. It cuts down the markup of websites in HTML, XHTML, SMIL, MathML,
on the time spent on saving the code and loading it on etc. To test the markup validity of any website, you have to
screen. Pasting the code in the editor gives instant results. choose the document type as HTML5 and enter your Web
It is very easy to use and also provides the auto-complete pages URL. By doing this, your code will get checked, and
feature for some of the code, which makes development all errors and warnings will be mentioned.
and testing faster and easier. HTML5 Reset: This tool allows developers to rewrite the
Font dragr: This previews the custom Web fonts in code of their old websites in HTML5.
a browser. It loads the font instantly, so you get to know You can use these tools to provide a great Web experience
whether it looks good or not. It also offers a drag-and-drop for visitors to your website.
interface, allowing you to drop your typefaces, Web open
fonts and vector graphics to test all of them immediately.
HTML5 Please: This allows us to find anything References
related to HTML5. If you want to know how to use any [1] https://www.w3schools.com/html/html5_intro.asp
feature, you can search for it on HTML Please. It provides [2] http://www.html-5-tutorial.com/
lists of useful resources about supporting browsers and [3] https://www.tutorialspoint.com/html5/
devices, syntax, general recommendations of how to use [4] https://www.udemy.com/learn-html5-programming-
from-scratch/learn/v4/overview
the element, etc.
Modernizr: This is an open source tool which is used
to provide the best experience possible, given the visitors By: Palak Shah
browser. With this tool, you can detect whether the The author is a senior software engineer. She loves to explore
visitors browser supports HTML5 features, and load the new technologies, learn innovative concepts, and is also fond
of philosophy. She can be reached at palak311@gmail.com.
scripts accordingly.
February 2018 Best in the world of Open Source (Tools and Services)
R
aspberry Pi, a small development board Raspberry Pi 3 Model B was launched, which is currently
minicomputer that runs the Linux operating the main product available. In 2017, the Foundation released
system, was developed in the United Kingdom the updated model of Raspberry Pi Zero named Raspberry Pi
by the Raspberry Pi Foundation to promote the teaching Zero W (W = wireless).
of basic computer science in schools in the UK and in In the near future, a model that has improved technical
developing countries. Raspberry Pi has USB sockets, specifications will arrive, offering a robust platform for
which support various peripheral plug-and-play devices embedded systems enthusiasts, researchers, hobbyists and
like the keyboard, the mouse, the printer, etc. It contains engineers to use it in multi-functional ways to develop real-
ports like HDMI (High Definition Multimedia Interface) time applications.
to provide users with video output. Its credit-card-like size
makes it extremely portable and affordable. It requires just Raspberry Pi as an efficient programming device
a 5V micro-USB power supply, similar to the one used After getting the Pi powered up and the LXDE WM up
to charge a mobile phone. and running, the user gets a full-fledged Linux box running
Over the years, the Raspberry Pi Foundation has released a Debian based operating system, i.e., Raspbian. The
a few different versions of the Pi board. The first version was Raspbian operating system comes with tons of free and open
Raspberry Pi 1 Model B, which was followed by a simple and source utilities for users, covering programming, gaming,
cheap Model A. In 2014, the Foundation released a significant applications and even education.
and improved version of the board Raspberry Pi 1 Model The official programming language of Raspberry Pi is
B+. In 2015, the Foundation revolutionised the design of the Python, which comes preloaded with the Raspbian operating
board by releasing a small form factor edition costing US$ system. The combination of Raspberry Pi and IDLE3,
5 (about ` 323) called Raspberry Pi Zero. In February 2016, a Python integrated development environment, enables
New Class...
Parser
Game
Compile
Command
Room
Parser1: room1:
Parser Room
Figure 1: Raspberry Pi
Creating object.. Done.
programmers to develop all sorts of Python based programs. Figure 2: The BlueJ GUI interface
In addition to Python, various other languages are
supported by Raspberry Pi. A number of IDEs (integrated BlueJ provides an efficient way for learning object-
development environments) that are free and open source oriented programming concepts and the GUI provides a class
are also available. These allow programmers, developers structure for applications like UML diagram. Every OOPS
and application engineers to develop programs and based concept, like class, objects and function calling, can be
applications on Pi. represented via interaction based design.
Features
Automatic indentation and completion of source code.
Effective syntax highlighting and error management.
Contains a debugger, scope explorer and dynamic help
system.
Supports GUI and traditional Logo programming
language Turtle for the development of source code.
Latest version: 2016-12-08 (when it was last updated)
Official website: http://www.algoid.net/
Adafruit WebIDE
Adafruit WebIDE provides a Web based interface for
Raspberry Pi users to perform programming functions, and
allows developers to compile the source code of various
languages like Python, Ruby, JavaScript and many others.
Adafruit IDE allows developers to put the code in a GIT
repository, which can be accessed anywhere via GitHub.
Features
An efficient code editor: Ninja-IDE is regarded as
the most efficient code editor as it performs various
functions like code completion and code indentation, and
Figure 4: The Adafruit WebIDE GUI interface functions as an assistant.
Errors and PEP8 finder: It highlights static and PEP8 IDE through Lazarus package files.
errors in the file. Makes use of Free Pascal, which is highly enhanced
Code locator: With this feature, quick and direct access with new features and is even used in Android app
to a file can be made. The user can just make use of the development.
CTRL+K shortcut to type anything, and the IDE will Highly extensible, open source and supports various
locate the specific text. frameworks to compile additional languages.
Its unique project management features and tons of Latest version: 1.6.4
plugins make Ninja-IDE highly extensible. Official website: http://www.lazarus-ide.org
Latest version: 2.3
Official website: http://ninja-ide.org
Codeblock IDE
Codeblock IDE was written in C++ using wxWidgets as a
GUI toolkit and was released in 2005. It is a free, open source
and cross-platform IDE supporting multiple compilers like
Figure 6: The Ninja IDE GUI interface GCC, Clang and Visual C++.
Codeblock IDE is highly intelligent and performs various
Lazarus IDE functions like Syntax highlighting, code folding, code
Lazarus IDE was developed by Cliff Baeseman, Shane completion and indentation, and has a number of external
Miller and Michael A. Hess in February 1999. It is regarded plugins for varied customisations. It can run on Windows,
as a cross-platform GUI based IDE for rapid application Mac OS X and Linux operating systems.
development, and it uses the Free Pascal Compiler. It Features
inherits three primary featurescompilation speed, Supports multiple compilers like GCC, Visual C++,
execution speed and cross-compilation. Applications can be Borland C++, Watcom, Intel C++ and many more.
cross-compiled from Windows to other operating systems Basically designed for C++, but today supports
like Linux, Mac OS X, etc. many languages.
This IDE consists of the Lazarus component library, Intelligent debugger, which allows users to debug
which provides varied facilities to developers in the form of programs via access to the local function symbol and
a single and unified interface with different platform-specific argument display, user defined watches, call stack,
implementations. It supports the principle of Write once and custom memory dump, thread switching and GNU
compile anywhere. debugger interface.
Supports varied features for migrating code from
Features Dev-C++, Visual C++ and others.
Powerful and fast enough to handle any sort of source Makes use of custom-built systems and stores information
code, and supports performance testing. in XML extension files.
Easy to use GUI, which supports drag-and-drop Latest version: 16.01
components. Additional components can be added to the Official website: www.codeblocks.org
SMC
A
lmost every software becomes complex as it evolves In this article, we look at the benefits of using state
over a period of time, and can therefore suffer from machines for modelling software along with some
frequent non-functional problems. These problems examples, and see what the open source world has
are linked to its maintainability, code manageability, to offer in this space.
extensibility, modifiability, determinism, etc. However, a
good plan and design carved out at the initial stages could Benefits of state machines
help developers enjoy the smoothness of the development Some of the benefits of adopting state machines are listed below.
process, as the software matures over a period of time. A complex problem can be broken down into smaller and
The use of state machines is one of the oldest and manageable pieces called states, with each state being
best known techniques for modelling the behaviour of delegated a narrowly defined task. Modelling the system
a system. And its adoption dates way back to the study with a state machine ensures a self-documenting and
of physical matter. As a reference, water (H20) can exist compact representation of the software that automatically
in three different states solid, liquid and gaseous satisfies non-functional demands like manageability,
and in each state it exhibits a specific behaviour; also, extensibility, modifiability and determinism. It might
there are defined events and actions that lead to water, seem like a lot of work in the beginning but as the system
steam or ice transitioning through its different states. grows, this technique helps to dramatically reduce the
Software designers have been using this example to overall complexity. Enabling a state machine for code that
model and partition systems into well-defined states, is already developed and has evolved quite a bit can be
with specific actions and events that define how these painful. So, the one-time investment in state machines for
systems move through these states. any software module right at the beginning of the software
development life cycle (SDLC) is always good. then define your states actions and various transitions using
Once a state machine is in place, the developer can the auto generated code and StatefulJ APIs. You can refer
focus on tuning the behaviour of the system to meet to http://www.statefulj.org/framework/#installation for the
functionality requirements and enhance business value, installation and usage steps.
rather than spending time on enforcing the rules of its
behaviour and other crucial non-functional attributes like SMC
code maintainability, flexibility, etc. State machine compiler (SMC) provides users with a
When a system has its responsibilities well delegated framework for writing a well-defined format to define states,
at different states, it also ensures predictability and transitions and actions. The framework is available for
determinism in the system, thereby making it developer- multiple programming languages like C, C++, Java, Python,
friendly when troubleshooting. Scala, Objective-C, JavaScript, Ruby and VB.NET. The
State machines with well-defined states and events can code that SMC generates out of the user-defined state model
keep in control the growth of conditional logic as well follows the state design pattern, with a few variations. The
as ad-hoc code branching out with scattered Boolean application then uses these generated APIs to instantiate and
flags in the software, and thereby control the overall run the state machine. You can refer to the SMC manual
cyclomatic complexity. (http://smc.sourceforge.net/SmcManual.htm) for rules
Digressing a bit into the history of software and to define the state model, transitions and other elements.
technology, good designs and implementations backed by Incorrect usage could lead to compile or runtime errors.
state machines have always proved excellent in various
verticals. These include commonly used elements in our The spring state machine
daily life like a DBMS transaction; TCP, BGP and many This is an open source framework released under the Apache
other networking protocols; system processes and threads, 2.0 licence for developers to use state machines in spring
gaming software development, etc. All these software applications. It uses the builder design pattern for configuration
structures have a state machine in their DNA. Even everyday and instantiation of states. Spring state machines provide some
occurrences like traffic lights, vending machines and other useful features like storing the state machine configurations
digital electronic systems could all be quickly modelled using in a persistent storage, UML Eclipse Papyrus modelling,
Mealy and Moore styled finite state machines. Zookeeper based distributed state machine, etc.
With all this said, let us now explore some options that the
open source world has to offer developers and designers. You
could enable a state machine for your code, even if its proprietary, References
with the open source state machine frameworks given below, and
[1] http://www.statefulj.org/framework/
reap the benefits of the privileges we discussed earlier.
[2] http://smc.sourceforge.net/
[3] http://projects.spring.io/spring-statemachine/
The StateFulJ framework [4] https://ocw.mit.edu/courses/electrical-engineering-
StateFulJ is an open source, lightweight, Java based finite and-computer-science/6-01sc-introduction-to-
electrical-engineering-and-computer-science-i-
state machine (FSM) framework that could help you embed
spring-2011/unit-1-software-engineering/state-
a state machine into your application. It is a useful aid machines/MIT6_01SCS11_chap04.pdf
when your application has to deal with many synchronous
and asynchronous events and requests, while handling
By: Shravan I.V.
concurrency in a reliable way. The user has to define the
state machine model (states, events and transitions) using The author currently works as a software developer at Cisco
Systems India. He is interested in open source technologies,
Java annotations, and the framework auto generates the and can be reached at iv.shravan@gmail.com.
necessary FSM infrastructure for the application. You can
OpenSourceForU.com
Follow us on Twitter@LinuxForYou
Q
t, which is pronounced as cute, is a cross-platform also provides Qt Quick, which allows the use of scripting
development framework which was originally created languages like JavaScript. Non-GUI features include SQL
by Haavard Nord and Eirik Chambe. It was first database access, XML parsing and JSON parsing.
released on May 20, 1995. The latest version, Qt 5.8, was
released on January 23, 2017. Qt comes in four editions Downloading and installing Qt
Community, Indie Mobile, Professional and Enterprise. The Download the copy of the Qt SDK or if you are using a Linux
Community version is under the open source licence, while system, then use a copy of Qt and a compiler. Remember that
the other three are commercially sold by the company, Qt. if you are starting off, you might want to consider the open
Qt is not a programming language at all but a cross-platform source LGPL version.
development framework for the desktop, embedded systems Qt can be installed in two ways:
and mobiles. It is basically written in C++. The t in it stands 1. Through the Qt installers, whereby you download and
for toolkit which describes it much better. It is, in fact, a set install it.
of tools. Remember that it is written as Qt and not as QT. 2. Through the Qt source.
The first letter stands for Apples QuickTime and has very little
to do with programming. Thus the framework itself and the Creating a new project
applications/libraries using it can be compiled by any standards- The following steps will help you create a project.
compliant C++ compiler like GCC, ICC, MSVC and Clang. Start up Qt Creator (refer to Figure 1). Go to the File
New File or Project menu entry.
Its purpose and capabilities Choose Qt GUI Application and choose a name for it (see
Qt is used for developing multi-platform applications and Figure 2). Enter a project name, say qt-tutorial-01 (Figure 3).
graphical user interfaces (GUIs). However, programs without Select one or more versions of Qt to target. A desktop
a GUI can also be developed, such as command line tools and build is fine for this tutorial (Figure 4).
consoles for servers. An example of a non-GUI program using Select the base class to be QWidget and for everything else,
Qt is the Cutelyst Web framework. GUI programs created leave it as the default settings (Figure 5). Check the project
with Qt can have a native-looking interface, in which case, Qt creation options on Summary and click Finish (Figure 6).
is classified as a widget toolkit. This will create a simple project consisting of four files.
It uses standard C++ with extensions, including signals main.cpp
and slots that simplify the handling of events, and this helps widget.h
in the development of both GUI and server applications. Qt widget.cpp
supports compilers like GCC and the Visual Studio suite. It widget.ui
Figure 1: Qt Creator
Figure 6: Summary
W
e started Android app that are available in the palette, and probably have already got the idea
development with App moving between designer and block from descriptions in earlier articles in
Inventor, picking up some editor is so much fun. this series. We will make an Android
pretty basic ideas to get used to the In this tutorial, I will give you the application that will present a square
concepts, and we have moved towards rather challenging task of building board, which is covered with numbers
more challenging and engaging yet another interesting and powerful on tiles (in a series starting from 1
application ideas. game with the resources available in but in jumbled order) with one empty
I have been getting regular App Inventor 2. I will be making a space. The objective is to arrange the
feedback, suggestions and debugging 15-number sliding puzzle which is also numbers in sequence. To make it more
questions. By now, most readers known by other names such as Gem interesting, you can count the time
have gained enough experience and Puzzle, Boss Puzzle, Game of Fifteen, and the number of moves it takes you
hands-on practice with all the features Mystic Square, etc. It also comes to solve the puzzle so that you can
of the tool. If you are a first-time in various sizes and variations. The challenge your friends as well.
reader of this series, you too can very objective is to arrange the numbers in
well learn from this point onwards sequence, leaving only the corner block GUI requirement
without having any prior programming empty to allow the number blocks to be For every application, we have a
experience or any specialised moved around. If the size of the puzzle graphical user interface or GUI, which
knowledge. Apps developed with is 33 tiles, it is called the 8-puzzle helps the user to interact with the on-
App Inventor can be uploaded to or 9-puzzle, and if it is made up of screen components. The block editor
the Google Play Store and I will 44 tiles, it is called the 15-puzzle or section defines how each component
be delighted to see the good work 16-puzzlenamed, respectively, for the responds to user actions.
done by readers. number of tiles or the number of spaces.
If we talk about App Inventor GUI requirements for Screen1
specifically, then we can proudly say Theme of the application 1. Label: This is a static text
that we have mastered the components The theme is pretty simple and you component that is used to display
each time to randomly change the this block should move to this
Components
numbers displayed on the board. empty position, and a blank should
Screen1 Now, lets head towards the block be created in the place from which it
TblScores editor to define the behaviour. Lets has moved. This is just a swapping
discuss the actual functionality that we of positions.
LblScoreHdr
are expecting from our application. 3. Each move will increase the
HorizontalArrangement1
1. The board will be loaded with move count.
LblTimer the numbers 1 to 15, in sequence. 4. Our clock timer will be running in
Label1 On pressing the Shuffle the tiles the background and will count the
LblMoves button, numbers will be randomly seconds. Make sure to check the
Tray distributed on the square board. Timer always fires checkbox in the
BtnShuffle
2. If there is an empty block adjacent clock properties.
to any block that is touched, then 5. Once the blocks are arranged in
Notifier1
sequence, we need to display a
Game message on the screen, and the
ScoresDB move count and the time taken
should be recorded to be presented
on the leader board.
So lets move on and add these
behaviours using the block editor. I
hope you remember how to switch
from designer to block editor. There is a
button right above the Properties pane
to switch between them.
Rename Delete
Block editor blocks
I have already prepared the blocks for
Figure 3: A view of the components you. All you need to do is drag the
Figure 4: Block editor image 1 relevant blocks from the left side palette
1. At the top, we have the title for and drop them on the viewer. Arrange
our application. Its always a good the blocks the same way as shown in
practice to name your application the image. I will explain what each does
and show it on the screen as well. and how it is called.
We have set the title property As soon as Screen1 is loaded,
of Screen1 as the name of the certain variables to control events later
application, so the top grey bar on will be declared. In Figure 4, all the
will be the application title or you necessary variables are declared with
can make it within the screen by Figure 5: Block editor image 2 their initial state.
providing a label. Before we present anything to the
2. Below that, we have a score card user, we need to reset everything by
which is hidden in the beginning keeping all the blocks at their default
and will be loaded as the leader position and setting the lists. How the
board at the end of the game. Screen1.Initialize block takes care of
3. In the middle, we have labels of the that is displayed in Figure 5.
time and the moves. We will display Figure 6: Block editor image 3 The Shuffle button will re-arrange
the time taken and the steps count to the blocks and start the game. Figure 6
solve the puzzle. shows the blocks for events when you
4. Beneath that, we have our actual click on the Shuffle button.
play area. We have placed 16 image The tile_shuffle procedure is a
components on the canvas. Assign a recursive call to shuffle the blocks; we
number to the 15 numbers and keep have put that line of blocks within a
one block empty. procedure name so that we can call it
5. At the end, the Shuffle the tiles any number of times.
button will begin a new session Figure 7: Block editor image 4 The counter will be triggered as
soon as your play board is ready to use. un-trusted source. Allow this
It will increase by one second as we from the settings and after the
have set the interval property to 1000 successful installation, you will
milliseconds in the designer for the see the icon of your application
clock component. in the menu of your mobile. Here,
Now, when a tile is touched, how Figure 8: Block Editor image 5 you will see the default icon,
it should move is depicted in Figure 9. which can be changed and we will
I have posted for two blocks. It will be tell you how to do so as we move
the same for the others as well, keeping ahead in this course.
a separate event handler for all; so I hope your application is working
please create accordingly. exactly as per the requirements
you have given. Now, depending
Application code upon your usage requirements and
It was not possible to snap each and customisation, you can change various
every block of the logic, so I am things like the image, sound and
providing the complete code as a bar behaviour, too.
code. Scan the code (see QRCode 1)
to obtain the .aia file, which you can Debugging the application
upload to your projects in App Inventor We have just created the prototype
2 and view the complete code. Figure 9: Block editor image 6 of the application with very basic
functionality, but what else might
Packaging and testing the user be interested in? Now come
To test the app, you need to get it various use cases which require
on your phone. First, you have to attention in order not to annoy the
download the application to your user. Your app should be able to
computer and then move it to your address the following use cases:
phone via Bluetooth or USB cable. Ill 1. Can we think of a way to share our
tell you how to download it. moves and puzzle-solving time
1. On the top row, click on the Build with our friends?
button. It will show you the option 2. Can we display two boards
to download the apk to your simultaneously for two users and
computer. make it a dual player game?
2. The progress of the download can be 3. What will other versions be like
seen, and after its been successfully if we think of expanding the size
QRCode 1: Project source code file (.aia)
done, the application will be placed of the square?
If you want to see how the in the Download folder of your These are some of the scenarios
application looks after installation, scan directory or the preferred location that might occur and users will be
the code given in QRCode 2 to get the you have set for it. pretty happy seeing these features
application apk. 3. Now you need to get this apk implemented.
file to your mobile phone either Think about all these scenarios
via Bluetooth or USB cable. and how you could integrate their
Once you have placed the apk solutions into the application. Do ask
file to your SD card, you need to me if you fail to address any of the
install it. Follow the on-screen above cases.
instructions to install it. You You have successfully built
might get some notification or another useful Android app for
warning saying,Install from yourself. Happy inventing!
H
ave you ever thought of searching a string in the files self.path1= path1
of a given folder? If you are a Linux lover, you must self.string1 = string2
be thinking about the grep command. But in Windows, self.i=i
there is no grep command. By using Python programming, if self.i:
you can make your own command which will search the string2 = string2.lower()
string pattern from the given files. The program also offers self.string2= re.compile(string2)
you the power of regular expressions to search the pattern.
In this article, I am going to show you an amazing utility, The following method gives the files name in which the
which will help you to find the string from a number of files. given string is found:
The program, see.py, will search for the string pattern
provided by the user, from the files presented in the directory, def txt_search(self):
also given by the user. This is equivalent to the grep command file_number = 0
in the Linux OS. Here, we will use Python 2.7. files = [f for f in os.listdir(self.path1) if os.path.
The program expects the string pattern and directory from isfile(self.path1+/+f)]
the user. Let us examine the code and discuss it. for file in files:
file_t = open(self.path1+/+file)
Import the mandatory modules file_text= file_t.read()
import os if self.i:
import re file_text=file_text.lower()
import sys file_t.close()
import argparse if re.search(self.string2, file_text):
print The text +self.string1+ found in ,
In the following code I have declared a class Text_search file
class Text_search :
file_number=file_number+1
def __init__(self, string2, path1,i=None): print total files are ,file_number
The following method returns the files name as well as print total files are ,file_number
the line numbers in which the given string is matched.
This is the main function of the program which handles
def txt_search_m(self): all the options. The program offers you six options. The
files = [f for f in os.listdir(self.path1) if os.path. m option gives the number of the file and the line. mi
isfile(self.path1+"/"+f)] is case-insensitive. You can use the h option to get help
file_number = 0 for all options.
for file in files:
file_t = open(self.path1+"/"+file) def main():
line_number=1 parser = argparse.ArgumentParser(version=1.0)
flag_file = 0 parser.add_argument(-m, nargs = 2, help = To get
for line1 in file_t: files as well as line number of files )
if self.i: parser.add_argument(-s, nargs = 2, help = To get the
line1 = line1.lower() files contain string )
if re.search(self.string2, line1): parser.add_argument(-r, nargs = 2, help = To search
flag_file= 1 in recusrive order )
print "The text "+self.string1+" found in parser.add_argument(-mi, nargs = 2, help = -m option
", file, " at line number ",line_number with case insensitive )
line_number=line_number+1 parser.add_argument(-si, nargs = 2, help = -s option
if flag_file == 1: with case insensitive )
file_number=file_number+1 parser.add_argument(-ri, nargs = 2, help = -r option
flag_file=0 with case insensitive )
file_t.close()
print "total files are ",file_number args = parser.parse_args()
The following method also returns the files name as well If you select option m, then it will call the txt_
as the line numbers in which the given string is matched. search_m() method of class Text_search().
This method works in recursive mode.
try:
def txt_search_r(self): if args.m:
file_number = 0 dir = args.m[1]
for root, dir, files in os.walk(self.path1, topdown = obj1 = Text_search(args.m[0],dir)
True): obj1.txt_search_m()
files = [f for f in files if os.path. If you select option s, then it will call the method
isfile(root+/+f)] txt_search().
for file in files:
file= root+/+file elif args.s:
file_t = open(file) if args.s[1]:
line_number=1 dir = args.s[1]
flag_file = 0 obj1 = Text_search(args.s[0],dir)
for line1 in file_t: obj1.txt_search()
if self.i:
line1=line1.lower() If you select the r option, then it will call the method
txt_search_r().
if re.search(self.string2, line1):
flag_file= 1 elif args.r:
print The text +self.string1+ found if args.r[1]:
in , file, at line number ,line_number dir = args.r[1]
line_number=line_number+1 obj1 = Text_search(args.r[0],dir)
if flag_file == 1: obj1.txt_search_r()
file_number=file_number+1
flag_file=0 If you select the mi option, then it will call the txt_
file_t.close() search_m() method in case-insensitive mode.
elif args.ri:
if args.ri[1]:
dir = args.ri[1]
obj1 = Text_search(args.ri[0],dir,i=1)
obj1.txt_search_r()
except Exception as e:
print e
print Please use proper format to search a file use
following instructions
print see file-name
print Use <see -h > For help
M
any young programmers dream of writing the code your own OS is that it's a great learning experience.
for their own operating system. But when they You are at the lowest level of software (just above the
realise they have to write everything from scratch, firmware), and in contact with bare metal. Any hardware
including the code for the device and file system drivers, component is ready to obey your orders. And all that
they give up the dream. matters is your capability to give the correct orders (which
Of course, one can just write the core components and is what is called drivers). Despite being time-consuming,
port all the existing stuff to the new system. But even getting bootsector experiments can give you the confidence that
a kernel ready one that supports only very basic features doing an entire Java or PHP course can't.
would be a long process. Moreover, porting the existing
components will not give you that developed-by-me feeling. Note: The code snippets and explanations given in this
So here is a solution: start off by writing something that article target the Intel x86 architecture. This means you can
just boots, rather than an entire OS, or even a kernel. Later, try them on Intel 8086 to Core i7, any x86 compatible CPU
the same steps can be followed to develop an advanced from AMD or other vendor, or on an emulator like QEMU.
bootloader, and eventually a kernel, which essentially lays the Also, modern technologies including GPT, EFI and GNU
foundation for your own OS. Multiboot have been avoided in favour of the traditional
Before starting, lets first address the following question: BIOS-based booting technology. It seems to be the best
why develop a new operating system? starting point, and is still supported by all modern machines.
This article doesnt assume that everybody is going to
develop a brand new operating system. We have many OSs The boot process and the bootsector
already, and our time and resources could be donated to such The steps involved in the boot process primarily depend on
existing community projects. the hardware components, firmware, BIOS, disks and the
However, one reason why you could consider writing operating system itself.
Generally speaking, when a system is turned on, the Getting it assembled using NASM
CPU starts and executes the startup code from the ROM Although there are many assemblers available (including
chip. After the Power-On-Self-Test (POST), the BIOS GNU Assembler), I prefer NASM, the Netwide Assembler,
locates the boot disk, loads its bootsector (the first sector for its simplicity. Let's use the following command to
or 512 bytes) code into the RAM (location 0x7c00), and assemble this code (before that, make sure you have the
transfers the controls to it. package nasm installed on your computer):
The program that has got the controls now is called the
first bootstrap loader (or the first stage bootloader). This is nasm -o hello.bin -f hello.asm
the program that we are going to write and test in this article.
With a size constraint of 512 bytes, its only purpose I am assuming the command shell is in the same directory
would be to load the next stages in the bootloading process. as the source code. If not, use the command cd to navigate.
But this limited space is sufficient for our experiments. hello.asm is the input file, and the option -o specifies
the output file, which is hello.bin (an extension has no
The Hello World program significance, actually).
The Assembly code for a simple Hello World program that The option -f says that the format of the output file should
works on the x86 architecture follows. There is no space be flat (plain or raw) binary. Usually, assemblers and linkers
for a detailed explanation. However, the core idea is to take choose high-level executable formats like ELF and PE, which
each letter from a string literal (msg, here), and display it cannot be executed by the CPU without help from an OS. But
using the BIOS function in order to print a character. we need something that can be directly executed by the CPU.
Now just enter the following code using a text editor This is why we assemble our program as flat binary.
and save it as hello.asm.
Testing it with QEMU
; Set DS (data segment base) as 0x7c0 We can use emulators and virtual machine monitors to test
mov ax, 0x7c0 our bootable code without restarting the actual machine and
mov ds, ax getting out of the current OS. Lets choose QEMU as the
emulator to be used in this article, for its portability. Most
mov cx, MSGLEN GNU/Linux distros provide the package qemu, and you can
mov si, msg install it directly.
mov ah, 0xe ; BIOS 10h function code for tty output Now, simply run the following command (again, if the
putchar: Shell is in a different directory, use cd to navigate first). This
mov al, [si] ; Character to be displayed command instructs QEMU to start a virtual machine with
int 0x10 ; BIOS interrupt for video service the disk image hello.bin considered to be the boot disk.
inc si
loop putchar qemu-system-i386 hello.bin
skip at the start of the output; and skip is the number of blocks
to skip at the start of the input. conv=notrunc ensures that the
output file is not truncated (i.e., all other sectors in the USB
Flash drive are preserved).
Now lets test it on the real BIOS. Connect the USB drive
and restart the computer. If USB booting is enabled and given
high preference, the system should directly load your boot
code. If it doesnt, restart again and enter the BIOS settings.
Ensure the following, save the settings and restart again:
USB booting is enabled and given preference over other
drives like HDD.
Legacy booting is enabled and is preferred over UEFI.
Now you should see your Hello World program running.
Figure 2: Bless hex editor displays the contents of a USB Flash drive When you've finished enjoying your own bootable program,
just press the power button on the tower to shut down, or use
Getting it set on an actual disk Ctrl + Alt + Del to restart.
Lets get our code written onto the bootsector of a USB Flash
drive. First, find the drive name of the USB Flash drive. If Using a hex editor
you have just a single SATA hard disk installed, the next drive A hex editor is a program that lets you view/edit the
you connect (here, the USB Flash drive) would be called /dev/ contents of any computer file as a plain stream of bytes,
sdb. To verify this, launch the Disk Utility or try the command and it is usually represented in hexadecimal values. While
lsblk after connecting the drive. developing bootable programs, we can use a hex editor to
review the internal byte patterns in a disk image or pseudo-
Caution: files like /dev/sdb. In our case, for example, you can use a
Incorrect identification of drive names can cause hex editor to ensure that we haven't exceeded the limit of
unexpected data loss. Also, take a backup of important files 446 bytes for our boot code.
before you start experimenting with a disk. The popular command hexdump might be already
available on your GNU/Linux system. However, I recommend
We are not performing a simple copy-paste. So it is better installing the package <i>bless</i>, which provides the easy
to unmount the drive (in case it got mounted automatically) and full-featured Bless hex editor.
by using the following command: After installation, launch Bless from the menu or by using
the command bless. If you are not the root user, you might not
sudo umount /dev/sdb be able to open system files like /dev/sdb (which represents
the hard disk). You'll need the assistance of commands like su,
Now, we can use the following command to copy the sudo or gksudo. For example:
bootsector. But wait! Dont even think about executing it until
you complete the next paragraph. sudo bless /dev/sdb
gksudo bless /dev/sdb
sudo dd if=hello.bin of=/dev/sdb
This command will copy the data in the file hello.bin Caution:
to the Flash drive, directly (i.e., not as a file). To make it Never open actual disks (especially your primary hard
useful again, youll have to format it. Alternatively, the disk) if you are not sure what you are doing. Editing files
following commands copy the necessary parts only, leaving like /dev/sda can even break the booting, OS and the
all other bytes intact. partition table. However, trying disk images (e.g., .img and
.iso files) is safe if you have their backup copies.
sudo dd bs=446 count=1 conv=notrunc if=hello.in of=/dev/sdb
sudo dd bs=1 count=2 seek=510 skip=510 conv=notrunc if=hello. Another example: A simple typewriter
bin of=/dev/sdb When we run hello.bin (our first example), the keyboard does
not respond. Given below is the code for a simple typewriter,
The first line copies the boot code and the second line which displays whatever you type.
copies the boot signature bytes (0x55, 0xaa). bs means the
block size is to be considered while copying; count is the mov ax, 0x7c0
number of blocks to copy; seek is the number of blocks to mov ds, ax
Use the option si as shown in Figure 5. You can see See Figure 10, which shows the power of regular
that only file names are returned, and text searching is expressions.
impervious to upper and lower case.
Use the option mi as shown in Figure 6. Use the By: Mohit
option ri as shown in Figure 7.
The author is a certified ethical hacker and EC Council
In order to get help, use the option h as shown certified security analyst. He has a masters degree in
in Figure 8. computer science from Thapar University, and is the author
The program offers you the power of regular of Python Penetration Testing Essentials. You can contact
expressions. Figure 9 shows the file 1.txt, which contains him at mohitraj.cs@gmail.com and https://in.linkedin.com/
in/mohit-raj-990a852a.
text. Let us use the regular expression, + operator.
A
part from offering mobile device users in the country Developers at Vodafone India also take support from
with seamless connectivity, Vodafone India is a large product sites. Additionally, the telco has some partner-
consumer of open source software. The subsidiary of managed solutions that are taken care of by third parties.
the UK-based Vodafone Group Plc has a talent pool of over
100 people involved in major open source developments. Moving away from proprietary technologies
Moreover, it considers open source as the key factor when it Vodafone India had initially relied on proprietary
comes to deciding the architecture for all its partners. technologies. But with the massive advances in the open
Vodafone India ensures that all partner contracts have source world, the operator has decided to make the shift to
open source as the key architecture deciding point, says Vikas community solutions.
Grover, former chief information officer, Vodafone India. Growth, cost reduction and architecture improvement
Vodafone's developer team uses traditional open initiatives compel us to keep transforming our IT state
source solutions such as Java, Drools, Eclipse Mars and year-over-year. This allows us to review our technology
Apache Hadoop as well as the new versions of R, Python, stack, avoid vendor lock-in and analyse cost implications,
Cassandra and Struts, among various others. resulting in wider implementation and induction of open
To enhance existing offerings and to discover new source technologies, Gupta told Open Source For You.
developments, the team accesses well-known repositories.
We sometimes take help from the contributors available Customer Point of Sale (CPOS)
on GitHub and Stack Overflow, says Rahul Gupta, VP for One of the technologies to have recently received open source
solution and planning of IT, Vodafone India. treatment by Vodafone engineers is a customer onboarding
Major open source solutions used at Vodafone India in order to shift the solution to open source software. The
CPOS (Customer Point of Sale) A customer on- major bottleneck in the transformation process was to enable
boarding application used for all types of new clients. real-time communication between the app server and JPS
It uses Apache Tomcat, BIRT, Java, JAXWS, Open server, which was based on the Java state machine. The
JPA, Spring and Struts. engineers were also required to optimise Enterprise Java
UPSS A system to support prepaid offers for over Beans (EJB) and Web service calls.
200 million customers. It uses Axis, Hibernate, Java, We designed XML-based flow and translated BPEL
Spring and Struts. rules to Java XML to begin the transformation. Our
A campaign management system An application to
engineers also used a caching mechanism to optimise
generate campaigns based on customer segmenta-
Appin server calls to JPS. After that, all transactions were
tion and value management. It uses Hadoop, Hive,
Pig and Red Hat Enterprise Linux. thoroughly tested with bucket movement, and Mini Sanity
(for bulk testing of post-paid connections) was simulated
system. Internally called Customer Point of Sale or CPOS, to ensure proper performance, says Gupta.
the technology has been moved from proprietary Websphere
Process Server (WPS) to a Drools-based custom workflow Open source campaign management
solution. The CPOS solution by Vodafone India helps in In addition to the customer onboarding system, Vodafone
acquiring new customers and offers efficient inventory India has an open source-powered Campaign Management
management. Our CPOS is effectively handling the smallest System that helps the telecom giant create unique offers and
of performance dips and availability issues that impact the promotions for customers, based on data-led segmentation
market directly, often leading to irrecoverable scenarios like a and real-time triggers including recharges.
customer moving away to other avenues, explains Abhilekh The offers made through the Campaign Management
Bhardwaj, head of IT delivery excellence, Vodafone India. System are available to customers at certain interventions. The
Apart from easing customer acquisition, Bhardwaj states system lists promotional activities when a customer contacts
that the open source code used in CPOS enables engineers to the operator for service needs. Also, the system circulates
scale the application and increase its resilience. pre-defined real-time triggers. These offers not only help
Vodafone India is also leveraging the features of CPOS Vodafone India to grow revenues but also let customers enjoy
for various eKYC (know your customer) services that offer a better and more personalised experience, asserts Bhardwaj.
Aadhaar-based instant activation. Open source adoption
within our CPOS has doubled the performance of activating Proprietary vs open source solutions
new prepaid, postpaid and enterprise customers, and has The IT engineers at Vodafone India make certain value-
delivered higher stability, Gupta comments. Today, the based evaluations to pick the right mix between proprietary
CPOS solution is accessed by all Vodafone-authorised technologies and open source software. There are parameters
distributors and retailers across the country. And it results including the technological edge, support, the roadmap and
in over 10 million activations per month. costs that help us decide between commercial and open
source options, says Gupta.
WPS Replacement Having said that, the team focuses more on open source.
The IT experts at Vodafone India accomplished the As a principle, we are committed to moving towards using
transformation project dubbed as WPS Replacement in open source, thereby reducing vendor lock-in to the extent
2014, wherein a WPS (Wi-Fi Protected Setup) backed bucket possible, says Bhardwaj.
movement was replaced with a custom Java state machine.
Gupta points out that more than 10 critical transactions Need for local competencies among Indian
impacting over 40 bucket movements had to be redesigned systems integrators
While open source is liberating the telco from the licensing
Key challenges involved in the WPS needed for proprietary solutions, the systems integrators
Replacement project in India also need to create their own competencies and
Complex workflows, which were as per TRAI regula- contribute to the community. This would help to reduce the
tions, had to be migrated from BPEL to Java Engine monopoly of a few support providers in the country.
More than 10 critical transactions impacting over 40 Open source adoption is no more a choice to be made
bucket movements had to be redesigned in the future. It is happening now and here, Bhardwaj
Java-based state machine (JPS) was hosted on a new emphasises.
server to ensure handling of high capacity activations
Real-time communication between app server and
JPS server By: Jagmeet Singh
Optimisation of EJB and Web service calls The author is an assistant editor at OSFY.
Beaglebone Black:
Flashing eMMC Through an SD Card
The Beaglebone Black is a low-power open source single-board computer. eMMC is
short for embedded multi media controller which refers to a package integrating
Flash memory and a memory controller in the same silicon die. In this article, we
flash the eMMC on to the Beaglebone Black using an SD card.
the trick. The best option is not to use the MMC1_CLK and
MMC1_CMD signals at all and tie them LOW.
T
more. Using an SD card smaller
he Beaglebone Black Rev C features a Sitara than 4GB will not boot the board.
AM3358BZ100, 1GHz processor and 512MB DDR3L Before starting, do remember to take
RAM. Its significant features are lower costs, and an a backup of all the contents of the
increase in both performance and memory size. In this low SD card that you are going to use, as
power device, EEPROM has been reduced from 32KB to flashing will erase them completely.
4KB, so that the cost falls. The board features a 4GB NAND Now, ensure to download the latest
(eMMC), and has an HDMI and a USB interface. In addition, images for the Beaglebone Black
it has a GPIO3_21 with a 24.576MHz clock. It also carries from the official Beagleboard
a microSD card. On-board Flash memory of 2GB acts as the website (Figure 2).
hard drive for the board to host a Linux operating system and Figure 1: Beaglebone Black The image can also be directly
other software development tools. downloaded from the system by using the following command:
With a user-friendly, browser-based Bonescript
programming environment called Cloud9, a learner can $ wget -c http://debian.beagleboard.org/images/BBB-eMMC-
easily program the Beaglebone Black (BBB) board to rapidly
prototype electronic systems that interface with real-world
applications. As user knowledge develops, the board provides
more complicated interfaces including C/C++ functions to
access digital and analogue pins aboard the ARM Cortex A8
microprocessor. The full power and capability of the BBB
board can be programmed in the underlying onboard Linux
operating system, such as Angstrom or Ubuntu.
Onboard eMMC
The onboard eMMC uses MMC1 signals. It is also
connected to the expansion header. The eMMC device on
the Beaglebone Black will need to be disabled by activating
the reset line to this device. To do this, you have to write to
eMMC first and instruct it to enable the reset. At this point
in time, it is not totally clear whether the reset line will do Figure 2: Latest image source
References
[1] https://en.wikipedia.org/wiki/BeagleBoard
[2] http://derekmolloy.ie/
[3] http://tinypic.com/1r55gh7o
The 'sox' suite includes two tools called 'rec' and 'play'. youtube-dl <VIDEO_URL>
To record audio, insert a microphone into your audio
jack and type the following command: You can also download in multiple formats. Run
the commands below to discover all that can be done
# rec -c 1 test_file.mp3 using this tool:
# export HISTTIMEFORMAT=%d/%m/%y %T and restart. This will get rid of the Dash lens that is
responsible for those results.
Then, from the terminal, run the following: Alternatively, you can also go into the System Settings
> Security & Privacy, and disable Online Search Results.
# source ~/.bashrc Do note that this toggle will affect not just the Amazon
search results, but also any other Dash lenses that require
Heres an explanation of the commands and switches: the Internet to function.
history GNU History library Harish Tiwari,
HISTIMEFORMAT Environmental variable harishtiwary46@gmail.com
%d Day
%m Month
%y Year
%T Time stamp
source In short, send the contents of the file to the shell
.bashrc Is a shell script that BASH runs whenever it Share Your Linux Recipes!
is started interactively The joy of using Linux is in finding ways to get around
problemstake them head on, defeat them! We invite you
to share your tips and tricks with us for publication in OSFY
Rajeeb Senapati, rajeeb.koomar@gmail.com so that they can reach a wider audience. Your tips could be
related to administration, programming, troubleshooting or
Add a welcome message to your terminal general tweaking. Submit them at www.opensourceforu.
com. The sender of each published tip will get a T-shirt.
This tip will show you how you can easily add a
.
qu
ire
me
nts
the Ubuntu Software Centre. With its 17.04 release, Ubuntu
nt
switches from swap partitions to using swap files, by default.
e
em
:P
lac
4,
1G
ep
Live
er
BR
Lubuntu 17.04
fre
AM
a
,
or
DV
17.04
in f
D-R
efy.
Driv
ppo
Rocksor 3.9.0
You can build and manage your own Linux and BTRFS
CD Team
e-mail: cdteam@efy.in