Saturday, December 29, 2012
Sunday, December 23, 2012
Saturday, December 22, 2012
Enable Hibernate in Ubuntu 12.04
In Ubuntu 12.04 and newer, hibernation has been disabled by default in policykit. To enable hibernation, you can follow official documentation here.
Before enabling hibernation, please try to test whether it works correctly by running
pm-hibernate
in a terminal. The system will try to hibernate. If you are able to start the system again then you are more or less safe to add an override.To do so, start editing:
sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
Paste the following lines:
[Re-enable hibernate by default] Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes
Save and exit gedit.
Restart and hibernation is back!
Or run the following code to just reset the menu:
killall unity-panel-service
Source: How to enable hibernation?
AUTHOR: OBSCURE
Wednesday, December 5, 2012
Serial Port Communication From Java - RxTx Installation.
Want to communicate with serial port using Java? You may want to try RxTx library. It's easy to use.
To install follow the instruction below:
To install follow the instruction below:
The official RxTx binary pack is available here. The provided link will download the distro with some standard binaries (for linux 32bit, 64 bit, etc). If binaries for your specific operating system are not included, you may consider recompiling RxTx yourselves.
For a custom Win64 RxTx distro, have a look at the CloudHopper's web site.
To install it, unzip the distribution file in a temporary place and do the following copies:
- File RXTXcomm.jar should go under JDKDIR/jre/lib/ext/
- The necessary library( .so for linux, .dll for windows) should go under JDKDIR/jre/bin/
Sunday, December 2, 2012
Ambiguity problem in C++
Functions with predefined value can cause ambiguity in C++. See the example below:
If I call this like this, the first call is ok, but the second call give the ambiguous function error.
AUTHOR:
OBSCUREIf I call this like this, the first call is ok, but the second call give the ambiguous function error.
AUTHOR:
Thursday, November 29, 2012
PYTHON REFERENCES
- Online Python Tutor : It is a free educational tool that helps students overcome a fundamental barrier to learning programming: understanding what happens as the computer executes each line of a program's source code. Using this tool, a teacher or student can write a Python program directly in the web browser and visualize what the computer is doing step-by-step as it executes the program.
- life is short - you need Python!: A blog on Python with tutorials, code, programs, tips and tricks, how-to, book-list, crawler / spider help, data structure and algorithm implementation and many more ... maintained by Tamim Shahriar Subeen, one of the best IT professional in Bangladesh.
- Python for fun - advanced python codes: This collection is a presentation of several small Python programs. They are aimed at intermediate programmers; people who have studied Python and are fairly comfortable with basic recursion and object oriented techniques. Each program is very short, never more than a couple of pages and accompanied with a write-up.
- site aims to be both a library of educational materials using Python to teach computer programming, and a virtual meeting place for teachers and students engaged in learning and teaching using Python. Happy computing!
Monday, November 26, 2012
Turtle
Turtle is a Python module to draw pictures.
import turtle # allows us to use the turtles library wn = turtle.Screen() # creates a graphics window alex = turtle.Turtle() # create a turtle named alex alex.forward(150) # tell alex to move forward by 150 units alex.left(90) # turn by 90 degrees alex.forward(75) # complete the second side of a rectangle wn.exitonclick()
Friday, November 23, 2012
Sending SMS via USB Connected Cell Phone with Python
import serial import time class SMSsender: def __init__(self): self.destination = "" self.msg = "" def setRecipient(self, dest): self.destination = dest def setContent(self, message): self.msg = message def connectPhone(self): #replace '/dev/ttyACM0' with your device name #replace 460800 with a suitable baud-rate of your phone self.ser = serial.Serial('/dev/ttyACM0', 460800, timeout=2) time.sleep(1) def sendMessage(self): self.ser.write('ATZ\r') time.sleep(1) self.ser.write('AT+CMGF=1\r') time.sleep(1) self.ser.write('''AT+CMGS="''' + self.recipient + '''"\r''') time.sleep(1) self.ser.write(self.content + "\r") time.sleep(1) self.ser.write(chr(26)) time.sleep(1) def disconnectPhone(self): self.ser.close()To send sms use this follow the code below:
sms = SMSsender() sms.setRecipient('+8801*********') sms.setContent('Write your message here') sms.connectPhone() sms.sendMessage() sms.disconnectPhone()You may also try this link(I've not tested yet): sms-over-3g-and-bluetooth-from-python
Source: linux-101.org
Labels:
DEVELOPMENT,
mobile,
programming,
Python,
serial-port,
sms
Thursday, November 15, 2012
Tuesday, November 6, 2012
Make them all glow, can you?
Instructions: Click on orbs arranged in a grid to make them all glow. Clicking on an orb changes its state from unlit to lit or lit to unlit along with the neighboring orbs. Turn on all the orbs to pass a level with as few moves as you can. There are 9 levels, each with more orbs than the previous one. Two difficulty modes. In the easy mode, all orbs are unlit in the beginning and in the hard mode, some orbs are already lit to make things difficult for the player. Author: MUKTO SOFTWARE LTD.
Monday, November 5, 2012
Python - Coding with fun
How to reverse a string?
How to read from console in Python?
Want to read an integer?
Swap values in python:
My motivation to learn python is: life is short - you need Python
s = 'abcdef' s = s[::-1] print sExplanation: "::" is known as stride notation
s[::2] s[::-2]Returns "ace" and "fdb" respectively.
How to read from console in Python?
name = raw_input()
Want to read an integer?
num = raw_input() num = int(num) # raw_input returns string, so convert it to integer
Swap values in python:
a, b = b, a
My motivation to learn python is: life is short - you need Python
Saturday, October 13, 2012
Installing Apache Maven-Java tool
Download maven.
Windows OS:
- Unzip the distribution archive, i.e. apache-maven-3.0.4-bin.zip to the directory you wish to install Maven 3.0.4. These instructions assume you chose C:\Program Files\Apache Software Foundation. The subdirectory apache-maven-3.0.4 will be created from the archive.
- Add the M2_HOME environment variable. [almost similar as this]: adding the M2_HOME variable in the system variables with the value C:\Program Files\Apache Software Foundation\apache-maven-3.0.4. Be sure to omit any quotation marks around the path even if it contains spaces.
- In the same dialog, add the M2 environment variable in the system variables with the value %M2_HOME%\bin.
- In the same dialog, update/create the Path environment variable in the system variables and prepend the value %M2% to add Maven available in the command line.
- In the same dialog, make sure that JAVA_HOME exists in your system variables and it is set to the location of your JDK, e.g.C:\Program Files\Java\jdk1.5.0_02 and that %JAVA_HOME%\bin is in your Path environment variable.
- Open a new command prompt and run mvn --version to verify that it is correctly installed.
Linux based/Ubuntu Operating Systems:
- Extract the distribution archive, to the directory you wish to install Maven 3.0.4. These instructions assume you chose /home/username/java/tools/maven.
- Open terminal and type: gedit ~/.bashrc
- Set environment variable by adding the following lines at the bottom of .bashrc :
- export M2_HOME=/home/username/java/tools/maven
- export M2=$M2_HOME/bin
- export PATH=$M2:$PATH
- export JAVA_HOME=/usr/lib/jvm/jdk-default #if JAVA_HOME not exist.
- Run mvn --version to verify that it is correctly installed.
Labels:
apache-maven,
DEVELOPMENT,
JAVA,
Linux,
maven,
Ubuntu,
Windows,
windows 7
Tuesday, October 9, 2012
Send and receive SMS using GSM modem or phone on Ubuntu | TechyTalk.info
Send and receive SMS using GSM modem or phone on Ubuntu | TechyTalk.info.
#go to terminal and give the msg as below #sudo python sms.py 'CellNumber Msg you want to send' import gammu import sys def main(): words = sys.argv[1].split(None, 1) dest = words[0] msg = words[1] print msg + "-----" + dest #return sms = gammu.StateMachine() sms.ReadConfig() sms.Init() message = { 'Text': msg, 'SMSC': {'Location': 1}, 'Number': destinationNumber, } print sms.SendSMS(message) if __name__ =='__main__': main()
Thursday, September 20, 2012
How to create non-editable JTable:
Override the method "isCellEditable" and implement as needed, such as:
//instance table model DefaultTableModel tableModel = new DefaultTableModel(){ @Override public boolean isCellEditable(int row, int column) { return false; } }; //...other codes table.setModel(tableModel);
Tuesday, September 18, 2012
System.getProperty(key) key list for JAVA:
java.version | Java Runtime Environment version |
java.vendor | Java Runtime Environment vendor |
java.vendor.url | Java vendor URL |
java.home | Java installation directory |
java.vm.specification.version | Java Virtual Machine specification version |
java.vm.specification.vendor | Java Virtual Machine specification vendor |
java.vm.specification.name | Java Virtual Machine specification name |
java.vm.version | Java Virtual Machine implementation version |
java.vm.vendor | Java Virtual Machine implementation vendor |
java.vm.name | Java Virtual Machine implementation name |
java.specification.version | Java Runtime Environment specification version |
java.specification.vendor | Java Runtime Environment specification vendor |
java.specification.name | Java Runtime Environment specification name |
java.class.version | Java class format version number |
java.class.path | Java class path |
java.library.path | List of paths to search when loading libraries |
java.io.tmpdir | Default temp file path |
java.compiler | Name of JIT compiler to use |
java.ext.dirs | Path of extension directory or directories |
os.name | Operating system name |
os.arch | Operating system architecture |
os.version | Operating system version |
file.separator | File separator ("/" on UNIX) |
path.separator | Path separator (":" on UNIX) |
line.separator | Line separator ("\n" on UNIX) |
user.name | User's account name |
user.home | User's home directory |
user.dir | User's current working directory |
Monday, September 17, 2012
Download video from youtube in Ubuntu terminal
First download and install the program youtube-dl from terminal:
After installation, you can download video from YouTube:
sudo apt-get install youtube-dl
After installation, you can download video from YouTube:
youtube-dl -o file_name.flv youtube-video-link
Monday, September 10, 2012
Sudoers - Community Ubuntu Documentation
Shutting Down From The Console Without A Password
Often people want to be able to shut their computers down without requiring a password to do so. This is particularly useful in media PCs where you want to be able to use the shutdown command in the media centre to shutdown the whole computer.
To do this you need to add some cmnd aliases as follows:
Cmnd_Alias SHUTDOWN_CMDS = /sbin/shutdown, /sbin/halt, /sbin/reboot
You also need to add a user specification (at the end of the file after the "%admin ALL = (ALL) ALL" line so it takes effect - see above for details):
ALL=(ALL) NOPASSWD: SHUTDOWN_CMDS
Obviously you need to replace "" with the username of the user who needs to be able to shutdown the pc without a password. You can use a user alias here as normal.
via Sudoers - Community Ubuntu Documentation.
Often people want to be able to shut their computers down without requiring a password to do so. This is particularly useful in media PCs where you want to be able to use the shutdown command in the media centre to shutdown the whole computer.
To do this you need to add some cmnd aliases as follows:
Cmnd_Alias SHUTDOWN_CMDS = /sbin/shutdown, /sbin/halt, /sbin/reboot
You also need to add a user specification (at the end of the file after the "%admin ALL = (ALL) ALL" line so it takes effect - see above for details):
ALL=(ALL) NOPASSWD: SHUTDOWN_CMDS
Obviously you need to replace "" with the username of the user who needs to be able to shutdown the pc without a password. You can use a user alias here as normal.
via Sudoers - Community Ubuntu Documentation.
Friday, September 7, 2012
Wednesday, August 22, 2012
How to convert flv to mp3 in Ubuntu
FFmpeg from the repository is not compiled to support restricted formats such as mp3. You can use a third-party repository such as Medibuntu, compile ffmpeg yourself, or use another library, such as: libavcodec-extra-53.
The basic command:
By default this will create a 64 kb/s file. You can declare the audio bitrate with -ab:
If the flv already has mp3 audio, then there is no need to re-encode. You can just copy the audio stream. This will preserve the audio quality and will be much quicker since there is no re-encoding:
Along with some other information, ffmpeg will provide file details with the above command:
The basic command:
Code:
ffmpeg -i inpuvvideofile.flv outputaudiofile.mp3
Code:
ffmpeg -i inpuvvideofile.flv -ab 128k outputaudiofile.mp3
Code:
Don't know what the audio is? Just ask ffmpeg:ffmpeg -i inpuvvideofile.flv -acodec copy outputaudiofile.mp3
Code:
ffmpeg -i inputvideo.flv
Code:
Stream #0.0: Video: flv, yuv420p, 320x240, 29.97 tb(r) Stream #0.1: Audio: mp3, 22050 Hz, mono, s16, 56 kb/sSource:ubuntuforums
Saturday, June 23, 2012
Thursday, June 21, 2012
grub2 - Grub Error in Ubuntu 12.04 after upgrade from 11.10
Boot into the Ubuntu Live Cd and open terminal.
1. Identify Ubuntu partition:
2. Mount it ( replace sda1 with the Ubuntu partition number):
3.Reinstall grub:
1. Identify Ubuntu partition:
sudo fdisk -l
2. Mount it ( replace sda1 with the Ubuntu partition number):
sudo mount /dev/sda1 /mnt
3.Reinstall grub:
sudo grub-install --root-directory=/mnt /dev/sda sudo update-grub
Solution from: grub2 - Ubuntu 11.10 not showing up in GRUB bootloader after update and restart :( - Ask Ubuntu.
Wednesday, June 20, 2012
Friday, June 15, 2012
Installing Oracle-JDK in Ubuntu
Download JDK from ORacle. Run Terminal:
#Next line will add java to symlink
Or, better if you can set environment variable by adding the following lines at the bottom of .bashrc by "gedit ~/.bashrc":
You can now check if the java is installed properly in terminal:
These will return the version of java and javac.
chmod u+x jdk-6u31-linux-i586.bin ./jdk-6u31-linux-i586.bin sudo mv jdk1.6.0_31 /usr/lib/jvm/
#Next line will add java to symlink
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_31/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_31/bin/javac" 1
Or, better if you can set environment variable by adding the following lines at the bottom of .bashrc by "gedit ~/.bashrc":
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_03 export PATH=$PATH:$JAVA_HOME/bin
You can now check if the java is installed properly in terminal:
java -version javac -version
These will return the version of java and javac.
Tuesday, April 24, 2012
Ubuntu Command Collection
- install debian file:
sudo dpkg -i package_name.deb
- install dependency:
sudo apt-get -f install
- install software:
sudo apt-get -f install package_name
- install bundle file:
sudo sh file_name.bundle
- install bin/sh file:
chmod +x file_name.bin ./file_name.bin
- Installing WIRESHARK's dumpcap without allowing non-root users to capture packets:
setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap
- Find the MAC address:
ifconfig
References:
Labels:
deb,
Debian,
Dpkg,
Linux,
package name,
TIPS 'N' TRICKS,
Ubuntu
Monday, April 9, 2012
Generics are not supported in -source 1.3 error in Maven Project
When compiling via maven project, you may have encountered following error:
To solve this you must add the below lines at your pom.xml :
generics are not supported in -source 1.3 error in Maven Project. use -source 5 or higher to enable generics.
Annotation is not allowed in -source 1.3 use -source 5 or higher to enable annotation.
To solve this you must add the below lines at your pom.xml :
org.apache.maven.plugins maven-compiler-plugin 1.5</source> 1.5
Labels:
annotation,
DEVELOPMENT,
error,
generics,
JAVA,
maven,
netbeans,
pom
Monday, February 13, 2012
Tuesday, January 17, 2012
C++ : keywords
32 keywords defined by standard C.
A list of some commonly used extended keywords:
All C (and C++) keywords are lowercase. Also, uppercase and lowercase are
different: else is a keyword; ELSE is not.
auto | double | int | struct |
break | else | long | switch |
case | enum | register | typedef |
char | extern | return | union |
const | float | short | unsigned |
continue | for | signed | void |
default | goto | sizeof | volatile |
do | if | static | while |
A list of some commonly used extended keywords:
asm | _cs | _ds | _es |
_ss | cdecl | far | huge |
interrupt | near | pascal |
All C (and C++) keywords are lowercase. Also, uppercase and lowercase are
different: else is a keyword; ELSE is not.
Subscribe to:
Posts (Atom)