BASH script for resize images using morgify
#!/bin/bash
FILES=/home/rafal/Pictures/Mockba/*
for f in $FILES
do
echo “resize $f “
cp $f $f”.bak”
mogrify -resize 50% $f
done
Debugging authentication problems
— to debug POP3 —
# telnet x.x.x.x 110
user USERNAME
pass PASSWORD
stat
quit
— to debug IMAP —
# telnet x.x.x.x 143
a login USERNAME PASSWORD
a examine inbox
a logout
— to debug POP3 over SSL —
# openssl s_client -connect x.x.x.x:995
(then use same commands as POP3 example)
— to debug IMAP over SSL —
# openssl s_client -connect x.x.x.x:993
(then use same commands as IMAP example)
Make ISO images on Linux
Create iso file from cd drive:
dd if=/dev/cdrom of=/home/user/cd.iso
Create iso file from cd drive:
dd if=/dev/dvd of=/home/user/dvd.iso
Create iso file from scsi cd drive:
dd if=/dev/scd0 of=/home/user/cd.iso
Mount iso file and unmount :
mount -o loop -t iso9660 /home/user/cd.iso /mnt/dir_for_mount
umount -lf /mnt/dir_for_mount
MySQL How change root password
UPDATE mysql.user SET Password=PASSWORD(‘myNewPassword’) WHERE User=’root’;
FLUSH PRIVILEGES;
Send mail from terminal with attachment
echo “This is the message body” | mutt -a file_attach.zip -s “subject of message” recipient@domain.com
Embedded developing resources
1. http://www.barrgroup.com/Embedded-Systems/How-To/Embedded-Java
2.http://www.youtube.com/watch?v=mdHCWPZ-kbQ&feature=BFa&list=PL62BE418C34C3B2BD
3.http://www.javaworld.com/javaworld/jw-09-1996/jw-09-ripps.html
Using rsync to Mirror Directories
rsync -vaz /path/to/dirA/ /path/to/dir/B
Copy all files from dirA to dirB
rsync -vaz /path/to/dirA /path/to/dir/B
Copy dirA with all files to dirB
rsync -vaz --exclude=subdirC/ --exclude=*.tmp /path/to/dirA /path/to/dirB
Copy all files from dirA to dirB without sundir named “subdirC” and files *.tmp
[Linux] How set JAVA_HOME and GRAILS_HOME ?
[skowroniasty@localhost ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export JAVA_HOME=/usr/java/latest
export PATH=”$PATH:$JAVA_HOME/bin”
export GRAILS_HOME=/home/skowroniasty/grails-2.0.3/
export PATH=”$PATH:$GRAILS_HOME/bin”
export PATH
[Python] Send e-mail from LAN client when WAN IP was changed
#!/usr/bin/env python
””” Send e-mail from LAN client when WAN IP was changed “”“
“Rafal Skowron”
“date 16-02-2012”
“for Python 2.7”
import urllib2
import smtplib
import re
import time
””“Current IP IParray”“”
IParray=()
isNewIP= False
sleepTime=4 #in sec
isError= False
sendError = False
def getIpFromWeb():
global IParray
global isNewIP
global isError
web=”http://www.showmyip.com”
try:
tmpHtml=urllib2.urlopen(web)
ip = re.findall( r’[0-9]+(?:.[0-9]+){3}’, tmpHtml.read())
except Exception, e:
print ‘Something bad happened when try get page.’
print ‘Reason: ‘, str(e.reason) + ” address: ” + web
time.sleep(4)
isError=True
return True
else:
CurrentIP = dict(map(lambda i: (i,1),ip)).keys()
isError=False
if len(IParray)<1:
IParray =CurrentIP
#print “New IP”
isNewIP=True
else:
tmp = set(IParray) & set (CurrentIP)
if len(tmp)>0:
#print “IP this same”
isNewIP=False
else:
#print “New IP”
isNewIP=True
def sendIpToEmail():
global IParray
global sendError
FROMADDR = “mymail@o2.pl”
LOGIN = “haslo_maslo”
PASSWORD = “password”
TOADDRS = [“destEmail@test.pl”]
SUBJECT = “IP was changed”
mText=”My new IP address is one of this: “
strIPs=”“
for i in IParray:
strIPs+=i
strIPs+=”, “
msg = (“From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n”
% (FROMADDR, “, “.join(TOADDRS), SUBJECT) )
msg += mText+strIPs+”\r\n”
try:
server = smtplib.SMTP(‘poczta.o2.pl’, 587)
server.set_debuglevel(1)
#server.ehlo() #FOR GMAIL
#server.starttls() #FOR GMAIL
server.login(LOGIN, PASSWORD)
server.sendmail(FROMADDR, TOADDRS, msg)
server.quit()
sendError=False
except Exception, e:
sendError=True
print ‘Something bad happened when try send email.’
print ‘MSG: ‘, str(e)
return True
””” RUN CODE “”“
while 1:
time.sleep(sleepTime)
getIpFromWeb()
if isNewIP== True and isError == False:
sendIpToEmail()
[Centos 6 x64] Install NVidia GeForce 210 drivers on linux
1. Download Driver from NVidia web
2. Set inittab to level 3
vi /etc/inittab
3. Remove nouveau driver
yum remove xorg-x11-drv-nouveau
and reboot OS.
4. Add nouveau to blocklist on boot
vi /boot/grub/menu.lst and add rdblacklist=nouveau on line with kernel params
5. Set chmod +x to downloaded driver and install
chmod +x NVIDIA-Linux-x86_64-285.05.09.run &&./ NVIDIA-Linux-x86_64-285.05.09.run