Falseif the number supplied is less than 2 and if the number is equally divisible with some other number different than 1 and itself. If none of the previous conditions apply the function will return
True. The below python script will let user to decide how many numbers needs to be check to see whether the number is prime number:
#!/usr/bin/env python prime_numbers = 0 def is_prime_number(x): if x >= 2: for y in range(2,x): if not ( x % y ): return False else: return False return True for i in range(int(raw_input("How many numbers you wish to check: "))): if is_prime_number(i): prime_numbers += 1 print i print "We found " + str(prime_numbers) + " prime numbers."Read more...
~/.vnc/passwdis the default location where the VNC password is stored. The password is stored at this location when the
vncserverstarts for a first time. To update or change your VNC password you should use
vncpasswdwill promt you two times to enter your new password:
$ vncpasswd Password: Verify:The
vncpasswdcommand also accepts a password input from STDIN which also allows to store password file into different location. The following example will change the VNC password to
MYVNCPASSWORDand store it to
~/.secret/vncpassgiven that the
$ echo MYVNCPASSWORD | vncpasswd -f > ~/.secret/passvnc $Read more...
pastecommand. Consider a following example. In our sand box directory we have 3 files where each contains a single column of date:
$ ls f1 f2 f3 $ cat f1 az dr qw rt er $ cat f2 iu dr gg hh jj qq ee ui $ cat f3 qp dfNext, we can join them together using
$ paste f1 f2 f3 az iu qp dr dr df qw gg rt hh er jj qq ee uiRead more...
TABseparated use a following command to convert it to comma separated value file before you proceed.
$ cat test 1 2 4 4 2 3 3 3 $ sed 's/\t/,/g' test 1,2,4,4 2,3,3,3 OR $ cat test | tr '\t' ',' 1,2,4,4 2,3,3,3Read more...
sedcommand and bash shell. Here is a content of our sample file:
$ cat example.txt AAAAAAAAAA BBBBBBBBBB CCCCCCCCCC DDDDDDDDDD EEEEEEEEEENext, we are going to remove a second row from the above
$ sed 2d example.txt AAAAAAAAAA CCCCCCCCCC DDDDDDDDDD EEEEEEEEEERead more...
# apt-get install cmake libsdl-image1.2-dev libboost1.55-all-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libpango1.0-dev libsdl-net1.2-dev wgetOnce the prerequisites are installed download Wesnoth's source code. For this we use wget:
$ wget -c http://downloads.sourceforge.net/project/wesnoth/wesnoth-1.12/wesnoth-1.12/wesnoth-1.12.tar.bz2Read more...
/etc/hostsfile. This is not a bulletproof solution but should help as a first level privacy protection for your kids, your self or should aid if your students do not pay enough attention in the class.
mcrypttool to easily encrypt files whether the file is large or small in size. We will also use Mcrypt to encrypt and compress files and directories on the fly which can be usefully for a number of backup and scripting purposes.
UBUNTU/DEBIAN # apt-get install mcrypt REDHAT/FEDORA/CENTOS # yum install mcrypt
$ mkdir dir1 $ cd dir1/ $ echo "My File to Encrypt" > file1 $ cat file1 My File to Encrypt $ fallocate -l 500MB file2 $ md5sum file* bccd44aaa84c7c9d04a268f670ae92c5 file1 4034379ecc54213fc9a51785a9d0e8e2 file2Read more...
/var/lib/puppet/reports/each time it is executed. If the puppet executions are rather frequent, depending on the filesystem size this may create a little bit of problem with disk space as this small in file size reports consume disk space and more importantly each of the files created take on inode. Thus, before you know it you run into a trouble of missing free inodes. Puppet YAML reports eg:
# ls /var/lib/puppet/reports/webserver.localdomain 201501142321.yaml 201501142322.yamlRead more...
#!/usr/bin/env python while True: try: # Try to convert bunary to decimal decimal_num = int(raw_input("Enter a binary number: "), 2) # If we fail we ask again user to enter binary number except ValueError: print "Your input is not a binary number! Please try again." else: # Exit program if the conversion from binary to decimal was successful break # print converted decimal number print decimal_numSave your script as eg. binary2decimal.py, make it executable and execute:
$ chmod +x binary2decimal.py $ ./binary2decimal.pyRead more...