Problem Upgrade and Update Linux Debian Distro

 
PROBLEM WITH UPDATE AND UPGRADE LINUX DEBIAN
 
PROBLEM :
 
W: GPG error: http://ppa.launchpad.net precise Release: The following signatures were invalid: BADSIG FAEB83059BD4ED25 Launchpad Trimage
W: GPG error: http://ppa.launchpad.net precise Release: The following signatures were invalid: BADSIG 7FB8BEE0A1F196A8 Launchpad PPA for Pidgin Developers
W: GPG error: http://archive.ubuntu.com precise Release: The following signatures were invalid: BADSIG 40976EAF437D05B5 Ubuntu Archive Automatic Signing Key
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/download.ebz.epson.net_dsc_op_stable_debian_dists_lsb3.2_main_binary-amd64_Packages
E: The package lists or status file could not be parsed or opened.
 

ANSWER :
 
sudo apt-get clean
cd /var/lib/apt
sudo mv lists lists.old
sudo mkdir -p lists/partial
sudo apt-get clean
sudo apt-get update

10 most popular Linux books as rated by Amazon's

Here's a list of the top 10 most popular Linux books as rated by Amazon's sales ranks and reader reviews. The list contains books for all users from general introductions to Linux concepts, to advanced handbooks for system administrators and programmers. If you go through the list you will also realise that the listed books are actually 10 essential books for Linux. Read on..

1. Moving From Windows to Linux by Chuck Easttom and Bryan Hoff

Moving from Windows to Linux, Second Edition is a step-by-step walk through the transition from Windows to Linux. This completely updated version of the best-selling book teaches Windows users how to make their PC a Linux PC. It covers the latest in Linux distributions, and provides Windows users with the information they need to choose the one that will best suit their needs. From there, the book works through the transition from Windows to SuSE Linux 9.3, leveraging what Windows users already know, and applying that knowledge to Linux. The transition from applications such as Microsoft Word, Microsoft Office and Adobe Photoshop to their Linux counterparts KWord, Open Office, and GIMP are treated thoroughly and made easy. Real-world, hands-on examples and troubleshooting problems are also included. After reading through the book, any knowledgeable Windows user will be able to set up, maintain, and utilise all aspects of a Linux PC.

Amazon rating: 5

2. Linux in a Nutshell

Linux in a Nutshell (fifth edition) brings users up-to-date with the current state of Linux. Considered by many to be the most complete and authoritative command reference for Linux available, the book covers all substantial user, programming, administration, and networking commands for the most common Linux distributions.

Comprehensive but concise, the fifth edition has been updated to cover new features of major Linux distributions. Configuration information for the rapidly growing commercial network services and community update services is one of the subjects covered for the first time.

But that's just the beginning, the book covers editors, shells, and LILO and GRUB boot options. There's also coverage of Apache, Samba, Postfix, sendmail, CVS, Subversion, Emacs, vi, sed, gawk, and much more. Everything that system administrators, developers, and power users need to know about Linux is referenced here, and they will turn to this book again and again.

Amazon rating: 5

3. A Practical Guide to Linux Commands, Editors, and Shell Programming

To be truly productive with Linux, you need to thoroughly master shells and the command line. Until now, you had to buy two books to gain that mastery: a tutorial on fundamental Linux concepts and techniques, plus a separate reference. Now, there’s a far better solution. Renowned Linux expert Mark Sobell has brought together comprehensive, insightful guidance on the tools system administrators, developers, and power users need most, and an outstanding day-to-day reference, both in the same book.

This book is 100 per cent distribution and release agnostic: You can use it with any Linux system, now and for years to come. Use Macs, too? This new edition adds comprehensive coverage of the Mac OS X command line, including essential OS X-only tools and utilities other Linux/UNIX books ignore.

Packed with hundreds of high-quality, realistic examples, this book gives you Linux from the ground up: the clearest explanations and most useful knowledge about everything from filesystems to shells, editors to utilities, and programming tools to regular expressions. Sobell has also added an outstanding new primer on Perl, the most important programming tool for Linux admins seeking to automate complex, time-consuming tasks.

Amazon rating: 5

4. Linux Quick Fix Notebook by Peter Harrison

This book provides step-by step instructions on how to configure the most popular Linux back office applications. To avoid confusion between the many flavors of Linux, each with it's own GUI interface, this book exclusively uses the command line to illustrate the tasks needed to be done. It provides all the expected screen output when configuring the most commonly used Linux applications to help assure the reader that they are doing the right thing.

The Notebook includes many of the most commonly encountered errors with explanations of their causes and how to fix them. The book's format is aimed at sys admins who often have to do advanced tasks in which the commands to do it are forgotten or at the tips of their tongues.

As the line between power users and administrators continues to blur, as Linux and Windows gain equal footing in business, it becomes harder to remember and do it all. This is the guide that gives admins the answers they need to common problems and tasks, allowing them time to eat lunch.

Amazon rating: 5

5. Linux Administration Handbook

Since 2001, Linux Administration Handbook has been the definitive resource for every Linux system administrator who must efficiently solve technical problems and maximise the reliability and performance of a production environment. Now, the authors have systematically updated this classic guide to address today's most important Linux distributions and most powerful new administrative tools.

The authors spell out best practices for every facet of system administration, including storage management, network administration, web hosting, software configuration management, performance analysis, Windows interoperability, and much more. Sysadmins will appreciate the thorough discussions of such difficult topics such as DNS, LDAP, security, and the management of IT service organizations.

Sharing their war stories and hard-won insights, the authors capture the behavior of Linux systems in the real world, not just in ideal environments. They explain complex tasks in detail and illustrate these tasks with examples drawn from their extensive hands-on experience.

Amazon rating: 5

6. Hacking Exposed Linux, ISECOM

Use this comprehensive guide to secure your Linux network. Completely rewritten third edition provides an up-to-date coverage from a team of topic-focused experts. The text is based on the ISECOM security research, it explains in detail how to defend your system against all attacks.

- Secure your system by using countermeasures from the latest research
- Harden VoIP, RF, RFID, Bluetooth, and IR devices
- Follow attack techniques of ISDN, PSDN, and PSTN
- Apply cryptography and Trusted Computing for your best defense
- Block Linux signal jamming and eavesdropping attacks
- Prevent SPAM, phishing, DoS, and DDoS exploits
- Fix vulnerabilities in Web 2.0 services
- Find and repair C code errors with static analysis

Amazon rating: (4)

7. Real World Linux Security by Bob Toxen

Will you be ready to protect your system when a cracker comes? Real World Linux Security goes beyond the books that merely detail system vulnerabilities by offering system administrators practical solutions for safeguarding Linux systems and actively responding to break-in attempts. Veteran Bob Toxen shows you how to know your enemies and stop them at the front gate, before they can damage your system.

The book is organised into four sections: securing your system, preparing for an intrusion, detecting an intrusion, and recovering from an intrusion. Toxen even provides at-a-glance icons and tables rating the severity and likelihood of each type of attack. Along the way, you'll learn how to configure systems so they alter themselves to lock out a cracker at the first sign of attack.

You'll discover virtually cracker-proof techniques for protecting credit card databases, even if your web server and network are compromised. Toxen also presents techniques for ensuring that, if a break-in does occur, damage will be minimal and a full recovery can happen fast.

Amazon rating: 5

8. Beginning Linux Programming by Neil Matthew and Richard Stones

Provided you have some previous basic exposure to C and Unix, this book delivers an excellent overview of the world of Linux development with an appealing range of essential tools and APIs.

The standout feature of Beginning Linux Programming is its wide-ranging coverage of important topics in basic Unix programming. In a series of short chapters, the authors discuss the basics of writing Unix programs in C, with material on basic system calls, file I/O, inter process communication, and advanced topics such as socket programming and how to create Unix device drivers.

Parallel to this, the book introduces the toolkits and libraries for working with user interfaces, from simpler terminal mode applications to X and GTK+ for graphical user interfaces. While you won't be an authority on X or GTK+ after reading this book, you will certainly be able to explore real Linux development on your own after the capable introductory guide provided here. This text also serves as a valuable primer on languages and tools such as Tcl, Perl, and CGI.

Amazon rating: 5

9. Linux Kernel Development by Robert Love

Linux Kernel Development details the design and implementation of the Linux kernel, presenting the content in a manner that is beneficial to those writing and developing kernel code. While the book discusses topics that are theoretical, it does so with the goal of assisting programmers so they better understand the topics and become more efficient and productive in their coding.

The book discusses the major subsystems and features of the Linux kernel, including design and implementation, their purpose and goals, and their interfaces. Important computer science and operating system design details are also addressed. The book covers the Linux kernel from both angles, theoretical and applied, which should appeal to both types of readers.

Specific topics covered will include: all the important algorithms, relevant subsystems, process management, scheduling, time management and timers, system call interface, memory addressing, memory management, paging strategies, caching layers, VFS, kernel synchronization, and signals.

Amazon rating: 5

10. Building Clustered Linux Systems by Robert Lucke

The intent of this book is to provide an introduction to clustered Linux systems for an audience that may not have any experience working with this type of solution. A cluster comprises multiple physical systems, interconnected and configured to act in concert with each other as if they were a single resource.

This book is not intended to be an introduction to Linux system administration or TCP/IP network administration. The author made every attempt to point you to appropriate reference books and external sources of information. Experience administering Linux or Unix systems and an understanding of network connections is essential to getting the most useful information from this book.

This book attempts to tie together the "big picture" for those who already understand the individual elements of that picture. The goal is to learn how to configure and use Linux tools on multiple computers to create the appearance of a single system "clustered" solution. This is a complex endeavor that relies on understanding the basic operation of Linux and subsystems which may involve network connections.

Amazon rating: 5

10 Free HTML Editor on Linux

Free HTML editors are ideal and offer great flexibility and power without shelling out much money. In case you want more features and flexibility, there are quite a number of reasonably priced HTML editors in the market.

As cited on webdesign.about.com, here’s looking at some of the best along with their features.

1. Komodo Edit – This is the best free XML editor available and has a lot of features for HTML and CSS development. Apart from this, you can avail extensions for adding languages or other useful features (including special characters). You can get two versions of it namely Komodo Edit and Komodo IDE. For further information you can go on-
Komodo Edit

2. Aptana Studio – It is an interesting take on web page development focusing on the HTML, JavaScript and other elements allowing you to make rich Internet applications. The most interesting thing is the outline view that enables it easy for visualizing the DOM. For further information you can go on-
Aptana Studio

3. NetBeans – This is a Java IDE that assist in building strong web applications. It has a steep learning curve as they work differently than other web editors. Its striking feature is the version control included in the IDE which is good for people working in large development environments. For further information you can go on-
NetBeans

4. Screem- This is a versatile text web page editor and XML editor. It can recognize the Doctype being used by you and validates and completes tags based on that. It also has wizards and help which is not generally seen on Unix software. For further information you can go on-
Screem

5. Bluefish – This is a full featured web editor for Linux with the 2.0 release adding a number of great new features. It also has native executables for Windows and Macintosh. It comes with code-sensitive spell check, auto complete of a number of different languages (HTML, PHP, CSS, etc.), snippets, project management, and auto-save. For further information you can go on-
Bluefish

6. Eclipse –This is a complex development environment ideal for people doing a lot of coding on different platforms in different languages. Eclipse is made as plug-ins so in case you need to edit anything you simply need to find the right plug-in and go. It has Java, JavaScript, and PHP plugins, along with plugin for mobile developers. For further information you can go on-
Eclipse

7. SeaMonkey - This is the Mozilla project integrated Internet application suite. It comes with a web browser, email and newsgroup client, IRC chat client, and composer — the web page editor. A good thing about using SeaMonkey is that it comes with a built-in browser so testing is quick. For further information you can go on SeaMonkey

8. Amaya – This is the W3C web editor that also acts as a web browser validating the HTML while you build your page. It permits you to view the tree structure of your web documents so it is great for understanding the DOM and how your documents appear in the document tree. For further information you can go on-
Amaya

9. KompoZer – This is a good WYSIWYG editor based on the Nvu editor. This came into existence by certain people who were very fond of Nvu, but did not like its slow release schedules and poor support. For further information you can go on-
KompoZer

10. Nvu – This is a great WYSIWYG editor and its free. It comes with a site manager that allows you to review the sites being built. It has XML support, advanced CSS support, full site management, built-in validator, and international support along with WYSIWYG and color coded XHTML editing. For further information you can go on-
Nvu

How we can choose Linux Distro!

We often get queries from our readers regarding which Linux to choose for a particular system or which Linux distro to start with. So here's a small guide, which can help you choose a suitable distro basis your needs.

1. Debian:

Who Should Choose: Those who need stability as it uses older software which is known to be stable.
Suitable for: Servers
Recommended system requirements: 1GHz processor, 512MB memory, 5GB hard-drive
Website: http://www.debian.org/distrib/

2. Ubuntu

Who Should Choose: Those want the latest software and an interface with better graphics.
Suitable for: Average mainstream desktop/laptop user
Recommended system requirements: 800MB memory, 1GHz processor, and 5GB hard-drive
Website: http://www.ubuntu.com/download

3. Kubuntu

Who Should Choose: Those want the latest software and an interface with better graphics but dislikes unity.
Suitable for: Average mainstream desktop/laptop user
Recommended system requirements: 1GHz processor, 10GB hard-drive, and more than 1GB memory
Website: http://www.kubuntu.org/getkubuntu


4. Xubuntu

Who Should Choose: Lightweight version of Ubuntu. Those want the latest software and an interface with better graphics but for older hardware or hardware with less resources.
Suitable for: Average mainstream desktop/laptop user
Recommended system requirements: 512MB memory and 5GB hard-drive
Website: http://xubuntu.org/getxubuntu/

5. Linux Mint

Who Should Choose: want a Debian-based system, but dislike Unity may be interested in Linux Mint. Comes with choice of interface i.e. MATE, Cinnamon, XFCE, or KDE.
Suitable for: Average mainstream desktop/laptop user
Recommended system requirements: 1GHz processor, 1GB memory, and 10GB hard-drive
Website: http://www.linuxmint.com/download.php

6. Kali

Who Should Choose: Hackers or security experts.
Suitable for: Average mainstream desktop/laptop user
Website: http://www.kali.org/downloads/

7. Slackware

Who Should Choose: advanced users who want light weight system.
Suitable for: Average mainstream desktop/laptop user
Recommended system requirements: i486 processor, 256MB memory, and 5GB hard-drive

8. Fedora

Who Should Choose: Who want RedHat counterpart of Ubuntu (Debian system). Suitable for: Mainstream desktop/laptop users.
Recommended system requirements are 1GB memory and 10GB hard-drive.
Website: http://fedoraproject.org/en/get-fedora

9. Red Hat Enterprise Linux

Who Should Choose: Who want paid servery system.
Suitable for: Server system

10. Puppy Linux

Who Should Use: Those with lightweight system
Suitable for: Older systems
Recommended system requirements: 333MHz processor, 64MB memory, 512MB swap, and 1GB hard-drive.
Website: http://puppylinux.org/main/Download Latest Release.htm

Atithya Amaresh, EFYTIMES News Network

10 Basic For Newbee in Python

We all know that Python is one of the most sought after programming language in the open source space. It is one language that lets you work very quickly and integrate your system more effectively. So, if you have just stepped into Python, we bring to you ten essential Python tips that will help ease out your journey in this world.

1. Running Python scripts

On major of the UNIX systems, you can run Python scripts from the command line using folowing command.

$ python mypyprog.py

2. Running Python programs from Python interpreter

The Python interactive interpreter is used interchangeable with Python shell. This is where the Python commands can be typed and executed. This makes it easy to try your first steps in programming and using all Python commands. You just issue each command at the command prompt, one by one, and the answer is immediate.

Python interpreter can be started by issuing the command:

$ python
atithya@ubuntu:~$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>>

In this article, all the code starting with the >>> symbol are meant to be given at the Python prompt. It is also important to remember that Python takes tabs very seriously – so if you are receiving any error that mentions tabs, correct the tab spacing.

3. Dynamic typing

In Java, C++, and other statically typed languages, you must specify the data type of the function return value and each function argument. On the other hand, Python is a dynamically typed language. In Python, you never have to explicitly specify the data type of anything. Based on what value you assign, Python will keep track of the data type internally.

4. Python statements

Python uses carriage returns to separate statements, and a colon and indentation to separate code blocks. Most of the compiled programming languages, such as C and C++, use semicolons to separate statements and curly brackets to separate code blocks.

5. == and = operators

Python uses ‘==’ for comparison and ‘=’ for assignment. Python does not support inline assignment, so there’s no chance of accidentally assigning the value when you actually want to compare it.

Today, Python is one of the most popular programming languages in the open source space. It’s a vast language and there are many gems to discover – here are ten tips for new users to get the ball rolling…

6. Concatenating strings

You can use ‘+’ to concatenate strings like so:

>>> print 'atit'+'hya'
atithya

7. The __init__ method

The __init__ method is run as soon as an object of a class is instantiated. The method is useful to do any initialization you want to do with your object. The __init__ method is analogous to a constructor in C++, C# or Java.

[Example]
class Person:
def __init__(self, name):
self.name = name
def sayHi(self):
print ‘Hello, my name is’, self.name
p = Person(‘Atithya’)
p.sayHi()

[Output]
[~/src/python $:] python initmethod.py
Hello, my name is Atithya

8. Modules

To keep your programs manageable as they grow in size, you may want to break them up into several files. Python allows you to put multiple function definitions into a file and use them as a module that can be imported into other scripts and programs. These files must have a .py extension.

[Example]
# file my_function.py
def minmax(a,b):
if a <= b:
min, max = a, b
else:
min, max = b, a
return min, max
Module Usage
import my_function
x,y = my_function.minmax(25, 6.3)

9. Module defined names

The built-in function ‘dir()’ can be used to find out which names a module defines. It returns a sorted list of strings.

[Example]
>>> import time
>>> dir(time)
[‘__doc__’, ‘__file__’, ‘__name__’, ‘__package__’, ‘accept2dyear’, ‘altzone’, ‘asctime’, ‘clock’, ‘ctime’, ‘daylight’, ‘gmtime’, ‘localtime’, ‘mktime’, ‘sleep’, ‘strftime’, ‘strptime’, ‘struct_time’, ‘time’, ‘timezone’, ‘tzname’, ‘tzset’]

10. Module internal documentation

You can see the internal documentation (if available) of a module name by looking at .__doc__.

[Example]
>>> import time
>>> print time.clock.__doc__
clock() -> floating point number

This example returns the CPU time or real time since the start of the process or since the first call to clock(). This has as much precision as the system records.

Courtesy: Linuxuser

Here is syntax most used on MATLAB

List Of Syntax For MATLAB
Have you been searching for syntax on MATLAB? We bring it for you.
Programming is much easier when you have a list of syntax in the next window. So, with that in mind, bookmark this one and keep this open whenever you're working on MATLAB. Here it is...

VARIOUS
foo ... end where foo in { if, for, while, ... }
block (grouping statements, especially when statements are not expressions)
...
breaking lines (useful when end-of-line and/or indentation has a special meaning)
%( ... %)
commenting (nestable)
%
commenting (until end of line)
< > <= >=
comparison
min / max
comparison (min / max (binary or more))
function MYFUNCTION
%MYFUNCTION the very first comment line is displayed in the help table of contents
%
% the remaining lines are displayed when getting help for MYFUNCTION
%
documentation comment
== ~= eq ne isequal isequalwithequalnans
equality / inequality (deep)
( ... )
grouping expressions
eval
runtime evaluation
case-sensitive
tokens (case-sensitivity (keywords, variable identifiers...))
[a-zA-Z][_a-zA-Z0-9]*
tokens (variable identifier regexp)
lowercasenoseparator
tokens (what is the standard way for scrunching together multiple words)
=
variable assignment or declaration (assignment)
global v1 v2
variable assignment or declaration (declaration)

FUNCTIONS

inline('...x...y...')(1)
anonymous function
f(a,b,...)
function call
f a b ...
function call
f
function call (with no parameter)
function retval = f(para1, para2)
retval = ...
function definition
function f(para1, para2)
...
function definition (procedures)
function f(varargin)
for i=1:nargin
 ...(varargin{i})
end
function definition (variable number of arguments)
return(2)
function return value (breaks the control flow)
no syntax needed(3)
function return value (function body is the result)
= val;
function return value (setting the result)
evalin('caller', ...)
runtime inspecting the caller information

CONTROL FLOW

continue / break
breaking control flow (continue / break)
return(2)
breaking control flow (returning a value)
try
  a
catch
  ...
end
exception (catching)
error
exception (throwing)
if c, ..., end
if_then
if c
  ...
end
if_then
if c1, b1, elseif c2, b2, else, b3, end
if_then_else
if c
  b1
elseif c2
  b2
else
  b3
end
if_then_else
for i = 10:-1:1, ..., end
loop (for each value in a numeric range, 1 decrement)
for i = 1:10, ..., end
loop (for each value in a numeric range, 1 increment (see also the entries about ranges))
for i = 1:3:10, ..., end
loop (for each value in a numeric range, free increment)
while c, ..., end
loop (while condition do something)
switch val
  case v1
    ...
  case {v2,v3}
    ...
  otherwise
    ...
end
multiple selection (switch)
,
sequence
;
sequence
end-of-line
sequence
TYPES
t(e)
cast (computed conversion (calls an internal or a user-defined function))
typecast(e,t)
cast (downcast (need runtime checking))
typecast(e,t)
cast (upcast)
mutability is the default
mutability, constness (type of a mutable value)

REFLEXIVITY AND OBJECT ORIENTED PROGRAMMING

class
class declaration
first parameter(4)
current instance
class
get the type/class corresponding to an object/instance/value
ismethod
has the method
method(object, para)
method invocation
method(object)
method invocation (with no parameter)
methods
methods available
o2 = o(5)
object cloning
class_name(...)
object creation
isa
testing class membership

PACKAGE AND MODULE
package declare(6)
declare
all files in package directory are exported. files in /private sub-directory are not exported, but can be used by the package itself
declare (selective export)
addpath
import (everything into current namespace)
/
package scope

STRINGS

s(n)
accessing n-th character
char
ascii to character
'z'
character "z"
(done automatically when applying mathematical operations on char, such as +)
character to ascii
repmat
duplicate n times
s(n:m)
extract a substring
strfind
locate a substring
t=strfind(s,p), t(end)
locate a substring (starting at the end)
nothing - just remove ";" at the end of the expression, and it will print it
simple print (on any objects)
disp
simple print (on any objects)
printf
simple print (printf-like)
sprintf
sprintf-like
[string1 string2]
string concatenation
strcmp
string equality & inequality
== ~=
string equality & inequality
length
string size
'...'
strings (with no interpolation of variables)
upper / lower(7)
upper / lower case character
upper / lower
uppercase / lowercase / capitalized string

BOOLEANS
 
false
false value
array containing at least one false value
false value
0(8)
false value
0.0
false value
''
false value
[]
false value
{}
false value
~
logical not
| / &
logical or / and (non short circuit (always evaluates both arguments))
|| / &&
logical or / and (short circuit)
anything not false
true value
logical
type name

LISTS AND BAGS

a(1,:), a(2,:)
2 lists from a list of couples
[e l]
adding an element at the beginning (list cons) (return the new list (no side-effect))
[l e]
adding an element at the end (return the new list (no side-effect))
a(2:end)
all but the first element
find(a == 3)
find an element
ismember
is an element in the list
any(9)
is the predicate true for an element
strcat
join a list of strings in a string using a glue string
a(a == 3)
keep elements (matching)
a(end)
last element
,
list concatenation
[ a, b, c ](10)
list constructor
[a b]
list of couples from 2 lists
[a.(:)]
list out of a bag
size
list size
length
list size
numel
list size
a(i)
list/array indexing
a.(e)
lookup an element in a association list
unique(11)
remove duplicates
fliplr flipud...
reverse
min / max
smallest / biggest element
sort(12)
sort
magical: sin(x) computes sin on each element
transform a list (or bag) in another one
magical: a binary function or operator is appliied on each element
transform two lists in parallel
cell
type name

OTHER DATA TYPES

{}
computable tuple (these are a kind of immutable lists playing a special role in parameter passing) (empty tuple)
t{:}
computable tuple (these are a kind of immutable lists playing a special role in parameter passing) (using a tuple for a function call)
h.k
dictionary (access: read/write)
struct(a, b, c, d)
dictionary (constructor)
isfield
dictionary (has the key ?)
fieldnames
dictionary (list of keys)
struct2cell
dictionary (list of values)
rmfield
dictionary (remove by key)
struct
dictionary (type name)
a:b
range (inclusive .. inclusive)
.
record (selector)
{ a, b, c }
tuple constructor

MATHEMATICS

+ / - / * / /
addition / subtraction / multiplication / division
bitand / bitor / bitxor
bitwise operators (and / or / xor)
bitcmp
bitwise operators (bitwise inversion)
bitshift
bitwise operators (left shift / right shift / unsigned right shift)
^
exponentiation (power)
log10
logarithm (base 10)
log2
logarithm (base 2)
log
logarithm (base e)
rem
modulo (modulo of -3 / 2 is -1)
mod
modulo (modulo of -3 / 2 is 1)
-
negation
1000, 1000., 1000.0
numbers syntax (integers)
mathematical
operator priorities and associativities (addition vs multiplication)
mathematical
operator priorities and associativities (exponentiation vs negation (is -3^2 equal to 9 or -9))
rand
random (random number)
rand('state',...)
random (seed the pseudo random generator)
sqrt realsqrt / exp / abs
square root / e-exponential / absolute value
sin / cos / tan
trigonometry (basic)
asin / acos / atan(13)
trigonometry (inverse)
trunc / round / floor / ceil
truncate / round / floor / ceil
single, double
type name (floating point)
int8, uint8, int16, uint16, ...64
type name (integers)

SOURCE: Regaux.org

Android Cheatsheet For Coders!

As an Android app developer, there are a number of things that you can do. But some help will always come in handy. Each example given below is an example of Context in Android and you can do some nifty things with these. Try them out the next time you sit down with coding for the Android platform on your mind.

Intents

Intents is amongst the most used and best features of Android. They are commonly used to start an Activity, like opening a contact or email, or for starting an Activity for a result, like scanning a barcode or taking a picture to attach it to your mail. You specify intents primarily by using action strings and URIs. In the following code, we use the android.intent.action.VIEW action and the startActivity().

Intent intent = new Intent(Intent.ACTION_VIEW);
// Choose a value for uri from the following.
// Search Google Maps: geo:0,0?q=query
// Show contacts: content://contacts/people
// Show a URL: http://www.google.com
intent.setData(Uri.parse(uri));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);


Other useful action and URI pairs include:

Intent.ACTION_DIAL, tel://8675309
Intent.ACTION_CALL, tel://8675309


You can achieve some other things with startActivityForResult() as well. This can be used to scan a barcode,

Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, 0);


After this, add onActivityResult to your activity

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == 0) {
Bundle extras = data.getExtras();
String result = extras.getStringExtra("SCAN_RESULT");
// ...
}
}


In order to take a picture,

Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, 0);
// ...

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == 0) {
String result = data.toURI();
// ...
}
}


Wifi

You can use the WiFiManager in order to enable and disable the WiFi of your device. This is actually quite simple,

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(enabled);


Notifications

Text notifications are known as Toast and they appear for a brief period above all other activities. They are also easy to put,

Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

The amount of time for displaying the notification can be increased by using Toast.LENGTH_LONG.

Alert and Input Dialogs

An alert is usually used in order to ask the user for an input. You can do this without having to create a new layout. For this use the AlertDialog.Builder,

AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(title);
alert.setMessage(message);

// You can set an EditText view to get user input besides
// which button was pressed.
final EditText input = new EditText(this);
alert.setView(input);

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText();
// Do something with value!
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});

alert.show();


Location

The LocationManager can be used in order to start up the GPS and then listen for location updates.

LocationManager locator = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener mLocationListener = new LocationListener() {
public void onLocationChanged(Location location) {
if (location != null) {
location.getAltitude();
location.getLatitude();
location.getLongitude();
location.getTime();
location.getAccuracy();
location.getSpeed();
location.getProvider();
}
}

public void onProviderDisabled(String provider) {
// ...
}

public void onProviderEnabled(String provider) {
// ...
}

public void onStatusChanged(String provider, int status, Bundle extras) {
// ...
}
};

// You need to specify a Criteria for picking the location data source.
// The criteria can include power requirements.
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE); // Faster, no GPS fix.
criteria.setAccuracy(Criteria.ACCURACY_FINE); // More accurate, GPS fix.
// You can specify the time and distance between location updates.
// Both are useful for reducing power requirements.
mLocationManager.requestLocationUpdates(mLocationManager.getBestProvider(criteria, true),
MIN_LOCATION_UPDATE_TIME, MIN_LOCATION_UPDATE_DISTANCE, mLocationListener,
getMainLooper());


The LocationManager can also be used in order to find the smartphone’s last known location. This is a faster method than using a LocationListener and then waiting for a fix. Do this by,

// Start with fine location.
Location l = locator.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (l == null) {
// Fall back to coarse location.
l = locator.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}


SMS

The SmsManager is the one that sends a text.

SmsManager m = SmsManager.getDefault();
String destination = "8675309";
String text = "Hello, Jenny!";
m.sendTextMessage(destination, null, text, null, null);


Vibrate

Vibrating an Android-based smartphone can be done for a specified duation,

(Vibrator) getSystemService(Context.VIBRATOR_SERVICE).vibrate(milliseconds);

Sensors

The SensorManager can be used in order to use the sensor data.

SensorManager mSensorManager = (SensorManager) getSystemService(Activity.SENSOR_SERVICE);
private final SensorListener mSensorListener = new SensorListener() {
public void onAccuracyChanged(int sensor, int accuracy) {
// ...
}

public void onSensorChanged(int sensor, float[] values) {
switch (sensor) {
case SensorManager.SENSOR_ORIENTATION:
float azimuth = values[0];
float pitch = values[1];
float roll = values[2];
break;
case SensorManager.SENSOR_ACCELEROMETER:
float xforce = values[0];
float yforce = values[1];
float zforce = values[2];
break;
case SensorManager.SENSOR_MAGNETIC_FIELD:
float xmag = values[0];
float ymag = values[1];
float zmag = values[2];
break;
}
}
};

// Start listening to all sensors.
mSensorManager.registerListener(mSensorListener, mSensorManager.getSensors());
// ...
// Stop listening to sensors.
mSensorManager.unregisterListener(mSensorListener);


Silence Ringer

The AudioManager can be used in order to enable or disable the silent mode on a smartphone.

mAudio = (AudioManager) getSystemService(Activity.AUDIO_SERVICE);
mAudio.setRingerMode(AudioManager.RINGER_MODE_SILENT);
// or...
mAudio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);


Source: Damon Kohler's Blog