Saturday, 31 August 2013

Click on NSBezierPath

Click on NSBezierPath

I'm drawing a NSBezierPath line on my NSImageView. I'm creating
NSBezierPath object, setting moveToPoint, setting lineToPoint, setting
setLineWidth: and after that in drawRect of my NSImageView subclass I'm
calling [myNSBezierPath stroke]. It all works just like I want, but I
can't seem to use containsPoint: method... I tried implementing
if([myNSBezierPath containsPoint:[theEvent locationInWindow]]{
//do something
}
in -(void)mouseUp:(NSEvent*)theEvent of my NSImageView subclass but it's
never reacting and I'm sure I'm hitting that line... Am I doing something
wrong? I just need to detect if NSBezierPath is being clicked.
Cheers.

How to free Watch Henderson vs Pettis live streaming UFC?

How to free Watch Henderson vs Pettis live streaming UFC?

Watch UFC live Fighting Click Here To: Watch Henderson vs Pettis
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/

Henderson vs Pettis Live Fight DETAILS Date : Saturday, August 31, 2013
Competition: UFC MMA Major Events live Live / Repeat:Live 10:00pm ET

Model binder can't handle double.MAX string representation back to double?

Model binder can't handle double.MAX string representation back to double?

Right now I have a ViewModel with a property double Maximum. On the view
side it's kept in a hidden input.
When post backing the values, the binding silently fails. I had to put a
breakpoint on this line:
if(ModelState.IsValid)
and check which ModelState property had an error. Then I found that this
double Maximum property had an error with the following message:
The parameter conversion from type 'System.String' to type 'System.Double'
failed. See the inner exception for more information.
On the view side inspecting the HTML with Firebug I can see that the
hidden input has this value:
1.79769313486232E+308
which correctly represents double.MAX constant.
I found this Scott Hanselman post from 2005 which deals with something
similar:
Why you can't Double.Parse(Double.MaxValue.ToString()) or
System.OverloadExceptions when using Double.Parse
Is there something wrong with my app config or this direct conversion from
string back to double is not supported? I think it should handle it
without errors.
Note: I tried changing the hidden input value with Firebug and did as
Scott mentions on his post: I subtracted 1 from the last digit...
1.79769313486231E+308
and did a postback again just to find the model binder handled it
correctly this time.

SQL Error: Every derived table must have its own alias

SQL Error: Every derived table must have its own alias

I know there are many questions that deal with this error but I've done
what they have asked to fix the issue I thought. Below is what I have done
but I'm still getting the error. The goal of this script is to display all
the zipcodes within a certain radius.
$zip = 94550; // "find nearby this zip code"
$radius = 15; // "search radius (miles)"
$maxresults = 10; // maximum number of results you'd like
$sql = "SELECT * FROM
(SELECT o.zipcode, o.city, o.state,
(3956 * (2 * ASIN(SQRT(
POWER(SIN(((z.latitude-o.latitude)*0.017453293)/2),2) +
COS(z.latitude*0.017453293) *
COS(o.latitude*0.017453293) *
POWER(SIN(((z.longitude-o.longitude)*0.017453293)/2),2)
)))) AS distance
FROM zipcoords z,
zipcoords o,
zipcoords a
WHERE z.zipcode = ".$zip." AND z.zipcode = a.zipcode AND
(3956 * (2 * ASIN(SQRT(
POWER(SIN(((z.latitude-o.latitude)*0.017453293)/2),2) +
COS(z.latitude*0.017453293) *
COS(o.latitude*0.017453293) *
POWER(SIN(((z.longitude-o.longitude)*0.017453293)/2),2)
)))) <= ".$radius."
ORDER BY distance)
ORDER BY distance ASC LIMIT 0,".$maxresults;
$result = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());
while ($ziprow = mysql_fetch_array($result)) {
$zipcode = $ziprow['zipcode'];
echo "$zipcode<br>";
}
All my columns in the database are varchar. zipcode is the primary and I
would make it INT but it doesn't allow there to be 0's at the beginning of
the zipcodes. So I changed it to varchar and it allowed it. Thanks for the
help!

Arduino + bluetooth + power supply + switcher

Arduino + bluetooth + power supply + switcher

I'm completely new in this field, so I need your help!!
I'd like to remotely control inside the house (bluetooth or wifi) some
appliances (lamp, fan...).
I would like to have a controllable system from my Windows pc (C# as a
programming language) and from my tablets/smartphones (phonegap solution
'cause I have different OS). If the phonegap solution it is not possible
no problem. that's a surplus, I just need it for my pc.
I think that one idea could be having just one board with a bluetooth/wifi
module and connected to different high voltage output letting me the
choice of switching off/on some appliances.
The other idea could be having one board for each appliances but maybe
this would cost a lot.
Overall can I connect the bluetooth board/shield to different devices
without pairing them everytime?
If you can please suggest me some good tutorials and some good places
where I could buy everything :-)
Thank you very very much!!

how to remove MarkerOptions objects in google api v2?

how to remove MarkerOptions objects in google api v2?

I added some markers in my map and now i want to remove them. is there any
method that i can use to remove my marker ? I used MarkerOption class to
build my markers and add() method of GoogleMap to add them. and I have a
reference of all of my markers in a List. I really need your help.

When are global variables actually considered good/recommended practice?

When are global variables actually considered good/recommended practice?

I've been reading a lot about why global variables are bad and why they
should not be used. And yet most of the commonly used programming
languages support globals in some way.
So my question is what is the reason global variables are still needed, do
they offer some unique and irreplaceable advantage that cannot be
implemented alternatively? Are there any benefits to global addressing
compared to user specified custom indirection to retrieve an object out of
its local scope?
As far as I understand, in modern programming languages, global addressing
comes with the same performance penalty as calculating every offset from a
memory address, whether it is an offset from the beginning of the "global"
user memory or an offset from a this or any other pointer. So in terms of
performance, the user can fake globals in the narrow cases they are needed
using common pointer indirection without losing performance to real global
variables. So what else? Are global variables really needed?

Friday, 30 August 2013

Unique function to read different streams

Unique function to read different streams

I'm looking for a way to read file and stdin stream using a unique void
function in C. I'm trying to use this function:
#define ENTER 10 //'\n' ASCII code
........
void read(FILE *stream, char *string) {
char c;
int counter = 0;
do {
c = fgetc(stream);
string = realloc(string, (counter+1) * sizeof(char));
string[counter++] = c;
} while(c != ENTER && !feof(stream));
string[counter-1] = '\0';
}
but it's working only with stdin stream. When I'm using a text file, the
file content isn't visible outside the function. I'm calling this function
like:
read(stdin, inputString);
read(inputFile, fileContent);
and only works right in the first case.
P.S.: Initially, inputString an fileContent have been declared as
char *inputString = malloc(sizeof(char));
char *fileContent = malloc(sizeof(char));
and I know fgetc returns int, the char by char reallocation are expensive
(but I need to use only the necessary memory) and EOF or '\n' are stored
in string (but are replaced by 0-terminator after).

Thursday, 29 August 2013

Weird behaviour with jQuery datepicker in IE10

Weird behaviour with jQuery datepicker in IE10

I have added a jQuery datepicker to my MVC application and it seems to be
working perfectly in all browsers except for Internet Explorer.
On click of the cell the calendar control appears but clicking through the
months using the navigation icons seems to stop after varying amount of
clicks. The date cells then become unclickable and I am unable to set the
date.
Has anyone ever seen this issue before? And if so was there a solution
available?
My javascript code is as follows:
$(document).ready(function () {
$('#expirydate').datepicker({ dateFormat: 'dd/mm/yy', changeMonth:
true, changeYear: true });
});
And my HTML is as follows:
<label for="expirydate">Expiry Date:</label>
<input type="text" id="expirydate" class="datepicker" name="expirydate"
/><br />

Wednesday, 28 August 2013

packageManager.getInstalledPackages(0) doesn't return all apps

packageManager.getInstalledPackages(0) doesn't return all apps

I'm using
PackageManager packageManager = getPackageManager();
List<PackageInfo> mApps = packageManager.getInstalledPackages(0);
to retrieve a list of all installed apps. However, the list doesn't
contain all installed apps, some (like Twitter, for example) are missing.
To test this, I'm using
int length = mApps.size();
for(int i=0; i<length; i++){
PackageInfo info = mApps.get(i);
Log.i(TAG, "Package: " + info.packageName);
}
com.twitter.android and others aren't among the logged strings, even
though they are installed on the phone.
P.S.: I've also tried
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> mApps =
getPackageManager().queryIntentActivities(mainIntent, 0);
which shows Twitter, but doesn't (obviously) return processes that can't
be launched via the launcher, such as "Download Manager" or "System UI". I
need a method that returns both system apps and third-party apps reliably.

Laravel seed MySQL from CSV

Laravel seed MySQL from CSV

I have several CSV files that I need to pull certain columns from to seed
MySQL table. How do I do this? Anyone have a code example to help me out.
I'm using Laravel 4.

Is there another simpler method to solve this elementary school math problem=?iso-8859-1?Q?=3F_=96_math.stackexchange.com?=

Is there another simpler method to solve this elementary school math
problem? – math.stackexchange.com

I am teaching an elementary student. He has a homework as follows. There
are 16 students who use either bicycles or tricycles. The total number of
wheels is 38. Find the number of students using …

CAS credential band

CAS credential band

A help please
I have a problem when I want to use the CAS authentication, the error is
invalid credentials, this shows me what the log
Browser
Estado HTTP 401 - Authentication Failed: Bad credential`s
Log CAS
ServiceValidateController [ERROR] TicketException generating ticket for:
[callbackUrl: https://localhost:8443/receptor]
Thanks for your time
DispatcherServlet [DEBUG] Rendering view
[org.springframework.web.servlet.view.RedirectView: unnamed; URL
[https://geo.org.bo:443/geonetwork/j_spring_cas_security_check?ticket=ST-2-dLgdARnZdtPHWZa9krt9-cas]]
in DispatcherServlet with name 'cas'
DispatcherServlet [DEBUG] Successfully completed request
DispatcherServlet [DEBUG] DispatcherServlet with name 'cas' determining
Last-Modified value for [/cas/serviceValidate]
SimpleUrlHandlerMapping [DEBUG] Mapping [/serviceValidate] to handler
'org.jasig.cas.web.ServiceValidateController@26a75b82'
DispatcherServlet [DEBUG] Last-Modified value for [/cas/serviceValidate]
is: -1
DispatcherServlet [DEBUG] DispatcherServlet with name 'cas' processing
request for [/cas/serviceValidate]
CasArgumentExtractor [DEBUG] Extractor generated service for:
https://geo.org.bo:443/j_spring_cas_security_check
HttpBasedServiceCredentialsAuthenticationHandler [DEBUG] Attempting to
resolve credentials for [callbackUrl: https://localhost:8443/receptor]
HttpClient [DEBUG] Response Code did not match any of the acceptable
response codes. Code returned was 404
AuthenticationManagerImpl [INFO] AuthenticationHandler:
org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler
failed to authenticate the user which provided the following credentials:
[callbackUrl: https://localhost:8443/receptor]
ServiceValidateController [ERROR] TicketException generating ticket for:
[callbackUrl: https://localhost:8443/receptor]
org.jasig.cas.ticket.TicketCreationException:
error.authentication.credentials.bad
at
org.jasig.cas.CentralAuthenticationServiceImpl.delegateTicketGrantingTicket(CentralAuthenticationServiceImpl.java:291)

Immidate command during MySQL Transaction

Immidate command during MySQL Transaction

During a sign up process, I'm using a Transaction to enclose all the
operations involved in the setup of an account so that in the event of a
problem they can be rolled back.
The last item that occurs is a billing process so that if payment is
successful, the Commit operation is called to finalise the account
creation, if say, the user's card is declined, I roll back.
However, I am wondering what the best way is to write a log of the
attempted billing to the database without that particular write operation
being 'covered' by the transaction protecting the other database
operations. Is this possible in MySQL? The log table in question does not
depend on any others. Holding on to the data in the application to write
it after the rollback operation is somewhat difficult due to legacy
payment libraries created before we started using transactions. I'd like
to avoid that if MySQL has a solution.

How do you use output redirection in combination with here-documents=?iso-8859-1?Q?=3F_=96_unix.stackexchange.com?=

How do you use output redirection in combination with here-documents? –
unix.stackexchange.com

Let's say I have a script that I want to pipe to another command or
redirect to a file (piping to sh for the examples). Assume that I'm using
bash. I could do it using echo: echo "touch somefile ...

Tuesday, 27 August 2013

How to update Listview item position when i updating lisview

How to update Listview item position when i updating lisview

I creating dialog and into dialog given a list of items.and also on dialog
i have added search functionality.when i clicking on items its get correct
item position but when i search list its not updated with data items
rather i cant retrieve exactly clickable items. Following is my Code.
public void uploadFromDirve(View vi) {
EditText et;
//setContentView(R.layout.list_dialog);
// TODO Auto-generated method stub
listDialog = new Dialog(Project_Define_Activity.this);
listDialog.setTitle("Select Item");
LayoutInflater li = (LayoutInflater)
Project_Define_Activity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = li.inflate(R.layout.list_dialog, null, false);
listDialog.setContentView(v);
listDialog.setCancelable(true);
//there are a lot of <span id="IL_AD7" class="IL_AD">settings</span>,
for dialog, <span id="IL_AD1" class="IL_AD">check</span> them all out!
ListView list1 = (ListView) listDialog.findViewById(R.id.listview);
adapter=new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,names);
list1.setAdapter(adapter);
et=(EditText)listDialog.findViewById(R.id.edit_Search);
et.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int
arg3) {
// When user changed the Text
Project_Define_Activity.this.adapter.getFilter().filter(cs);
adapter.notifyDataSetChanged();
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});
//list1.setAdapter(new
ArrayAdapter<String>(Project_Define_Activity.this,android.R.layout.simple_list_item_1,names));
//now that the dialog is set up, it's time to <span id="IL_AD2"
class="IL_AD">show</span> it
list1.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> adapter, View arg1, final
int arg2,
long arg3) {
// TODO Auto-generated method stub
AlertDialog.Builder builder = new
AlertDialog.Builder(Project_Define_Activity.this);
builder.setMessage("Attach file "+arg2)
.setPositiveButton("Attach ", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
System.out.println("OK CLICKED");
Log.e("Selected", names.get(arg2));
fileflag = 1;
fileindex = arg2;
listDialog.cancel();
nameOfFile.setText(names.get(arg2));
}
});
builder.setNegativeButton("cancel", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
listDialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.setTitle("Information");
alert.show();
}
});
listDialog.show();
}

Howto specify a Model for List

Howto specify a Model for List

This is my JSON data returned from the server. I am not seeing my combo
getting loaded. What is wrong here?
{"suffixList":["-1","-2","-3"]}
Model:
Ext.define('ExtMVC.model.Suffix', {
extend: 'Ext.data.Model',
fields: [
{name: 'suffix'}
]
});
Store:
Ext.define('ExtMVC.store.Suffixes', {
extend: 'Ext.data.Store',
model: 'ExtMVC.model.Suffix',
autoLoad : false,
proxy: {
type: 'ajax',
url: 'http://'+window.location.host+'/populateCombo',
reader: {
type: 'json',
root: 'suffixList'
}
}
});
View:
{
xtype:'combo',
id: 'suffix',
name: 'suffix',
store : 'Suffixes',
displayField: 'suffix',
valueField: 'suffix'
}

How to block ruby exec commands

How to block ruby exec commands

Does anybody know how to block/disable ruby exec commands? There are three
commands that execute shell commands in ruby: exec, system, and %x() or
``. I want to block/disable exec commands.

Spring webflow - transition

Spring webflow - transition

I am newbie to Spring web flow. Just started with simple 2 screen project
along thymeleaf. I could get on to the first flow but unable to move to
second screen. If I click on OrderAward I keep coming to first screen. I
see that JSESSIONID is same in two requests. Not able to figure out the
issue.
Here are the files I have configured(referred from hotel booking Spring
web flow example)
webflow-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="
_http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
_http://www.springframework.org/schema/webflow-config
_http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">
<!-- Executes flows: the entry point into the Spring Web Flow system -->
<webflow:flow-executor id="flowExecutor">
<webflow:flow-execution-listeners>
<webflow:listener ref="securityFlowExecutionListener" />
</webflow:flow-execution-listeners>
</webflow:flow-executor>
<!-- The registry of executable flow definitions -->
<webflow:flow-registry id="flowRegistry"
flow-builder-services="flowBuilderServices" base-path="/WEB-INF">
<webflow:flow-location-pattern value="/**/*-flow.xml" />
</webflow:flow-registry>
<!-- Plugs in a custom creator for Web Flow views -->
<webflow:flow-builder-services id="flowBuilderServices"
view-factory-creator="mvcViewFactoryCreator"
development="true" validator="validator" />
<!-- Configures Web Flow to use Tiles to create views for rendering;
Tiles allows for applying consistent layouts to your views -->
<bean id="mvcViewFactoryCreator"
class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers" ref="tilesViewResolver"/>
<property name="useSpringBeanBinding" value="true" />
</bean>
<!-- Installs a listener to apply Spring Security authorities -->
<bean id="securityFlowExecutionListener"
class="org.springframework.webflow.security.SecurityFlowExecutionListener"
/>
<!-- Bootstraps JSR-303 validation and exposes it through Spring's
Validator interface -->
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
</beans>
award-flow.xml is
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<secured attributes="ROLE_USER" />
<input name="awardId" type="java.lang.String" />
<on-start>
<evaluate expression="awardService.findById(awardId)"
result="flowScope.award" />
</on-start>
<view-state id="order" model="award">
<on-render>
<render fragments="body" />
</on-render>
<transition on="order" to="orderAward"/>
</view-state>
<end-state id="orderAward">
<output name="confirmed" value="'Your order is confirmed.'"/>
</end-state>
<end-state id="cancel" />
</flow>
order.html is
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:tiles="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org"
lang="en">
<head>
<meta charset="utf-8" />
<title>Exchange Loyalty Points</title>
</head>
<body>
<form action="#" th:object="${award}" method="get"
th:action="${flowExecutionUrl}">
<span th:text="${award}"></span>
<p>
<button type="submit" id="orderAward" name="_eventId_order"
value="orderAward">OrderAward</button>
<input type="hidden" name="flowExecutionKey"
th:value="${flowExecutionKey}"/>
<button type="submit" name="_eventId_cancel" >Cancel</button>
</p>
</form>
</body>
</html>

Monday, 26 August 2013

how to parse results of joint query in hibernate

how to parse results of joint query in hibernate

In my project I have 2 beans (Demande & Candidat ), and I want to execute
a join query with Hibernate like this:
String squery="select d.date_demande, c.nom, c.prénom from Demande d ,
Candidat c where d.id_candidat=c.id_candidat";
SQLQuery query=session.createSQLQuery(squery);
The issue is that I don't know which object this query returns. I want to
put the result of this query in a list so I can use it in a jsp file
easily.

Warning: Overfull \hbox in table

Warning: Overfull \hbox in table

Consider the following example:
\documentclass{article}
\usepackage{booktabs,dcolumn}
\usepackage{siunitx}
\newcommand*\mc[1]{\multicolumn{2}{c}{Eleverne fra $9$.~#1}}
\begin{document}
\begin{table}
\def\spc{\hspace{0.8em}}
\centering
\caption{Something.}
\label{tbl:1}
\begin{tabular}{
S[table-format = 2.1]
>{\spc}S[table-format = 2]
S[table-format = 3]
>{\spc}S[table-format = 2]
S[table-format = 3]
}
\toprule
{S{\o}vnm{\ae}ngde} & \mc{A} & \mc{B} \\
\midrule
\si{\hour} & {Abs.} & {Rel.} & {Abs.} & {Rel.} \\
\midrule
6.5 & 1\spc & 4 & 0\spc & 0 \\
7 & 4\spc & 16 & 2\spc & 10 \\
7.5 & 3\spc & 12 & 3\spc & 15 \\
8 & 8\spc & 32 & 9\spc & 45 \\
8.5 & 5\spc & 20 & 3\spc & 15 \\
9 & 2\spc & 8 & 3\spc & 15 \\
9.5 & 1\spc & 4 & 0\spc & 0 \\
10 & 1\spc & 4 & 0\spc & 0 \\
\midrule
& 25\spc & 100 & 20\spc & 100 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

I get the following warning:
Overfull \hbox (8.00003pt too wide) detected at line
for lines 27--36.
How do I get rit of these without changing the output layout in the table?

How do i suppress "Preparing Windows" in windows embedded 8?

How do i suppress "Preparing Windows" in windows embedded 8?


Is there an option in windows embedded ICE or through the registry to
suppress or hide the screen shown?

How to send this Android device id to database using JSON?

How to send this Android device id to database using JSON?

Do Android devices have a unique id, and if so, what is a simple way to
access it via java? How to send this Android device id to database using
JSON, Kindly Help me,Thanks in Advance.

Create image buttons in jquery mobile

Create image buttons in jquery mobile

Im trying to create a button in jquery mobile only with a image and no
text, as far as able to do is to add a data-icon, But i have i feeling it
could be done better.
<a onclick="newfunction();" data-icon="plus" data-iconpos="notext" ></a>

Sunday, 25 August 2013

Webapplication common resources & Loadbalance

Webapplication common resources & Loadbalance

I am about to implement load balancing with apache webserver and two
tomcat servers.
The war deployed on both tomcats has common resources like images and css
folders, which are quietly large, so if some change happens in image i
have to do a copy and past again in the other war file deployed.
I am looking out to try to map a fix directory for both the war files that
will fetch from common folder. (i.e Tomcat 1 and Tomcat 2 will access css
folder from C:\css\ same for images )
I tried writing servlet that deployed images but that was not feasible.
Any other way to work around for high availability for resource serving ?
Please Assist if you have any idea.

Unqualified IDs and Template Classes

Unqualified IDs and Template Classes

I've been writing a custom class for a circular list, called CList. I've
been basing it off a homework assignment I completed a long while ago with
a lot of copy paste so I don't exactly remember exactly everything I've
been writing works.
Anyway, simply trying to include the .h file causes me the error on the
using namespace std line:
main.cpp:11: error: expected unqualified-id before ';' token
As well as two errors pointing to a function in my code:
In file included from main.cpp:9:
CList.h:119: error: non-template 'CIterator' used as template
CList.h:119: note: use 'CList<T>::template CIterator' to indicate that it
is a template
This is the function in question:
template <class T>
typename CList<T>::CIterator<T> CList<T>::push(T const& v)
{
size++;
Node<T>* p = new Node<T>(v);
if (this -> size_ == 1)
{
head = p;
tail = p;
p -> next = p;
p -> prev = p;
}
else
{
tail -> next = p;
p -> next = head;
p -> prev = tail;
head -> prev = p;
tail = p;
}
return CIterator(p);
}
I don't really understand what the error here is. I am telling the
function to return a CIterator of a CList, and am denoting that this
function is part of the CList class. That is what I understand when I read
the line
typename CList<T>::CIterator<T> CList<T>::push(T const& v)
Why does it think that CIterator is the template when clearly T is the
template? I'm just confused.

duplicate results from mysql statement

duplicate results from mysql statement

I have this select query
SELECT * FROM Category cgy, Product pd, Transactions tr WHERE cgy.CatID =
1 AND tr.payment_status = 'Completed' AND pd.pid=cgy.pid
with that query I am only meant to get 1 result back but unfortunately I
am getting 2 of the same result. I don't understand why because I have
join both the primary key and foreign key.
Transactions doesn't have any key related to any of those tables

Can not connect to lighthttpd from my laptop

Can not connect to lighthttpd from my laptop

I am using Lighthttpd with php and mysql it is working fine as it should.
i can connect to my server from android browser by typing 127.0.0.1:8080
but when i connect it from my computer by typing the address:8080 it says
Server is taking too long to respond
Note: I got the ip from adb shell netcfg

foxpro in Google drive

foxpro in Google drive

Sir,
I am using google drive. In this I can easily view MS Excel file with the
same Excel format. However I could not open foxpro or run foxpro program.
Kindly advice me how to use foxpro in google drive.
Thanking you,
With regards, Jayakumar K

Saturday, 24 August 2013

C - runtime error, `malloc(sizeof(int))` causing program to crash

C - runtime error, `malloc(sizeof(int))` causing program to crash

Here is a piece of code:
int* linenump;
// ... other stuff
printf("----\n");
linenump = malloc(sizeof(int));
printf("*****\n");
The program only print out ---- then stopped, pop up a window says that
the program has stopped, I paste the code in VS then build&run it, no
errors, the program works fine.
It's a console application.
So, what I want to know is, in what situation that this will happen? and
how should solve it?
Thanks in advance.

Need help on deleting row(s) from SQLCE Database

Need help on deleting row(s) from SQLCE Database

another question today. This time, I'm having trouble deleting a row from
an SQLCE database.
private void Form1_Load(object sender, EventArgs e)
{
// Create a connection to the file datafile.sdf in the program folder
string dbfile = new
System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName
+ "\\userDtbs.sdf";
SqlCeConnection connection = new SqlCeConnection("datasource=" +
dbfile);
// Read all rows from the table test_table into a dataset (note,
the adapter automatically opens the connection)
SqlCeDataAdapter adapter = new SqlCeDataAdapter("SELECT * FROM
history", connection);
DataSet data = new DataSet();
adapter.Fill(data);
//Delete from the database
using (SqlCeCommand com = new SqlCeCommand("DELETE FROM accounts
WHERE Id = 0", connection))
{
com.ExecuteNonQuery();
}
// Save data back to the databasefile
var cmd = new SqlCeCommandBuilder(adapter);
adapter.Update(data);
// Close
connection.Close();
}
My program's giving me an error telling me that connection is in a closed
state, and I can't figure out why it would close before the DELETE command
is executed.

How does gmail show desktop notifications

How does gmail show desktop notifications

What is the method used by gmail to show desktop notifications with
Chrome? Can you please point me to another example, or to the
documentation?

text disappears when attachments are downloaded

text disappears when attachments are downloaded

Using att yahoo mail on htc EVO. When I open mail there is message text
which I can read. When attachments finish downloading the message text
disappears never to be seen again. I can read attachments ok but message
text has disappeared.

Sound not working in Admin mode, but in Guest mode

Sound not working in Admin mode, but in Guest mode

Sound system is mute in Admin mode but is very well working in Guest mode.
Sound is also working when the user is not logged.

Visual Studio Office 365 SharePoint Apps - codebhind and C# classes SharePoint Hosted

Visual Studio Office 365 SharePoint Apps - codebhind and C# classes
SharePoint Hosted

Did a simple deployment of sharePoint Hosted App from Visual Studio... it
worked - but I want to understand the limits of what I can do from visual
studio.
I see no aspx page cs codebehind in the solution. Any way to do that? I
added a c# class, but will I be able to reference it? so, If I want to
bind SPO List data to a asp.net gridview, where/how should I do that?

Why CentOS server hanged?

Why CentOS server hanged?

I have a linux Server, on CentOS 6.2. Recently my server got hanged and I
had to reboot it forcefully.
Now the client is asking me the reason? Nothing useful in apache/mysql
log. Suggessions?

Friday, 23 August 2013

How to build a simple string from a multidimensional array?

How to build a simple string from a multidimensional array?

Basically, I have a multidimensional array that I need to build into a
simple string.
Quite an easy question, although it has been eating away at me for quite
some time now since I can't seem to nail it.
Here is an example of how my array could look with just 3 questions within
it:
[["question1","answer1","answer2","answer3","answer4"],["question2","answer1","answer2","answer3","answer4"],["question3","answer1","answer2","answer3","answer4"]]
For example, D.rows[0][0] would be "question1" and D.rows[2][3] would be
"answer3", just to clarify.
Here is how it must be saved into a string as:
question1,answer1,answer2,answer3,answer4
question2,answer1,answer2,answer3,answer4
question3,answer1,answer2,answer3,answer4
Each element must have a comma between them, and each question must be
separated by a line-break.
I had this working with a foreach loop in PHP, although I decided to
convert all my code to Javascript and I am no expert when it comes to
Javascript or multidimensional arrays.
Thanks in advance!

How does CUDA handle multiple updates to memory address?

How does CUDA handle multiple updates to memory address?

I have written a CUDA kernel in which each thread makes an update to a
particular memory address (with int size). Some threads might want to
update this address simultaneously.
How does CUDA handle this? Does the operation become atomic? Does this
increase the latency of my application in any way? If so, how?
Thank you very much!

Bootstrap 3: Alignment of Close Icon

Bootstrap 3: Alignment of Close Icon

Close Icon is acting weird.
Code
<div class="well sidebar-nav">
<ul class="list-unstyled">
<li>File Uploaded</li>
<li><a href="#">File 1</a> <button type="button"
class="close" aria-hidden="true">&times;</button></li>
<li><a href="#">File 2</a> <button type="button"
class="close" aria-hidden="true">&times;</button></li>
<li><a href="#">File 3</a> <button type="button"
class="close" aria-hidden="true">&times;</button></li>
</ul>
</div>
It's appearing like this:

unable to connect to ClearDB Mysql from NodeJS on Heroku server

unable to connect to ClearDB Mysql from NodeJS on Heroku server

ANy idea how can I connect from NodeJs to the Mysql ClearDB on Heroku?
I was able to connect to the ClearDB Mysql runing on Heroku from Navicat,
I even created a table called t_users. But I'm having problems connecting
from NodeJs from Heroku.
This is my code, it is very simple: everything works find until it tries
to connect to MySQL
web.js:
var express = require("express");
var app = express();
app.use(express.logger());
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'us-cdbr-east-04.cleardb.com',
user : 'b32fa719432e40',
password : '87de815a',
database : 'heroku_28437b49d76cc53'
});
connection.connect();
app.get('/', function(request, response) {
response.send('Hello World!!!! HOLA MUNDOOOOO!!!');
connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
if (err) throw err;
response.send('The solution is: ', rows[0].solution);
});
});
var port = process.env.PORT || 5000;
app.listen(port, function() {
console.log("Listening on " + port);
});
This is what I got when I run on the command line: Heroku config
C:\wamp\www\Nodejs_MySql_Heroku>heroku config
=== frozen-wave-8356 Config Vars
CLEARDB_DATABASE_URL:
mysql://b32fa719432e40:87de815a@us-cdbr-east-04.cleardb.com/heroku_28437b49d76cc53?reconnect=true
PATH: bin:node_modules/.bin:/usr/local/bin:/usr/bin:/bin
This is the LOG: http://d.pr/i/cExL
ANy idea how can I connect from NodeJs to the Mysql ClearDB on Heroku? Thanks

Why does a wrong override compile ? (MinGW)

Why does a wrong override compile ? (MinGW)

I have this code :
class A
{
virtual void operator()(std::complex<double>* const input_spectrum,
double* const noise_spectrum) = 0;
};
class B : public A
{
virtual void operator()(std::complex<double>* input_spectrum,
double* noise_spectrum) override;
}
I don't get why it compiles ? The const qualifiers are different, so it
should throw an error, doesn't it ?. Running under MinGW 4.8

Saving "post" link in Chrome

Saving "post" link in Chrome

So I've filled out a form and it's returned a result. Now if this was a
"get" request, I'd see all the parameters in the URL, and be able to send
the link to someone else to reproduce the result. However, I believe this
is sent as a post request, so sending the link just goes back to the
original page.
Is there anyway to generate a link that reflects the parameters sent for a
post request? I think even if it's redone as a get request it'll work
fine, the form probably won't care where it's getting it's data from.

Thursday, 22 August 2013

XNA Direction based on Rotation

XNA Direction based on Rotation

I have an arrow in my XNA Project, which I have successfully made to
rotate towards the position of the mouse with this code-
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Test
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D arrowSprite;
float rotation;
Vector2 direction;
Vector2 position;
float speed;
Vector2 mousePos;
SpriteFont font1;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to
before starting to run.
/// This is where it can query for any required services and load
any non-graphic
/// related content. Calling base.Initialize will enumerate
through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
position = new Vector2(GraphicsDevice.Viewport.Width / 2,
GraphicsDevice.Viewport.Height / 5);
speed = 1000.0f;
this.IsMouseVisible = true;
MouseState mouse = Mouse.GetState();
mousePos.X = mouse.X;
mousePos.Y = mouse.Y;
rotation = Angle(position, mousePos);
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
arrowSprite = Content.Load<Texture2D>("Sprites\\Arrow");
font1 = Content.Load<SpriteFont>("Sprites\\Test");
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to
unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing
values.</param>
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
MouseState mouse = Mouse.GetState();
mousePos.X = mouse.X;
mousePos.Y = mouse.Y;
rotation = Angle(position, mousePos);
direction = new Vector2((float)Math.Cos(rotation),
(float)Math.Sin(rotation));
position += direction * 10.0f *
(float)gameTime.ElapsedGameTime.TotalSeconds;
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing
values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
spriteBatch.Begin();
spriteBatch.Draw(arrowSprite, position, null, Color.White,
rotation, new Vector2(arrowSprite.Width / 2,
arrowSprite.Height / 2), 1.0f, SpriteEffects.None, 1.0f);
spriteBatch.DrawString(font1, mousePos.X.ToString()+ " " +
mousePos.Y.ToString(), new
Vector2(GraphicsDevice.Viewport.Width / 2, 0), Color.White);
//spriteBatch.DrawString(font1, "Rotation:" +
rotation.ToString(), Vector2.Zero, Color.White);
spriteBatch.DrawString(font1, "Direction" +
direction.ToString(), Vector2.Zero, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
public static float Angle(Vector2 from, Vector2 to)
{
return (float)Math.Atan2(from.X - to.X, to.Y - from.Y);
}
}
}
However, when I run the code, the arrow simply rotates AROUND the mouse,
and the radius at which it does so expands slightly over time. I wish for
the arrow to rotate TO the mouse and then it to move towards the area it's
rotated to. Thanks, any help is appreciated.

C# calling external method (delegate) from within

C# calling external method (delegate) from within

I'm generating and executing C# from within a C# program using as
described here.
As you can see, one can call "Execute" method of the compiled code via
classType.GetMethod("Execute").Invoke(instance, args).
The variable args is an object array of parameters to be passed to the
Execute method. I've been able to pass things relatively easy and without
issue using this system.
Now here's the big issue... I need to pass a callback function (eg a
Delegate) so that the Execute method will be able to signal stuff to the
main program. I've been trying to pass a typed Delegate that matches the
signature, but it failed (wouldn't even run). Next I tried passing a
Delegate without specifying the type which also failed (this time it
failed at when the call was attempted). I also tried passing it as a
normal object and cast it back inside the generated code, but it didn't do
anything different.
Since I'm not this much into C#, I think I'm missing something very basic.
Also, I don't have a valid test case code...but it shouldn't be too
difficult to work with the link I provided above..
See also: http://support.microsoft.com/kb/304655

Echo Hebrew from mysql database to localhost

Echo Hebrew from mysql database to localhost

I have a mysql database and i'm using phpMyAdmin. I have a table contains
names in Hebrew (defined as VARCHAR and "uft8_general_ci") I tried to
fetch these names and print them as JSON array using the following php
code:
// array for JSON response
$response = array();
// include db connect class
include 'db_config.php';
// connecting to db
//$db = new DB_CONNECT();
$mysqli = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE);
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
/* change character set to utf8 */
if (!$mysqli->set_charset('utf8')) {
printf("Error loading character set utf8: %s\n", $mysqli->error);
} else {
printf("Current character set: %s\n", $mysqli->character_set_name());
}
// get all contacts from contacts table
$result = $mysqli->query("SELECT * FROM myList");
// check for empty result
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$response[] = $row;
}
// echoing JSON response
echo json_encode($response);
} else {
// no contacts found
$response["success"] = 0;
$response["message"] = "No contacts found";
// echo no users JSON
echo json_encode($response);
}
The output I get in my localhost is:
[{"first_name":"\u05d0\u05de\u05d9\u05e8","last_name":"\u05de\u05d6\u05e8\u05d7\u05d9","phone":"516"},{"first_name":"\u05d0\u05d9\u05dc\u05df","last_name":"\u05de\u05d6\u05e8\u05d7\u05d9","phone":"490"},{"first_name":"\u05d0\u05d5\u05e8\u05d4","last_name":"\u05de\u05d6\u05e8\u05d7\u05d9","phone":"490"},{"first_name":"\u05d0\u05d9\u05d9\u05dc\u05d4","last_name":"\u05e4\u05d8\u05e8","phone":"636"},{"first_name":"\u05e2\u05d5\u05d6","last_name":"\u05e4\u05d8\u05e8","phone":"636"},{"first_name":"\u05d0\u05e1\u05e0\u05ea","last_name":"\u05d1\u05e8\u05d9","phone":"629"},{"first_name":"\u05e9\u05d5\u05e9\u05d9","last_name":"\u05d0\u05dc\u05de\u05e7\u05d9\u05d9\u05e1","phone":"554"},{"first_name":"\u05e9\u05dc\u05d5\u05dd","last_name":"\u05d0\u05dc\u05de\u05e7\u05d9\u05d9\u05e1","phone":"554"},{"first_name":"\u05de\u05e8\u05d9\u05dd","last_name":"\u05d1\u05e8\u05d9","phone":"491"},{"first_name":"\u05d9\u05d5\u05e1\u05d9","last_name":"\u05d1\u05e8\u05d9","phone":"491"}]
How can i fix it so i will be able to see Hebrew characters instead of
this unicoding?
Thanks!

How to get keys and values from a dictionary

How to get keys and values from a dictionary

So I have a dictionary that is set up like:
Dictionary<DateTime, List<Double>>
The date and times are months I pull from an excel spreadsheet and then my
integers is the dollar amount. The columns look like this:
7/1/10 | 6/1/10
----------------
100.00 | 90.00
----------------
3.00 | 20.00
----------------
35.00 | 10.00
and so on and so forth for about 6 months. I need to get these keys and
the values. I need to put it into my database. For example for the values
100.00, 3.00, 35.00 they all coordinate with month 7/1/10 (the first key
has the 3 Values under it and etc.)
Could someone just show me how to iterate over these things? When I
debugged my dictionary put's all the info in correctly but I can't pull
them back out.

Python Tools - Unable to run commands in interpreter

Python Tools - Unable to run commands in interpreter

I'm trying to get south working in my Visual Studio environment but I
can't seem any of the commands shown in the tutorial to work like
manage.py schemamigration movies --initial that will just show the
following error
File "<stdin>", line 1
manage.py schemamigration movies --initial
^
SyntaxError: invalid syntax
I've tried using Django Shell, Validate Django App..., Django Sync DB...
options from the project context menu to open the interpreter and Tools >
Python Tools > Python 64-bit 2.7 Interactive but neither of those worked.
I'm using Visual Studio Ultimate 2013 Preview with Python Tools version 2.0.

aligning vector column

aligning vector column

I have the next latex code:
$$\begin{align*}\pi(X)f(x) = \frac{d}{dt}\Pi(e^{tX})\vert_{t=0} f(x) &=
\frac{d}{dt}
(\Pi(e^{tX})f(x))\vert_{t=0})= \\
&=\frac{d}{dt}(f(e^{-tX}x))\vert_{t=0} & \\
&= \nabla_{\xi} f \l`enter code here`eft(-\[ \left( \begin{array}{ccc}
X_{11} & \cdots & X_{1n} \\
\vdots & \cdots & \vdots \\
X_{n1} & \cdots & X_{nn} \end{array} \right)\] \right) \[ \left(
\begin{array}{ccc} \xi_1
\\ \vdots \\ \xi_n \end{array} \right) \] &\\
&= -\sum_{i,j}X_{ij}\xi_j \frac{\partial f}{\partial \xi_i} &\end{align*}$$
and the attached pic of what is shown:

My problems are:
there's a missing right bracket for the matrix with the minus sign symbol,
how do I fix this?
the \xi's column vector is not placed at the right place it should be to
right after the second right bracket which is missing from the output, and
not placed above there, how to fix this?
the last equality should be aligned with the rest of the equalities i.e
the equality should be placed beneath the rest of the equalities and not
as it's displayed.
Any ideas as to how to fix this?
Thanks in advance, your help is much appreciated.

Wednesday, 21 August 2013

Implementing colspan on DIVS

Implementing colspan on DIVS

I have a div layout like this
Style
.l-item{
display:inline-block;
border:1px solid #CCC;
width:20px;
height:20px
}
<div id="head">
<div>
<div class="l-item">a</div>
<div class="l-item">a</div>
<div class="l-item">a</div>
<div class="l-item">a</div>
<div class="l-item">b</div>
<div class="l-item">b</div>
</div>
<div>
<div class="l-item">x</div>
<div class="l-item">y</div>
<div class="l-item">z</div>
<div class="l-item">z</div>
<div class="l-item">z</div>
<div class="l-item">x</div>
</div>
<div>
<div class="l-item">1</div>
<div class="l-item">2</div>
<div class="l-item">3</div>
<div class="l-item">4</div>
<div class="l-item">4</div>
<div class="l-item">4</div>
</div>
</div>
My requirement is to merge similar valued and sibling DIVS into single DIV
as colspan. For that I have an approach like below
$('#head > div').each(function(){
$(this).find('.l-item').each(function(){
var txt = $(this).text();
$(this).siblings().filter(function(){
return $(this).text() == txt;
});
});
});
It seems like it will mess with the DOM, any other solution for this please..

Applescript - Run Multiple Instances of an App in Mac OSX

Applescript - Run Multiple Instances of an App in Mac OSX

I was hoping one of you kind folks could help me write a script that would
open another instance of Transmission.
From my online research, I took a stab at making my own and compiled the
following script for AppleScript Editor.
do shell script "open -n -a '/Volumes/2 TB/App/Transmission.app'"
However, i get the following error message, "There is already a copy of
Transmission running. This copy cannot be opened until that instance is
quit."
Can anyone tell me what I'm doing wrong?
Thanks!

JS callback when ignoring geolocation permission request?

JS callback when ignoring geolocation permission request?

When utilizing JS geolocation on a web page, the browser asks the user if
they want to allow or deny the webpage to access their location.
navigator.geolocation.getCurrentPosition(showPositionFunction,
errorFunction);
The showPositionFunction is what is called if the user grants geolocation
access. errorFunction is called if the user deny's geolocation access or
if the geolocation fails for some reason.
But most browsers also allow you to ignore the geolocation permission
question. For Chrome and Firefox, you can simply hit the X button to close
the permission dialog, neither allowing or denying geolocation access. Is
there a callback for this event?

regex: plus sign vs asterisk

regex: plus sign vs asterisk

The asterisk or star tells the engine to attempt to match the preceding
token zero or more times. The plus tells the engine to attempt to match
the preceding token once or more.
Based on the definition, I was wondering why the plus sign returns more
matches than the asterisk sign.
echo "ABC ddd kkk DDD" | grep -Eo "[A-Z]+"
returns
ABC DDD
echo "ABC ddd kkk DDD" | grep -Eo "[A-Z]*"
returns ABC

Javascript regexp for smile images replacements

Javascript regexp for smile images replacements

i need replace {smile:smilename} to it's image tag with src <img
src="/img/smile/smilename.gif">
i'm trying:
data['text'] = 'text{smile:smile3}text{smile:smile3}text{smile:smile3}text';
data['text'] = data['text'].replace('/{smile:(.*?)}/g', '<img
src="/img/smile/$1.gif">');
but it doesn't work

Change common keys using KeyStroke in Java

Change common keys using KeyStroke in Java

I'm trying to create an editor that have several hotkeys. This editor will
be have some function each ke we press. (btw, sorry if my english bad :D )
I've done with Enter key (backspace, delete, & arrow key too). (note: ta
is text area, javaswing)
String keyStrokeAndKey_enter = "ENTER";
KeyStroke keyStroke_enter =
KeyStroke.getKeyStroke(keyStrokeAndKey_enter);
ta.getInputMap().put(keyStroke_enter, keyStrokeAndKey_enter);
ta.getActionMap().put(keyStrokeAndKey_enter, enter);
I've done if we use alt+[key]
String keyStrokeAndKey_1 = "1";
KeyStroke keyStroke_1 = KeyStroke.getKeyStroke(KeyEvent.VK_1,
Event.CTRL_MASK);
ta.getInputMap().put(keyStroke_1, keyStrokeAndKey_1);
ta.getActionMap().put(keyStrokeAndKey_1, _1);
But, i stuck with only alphabet key (a,b,c,etc). I've try like this:
String keyStrokeAndKey_a = "a";
KeyStroke keyStroke_a = KeyStroke.getKeyStroke(keyStrokeAndKey_a);
ta.getInputMap().put(keyStroke_a, keyStrokeAndKey_a);
ta.getActionMap().put(keyStrokeAndKey_a, _a);
So, what must i do to solve my problem? Thanks before :)

programmatically add appointment directly to calendar in windows phone 8

programmatically add appointment directly to calendar in windows phone 8

please can anyone out there tell me method how to programmatically add
appointment directly to calendar without user intervention in windows
phone 8.
Thanks in advance

Tuesday, 20 August 2013

Cannot connect to android 2.2.2 device with adb 1.0.31 over wifi

Cannot connect to android 2.2.2 device with adb 1.0.31 over wifi

Before upgrading my phone from android 2.1, I had no problems using adb
(over wifi). I just upgraded my phone to android 2.2 and adb to 1.0.31.
Unfortunately:
$ adb version
Android Debug Bridge version 1.0.31
$ adb connect 192.168.1.126
* daemon not running. starting it now on port 5037 *
$ adb devices
List of devices attached
192.168.1.126:5555 offline
$ adb shell
error: device offline
No prompt ever occurred on my phone to authorize my device. Is there
something wrong with what I'm doing?
Running Cyanogenmod 10.1.2
Note: I haven't tried going over USB because my USB port is broken (can
charge, but can't get a data connection)

Javah not recognized as an internal or external command

Javah not recognized as an internal or external command

I'm trying to run javah to create header files i always get the error
'javah' is not recognized as an internal or external command, operable ....
I can't figure out why at all. I tried to google it but all I could find
was to add the java path to your enviornment path variable, but thats
already added. Also, if I remove the path variable, it seems that the
"java" command operator still works fine.
Here's my Path variable
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program
Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files
(x86)\Common Files\Microsoft Shared\Windows
Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\Windows Live\Shared;;C:\Program
Files\Intel\WiFi\bin\;C:\Program Files\Common
Files\Intel\WirelessCommon\;C:\Program Files\Microsoft\Web Platform
Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web
Pages\v1.0\;C:\Program Files\Microsoft SQL
Server\110\Tools\Binn\;C:\Program
Files\WPIJavaCV\OpenCV_2.2.0\bin;C:\MinGW\bin;C:\Program Files\Microsoft
Windows Performance Toolkit\;C:\Program Files\Java\jdk1.7.0_07\bin\
(its at the end, the variable just continually grows :/)
EDIT : Nevermind, solved... Command line had to be run in administrator

'Interesting' orthogonal martices?

'Interesting' orthogonal martices?

I'm working with an algorithm that takes as part of its input an
orthogonal matrix with real entries. I'm trying to understand how the
specification of this matrix affects performance of the algorithm. It's
very difficult to do this analytically, so I'm working experimentally for
now.
I'm loking for examples of orthogonal matrices that are in some sense
'interesting' or 'extreme'. Obviously the identity matrix is one choice.
Another choice might be the matrix that is 'least sparse' in the sense
that the sum of the absolute values of the entries is as large as possible
(is there a name for this?). Another choice is a random sample from the
Gaussian orthogonal ensemble.
Can anyone suggest some other examples?
Many thanks.

Fast multiple string compare

Fast multiple string compare

In c# is there a quick way to replace the following with more efficient code:
string letters = "a,b,c,d,e,f";
if (letters.Contains("a"))
{
return true;
}
if (letters.Contains("b"))
{
return true;
}
if (letters.Contains("c"))
{
return true;
}
I want to do away with having to have three compare lines of code.
Thanks!

String extension method in Linq query

String extension method in Linq query

How to use string extension method in linq query:
public NewsType GetNewsType(string name)
{
var newsType = db.NewsTypes.FirstOrDefault(x => x.Name.ToFriendlyUrl()
== name.ToFriendlyUrl());
return newsType;
}
Above query "x.Name.ToFriendlyUrl()" is not allowed at the minute. Is
anyone know how to achieve with it.

Monday, 19 August 2013

Linux: Disable Laptop Touchpad Using In-Build Sensor

Linux: Disable Laptop Touchpad Using In-Build Sensor

These days many laptop devices come with a touchpad that have sensor next
to them. By double clicking these sensor (or single clicking on some of
them) the touch pad is disabled until the sensor is double clicked again.
However, this happens only in Windows.
Ever since I have switched to Linux (using Arch Linux this time) this
shortcut method does not work.
Although I have seen a couple of scripts to disable touchpad and some
packages available on the internet, it's good to be able to have it done
by an easy method as using the in-built sensor.
Anyone knows how we can do this?

How do I use the CloudBees SDK (command line interface) on Jenkins

How do I use the CloudBees SDK (command line interface) on Jenkins

I am running a job in DEV@cloud on cloudbees - but I want to use the
CloudBees SDK/CLI, how do I do this from within the job?

Tooltip Not Showing Up When No Validation Error WPF

Tooltip Not Showing Up When No Validation Error WPF

I searched and did not see a solution.
I can only get the validation to show the tooltip if I do not set a
tooltip in the combo box tooltip property. I would like to see the
validation error tooltip when one is present otherwise show the tooltip
from the combobox property. The validation tooltip shows up fine when I
remove the text from the tooltip property (i.e. from the property panel
for the combo box).
The XAML in Application.Resources (App.XAML)for the tooltip to show the
validation error is
<Style x:Key="StandardComboBoxStyle" TargetType="{x:Type ComboBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding
RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
I also use a validation template for the Combobox as follows. This is in
the UserControl.Resources section within the user control cs file.
<ControlTemplate x:Key="comboBoxValidationTemplate">
<DockPanel Name="myDockPanel">
<Border BorderBrush="Red" BorderThickness="3">
<AdornedElementPlaceholder Name="MyAdorner" />
</Border>
<TextBlock Text="*" FontWeight="Bold" FontSize="18"
Foreground="Red" DockPanel.Dock="Left" />
</DockPanel>
</ControlTemplate>
The control itself is defined as follows. Note that there are other
references not defined here (but hopefully not pertinent - feel free to
let me know if questions).
<ComboBox x:Name="ExposureTime" SelectedValuePath="Content"
Text="{Binding ExposureTime, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True,
ValidatesOnExceptions=True}" IsEditable="True"
Validation.ErrorTemplate="{StaticResource
comboBoxValidationTemplate}"
HorizontalContentAlignment="Right" FontSize="18"
Margin="136,47,462,0" Height="27" VerticalAlignment="Top"
GotFocus="ComboBox_GotFocus_1" LostFocus="ComboBox_LostFocus_1"
PreviewTextInput="ExposureTime_PreviewTextInput" Opacity="{Binding
BackgroundOpacity, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" FontWeight="Thin"
Style="{DynamicResource StandardComboBoxStyle}"
SelectedValue="{Binding Mode=OneWay, ValidatesOnDataErrors=True,
ValidatesOnExceptions=True}" IsTextSearchEnabled="False"
ToolTip="My tooltip test.">
<ComboBoxItem Content="0.05"/>
<ComboBoxItem Content="0.1"/>
<ComboBoxItem Content="0.2" />
<ComboBoxItem Content="1" />
<ComboBoxItem Content="2" />
<ComboBoxItem Content="5" />
<ComboBoxItem Content="10" />
<ComboBoxItem Content="20" />
<ComboBoxItem Content="60" />
<ComboBox.IsEnabled >
<MultiBinding Converter="{StaticResource multiBooleanConverter}">
<Binding Path="NotPerformingExposure"
UpdateSourceTrigger="PropertyChanged"/>Th
<Binding Path="NotPerformingFocusTest"
UpdateSourceTrigger="PropertyChanged"/>
</MultiBinding>
</ComboBox.IsEnabled>
</ComboBox>
Thanks! Buck

java file readline returns null

java file readline returns null

I am trying to create a booking system in Java, however every time I run
the program the while loop (shown below) skips straight to the end as
though the line read was null
//hardcoded file path - needs to be changed when program moved
String fileName =
"C:\\Users\\BOO\\Desktop\\SystemsSoftwareBookingsystem\\FilmData.txt";
String line = null;
int readInt = 0;
float readFloat = 0;
int item_counter = 0;
try
{
BufferedReader bufferedReaderF = new BufferedReader(new
FileReader(new File(fileName)));
while ((line = bufferedReaderF.readLine()) != null)
{
Film tmpFilm = new Film();
switch (item_counter)
{
case 0:
{
line = bufferedReaderF.readLine();
tmpFilm.name = line;
item_counter++;
}
case 1:
{
readInt = bufferedReaderF.read();
tmpFilm.seatsTotal = readInt;
item_counter++;
}
case 2:
{
readInt = bufferedReaderF.read();
tmpFilm.seatsAvailable = readInt;
item_counter++;
}
case 3:
{
readInt = bufferedReaderF.read();
tmpFilm.price = readFloat;
item_counter++;
}
case 4:
{
readInt = bufferedReaderF.read();
tmpFilm.showingTime = readFloat;
item_counter++;
}
case 5:
{
readInt = bufferedReaderF.read();
tmpFilm.day = readInt;
item_counter++;
}
case 6:
{
readInt = bufferedReaderF.read();
tmpFilm.month = readInt;
item_counter++;
}
case 7:
{
readInt = bufferedReaderF.read();
tmpFilm.year = readInt;
item_counter = 0;
}
}
line = bufferedReaderF.readLine();
server.filmList.add(tmpFilm);
}
bufferedReaderF.close();
} catch (FileNotFoundException ex)
{
System.out.println("Unable to open file '" + fileName + "'");
} catch (IOException ex)
{
System.out.println("Error reading file '" + fileName + "'");
}
}
}`
any ideas / help would be greatly appreciated
EDIT added rest of the code in the while loop as requested

Differences between VPN Types

Differences between VPN Types

I need to confifure L2TP_IPSEC_RSA in my app. Can anybody tell me the
difference between VPN types L2TP_IPSEC_RSA and L2TP_IPSEC_CRT.

Sunday, 18 August 2013

BlackBerry 10: Load GroupDataModel data into a JSON file?

BlackBerry 10: Load GroupDataModel data into a JSON file?

I have a ListView in QML using a cpp GroupDataModel that is created from a
.json file in the assets folder. Items from this ListView are removed and
added to. In cpp how do I get the GroupDataModel data into the JSON file?
I know there is this:
JsonDataAccess jda;
jda.save(huh?, "/app/native/assets/employees.json");
How do I get the GroupDataModel data into a QVariant to put in the first
parameter of that function? I can't just stick my m_model GroupDataModel
in there; it causes an error.

Toggle state in c# - wpf

Toggle state in c# - wpf

I want to make a function to work in toggle(switch) mode when i press a
key and i really can't figure how to do it. I tried lots of ways and only
the "RegisterHotKey" method is working fine. But "RegisterHotKey" is
overwriting the mapped key from the game and this is not what i need. So
i'm trying to use "GetKeyState". The code below it's only working for one
position no matter what i change...:
private void mw_KeyDown(object sender, KeyEventArgs e){
bool toggle = true;
bool sw = (toggle = !toggle);
int tog = (GetKeyState(Key.Tab));
if ((tog & 1) == 1)
{
if (sw)
{
System.Windows.MessageBox.Show("go to second position...!");
}
}
else
{
System.Windows.MessageBox.Show("go to first position...!");
}
}
Any idea or suggestion how can i do this ?
Thank you,

Error with clipboard data when copying all using Ctrl+A in web browser

Error with clipboard data when copying all using Ctrl+A in web browser

I am working with clipboard data processing for a new project. I am facing
a strange problem in IE 10 (Version 10.0.9200.16660)
Following is my code
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>page - title</title>
<script type='text/javascript'
src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
jQuery(document).on('copy', function(e){
var body_element, selection, pageLink, copytext, newdiv, url;
url = document.location.href;
body_element = document.getElementsByTagName('body')[0];
selection = window.getSelection();
alert(selection);
});
</script>
</head>
<body>
<ol>
<li>Hi</li>
<li>Hi</li>
<li>Hi</li>
<li>Hi</li>
<li>Hi</li>
</ol>
</body>
</html>
Error
Save the above code to an HTML file
Run it
Use Ctrl + A, Ctrl + C
It is alerting the whole html, including the page title, the javascripts
etc.. in IE (see the attached image) but working fine in Chrome.
Can someone give me some hint on whats happening?

Installation error mySQL with visual c++ 2010

Installation error mySQL with visual c++ 2010

So I've just installed mySQL (5.6) to use with visual c++ 2010 and i've
encountered an error.
I'm using the tutorial located here:
http://dev.mysql.com/doc/refman/5.6/en/connector-cpp-apps-windows-visual-studio.html
At the part where it states to include the directory c:/Program
Files/mySQL/lib/opt I found that my installation doesn't have this
directory. The only lib folder that contains an opt folder in my mySQL
installation is the folder under C:\Program Files\MySQL\Connector C++
1.1.3\lib\opt
Should I be linking this file to the additional directoried, or have I
done something wrong?
I ask that you don't refer me to some tutorial and instead provide a
step-by-step explanation. I have been looking at quite a few tutorials but
they all seem to be using older version of both mySQL and VC++.
Thank you for your time.

List Of Text And Clickable

List Of Text And Clickable

I want to ask how to make a list of text that we can tap in each of the
text and then get the selected text to editText. I just added the
screenshot
http://i.stack.imgur.com/ddZSg.png
I have been searching it since yesterday, but I can not find exact
solution. I also tried with listview, but I don't know how it's possible
with horizontal, and flow list item.

Saturday, 17 August 2013

Select all where values equal 1?

Select all where values equal 1?

It is the best way to select only records with "1" value? I cant make it
works :/
$results = mysqli_query($connecDB,"SELECT * FROM codes WHERE php = 1 AND
java = 1 AND ruby = 1 ORDER BY id ASC");
+------+----------------+---------+--------+--------+
| ID | CODES | PHP | RUBY | JAVA |
+------+----------------+---------+--------+--------+
| 1 | ford | 1 | 0 | 0 |
+------+----------------+---------+--------+--------+
| 2 | seat | 1 | 1 | 1 |
+------+----------------+---------+--------+--------+
| 3 | fiat | 1 | 1 | 0 |
+------+----------------+---------+--------+--------+
| 4 | toyota | 1 | 0 | 0 |
+------+----------------+---------+--------+--------+
| 5 | chevrolete | 1 | 0 | 1 |
+------+----------------+---------+--------+--------+

Error 1004 in my Macro while saving a Excel workbook as a CSV for Japnese

Error 1004 in my Macro while saving a Excel workbook as a CSV for Japnese

I have written a simple Macro for saving all the Workbooks as separate CSV
files. This works fine on my local machine (English Lang) for paths like
*D:\MyFolder* .
But when I am trying the same Macro on another windows machine with
Japanese language enabled I am getting 1004 error for SaveAS method.
File paths like D:¥MyFolder¥
Below is the my code which is causing the error:
For Each WS In ThisWorkbook.Worksheets
newName = WS.Name & "-" & Format(Date, "yyyy-mm-dd") & "-" &
Format(Time, "hhmmss")
WS.Copy
ActiveWorkbook.SaveAs SaveToDirectory & newName, xlCSVMSDOS, Local:=True
ActiveWorkbook.Close Savechanges:=False
Next

How to set base line of inline-block element equal to the base line of its last child

How to set base line of inline-block element equal to the base line of its
last child

I have the following HTML:
<div class="horizontal">
<div>A</div>
<div>B</div>
<div class="vertical">
<div>X</div>
<div>Y</div>
</div>
</div>
And the following CSS:
.horizontal > div {
display : inline-block;
}
.vertical > div {
display : block;
}
Currently I have
X
A B Y
But I want to have
A B X
Y
I tried setting vertical-align: text-top, but it doesn't align in exact
way, there are a couple of pixels missing which looks really ugly.
P.S. I have jsfiddle for this: http://jsfiddle.net/Lr8W4/10/

Having errors on parsing JSON

Having errors on parsing JSON

I'm trying to parse JSON from sdcard. When I try to execute to AsyncTask
Simple Adapter, I'm getting following error:
The method execute(String...) in the type
AsyncTask<String,Void,SimpleAdapter> is not applicable for the arguments
(StringBuilder)
I spent more than a week to solve this code but I couln't made it. My code
is:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import com.kabelash.salesgossip02.util.ExternalStorage;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Menu;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class Jeans extends Activity {
private final String JSON_file = "country.json";
File jsonFile;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.baby1_1);
/** Getting Cache Directory */
File cDir = ExternalStorage.getSDCacheDir( this, "json_files" );
/** Getting a reference to temporary file, if created earlier */
jsonFile = new File(cDir.getPath() + "/" + JSON_file) ;
String strLine="";
StringBuilder strJson = new StringBuilder();
/** Reading contents of the temporary file, if already exists */
try {
FileReader fReader = new FileReader(jsonFile);
BufferedReader bReader = new BufferedReader(fReader);
/** Reading the contents of the file , line by line */
while( (strLine=bReader.readLine()) != null ){
strJson.append(strLine);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
System.out.println(strJson);
/** The parsing of the xml data is done in a non-ui thread */
// ListViewLoaderTask listViewLoaderTask = new ListViewLoaderTask();
/** In here i'm getting the error */
new ListViewLoaderTask().execute(strJson);
}
private class ListViewLoaderTask extends AsyncTask<String, Void,
SimpleAdapter>{
JSONObject jObject;
/** Doing the parsing of xml data in a non-ui thread */
@Override
protected SimpleAdapter doInBackground(String... strJson) {
try{
jObject = new JSONObject(strJson[0]);
CountryJSONParser countryJsonParser = new
CountryJSONParser();
countryJsonParser.parse(jObject);
}catch(Exception e){
Log.d("JSON Exception1",e.toString());
}
CountryJSONParser countryJsonParser = new CountryJSONParser();
List<HashMap<String, String>> countries = null;
try{
/** Getting the parsed data as a List construct */
countries = countryJsonParser.parse(jObject);
}catch(Exception e){
Log.d("Exception",e.toString());
}
/** Keys used in Hashmap */
String[] from = { "country","flag","details"};
/** Ids of views in listview_layout */
int[] to = {
R.id.tv_country,R.id.iv_flag,R.id.tv_country_details};
/** Instantiating an adapter to store each items
* R.layout.listview_layout defines the layout of each item
*/
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(),
countries, R.layout.lv_layout, from, to);
return adapter;
}
/** Invoked by the Android system on "doInBackground" is executed
completely */
/** This will be executed in ui thread */
@Override
protected void onPostExecute(SimpleAdapter adapter) {
/** Getting a reference to listview of main.xml layout file */
ListView listView = ( ListView ) findViewById(R.id.lv_countries);
/** Setting the adapter containing the country list to
listview */
listView.setAdapter(adapter);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Please someone solve this code for me please.

Connected via SSH Tunnel, but IP address stays the same

Connected via SSH Tunnel, but IP address stays the same

I have installed SSH Tunnel on my phone, and can connect to an ssh account
I created on my server. Whenever I enable sshtunnel, it says it's
connected, but the ip address does not change. I created a simple php-page
on my webserver that shows the ip address plus current time. The time is
updated each time, so it's not a caching problem.
How can I get this working?

Secure java card access in windows phone 8

Secure java card access in windows phone 8

Is there any smart card accessing api for windows phone 8 like
"openmobileapi" for android and "jsr177 satsa api" for j2me?
As windows phone 7 devices are not having external memory card support , i
am looking only for windows phone 8

Convert pinyin to Chinese Character

Convert pinyin to Chinese Character

I want to take pinyin (english) as an input and return Chinese characters
that user can choose from. I saw that this has been implemented in many
place (support by OS keyboards and various websites), but can't find a
library to do it.
Or possibly even doing it myself if it's not that complex or require large
amount of data.

Friday, 16 August 2013

Inserting inline image from URL on email

Inserting inline image from URL on email

I want to add an inline image from a URL In hotmail and yahoo gmail allows
it simply by: https://support.google.com/mail/answer/148408

Saturday, 10 August 2013

dropdown menu and javascript form change

dropdown menu and javascript form change

I am trying to change some form options based on a dropdown selection. I
think I wrote the javascript correctly but I am not sure. If someone could
atleast get me pointed in the right direction or if there is a better way
to accomplish the same thing that would be fine as well. I am a newbie to
javascript.
Here is the code.
<form method="post">
<div class="row requiredRow">
<label for="ClassName" id="ClassName-ariaLabel">Class Name:</label>
<input id="ClassName" name="ClassName" type="text"
aria-labelledby="ClassName-ariaLabel" class="required" title="Class
Name:. This is a required field">
</div>
<div class="row">
<label for="ProfessorName" id="ProfessorName-ariaLabel">Professor
Name:</label>
<input id="ProfessorName" name="ProfessorName" type="text"
aria-labelledby="ProfessorName-ariaLabel">
</div>
<div class="row requiredRow">
<label for="GradingScale" id="GradingScale-ariaLabel">Grading
Scale:</label>
<select id="GradingScale" name="GradingScale"
aria-labelledby="GradingScale-ariaLabel" class="required"
title="Grading Scale:. This is a required field">
<option value="1">A,A-,B+,B,B-,C+,C,C-,D+,D,D-,F</option>
<option value="2">A,B,C,D,F</option>
</select>
</div>
<div class='grades'>
<script>
var e = document.getElementById("GradingScale");
var scale = e.options[e.selectedIndex].value;
if (scale = 2)
{
document.write("<p>Grading Scale:</p><br />");
document.write("A: <input type='text' name='grade-a'><br />");
document.write("B: <input type='text' name='grade-b'><br />");
document.write("C: <input type='text' name='grade-c'><br />");
document.write("D: <input type='text' name='grade-d'><br />");
document.write("F: <input type='text' name='grade-f'><br />");
}
else if (scale = 1)
{
document.write("<p>Grading Scale:</p><br />");
document.write("A: <input type='text' name='grade-a'><br />");
document.write("A-: <input type='text' name='grade-a-'><br />");
document.write("B+: <input type='text' name='grade-b+'><br />");
document.write("B: <input type='text' name='grade-b'><br />");
document.write("B-: <input type='text' name='grade-b-'><br />");
document.write("C+: <input type='text' name='grade-c+'><br />");
document.write("C: <input type='text' name='grade-c'><br />");
document.write("C-: <input type='text' name='grade-c-'><br />");
document.write("D+: <input type='text' name='grade-d+'><br />");
document.write("D: <input type='text' name='grade-d'><br />");
document.write("D-: <input type='text' name='grade-d-'><br />");
document.write("F: <input type='text' name='grade-f'><br />");
}
</script>
</div>
<div class="row">
<input type="submit" value="Add Class">
</div>
</form>

Remove duplicate string in an array

Remove duplicate string in an array

i'm new to c++ and i'm looking for a way to remove duplicate strings from
an array of strings that looks like this: string exempleArray[]=
{"string1", "string2", "string1"}; after the code it should look like
this: "string1", "string2", but the order doesn't matter at all. Thanks a
lot for your time.

Phonegap camera crash on android 4.1.2, samsung galaxy s3, HTC

Phonegap camera crash on android 4.1.2, samsung galaxy s3, HTC

I think a lot of developers are familier with this problem of phonegap
crashes/restarts after getting a picture from camera / library on android
4.1.2.
After many searches of many solutions I want to put some order into this
problem and I wish you could help me understand what is the current
solution. Note: the current stable phonegap version is 2.9.0.
Using fileURI and not dataURL, because the encoded base64 is too big for
the DOM to handle.
Editing (not via phonegap build config.xml) the android manifest file and
add the following line to every activity:
android:alwaysRetainTaskState="true" android:launchMode="singleTask".
Limit the resolution using targetWidth/targetHeight, because the image is
to big which causes memory over load. and reducing quality..
Switch off the
"Do not keep actitivies"
option in android settings.. which is ofcourse not a real solutions
becaues we can't ask users to do that..
Again, editing the android manifest (with discarding phonegap build
service) and add:
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
<uses-feature android:name="android.hardware.camera"
android:required="false"/>
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="10"/>
<activity android:configChanges="orientation|keyboardHidden" />
Using an external camera plugin (not phonegap's):
links to all these solutions are here:
http://community.phonegap.com/nitobi/topics/phonegap_camera_crash_on_android_4_1_2_samsung_galaxy_s3_htc
Now.. After this literature review.. Does anyone know which combination
works? please help!

Friday, 9 August 2013

How to check if a local user account still have the same password

How to check if a local user account still have the same password

I have a PowerShell script which does the following on Windows 7 computers:
Get a random password from a secure server-side application
reset the password of a specific local user account using this password value
As a next step, I want to periodically check if the password saved on the
server is still valid. For now, I am using ValidateCredentials from
System.DirectoryServices.AccountManagement.PrincipalContext (see
Powershell To Check Local Admin Credentials) but it involves to unencrypt
the password and send it back to the computer just for this purpose.
Do you see any better way to check if password is still valid avoiding to
use clear text password ? Is it possible to compare some hash, or anything
else ?
Regards.

why buffer memory allocation error in opencl

why buffer memory allocation error in opencl

I execute the OpenCL program on an NDRange with a work-group size of 16*16
and work-global size of 1024*1024. The application is matrix
multiplication. When the two input matrix size are both little, it works
well. But when the size of input matrix becomes large, for example, larger
than 20000*20000, it reports error "CL_MEM_OBJECT_ALLOCATION_FAILURE" in
the function of enqueuendrangekernrl.
I am puzzled. I am not familiar with memory allocation. What's the reason?

How to get web service sub group XML data as a list?

How to get web service sub group XML data as a list?

Sub XML elements are returning as a long strings of x = "y" in a list with
a length of 1. How can I get sub xml elements to return into a useful data
set so I don't have to write string parsing code?
Details:
I call a web service with suds as normal like this:
myWebServiceData=client.service.getMethod("P1", "P2", "P3")
It Returns a dictionary as I would like however it looks like this:
myWebServiceData = { elm1: "data1", elm2: "data2", elm3: "[(data3){ elm4 =
data4 elm5 = data5 elm6 = data6 }]
So any data under data4 is a list with a length of 1. like this:
print myWebServiceData['elm4'][0]
elm4 = data4 elm5 = data5 elm6 = data6
However my xml looks like this (as seen in my logger):
<elm1>data1</elm1>
<elm2>data2</elm2>
<elm3>
<elm4>data4</elm4>
<elm5>data5</elm5>
<elm6>data6</elm6>
</elm3>

how to hide spinner after the content loads

how to hide spinner after the content loads

I'm using pjax to load content and while the content is loading, I show a
spinner:
$('a[data-pjax]').pjax().live ("click", function () {
$("#loader").show();
});
This works fine, however, after the content loads the loader still stays
there.
Where should I call $(#loader).hide() to hide the loader after the content
has loaded?

Small dropdown, large data

Small dropdown, large data

I have limited space and element in a dropdown with a large amount of text.
It it possible to have the dropdown width small but the popup of the list
large?

How to create variable name with integer appended to the end?

How to create variable name with integer appended to the end?

I want to create a for loop that will fill a bunch of arrays with data in
c++. Now to save space and in the future once more arrays are added which
they will, I have the for loop. Each array for demonstration purposes is
called Array# (# being a number) The point of the for loop would be to set
a constant with maximum arrays, then cycle through each array filling by
appending i to the end of the Array name.
For example in pseudo code:
for (i = 1; i < numberofarrays; i++)
{ fill (Array & i) with ("Array" & i & "-default.txt")}