while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done &
понедельник, 9 декабря 2013 г.
Clock in console
вторник, 22 октября 2013 г.
Virtual Box Console commands
As something of a follow-up post to the previous entry, here’s a quick recipe for creating a Virtual Machine using the VirtualBox command line tools:
We’re using Windows Server 2008 64bit as an example, modify to taste.
$ VM='Windows-2008-64bit'
Create a 32GB “dynamic” disk.
$ VBoxManage createhd --filename $VM.vdi --size 32768
You can get a list of the OS types VirtualBox recognises using:
$ VBoxManage list ostypes
Then copy the most appropriate one into here.
$ VBoxManage createvm --name $VM --ostype "Windows2008_64" --register
Add a SATA controller with the dynamic disk attached.
$ VBoxManage storagectl $VM --name "SATA Controller" --add sata \
> --controller IntelAHCI
$ VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 \
> --device 0 --type hdd --medium $VM.vdi
Add an IDE controller with a DVD drive attached, and the install ISO inserted into the drive:
$ VBoxManage storagectl $VM --name "IDE Controller" --add ide
$ VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 \
> --device 0 --type dvddrive --medium /path/to/windows_server_2008.iso
Misc system settings.
$ VBoxManage modifyvm $VM --ioapic on
$ VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none
$ VBoxManage modifyvm $VM --memory 1024 --vram 128
$ VBoxManage modifyvm $VM --nic1 bridged --bridgeadapter1 e1000g0
Configuration is all done, boot it up! If you’ve done this one a remote machine, you can RDP to the console via vboxhost:3389.
$ VBoxHeadless -s $VM
Once you have configured the operating system, you can shutdown and eject the DVD.
$ VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 \
> --device 0 --type dvddrive --medium none
Finally, it’s a good idea to take regular snapshots so that you can always revert back to a known-good state rather than having to completely re-install.
$ VBoxManage snapshot $VM take <name of snapshot>
And, if you need to revert back to a particular snapshot:
$ VBoxManage snapshot $VM restore <name of snapshot>
Enjoy!
Readline shortcuts
Readline shortcuts
GNU Readline is the library used to make advanced command-line wizardry convenient and conistent across a multitude of command-line applications. These programs include bash, bc, ftp, gnuplot, gpg, ksh, mysql, psql, python, smbclient, xmllint and zsh.The cheatsheet at the right contains a summary of many of the useful line editing command shortcuts which are available in all applications that use libreadline.
See the documentation on the Readline website for even more shortcuts with more elaborate descriptions.
| Emacs keys | Action | Scope | Direction/Place | |
|---|---|---|---|---|
| Moving around | Ctrl-b | Move the cursor | one character | ⇦ to the left |
| Ctrl-f | Move the cursor | one character | ⇨ to the right | |
| Alt-b | Move the cursor | one word | ⇦ to the left | |
| Alt-f | Move the cursor | one word | ⇨ to the right | |
| Ctrl-a | Move the cursor | ⇤ to the start of the line | ||
| Ctrl-e | Move the cursor | ⇥ to the end of the line | ||
| Ctrl-x-x[1] | Move the cursor | ⇤⇥ to the start, and to the end again | ||
| Cut, copy and paste |
Backspace | Delete | the character | ⇦ to the left of the cursor |
| DEL Ctrl-d |
Delete | the character | underneath the cursor | |
| Ctrl-u | Delete | everything | ⇤ from the cursor back to the line start | |
| Ctrl-k | Delete | everything | ⇥ from the cursor to the end of the line | |
| Alt-d | Delete | word | ⇨ untill before the next word boundary | |
| Ctrl-w | Delete | word | ⇦ untill after the previous word boundary | |
| Ctrl-y | Yank/Paste | prev. killed text | at the cursor position | |
| Alt-y | Yank/Paste | prev. prev. killed text | at the cursor position | |
| History | Ctrl-p | Move in history | one line | ⇧ before this line |
| Ctrl-n | Move in history | one line | ⇩ after this line | |
| Alt-> | Move in history | all the lines | ⇩ to the line currently being entered | |
| Ctrl-r | Incrementally search the line history | ⇧ backwardly | ||
| Ctrl-s[2] | Incrementally search the line history | ⇩ forwardly | ||
| Ctrl-J | End an incremental search | |||
| Ctrl-G | Abort an incremental search and restore the original line | |||
| Alt-Ctrl-y | Yank/Paste | arg. 1 of prev. cmnd | at the cursor position | |
| Alt-. Alt-_ |
Yank/Paste | last arg of prev. cmnd | at the cursor position | |
| Undo | Ctrl-_ Ctrl-x Ctrl-u |
Undo the last editing command; you can undo all the way back to an empty line | ||
| Alt-r | Undo all changes made to this line | |||
| Ctrl-l | Clear the screen, reprinting the current line at the top | |||
| Ctrl-l | Clear the screen, reprinting the current line at the top | |||
| Completion | TAB | Auto-complete a name | ||
| Alt-/[3] | Auto-complete a name (without smart completion) | |||
| Alt-? | List the possible completions of the preceeding text | |||
| Alt-* | Insert all possible completions of the preceeding text | |||
| Transpose | Ctrl-t | Transpose/drag | char. before the cursor | ↷ over the character at the cursor |
| Alt-t | Transpose/drag | word before the cursor | ↷ over the word at/after the cursor | |
вторник, 8 октября 2013 г.
Installing b43 wireless on ubuntu
http://downloads.openwrt.org/sources/wl_apsta-3.130.20.0.o
and
http://mirror2.openwrt.org/sources/broadcom-wl-4.150.10.5.tar.bz2
Copy them into your installation flashdrive
Install b43-fwcutter from /cdrom/pool/main/b/ there will be .deb package
Than:
tar -xjvf broadcom-wl-4.150.10.5.tar.bz2
sudo b43-fwcutter -w /lib/firmware wl_apsta-3.130.20.0.o
sudo b43-fwcutter --unsupported -w /lib/firmware broadcom-wl-4.150.10.5/driver/wl_apsta/wl_prebuilt.o
sudo chmod 775 /lib/firmware/b43
sudo chmod 775 /lib/firmware/b43legacy
sudo modprobe -r b43
sudo modprobe b43
Thats it :) Works on Ubuntu 13.04
пятница, 4 октября 2013 г.
Sphinx on Gentoo
emerge --sync
emerge portage
# Установить sphinx
USE="debug id64 mysql -postgres stemmer test" emerge app-misc/sphinx
# Скопировать или переименовать конфигурационный файл
cd /etc/sphinx
cp sphinx.conf.dist sphinx.conf
# Настроить разрешения, чтоб группа web могла редактировать конфигурационный файл
chmod 664 /etc/sphinx/*
chown root:web /etc/sphinx/*
# Добавить пользователя и группу sphinx
groupadd -g 494 sphinx
useradd -g sphinx -u 494 -d /var/lib/sphinx -s /bin/bash -c "Sphinx server" sphinx
# Создать папки, где будут храниться логи, pid-файлы и данные
mkdir -p /var/log/sphinx
mkdir -p /var/run/sphinx
mkdir -p /var/lib/sphinx/data
# Настроить правильные разрешения на эти папки
chown sphinx:sphinx /var/log/sphinx
chown -R sphinx:sphinx /var/lib/sphinx
chown sphinx:sphinx /var/run/sphinx
# Добавить в /etc/sudoers что-то типа
%web ALL=NOPASSWD:/etc/init.d/searchd
%web ALL=(sphinx) NOPASSWD:/usr/bin/indexer
# Проверить от пользователя группы web
sudo -u sphinx /usr/bin/indexer
sudo /etc/init.d/searchd restart|stop|start
# Установить расширения php
PHP_TARGETS="php5-4" emerge pecl-sphinx
Так же пришлось немного подправить init скрипт, чтобы запускать свинкс от моего пользователя
среда, 2 октября 2013 г.
AntHillPro: Create, manage and delete environments via BeanShell scripts
Creating new entity (project, environment etc)
- <your_new_entity> = new <Something>;
- <you_new_entity>.store();
- Finish step.
Adding into Environment Group
- Get environment group: EnvironmentGroup envGroup = EnvironmentGroupFactory.getInstance().restore( envGroupID );
- envGroup.addServerGroup( env ) , where env should be instance of ServerGroup
Adding into project's workflows.
- Get project: Project prj = ProjectFactory.getInstance().restore( projectID );
- Get non-originating workflow like Workflow wf = prj.getWorkflow( nonOrigWFID ) or get an array of workflows Workflow[] wfArray = prj.getNonOriginatingWorkflowArray() and iterate over it.
- Add environment into it: wf.addServerGroup( env ) , where env should be instance of ServerGroup
Deleting environment
First step:
- Get environment: ServerGroup env = ServerGroupFactory.getInstance().restoreForName( "my-env-name" );
- Get environment's group: EnvironmentGroup[] envGroupArray = EnvironmentGroupFactory.getInstance().restoreAllForEnvironment( env );
- Workflow[] wfInEnvArray = WorkflowFactory.getInstance().restoreAllNonOriginatingWorkflowsForEnvGroupsInEnvironment( env, envGroupArray, "*", "*", "*" );
Second step:
We have environment group which this environment belongs to, so just remove: envGroup.removeServerGroup( env );
Third step:
вторник, 1 октября 2013 г.
NGINX + FastCGI Perl on Gentoo
NGINX_MODULES_HTTP="access auth_basic autoindex charset fastcgi gzip gzip_static limit_req map proxy rewrite scgi ssi stub_status"
NGINX_MODULES_MAIL=""
Emerging nginx
emerge -av nginx www-misc/fcgiwrap www-servers/spawn-fcgi
www-misc/fcgiwrap, a FastCGI server for wrapping CGI scriptswww-servers/spawn-fcgi, a FastCGI manager for spawningfcgiwrap.
/etc/nginx/mime.types. I added:types {
…
application/x-python py;
application/x-shell sh;
…
}
Configure spawn-fcgi to launch fcgiwrap with:# cp /etc/conf.d/spawn-fcgi /etc/conf.d/spawn-fcgi.fcgiwrap
# emacs /etc/conf.d/spawn-fcgi.fcgiwrap
# cat /etc/conf.d/spawn-fcgi.fcgiwrap
FCGI_SOCKET=/var/run/fcgiwrap.sock
FCGI_ADDRESS=
FCGI_PORT=
FCGI_PROGRAM=/usr/sbin/fcgiwrap
FCGI_USER=nginx
FCGI_GROUP=nginx
FCGI_EXTRA_OPTIONS="-M 0700"
ALLOWED_ENV="PATH HOME"
HOME=/
FCGI_CHILDREN=1
FCGI_CHROOT=
# cd /etc/init.d/
# ln -s spawn-fcgi spawn-fcgi.fcgiwrap
Start fcgiwrap with:# /etc/init.d/spawn-fcgi.fcgiwrap start
Add it to the default runlevel with:# rc-update add spawn-fcgi.fcgiwrap default
NGINX configuration:
server {
...
location / {
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.sock-1;
}
...
}
Should work now!