Tuesday, May 8, 2012

Internet Explorer Local Storage

I have a application which works great on all browsers but IE. I am using the local database provided with HTML5. I need to store 3 attributes for the users of the application. I know in IE I can't use the database approach and I was thinking of using 3 arrays stored in local storage, one array for each attribute. Is there a better (and easier) way of doing this?



Thanks



For example, I want to store 1) destination 2) where they are from 3) date
So I was thinking I will store an array for destinations, an array fro from locations and an array for dates. Then using some id I can index the arrays and get the corresponding information.





Partially missing gridlines on log-scale charts in Excel 2007

I'm using Excel 2007 to create a log-scale chart of numbers (specifically the Zimbabwean dollar exchange rate) over time. I'm using an x-y scatterplot and noticing one odd quirk.



The range of y values (numbers) spans a factor of about 10^30. On every chart I make using this data, half the gridlines are missing. Specifically, only the gridlines corresponding to the largest values show up. In fact, regardless of the total range only the top factor of 10^13 or so have gridlines. This is not dependent on the log base.



Am I doing something wrong? Is this a known bug? I can't find any references to this issue on google or microsoft's bug reports.





Selenium Testing in Hudson question

I'm having some trouble running a simple selenium test through Hudson.



I've installed the SeleniumHQ plugin for Hudson and configured a job to run a simple test suite which consists of two tests which run fine from the Selenium IDE and from the TestNG plugin in Eclipse.



However, when I try to run them through Hudson, the testing just seems to stall at the end of the first test (regardless of which test it is, I've tried many different ones which are all valid when ran in other enviornments).



The Console Output from Hudson reads as follows:




11:48:09.543 INFO - Java: Sun Microsystems Inc. 14.2-b01
11:48:09.544 INFO - OS: Windows Vista 6.0 x86
11:48:09.559 INFO - v1.0.1 [2696], with Core v@VERSION@ [@REVISION@]
11:48:09.655 INFO - Version Jetty/5.1.x
11:48:09.656 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
11:48:09.657 INFO - Started HttpContext[/selenium-server,/selenium-server]
11:48:09.657 INFO - Started HttpContext[/,/]
11:48:09.670 INFO - Started SocketListener on 0.0.0.0:4444
11:48:09.670 INFO - Started org.mortbay.jetty.Server@c40c80
11:48:09.825 INFO - Preparing Firefox profile...
11:48:12.046 INFO - Launching Firefox...
11:48:12.919 INFO - Checking Resource aliases


The strange thing is, I can see the first test being ran, and it passes but selenium then doesnt skip onto the next one, and if I create a test suite with just the one test, it simply hangs there indefinitely. Please note that I have an AssertVisible action in the test to check the validity of the results. Do I need to return anything else for Hudson to run the test properly?



Thanks in advance for any help on this...





Linux /media folder not showing all disk drives

If I use terminal, I can only see drives that I recently worked with. How can I access all drives like usb and also others?Is /media folder the right place to search for drives?





Failed to export android application (Eclipse)

I updated my Eclipse to the new version, and now I can't export my signed applications.
Below is the error report:



eclipse.buildId=M20110909-1335
java.version=1.6.0_26
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=hr_HR
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

Error
Wed Dec 14 15:58:02 CET 2011
Failed to export application

Command-line Error 2
Output:
ERROR: Unknown command 'crunch'
Android Asset Packaging Tool

Usage:
aapt l[ist] [-v] [-a] file.{zip,jar,apk}
List contents of Zip-compatible archive.

aapt d[ump] [--values] WHAT file.{apk} [asset [asset ...]]
badging Print the label and icon for the app declared in APK.
permissions Print the permissions from the APK.
resources Print the resource table from the APK.
configurations Print the configurations in the APK.
xmltree Print the compiled xmls in the given assets.
xmlstrings Print the strings of the given compiled xml assets.

aapt p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] \
[-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] \
[--debug-mode] [--min-sdk-version VAL] [--target-sdk-version VAL] \
[--app-version VAL] [--app-version-name TEXT] [--custom-package VAL] \
[--rename-manifest-package PACKAGE] \
[--rename-instrumentation-target-package PACKAGE] \
[--utf16] [--auto-add-overlay] \
[--max-res-version VAL] \
[-I base-package [-I base-package ...]] \
[-A asset-source-dir] [-G class-list-file] [-P public-definitions-file] \
[-S resource-sources [-S resource-sources ...]] [-F apk-file] [-J R-file-dir] \
[--product product1,product2,...] \
[raw-files-dir [raw-files-dir] ...]

Package the android resources. It will read assets and resources that are
supplied with the -M -A -S or raw-files-dir arguments. The -J -P -F and -R
options control which files are output.

aapt r[emove] [-v] file.{zip,jar,apk} file1 [file2 ...]
Delete specified files from Zip-compatible archive.

aapt a[dd] [-v] file.{zip,jar,apk} file1 [file2 ...]
Add specified files to Zip-compatible archive.

aapt v[ersion]
Print program version.

Modifiers:
-a print Android-specific data (resources, manifest) when listing
-c specify which configurations to include. The default is all
configurations. The value of the parameter should be a comma
separated list of configuration values. Locales should be specified
as either a language or language-region pair. Some examples:
en
port,en
port,land,en_US
If you put the special locale, zz_ZZ on the list, it will perform
pseudolocalization on the default locale, modifying all of the
strings so you can look for strings that missed the
internationalization process. For example:
port,land,zz_ZZ
-d one or more device assets to include, separated by commas
-f force overwrite of existing files
-g specify a pixel tolerance to force images to grayscale, default 0
-j specify a jar or zip file containing classes to include
-k junk path of file(s) added
-m make package directories under location specified by -J
-u update existing packages (add new, replace older, remove deleted files)
-v verbose output
-x create extending (non-application) resource IDs
-z require localization of resource attributes marked with
localization="suggested"
-A additional directory in which to find raw asset files
-G A file to output proguard options into.
-F specify the apk file to output
-I add an existing package to base include set
-J specify where to output R.java resource constant definitions
-M specify full path to AndroidManifest.xml to include in zip
-P specify where to output public resource definitions
-S directory in which to find resources. Multiple directories will be scanned
and the first match found (left to right) will take precedence.
-0 specifies an additional extension for which such files will not
be stored compressed in the .apk. An empty string means to not
compress any files at all.
--debug-mode
inserts android:debuggable="true" in to the application node of the
manifest, making the application debuggable even on production devices.
--min-sdk-version
inserts android:minSdkVersion in to manifest. If the version is 7 or
higher, the default encoding for resources will be in UTF-8.
--target-sdk-version
inserts android:targetSdkVersion in to manifest.
--max-res-version
ignores versioned resource directories above the given value.
--values
when used with "dump resources" also includes resource values.
--version-code
inserts android:versionCode in to manifest.
--version-name
inserts android:versionName in to manifest.
--custom-package
generates R.java into a different package.
--auto-add-overlay
Automatically add resources that are only in overlays.
--rename-manifest-package
Rewrite the manifest so that its package name is the package name
given here. Relative class names (for example .Foo) will be
changed to absolute names with the old package so that the code
does not need to change.
--rename-instrumentation-target-package
Rewrite the manifest so that all of its instrumentation
components target the given package. Useful when used in
conjunction with --rename-manifest-package to fix tests against
a package that has been renamed.
--product
Specifies which variant to choose for strings that have
product variants
--utf16
changes default encoding for resources to UTF-16. Only useful when API
level is set to 7 or higher where the default encoding is UTF-8.
--non-constant-id
Make the resources ID non constant. This is required to make an R java class
that does not contain the final value but is used to make reusable compiled
libraries that need to access resources.
at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeAapt(BuildHelper.java:887)
at com.android.ide.eclipse.adt.internal.build.BuildHelper.updateCrunchCache(BuildHelper.java:161)
at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:131)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:290)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:229)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:214)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)


Yesterday everything was fine, but today after the update it doesn't work anymore.





is UIScrollView or a UIWebView the better solution for this?

I am spec'ing out an iOS app and there is a piece that is a run-on section that will need to scroll. I was thinking of doing it as a UIScrollView (have never used one but seems logical) but it sounds like the contentSize always needs to be calculated. This could be extremely variable in this case (UGC images etc...). Is this correct? Or is there a legitimate workaround? If not, would a UIWebView be the better solution?



The app functionality would be like a FB feed or Instagram. Is it known what they use (FB looks like UIWebView to me).



thx





Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\

Hi I keep getting this error, and I changed the sendmail in the php.ini to:
sendmail_from = 12343OHBS@gmail.com



  $to='12343OHBS@gmail.com';//assigns the email address to the reciever part of the script
$subject='User Comments OHBS.com';
$header='test';
$name=($_POST['Name']);
$email=($_POST['Email']);
$Question=($_POST['MessageTitle']);
// the mail, the .= function is used to add more elements to the message array
$message="Name: $name\n\n";
$message.="Email: $email\n\n";
$message.="Comment or Question: $Question";
//Wordwrap to limit each line to 100 characters
$message=wordwrap($message, 100);
//Script to send the mail
$mailSent=mail($to,$header,$subject,$message);


Please help!





Way to Remove Invite Limit on FBML Multi-Friend Selector

I tried to look through various resources before posting here, but was having a surprisingly difficult time finding an answer to my question. Sorry in advance if I overlooked it.



I'm currently trying to add the FBML Multi-Friend Selector to my Facebook page. It has a limit on the number of friends you can invite at a time ("Add up to 20 of your friends by clicking on their pictures below"). From what I've looked through it sounds like 20 is the max number of friends a user can invite, but then looking at Mint's page, they have a 22 max invite (http://www.facebook.com/mint?ref=ts)



I thought it might be based on number of page fans, as Mint has 56,000, but that doesn't seem to be the case as this page only has 256 fans and have a max of 26 friend invites (http://www.facebook.com/tivix?v=app_106437999388442).



Therefore, I don't really understand how this system works. Is there a way for me to increase to 26? Unlimited?



Thanks for your help!





How to Using ContainsAll in Mongodb

Help me



var query =
collection.AsQueryable<C>()
.Where(c => c.A.ContainsAll(new[] { 1, 2, 3 }));


Error

int does not contain a definition for ContainsAll and the best extension method overload MongoDB.Driver.Linq.LinqToMongo.ContainsAll(System.Collections.Generic.IEnumerable)





Comparing a byte value with a bytea column in postgresql

I am using PostgreSQL as my database and java servlet to communicate with PostgreSQL. My application requires that I fetch data from database for a matching input file. All the files are stored in the database in a bytea column. This is my code:



String checkdb="select * from key where certificate = '"+c+"';";
Statement stcheck=conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet newrs=stcheck.executeQuery(checkdb);
newrs.last();
int rowcount=newrs.getRow();
if(rowcount!=0)
throw new ArithmeticException();


where certificate is the name of the column containing the bytea data and c (uploaded) is a certificate in byte[] form. So here I am checking if the uploaded certificate is already present in the database. If it is present then I am throwing an exception.



But the problem is uploading the same certificate multiple times is not throwing an exception is working as if the two certificates are different.



Am I comparing the byte values correctly. What should I do to correct this?

EDIT

I tried setting the certificate column as the primary key. But still the certificate gets inserted into the database. How could this happen? The internal comparison also fails for some reason.

EDIT

I tried retrieving a ile and converted it to string :



InputStream input13 = retrs.getBinaryStream("certificate");
ByteArrayOutputStream output13 = new ByteArrayOutputStream();
byte buf[]=new byte[1024];
int len;
IOUtils.copy(input13, output13);
input13.close();
byte[] retvalue=output13.toByteArray();
String s1=new String(retvalue);

String s2=new String(c);
System.out.println("in--------------"+s2);


System.out.println("out----------------"+s1);



retrs is the result set containing the just stored certificate. c is the input certificate in byte[]. The out put that I get is:



19:05:43,156 INFO  [STDOUT] in-------------------BEGIN CERTIFICATE-----
MIICIjCCAYsCAQMwDQYJKoZIhvcNAQEFBQAwYTELMAkGA1UEBhMCYXMxCzAJBgNV
BAgMAmFzMQswCQYDVQQHDAJhczELMAkGA1UECgwCYXMxCzAJBgNVBAsMAmFzMQsw
CQYDVQQDDAJjYTERMA8GCSqGSIb3DQEJARYCYXMwHhcNMTIwNDEwMDY0ODQ3WhcN
MTMwNDEwMDY0ODQ3WjBSMQswCQYDVQQGEwJhczELMAkGA1UECBMCYXMxCzAJBgNV
BAcTAmFzMQswCQYDVQQKEwJhczELMAkGA1UECxMCYXMxDzANBgNVBAMTBmNsaWVu
dDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsfJq9TVgTLqz84nuWpDm+dvI
do2HIWoHkmEPNowK4xn1+qWUPCy30aASWI92YMtE6njtQGyZBYij0iTAxldDktqd
bMdpKAONDlSv71rn+fZPuyenbBFYZexybNVsRMFzTD/F/hiPPXT7E1j9CrgIMxVz
ScZeNATh/dPLwuNQ0dsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQDDUyeIWlKaMMkM
8VRGuDJyKFC8miQfmul6zE4+6RTswHKjcUoje2vhTQgV+GBfqx8ai+ziujx8CeyR
eJWcb1G8gg+LMUNDcTOlXTeBG9L2c/gMOEu7BEjtpojSYmFyEvJEQ5Yep44HKZZb
FSPFVNxGiXBhNxtKQdAu6/smQ/eBNg==
-----END CERTIFICATE-----
19:05:43,156 INFO [STDOUT] out----------------[B@17f8b39




AUGraphInitialize an error code -10868 when adding kAudioUnitSubType_Reverb2 to AUGraph

I'm attempting to add an AudioUnit of type kAudioUnitSubType_Reverb2 to an AUGraph and am getting a -10868 (kAudioUnitErr_FormatNotSupported) supported error on AUGraphInitialize. My starting point was Apple's iPhoneMixerEQGraphTest sample app, I've basically just added a new AudioUnit for the reverb but cannot get it to work.



Here is the code -



- (void)initializeAUGraph
{
printf("initializeAUGraph\n");

AUNode outputNode;
AUNode eqNode;
AUNode mixerNode;
AUNode reverbNode;

printf("create client ASBD\n");

// client format audio goes into the mixer
mClientFormat.SetCanonical(2, true);
mClientFormat.mSampleRate = kGraphSampleRate;
mClientFormat.Print();

printf("create output ASBD\n");

// output format
mOutputFormat.SetAUCanonical(2, false);
mOutputFormat.mSampleRate = kGraphSampleRate;
mOutputFormat.Print();

OSStatus result = noErr;

// load up the audio data
[self performSelectorInBackground:@selector(loadFiles) withObject:nil];

printf("new AUGraph\n");

// create a new AUGraph
result = NewAUGraph(&mGraph);
if (result) { printf("NewAUGraph result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

// create three CAComponentDescription for the AUs we want in the graph

// output unit
CAComponentDescription output_desc(kAudioUnitType_Output, kAudioUnitSubType_RemoteIO, kAudioUnitManufacturer_Apple);

// iPodEQ unit
CAComponentDescription eq_desc(kAudioUnitType_Effect, kAudioUnitSubType_AUiPodEQ, kAudioUnitManufacturer_Apple);

// multichannel mixer unit
CAComponentDescription mixer_desc(kAudioUnitType_Mixer, kAudioUnitSubType_MultiChannelMixer, kAudioUnitManufacturer_Apple);

// reverb unit
CAComponentDescription reverb_desc(kAudioUnitType_Effect, kAudioUnitSubType_Reverb2, kAudioUnitManufacturer_Apple);

printf("add nodes\n");

// create a node in the graph that is an AudioUnit, using the supplied AudioComponentDescription to find and open that unit
result = AUGraphAddNode(mGraph, &output_desc, &outputNode);
if (result) { printf("AUGraphNewNode 1 result %lu %4.4s\n", result, (char*)&result); return; }

result = AUGraphAddNode(mGraph, &eq_desc, &eqNode);
if (result) { printf("AUGraphNewNode 2 result %lu %4.4s\n", result, (char*)&result); return; }

result = AUGraphAddNode(mGraph, &mixer_desc, &mixerNode);
if (result) { printf("AUGraphNewNode 3 result %lu %4.4s\n", result, (char*)&result); return; }

result = AUGraphAddNode(mGraph, &reverb_desc, &reverbNode);
if (result) { printf("AUGraphNewNode 4 result %lu %4.4s\n", result, (char*)&result); return; }

// connect a node's output to a node's input
// mixer -> eq -> output
result = AUGraphConnectNodeInput(mGraph, mixerNode, 0, eqNode, 0);
if (result) { printf("AUGraphConnectNodeInput result %lu %4.4s\n", result, (char*)&result); return; }

result = AUGraphConnectNodeInput(mGraph, eqNode, 0, reverbNode, 0);
if (result) { printf("AUGraphConnectNodeInput result %lu %4.4s\n", result, (char*)&result); return; }

result = AUGraphConnectNodeInput(mGraph, reverbNode, 0, outputNode, 0);
if (result) { printf("AUGraphConnectNodeInput reverb result %lu %4.4s\n", result, (char*)&result); return; }

// open the graph AudioUnits are open but not initialized (no resource allocation occurs here)
result = AUGraphOpen(mGraph);
if (result) { printf("AUGraphOpen result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

// grab the audio unit instances from the nodes
result = AUGraphNodeInfo(mGraph, mixerNode, NULL, &mMixer);
if (result) { printf("AUGraphNodeInfo result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

result = AUGraphNodeInfo(mGraph, eqNode, NULL, &mEQ);
if (result) { printf("AUGraphNodeInfo result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

result = AUGraphNodeInfo(mGraph, reverbNode, NULL, &mReverb);
if (result) { printf("AUGraphNodeInfo reverb result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

// set bus count
UInt32 numbuses = 2;

printf("set input bus count %lu\n", numbuses);

result = AudioUnitSetProperty(mMixer, kAudioUnitProperty_ElementCount, kAudioUnitScope_Input, 0, &numbuses, sizeof(numbuses));
if (result) { printf("AudioUnitSetProperty result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

for (int i = 0; i < numbuses; ++i) {
// setup render callback struct
AURenderCallbackStruct rcbs;
rcbs.inputProc = &renderInput;
rcbs.inputProcRefCon = &mUserData;

printf("set AUGraphSetNodeInputCallback\n");

// set a callback for the specified node's specified input
result = AUGraphSetNodeInputCallback(mGraph, mixerNode, i, &rcbs);
if (result) { printf("AUGraphSetNodeInputCallback result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

printf("set input bus %d, client kAudioUnitProperty_StreamFormat\n", i);

// set the input stream format, this is the format of the audio for mixer input
result = AudioUnitSetProperty(mMixer, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, i, &mClientFormat, sizeof(mClientFormat));
if (result) { printf("AudioUnitSetProperty result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }
}

printf("get EQ kAudioUnitProperty_FactoryPresets\n");

// get the eq's factory preset list -- this is a read-only CFArray array of AUPreset structures
// host owns the retuned array and should release it when no longer needed
UInt32 size = sizeof(mEQPresetsArray);
result = AudioUnitGetProperty(mEQ, kAudioUnitProperty_FactoryPresets, kAudioUnitScope_Global, 0, &mEQPresetsArray, &size);
if (result) { printf("AudioUnitGetProperty result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

/* this code can be used if you're interested in dumping out the preset list
printf("iPodEQ Factory Preset List:\n");
UInt8 count = CFArrayGetCount(mEQPresetsArray);
for (int i = 0; i < count; ++i) {
AUPreset *aPreset = (AUPreset*)CFArrayGetValueAtIndex(mEQPresetsArray, i);
CFShow(aPreset->presetName);
}*/

printf("set output kAudioUnitProperty_StreamFormat\n");

// set the output stream format of the mixer
result = AudioUnitSetProperty(mMixer, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &mOutputFormat, sizeof(mOutputFormat));
if (result) { printf("AudioUnitSetProperty result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

printf("set render notification\n");

// add a render notification, this is a callback that the graph will call every time the graph renders
// the callback will be called once before the graph's render operation, and once after the render operation is complete
result = AUGraphAddRenderNotify(mGraph, renderNotification, &mUserData);
if (result) { printf("AUGraphAddRenderNotify result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }

printf("AUGraphInitialize\n");

// now that we've set everything up we can initialize the graph, this will also validate the connections
result = AUGraphInitialize(mGraph);
if (result) { printf("AUGraphInitialize result %ld %08X %4.4s\n", result, (unsigned int)result, (char*)&result); return; }
// ---- result here is error code 10868

CAShow(mGraph);
}




Confusion about superclass references and subclass objects

I have some questions about this code:



class superclass
{
p.bark()
}

class subclass extends superclass
{
p.bark
}

{
p.s.v.m()
superclass refvar = new subclass();
p.bark();
}



  1. Why is it necessary for the parent to have a method in this case, whether the child has it or not? I am told that at compile time the reference variable is of superclass type, so the compiler checks for this method in the superclass at compile time; is that accurate?


  2. When the compiler reads p.bark(), how does it know where to go next? I know the child method overrides it, but I want to know that first it goes to the superclass method or subclass, and why.


  3. Why does the subclass need to have an access modifier of wider scope?






EF CF 4.2 and SQL Instead of insert trigger

I have a CF class:



public class A
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id {get;set;}
[Required]
public string Name {get;set;}
public string LoweredName {get;set;}
[Timestamp]
public byte[] RowVersion {get;set;}
}


In the database i have a trigger:



CREATE TRIGGER IOI_LoweredName
ON Abc
INSTEAD OF INSERT
AS;
BEGIN;
SET NOCOUNT ON;

INSERT INTO Abc(Name, LoweredName) SELECT Name, LOWER(Name) FROM inserted
END;


Now if i try to insert a record:



dc.Names.Add(new A { Name = "Test" });
dc.SaveChanges();


I get the following error:



Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.


Any ideas how to get around this?
All my classes inherit from a base class that has the RowVersion (Timestamp) column. Can't i use such a simple trigger with EF when using concurrency on a timestamp field ?



Updated



There is a primary key (also added it to the example above).



Update 2



This is from the SQL Profiler:



declare @0 nvarchar(100)
set @0=N'Test'
insert [dbo].[abc]([Name], [LoweredCompanyName]) values (@0, null)
select [Id], [RowVersion] from [dbo].[Abc] where @@ROWCOUNT > 0 and [Id] = scope_identity()


Problem is that the select doesn't return anything.





How to perform leet with Python?

I have a lists of words in a text file which I would like to perform leet on every word. That is for example if I have the word 'Hello', this will change to '5E11O'. In other words the program should be able to automatically replace every letter in a word.



Is this possible please? Thanks





Android: ArrayAdapter getView() method is not executed

In My Project I have to display a list of reports. So In Activity page I write the following code



super.onCreate(savedInstanceState);
setContentView(R.layout.report_full);
List<Employee> data = new ArrayList<Employee>();
Employee eg=new Employee();
ListView li=(ListView)findViewById(R.id.report_list);
Intent myIntent = getIntent(); // this is just for example purpose
Bundle b=myIntent.getExtras();
Log.i("User Report", b.toString());
Toast.makeText(getApplicationContext(), "User Report", Toast.LENGTH_LONG).show();
if(b !=null)
{
String username = b.getString("username");
String userid = b.getString("userid");
String startdate = b.getString("startdate");
String enddate = b.getString("enddate");
String mode=b.getString("mode");
Log.i("LOOP", userid+"-"+startdate+"-"+enddate+"-"+mode);
data=eg.getTimeEntryUserReports(username, userid, startdate, enddate,mode);
Log.i("Get Report",data.toString());
li.setAdapter(new UserReportArrayadapter(this, data));
}


And In UserReportArrayadapter.java , I write the following code,



    private LayoutInflater inflater;
private List<EmployeeGlobal> data;
public UserHoursByReportArrayadapter(Context context, List<EmployeeGlobal> objects) {
super(context, R.layout.list_time_mode_report, objects);
Log.i("User Report by HoursAdapter","Inside constructor");
inflater = LayoutInflater.from(context);
this.data = objects;
}

@Override
public int getCount() {
// TODO Auto-generated method stub
return 1;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
Log.i("User Report by HoursAdapter","Inside getView");
//if it's not create convertView yet create new one and consume it
if(convertView == null){
//instantiate convertView using our employee_list_item
convertView = inflater.inflate(R.layout.list_time_mode_report, null);
//get new ViewHolder
holder =new ViewHolder();
//get all item in ListView item to corresponding fields in our ViewHolder class
holder.project=(TextView)convertView.findViewById(R.id.time_entry_1);
holder.hours=(TextView)convertView.findViewById(R.id.time_entry_2);

//set tag of convertView to the holder
convertView.setTag(holder);
}
//if it's exist convertView then consume it
else {
holder =(ViewHolder) convertView.getTag();
}
//set data to holder
Log.i("User Report by HoursAdapter:data",data.get(position).getData());
holder.project.setText(data.get(position).getData());
holder.hours.setText(data.get(position).getNo_of_hrs());

return convertView;
}
//ViewHolder class that hold over ListView Item
static class ViewHolder{
TextView hours;
TextView project;


}


On Running this application, there is no items displayed in screen. And I have noticed that getView() method is not being called.
Please provide me the solution for this problem





C++ Namespace Functions

I am a Java developer and I am pretty new to C++. I need to implement some kind of utility class, and I was thinking of implementing the methods as static. However, I came across to this stackoverflow question about namespace functions vs static method, and apprently namespace functions is preferred approach. So I would like to konw if there is any article or example on how to implement namespace function. E.g, how should I declare namespace functions in header file? Should header only contain function definitions like class header file and implementations should be in cpp file, or should I straight away implement functions in header file?



Basically, I am trying to implement an application to parse a text file that contains so commands. So I am thinking of implementing static helper methods to handle text processing. E.g readCommand(string line). Please let me know if I am in the wrong direction. Thanks





could someone help me with my ereg_replace converted to preg_replace

I just need a bit of help with my ereg_replace changed to preg_replace..



ereg_replace('<caption.*</caption>', '', $match);


and I've tried



preg_replace('/<caption.*</caption>/', '', $match);


but it doesn't work.. and it says "Warning: preg_replace(): Unknown modifier 'c'"



I'm new to this kinda thing.. so any help would be appreciated :)





Creating Back Order from Invoice using SQL queries in Dynamics GP 2010

I have a task of creating Duplicate Order.
means i have to create back order from invoice for the items already in invoice using direct db manipulations(sql queries).



does anybody have any idea how to do it?





Extending/overriding in JavaScript?

I want to write a small game using JavaScript and <canvas> but first I want to nail the "correct" or at least common approach to working with Objects.



One topic I am having trouble understanding in particular is how I could implement overriding of method.



When I create an Object, I may have this:



function MyObject()
{
var base = {};

base.i = 0;
base.update = function()
{
base.i ++;
}

return base;
}


Then when I create another Object that should start with the same members, I use this:



function AnotherObject()
{
var base = new MyObject();

base.j = 0;

return base;
}


I want to add more content to AnotherObject.update() while still running the logic I have in MyObject.update(), but when I do this within AnotherObject():



base.update = function()
{
j ++;
}


Then I of course lose the logic I added in MyObject.update().



How can I write AnotherObject.update() so that it also calls the original update() method defined by MyObject?





What objects should not be spring managed?

What objects should not be managed by spring containers ? To my understanding, data transfer objects need not be spring managed and can be created with new operator... but is there a generic rule and reasoning which i can follow while developing web applications...





How to send HttpPost of a list item and a spinner and a checkbox collectively

I have a ListView ,checkbox and spinner in one layout , and on different layout i have called the listview item by parsing it from xml. how to send collectively the value of checkbox , spinner and the list view item names by using http post
I want the detail code for explanation.



Here is my activity where i have parsed into xml and declared it into listview



public class Hut extends ListActivity {


static final String URL = "http://192.168.1.112/andro/index.php/androctrl/provider_detail/";

// XML node keys
static final String KEY_ITEM = "element"; // parent node
static final String KEY_ID = "foodjoint_id";
static final String KEY_NAME = "foodjoint_name";
static final String KEY_LAT = "foodjoint_latitude";
static final String KEY_DESC = "foodjoint_description";


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pizzahut);



ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();

XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL); // getting XML
Document doc = parser.getDomElement(xml); // getting DOM element

NodeList nl = doc.getElementsByTagName(KEY_ITEM);
// looping through all item nodes <item>
for (int i = 0; i < nl.getLength(); i++) {
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) nl.item(i);
// adding each child node to HashMap key => value
map.put(KEY_ID, parser.getValue(e, KEY_ID));
map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
map.put(KEY_LAT, "Rs." + parser.getValue(e, KEY_LAT));
map.put(KEY_DESC, parser.getValue(e, KEY_DESC));

// adding HashList to ArrayList
menuItems.add(map);
}

// Adding menuItems to ListView
ListAdapter adapter = new SimpleAdapter(this, menuItems,
R.layout.list_item,
new String[] { KEY_NAME, KEY_DESC, KEY_LAT }, new int[] {
R.id.name, R.id.desciption, R.id.cost });

setListAdapter(adapter);

// selecting single ListView item
ListView lv = getListView();





}
//the continue button
public void onClick(View v)
{
Intent personal = new Intent(this, UserPersonal.class);
startActivity(personal);
}


here is my pizzahut.xml where is just my list view and button to submit



<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white" >
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="181dp"
android:layout_height="504dp"
android:background="@color/white"
android:gravity="fill"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="216dp"
android:layout_height="483dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >

</ListView>






<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="@string/picktime" />

</RelativeLayout>

</ScrollView>


Here is my list_item.xml



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="483dp"
android:orientation="vertical" >

<!-- Name Label -->

<TextView
android:id="@+id/name"
android:layout_width="104dp"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:paddingTop="6dip"
android:textColor="#dc6800"
android:textSize="16sp"
android:textStyle="bold" />

<!-- Description label -->
<TextView
android:id="@+id/desciption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:paddingBottom="2dip">
</TextView>
<!-- Linear layout for cost and price Cost: Rs.100 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- Cost Label -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#5d5d5d"
android:gravity="left"
android:textStyle="bold"
android:text="Cost: " >
</TextView>
<!-- Price Label -->
<TextView
android:id="@+id/cost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:textStyle="bold"
android:gravity="left">
</TextView>

</LinearLayout>

<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CheckBox" />


<Spinner
android:id="@+id/spinner1"
android:layout_width="118dp"
android:layout_height="wrap_content" />

</LinearLayout>

</LinearLayout>


whenever i will click on button check [ pizzahut.xml and PizzaHut.java]



i want to HTTPPost menu item name [got from xmlparsing ] , the checkbox value if selected , the spinner value togetherly.please give me the complete explanation.





how to filter more than once in Microsoft.Win32.OpenFileDialog()

    Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".txt"; // Default file extension
dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension here


I want to filter more than one type





Multiple threads reading from single List, one thread at the time using Lock.. how?

I currently have the following class:



    public List<DB_ROW> DB = new List<DB_ROW>();

class MY_CLASS
{

// contructor executes two READER_THREAD's
public void MY_CLASS()
{
Thread reader_thread_1 = new Thread(READER_THREAD);
Thread reader_thread_2 = new Thread(READER_THREAD);

reader_thread_1.Start();
reader_thread_2.Start();
}

// reader thread fetches a single field from the 'global' database
public void READER_THREAD()
{
List<DB_ROW> ORDERED_DB = GLOBAL.DB.OrderByDescending();
string ID = ORDERED_DB[0].ID;
GLOBAL.DB[original_index].LAST_USED = NOW(); // update LAST_USED time
}
}


*The problem is.. * that both threads execute at the same time, therefor they fetch the same 'ID'. I looked into Lock's and modified my class like this:



   public List<DB_ROW> DB = new List<DB_ROW>();

class MY_CLASS
{

// contructor executes two READER_THREAD's
public void MY_CLASS()
{
Thread reader_thread_1 = new Thread(READER_THREAD);
Thread reader_thread_2 = new Thread(READER_THREAD);

reader_thread_1.Start();
reader_thread_2.Start();
}

static readonly object _locker = (object)GLOBAL.DB;

// reader thread fetches a single field from the 'global' database
public void READER_THREAD()
{
lock(_locker){
List<DB_ROW> ORDERED_DB = GLOBAL.DB.OrderByDescending();
string ID = ORDERED_DB[0].ID;
GLOBAL.DB[original_index].LAST_USED = NOW(); // update LAST_USED time
}
}
}


But it doesn't change anything.. The DB List is outside the class, how can I 'lock' it, so only one READER_THREAD reads and updates it at a time?



Also, I have different threads outside this class updating DB as well, will the lock block them from updating the DB too while READER_THREAD is running or will the lock only apply to READER_THREAD (that's what I need)? Thanks!



RESULT I GET NOW:



  READER_THREAD_1: Fetches ID: 1
READER_THREAD_2: Fetches ID: 1


RESULT I WANT:



  READER_THREAD_1: Fetches ID: 1
READER_THREAD_2: Fetches ID: 2




PHP friends data display....?

I'm struggling with this for hours so please help me. my tables detail as




+--------------+
| friendstable |
+--------------+
| + user_id |
| + friends_id |
+--------------+



+--------------+
| table2 |
+--------------+
| + id |
| + comments |
| + user_id |
+--------------+


i want to display friends comments only



Please guide....



thanks





C++: Inheriting from std::map

I want to inherit from std::map, but as far as I know std::map hasn't any virtual destructor.



Is it therefore possible to call std::map's destructor explicitly in my destructor to ensure proper object destruction?





How to set tooltip position for linechart in jfreechart?

Chart



Hi i am new to jfreechart.



The above graph displays tooltip only when mouse over at the starting and ending position of two values.



But i want to display in between the line of the graph when mouseover.



can anyone tell me how to set tooltip position for jfreechart?



I want to tooltip visible on entire line of graph not only in the point of line.



Is there any properties available to set the position of tooltip on line of the graph in jfreechart?



Is there any possible by chartPanel.getToolTipLocation() method?





Implement Product key

I have developed a Java Based Desktop application and I want to distribute it with a product key so, that when the correct key is entered the application is activated. So, the product key should be different for individual users. How can I implement this concept in Java. Thanks in Advance





When I use the following code it will give me a blank image?

-(void)generateImage
{
NSURL *url = [NSURL URLWithString:@"http://174.120.32.69/~mobadmin/b/MMAApp/videos/FitnessTrainingTammy.mp4"];
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:url options:nil];
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
generator.appliesPreferredTrackTransform=TRUE;
[asset release];
CMTime thumbTime = CMTimeMakeWithSeconds(0,30);

AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef im, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error){
if (result != AVAssetImageGeneratorSucceeded) {
NSLog(@"couldn't generate thumbnail, error:%@", error);
}
[self.button setImage:[UIImage imageWithCGImage:im] forState:UIControlStateNormal];
UIImage *thumbImg = [[UIImage imageWithCGImage:im] retain];
[generator release];
};

CGSize maxSize = CGSizeMake(320, 180);
generator.maximumSize = maxSize;
[generator generateCGImagesAsynchronouslyForTimes:[NSArray arrayWithObject:[NSValue valueWithCMTime:thumbTime]] completionHandler:handler];
}




django.http.HttpResponse does not deal unicode properly

following Tutorial 3, I have written this trivial views.py:



# coding = UTF-8
from django.http import HttpResponse

def index(request):
return HttpResponse( u"Seznam kontakt?" )


I tried also other tricks, such as using django.utils.encoding.smart_unicode(...), the u"%s" % ... trick, etc.



Whatever I try, I always get "Non-ASCII character" error:



SyntaxError at /kontakty/

Non-ASCII character '\xc5' in file C:\Users\JindrichVavruska\eclipse\workspace\ars\src\ars_site\party\views.py
on line 5, but no encoding declared;
see http://www.python.org/peps/pep-0263.html for details (views.py, line 5)


It is even more mysterious because I used a lot of national character strings in other files, such as models.py, e.g. text = models.CharField( u"VÅ¡echen text", max_length = 150), and there was absolutely no problem at all.



I found other answers on this site irrelevant, the suggested changes make no difference in my views.py



Jindra





.htaccess to nginx rewrite rules excluding certain folders

So im trying to move an application from apache to NginX but I've discovered i need to re write the .htaccess file, I've had a good look around but finally I need to ask for some help.



Below is the .htaccess file from apache, im trying to redirect all requests to index.php except for requests to /html, /css, /images, /php.



Thanks for your help in advance!
Bill



RewriteEngine on 
RewriteRule ^html [L,NC]
RewriteRule ^css [L,NC]
RewriteRule ^images [L,NC]
RewriteRule ^php [L,NC]
RewriteRule ^.*$ index.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !directory/(.*)$
RewriteCond %{REQUEST_URI} !(.*)$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]


So far I have the below and the requests for the html, css, images and php files are working great.



But when i make a request for www.domain.com/blah/blah/blah/ im getting a 404, what i really want is for the URL to reamin as www.domain.com/blah/blah/blah/ but load the index.php file



location ~ directory/(.*)$ {
}

location ~ (.*)$ {
}

location /html {
rewrite ^/html / break;
}

location /css {
rewrite ^/css / break;
}

location /images {
rewrite ^/images / break;
}

location /php {
rewrite ^/php / break;
}

location / {
rewrite ^(.*)$ /index.php break;
if (!-e $request_filename){
rewrite ^(.*)$ http://www.domain.com/$1 redirect;
}
}