Search This Blog

Monday, March 28, 2011

Flex force DataGrid refresh from source; Flex refresh datagrid after update

The problem is that DataGrid is bound to the ArrayList and in most cases this ArrayList is stored locally, so just calling  invalidateList() on DataGrid is not enough. I had my DataGrid bound to a MySQL data table and that’s how I succeeded:

 

FlexGlobals.topLevelApplication.getRunningTestsResult.token = FlexGlobals.topLevelApplication.testService.getRunningTests();
                       
//dataGrid.invalidateDisplayList();
dataGrid.invalidateList();

 

getRunningTestsResult() is my function in bounded service in PHP that downloads running tests. I had to “update” the array (i.e. fill it with data once more). Then I used invalidateList() that moved data from the Array to DataGrid.

You can you a [Bindable] Array to make changes “in real time”. So this is a half-solution.

Note:

I used FlexGlobals.topLevelApplication just because I updated DataGrid from ItemRunderer. If you do this locally there is no need to use global vars.

Flex access dataGrid from ItemRenderer

If you have a buttonClickCall in your DataGrid and you want to access the whole DataGrid from your ItemRenderer call do the following:

add imports:

import mx.controls.DataGrid;
import mx.core.Application;
import mx.core.FlexGlobals;

access DataGrid in the following way:

var dataProvider = FlexGlobals.topLevelApplication.dataGrid.dataProvider;
var dataProvider = Application.application.dataGrid.dataProvider;

 

It will work despite the fact that these DataGrid variable is defined in a different mxml file.

ItemRenderer – ItemRendererXXX.mxml
Application – Name_Of_Your_App.mxml

 

You can that access all items in the following way:

for (var i:int = 0; i < dataProvider.length; i++)
{
    item = dataProvider.getItemAt(i);
    daneService.updateDane(item);
}

Thursday, March 24, 2011

SQLite GUI; SQLite executing commands

I’ve found a nice GUI for SQLite. It’s from ‘tksqlite’ project located here. You can download a working version here.

From console (sqlite3.exe) you can do the following:

.read FILENAME – execute a file with sql commands;
.quit
.databases – list databases
.tables – list tables
.headers ON – display table headers while executing (SELECT * …)
.schema – display database schema

Remember to open sqlite3.exe with a database argument:

sqlite3.exe database.db

Thursday, March 17, 2011

Ubuntu 10.10 using GRUB 2.0 command prompt; Reconfigure GRUB after changing hard drive

When you see the grub splash boot menu press ‘c’ or ‘control-c’ to enter command prompt.

To successfully boot the system when something fails do the following:

grub> root
(to see what partition is to be booted)

grub> set root=(hd0,0)
(to set the root partition)

grub> kernel /vmlinuz root=/dev/sda1 ro Single
(or whatever other options you’d like at the end – these are passed as arguments to the kernel)
(you can use ‘linux’ command alternatively if there is no kernel command)

grub> initrd /initrd.img

grub> boot

 

Reconfigure GRUB after changing hard drive:

GRUB 2.0 config files are kept in: /etc/grub.d/

00_header        05_debian_theme  10_linux         20_linux_xen     20_memtest86+    30_os-prober     40_custom        41_custom        README

and in /etc/default/grub

?> update-grub
(generates grub.cfg from the above files) and updates UUIDs

?> grub-install /dev/sda1

 

Reconfigure GRUB 1.0 after changing hard drive:

run grub (usually in /boot/grub)

grub> root(hd0,0)

grub> setup(hd0)
(generates config from menu.lst)

Ubuntu check UUID of the installed hard drives

To check what UUID your drives have type:

?> blkid

This is helpful while configuring GRUB & LILO.

Allow remote access to apache on WAMP server on Windows; allow remote access to MySQL on WAMP server on Windows;

 

To allow remote access to apache on Windows change the file: c:\wamp\bin\apache\Apache2.2.17\conf\httpd.conf

You need to allow remote access to directory C:\wamp\www like this:

<Directory "c:/wamp/www/">
    ExecCGI MultiViews
    Options Indexes FollowSymLinks
    AllowOverride all

    Order allow,deny
    Allow from all

</Directory>

 

To grant remote access to MySQL:

use mysql;

GRANT ALL PRIVILEGES ON *.* to root@'%' IDENTIFIED BY 'sys';

flush privileges;

 

To see what is already allowed do this:

use mysql;

select user,host from user;

+------+-----------+
| user | host      |
+------+-----------+
| root |           |
| root | %         |
|        | localhost |
| root | localhost |
+------+-----------+
4 rows in set (0.00 sec)

“empty” places are nulls here. ‘%’ means from any host.

Wednesday, March 16, 2011

Export installed packages and import them on another machine

If you don’t have any specific settings and you just want to “copy” your linux working environment like running services and so on you can install a machine with identical packages installed by exporting the list of packages and importing it on another machine.

Backup installed package list on current machine
dpkg --get-selections > selections.txt

On new machine install packages like this:
dpkg --set-selections < selections.txt
apt-get update
apt-get upgrade

 

To see what packages are installed on the system, fire up:

aptitude search '~i'
 
 

Change partition label in Ubuntu

To change partition label on various file systems use:

FAT16/32

mlabel -i /dev/sdb1 ::my_external
NTFS
ntfslabel /dev/sdb1 my_external
EXT3/4
e2label /dev/sdb1 my_external
BTRFS
For BTRFS you can set label while creating the partition with:
mkfs.btrfs –-label LABEL_LABEL
mkfs.btrfs –L LABEL_LABEL
 

Make PATH variable permanent on SSH login attempt/ Make PATH variable permanent on Ubuntu Linux

 

If you just want to have PATH variable available on a simple SSH login add the following like to your .profile:
export PATH=$PATH:/usr/local/lib/jdk1.6.0_24/bin

If you want to have PATH variable to be available after “su” login  change ENV_SUPATH & ENV_PATH
in file: /etc/login.defs

add this line:
export PATH=$PATH:/usr/local/lib/jdk1.6.0_24/bin
to all your users .bashrc files

You can always make symbolic links to /usr/local/bin.

Go to: /usr/local/bin
Execute: ln -s /usr/local/lib/jdk1.6.0_24/bin/* .
(don’t forget the dot at the end)

Monday, March 14, 2011

Windows 7 debug windows kernel; get information from Windows 7 *.dmp file; Dumpchk.exe; WinDbg.exe

 

When you experience a BOD (Blue Screen of Death) you’ll most likely get a memory dump from Windows from the time of the crush.

There are three things we want to do:

  • check the consistency of the dump
  • analyze the dump
  • check what program/driver is causing BOD

 

Debugging Tools for Windows

http://msdn.microsoft.com/en-us/windows/hardware/gg463009.aspx

Windows XP Service Pack 2 Support Tools
(contains Dumpchk.exe and WinDbg)

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=49ae8576-9bb9-4126-9761-ba8011fabf38&displaylang=en

Dumpchk.exe –> Dumpchk.exe displays some basic information from the memory dump file, then verifies all the virtual and physical addresses in the file

WinDbg.exe –> gathers information from a dump file

image

Look for *.sys file in the report that is causing BOD!

Instructions from ehow on how to use WinDbg.exe:

Instructions

  1. Go to the Microsoft website to download and install the Windows Debugging Tool (see Resources). Choose the correct version of the tool: 32- or 64-bit.

  2. Click "Start" and choose "All Programs".

  3. Locate the "Debugging Tools for Windows" folder.

  4. Double-click the "WinDBG" icon to launch the debugging tool.

  5. Click "File" and choose "Symbol File Path". A window with a text box will open.

  6. Type "SRV*c:\symbols*http://msdl.microsoft.com/download/symbols" in the text box and press the "OK" button.

  7. Close the WinDBG tool and click "Yes" when the tool prompts you to save the workspace.

  8. Launch the WinDBG tool from the "Start" menu again. It should now be ready to debug your memory dump.

  9. Click "File" and choose "Open Crash Dump" from the drop-down menu.

  10. Browse to find the folder where your memory dump file is saved, click on it and press the "Open" button. Memory dumps are saved in the "C:\WINDOWS\" folder by default.

  11. Click the "! analyze -v" link under "Bugcheck Analysis".

  12. Allow the debugger to analyze the memory dump. It will gather information from the memory dump and provide troubleshooting feedback on the screen.


Read more: How to Gather Information After a Memory Dump in Windows XP | eHow.com http://www.ehow.com/how_7238421_gather-memory-dump-windows-xp.html#ixzz1GZhkmmBZ

Friday, March 11, 2011

Export data from Firebird into pure SQL inserts/ export data from Firebird to MySQL

When you need to export data from firebird into mySQL the easiest way is to use fbexport program. It’s manual is located here:

http://fbexport.sourceforge.net/manual.html


$> FBExport.exe -D "c:\DB\WL.FDB" -U user –P password -Si -V TEST -F test.out

Where:
Si – means “export to SQL inserts” format
V – table name to export
F – output filename

Be careful with dates in mysql. Export in the correct format. To export db in custom date format use:

$> FBExport.exe -D "c:\DB\WL.FDB" -U user –P password -Si -V TEST -F test.out -J "Y-M-D" -K "H:M:S"

Where:
J  - date format
K – time format

 

To import date to mySQL use SOURCE command:

$> mysql --user=root --password=password

$> use  database_name

$> SOURCE  c:\export\table_name.out

 

SOURCE command imports the whole file (executes SQL statements in it)

Flex/Flashbuilder Security error accessing url; crossdomain.xml

There’re new security rules applied in Flash Builder 4. Everything works fine when you debug your application from localhost. However if you try to access your page from remote host you’ll come across an error: “Security error accessing url”. To resolve the situation you’ll have to create a file named: crossdomain.xml at the root of your domain. Sample crossdomain.xml can be found here.

That’s not all. If you want to access the site from remote hosts, just export the project from FlashBuilder! (Project->Export release build). In debug releases Flash forces browser to download crossdomain.xml from “localhost”. In release builds crossdomain.xml will be downloaded from the server.

 

<?xml version="1.0"?>
   <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
   <cross-domain-policy>
   <site-control permitted-cross-domain-policies="all"/>
   <allow-access-from domain="*" to-ports="*" />
   <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

Tuesday, March 8, 2011

Force Firefox not to use any cache while developing in Flex/Flash Builder

If you use Firefox for Flex development, you may have had problems with a SWF caching problem.  Even though a Flex compile updates the SWF file on the file system, Firefox doesn’t pull the new SWF from the server, but rather uses its internal already cached SWF file.  This can cause headaches when trying to guess why the code change doesn’t appear in the browser.  To solution has been to clear the cache in Firefox and reload the page.  I turned my browser cache size limit down to 0MB.  This doesn’t seem to fix the problem either.  There is another setting that can’t be found in the Firefox interface.

  1. Open a new tab in Firefox.
  2. Type about:config in the url.
  3. Agree to the warning.
  4. Change the property browser.cache.disk.enable and set it to false.

Thus far this solution seems to keep my SWF file from being cached by Firefox.

From:
http://www.flexpasta.com/index.php/2008/11/24/firefox-swf-cache/

Windows 7 SP1/Service Pack 1–make permanent

To make Windows 7 Service Pack 1 permanent and by implication reclaim used space/remove backup files use these commands:

Online installation (from Windows Update):

dism /online /cleanup-image /spsuperseded

Offline installation:

DISM.exe /Image:C:\test\offline /Cleanup-Image /spsuperseded /hidesp

Monday, March 7, 2011

STAF – call remote command

To call a command on a remote computer, use STAF
(http://staf.sourceforge.net/)

To restart computer remotely e.g.:

STAF 10.60.60.64 PROCESS START SHELL COMMAND "shutdown -s -t 5 -f"

Breakthrough game in Java3d

The game was developed to present Alfa-Beta algorithm.
It's goal is to reach opponent's last (nearest to him) row. Breakthrough is similar to checkers. You beat pieces crosswise (aslant) if you're near opponent's piece.
After knocking other player's piece you place your piece in the same place. You cannot beat pieces in backward "backward" direction (i.e. you cannot go back).

Authors:
Jacek Dalkowski
Bartosz Kosarzycki

Game purpose:
Get to the opponent's last row first.

Game modes:
Computer vs. Computer
Computer vs. Human
Human    vs. Human

Screenshots:

breakthrough_1

breakthrough_2

breakthrough_3_rotate_board

breakthrough_4_dark_pieces_won

breakthrough_5_game_menu


Video:

Game (Java):
http://sites.google.com/site/bkosarzyckiaboutme/BreakThroughGameJava3d.rar

To run the game you need Java3d:
http://sites.google.com/site/bkosarzyckiaboutme/java3d-1_5_1-windows-i586.7z
http://sites.google.com/site/bkosarzyckiaboutme/java3d-1_5_1-windows-amd64.7z

Java 3d developer’s docs:
http://sites.google.com/site/bkosarzyckiaboutme/j3d_tutorial_ch1.pdf

Game’s documentation/report (Polish):
http://sites.google.com/site/bkosarzyckiaboutme/BreakThrough_documentation.pdf

Friday, March 4, 2011

Starting services at boot time

During start up or when changing runlevel, scripts are run from /etc/rcX.d/ where X is the runlevel number.

To execute your script at boot:

  • Write a script.
  • Put it in the /etc/init.d/ directory.
  • $> update-rc.d SCRIPT_NAME defaults
  • $> chmod +x SCRIPT_NAME

Change main tty resolution to vga in Ubuntu Server 10.10

The problem is that standard resolution in Ubuntu Server is too high in the main tty. I t should be 640x480 (vga).

Just set in /etc/default/grub:
GRUB_GFXMODE=1024x768
GRUB_GFXPAYLOAD_LINUX=keep
But also change:
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
to
GRUB_CMDLINE_LINUX_DEFAULT="quiet nomodeset"

$> update-grub2; reboot


‘nomodeset’ was preventing it from switching to highest resolution.

When you remove ‘quiet’ it will say what it does at boot time. Well I would remove quiet as well – who doesn’t want to know what is going on?!

Thursday, March 3, 2011

Some more ubuntu tricks

  • remove users from group; edit the file:
    /etc/group
  • can’t start VNC with XServer; add pemissions to:
    /etc/X11/xinit/xinitrc
  • mount ntfs that had unclean shutdown:
    ntfsmount /dev/sdb1 /bbb –o force
  • remount root filesystem readonly:
    mount –o ro,remount –f /
  • change ubuntu server start resolution:
    add vga=786 parameter in:
    /etc/default/grub
    $>update-grub
  • exclude certain directories while tarring:
    tar -cvzpP --file=/distr/backup.tar.gz --exclude={/dev/*,/proc/*,/sys/*,/srv/*,/distr/*,/tmp/*} /

Configuring moblock on ubuntu

 

$> blockcontrol reload
(reloading IP lists)

$> blockcontrol restart

$> blockcontrol stop | start | restart | reload

FILE: /etc/blockcontrol/blockcontrol.conf – configuring ports

WHITE_TCP_OUT="0:65000"
WHITE_UDP_OUT="0:65000"
WHITE_TCP_IN="0:65000"
WHITE_UDP_IN="0:65000"
WHITE_TCP_FORWARD="0:65000"
WHITE_UDP_FORWARD="0:65000"

/etc/blockcontrol/blocklists.list  - configuring blocking lists

/etc/blockcontrol/allow.p2p – ranges to allow

e.g.
company1 IP1:212.160.159.100-212.160.159.200
company1 IP2:83.238.245.0-83.238.245.254
company1 IP3:83.238.74.0-83.238.74.254
company1 IP4:80.52.240.0-80.52.240.254
company1:150.254.28.0-150.254.31.254

Check logs in:

/var/log/moblock.log
/var/log/blockcontrol.log

 

Installation:

$> gpg --keyserver keyserver.ubuntu.com --recv 9C0042C8
$> gpg --export --armor 9C0042C8 | sudo apt-key add -
$> gksu gedit /etc/apt/sources.list
For Ubuntu 10.10 add:
deb http://ppa.launchpad.net/jre-phoenix/ppa/ubuntu maverick main
deb-src http://ppa.launchpad.net/jre-phoenix/ppa/ubuntu maverick main
$> sudo aptitude update
$> sudo aptitude install moblock blockcontrol mobloquer

Start an already detached screen

screen -d –m 'command_to_run'

update-rc.d make script start at boot

  • Write the script and place it in /etc/init.d
  • change it to executable type
    chmod 755 /etc/init.d/your_script
  • add it to runlevels:
    update-rc.d your_script defaults
  • if you ever wanted to remove the script from boot, run:
    update-rc.d -f  your_script remove
  •  

Ubuntu 10.10 & vnc4server pressing ‘D’ minimizes all windows

There's a bug in vnc4server. When you have gnome installed and you install vnc4server you'll experience it. Pressing 'D' wherever & whenever inside gnome will cause all the windows to minimize.

Change System->Preferences->Keyboard shortcuts; find the shortcut:

"Hide all normal windows and set focus to the desktop"

and change ‘D’ to something else.

Running VNC Server without XServer on Ubuntu

What we want to do is to install VNC Server (which is about 45MB) without install the whole gnome environment. Such a vnc server can be started at boot time and serve as a XFCE or Fluxbox desktop with single user.

Install basic gnome environment (or any other lightweight):

?> apt-get install gnome-core

install vnc server:

?> apt-get install vnc4server

run the server to set password:

?> vncserver -geometry 1280x1024 -depth 24 :0

kill the server:

?> vncserver -kill :0

edit ~/.vnc/xstartup file:

change x-window-manager & in the end to:

gnome-session &

start the server:

?> vncserver -geometry 1280x1024 -depth 24 :0

Configuring WebInterface for rtorrent

 

Install rtorrent:

$> aptitude install rtorrent

$> apt-get install libapache2-mod-scgi

let’s configure apache to setup a scgi socket to a local process.
# nano /etc/apache2/httpd.conf

add a line:

SCGIMount /RPC2 127.0.0.1:5000

Then do the following:

$> a2enmod scgi

$> /etc/init.d/apache2 restart

install php support:

$>  aptitude install libapache2-mod-php5


$> a2enmod php5


$> wget http://rutorrent.googlecode.com/files/rutorrent-3.2.tar.gz
(or from http://sites.google.com/site/bkosarzyckiaboutme/rutorrent-3.2.tar.gz)
Unpack these files and place in apache’s www directory.


$> aptitude install screen
$> aptitude install gcc libncurses-dev libncurses5 libsigc++-2.0-dev libsigc++-2.0-0c2a libssl-dev libssl-dev
$> aptitude install php5-xmlrpc coreutils


 

remember that you need to give rights to your rutorrent files. You can do this with chmod 666 for example.

mine rutorrent files were placed in:
/var/www/rutorrent

To use WebGUI you need to configure rtorrent and run it in background (e.g. in screen)
$> screen rtorrent

Rtorrent configuration has to be placed in home directory:
~/.rtorrent.rc


configure port settings in .rtorrent.rc:
port_range = 10000-10000
port_random = no

Running step-by-step:
a) you need Apache running (configured in SCGI mode)
b) you need rtorrent running (with SCGI enabled)
c) access RuTorrent (GUI) via browser

look for errors in:
/var/log/apache2/error.log

Wrong version of xmlrpc-c.
Ubuntu has old version (only stable) of xmlrpc. Until they update their packages you'll experience an error in rutorrent:

“rtorrent is compiled with incorrect version of xmlrpc - without i8 support.”

I use this old library and everything works more or less ok. Torrent size is invalid (it shows –2343444) and rtorrent settings do not work. But the main functionality remains intact.

You can download unstable xmlrpc-c release from:
http://xmlrpc-c.sourceforge.net/downloading.php
to remove this error.

Wednesday, March 2, 2011

Ubuntu – change Message Of The Day (MOTD)

The usual problem MOTD is that you want to change it in /etc/motd and it keeps reverting to the default value.

Try different approach.

Install package  update-motd

aptitude install update-motd

Now you can control motd via editing files:

/etc/update-motd.d/00-header
/etc/update-motd.d/10-help-text
/etc/update-motd.d/91-release-upgrade
/etc/update-motd.d/99-footer

If you just want to add something in the bottom, create & edit the file:

/etc/motd.tail

Setting samba share

install samba:

aptitude install samba smbfs smbclient

In the ####authentication#### section find the line that says security, uncomment it and change it to:

security = share

Define new share in this way:

[public]
writable = yes
path = /public
public = yes
guest ok = yes
guest only = yes
guest account = nobody
browsable = yes

Tuesday, March 1, 2011

udev: eth0 stopped working - renamed to eth2

 

After putting new ethernet cards my ubuntu renamed eth0 to eth2 and eth1 to eth3. I wanted to have my old names back.

in dmesg there was:

eth0 –> renamed to eth2.

All you have to do is delete all old entries in:

/etc/udev/rules.d/70-persistent-net.rules
and you’ll have eth0 and eth1 names back.
 

VirtualBox can't operate in VMX root mode. Please disable the KVM kernel extension, recompile your kernel and reboot (VERR_VMX_IN_VMX_ROOT_MODE).

This error is caused by having kernel module kvm and VirtualBox at the same time. KVM is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V).
http://www.linux-kvm.org/page/Main_Page

To remove kvm module enter:

sudo modprobe -r kvm-intel
sudo modprobe -r kvm-amd

remove kvm from modules that are loaded at boot time. These are stored in file:

/etc/modules