вторник, 24 мая 2011 г.

bamf problem with gcc 4.6

by default in gcc 4.6 -Werror=unused-but-set-variable

and the build error appeared


bamf-view.c In the function ‘bamf_view_set_property’:
bamf-view.c:543:13: error: variable self is definet but not used



workaround for  archlinux
open  pkgbuild.sh
and add following string  before configure
sed -i 's/CFLAGS="$CFLAGS -Wall -Werror -lm"/CFLAGS="$CFLAGS -Wall -lm"/' configure



понедельник, 16 мая 2011 г.

using ssh-agent

ssh-agent очень удобная штука когда надо работать с ssh  на куче машин, особенно если ваши приватные ключи закрыты паролем.

запускается просто на локальной машине
ssh-agent
на выводе будет что-то  типа
SSH_AUTH_SOCK=/tmp/ssh-aKKXoDyN1761/agent.1761; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1762; export SSH_AGENT_PID;


копируем все это в  .profile или в любой ваш подгружаемый при логине сценарий

далее добавляем ключи

ssh-add  ~/.ssh/id_dsa
вводим пароль на ключ

и все можно передвигаться между серверами не набирая каждый раз пароль на ключ

некоторые примечания что бы "магия" работала:



в файле /etc/ssh/ssh_config
должна быть опция
ForwardAgent yes

на промежуточных серверах используемых как точки доступа, должны быть приватные  ключи  для переходов дальше.



среда, 20 апреля 2011 г.

command line hints

one line magic ;)

loop command

while true; do sleep 3 ; ls -Flh|grep -v total;  done

make a lot of files with random input

while true; do    dd if=/dev/urandom of=tmp.$RANDOM.txt  count=200;  done



check md5
MD5=`md5 -q blabla ` && if [ $MD5 = 66f1a2dc15218b64023fc566fe51f39a ];  then;  echo ok ; else; echo false; fi

check open port
echo -n "GET / HTTP/1.0\r\n\r\n" | nc localhost 80 
or
echo -n "\r\n" | nc  localhost 80 > /dev/null  && echo ok || echo false

воскресенье, 20 февраля 2011 г.

суббота, 12 февраля 2011 г.

some awk magic

по мотивам http://bashshell.net/stream-filtering-utilities/exercise-1-learning-awk-basics/

записать вывод  в файл

ps aux > processes

вывести весь файл
awk ‘{ print }’ processes

вывести первый столбец
awk ‘{ print $1}’ processes


вывести столбец 3 и 5 в строках соответствующих шаблону httpd
awk ‘/httpd/  {print $3,$5}’ processes


найти строки где в 11  столбце слова(в нашем случае процессы) начинаются с "s" или "с"
awk ‘$11 ~ /^[sc]/’  processes


пример:

root     13880  0.0  0.2   1816   612 ?        Ss   Feb08   0:00 syslogd -m 0
root     13977  0.0  0.6   9300  1680 ?        Ss   Feb08   0:00 sendmail: accepting connections
root     14031  0.0  0.4   4492  1104 ?        Ss   Feb08   0:00 crond
root     15857  0.0  1.1  10032  2900 ?        Ss   12:02   0:00 sshd: 




вторник, 25 января 2011 г.

autoconf error

при сборке пакетов php5-extension вылезла ошибка

autoconf: required version 2.68 not found

далее список пакетов на обновление что бы она исчезла


libtool
libltdl
autoconf
automake
automake-wrapper
autoconfig-wrapper


воскресенье, 23 января 2011 г.

mysql hints


проблема:
mysqldump: Got error: 23: Out of resources when opening file './bigtest/table_4543646.MYD' (Errcode: 24) when using LOCK TABLES

решение:
mysqldump --single-transaction

проблема репликации:
Slave SQL: Error 'Duplicate entry '11902' for key 'PRIMARY'' on query. Default database: 'bigtest'. Query: 'INSERT INTO table_1000061 set num=592121', Error_code: 1062

решение:
пока из решений только валить таблицу и заливать заново.

----

заливка данных из binary log
mysqlbinlog hostname-bin.001 | mysql news_database 
данные из базы test
mysqlbinlog --database=test   hostname-bin.001 | mysql news_database


----
repair всех таблиц
mysqlcheck -r dbname -uuser -ppass

----
MyISAM repair
myisamchk --silent --force --fast --update-state /var/db/mysql/dbname/*.MYI
 
----
MyISAM "is not a MyISAM-table"  error
REPAIR TABLE tablename  USE_FRM

понедельник, 17 января 2011 г.

git tips

git push

error message
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.


solution:
git config --bool core.bare true

среда, 1 декабря 2010 г.

work with initrd linux

# open directory tree
zcat /tmp/initrd.img | cpio -i --no-absolute-filenames

# compress initrd
find . | cpio -o -c | gzip -9 > /boot/initrd-kernel_version.img

воскресенье, 7 ноября 2010 г.

пятница, 5 ноября 2010 г.

mysql repair and optimize

 mysqlcheck

-A - Check all Mysql databases
-r - Repair all Mysql databases
-o - Optimize all Mysql databases


mysqlcheck -Arp   repair all databases
mysqlcheck -Arop  repair and optimize

среда, 13 октября 2010 г.

enable debug symbols in libc

в freebsd release не включен debug в libc , из-за чего нет возможности эффективно использовать gdb


cd /usr/src/lib/libc
make cleandir obj
make DEBUG_FLAGS=-g && make install

понедельник, 4 октября 2010 г.

php 5.3.3 freebsd 8.1 build error

error while build
main/spprintf.c:186 static declaration of 'strnlen' follows non-static declaration  freebsd
/usr/include/string.h:105: error: previous declaration of 'strnlen' was here

go to the line 186 in main/spprintf.c

find  this block of code and comment it
static size_t strnlen(const char *s, size_t maxlen) {
  char *r = memchr(s, '\0', maxlen);
  return r ? r-s : maxlen;
}

четверг, 30 сентября 2010 г.

mpd5 l2tp config

l2tp2:

        set ippool add pool1 192.168.88.11 192.168.88.100
        create bundle template BL
        set iface enable proxy-arp
        set iface idle 1800
        set iface enable tcpmssfix
        set ipcp yes vjcomp
# Specify IP address pool for dynamic assigment.
        set ipcp ranges 192.168.88.10/24 ippool pool1
        set ipcp dns local_dns_ip
# The five lines below enable Microsoft Point-to-Point encryption
# (MPPE) using the ng_mppc(8) netgraph node type.
        set bundle enable compression
        set ccp yes mppc
        set mppc yes e40
        set mppc yes e128
        set mppc yes stateless
# Create clonable link template named L
        create link template L2 l2tp
# Set bundle template to use
        set link action bundle BL
# Multilink adds some overhead, but gives full 1500 MTU.
        set link enable multilink
        set link yes acfcomp protocomp
        set link no pap chap
        set link enable chap
        set link keep-alive 10 60
        set link mtu 1460
# Configure l2tp
# IP адресс нашего VPN сервера. (Собственно адресс машины с фряхой)
        set l2tp self your_real_ip
# Allow to accept calls
        set link enable incoming


if you don`t want use certificate in windows systems open regedit
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RasMan\Parameters
add key
ProhibitIpSec DWORD 1

вторник, 28 сентября 2010 г.

mysql sphinx install

download http://sphinxsearch.com/downloads.html



cp -R /root/builds/sphinx-0.9.7/mysqlse /root/builds/mysql-5.1.14/storage/sphinx
 
sh BUILD/autorun.sh
 
./configure --with-plugins=sphinx
 
make
make install

четверг, 19 августа 2010 г.

thunderbird tips

disable storing read messages  on the local disk

Edit->Account Settings->Synchronization  & Storage

turn off checkbox  "Keep messages for this account on this computer"

среда, 4 августа 2010 г.

pptp mpd5 config

part of pptp mpd5 config suitable for ipad vpn client working thru GSM providers

pptp:
    create bundle template B
    set iface enable proxy-arp
    set iface idle 1800
    set iface enable tcpmssfix
    set ipcp yes vjcomp

    set ippool add poolsat 192.168.0.2 192.168.0.100
    set ipcp ranges 192.168.0.1/32 ippool pool1
    set ipcp dns DNSIP_IFEXIST
    set bundle enable compression
    set ccp yes mppc
    set mppc yes e40
    set mppc yes e128
    set mppc yes stateless

    create link template L pptp
    set link action bundle B

    set link enable multilink
    set link yes acfcomp protocomp

    set link no pap chap
    set link enable chap
    set link enable chap-msv1
    set link enable chap-msv2

    set link keep-alive 10 60
    set link mtu 1460
    set pptp self REALVPN_IP
    set link enable incoming

четверг, 22 июля 2010 г.

pcre regex

Positive Integers --- ^\d+$
Negative Integers --- ^-\d+$
Integer --- ^-{0,1}\d+$
Positive Number --- ^\d*\.{0,1}\d+$
Negative Number --- ^-\d*\.{0,1}\d+$
Positive Number or Negative Number - ^-{0,1}\d*\.{0,1}\d+$
Phone number --- ^\+?[\d\s]{3,}$
Phone with code --- ^\+?[\d\s]+\(?[\d\s]{10,}$
Year 1900-2099 --- ^(19|20)[\d]{2,2}$
Date (dd mm yyyy, d/m/yyyy, etc.) --- ^([1-9]|0[1-9]|[12][0-9]|3[01])\D([1-9]|0[1-9]|1[012])\D(19[0-9][0-9]|20[0-9][0-9])$
IP v4 --- ^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]){3}$

Personal Name --- ^[\w\.\']{2,}([\s][\w\.\']{2,})+$
Username --- ^[\w\d\_\.]{4,}$
Password at least 6 symbols --- ^.{6,}$
Password or empty input --- ^.{6,}$|^$
email --- ^[\_]*([a-z0-9]+(\.|\_*)?)+@([a-z][a-z0-9\-]+(\.|\-*\.))+[a-z]{2,6}$
domain --- ^([a-z][a-z0-9\-]+(\.|\-*\.))+[a-z]{2,6}$

Match no input --- ^$
Match blank input --- ^\s[\t]*$
Match New line --- [\r\n]|$

пятница, 2 июля 2010 г.

среда, 26 мая 2010 г.

openssl crypt and decrypt files

создать шифрованный tar архив
tar -czf - /dir | openssl enc des3  -salt -k KEY  > file.tar.gz.des3
расшифровать
cat file.tar.gz.des3 | openssl enc -des3  -d  -salt -k KEY  | tar -xvzf -

зашифровать полный dump mysql
mysqldump -A -pPASS |  gzip -c | openssl des3  -d  -salt -k KEY > file.sql.gz.des3
расшифровать

cat file.sql.gz.des3 | openssl des3  -d  -salt -k KEY  | gunzip  > file.sql

вторник, 18 мая 2010 г.