Thursday, 3 October 2013

How to get aSQL of a table?

How to get aSQL of a table?

How to get aSQL of a table?
I want tghe SQL...Can anybody tell me the TABLE_NAME where SQL is maintained?
I used SQL developer but is there any command or script or table name
which shows the SQL of a table.

Wednesday, 2 October 2013

Oracle blocking repeated inserts

Oracle blocking repeated inserts

Consider a system that has multipile requests for course enrollments
coming in. We need a way to block duplicate enrollments in the system. I
created a trigger as follows, but when I get two requests from different
connections at the same time (ms apart) they are both inserted. What am I
doing wrong
create trigger enrollment_duplicates
before insert
on enrollment
for each row
begin
select count(*) into cnt from enrollment where user = :new.user and
course = :new.course and status = 'Enrolled';
if cnt > 0 then
raise_application_error(-20001, 'User already enrolled in course');
end if;
end;

How to return a dynamic allocated struct of arrays in a method?

How to return a dynamic allocated struct of arrays in a method?

I have the following struct and method in the public part of my headerfile:
struct InputtedInstructions
{
string name;
string arg1;
string arg2;
string arg3;
};
InputtedInstructions get_instruction(vector<string>& text, int count);
then in my cpp file:
Instructions::InputtedInstructions
Instructions::get_instruction(vector<string>& vec, int counter)
{
int ListPosition = 0;
InputtedInstructions* InputList = new InputtedInstructions[counter];
while (ListPosition != counter)
{
string text = vec.at(ListPosition);
istringstream iss(text);
string command, arg1, arg2, arg3;
int CommaAmount = count(text.begin(), text.end(), ',');
if (CommaAmount == 2)
{
while( iss >> command >> arg1 >> arg2 >> arg3)
{
InputList[ListPosition].name = command;
InputList[ListPosition].arg1 = arg1;
InputList[ListPosition].arg2 = arg2;
InputList[ListPosition].arg3 = arg3;
ListPosition++;
}
}
//same thingfor 3 commas, 4, etc.
return InputList;
My issue is on that return statement down there. it wants me to add [] to
the end of it. but I want to return the entire InputList array. Is there
something glaringly obvious I am doing wrong? Thanks for your help.

Stack trace analysis assistance

Stack trace analysis assistance

I have a mvc3 app and I'm unable to debug it. Any assistance would be
great since I'm a newbie to reading the stack trace. Is this 1 exception
thrown or more and where to search for the prob? Tnx
Server Error in '/' Application.
The network path was not found
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The network path
was not found
Source Error:
Line 188: orderby s.Name Line 189: select s; Line 190: var settings =
query.ToDictionary(s => s.Name.ToLowerInvariant()); Line 191: Line 192:
return settings;
Source File: C:...***.FB.Services\Configuration\Services\SettingService.cs
Line: 190
Stack Trace:
[Win32Exception (0x80004005): The network path was not found]
[SqlException (0x80131904): A network-related or instance-specific error
occurred while establishing a connection to SQL Server. The server was not
found or was not accessible. Verify that the instance name is correct and
that SQL Server is configured to allow remote connections. (provider:
Named Pipes Provider, error: 40 - Could not open a connection to SQL
Server)] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection, Action1 wrapCloseInAction) +5296071
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,
SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64
timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean
integratedSecurity, Boolean withFailover) +5308555
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
serverInfo, String newPassword, SecureString newSecurePassword, Boolean
ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo
serverInfo, String newPassword, SecureString newSecurePassword, Boolean
redirectedUserInstance, SqlConnectionString connectionOptions,
SqlCredential credential, TimeoutTimer timeout) +889
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer
timeout, SqlConnectionString connectionOptions, SqlCredential credential,
String newPassword, SecureString newSecurePassword, Boolean
redirectedUserInstance) +307
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential credential,
Object providerInfo, String newPassword, SecureString newSecurePassword,
Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions)
+434
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions
userOptions) +225
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnectionOptions options, DbConnectionPoolKey poolKey,
DbConnectionOptions userOptions) +37
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions
userOptions) +558
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions
userOptions) +67
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate,
Boolean onlyOneCheckConnection, DbConnectionOptions userOptions,
DbConnectionInternal& connection) +1052
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) +167
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) +143
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
+83 System.Data.SqlClient.SqlConnection.Open() +96
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean
openCondition, DbConnection storeConnectionToOpen, DbConnection
originalConnection, String exceptionCode, String attemptedOperation,
Boolean& closeStoreConnectionOnFailure) +44
[EntityException: The underlying provider failed on Open.]
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean
openCondition, DbConnection storeConnectionToOpen, DbConnection
originalConnection, String exceptionCode, String attemptedOperation,
Boolean& closeStoreConnectionOnFailure) +203
System.Data.EntityClient.EntityConnection.Open() +104
System.Data.Objects.ObjectContext.EnsureConnection() +75
System.Data.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) +41
System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
+36 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2
keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +146
System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2
keySelector) +89
***.FB.Services.Configuration.Services.SettingService.<GetAllSettings>b__3()
in C:\***.FB.Services\Configuration\Services\SettingService.cs:190
***.FB.Core.Caching.Extensions.CacheExtensions.Get(ICacheManager
cacheManager, String key, Int32 cacheTimeInMinutes, Func1 acquire) in
C:**.FB.Core\Caching\Extensions\Extensions.cs:47
.FB.Core.Caching.Extensions.CacheExtensions.Get(ICacheManager
cacheManager, String key, Func1 acquire) in
C:\***.FB.Core\Caching\Extensions\Extensions.cs:19
***.FB.Services.Configuration.Services.SettingService.GetAllSettings() in
C:\***.FB.Services\Configuration\Services\SettingService.cs:185
***.FB.Services.Configuration.Services.SettingService.GetSettingByKey(String
key, T defaultValue) in
C:\***.FB.Services\Configuration\Services\SettingService.cs:116
***.FB.Services.Configuration.ConfigurationProvider1.b__4(PropertyInfo
prop) in C:*.FB.Services\Configuration\ConfigurationProvider.cs:30
System.Linq.WhereSelectArrayIterator2.MoveNext() +66
System.Linq.WhereSelectEnumerableIterator2.MoveNext() +85
System.Collections.Generic.List1..ctor(IEnumerable1 collection) +381
System.Linq.Enumerable.ToList(IEnumerable1 source) +58
***.FB.Services.Configuration.ConfigurationProvider1.BuildConfiguration()
in C:**.FB.Services\Configuration\ConfigurationProvider.cs:37
.FB.Services.Configuration.ConfigurationProvider`1..ctor(ISettingService
settingService) in
C:*.FB.Services\Configuration\ConfigurationProvider.cs:16
lambda_method(Closure , Object[] ) +66
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
+212
[DependencyResolutionException: An exception was thrown while invoking the
constructor 'Void
.ctor(*.FB.Services.Configuration.Interfaces.ISettingService)' on type
'ConfigurationProvider1'.]
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
+381
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext
context, IEnumerable1 parameters) +184
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters)
+48 Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +7
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1
creator) +112 Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope
currentOperationScope, IComponentRegistration registration, IEnumerable1
parameters) +167
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration
registration, IEnumerable1 parameters) +24
Autofac.Core.Activators.Reflection.<>c_DisplayClass2.b_0() +31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
+94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext
context, IEnumerable1 parameters) +184
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters)
+48 Autofac.Core.Resolving.InstanceLookup.b_0() +7
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1
creator) +112 Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope
currentOperationScope, IComponentRegistration registration, IEnumerable1
parameters) +167
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration
registration, IEnumerable1 parameters) +24
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0()
+31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
+94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext
context, IEnumerable1 parameters) +184
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters)
+48 Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +7
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1
creator) +112 Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope
currentOperationScope, IComponentRegistration registration, IEnumerable1
parameters) +167
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration
registration, IEnumerable1 parameters) +24
Autofac.Core.Activators.Reflection.<>c_DisplayClass2.b_0() +31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
+94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext
context, IEnumerable1 parameters) +184
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters)
+48 Autofac.Core.Resolving.InstanceLookup.b_0() +7
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1
creator) +112 Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope
currentOperationScope, IComponentRegistration registration, IEnumerable1
parameters) +167
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration
registration, IEnumerable1 parameters) +24
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0()
+31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
+94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext
context, IEnumerable1 parameters) +184
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters)
+48 Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +7
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1
creator) +112 Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope
currentOperationScope, IComponentRegistration registration, IEnumerable1
parameters) +167
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration
registration, IEnumerable1 parameters) +24
Autofac.Core.Activators.Reflection.<>c_DisplayClass2.b_0() +31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
+94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext
context, IEnumerable1 parameters) +184
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters)
+48 Autofac.Core.Resolving.InstanceLookup.Execute() +48
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope
currentOperationScope, IComponentRegistration registration, IEnumerable1
parameters) +167
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration
registration, IEnumerable1 parameters) +64
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration
registration, IEnumerable1 parameters) +163
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context,
Service service, IEnumerable1 parameters, Object& instance) +70
Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext
context, Service service, IEnumerable`1 parameters) +54
Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context,
Type serviceType) +84
Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type
serviceType) +21
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext
requestContext, Type controllerType) +41
[InvalidOperationException: An error occurred when trying to create a
controller of type '*.FB.Redirector.Controllers.RedirectController'. Make
sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext
requestContext, Type controllerType) +179
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext
requestContext, Type controllerType) +80
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext
requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext,
IController& controller, IControllerFactory& factory) +196
System.Web.Mvc.<>c_DisplayClass6.b_2() +49
System.Web.Mvc.<>c__DisplayClassb1.<ProcessInApplicationTrust>b__a() +13
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func1 func) +88
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext,
AsyncCallback callback, Object state) +98
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext,
AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext
context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+301 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +155

Tuesday, 1 October 2013

Should I use Nullable in F#?

Should I use Nullable in F#?

Which way is more idiomatic to use Nullable<'a> or to use Option<'a> for
representing a nullable int?

Stripe.com component or module for use with Joomla CMS?

Stripe.com component or module for use with Joomla CMS?

Does anyone know of a component or module for Joomla that uses Stripe.com
to process payments?
The closest I've found is: http://www.jpayplans.com/
Any help would be great!

how do I run the ISO installation file?

how do I run the ISO installation file?

pOK, I've downloaded ubuntu desktop file ubuntu-12.04.3-desktop-i386.iso
but what do I do to get it to run amp; install ubuntu?/p

Norms and Inner Products

Norms and Inner Products

Is it possible to form an inner product from a norm or only the other way
around? When do inner products not have norms?

Monday, 30 September 2013

Check external IP from a Linux headless server – superuser.com

Check external IP from a Linux headless server – superuser.com

I have access to a headless Debian server which I would like to learn the
external IP address. How can I do that? The server is connected to the
Internet.

Proof of independence (linear algebra) [duplicate]

Proof of independence (linear algebra) [duplicate]

This question already has an answer here:
Proof that this is independent 2 answers
Prove that {1,sin(x),sin(2x),sin(3x),…,sin(nx)} is an independent set. I
received 1 answer 3 days ago but didn't find the answer very clear.
Please advice, thanks!

Paraview cannot open large *.e files(windows 7): Could not retrieve time values

Paraview cannot open large *.e files(windows 7): Could not retrieve time
values

when I open large Exodus files(*.e) (for example, 5GB) in Paraview 4.0.1
(windows 7, 64 bit), I met this mistake:
ERROR: In
C:\DBD\pvs-x64\paraview\src\paraview\VTK\IO\Exodus\vtkExodusIIReader.cxx,
line 3522 vtkExodusIIReaderPrivate (000000000C0D27B0): Could not retrieve
time values.
But I can open 2GB *.e files normally. And I have tried to open a 17GB *.e
file in a Marc PC with paraview 4.0.1 as well, and it works. Could anyone
tell me why this happen and how can I fix the problem in windows? Thanks!

How Read data from XML variable in Sqlserver and show in table format?

How Read data from XML variable in Sqlserver and show in table format?

I have below format of xml.

need to show this data below table format.

Sunday, 29 September 2013

Change behavior for tab-key (autocomplete) when cursor is placed right after colon

Change behavior for tab-key (autocomplete) when cursor is placed right
after colon

I want this...
html,body{
padding:/*tab-key-pressed!*/0;
margin:/*tab-key-pressed!*/0;
}
...to become this:
html,body{
padding: 0;
margin: 0;
}
But instead I get an auto-complete like this:
html,body{
padding::;0;
max-resolution: res;0;
}
I've been looking at the css_completions.py, but I've never learned python
and I'm not man enough to make sense of things. :(
So to sum up things: Is it possible to selectively disable auto-complete
when the cursor is after a colon?
Thank you for your time!

Ascii Conversion Program; printing error

Ascii Conversion Program; printing error

I have been working on this program in C, and I don't understand why it is
printing beyond the range that parameters state. here is the program, can
anyone help me? Also, how do i get the input to reject numbers that arent
in specified range? Thanks in advance!
#include <stdlib.h>
#include <stdio.h>
#define LEN 64
int main(){
char line[LEN];
printf("Enter a #, 32-127: ");
fgets(line,LEN,stdin);
int i = atoi(line);
printf("Enter a #, %d-127: ",i);
fgets(line,LEN,stdin);
int j = atoi(line);
for(i;j;i++)
printf("ASCII value of character %d: %c\n",i,i);
return(EXIT_SUCCESS);
}

Android (View): Child position inside ListView depending on android version

Android (View): Child position inside ListView depending on android version

Im developing an android-app which handles a ListView with several
TextViews within it as childs.
The problem (already solved) came when I tried to get child from the
parent view by using getChildAt(pos) method.
I have tested my app in two devices with different android versions
installed, and I got the following conclusions:
In android 2.2.1 the parent view refers their childs by using the
following position-indexation:
Parent.
Child_A: position 2
Child_B: position 1
Child_C: position 0
In android 4.0.3 the parent view refers their childs by using the
following position-indexation:
Parent.
Child_A: position 0
Child_B: position 1
Child_C: position 2
So, I would like to know from which version it changed the child
indexation protocol in order to operate in one way or antoher depending on
the android version installed in the target device.
What I want to do is somthing like this:
if androidVersion >= X then
___Use new chlid-indexation protocol
else
___Use old child-indexation protocol
Thanks.

How to get a result from DialogFragment in the calling Fragment?

How to get a result from DialogFragment in the calling Fragment?

I have the following DialogFragment to pick date:
public class Fragment_Picker_Time extends DialogFragment implements
TimePickerDialog.OnTimeSetListener {
int hour;
int minute;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
hour = c.get(Calendar.HOUR_OF_DAY);
minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute,
DateFormat.is24HourFormat(getActivity()));
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// Do something with the time chosen by the user
}
}
And this is how I call it from another Fragment:
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.btn_call_time:
DialogFragment newFragment = new Fragment_Picker_Time();
newFragment.show(getFragmentManager(), "timePicker");
break;
}
}
However I don't know how to get the values from the DialogFragment and
pass them to my Fragment. I tried the following:
In the DialogFragment I set the onTimeSet function:
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
Intent intent = new Intent(getParentFragment().getActivity(),
Fragment_Schedules.class);
intent.putExtra("HOUR", hour);
intent.putExtra("MINUTE", minute);
getTargetFragment().onActivityResult(getTargetRequestCode(),
Activity.RESULT_OK, intent);
}
Added the following line to calling this fragment:
case R.id.btn_call_time:
DialogFragment newFragment = new Fragment_Picker_Time();
newFragment.setTargetFragment(this, 55);
newFragment.show(getFragmentManager(), "timePicker");
break;
}
And set an OnActivityResult function:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
getActivity();
//super.onActivityResult(requestCode, resultCode, data);
if(resultCode==Activity.RESULT_OK)
{
switch(requestCode)
{
case 55:
int hour = data.getExtras().getInt("HOUR");
int minute = data.getExtras().getInt("MINUTE");
Toast.makeText(getActivity(), "The selected time is:
"+hour+":"+minute, Toast.LENGTH_LONG).show();
break;
}
} else {
// handle error
}
}
But when I tried to run it my app crashed. This is what I got in logcat:
09-29 10:06:43.666: E/AndroidRuntime(14088): FATAL EXCEPTION: main
09-29 10:06:43.666: E/AndroidRuntime(14088): java.lang.NullPointerException
09-29 10:06:43.666: E/AndroidRuntime(14088): at
com.myname.myproject.fragments.
Fragment_Picker_Time.onTimeSet(Fragment_Picker_Time.java:32)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
android.app.TimePickerDialog
.onClick(TimePickerDialog.java:119)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
com.android.internal.app.AlertController$ButtonHandler
.handleMessage(AlertController.java:166)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
android.os.Looper.loop(Looper.java:137)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
android.app.ActivityThread.main(ActivityThread.java:4424)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
java.lang.reflect.Method.invokeNative(Native Method)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
java.lang.reflect.Method.invoke(Method.java:511)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-29 10:06:43.666: E/AndroidRuntime(14088): at
dalvik.system.NativeStart.main(Native Method)
What am I doing wrong? How can I pass the selected values from
DialogFragment to Fragment?

Saturday, 28 September 2013

Relational Algebra Selecting Duplicates

Relational Algebra Selecting Duplicates

I am trying to do part C of this assignment here below

I have been stuck on this for quite a while now, I can't seem to come up
with a solution because no matter what operation I use it automatically
removes duplicates and proves useless. I initially tried to take the
accnumber from the Owns table and subtract from it the accnumber in the
Account table, and selecting all rows with this accnumber from the Owns
table again. This proved futile, or maybe I didn't do it correctly. If
anyone can help, that would be awesome. Thanks.

The name does not exist in the current context - grrr

The name does not exist in the current context - grrr

in the following code, no matter what I try, the name strSide "does not
exist in the current context", when I place a break point as shown. I want
strSide to contain the last character in rawId and then to strip that
character so that the value of rawId will convert to an integer. I don't
get a compiler error, but do get a runtime error.
When the value of rawId is 8429R, the stripping works, but I cannot get
the R assigned to strSide.
foreach (string fieldName in Request.QueryString)
{
rawId = fieldName;
String strSide = Convert.ToString(rawId[rawId.Length -
1]); <-- name does not exist
if (!IsNumeric(rawId)) <--break point set here.
{
rawId = StripRightChar(rawId);
}
Qty = Request.QueryString[fieldName];
int productId = 0;
if (fieldName == "txtReference")
{
strComments = Request.QueryString[fieldName];
}

Access php object value

Access php object value

I have this object i am able to access the name by $object->name but not
able to get the starline and endline. I try $object->starline it return
null.
PHPParser_Node_Expr_Variable Object ( [subNodes:protected] => Array (
[name] => var ) [attributes:protected] => Array ( [startLine] => 2
[endLine] => 2 ) )

Friday, 27 September 2013

Expect multiple calls to method

Expect multiple calls to method

How can I tell Moq to expect multiple calls so I can still use the
MockRepository to VerifyAll, as below?
[TestFixture]
public class TestClass
{
[SetUp]
public void SetUp()
{
_mockRepository = new MockRepository(MockBehavior.Strict);
_mockThing = _mockRepository.Create<IThing>();
_sut = new Sut(_mockThing.Object);
}
[TearDown]
public void TearDown()
{
_mockRepository.VerifyAll();
}
private Mock<IThing> _mockThing;
private MockRepository _mockRepository;
[Test]
public void TestManyCalls(Cell cell)
{
_mockThing.SetUp(x => x.DoSomething()).Return(new DoneStatus());
}
}
I know you can do this at verify time, but then I would have to verify
everything independently. Is there a to tell it what to expect, rather
than verifying it after the event?
Somthing similar to:
_mockThing.SetUp(x => x.DoSomething()).Return(new DoneStatus()).Times(20);

How can I plot the counts of my observed variable against the counts of a different level of the observed variable in a scatterplot?

How can I plot the counts of my observed variable against the counts of a
different level of the observed variable in a scatterplot?

I'd like to create scatter plots of the different conflict types against
each other. Each numbered sample would be a point. Samples should be
removed when there isn't aren't conflicts of the two types being plotted
against each other. I want to look at each relationship between conflict
types.
I made an example plot below of what I've been working on below but it
required lines and lines of explicit hard coding.

df <- structure(list(Name = c("487", "487", "232", "276", "405", "19",
"477", "487", "232", "159", "19", "232", "405", "487", "276",
"159", "159", "19", "286", "232", "232", "174", "19", "405",
"286", "599", "232", "30", "477", "232", "477", "477", "477",
"477", "477", "286", "159", "721", "487", "487", "276", "30",
"660", "345", "345", "345", "345", "174", "477", "355", "477",
"174", "159", "30", "477", "345", "276", "405", "608", "286",
"30", "232", "19", "721", "721", "102", "599", "345", "430",
"296", "174", "174", "174", "430", "430", "477", "487", "487",
"430", "430", "487", "345", "702", "30", "19", "30", "702", "702",
"174", "477", "174", "355", "159", "232", "430", "296", "702",
"286", "430", "702", "702", "712", "345", "184", "721", "184",
"102", "296", "599", "702", "702", "702", "38", "38", "38", "430",
"430", "430", "477", "477", "430", "477", "660", "702", "702",
"660", "660", "660", "702", "296", "702", "174", "296", "296",
"345", "702", "660", "599", "417", "417", "417", "702", "652",
"345", "184", "591", "184", "184", "599", "417", "90", "599",
"430", "678", "678", "38", "38", "477", "678", "678", "477",
"678", "678", "417", "430", "430", "572", "572", "572", "702",
"572", "702", "702", "702", "442", "442", "678", "442", "296",
"30", "311", "311", "311", "311", "311", "311", "591", "591",
"102", "442", "608", "430", "194", "194", "194", "678", "678",
"678", "38", "38", "678", "38", "38", "49", "49", "49", "690",
"690", "690", "572", "690", "296", "296", "552", "690", "702",
"580", "580", "580", "580", "454", "454", "454", "702", "702",
"345", "311", "311", "311", "184", "608", "194", "102", "224",
"224", "194", "194", "194", "660", "660", "38", "660", "660",
"90", "90", "212", "212", "212", "212", "690", "668", "690",
"690", "442", "562", "562", "562", "562", "562", "562", "562",
"562", "417", "417", "652", "652", "320", "320", "320", "184",
"599", "430", "678", "678", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "690", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "591", "194",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "102", "102", "224",
"329", "329", "224", "224", "224", "224", "224", "660", "212",
"212", "212", "212", "203", "203", "203", "203", "212", "212",
"668", "62", "76", "76", "76", "76", "76", "76", "76", "76",
"76", "76", "76", "76", "76", "652", "652", "62", "62", "430",
"678"), Conflict = structure(c(2L, 2L, 2L, 1L, 1L, 1L, 2L, 3L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 3L, 2L, 1L, 4L, 1L, 1L,
2L, 2L, 1L, 1L, 2L, 2L, 2L, 3L, 4L, 4L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 3L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 3L, 2L, 2L, 2L, 2L,
2L, 4L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L,
1L, 1L, 3L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L,
2L, 4L, 3L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 3L, 3L,
4L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 1L, 2L, 2L, 4L, 1L, 2L, 3L,
1L, 2L, 4L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 4L,
1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 4L, 1L, 1L, 2L, 2L, 1L, 2L,
1L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 3L, 3L, 1L, 3L, 2L, 2L,
3L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 4L, 2L, 2L, 1L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L,
2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 2L,
1L, 1L, 3L, 3L, 1L, 1L, 2L, 4L, 2L, 4L, 2L, 3L, 1L, 1L, 1L, 2L,
3L, 1L, 2L, 1L, 3L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 3L, 3L, 1L,
2L, 1L, 3L, 1L, 2L, 2L, 2L, 1L, 1L, 3L, 2L, 2L, 2L, 2L, 3L, 2L,
4L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L,
2L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 2L,
2L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L,
2L, 3L, 3L, 2L, 2L, 3L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 3L, 1L, 2L, 2L,
1L, 3L, 4L, 2L, 4L, 2L, 1L, 2L, 1L, 4L, 1L, 1L, 1L, 2L, 2L, 4L,
2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 3L, 1L, 2L, 3L, 2L,
2L), .Label = c("DB Zero", "File Zero", "Het - Homo", "Homo - Het"
), class = "factor")), .Names = c("Name", "Conflict"), row.names = c(NA,
-393L), class = "data.frame")

Creating Rails Gems

Creating Rails Gems

I want to build my application in a modular way: For example I might have:
Users->has_and_belongs_to_many->Projects
Users->has_and_belongs_to_many->Tasks
Projects->has_many->Tasks
Tasks->belongs_to->Project (1 task belongs to 1 project.)
Note: Projects AND tasks can have many users.
The way I was thinking of building this is by doing:
User = Gem
Projects = Gem
Tasks = Gem
Each can return either json (for ember) or html. Neither depend on each
other, The idea is that each is just a detail. Rails, ember and html are
all just details.
How could I go about this and at the end of the day hook them together
like a puzzle? or is this even feasible?
Right now I have the user piece of this concept almost done. It contains
models, tests, controllers and views. Can I bundle that as a gem or should
I only bundle the controller and the models? This "User" gem would make
use of friendlyId gem to make the urls look nice, infact all the "gems"
(project, tasks and users) will depend on this gem.
What would you recommend to do to have the kind of modularity I want? is
it good practice? bad practice?

How do I identify unique elements within my array in C#?

How do I identify unique elements within my array in C#?

Let's say I work at the Dept. of Health. I've processed food poisoning
complaints and stored the complaints data into a multi-dimensional array
like so:
ID - 5 digit ID number for the restaurant victim ate at Date - Date of
Food Poisoning Name - Name of Victim Age - Age of Victim Phone - Victim's
Phone Number
Array[0] contains the first complaint's data. Array[0].ID contains the
restaurant ID of the first complaint and so forth.
Within my array how do I extract a list of unique 5 digit IDs?
Some restaurants might have 50 complaints and some might have just 1. I
want to create a list of all of the unique restaurant IDs that show up in
my complaints data.
var Unique = array.ID.Distinct();
does not work. What am I doing wrong?

Java ArrayList with condition

Java ArrayList with condition

I have a question about if condition in ArrayList, Please see code:
public class Test {
public static void main(String[] args) {
ArrayList<BankAccount>accounts=new ArrayList<BankAccount>();
BankAccount Mary=new BankAccount(1,50);
BankAccount Lucy=new BankAccount(2,100);
BankAccount Lily=new BankAccount(3,20);
BankAccount Pete=new BankAccount(4,200);
BankAccount Paul=new BankAccount(5,30);
accounts.add(Mary);
accounts.add(Lucy);
accounts.add(Lily);
accounts.add(Pete);
accounts.add(Paul);
double min=accounts.get(0).getBalance();
int poorestPerson=accounts.get(0).getAccountNumber();
for(BankAccount a:accounts){
if(a.getBalance()<min){
poorestPerson=a.getAccountNumber();
}
}
System.out.println("Poorest person is "+poorestPerson);
}
}
The result is always 5, but the correct print should be 3, when I add :
poorestPerson=a.getAccountNumber();
**min=a.getBalance();**
It prints right answer, my question is how does this command vary the
result?Cheers.

MVC Url not pathing correctly

MVC Url not pathing correctly

I have a link going to
<a class="k-link" href="/UserView/EditByName?UserName=MVCTest6">Profile</a>
When the link it is clicked it goes to this
URL: http://localhost:3256/MVCTest6/Create
which works when i am logged in as an admin user. (The folder has no
security in a web.config setting it apart). This link actually works on
another part of the page.
The user also already exist and has been authenticated.
Can this please be explained?

How to get the facebook signed request in c#

How to get the facebook signed request in c#

I'm new to Facebook apps. I'm trying to create an MVC 4 application with
Facebook Application as my Project Template. I'm trying to catch the page
id on which the page tab is created and I've got it somehow. My problem
here is when someone visits my app, I want to know the page id through
which they are viewing the page tab. I've searched a lot where I got to
know that I've to use FacebookSignedRequest for this. But this class is
not available to me.
Thanks in advance for any help.

Thursday, 26 September 2013

Onclick button disables checkboxes

Onclick button disables checkboxes

. .I couldn't find a proper answer for onclick function on a button
disables three checkboxes. . .
<input id="option" name="item_number" type="checkbox" class="ckbox"
value="1" onclick="this.checked=!this.checked;"/>
<input id="option" name="item_number" type="checkbox" class="ckbox"
value="1" onclick="this.checked=!this.checked;"/>
<input id="option" name="item_number" type="checkbox" class="ckbox"
value="1" onclick="this.checked=!this.checked;"/>
And the button to add onclick function already there are many onclick
functions.
<input type="button" class="button2" id="item2" value="Add to Cart"
Title="Add to Cart"
onClick="addItem_check('item_listing_100','ItemTable','100','Amul
Butter','500','g','150.00','1','kg','200.00','2','kg','250.00');
amul1.style.backgroundColor='#c2ed5c'; if(this.value=='Add to Cart')
{this.value = 'Remove from Cart'}; item2();"/>
So please give me a solution guys

Wednesday, 25 September 2013

wx.lib.activex fails to import using Enthought Canopy and EPD

wx.lib.activex fails to import using Enthought Canopy and EPD

import wx.lib.activex fails with the supplied version of wx in Enthought
Canopy or EPD on Windows. How can I get the activex container to work with
the Enthought Python Distributions?

Thursday, 19 September 2013

jQuery selector special character doesn't work with escape in variable

jQuery selector special character doesn't work with escape in variable

I have a button onlcick it will get the id of the btn and append the new
cloned row to append to the closest table. I have a jquery function that
when the button class onclick it will get the id of the button and get the
id of the table which is the same name. just different initial. I wasn't
able to get the table since in the variable there are special character in
it.
Now I understand that I have to add '\' in front of the special characer
but it doesn't work when the '\' is in the variable.
so this is working:
$('#form_instance').on('click', '.btn_clone', function () {
var b_id = $(this).attr('id');
var t_id = '#t' +
b_id.substring(1).replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g,
"\\\\$&");
//this is just show that it works when I put static table id in it. it
works. but not when i put t_id (the output are the same).
var static = '#t_form1\\/t1';
$(static +' tr').eq(1).clone().find('input')
.val('').end()
.appendTo(static);
});
when I switch t_id with static it doesn't work which I need t_id to work
since I would like to have this function apply to every table with button.
this is my fiddle: http://jsfiddle.net/mishxpie/Ugqmv/2/
any idea?

Coldfusion function variable name and CfBuilder

Coldfusion function variable name and CfBuilder

I need to call a function of an object and pass it a variable. Because I
need to make multiple call to function of this object I've tried to make
one only handler that invoke the specific function by the form value I
pass it. The code works, but cfbuilder show me that there is an error
(missing semicolon on the last row). I'm on Railo.
local.myReport = seoUtility.init();
local.func = form.action;
local.action = local.myReport;
local.report = local.myReport[local.func](form.user);
So the question is: this code is correct? I could simply ignore the
cfbuilder error icon?

how to supply data to a php array from an external file?

how to supply data to a php array from an external file?

i am using phplot to plot a graph in a web page, and i have the following
code for it,
<?php
//Include the code
require_once 'C:/xampp/htdocs/phplot-6.1.0/phplot.php';
//Define the object
$plot = new PHPlot();
//Define some data
$example_data = array(
array('a',3),
array('b',5),
array('c',7),
array('d',8),
array('e',4),
array('f',6),
array('g',7)
);
$plot->SetDataValues($example_data);
//Turn off X axis ticks and labels because they get in the way:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
//Draw it
$plot->DrawGraph();
?>
i don't want to define the data as in $example_data, but i want to read or
upload this from an external file like txt or json, please suggest how to
achieve this and what can be the type of the external file to be uploaded
?

Javascript: read Array of Objects

Javascript: read Array of Objects

I have two .js files. In one, I want to fill an array with objects, that
have two properties. In the other file I want to loop over the array and
work with the objects properties.
My coding looks like this:
file1.js
var selection = new Object();
selection.column = "";
selection.term = "";
var selectionContainer = new Array();
...
press: function(){
var i;
for (i=1;i<=selectionContainer.length;i++){
selection = selectionContainer[i];
alert("Search Term: " + selection.column + selection.term);
}
}
file2.js
change: function(oEvent){
selection.column = "someText";
selection.term = "someOtherText";
selectionContainer[nrOfEntries] = selection;
}
When executing the javascript I receive 'Uncaught TypeError: Cannot read
property 'column' of undefined'.
What am I doing wrong?
Thanks in advance!

JavaScript: clock and the Date()

JavaScript: clock and the Date()

So I have this clock script:
function digitalWatch(timestamp) {
var date = new Date(timestamp);
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
if (hours < 10) hours = "0" + hours;
if (minutes < 10) minutes = "0" + minutes;
if (seconds < 10) seconds = "0" + seconds;
document.getElementById("digital_watch").innerHTML = hours + ":" +
minutes + ":" + seconds;
setTimeout(function(){digitalWatch(timestamp+1)}, 1000);
}
digitalWatch(<<here I pass a UNIX timestamp from server>>)
The clock don't work. I debuged it with console.log() and I saw that
timestamp incremented correctly but the Date() constructor returns the
same result again and again.
Someone knows what's the problem here? And how can I solve it?

Asyncronous server call, resource, angular

Asyncronous server call, resource, angular

I'm very confused. I hope you can help me.
This is my factory
productsFactory.getAllDiciplines = function(){
return $resource('/api/disciplines/');
}
It returns an array.
This is my controller:
$scope.diciplines = ProductsFactory.getAllDiciplines().query();
This is my view:
<select ng-model="diciplines" ng-options="d.dp_title for d in
diciplines"></select><br>
This works. However, when I choose an item in my selectbox. It get's
empty. All items disappear. I know this has something do to with that
$resource uses asyncronous calls.
How do I fix this?

Wednesday, 18 September 2013

Display high resolution image using C#

Display high resolution image using C#

I'm saving both high resolution and compressed version of high resolution
image in the database. When the user requests a high resolution image, i
need to display that else the compressed one. here is my code. The issue
is : when i set that image byte array into a stream and bitmap, file size
has compressed 2.27MB to 339kB. What i'm doing wrong here.
private void DisplayImageFromBytes(byte[] byteArray, int resizeWidth, bool
isHiResImage) {
if (isHiResImage)
{
Stream stream = new MemoryStream(byteArray);
System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
Bitmap bitmap = null;
if (resizeWidth > 0 && img.Width > resizeWidth)
{
int newHeight = (int)((float)img.Height * ((float)resizeWidth /
(float)img.Width));
bitmap = new Bitmap(img, resizeWidth, newHeight);
}
else
{
bitmap = new Bitmap(img.Width, img.Height,
System.Drawing.Imaging.PixelFormat.Max);
}
Response.ContentType = "image/Jpeg";
bitmap.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg);
stream.Dispose();
img.Dispose();
bitmap.Dispose();
}
else
{
DisplayImageFromBytes(byteArray, resizeWidth);
}
}

Step by Step App Debugger Checksum === 1 Unit Test to rule them all?

Step by Step App Debugger Checksum === 1 Unit Test to rule them all?

From the standpoint of a debugger, there is a global state, which sums up
the entire global context of an applications run state.
This state, I assume, could be assessed or accumulated into in a single
file, which itself could be summarized as single checksum, at any point in
time.
Therefore, a debugger based step by step global checksum could be used to
easily find where a program differs from where it used to operate, in
comparison to where it currently operates, given of course the exact same
inputs.
Does this exist in any development environment, or as a library/RFC that
could be used cross language?
In my particular case, I'm porting an app from VB6 to C#, and am
constantly walking the code in both environments to find where my port is
broken. It seems to me that if there were some library that existed that
could, in debug mode, store the above detailed checksum, on a step by step
basis, then I could easily find where my port was broken without having to
step through line by line by line.
Thanks for any suggestions!

Textarea char count fail on page load

Textarea char count fail on page load

English is not my native idiom, so apologies in advance for bad grammar.
I am using a javascript to count the characters of a textarea, the code
work smoothly showing the character limit decreasing when typing, using
this code i called on the textarea a php method to call from a database a
text, and heres is where the problem comes, when testing the page at load
it show the text on the textarea but the character limit stay on 500,
ofcourse it change value if u type on the textarea showing the correct
character limit.
How do i manage to show the correct character limit when the page load?
here is my code:
HTML CODE:
<tr>
<td align="center" colspan="4">
<textarea "rows="10" cols="35" onKeyPress="return charLimit(this)"
onKeyUp="return characterCount(this)"><?php echo $oRep->getDescripcion();
?> </textarea>
</td>
</tr>
<tr>
<td align="center" colspan="4"><p><strong><span
id="charCount">500</span></strong> Caracteres disponibles.</p></td>
</tr>
JS CODE:
<tr>
<td align="center" colspan="4">
<textarea "rows="10" cols="35" onKeyPress="return charLimit(this)"
onKeyUp="return characterCount(this)"><?php echo $oRep->getDescripcion();
?> </textarea>
</td>
</tr>
<tr>
<td align="center" colspan="4"><p><strong><span
id="charCount">500</span></strong> Caracteres disponibles.</p></td>
</tr>
i be tried to add a event on the textrea like 'onchange="return
charLimit(this)"' but with no change.

AD Banner Views and iOS 7/Xcode 5

AD Banner Views and iOS 7/Xcode 5

I upgraded my iphone software to iOS 7 and I noticed that the ad banners
in my free apps are barely showing up (extremely low fill rate). Does
anybody know a solution to this problem? I'm using the iAD Network.

Creating a XML file from a SQL database using Java

Creating a XML file from a SQL database using Java

There seems to be no information on this anywhere.
In anycase, I've been asked to create a Java program that takes
information from a SQL database and creates a XML file.
I can see I'm going to be using the DocumentBuilder tool. However, I'm not
sure exactly how to implement or how to begin, considering it's SQL.
The Database has not been created yet.
Thanks in advance.

Python regex - Spurious SystemError 'bad argument to internal function'

Python regex - Spurious SystemError 'bad argument to internal function'

I'm on 32 bit Python 2.7.3 and Windows 7. I am working on a complex
application which uses COM to communicate with other processes.
My application uses regular expressions in a few (but not very many)
places. Very frustratingly, I spuriously get errors of the following form:
Traceback (most recent call last):
...
File "re.pyc", line 137, in match
SystemError: ..\Objects\weakrefobject.c:903: bad argument to internal
function
The errors are not reproducible and seem to occur randomly. What's more,
they occur in any of the places where I use re.match. To me, this seems
very much like a Python bug.
Has anybody else encountered this behaviour, and knows how to fix it?

storing values of multiple dynamic textboxes to array

storing values of multiple dynamic textboxes to array

textboxes are generated dynamically
public void createtxtbox(int d)
{
int x = 0;
int y = 0;
txtbox = new TextBox[d*d];
for (int u = 0; u < txtbox.Count(); u++)
{
txtbox[u] = new TextBox();
}
for (int i = 0; i < txtbox.Length; i++)
{
int name = i + 1;
txtbox[i].Name = "TXT" + name.ToString();
txtbox[i].Location = new Point(42 + (x * 31), 47 + (y * 21));
txtbox[i].Visible = true;
txtbox[i].Size = new Size(30, 20);
txtbox[i].MaxLength = 1;
txtbox[i].TextAlign = HorizontalAlignment.Center;
this.Controls.Add(txtbox[i]);
x++;
if (x == d)
{
x = 0; y++;
}
}
}
in the form user inputs values into them and would be stored later in an
array at exit
the only way I know of storing textbox values to string
txtbx = textBox.Text

How to display a proper page in a div using ajax?

How to display a proper page in a div using ajax?

I tried to load a page (of same domain) using ajax. But it's showing only
the static html part. Styling and js actions are not there. How to load
the exact page in a div using ajax?

Tuesday, 17 September 2013

retrieve a complex JSON response and display the parts that I want from it

retrieve a complex JSON response and display the parts that I want from it

this is the first time I use JSON and underscore.js.
I'm getting a JSON response :
response Object { numFound=12, start=0, docs=[10]} responseHeader Object {
status=0, QTime=1, params={...}}
the docs nested array has another nested array like this
0 { id="23", name="8asjkdnsd",absolute_path="kkskskmasd8234", more... } .
. . 9 { id="89234", name="awdcs",absolute_path="qwdacsc", more... }
I want to use underscore.js in my jquery script to convert the response to
an array to be able to access any key, value pair when I want to, like if
I want to print all the names inside the docs[10]?
I'm trying something like this :
_.each(response.docs.name, function(docs){console.log(response.name);});
but I'm getting undefined and actually I don't know what I'm doing. so any
help would be appreciated.
thanks in advance.

sort array values by key using php

sort array values by key using php

i have an PHP array in the following format,
Array
(
[0] => Array
(
[40] => 2
[80] => 1
[20] => 0
[60] => 0
[100] => 0
)
[1] => Array
(
[60] => 2
[80] => 1
[20] => 0
[40] => 0
[100] => 0
)
)
Expected output is (20=>0,40=>0,60=>2,80=>1 etc) i tried using
array_values and array_combine, but no luck.
How do i sort array by key using PHP.

Am I able to write to a file using a user defined function?

Am I able to write to a file using a user defined function?

def writetofile():
myFile = open("C:\Jazmyn\myText.txt", "a")
myFile.write(a)
myFile.close()
creating new text file, I have created a folder named "Jazmyn" in my C
drive and the text file is created there.
def greenbottles():
bottle =
['Zero','One','Two','Three','Four','Five','Six','Seven','Eight',
'Nine', 'Ten' ]
text_one = 'green bottles hanging on the wall'
text_two = 'And if one green bottle should accidentally fall\nThere\'ll be'
for i in range(10, 0, -1):
print(bottle[i], text_one)
print(bottle[i], text_one)
print(text_two, bottle[i-1], text_one)
greenbottles()
this needs to be written to the file
I am new to python and I am finding it difficult. It is possible to make
it so that the greenbottles code can be written to the new text file
(myText) or can i fix the print statement so they write to the file?

Three div - arrange as table

Three div - arrange as table

I have three divs:
<div>
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
.one {
width: 100px;
height: 200px;
background-color: red;
}
.two {
width: 100px;
height: 100px;
background-color: green;
float: left;
}
.three {
width: 100px;
height: 100px;
background-color: blue;
float: left;
}
But this not working good. I would like receive:
<table>
<tr><td rowspan="2" class="one"></td><td class="two"></td></tr>
<tr><td class="three"></td></tr>
</table>
LIVE
How can i make it with DIV, same as with TABLE?

Focus not highlighting anchor link on tab

Focus not highlighting anchor link on tab

All anchor links except for one are getting background color changed on
focus, except for one.
HTML
<a id="login-as-guest">Cancel and browse as guest</a>
CSS
#login-as-guest a:focus{ background-color: yellow; }
Any ideas?

Sunday, 15 September 2013

incomplete type not allowed error, How to fix ?

incomplete type not allowed error, How to fix ?

I am getting this error
"Incomplete type not allowed"
the line getting this error :
Vec3 MaxHeight;

Computing Partial Derivative for RTRL training for Recurrent Neural networks

Computing Partial Derivative for RTRL training for Recurrent Neural networks

Ok so first off Hi,
Secondly its 3am and I promise you I am fried after spending 3 solid days
I understand RNN's and RTRL, but my calculus brain has ran away from me at
this point in time.
Basically I'm at the stage where I Need to calculate this:

I used a variety of sites and my textbook (which had 0 on this subject),
but this is the rest of my primary source willamette.edu
The issue I'm having is how to programmatically (Java) partially
differentiate
Yk in the direction Wij
I can't wrap my head around how to go about that.
NOTE: I do actually understand how the RNN and RTRL works, confidently.

How to optimize a factor counting algorithm

How to optimize a factor counting algorithm

I've been asked to sum the factors other than 1 and the number itself of
every number in an array. The problem is it must be able to handle very
large arrays with very large numbers and my current implementation takes
very long for arrays of size 100,000,000. My code for counting each
numbers factors is
static long countFactors(long num){
long count=0;
long max =(long) Math.floor(Math.sqrt(num));
for(int i=2; i<=max;i++){
if(num%i==0&&(i*i)!=num){
// count i and n/i as a factor
count+=2;
if(num/i<max){
max=num/i;
}
}
else if(num%i==0){
// just add one factor since it is the numbers root.
count+=1;
}
}
return count;
}
Does anybody have any optimisation suggestions.

Dynamic Routing on Apache Server with subdomains

Dynamic Routing on Apache Server with subdomains

So I am setting up a development and public servers and I am trying to
figure out how to point apache to a specific folder based on the
subdomain.
for example I want subdomain:
projectname.username.dev.domain.com
to point to:
/home/username/projectname/
any idea how to accomplish this without having to set up a separate domain
name in my DNS Zone File?

Does anybody know of any Simple.Data.Azure sample projects?

Does anybody know of any Simple.Data.Azure sample projects?

I can't seem to find any documentation or sample projects on using
simple.data.azure. Does anybody know of any?

Another way to make "always running application"?

Another way to make "always running application"?

Just noticed that Easy Controller-Control Center application doesn't have
foreground service, but never been closed by Android.
Does the SYSTEM_ALERT_WINDOW make applications non-closeble?

how to add extra charcter in a list of string

how to add extra charcter in a list of string

I had a list of strings
List<string> li = new List<string>()
{ word1,word2,word3,word4,word5,word6 };
i want to concatinate some some character in each word output list will be
will be
word1#,word2#,word3#,word4#,word5#,word6#

Saturday, 14 September 2013

Scroll bar disappearing in responsive design when screen size goes beyound 1280 px

Scroll bar disappearing in responsive design when screen size goes beyound
1280 px

I am using one css design and it works perfectly in full size browser but
whenever screen size is reduced below 1280 px in width scroll bar goes
missing and responsiveness in design gets frozen to that frame so user can
not view complete site, can not scroll when on mobile devices or after
reducing browser screen size. Request to please help with that. Below is
the link to site where this problem is occurring
http://goo.gl/VzVmTW

There is any algorithm I can follow to get a Youtube video direct URL?

There is any algorithm I can follow to get a Youtube video direct URL?

I'd like to implement my own library to download videos from Youtube, but
I after looking at the questions here at SO I saw that many questions even
got a vote and others are outdated.
So to make this question different from the others and more constructive.
I'd like to ask if someone could answer, what is the algorithm to discover
information about a Youtube video based on its normal URL.
I've read some other people implementation and looks like they build a
dictionary (data type) with the information and then passes it to some
class that have the capabilities to download the video at the specified
format.

VS2012 using 3D models dilemma

VS2012 using 3D models dilemma

I'm having problems understanding the the usage of VS2012's 3D features in
a project. I'm current building a 3D project using DirectX (Direct3D) and
want display a simple 3D object (teapot) for starters. I understand the
usage of the shadergraph which is of great help, but when it comes to
loading an FBX model, is there an alternative to using the Autodesk FBX
SDK built in or am I just stuck with it (FBXSDK)?
Generally, is there anything in VS2012 for C++ similar in nature to how
XNA uses it's content pipeline to simplify loading and working with
models?

Interrogation about Yeoman, Maven and the location of Thymeleaf HTML templates

Interrogation about Yeoman, Maven and the location of Thymeleaf HTML
templates

I recently discovered Yeoman, a tool that greatly facilitates JS
dependency and build lifecycle management.
Furthermore, I use Maven as my Java dependency and build tool. I am
actually seeking to integrate both tools so that I get the best of both
worlds.
It seems the community has put a lot of effort into Maven/Yeoman
integration with various articles such as this one:
http://addyosmani.com/blog/making-maven-grunt/ as well as a yeoman-maven
plugin: https://github.com/trecloux/yeoman-maven-plugin
Last, I use Thymeleaf as my Spring-MVC templating solution.
Assuming the following directory layout (see yeoman-maven-plugin above):
pom.xml
- src
- main
- java
- webapp
- …
- test
- ..
- yo
package.json
component.json
Gruntfile.js
- app
index.html
...
- test
...
- dist
...
My question is where should my Thymeleaf templates reside?
Under the yo/app directory? (they would be subsequently copied into
appropriate directory by maven)
Directly under the src/main/webapp/WEB-INF/templates directory?
What I can't figure out in the case of an AngularJS application for
instance, is when and how templates/pages including server-side content
can interact with the servlet container given they Yeoman assumes they
live under its app directory...

How to call a dynamically created label from its associated dynamically created button's click in vb.net

How to call a dynamically created label from its associated dynamically
created button's click in vb.net

I have a tab in a form. On form load i am getting text from a text file
line by line and displaying them as labels on a form Tabcontrol Tabpage
along with dynamically displaying buttons beside them. Now on those
buttons click i want to copy the text in the associated labels.Can anyone
suggest what to go in the Nextbtn_Click event.
Dim FILE_NAME As String = "D:\1.txt"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
Dim i As Integer = 1
For Each line As String In System.IO.File.ReadAllLines(FILE_NAME)
Dim NextLabel As New Label
Dim Nextbtn As New Button
NextLabel.Text = line
Nextbtn.Text = "Copy"
NextLabel.Height = 22
Nextbtn.Width = 55
Nextbtn.Height = 22
NextLabel.BackColor = Color.Yellow
TabPage2.Controls.Add(NextLabel)
TabPage2.Controls.Add(Nextbtn)
NextLabel.Location = New Point(10, 10 * i + ((i - 1) *
NextLabel.Height))
Nextbtn.Location = New Point(120, 10 * i + ((i - 1) *
Nextbtn.Height))
AddHandler Nextbtn.Click, AddressOf Me.Nextbtn_Click
i += 1
Next
End Sub
Private Sub Nextbtn_Click(sender As Object, e As EventArgs)
End Sub

EXTJS 4: Can not load data from json file

EXTJS 4: Can not load data from json file

I am trying to load data from json file in my application but no data
loaded, I am stuck with it:
(model)Singers.js:
Ext.define('SGM.model.Singers', {
extend: 'Ext.data.Model',
fields: ['id', 'ten_that', 'nghe_danh', 'ngay_sinh', 'tieu_su',
'anh_dai_dien', 'luot_like'],
idProperty: 'id',
proxy: {
type: 'ajax',
url: 'data/singers.json',
reader: {
type: 'json',
root: 'data',
successProperty: 'success'
}
}
});
(store)Singers.js
Ext.define('SGM.store.Singers', {
extend: 'Ext.data.Store',
model: 'SGM.model.Singers',
/*data:[
{ id: 1,
ten_that: "Bui Anh Tuan",
nghe_danh: "Bui Anh Tuan",
ngay_sinh:"20/9/1992",
tieu_su: "Tieu su cua Bui Anh Tuan",
anh_dai_dien:"buianhtuan.jpg",
luot_like:100},
{
id: 2,
ten_that: "Cao Mi Kim",
nghe_danh: "Cao Mi Kim",
ngay_sinh:"20/9/1992",
tieu_su: "Tieu su cua Cao Mi Kim",
anh_dai_dien:"caomikim.jpg",
luot_like:100},
{
id: 3,
ten_that: "Pham Khanh Phuong",
nghe_danh: "Khanh Phuong",
ngay_sinh:"20/9/1992",
tieu_su: "Tieu su cua Khanh Phuong",
anh_dai_dien:"khanhphuong.jpg",
luot_like:100},
{
id: 4,
ten_that: "Ho Quang Hieu",
nghe_danh: "Ho Quang Hieu",
ngay_sinh:"20/9/1992",
tieu_su: "Tieu su cua Ho Quang Hieu",
anh_dai_dien:"hoquanhieu.jpg",
luot_like:100}
],*/
});
The inline data above work well but when I create a separated json file:
singers.js (in folder 'data') with the following code:
{
"success": true,
"results": [
{ "id": 1,
"ten_that": "Bui Anh Tuan",
"nghe_danh": "Bui Anh Tuan",
"ngay_sinh":"20/9/1992",
"tieu_su": "Tieu su cua Bui Anh Tuan",
"anh_dai_dien": "buianhtuan.jpg",
"luot_like": 100},
{
"id": 2,
"ten_that": "Cao Mi Kim",
"nghe_danh": "Cao Mi Kim",
"ngay_sinh": "20/9/1992",
"tieu_su": "Tieu su cua Cao Mi Kim",
"anh_dai_dien": "caomikim.jpg",
"luot_like":100},
{
"id": 3,
"ten_that": "Pham Khanh Phuong",
"nghe_danh": "Khanh Phuong",
"ngay_sinh": "20/9/1992",
"tieu_su": "Tieu su cua Khanh Phuong",
"anh_dai_dien": "khanhphuong.jpg",
"luot_like": 100},
{
"id": 4,
"ten_that": "Ho Quang Hieu",
"nghe_danh": "Ho Quang Hieu",
"ngay_sinh": "20/9/1992",
"tieu_su": "Tieu su cua Ho Quang Hieu",
"anh_dai_dien": "hoquanhieu.jpg",
"luot_like": 100}
]
}
And this is my folder directory:
+app
++controller
++model
+++Singers.js
++store
+++Singers.js
+view
+data
++singers.json
+app.js
-index.html.js
Thank in advanced!

am using sql code for foreach in codeigniter but there are some small problems

am using sql code for foreach in codeigniter but there are some small
problems

function get_contents() {
$this->db->select('question_no');
$this->db->from('questionnaire');
$this->db->group_by('question_no');
$query = $this->db->get();
$results = $query->result();
//print_r($results);exit;
$result_array = array();
foreach ($results as $row){
$this->db->select_avg('questionnaire.organization_answer_rating');
$this->db->from('questionnaire');
$this->db->where('questionnaire.question_no',$row->question_no);
$query = $this->db->get();
$result = $query->result();
$this->db->select_avg('questionnaire.workgroup_answer_rating');
$this->db->from('questionnaire');
$this->db->where('questionnaire.question_no',$row->question_no);
$query = $this->db->get();
$result1 = $query->result();
$info['question_no'] = $results;
$info['organization_answer_rating'] = $result;
$info['workgroup_answer_rating'] = $result1;
$result_array[]= $info;
echo '<pre>';print_r( $result_array);exit;
}
return $result_array;
}
am using the above code in which when am printing result array am getting
output as
Array
(
[0] => Array
(
[question_no] => Array
(
[0] => stdClass Object
(
[question_no] => 1
)
[1] => stdClass Object
(
[question_no] => 2
)
)
[organization_answer_rating] => Array
(
[0] => stdClass Object
(
[organization_answer_rating] => 3.0000
)
)
[workgroup_answer_rating] => Array
(
[0] => stdClass Object
(
[workgroup_answer_rating] => 3.0000
)
)
)
)
i need to get all these in same array and also one more problem is that am
getting all the questions in db but i need to get particular question_no
in that array. can someone guide me and say me what was the problem and
how to rectify it please. thanks.

Geocoder not returning name of correct city

Geocoder not returning name of correct city

I have an app that needs to get the name of a nearby city and return it as
a string. The code below has a String called cityName which is supposed to
be displaying my correct city. However, when I run the app, it says I'm in
Mumbai, India while I'm actually in a different continent altogether. How
can I fix this?
private Boolean displayGpsStatus() {
ContentResolver contentResolver = getBaseContext()
.getContentResolver();
boolean gpsStatus = Settings.Secure
.isLocationProviderEnabled(contentResolver,
LocationManager.GPS_PROVIDER);
if (gpsStatus) {
return true;
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Your Device's GPS is Disabled")
.setCancelable(false)
.setTitle("GPS Disabled")
.setPositiveButton("Enable GPS",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// finish the current activity
// AlertBoxAdvance.this.finish();
Intent myIntent = new Intent(
Settings.ACTION_SECURITY_SETTINGS);
startActivity(myIntent);
dialog.cancel();
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// cancel the dialog box
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
return false;
}
}
/*----------Listener class to get coordinates ------------- */
private class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
/*----------to get City-Name from coordinates ------------- */
cityName=null;
Geocoder gcd = new Geocoder(getBaseContext(),
Locale.getDefault());
List<Address> addresses;
try {
addresses = gcd.getFromLocation(loc.getLatitude(), loc
.getLongitude(), 1);
if (addresses.size() > 0)
cityName=addresses.get(0).getLocality();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider,
int status, Bundle extras) {
// TODO Auto-generated method stub
}
}

Friday, 13 September 2013

How can I do somthing with F12 and Shift+Enter on macos? Use NSTextView

How can I do somthing with F12 and Shift+Enter on macos? Use NSTextView

-(void)flagsChanged:(NSEvent *)theEvent
{
NSUInteger flags = [NSEvent modifierFlags] &
NSDeviceIndependentModifierFlagsMask;
if( flags == NSShiftKeyMask ){
NSLog(@"Shift - TRUE");
} else {
NSLog(@"Shift - FALSE");
}
}

Initializing a member from struct to the direction of an external function

Initializing a member from struct to the direction of an external function

Let's say I have this
typedef struct qwerty {
void *f;
} qwerty_t;
and I want to do this
static qwerty_t x = {
.f = (void *)some_external_function
};
I'm getting error: initializer element is not constant because (if I
understand correctly) the direction of some_external_function is unknown
when I'm compiling.
If that is not the correct explanation of the error, please explain what is.
Also, how can I initialize .f to the direction of that function?

2D array assignment using a for loop

2D array assignment using a for loop

I'm trying to create a grid of characters, and for this example am using a
3by 3 grid. I am using two for loops to assign from a separate one
dimensional array of characters, but the final value in each row is always
equal to the first value of the next, but can't understand why. Is
something wrong with my calculation of row and col?
char text[8] = "abcdefghi";
char grid[2][2];
int i,j;
for(i=0; i<=8; i++)
{
char c = text[i];
int row = i/3;
int col = i%3;
printf("%c row=%d col=%d i=%d\n", c, row, col, i);
grid[row][col] = c;
}
printf("------\n");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
printf("%c row=%d col=%d \n", grid[i][j], i, j);
}
}

Clojure: What is the easiest way to remove all the nil items in a nested data structure?

Clojure: What is the easiest way to remove all the nil items in a nested
data structure?

Say we have this nested vector:
(def coll [nil [["this" nil "this"] nil] nil "this"])
How would you design a remove-nil function so that all nil disappear?
(remove-nil coll)
;> [[["this" "this"]] "this"]

How to get the single value from the database from the android?

How to get the single value from the database from the android?

I have a database for the employee details,i want to get the password from
the database.am trying to get the value but am facing problem.How to
retrieve the password from the databasssse....i have column
keyid,fistname,lastname,mobile,dateofbirth,email,gender,personal id,date
of joining,security question,answer,username,password.
need to retrieve the password value
public List<String> credientials(String eid) {
List<String> labels = new ArrayList<String>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_EMPLOY, new String[] {
KEY_PASSWORD,
}, KEY_USERNAME + " = ?", new String[] { String.valueOf(eid) },
null, null, null, null);
if (cursor != null){
do{
cursor.moveToFirst();
labels.add(cursor.getString(12));
} while (cursor.moveToNext());
}cursor.close();
db.close();
return labels;
}
My Error log Cat
09-13 13:24:00.354: E/AndroidRuntime(28252): FATAL EXCEPTION: main
09-13 13:24:00.354: E/AndroidRuntime(28252): java.lang.OutOfMemoryError:
[memory exhausted]
09-13 13:24:00.354: E/AndroidRuntime(28252): at
dalvik.system.NativeStart.main(Native Method)
09-13 13:24:00.373: E/SQLiteDatabase(28252): close() was never explicitly
called on database '/data/data/com.example.analyticbeans/databases/jk'
09-13 13:24:00.373: E/SQLiteDatabase(28252):
android.database.sqlite.DatabaseObjectNotClosedException: Application did
not close the cursor or database object that was opened here
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1943)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1007)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:986)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1051)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:770)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:157)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:231)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
com.example.analyticbeans.dataBaseHelper.credientials(dataBaseHelper.java:129)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
com.example.analyticbeans.existinguserActivity.getData(existinguserActivity.java:86)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
com.example.analyticbeans.existinguserActivity.login(existinguserActivity.java:80)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
com.example.analyticbeans.existinguserActivity$1.onClick(existinguserActivity.java:55)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.view.View.performClick(View.java:3511)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.view.View$PerformClick.run(View.java:14105)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.os.Handler.handleCallback(Handler.java:605)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.os.Looper.loop(Looper.java:137)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
android.app.ActivityThread.main(ActivityThread.java:4424)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
java.lang.reflect.Method.invokeNative(Native Method)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
java.lang.reflect.Method.invoke(Method.java:511)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-13 13:24:00.373: E/SQLiteDatabase(28252): at
dalvik.system.NativeStart.main(Native Method)
09-13 13:24:00.484: E/System(28252): Uncaught exception thrown by finalizer
09-13 13:24:00.573: E/System(28252): java.lang.IllegalStateException:
Don't have database lock!
09-13 13:24:00.573: E/System(28252): at
android.database.sqlite.SQLiteDatabase.verifyLockOwner(SQLiteDatabase.java:2090)
09-13 13:24:00.573: E/System(28252): at
android.database.sqlite.SQLiteDatabase$1.entryRemoved(SQLiteDatabase.java:2182)
09-13 13:24:00.573: E/System(28252): at
android.database.sqlite.SQLiteDatabase$1.entryRemoved(SQLiteDatabase.java:2178)
09-13 13:24:00.573: E/System(28252): at
android.util.LruCache.trimToSize(LruCache.java:197)
09-13 13:24:00.573: E/System(28252): at
android.util.LruCache.evictAll(LruCache.java:285)
09-13 13:24:00.573: E/System(28252): at
android.database.sqlite.SQLiteDatabase.deallocCachedSqlStatements(SQLiteDatabase.java:2143)
09-13 13:24:00.573: E/System(28252): at
android.database.sqlite.SQLiteDatabase.closeClosable(SQLiteDatabase.java:1126)
09-13 13:24:00.573: E/System(28252): at
android.database.sqlite.SQLiteDatabase.finalize(SQLiteDatabase.java:1914)
09-13 13:24:00.573: E/System(28252): at
java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182)
09-13 13:24:00.573: E/System(28252): at
java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
09-13 13:24:00.573: E/System(28252): at
java.lang.Thread.run(Thread.java:856)

Thursday, 12 September 2013

Null pointer exception on getting drawable from ImageVeiw

Null pointer exception on getting drawable from ImageVeiw

I have: public class TestButton extends ImageButton {....
I have some code which generates a null pointer exception at:
final Drawable temp1 = babyview.getDrawable();
Before this I use:
public void dancebabydance() {
babyview = (ImageView) findViewById(R.id.baby);
Here is the xml portion:
<ImageView
android:id="@+id/baby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:src="@drawable/dbaby2"
/>
I am ideally trying to compare this dbaby2 to a drawable and see if they
are equal, and if they are change them to something new.
Can this be done extending ImageButton like this? Where am I stuffing up?

[Ruby]How to search multiple keywords in a single string line

[Ruby]How to search multiple keywords in a single string line

I am new to ruby. I want to know how to find if multiple keywords exist or
not in a single line. For example, a line "Hello, how are you?", if
"Hello" or "how" exits, return true. I try to use reg exp like
/Hello|how/, but performance is not good when there are lots of lines to
process. Maybe Regexp suits this use case, but I cannot find specific
example in google.
Thanks for the help!

on asp.net chart control some datas does not appear

on asp.net chart control some datas does not appear

some of datas in chart control does not appear. i use .net 4.0. i tried
sql view and stored procedure (i got some values from different tables).
in test query all of values comes. please any one can help me. thank you.
this is the view' code i used:
ALTER VIEW [V_TeklifSayilari] as with
hazirlayan(TeklifHazirlayanId,userName) AS ( select
teklif.TeklifHazirlayanId,kullanicim.userName FROM teklif inner join
kullanicim on teklif.TeklifHazirlayanId=kullanicim.userId
) select count(TeklifHazirlayanId) as toplamteklif,userName from
hazirlayan group by userName GO view works properly but when i connect it
to the chart kontrol, "userName" value does not appepr on X(axis).

Understanding delegate contravariance usefulness

Understanding delegate contravariance usefulness

So I have a delegate defined as:
public delegate void MyDelegate<T>(T myParameter);
Resharper suggests that I should make T contravariant as follows:
public delegate void MyDelegate<in T>(T myParameter);
Now, I have a hard time understanding what this is good for? I know it
prevents me from making T a return type, but other than that, what useful
constraints do I get by making T contravariant? That is, when it's time to
use the delegate with an instance, what instances can I create with
public delegate void MyDelegate<T>(T myParameter);
that I cannot create with
public delegate void MyDelegate<in T>(T myParameter);

encrypting in xcode decrypting nodejs

encrypting in xcode decrypting nodejs

I'm encrypting some text i want to send to a server and I have no problems
encrypting it, and decrypting it in Xcode but when I send it to the nodejs
server the result by decrypting it never comes right the encrypted data
comes always the same... I think the problem is how I use the crypto
library, here's my Xcode code:
NSString * key =@"1234567890123456";
NSString * url = @"http://flystory.herokuapp.com/register";
NSString *post = @"hola mundo!!!!!!!!!!";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding
allowLossyConversion:YES];
NSLog(@"%@",[[NSString alloc] initWithData:postData
encoding:NSASCIIStringEncoding]);
NSError *e;
CCCryptorStatus err;
postData = [postData dataEncryptedUsingAlgorithm:kCCAlgorithmAES128
key:key options:kCCOptionECBMode error:&err];
NSLog(@"%@",[[NSString alloc] initWithData:postData
encoding:NSASCIIStringEncoding]);
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"post"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"body" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *r, NSData *d,
NSError *e) {
if (e) NSLog(@"%@",e.description);
else [self handleRespondedData:d];
}];
postData = [postData decryptedDataUsingAlgorithm:kCCAlgorithmAES128
key:key options:kCCOptionECBMode error:&err];
NSLog(@"%@",[[NSString alloc] initWithData:postData
encoding:NSASCIIStringEncoding]);
to encrypt I'm using this NSData extension contained in the
NSData+CommonCrypto.h/m in https://github.com/Gurpartap/AESCrypt-ObjC
my Node.JS code goes as follows:
var express = require("express");
var app = express(express.bodyParser());
//...
app.post("*", function(request, response) {
var body = '';
request.setEncoding('hex');
request.on('data', function (data) {
body += data;
var crypto=require('crypto');
var decipher=crypto.createDecipheriv('aes-128-ecb',
'1234567890123456', '\0');
decipher.setAutoPadding(auto_padding=false);
var enc = decipher.update(body, 'hex', 'utf8') +
decipher.final('utf8');
console.log('encrypted: ' + body);
console.log('decrypted: ' + enc);
});
request.on('end', function () {
// use POST
route(handle, request.path, response, body);
});
});

Sharepoint 2010 Workflow Intermittently shows Error Occurred

Sharepoint 2010 Workflow Intermittently shows Error Occurred

Using and InfoPath form, a person will submit a request to a form library.
Upon creation of new item in the library, the workflow (using SharePoint
Designer out of the box functionality - no code) is set to automatically
start. It's a fairly simple workflow with 3 approval steps. 75% of the
time it runs perfectly fine, 25% of the time it will switch to 'Error
Occurred'. It particularly seems to error more often in the morning hours,
although not limited to that time of day. I've read just about every
article out there and have not found a solution.
-Workflow history screen will show 'Note: Due to heavy load, the latest
workflow operation has been queued. It will attempt to resume at a later
time', until it finals errors.
-Have already increased workflow throttle and batch size, issue seems to
of gotten worse since then
-Workflow history will says 'An error has occurred in [workflow name]' by
the system account.
-There appear to be no batch jobs running at the same time, no heavy work
like backups occurring
-This is occurring on more than one workflow for more than one form
library, they are all completely not related to each other
-We've checked our CPU on the server, no spikes during that time, we have
plenty of memory. We don't have a lot of workflows running at the same
time. Particularly in the morning when I'm seeing this occur the most, I'm
just about the only user submitting forms and kicking off workflows.
-We have checked to ensure our times are synced on the server (they are by
1 second) and that we have time zones set in our web applications
-If you manually restart the workflow on one that had errored, it will
process through fine again on the second try (based on that, assuming this
means it can't be related to how the SPD workflow was built or
permissions)
-Tried logging to the workflow history to see where it errors, my logging
prior to the 'approval process' step does appear in the history...
workflow appears to fail upon trying to initiate the first task. Again,
restarting workflow works fine and does assign the task, so I don't think
it could be related to anything with the task list.
Any suggestions that you may have to help me out here would be greatly
appreciated!
Below are the errors logs from 14:
*Unexpected WinWF Internal Error, terminating workflow Id#
f413610c-0981-4c37-9583-1d7cac4f0265
09/12/2013 06:57:42.65 w3wp.exe (0x2768) 0x1740 SharePoint Foundation
Workflow Infrastructure 98d4 Unexpected
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. ---> Microsoft.SharePoint.SPException: The
context has expired and can no longer be used. (Exception from HRESULT:
0x80090317) ---> System.Runtime.InteropServices.COMException (0x80090317):
The context has expired and can no longer be used. (Exception from
HRESULT: 0x80090317) at
Microsoft.SharePoint.Library.SPRequestInternalClass.SetHttpParameters(String
bstrHttpMethod, String bstrRequestDigest, UInt32 flags, Guid
gTranLockerId, Byte[]& ppsaImpersonateUserToken, Boolean bIgnoreTimeout,
String bstrUserLogin, String bstrUserKey, UInt32 ulRoleCount, String
bstrRoles, Boolean bWindowsMode, ApplicationPrincipalInfo& pAppUserInfo,
Boolean bInvalidateCachedConfigurationProperties, Int32 lAp...
09/12/2013 06:57:42.65* w3wp.exe (0x2768) 0x1740 SharePoint Foundation
Workflow Infrastructure 98d4 Unexpected ...pDomainId,
ISPManagedObjectFactory pFactory, Boolean bCallstack) at
Microsoft.SharePoint.Library.SPRequest.SetHttpParameters(String
bstrHttpMethod, String bstrRequestDigest, UInt32 flags, Guid
gTranLockerId, Byte[]& ppsaImpersonateUserToken, Boolean bIgnoreTimeout,
String bstrUserLogin, String bstrUserKey, UInt32 ulRoleCount, String
bstrRoles, Boolean bWindowsMode, ApplicationPrincipalInfo& pAppUserInfo,
Boolean bInvalidateCachedConfigurationProperties, Int32 lAppDomainId,
ISPManagedObjectFactory pFactory, Boolean bCallstack) --- End of inner
exception stack trace --- at
Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at
Microsoft.SharePoint.Library.SPRequest.SetHttpParameters(String
bstrHttpMethod, String bstrRequestDigest, UInt32 flags, Guid gTranLock...
09/12/2013 06:57:42.65* w3wp.exe (0x2768) 0x1740 SharePoint Foundation
Workflow Infrastructure 98d4 Unexpected ...erId, Byte[]&
ppsaImpersonateUserToken, Boolean bIgnoreTimeout, String bstrUserLogin,
String bstrUserKey, UInt32 ulRoleCount, String bstrRoles, Boolean
bWindowsMode, ApplicationPrincipalInfo& pAppUserInfo, Boolean
bInvalidateCachedConfigurationProperties, Int32 lAppDomainId,
ISPManagedObjectFactory pFactory, Boolean bCallstack) at
Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site,
String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean
bNotAddToContext, Byte[] UserToken, String userName, Boolean
bIgnoreTokenTimeout, Boolean bAsAnonymous) at
Microsoft.SharePoint.SPSite.GetSPRequest() at
Microsoft.SharePoint.SPSite.get_Request() at
Microsoft.SharePoint.SPSite.InitSite() at
Microsoft.SharePoint.SPSite.get_SystemAccount() at Microsoft.Shar...
09/12/2013 06:57:42.65* w3wp.exe (0x2768) 0x1740 SharePoint Foundation
Workflow Infrastructure 98d4 Unexpected
...ePoint.WorkflowActions.Helper.SplitMultiUserToObjects(WorkflowContext
context, Object val) at
Microsoft.SharePoint.WorkflowActions.Helper.MultiDisplayNameSemicolon(WorkflowContext
context, Object val) --- End of inner exception stack trace --- at
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[]
arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture,
Boolean skipVisibilityChecks) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at
System.Reflection.MethodBase.Invoke(Object obj, Ob...
09/12/2013 06:57:42.65* w3wp.exe (0x2768) 0x1740 SharePoint Foundation
Workflow Infrastructure 98d4 Unexpected ...ject[] parameters) at
Microsoft.SharePoint.WorkflowActions.CoerceActivity.Coerce() at
Microsoft.SharePoint.WorkflowActions.CoerceActivity.Execute(ActivityExecutionContext
provider) at System.Workflow.ComponentModel.ActivityExecutor1.Execute(T
activity, ActivityExecutionContext executionContext) at
System.Workflow.ComponentModel.ActivityExecutor1.Execute(Activity
activity, ActivityExecutionContext executionContext) at
System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime
workflowCoreRuntime) at System.Workflow.Runtime.Scheduler.Run()*