Monday, April 30, 2012

PHP CGI Environment customization

What is the proper way to set the CGI environment for running scripts in PHP? If I would like to run a script and pass in all the CGI ENV variables - it should have only AUTH_TYPE,PATH_INFO etc.



Right now,if I do exec() - it uses the OS ENV variables like PATH,TERM etc. I can't use pcntl_exec(). Appreciate any hints.



Thanks.





preg_match_all not working when trying to get all characters including whitespace

Here is my function:



function grabstuff()
{
foreach (glob("../folder/*.php") as $fn)
{
$file = file_get_contents($fn);

preg_match_all("#\{\('(\w+)'\)}#", $file, $matches);

foreach ($matches[1] as $match)
{

$query = ("ALTER TABLE xxxxx ADD COLUMN `$match` LONGTEXT AFTER xxxxx;");

$result = mysql_query($query) or die("Err: ".mysql_error());

}
}
}


And here is what it looks for on the pages:



<?/*{('test test')}*/?>


It is ignoring this instance where there is a whitespace. It works well for testtest and test_test. Not getting any php errors or mysql errors. Do I need to use \w+\S or \w+\W? I tried both of those, even (...) and it still didn't work. How do I get my above function to recognize any characters within the {('')}, whether they be a normal abc characters or whitespace. I'm sure this is simple. I've done research on google and here and wasn't able to find a solution. (There will be multiple instances of {('')} on any given page if that helps). I've been using this function for a while now, but would like to add the ability to include whitespaces. Thanks!





Javascript - JSON date formatting

With some help from some fellow stack users, I currently have this:




http://jsfiddle.net/wZETP/




The JSON data gives me the {start.date} in YYYY-MM-DD formatting, but I would like to know how to implement a date change to:




Mon 01 Jan






Javascript function taking too long to complete?

Below is a snipet of code that I am having trouble with. The purpose is to check duplicate entries in the database and return "h" with a boolean if true or false. For testing purposes I am returning a true boolean for "h" but by the time the alert(duplicate_count); line gets executed the duplicate_count is still 0. Even though the alert for a +1 gets executed.



To me it seems like the function updateUserFields is taking longer to execute so it's taking longer to finish before getting to the alert.



Any ideas or suggestions? Thanks!



var duplicate_count = 0

for (var i = 0; i < skill_id.length; i++) {

function updateUserFields(h) {
if(h) {
duplicate_count++;
alert("count +1");
} else {
alert("none found");
}
}

var g = new cfc_mentoring_find_mentor();
g.setCallbackHandler(updateUserFields);
g.is_relationship_duplicate(resource_id, mentee_id, section_id[i], skill_id[i], active_ind,table);
};

alert(duplicate_count);




Storing a pointer's address in an unsigned int in C

Is it possible to cast a pointer to an unsigned int, then later cast it back to a pointer? I'm trying to store the pointer to a struct in a pthread_t variable, but I can't seem to get it to work.





How to use Encryption/Decryption to send encrypt data using post (JSON) method?

how to send the password,bank account, credit card information using JSON POST method,We cant send it as plain text. How to use encryption/Decryption method for sending this highly important data?



Three major problem :




  1. How to encrypt data ? (Data means password,bank account, credit card information).

  2. How to send this encrypt data using web service (JSON format)?

  3. How to retrieved this data from server and decrypt ?





how are android security permissions checked at run-time?

This question has been asked before at How does Android enforce permissions?. While the discussions there are good, the question is still not fully answered.



In the development environment, exceptions are thrown when the app tries to do something that requires permissions not declared in AndroidManifest.xml. So how does the run-time system implement the run-time checking?



I guess it's most likely done in the core framework, which may or may not need support from native code. But I don't know what source code files in AOSP are relevant to this.





About haskell, how to define function in file?

I am totally newbie to haskell.



I have such snippet code



lucky:: Int->String
lucky 7 = "LUCKY NUMBER SEVEN!"
lucky x = "Sorry , youre out of luck pal!"


I tried to input to terminal directly, seems not right.
But if I want to put this in file and load this file, then call lucky function. How should I construct this file?
Thank you!



I tried this:



module Main where
lucky:: Int->String
lucky 7 = "LUCKY NUMBER SEVEN!"
lucky x = "Sorry , youre out of luck pal!"


main = do


But when i try to call lucky in terminal, i got this:



factorial.hs:7:8: Empty 'do' construct
lucky 7

<interactive>:1:1: Not in scope: `lucky'




Windows Server Crash Dump Analysis

I'm not certain that this is the right venue for this question, but a programmer friend of mine said I should try this here.



My company's main application is hosted on a terminal server running Windows Server 2008. Since last Thursday we have seen this server crash and reboot 3 times, and we just went live with this server on the previous Tuesday. I have used the the WinDbg program to analyze the crash dump file, but I'm a little outside by depth at this point and I'm hoping that someone out there can help me get this issue resolved.



The application that appears to me to be at fault is winoac.exe which is the executable for SmartWare 4.5 (www.smartware4.com). This is the platform that our application runs on. If this application is at fault, is there anything that I can do about it, other than complaining to SmartWare?



Thanks a million to anybody that can help.



Here are the results of the analysis.



Microsoft (R) Windows Debugger Version 6.10.0003.233 X86
Copyright (c) Microsoft Corporation. All rights reserved.


Loading Dump File [C:\Users\esinnard\Desktop\Windows Dumps\1-29-09\MEMORY.DMP]
Kernel Summary Dump File: Only kernel address space is available

Symbol search path is: SRV*C:\ProgramData\Symbols*http://msdl.microsoft.com/download/symbols
Executable search path is:
Windows Server 2008/Windows Vista SP1 Kernel Version 6001 (Service Pack 1) MP (8 procs) Free x86 compatible
Product: Server, suite: TerminalServer
Built by: 6001.18145.x86fre.vistasp1_gdr.080917-1612
Machine Name:
Kernel base = 0x81c41000 PsLoadedModuleList = 0x81d4e930
Debug session time: Thu Jan 29 12:49:43.870 2009 (GMT-6)
System Uptime: 0 days 11:18:08.929
Loading Kernel Symbols
...............................................................
................................................................
..............
Loading User Symbols
PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details
Loading unloaded module list
.....
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************

Use !analyze -v to get detailed debugging information.

BugCheck 8E, {c0000005, 81c88043, 9cef0840, 0}

Page bd1f2 not present in the dump file. Type ".hh dbgerr004" for details
Page bc9c3 not present in the dump file. Type ".hh dbgerr004" for details
PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details
PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details
Probably caused by : RDPDD.dll ( RDPDD!OE2_TableEncodeOrderFields+11e )

Followup: MachineOwner
---------

7: kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************

KERNEL_MODE_EXCEPTION_NOT_HANDLED (8e)
This is a very common bugcheck. Usually the exception address pinpoints
the driver/function that caused the problem. Always note this address
as well as the link date of the driver/image that contains this address.
Some common problems are exception code 0x80000003. This means a hard
coded breakpoint or assertion was hit, but this system was booted
/NODEBUG. This is not supposed to happen as developers should never have
hardcoded breakpoints in retail code, but ...
If this happens, make sure a debugger gets connected, and the
system is booted /DEBUG. This will let us see why this breakpoint is
happening.
Arguments:
Arg1: c0000005, The exception code that was not handled
Arg2: 81c88043, The address that the exception occurred at
Arg3: 9cef0840, Trap Frame
Arg4: 00000000

Debugging Details:
------------------

PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details
PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details

EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

FAULTING_IP:
nt!RtlInitUnicodeString+1b
81c88043 f266af repne scas word ptr es:[edi]

TRAP_FRAME: 9cef0840 -- (.trap 0xffffffff9cef0840)
ErrCode = 00000000
eax=00000000 ebx=fe414fd8 ecx=ffffffec edx=9cef0914 esi=fe40fcf0 edi=fe415000
eip=81c88043 esp=9cef08b4 ebp=9cef0924 iopl=0 nv up ei pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010246
nt!RtlInitUnicodeString+0x1b:
81c88043 f266af repne scas word ptr es:[edi]
Resetting default scope

DEFAULT_BUCKET_ID: VISTA_DRIVER_FAULT

BUGCHECK_STR: 0x8E

PROCESS_NAME: WINOAC.EXE

CURRENT_IRQL: 0

LAST_CONTROL_TRANSFER: from 81c72fbe to 81cfc759

STACK_TEXT:
9cef0400 81c72fbe 0000008e c0000005 81c88043 nt!KeBugCheckEx+0x1e
9cef07d0 81c9953a 9cef07ec 00000000 9cef0840 nt!KiDispatchException+0x1a9
9cef0838 81c994ee 9cef0924 81c88043 badb0d00 nt!CommonDispatchException+0x4a
9cef085c 9976011a 99771680 997708e8 00000000 nt!Kei386EoiHelper+0x186
9cef0924 9959efab 5d0102bb 00000006 00000002 RDPDD!OE2_TableEncodeOrderFields+0x11e
9cef0a0c 995aeaf8 5d0102bb 00000006 00000002 win32k!xxxRealDrawMenuItem+0x80b
9cef0abc 9958455b 5d0102bb 0110007e 9cef0b04 win32k!xxxDrawState+0x1c9
9cef0b2c 995853e1 5d0102bb fe40fc78 00c8d0d4 win32k!xxxDrawMenuItem+0x3f8
9cef0b98 9959f511 5d0102bb 00000000 fe414570 win32k!xxxMenuDraw+0x1f2
9cef0bf0 994ed1d6 00000017 5d0102bb 00000004 win32k!xxxMenuBarDraw+0x1bf
9cef0c38 9950c0f5 fe414570 5d0102bb 00000001 win32k!xxxDrawWindowFrame+0xf7
9cef0cb4 9950d73d fe414570 00000085 090402df win32k!xxxRealDefWindowProc+0x88b
9cef0ccc 994e673d fe414570 00000085 090402df win32k!xxxWrapRealDefWindowProc+0x2b
9cef0ce8 9950d6f4 fe414570 00000085 090402df win32k!NtUserfnNCDESTROY+0x27
9cef0d20 81c9897a 000200ba 00000085 090402df win32k!NtUserMessageCall+0xc6
9cef0d20 77089a94 000200ba 00000085 090402df nt!KiFastCallEntry+0x12a
WARNING: Frame IP not in any known module. Following frames may be wrong.
0012d7cc 00000000 00000000 00000000 00000000 0x77089a94


STACK_COMMAND: kb

FOLLOWUP_IP:
RDPDD!OE2_TableEncodeOrderFields+11e
9976011a 8b4518 mov eax,dword ptr [ebp+18h]

SYMBOL_STACK_INDEX: 4

SYMBOL_NAME: RDPDD!OE2_TableEncodeOrderFields+11e

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: RDPDD

IMAGE_NAME: RDPDD.dll

DEBUG_FLR_IMAGE_TIMESTAMP: 4791923e

FAILURE_BUCKET_ID: 0x8E_RDPDD!OE2_TableEncodeOrderFields+11e

BUCKET_ID: 0x8E_RDPDD!OE2_TableEncodeOrderFields+11e

Followup: MachineOwner
---------

------------------------------------------------------------------------------------------


Microsoft (R) Windows Debugger Version 6.10.0003.233 X86
Copyright (c) Microsoft Corporation. All rights reserved.


Loading Dump File [C:\Users\esinnard\Desktop\Windows Dumps\1-29-09\MEMORY.DMP]
Kernel Summary Dump File: Only kernel address space is available

Symbol search path is: SRV*C:\ProgramData\Symbols*http://msdl.microsoft.com/download/symbols
Executable search path is:
Windows Server 2008/Windows Vista SP1 Kernel Version 6001 (Service Pack 1) MP (8 procs) Free x86 compatible
Product: Server, suite: TerminalServer
Built by: 6001.18145.x86fre.vistasp1_gdr.080917-1612
Machine Name:
Kernel base = 0x81c41000 PsLoadedModuleList = 0x81d4e930
Debug session time: Thu Jan 29 12:49:43.870 2009 (GMT-6)
System Uptime: 0 days 11:18:08.929
Loading Kernel Symbols
...............................................................
................................................................
..............
Loading User Symbols
PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details
Loading unloaded module list
.....
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************

Use !analyze -v to get detailed debugging information.

BugCheck 8E, {c0000005, 81c88043, 9cef0840, 0}

Page bd1f2 not present in the dump file. Type ".hh dbgerr004" for details
Page bc9c3 not present in the dump file. Type ".hh dbgerr004" for details
PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details
PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details
Probably caused by : RDPDD.dll ( RDPDD!OE2_TableEncodeOrderFields+11e )

Followup: MachineOwner
---------

7: kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************

KERNEL_MODE_EXCEPTION_NOT_HANDLED (8e)
This is a very common bugcheck. Usually the exception address pinpoints
the driver/function that caused the problem. Always note this address
as well as the link date of the driver/image that contains this address.
Some common problems are exception code 0x80000003. This means a hard
coded breakpoint or assertion was hit, but this system was booted
/NODEBUG. This is not supposed to happen as developers should never have
hardcoded breakpoints in retail code, but ...
If this happens, make sure a debugger gets connected, and the
system is booted /DEBUG. This will let us see why this breakpoint is
happening.
Arguments:
Arg1: c0000005, The exception code that was not handled
Arg2: 81c88043, The address that the exception occurred at
Arg3: 9cef0840, Trap Frame
Arg4: 00000000

Debugging Details:
------------------

PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details
PEB is paged out (Peb.Ldr = 7ffd400c). Type ".hh dbgerr001" for details

EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

FAULTING_IP:
nt!RtlInitUnicodeString+1b
81c88043 f266af repne scas word ptr es:[edi]

TRAP_FRAME: 9cef0840 -- (.trap 0xffffffff9cef0840)
ErrCode = 00000000
eax=00000000 ebx=fe414fd8 ecx=ffffffec edx=9cef0914 esi=fe40fcf0 edi=fe415000
eip=81c88043 esp=9cef08b4 ebp=9cef0924 iopl=0 nv up ei pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010246
nt!RtlInitUnicodeString+0x1b:
81c88043 f266af repne scas word ptr es:[edi]
Resetting default scope

DEFAULT_BUCKET_ID: VISTA_DRIVER_FAULT

BUGCHECK_STR: 0x8E

PROCESS_NAME: WINOAC.EXE

CURRENT_IRQL: 0

LAST_CONTROL_TRANSFER: from 81c72fbe to 81cfc759

STACK_TEXT:
9cef0400 81c72fbe 0000008e c0000005 81c88043 nt!KeBugCheckEx+0x1e
9cef07d0 81c9953a 9cef07ec 00000000 9cef0840 nt!KiDispatchException+0x1a9
9cef0838 81c994ee 9cef0924 81c88043 badb0d00 nt!CommonDispatchException+0x4a
9cef085c 9976011a 99771680 997708e8 00000000 nt!Kei386EoiHelper+0x186
9cef0924 9959efab 5d0102bb 00000006 00000002 RDPDD!OE2_TableEncodeOrderFields+0x11e
9cef0a0c 995aeaf8 5d0102bb 00000006 00000002 win32k!xxxRealDrawMenuItem+0x80b
9cef0abc 9958455b 5d0102bb 0110007e 9cef0b04 win32k!xxxDrawState+0x1c9
9cef0b2c 995853e1 5d0102bb fe40fc78 00c8d0d4 win32k!xxxDrawMenuItem+0x3f8
9cef0b98 9959f511 5d0102bb 00000000 fe414570 win32k!xxxMenuDraw+0x1f2
9cef0bf0 994ed1d6 00000017 5d0102bb 00000004 win32k!xxxMenuBarDraw+0x1bf
9cef0c38 9950c0f5 fe414570 5d0102bb 00000001 win32k!xxxDrawWindowFrame+0xf7
9cef0cb4 9950d73d fe414570 00000085 090402df win32k!xxxRealDefWindowProc+0x88b
9cef0ccc 994e673d fe414570 00000085 090402df win32k!xxxWrapRealDefWindowProc+0x2b
9cef0ce8 9950d6f4 fe414570 00000085 090402df win32k!NtUserfnNCDESTROY+0x27
9cef0d20 81c9897a 000200ba 00000085 090402df win32k!NtUserMessageCall+0xc6
9cef0d20 77089a94 000200ba 00000085 090402df nt!KiFastCallEntry+0x12a
WARNING: Frame IP not in any known module. Following frames may be wrong.
0012d7cc 00000000 00000000 00000000 00000000 0x77089a94


STACK_COMMAND: kb

FOLLOWUP_IP:
RDPDD!OE2_TableEncodeOrderFields+11e
9976011a 8b4518 mov eax,dword ptr [ebp+18h]

SYMBOL_STACK_INDEX: 4

SYMBOL_NAME: RDPDD!OE2_TableEncodeOrderFields+11e

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: RDPDD

IMAGE_NAME: RDPDD.dll

DEBUG_FLR_IMAGE_TIMESTAMP: 4791923e

FAILURE_BUCKET_ID: 0x8E_RDPDD!OE2_TableEncodeOrderFields+11e

BUCKET_ID: 0x8E_RDPDD!OE2_TableEncodeOrderFields+11e

Followup: MachineOwner
---------

------------------------------------------------------------------------------------------


Microsoft (R) Windows Debugger Version 6.10.0003.233 X86
Copyright (c) Microsoft Corporation. All rights reserved.


Loading Dump File [C:\Users\esinnard\Desktop\Windows Dumps\2-3-09-2\MEMORY.DMP]
Kernel Summary Dump File: Only kernel address space is available

Symbol search path is: SRV*C:\ProgramData\Symbols*http://msdl.microsoft.com/download/symbols
Executable search path is:
Windows Server 2008/Windows Vista SP1 Kernel Version 6001 (Service Pack 1) MP (8 procs) Free x86 compatible
Product: Server, suite: TerminalServer
Built by: 6001.18145.x86fre.vistasp1_gdr.080917-1612
Machine Name:
Kernel base = 0x81c13000 PsLoadedModuleList = 0x81d20930
Debug session time: Tue Feb 3 14:20:03.117 2009 (GMT-6)
System Uptime: 0 days 2:00:33.869
Loading Kernel Symbols
...............................................................
................................................................
.............
Loading User Symbols
PEB is paged out (Peb.Ldr = 7ffdc00c). Type ".hh dbgerr001" for details
Loading unloaded module list
.....
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************

Use !analyze -v to get detailed debugging information.

BugCheck 8E, {c0000005, 81c5a043, d60a5840, 0}

Page bce51 not present in the dump file. Type ".hh dbgerr004" for details
Page bce22 not present in the dump file. Type ".hh dbgerr004" for details
Page bb16b not present in the dump file. Type ".hh dbgerr004" for details
Page bce5a not present in the dump file. Type ".hh dbgerr004" for details
Page bce5a not present in the dump file. Type ".hh dbgerr004" for details
Page bce5a not present in the dump file. Type ".hh dbgerr004" for details
PEB is paged out (Peb.Ldr = 7ffdc00c). Type ".hh dbgerr001" for details
PEB is paged out (Peb.Ldr = 7ffdc00c). Type ".hh dbgerr001" for details
Probably caused by : win32k.sys ( win32k!OffBitBlt+97 )

Followup: MachineOwner
---------

0: kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************

KERNEL_MODE_EXCEPTION_NOT_HANDLED (8e)
This is a very common bugcheck. Usually the exception address pinpoints
the driver/function that caused the problem. Always note this address
as well as the link date of the driver/image that contains this address.
Some common problems are exception code 0x80000003. This means a hard
coded breakpoint or assertion was hit, but this system was booted
/NODEBUG. This is not supposed to happen as developers should never have
hardcoded breakpoints in retail code, but ...
If this happens, make sure a debugger gets connected, and the
system is booted /DEBUG. This will let us see why this breakpoint is
happening.
Arguments:
Arg1: c0000005, The exception code that was not handled
Arg2: 81c5a043, The address that the exception occurred at
Arg3: d60a5840, Trap Frame
Arg4: 00000000

Debugging Details:
------------------

Page bb16b not present in the dump file. Type ".hh dbgerr004" for details
Page bce5a not present in the dump file. Type ".hh dbgerr004" for details
Page bce5a not present in the dump file. Type ".hh dbgerr004" for details
Page bce5a not present in the dump file. Type ".hh dbgerr004" for details
PEB is paged out (Peb.Ldr = 7ffdc00c). Type ".hh dbgerr001" for details
PEB is paged out (Peb.Ldr = 7ffdc00c). Type ".hh dbgerr001" for details

EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

FAULTING_IP:
nt!RtlInitUnicodeString+1b
81c5a043 f266af repne scas word ptr es:[edi]

TRAP_FRAME: d60a5840 -- (.trap 0xffffffffd60a5840)
ErrCode = 00000000
eax=00000000 ebx=fe41afd8 ecx=ffffffec edx=d60a5914 esi=fe40f5e0 edi=fe41b000
eip=81c5a043 esp=d60a58b4 ebp=d60a5924 iopl=0 nv up ei pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00010246
nt!RtlInitUnicodeString+0x1b:
81c5a043 f266af repne scas word ptr es:[edi]
Resetting default scope

DEFAULT_BUCKET_ID: VISTA_DRIVER_FAULT

BUGCHECK_STR: 0x8E

PROCESS_NAME: WINOAC.EXE

CURRENT_IRQL: 0

LAST_CONTROL_TRANSFER: from 81c44fbe to 81cce759

STACK_TEXT:
d60a5400 81c44fbe 0000008e c0000005 81c5a043 nt!KeBugCheckEx+0x1e
d60a57d0 81c6b53a d60a57ec 00000000 d60a5840 nt!KiDispatchException+0x1a9
d60a5838 81c6b4ee d60a5924 81c5a043 badb0d00 nt!CommonDispatchException+0x4a
d60a585c 999e2242 ff888010 00000000 00000000 nt!Kei386EoiHelper+0x186
d60a5924 999befab 1401009b 00000006 00000002 win32k!OffBitBlt+0x97
d60a5a0c 999ceaf8 1401009b 00000006 00000002 win32k!xxxRealDrawMenuItem+0x80b
d60a5abc 999a455b 1401009b 0110007e d60a5b04 win32k!xxxDrawState+0x1c9
d60a5b2c 999a53e1 1401009b fe40d168 00c8d0d4 win32k!xxxDrawMenuItem+0x3f8
d60a5b98 999bf511 1401009b 00000000 fe418398 win32k!xxxMenuDraw+0x1f2
d60a5bf0 9990d1d6 00000017 1401009b 00000004 win32k!xxxMenuBarDraw+0x1bf
d60a5c38 9992c0f5 fe418398 1401009b 00000001 win32k!xxxDrawWindowFrame+0xf7
d60a5cb4 9992d73d fe418398 00000085 0904035f win32k!xxxRealDefWindowProc+0x88b
d60a5ccc 9990673d fe418398 00000085 0904035f win32k!xxxWrapRealDefWindowProc+0x2b
d60a5ce8 9992d6f4 fe418398 00000085 0904035f win32k!NtUserfnNCDESTROY+0x27
d60a5d20 81c6a97a 0003001c 00000085 0904035f win32k!NtUserMessageCall+0xc6
d60a5d20 77049a94 0003001c 00000085 0904035f nt!KiFastCallEntry+0x12a
WARNING: Frame IP not in any known module. Following frames may be wrong.
0012d7cc 00000000 00000000 00000000 00000000 0x77049a94


STACK_COMMAND: kb

FOLLOWUP_IP:
win32k!OffBitBlt+97
999e2242 8b4d20 mov ecx,dword ptr [ebp+20h]

SYMBOL_STACK_INDEX: 4

SYMBOL_NAME: win32k!OffBitBlt+97

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: win32k

IMAGE_NAME: win32k.sys

DEBUG_FLR_IMAGE_TIMESTAMP: 48d1b9ef

FAILURE_BUCKET_ID: 0x8E_win32k!OffBitBlt+97

BUCKET_ID: 0x8E_win32k!OffBitBlt+97

Followup: MachineOwner
---------




Error 1606. Could not access network location %SystemDrive%\inetpub\wwwroot\ while installing on IIS7

I'm trying to port our software installer which currently supports Windows 2000 and Windows 2003 to a Windows 2008 environment. Currently, the installer gets an error which reads "Error 1606. Could not access network location %SystemDrive%\inetpub\wwwroot."



%SystemDrive% is without a doubt C:\, and C:\inetpub\wwwroot\ has the correct accessibility.



It is interesting that if I hardcode the path in the following keys in the registry to C:\inetpub\wwwroot\, without using the environment variable, the installer works correctly.
• HKLM/Software/Wow6432Node/Microsoft/InetStp/PathWWWRoot
• KHLM/Software/Microsoft/InetStp/PathWWWRoot.



This seems like a very poor hack. I do not want to tell our clients that they need to hack their registry before they will be able to install our product. Another option is to change the registry behind the scenes, do our install, and revert the registry keys to their original values at the end of the install, but obviously I don't like this solution either.



I find it hard to believe that Microsoft would have done this without reason, so there must be an alternate approach to get these installers to work without modifying the registry.



Any tips appreciated.





jQuery toggle/vertical slider effect with multiple Divs

Actually, I am new to jQuery and I am writting a sample page with jQuery functions. In this page I am making use of toggle function. Please help me to get the intended effect. I am trying to get it but it is not working properly.
The effect I am trying to apply is;




  1. There are 2 buttons on the page, say Button1 and Button2.

  2. There are 2 Divs, say Div1 and Div2.

  3. Initially both Divs are hidden and only 2 buttons are visible.

  4. If Button1 is clicked, Div1 should get toggle down and vice versa.

  5. If Div1 is in open state and Button2 is clicked, Div1 should go up slightly and Div2 should fall down.



I have written some code with CSS applied on it. But I am not getting the sliding effect as it gives with only one Div.



I have written Javascript as;



var IsPanelDown = false;
var IsPanel2Down = false;

$(document).ready(function() {

// Expand Panel
$("#open").click(function(){
if (IsPanel2Down == false)
{
$("div#panel2").slideUp("slow");
IsPanel2Down = false;
}
$("div#panel").slideDown("slow");
IsPanelDown = true;
});

// Collapse Panel
$("#close").click(function(){
$("div#panel").slideUp("slow");
IsPanelDown = false;
});

// Switch buttons from "Log In | Register" to "Close Panel" on click
$("#toggle a").click(function () {
$("#toggle a").toggle();
});

$("#toggle2 a").click(function () {
$("#toggle2 a").toggle();
});

$("#open1").click(function(){
if(IsPanelDown == false)
{

$("div#panel").slideUp("slow");
IsPanelDown = false;
}
$("div#panel2").slideDown("slow");
IsPanel2Down = true;
});

// Collapse Panel
$("#close1").click(function(){
$("div#panel2").slideUp("slow");
IsPanel2Down = false;
});
});




Deploying Content Type with Publishing HTML Field by Feature saving content not correctly

I have a problem using a Publishing HTML Field.



The Elements.xml:



<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field ID="{987B9BA2-23AB-4E52-99DD-2D59BAA79F4B}" Name="LeftContent" DisplayName="Left Content" RichText="TRUE" RichTextMode="FullHtml" Type="HTML" Hidden="FALSE"></Field>

<!-- Parent ContentType: Article Page (0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D) -->
<ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D002da882f450a44abaacff86118ffffaeb"
Name="Left Content"
Version="0">
<FieldRefs>
<FieldRef ID="{987B9BA2-23AB-4E52-99DD-2D59BAA79F4B}"/>
</FieldRefs>
</ContentType>

</Elements>


In my Page Layout I use ...



<PublishingWebControls:RichHtmlField id="rchHtmlFldROSTableTwoColumnRight" FieldName="ROSTableTwoColumnRight" runat="server"/>


The problem is that when I create a page based on the page layout with this content type and edit the field, SharePoint saves the content not as HTML but HTML Entities. So in not-edit-mode you see the HTML source code like

Hello World



I hope somebody can help me.
Thanks!! ;)





apache rewrite port for a certain path

I would need to rewrite



(http: or https:)//my.domain.com/foo/


into



(http: or https:)//my.domain.com:8080/foo/


I was not sure if apache mod-proxy could do that, and how





AS3 How to simulate the throwing of something?

So I have started this game, and the premise is you are going to be running around, and balls are going to be thrown from the sides of the screens. You have to try to dodge the balls. What I want to know is how do you make the balls act like they are actually being thrown. Like what would be the formula or whatever for something like this.





Should we use IE's CSS Dynamic properties?

Should we use IE's CSS Dynamic properties?



I read IE8+ would not support these.



What is the best strategy to handle this?





forcefully logout a specific user among all online users

I'm developing a website in asp.net.

In my site administrator can view list all other online users.

Administrator can also disable any account from that list.

Everything was going fine so far. But now i decided to logout the user which is beeing disabled. How to do a logout operation for a particular user from the above specified online user list.



NOTE: I'm using default membership schema for my sql server database.



PLEASE HELP.





My mod_rewrite code in htaccess caused the page to not load

I have horrible URLs like this:



http://example.com/subfolder/index.php?a=1&b=1&token=8d519decbe60db44154b1fbc8c553ac4



I am trying to make it look like this:



http://example.com/subfolder/menu/1/1/#/



But this code is causing the page to crash/not be found or something:



RewriteEngine on

RewriteCond %{QUERY_STRING} ^a=([0-9]+)&b=([0-9]+)&token=([A-Za-z0-9]+)
RewriteRule ^subfolder/index.php /menu/$1/$2/#? [R=301,L]


I put this .htaccess file in my root folder example.com/.htaccess, do I need to put it in the subfolder?



I'm getting 404 page not found error !





No action after PHP form Posted to SQL

I'm making a calendar of events, and the "details" for the event are on a hidden div.
I have a small icon that, when clicked, uses javascript to show the details.



What I want is that when this is clicked, the icon is replaced by a different icon (to show it is 'open') and for that icon, when clicked, to close the div again.



So the current code is



<a href="#" onclick="Effect.BlindDown('eventdetails<?php echo $event_count;?>'); return false;"><img class="open" src="./img/plus.png"></a>


And I'd want the image to change to "minus.png". So then it would be



<a href="#" onclick="Effect.BlindUp('eventdetails<?php echo $event_count;?>'); return false;"><img class="open" src="./img/minus.png"></a>  


But cant quite figure it out. Any ideas?



UPDATE



OKay, currently have from Mia, but still not working



<a href="#" onclick="toggleDisplayWait("eventdetails<?php echo $event_count;?>", "icon", 800); return false;"><img id="icon" class="open" src="./img/plus.png"></a>


And in the header...



    function toggleDisplayWait(divId, imgId, durationmSec) {
if(!$(divId).visible()) {
move = Effect.BlindDown;
newImage = "./img/minus.png";
}
else {
move = Effect.BlindUp;
newImage = "./img/plus.png";
}
move(divId, {duration: durationmSec / 1000.0 });
setTimeout(function() { $(imgId).src = newImage; }, durationmSec)
}

$(divId).hide();

</script>


When I run the event, I get a syntax error on toggledisplaywait (





AIR native extension: how do I return an ArrayList from android native code

I have written an android native extension to get the list of songs in the android phone. Retrieving song works fine. I am saving the list of songs in an ArrayList in native code.



I am able to return the size of the ArrayList to AIR app, but how do I return the full ArrayList itself.



Can someone please guide me?



Thank you in advance.





I have two identical mysql databases running on the same server. The old one works fine. The new one is getting terrible performance with 'order by'

I've been in the middle of migrating a drupal-5 site to drupal-6. Unfortunately, once I made a copy of the drupal-5 database, the new db has terrible performance problems. Queries like this one:




SELECT DISTINCT(n.nid), n.title, n.created FROM node n INNER JOIN term_node tn ON n.nid = tn.nid WHERE n.type <> 'acidfree' AND tn.tid = 402 AND n.status = 1 ORDER BY n.nid, limit 1;



can take several seconds to execute on the new db while the identical query completes in under a millisecond on the old db. I've run mysqlcheck --repair and --optimize, with no benefit, and the hosting provider is insisting that it's my lousy sql that's causing the problem.



Any suggestions on how to fix this? Queries like that one are used to load random photos onto pages of the site and some pages are taking as long as a minute to load.



EDIT: After 2 weeks of complaints about this, the problem suddenly resolved itself (within minutes of posting here). The provider insists they didn't change anything.....



I might as well close this question for now. Thanks for the suggestions.





Wednesday, April 25, 2012

How to make queries and send them to solr

I want to make queries according to the parameters I get from my server and query solr server.



First I want a guide how to make a query url and second, how to send it to solr. For the time being I use the default graphical user interface.





Two ListFragment inside one Fragment

I have created following thing in android using android compatibility support package



enter image description here



Basically i have a FragmentAcitivity which shows two Tabs. One Tab represents Fragment #1 and second is Fragment #2. Fragment #2 has two ListFragment i.e. ListFragment #1 and ListFragment #2 , but the problem is m i am getting following error when i try to do that.



    android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:582)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at com.myexample.template.TextVoiceFragment.onCreateView(TextVoiceFragment.java:19)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:837)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1041)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:616)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1359)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:422)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:86)
at android.support.v4.view.ViewPager.populate(ViewPager.java:453)
at android.support.v4.view.ViewPager.onAttachedToWindow(ViewPager.java:563)
at android.view.View.dispatchAttachedToWindow(View.java:6015)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1124)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1129)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1129)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1129)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1129)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:1129)
at android.view.ViewRoot.performTraversals(ViewRoot.java:731)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1744)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4914)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.myexample.template.VoiceTemplate.onActivityCreated(VoiceTemplate.java:82)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:858)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1020)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1099)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:263)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)


Binary XML



<fragment class="com.myexample.template.VoiceTemplate" 
android:id="@+id/voiceListFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>


Line number 19 contains inside onCreateView of TextVoiceFragment.class which is Fragment #2 in this case



 return inflater.inflate(R.layout.text_voice_fragment, container, false);


Line number 82 contains in code inside onActivityCreated of VoiceTemplate.class which extents ListFragment & a ListFragment #2



// 
getListView().setOnItemClickListener( new OnItemClickListener(){

@Override
public void onItemClick(AdapterView<?> adapterView, View view,
int position, long arg3) {
// TODO Auto-generated method stub
}

});


i have tried replacing Fragment #2 with FragmentActivity as follows



enter image description here



but in that case i am getting following error



 java.lang.ClassCastException: com.myexample.template.TextVoiceFragment 


here TextVoiceFragment is Tab second





Android: SSO on Twitter

Please help me out I am getting this error



 04-09 15:18:49.120: W/System.err(8085): oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: api.twitter.com
04-09 15:18:49.123: W/System.err(8085): at oauth.signpost.commonshttp.CommonsHttpOAuthProvider.retrieveToken(CommonsHttpOAuthProvider.java:106)
04-09 15:18:49.123: W/System.err(8085): at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:66)


I am using this link https://github.com/brione/Brion-Learns-OAuth example. Please can u say me where I am going wrong..



Thanks in Advacnce..





Is there any compare operator in c# like SQL's IN statement

This is not a specific question but a generic question which was in my mind from long time



I have to check one variable if it contains a value from a list of strings



for e.g.



status == "Open" && status =="Active" && status =="Reopen" && status = "InActive etc..


In SQL it is very easy to write this kind of statements e.g.



select * from ticket where status in ("Open","Active","Reopen","InActive)



I wonder we don't have such easy statement in C#?



Do anybody know any easy way like SQL to write this kind of statements without using generic types of if else ,foreach loop etc..





how to bind ajaxStart/ajaxStop to a form?

How to bind ajaxStart/ajaxStop to a form?



I need a loading block to show while uploading the file



Now the form is not submitted at all



var iframe = $('<iframe name="iframe_file_upload" src="'+src_file_upload+'" style="display:none"></iframe>');
var btn_send = $('<input type="button" />')
.click(function(){
$('#form_upload_file').bind('ajaxStart', function(){
$(this).submit();
});
iframe.bind('ajaxStop', function(){
$(this).load(function(){
...


update



var btn_send = $('<input class="btn btn_margin_left" type="button" value="'+Lang.get('BTN_UPLOAD')+'" />')
.click(function(){
$('#form_upload_file').ajaxForm(function(response){
if(response.error){
// alert error
}
else{
// success
}




How to resolve Error executing aapt in Android/Eclipse?

Error executing aapt.



Please check aapt is present at /home/padmakumar/android-sdk/platform-tools/aapt    NhpAndroid_tablet_k4        line 1  Android ADT Problem

Hint: On 64-bit systems,
make sure the 32-bit libraries are installed: sudo apt-get install ia32-libs
line 1 Android ADT Problem


I can delete 2 errors in problem tab for temp solution or cleaning the projects or deleting the gen/bin folder and recreating or restarting works fine for temporary.



how to resolve permanently to aviod this problem? any help?



Note: I executed this command 'sudo apt-get install ia32-libs' still its asking.





Compare Two arrays and merging in PHP

I have two arrays :



$array1 = array(1=>1,10=>1,12=>0,13=>13);
$array2 = array(1=>"Hello",10=>"Test",12=>"check",13=>"error");


Here $array1 have keys and values.Now i want to take first value from $array1(as 1) and want to check if this is repeated in this array .



Here 1 is repeated two times so i want to take the twp keys 1,10 and display the corresponding values of this keys from $array2.If the value in $array1 not repeated just display the value of this key from $array2.



That is i want to get the output as :



Hello Test
check
error


That means ,
In $array1 1,10 keys have same value so value of 1 and 10 from $array2 is merged.then displayed.



Like 12 ,have 0 this is not repeated so simply take value of 12 from $array2.



Like 13.



How can i do this?





Rebinding a port to datagram socket on a difftent IP

In my application I hyave created a datagarm socket and binded a port say 9999 to ip 192.168.173.1 now i want to bind the port to a new ip say 192.168.173.2
but i am not able to do it
Steps i followed
1 DatagramSocket s= new DatagramSocket(port,ip1);
2 s.disconnect();



s.close();



s= new DatagramSocket(port,ip2);



but this gives a java,net,BindException :Address already in use : Cannot bind
any insight would be very helpfull





Xna collision detection 2d

Hi i am trying to write simple game where there is one player and some simple world like trees or some buildings, player can walk having muchine gun and shoot to world object like trees and finally destroy it, view is from the top so i don't need any gravity. Player can hit a lot of bullets and some monster in world can shoot to. SO there can be a lof of bullets in one time on the screen so i need some good tool to make colision detection. Also important is that player can't now walk on other object, like there is a monster and player and they can't exist in the same place (one shouldn't go on another). Can you recoment me some collision detection engine or better I should write it my self?





Send SMS using way2sms gateway

I want to create an android app that will send text sms using way2sms gateway can someone please explain how to do so?





the height of tableview cell according to Content of UITextView

I want to dynamically increase the height of tableview cell according to Content of textview in cell. Here I create textview and add that textview in cell as subview. So according to content of textview height of tableview cell is get fixed. Any one know how to do that.



Thanks in advance





How do I import nodes into the Facebook wall?

I wants to import drupal nodes and blogs into facebook wall. Which module should I use for this function?





C/C++ MultiMap Library

I have store 111 million key-value pairs (one key can have multiple values - maximum 2/3) whose key are 50 bit Integers and values are 32 bit (maximum) Integers. Now, my requirements are:




  1. Fast Insertion of (Key, Value) pair [allowing duplicates]

  2. Fast retrieving of value/values based on key.



Is there any library for C/C++ which solves this issue ? I can provide 5/6 GB main memory for that. For more info: my previous post.





What is the most efficient way to choose a random value in a stream?

What is the most efficient way to choose a random value in a stream? Given that each of them has a chance of occurring equally.



Thanks.





what are the best practices for reading from a serial connection in python

I have been using pyserial to read lines sent from an arduino. While it works fine, I was wondering if there are some best practices. In particular when the input needs to be passed through multiple functions (ie, a filter and then a rangefinder class).





How to use carmen for country_select in formatstic

How can I use carmen for country_select with formtastic? Right now I am using country_Select and it works fine but I need the iso codes now and it seems it is not provided by country_select.





PHPUnit Fatal Error with Selenium/Ubuntu

I have gone through various tutorials/posts to install PHPUnit with Selenium on my Ubuntu system. I believe I have everything setup as required:



/usr/share/php$ phpunit --version
PHPUnit 3.6.10 by Sebastian Bergmann.


So using the IDE I create my test, and save it for running, which appears to be setup as required. So I run the test using:



phpunit /home/retrobadger/working_files/tutorials/phpunit/selenium1.php


But everytime I run it, I get the error below:



PHP Fatal error:  Class 'PHPUnit_Extensions_SeleniumTestSuite' not found in /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php on line 394
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/php/PHPUnit/TextUI/Command.php:150
PHP 5. ReflectionMethod->invoke() /usr/share/php/PHPUnit/Runner/BaseTestRunner.php:124
PHP 6. PHPUnit_Extensions_SeleniumTestCase::suite() /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php:0


The file in extensions exists, and I have set very open priviledges to it. The only things I can think of are that either my SeleniumTestCase.php is faulty, or that I need to require another file no other tutorials have suggested.



Any recommendations would be greatly appreciated. I have little experience with PHPUnit so expect my mistake is a basic one.



Thanks for any advice you can give,
Dan





xcode UIWebView loader code HTML

I've a question about load inside the web view:



I create a Json file to get Wordpress table and work well but inside the content table i can get only pure HTML code in one Line, so if i do a request from the web view to load the content like standard code i can't see the content, but only pure code with tags:



[MyWeview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:MyJsonClass.MyContentTeble ]]];


This normal code working, but not to encode HTML, how can encode the HTML directly inside the web view?



Thanks for help.





How to make expect command in expect program script to wait for exact string matching

I want to know how to make expect command in expect script to wait for exact string to be matched before proceeding to next line in the script.



The code is as shown below



#!/bin/sh
#!/usr/bin/expect

spawn ssh -Y localuser@lbblr-tirumala
expect -exact "localuser@lbblr-tirumala's password: "

# replace password with ur own passwd
send "geomax45\r"

# replace the prompt with ur own prompt
expect "localuser@lbblr-tirumala:~$ "

# run application
send "./sample\r"

expect "*Menu*\r
1. print hello world\r
2. print Bye world\r
3. quit\r
enter choice: "
# enter choice 1
send "1\r"
expect "Bye world\r
*Menu*\r
1. print hello world\r
2. print Bye world\r
3. quit\r
enter choice: $"
# enter choice 2
send "2\r"


In the above code after entering 1 the code should wait for "Bye world\r......" string to occur on the screen. But even though the screen prompts different string altogether, the code is executing the mext line and entering option 2, which should not occur as per definition of expect. It should wait untill the complete string in expect command matches.



I want to know whether there is any stricter command that can be used so that expect waits until exact string matching occurs. Please help me in this issue





Flash/AIR Stage Video on iOS

Does any of you can point me to some resource about video performance of AIR (3.2) on iOS devices.



I am interested into:




  • is StageVideo available

  • is video streaming allowed/enabled

  • is the performance ok ?





navigation bar image hiding custom navigation bar button

I am able to give image to navigation bar and also changed image of navigation bar button item. For some reason navigation bar image, i guess, overlapped over navigation bar button image. Navigation bar button is functioning right when i click on navigation bar image at left but its not displaying over navigation bar image. here is the code ;



UIImage *imagebar = [UIImage imageNamed: @"schedule-strip.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: imagebar];
imageView.frame = CGRectMake(0, 0, 190, 44);
imageView.contentMode = UIViewContentModeScaleAspectFill;
self.navigationItem.titleView = imageView;


UIImage* image = [UIImage imageNamed:@"back-icon.png"];
CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
UIButton* someButton = [[UIButton alloc] initWithFrame:frame];
[someButton setBackgroundImage:image forState:UIControlStateNormal];
[someButton setShowsTouchWhenHighlighted:YES];
[someButton addTarget:self action:@selector(backToMore) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem* someBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:someButton];
[self.navigationItem setLeftBarButtonItem:someBarButtonItem];

[someBarButtonItem release];
[someButton release];


help me out.





Timeline Chart framework, Flotr vs AmChart

I have been comparing many chart framework, and these two are the final contenders. There is no point to compare frameworks if there are no specifications. So, I will lay down my specifications and hope to have some responses, would be valuable to people having questions on which framework they should choose.



Final Goal : Stock Chart just like Google Finance
Points of interest
1. No Flash, for mobile device compatibility
2. No Charge (HighCharts is cool if you have money)
3. Annotation on Chart, for marking events
4. Zoom in/ Zoom out
5. Multiple Y-axes



Where do you think?





JMeter JDBC Sampler extract more than one column values

I have a sql like the following in JDBC Sampler of JMeter



select id,code from table where .....


how do I extract the value of the two columns.





Ruby: Cryptographically sign a string to ensure authenticity?

Lets say I have a origin server which through the act of a redirect with particular query string params needs to provide details to a target server. However, I need to ensure those details came from my origin server only.



Also I can't sure the integrity of the target server. Or specifically, the target server might be compromised so any encryption keys might have been read by a malicious party.



I'm thinking I could sign the query string using some form of public/private keypair. The origin server uses a private key to sign the string, and the target server uses a public key to verify it came from my origin server, and the message hasn't been tampered with.



I'm far from a cryptography expert or anything, so any assumption here I've made might be wrong, please correct me if so :)



I'm basically after a (hopefully) simple way to do this in Ruby.





Incrementing elements in SWI-Prolog

Well, since I'm practising "the Prolog logic" today and I found this unanswered problem in another thread here, I was wondering how it works.




increment every element of list by its depth, example
increment([0,0,[0]],[1,1,[2]]) -> true




And I almost thought that I like this language... :))
Is something like that possible? Thanks.





Not connect to database

I am trying to insert record in database



but it showing error on database conect



Could not connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client





django unable to open database file

i am implementing a django web site,



the site goes to the hello world view:




http://ec2-107-20-20-19.compute-1.amazonaws.com/




views.py /home/ubuntu/djangoProj/micopiloto/portfolio



    # Create your views here.
from django.http import HttpResponse

def view(request):
return HttpResponse('Hello Worlsss9d!')

but i cannot see the amin site,
I see this error: unable to open database file

> http://ec2-107-20-20-19.compute-1.amazonaws.com/admin/

settings.py `/home/ubuntu/djangoProj/micopiloto`


# Django settings for micopiloto project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'thadb.db', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '2&g_&k=+^(0t)1xf82m^=#0u6v1e!)nn7ixq*+2^h%4$mwlrsm'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'micopiloto.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'portfolio'
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}


so i see the created thadb.db
in my project folder,



i have the error:



Exception Value:    
unable to open database file


so I have $sudo chmod 777 thadb.db



but still get the same error,



is this because of the permission?
should i set the folder to 777?



but i dont know how will the security be affected?



thanks!





Intermediate code generator for Java

is there a tool for generating intermediate code for java files?Or are there any resources that could help in generating one?Thanks.





Why is a bad practice to distribute the Debug version of the application in .NET?

Reading this question, in the first comment, @Cody Gray says:




Erm, you know that you're not supposed
to redistribute the "Debug" version,
right?




I'm concerned about it. In Visual Studio, I usually develop my applications in Debug mode, and if I need to distribute the executable, all I do is zip the .exe and required .dll files (in bin\Debug folder).



Why is it a bad idea?



What is the difference between doing this and doing exactly the equivalent thing in Release mode?



Edit:

I asked this question time ago, but I just wanted to edit it to add a difference:



When using Debug.Assert in the code to test it, and compile in Release Mode, all those lines are gone, so that could be another difference.





extracting theNamespace from the xml file

I am working on the XML files in C#.



I want to extact the name space and do some maniplations.



say my xml file looks like this.



        <Content xmlns="http://ABCD.com/sdltridion/schemas/XXXXX">
<first>ABCD</first>
<second>DCEF</second>
</Content>


I want to extract Xml namespace from the root tag, ang get the value of XXXXX.



Output needed: XXXXX



Can any one help regarding this.



Thank you.





Tuesday, April 24, 2012

mixed-type, variable length argument list (varargin, *args, ...) for C++

I am building a C++ clone of a project originally written in MATLAB. I'd like to "translate" the code keeping as close to the original as possible (given the unavoidable differences between a dynamically typed language like MATLAB and a statically typed language like C++).



My question is about variable length argument lists as function parameters which can contain arguments of mixed type.



MATLAB has varargin as a function parameter:



 varargin Variable length input argument list.
Allows any number of arguments to a function. The variable
varargin is a cell array containing the optional arguments to the
function. varargin must be declared as the last input argument
and collects all the inputs from that point onwards. In the
declaration, varargin must be lowercase (i.e., varargin).


In Python, *args and **kwargs handle this very comfortably.



How close can I get to this kind of flexibility in C++? Are there any standard argument list classes I should use?





How to change array index to start from 1?

How can I change my array's indices to start from 1 instead of 0. I am trying to fetch news from a site (JSON) and after parsing it:



@news = JSON.parse(Net::HTTP.get(URI.parse('http://api.site.com/news?format=json')))


But to see the individual news title, I have to do @news["items"][0] for the first link's title. Is it possible to change that behavior so when I do @news["items"][1] it shows me the first link's title?





Add an undo/redo method to core graphic draw app

I am trying to implement an undo/redo method using NSUndoManager. I have asked other questions on this, but am still stuck.



Where I am at the moment is as follows:



.h
NSUndoManager *undoManager;
@property(nonatomic,retain) NSUndoManager *undoManager;

.m
@synthesize undoManager;


[undoManager setLevelsOfUndo:99];
viewdidload:



NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];      
[dnc addObserver:self selector:@selector(undoButtonTapped) name:@"undo" object:nil];
[dnc addObserver:self selector:@selector(redoButtonTapped) name:@"redo" object:nil];

- (void)resetTheImage:(UIImage*)image
{
NSLog(@"%s", __FUNCTION__);

// image = savedImage.image;
if (image != drawImage.image)
{
[[undoManager prepareWithInvocationTarget:self] resetTheImage];
image = drawImage.image ;
} else {
NSLog(@"That didn't work");
}
}

- (void)undoButtonTapped {
NSLog(@"%s", __FUNCTION__);
[undoManager undo];
}


I get "That didn't work"...



I would appreciate help. I will post the answer to my original question when I figure out what I'm doing wrong.



---EDIT---



I have changed resetTheImage as follows:



- (void)resetTheImage:(UIImage*)image
{
NSLog(@"%s", __FUNCTION__);

image = savedImage.image;
if (image != drawImage.image)
{
drawImage.image = image;
savedImage.image = image;
NSLog(@"undo image");
[[self.undoManager prepareWithInvocationTarget:drawImage.image] image];

} else {
NSLog(@"same image");
savedImage.image = image;
}
}


However, confusion rains - it may help if someone (Brad?, Justin?) can provide a bullet point list of the steps I need to take to get this working. For example:



. Add notifications in ...
. Trigger notifications....
. Have undo /redo buttons point to...
. What methods/functions I really need to build..
....



I wish SO would allow me to give you more points than 1..



(It doesn't help that my "o" key is getting wonky)
It does help that I had a baby granddaughter yesterday :))))





ROC Curves Turorial

Guys I am looking for a third party software that applies classifiers (like SVM, multilayer perceptrons, I head libsvm is quite good) and also more important any tutorial about ROC Curves as I want to learn how to do them. The ones I found In google are not really helpful so if you know anything else that would be nice.





Android - assign and retrieve ID's dynamically

I know how to assing ID's dynamically by invoking setID(). For the ID's to be unique, I used to utilize ids.xml and pass to setID() ID's from the pre-generated pool of ID's.



Question 1: Is there any way to assign ID's without utilizing the ids.xml since I cannot participate how many ID's I will need in runtime?



I tried to by pass the first issue presented in Question 1 by dynamically assigning each of which an id based on its label's hash (each label is unique), but there is no way to gaurantee that ID's won't be colliding with ID's auto generated in R.java.



Question 1.1: How the ID naming collision can be resolved?



Question 2: Assume I have the ID value of which I assign and generate dynamically. Since the aformentioned ID does not appear in R.id, findViewById() won't be applicable for retrieving the view. Hence, how can the view be retrieved when the ID is known?





JQuery/Javascript and the use of && operators

I'm trying to get a simple conditional statement to work, and running into problems. The failing code:



    $(document).ready(function(){
var wwidth = $(window).width();

if (wwidth < 321) {
alert("I am 320 pixels wide, or less");
window.scrollTo(0,0);
} else if (wwidth > 321) && (wwidth < 481) {
alert("I am between 320 and 480 pixels wide")
}
});


If I remove the else if part of the code, I get the alert. If I try to use && or || operators it will fail. I've Googled, I can't find a reason why it's not working. I've also tried:



((wwidth > 321 && wwidth < 481))


along with other ways, just in case it's some odd syntax thing.



Any help would be greatly appreciated. Thanks :)





send simple data from wp7 to winforms application

I want to send simple data (geolocation data to be precise) from Windos Phone 7 application to a windows forms application and use it, as I'm a total beginner in this field I don't know which tools to use.
I searched about wcf services and tested this method but there's some issues: the data is sent from the phone application but isn't sent to the winforms application (guess something is missing)



If your know how to do this in a quick way, or have good tutorials I'll be thankful.





HTML5 getCurrentPosition with Meteor

I'm trying to use the html5 geolocation api with Meteor.
I'm using:
navigator.geolocation.getCurrentPosition(handle_geolocation_query); in my js but it doesn't seem to work - I think it may be related to the timer ( http://docs.meteor.com/#timers ) restrictions Meteor has. Any thoughts?





How to specialize a template member funcion depending on the class' template arguments?

I would like to write this:



template<typename T1, typename T2>
class OK
{
T1 t1;
T2 t2;

public:
template<typename TX> const TX & GetRef() const;
};

template<typename T1,typename T2>
template<>
const T1 & OK<T1,T2>::GetRef<T1>() const { return t1; }


Which VS10 fails to compile.



To check my understanding of template specialization, I tried and compiled this all right:



typedef int  T1;
typedef char T2;
class OK
{
T1 t1;
T2 t2;

public:
template<typename TX> const TX & GetRef() const;
};

template<>
const T1 & OK::GetRef<T1>() const { return t1; }


What am I missing ? Is what I want to do even possible ?





Liquibase Auto Rollback

I'm working on a branch and for instance need to delete a column in table X, I add a change and its good for that specific branch, then I switch to another branch that still requires that column and that change needs to be rolled back. There are a lot of changes to the db such as this from branch to branch.



I add a new changelog xml for every branch and include it in the master changelog xml. Obviously when I switch to another branch the changlog xml for the previous branch is no longer in the workspace and liquibase does not save the actual changeset in the database only its name and when it was applied, thus it won't be able to rollback changes automatically.



I'm using the Liquibase Servlet to apply changes on start up of my application.



Liquibase experts, is there an easy solution to this problem already implemented? Thank you!





Android SOAP NTLM example?

I've tried to google around for a working example. I've tried KSOAP2 and JCIFS examples but no success. The web service i'm trying to connect is 3rd parties (Microsoft Dynamics NAV) and can't be modified. It uses SOAP and either SPNEGO or NTLM authentication. And I guess it's already NTLMv2 but I'm not sure on that.
Can anybody please suggest me a full code for the following SOAP request?



$<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:item="urn:microsoft-dynamics-schemas/page/items">
$ <soapenv:Header/>
$ <soapenv:Body>
$ <item:ReadMultiple>
$ <!--1 or more repetitions:-->
$ <item:filter>
$ <item:Field>No</item:Field>
$ <item:Criteria>1000</item:Criteria>
$ </item:filter>
$ <item:setSize>500</item:setSize>
$ </item:ReadMultiple>
$ </soapenv:Body>
$</soapenv:Envelope>


I've validated this request with soapUI and it works fine. But when I tried to run it with KSOAP2 and JCIFS I get an error message "Connection refused".
Important to note I am a beginner in Java and Android.





Jquery how to animate a div ONLY if at a certain position?

hope your all well... Is there a way to animate a div (slide down) for example if its ONLY at a certain position on the page?
For example, there are four Divs that all have the same class .ALLCONTENT but when a button is clicked (.BUTTONS) only the Div thats at 30px from the top will animate downwards, the rest will remain in the same place.



Basically, slide down a div to a certain position, if that divs in that position already it wont slide further down (the problem im having now with



$(".BUTTONS").click(function(){
$(".ALLCONTENT").animate({"top":"+=558px"}, 250, 'linear');
});


Thanks, Tom





use of undeclared identifier 'isinf' error

My iOS project includes both C and C++ code (because I have integrated openCV).

Everything works fine as long as I don't include Mapkit.h. As soon as I include Mapkit.h I get the the following compile error:



Use of undeclared identifier 'isinf'


This error occurs in MKGeometry.h. I Google'ed around and the only thing I gathered is that the error has something to do with the fact that C++ has undefined isinf as a macro and declared it as a function in cmath.h.



I can't change MKGeometry.h (which is not a good idea, anyway) and I don't really want to change the standard headers (math.h or cmath.h) either. Is there a fix for this?



Many thanks for the help,





Retrieving javascript output from a form via php

I have a hidden field in a form where I'm trying to grab the users screen resolution. Then on the processing end retrieve the screen resolution via php. Unfortunately, my understanding of javascript is pretty limited. Here is what I have. I would really appreciate any help.



<head>
<script type="text/javascript">
function xy(){
document.write(screen.width + "x" + screen.height);
document.getElementById('xy').value;
}
</script>
</head>




<form action="" method=post >

//other fields here

<input type="hidden" name="xy" id="xy" value=""/>
<input type=submit name="button" value="button" />
</form>


When I view the page's source code, shouldn't I see the value set to for example "1366x768"? Now on the processing side, I would like to pull out information with php like this.



if(isset($_POST['xy']) && (!empty($_POST['xy'])){
$blah = $_POST['xy'];
//sanatize $blah;
}




Why can't I use a try block around my super() call?

So, in Java, the first line of your constructor HAS to be a call to super... be it implicitly calling super(), or explicitly calling another constructor. What I want to know is, why can't I put a try block around that?



My specific case is that I have a mock class for a test. There is no default constructor, but I want one to make the tests simpler to read. I also want to wrap the exceptions thrown from the constructor into a RuntimeException.



So, what I want to do is effectively this:



public class MyClassMock extends MyClass {
public MyClassMock() {
try {
super(0);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

// Mocked methods
}


But Java complains that super isn't the first statement.



My workaround:



public class MyClassMock extends MyClass {
public static MyClassMock construct() {
try {
return new MyClassMock();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public MyClassMock() throws Exception {
super(0);
}

// Mocked methods
}


Is this the best workaround? Why doesn't Java let me do the former?






My best guess as to the "why" is that Java doesn't want to let me have a constructed object in a potentially inconsistent state... however, in doing a mock, I don't care about that. It seems I should be able to do the above... or at least I know that the above is safe for my case... or seems as though it should be anyways.



I am overriding any methods I use from the tested class, so there is no risk that I am using uninitialized variables.





Values Disappearing in Form

Well, the below snippet contains the text fields that I am filling in, whose values are used later in the JavaScript function.These are contained in a form.



   <br/>
<br/>
<label for="rchange">Change in Rate : </label>
<input type="text" id="rchange" name="ratechange" />


//same as above for Change in Capacity, but with name=capachange

<br/>
<br/>
<label for="rev">Annual Revenue : </label>
<input type="text" id="rev" readonly />

<input type="submit" name="sub" value="Submit Form" onClick="calculateRevenue(this.form)" />


JavaScript function that calculates some value and places it in the text field called rev.



     function calculateRevenue(form) 
{
if (form.capachange.value == '')
{
alert('Please enter a value for the Change in Capacity field.');


}
if (form.ratechange.value == '')
{
alert('Please enter a value for the Change in Rate field. ');


}

else

{

form.rev.value=parseInt(form.capachange.value)+parseInt(form.ratechange.value);
}

}

</script>


The problem is when I submit the form, I get the correct value and then the contents of the fields filled in vanish after around 2 seconds. The same thing happen if I don't fill in the change in rate or change in capacity field, it gives the alert and then the value disappears. Any idea whats happening here? Im not even using 'refresh' anywhere. Thank you for your time.





Unit Testing the IoC container itself

I don't think this was asked before, although it's really hard to search for a term like unit test ioc container and not find a question about how to implement IoC in order to perform unit tests.



I would like to have unit tests against the IoC container itself basically because sometimes I have issues with the container (like you could with any other part of an application), and it's pretty troublesome to test the resolution of dependencies merely debugging.



If I could introduce unit tests for these cases, I think it would save me a lot of trouble.



Update



Is something like this, not an Unit Test? Is it an integration test?



[TestClass]
public class IoC
{
private IWindsorContainer _container;

[TestInitialize]
public void TestInit()
{
_container = new WindsorContainer();
_container.Install(new WindsorInstaller());
}

[TestMethod]
public void ContainerShouldResolve_MembershipProvider()
{
ContainerShouldResolve<IMembershipProvider>();
}

public void ContainerShouldResolve<T>()
{
T result = _container.Resolve<T>();
Assert.IsInstanceOfType(result, typeof(T));
}
}


The only real "not self-contained" reference is a connection string I had to wire into app.config. Also: when trying to resolve PerWebRequest lifestyle components I had to add the related httpModule, too.



By the way: by doing this I found out the source of my issue in little time compared to what it was taking me to debug it through using the web application.





How do different apps written in different languages interact?

Off late I'd been hearing that applications written in different languages can call each other's functions/subroutines. Now, till recently I felt that was very natural - since all, yes all - that's what I thought then, silly me! - languages are compiled into machine code and that should be same for all the languages. Only some time back did I realise that even languages compiled in 'higher machine code' - IL, byte code etc. can interact with each other, the applications actually. I tried to find the answer a lot of times, but failed - no answer satisfied me - either they assumed I knew a lot about compilers, or something that I totally didn't agree with, and other stuff...Please explain in an easy to understand way how this works out. Especially how languages compiled into 'pure' machine code have different something called 'calling conventions' is what is making me clutch my hair.
Thanks!





How to define x++ (where x: int ref) in F#?

I currently use this function



let inc (i : int ref) =
let res = !i
i := res + 1
res


to write things like



let str = input.[inc index]


How define increment operator ++, so that I could write



let str = input.[index++]




Implementing search into mediaplayer

ok i have a mediaplayer app tht works perfect. ive been trying to implement a search feature into it. like take user input words query them and match and find songs on the sd card. anyone wanna help as im completely lost





Monday, April 23, 2012

Grey to Binary Image using R

Is there any R function to convert grey scale image to binary image. There is one to convert from RGB to Grey but I want to convert Grey to Binary.





ZendFramework, using same variable twice causing null value

Hi I have a application where I have a list of clubs once the club is clicked it goes to a description page of this club by passing the variable "club_id" and then getting the information for that specific club. On this page is a comments box, at the moment If I click the comment button I get the data I need in the comments box but then when trying to redirect to the index page I get the error below:



Error -> http://pastebin.com/VscHSGXF



clubDescriptionController:



public function indexAction()
{
$this->authoriseUser();
//get id param from index.phtml (view)
$id = $this->getRequest()->getParam('club_id');
//get model and query by $id
$clubs = new Application_Model_DbTable_Clubs();
$clubs = $clubs->getClub($id);
//assign data from model to view [EDIT](display.phtml)
$this->view->clubs = $clubs;

$form = new Application_Form_Comment();
$form->submit->setLabel('Comment');
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$comment = new Application_Model_DbTable_Comments();
$comment->addComment($formData['comment'], $id);
$this->_helper->redirector('index');
} else {
$form->populate($formData);
}
}
}


Comment form:



<?php

class Application_Form_Comment extends Zend_Form
{

public function init()
{
$this->setName('comment');
$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int');
$comment = new Zend_Form_Element_Text('comment');
$comment->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($id, $comment, $submit));
}
}


Comments model:



<?php

class Application_Model_DbTable_Comments extends Zend_Db_Table_Abstract
{

protected $_name = 'comments';

public function getComment($id) {
$id = (int) $id;
$row = $this->fetchRow('id = ' . $id);
if (!$row) {
throw new Exception("Count not find row $id");
}
return $row->toArray();
}

public function addComment($comment, $club_id) {
$data = array(
'comment' => $comment,
'club_id' => $club_id,
'comment_date' => new Zend_Db_Expr('NOW()'),
);
$this->insert($data);
}

public function deleteComment($id) {
$this->delete('id =' . (int) $id);
}
}


ClubDescription Index.phtml:



<div id="comments-holder">
<p id="comments-title">Comments</p>
<?php echo $this->form; ?>
</div>


Thanks



Rik





soap-response: is Content-Length required in http-header?

I didn't found a answer to this in w3.org.



Almost all examples include the content length in the soap-response http-header.



first Q:
But is it technically necessary?



i am struggling with an soap-service where the php-soap-library is setting the right content length of the response xml, but lighttpd afterwards is compressing the content, and so i am getting a smaller response than the content length.



And some applications like soapUI is waiting for alle the content (set by the http-header) to arrive.



second Q:




  • Who is behaving/configured wrong in this chain? php -> lighttpd -> soapUI

  • is it the php-code

  • which sets the unzipped content-length?

  • is it lighttpd which compresses the response, but doesn't override or delete the
    content-length header?

  • Or is it soapUI, which shouldn't wait 15sec for further content?





How to check whether a website deployed in IIS 6.1 is being access by user or not?

We have deployed 5 website (read only data) in IIS 6.1 on last month now we want to remove those website which are not acceses/used by used. We have total 10 website on IIS 6.1.





GUI programming in java for Windows?

Can someone tell me what is the best approach for making GUI applications for windows with JAVA ? is it AWT and SWING ? Or is it outdated?





How to check the connection state of a TCP Server (Socket) with TCP Client in VB.NET

For almost a week I am reading and trying to find a solution for checking connection state using a TCP Client (using socket class)
In my scenario I have a TCP Client that is connected to a server (it is not controlled by me) and i want that from time to time to check the connection state, and reconnect if necessary.
I have read a lot of information on the internet but i did not find a suitable solution.



Briefly, these are the methods that i have found on the internet and try to implement.
But unfortunatelly, i have found some scenarios where the TCP Server is closed and the TCP Client is still saying Connected



May i kindly ask someone that have encountered this issue to help me?



1.Example from MSDN



Private Function IsConnected(tcpSocket As Socket) As Boolean
Dim blockingState As Boolean = tcpSocket.Blocking
IsConnected = False
Try
Dim tmp(0) As Byte
tcpSocket.Blocking = False
tcpSocket.Send(tmp, 0, 0)
Return True
Catch e As SocketException
If e.NativeErrorCode.Equals(10035) Then
Return True
Else : Return False
End If
ThrowError(e)
Finally
tcpSocket.Blocking = blockingState
End Try
End Function


2.Example using Poll



Function Connected() As Boolean
Connected = False
If (tcpSocket.Connected) Then
If ((tcpSocket.Poll(0, SelectMode.SelectWrite)) AndAlso (Not tcpSocket.Poll(0, SelectMode.SelectError))) Then
Dim b As Byte() = New Byte(1) {}
If tcpSocket.Receive(b, SocketFlags.Peek) = 0 Then
Return False
Else : Return True
End If
Else
Return False
End If
Else
Return False

End If
End Function


3.Using Poll



Private Function Connect2() As Boolean
Connect2 = False
If tcpSocket.Poll(0, SelectMode.SelectRead) = True Then
Dim byteArray As Byte() = New Byte(1) {}
If (tcpSocket.Receive(byteArray, SocketFlags.Peek)) = 0 Then Connect2 = True
End If
Return Connect2()
End Function