var hasClass = function(element,className) {
return (function() {
var classes = element.className.split(' ');
for(var i in classes) {
if(classes[i] == className) {
return true;
}
}
return false;
})();
}
Monday, March 8, 2010
Check class
Tuesday, March 2, 2010
CSS attribute selectors
[rel=value] — attribute equals to value
<h1 rel="value">Attribute Equals</h1>
h1[rel=value] { color: red; }
[rel*=value] — attribute contains value anywhere
<h1 rel="xxxvaluexxx">Attribute Contains</h1>
h1[rel*=value] { color: red; }
[rel^=value] — attribute starts with value
<h1 rel="value-link yep">Attribute Begins</h1>
h1[rel^=value] { color: red; }
[rel$=value] — attribute ends with value
<h1 rel="friend value">Attribute Ends</h1>
h1[rel$=value] { color: red; }
[rel~=value] — attribute contains value in space-delimited list
<h1 rel="friend value sandwich">Attribute Space Separated</h1>
h1[rel~=value] { color: red; }
[rel|=value] — attribute contains value in dash-delimited list
<h1 rel="friend-value-sandwich">Attribute Dash Separated</h1>
h1[rel|=value] { color: red; }
Table checkboxes selection
(function() {
// checkboxes in the table
var cbs = document.getElementsByName('checkboxes');
// header checkbox
var all = document.getElementById('header_checkbox');
all.onclick = function() {
for(var i=0;i<cbs.length;i++) {
cbs[i].checked = this.checked;
}
}
var cbClick = function() {
all.checked = (function() {
for(var i=0;i<cbs.length;i++) {
if(cbs[i].checked != true) {
return false;
}
}
return true;
})();
}
for(var i=0;i<cbs.length;i++) {
cbs[i].addEventListener('click', cbClick, true);
}
})();
Monday, February 22, 2010
Universal archive unpacking tool
### Handy Extract Program
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
Поместить в ~/.bashrc или profileoriginal
Thursday, February 4, 2010
Setting up a network adapter alias
sudo ifconfig eth0:[0-254] 192.168.1.2 up.Instead of
eth0 you can use any of existing interfaces
Wednesday, January 27, 2010
Firefox extension. Thoughts.
- You want to append event handler to created by you DOM-element somewhere in '1body' descendants. Don't try to use onclick or like it - you'll get a fail. Use addEventHandler method, and you'll get success :)
Tuesday, January 26, 2010
Django model field inheritance
Firefox extension. The first tries
- To create a developer profile may that
firefox -profilemanager
- To run another -- development -- copy of Firefox
firefox -no-remote -P <profile name>
Monday, December 28, 2009
Django and Oracle support
To get work Django and Oracle client in Ubuntu:
Download cx_Oracle (choose for your system), Oracle InstantClient and Sql*Plus (in this page you can choose your OS and download the packages (in my case are oracle-instantclient11.2-basic-11.2.0.0.2-1.x86_64.rpm and oracle-instantclient11.2-sqlplus-11.2.0.0.2-1.x86_64.rpm).
Move the files into one directory for simplicity and run
alien -k *.rpm dpkg -i *.debto convert all the downloaded packages to ubuntu deb-format and install them.
Then make symlink to lib, otherwise module won't be found by Django
cd /usr/lib/python2.6 ln -s site-packages/cx_Oracle.so
To avoid
Traceback (most recent call last): File "add to ~/.bashrc (or /etc/bash.bashrc to system-wide apply)", line 1, in ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/11.2/client64/libIf you see the message
Traceback (most recent call last): File "run", line 1, in ImportError: libaio.so.1: cannot open shared object file: No such file or directory
sudo apt-get install -y libaio1
P.S. If you choose more modern (or older) version of Oracle IntstantClient you have to create symlinks for necessary version, e.g. you see the following error:
Traceback (most recent call last): File "but in /usr/lib/oracle/11.2/client64/lib directory exists libclntsh.so.11.1. Just make it symbolic link with", line 1, in ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory
ln -s libclntsh.so.11.1 libclntsh.so.10.1
Install RPM in Ubuntu
- install alien package:
sudo apt-get install alien
- Convert Rpm to Deb (in current directory)
alient -k <package-file>.rpm
- Install the new Deb package
dpkg -i <package-file>.deb
Problems with VPN-connections in Ubuntu Karmic
NetworkManager: nm-vpn-connection.c.828: NeedSecrets failed: dbus-glib-error-quark Rejected se nd message, 1 matched rules; type="method_call", sender=":1.5" (uid=0 pid=969 comm="NetworkManager) interface="org.freedeskt op.NetworkManager.VPN.Plugin" member="NeedSecrets" error name="(unset)" requested_reply=0 destination="org.freedesktop.Netwo rkManager.vpnc" (uid=0 pid=7971 comm="/usr/lib/network-manager-vpnc/nm-vpnc-service))Some googling gives me a bit of information - Keyring manager denied connection of the VPN service. And how to grand access I didn't know. Googling more brings me the answer:
In /etc/dbus-1/system.d/nm-vpnc-service.conf
--- nm-vpnc-service.conf.fixed 2009-04-18 17:56:45.000000000 -0500 +++ nm-vpnc-service.conf 2009-04-18 17:57:37.000000000 -0500 @@ -6,6 +6,10 @@ <allow own="org.freedesktop.NetworkManager.vpnc"/> <allow send_destination="org.freedesktop.NetworkManager.vpnc"/> </policy> + <policy user="at_console"> + <allow own="org.freedesktop.NetworkManager.vpnc"/> + <allow send_destination="org.freedesktop.NetworkManager.vpnc"/> + </policy> <policy context="default"> <deny own="org.freedesktop.NetworkManager.vpnc"/> <deny send_destination="org.freedesktop.NetworkManager.vpnc"/>
Thursday, December 24, 2009
Ubuntu's Archive Manager and RAR-archives support
sudo apt-get install unrar
Wednesday, December 16, 2009
Disabled Mercurial's strip command
[extensions]
hgext.mq =