Saturday, 31 August 2013

Looping for string comparison

Looping for string comparison

I developed code to search for - and / and then compare and arrange them.
Unfortunatly, it only works for two strings to compare and if more than
two strings compared by loop, it gives redundant data.
for($x=1, $y = 2; $x<$arrlength, $y<$arrlength; $x++, $y++) {
switch ($sort[$x])
{
case (strncasecmp($sort[$x],$sort[$y],strpos($sort[$x],'-')) == 0):
if
(substr(substr($sort[$x],0,strpos($sort[$y],'/')),0,strpos($sort[$y],'-'))
== false ){
echo " <TH class=\"tr1 td26\"><table><caption><P class=\"p16
ft4\">".substr($sort[$y],0,strpos($sort[$x],'-'))."</P></caption></table>";
echo "<P class=\"p12
ft4\">".ltrim(substr($sort[$x],strpos($sort[$x],'-')),"-")."</p></TH>";
echo " <TH class=\"tr1 td26\"><P class=\"p12
ft4\">".ltrim(substr($sort[$y],strpos($sort[$y],'-')),"-")."</P></TH>";
}
else {
echo " <TH class=\"tr1 td26\">";
echo " <table><caption><u><P class=\"p16
ft4\">".rtrim(rtrim((ltrim(substr(substr($sort[$x],strpos(strpos($sort[$x],'-'),'/')),strpos($sort[$x],'/')),"/")),ltrim(substr($sort[$x],strpos($sort[$x],'-')),"-")),"-")."</p><u></caption></table>";
echo "<P class=\"p12
ft4\">".ltrim(substr($sort[$x],strpos($sort[$x],'-')),"-")."</p></TH>";
echo " <TH class=\"tr1 td26\"><P class=\"p12
ft4\">".ltrim(substr($sort[$y],strpos($sort[$y],'-')),"-")."</P></TH>";
}
break;
case (strncasecmp($sort[$x],$sort[$y],strpos($sort[$x],'-')) <= 0):
echo " <TH class=\"tr1 td26\"><P class=\"p12
ft4\">".$sort[$x]."</P></TH>";
break;
case ((strncasecmp($sort[$x],$sort[$y],strpos($sort[$x],'/')) == 0) &&
(substr(substr($sort[$y],0,strpos($sort[$y],'/')),0,strpos($sort[$y],'-'))
!== false )) :
echo " <P class=\"p17
ft4\">".substr($sort[$y],0,strpos($sort[$x],'/'))."</P>";
break;
}
}

jquery checkbox enable onload to display other elements

jquery checkbox enable onload to display other elements

http://jsfiddle.net/Q9Lg4/20/
ok, i've found an example that i've altered a bit to see if any of you
alter my example to the way i want it to work
my php page is going to load and assign the check box to either be enabled
(checked) or disabled (unchecked).
if enabled on page load. I want the fields to be enabled and allowed to
enter a variable which will be sent back to the database
if disabled on page load. I want the fields to be disabled
<form>
<input type="checkbox" name="detailsgiven" id="checkbox" checked=checked>
Enabled?<br>
<input type='text' name="details" id="tb1" value='box1'><br>
<input type='text' name="details" id="tb2" value='box2'><br>
<input type='text' name="details" id="tb3" value='box3'><br>
</form>
jquery
var check = document.getElementById('checkbox');
check.addEventListener('click', toggleDisabled, false );
function toggleDisabled(evt) {
var checked = evt.target.checked;
if(checked){
document.getElementById('tb1').disabled = "disabled";
document.getElementById('tb2').disabled = "disabled";
document.getElementById('tb3').disabled = "disabled";
}else{
document.getElementById('tb1').disabled = "";
document.getElementById('tb2').disabled = "";
document.getElementById('tb3').disabled = "";
}
}

How to rename a column of a pandas.core.series.TimeSeries object?

How to rename a column of a pandas.core.series.TimeSeries object?

Substracting the 'Settle' column of a pandas.core.frame.DataFrame from the
'Settle' column of another pandas.core.frame.DataFrame resulted in a
pandas.core.series.TimeSeries object (the 'subs' object).
Now, when I plot subs and add a legend, it reads 'Settle'.
How can I change the name of a column of a pandas.core.series.TimeSeries
object?
thank you.

Java: Keep SecureRandom (SHA1PRNG) seed secret - calculate hash before seeding?

Java: Keep SecureRandom (SHA1PRNG) seed secret - calculate hash before
seeding?

I'm using SecureRandom with SHA1PRNG to generate a random sequence. I
won't let SecureRandom seed itself, I'm using my own values to seed it.
(Please don't tell me that this is unsafe, I have my reasons for doing
this).
However, I don't want anyone to know what seed I used. The seed must
remain secret and it shouldn't be possible to recalculate the seed from
the random sequence.
Does it make sense to calculate the SHA-512 from my value and seed
SecureRandom with it? Or will SecureRandom create a SHA1 hash from the
seed itself?
Long story short: Should I seed SecureRandom with "value".getBytes() or
with the SHA-512 hash of "value", if I want to keep "value" secret?
Where can I find information how the SHA1PRNG algorithm works?

Null Pointer Exception when method is invoked too many times

Null Pointer Exception when method is invoked too many times

I have a page where I set date and specialization:
<form>
<p:panel header="Szukaj wizyty">
<p:panelGrid columns="2">
<p:outputLabel for="Od"
value="Od"></p:outputLabel>
<p:calendar id="Od" label="Od"
value="#{visitPatientMB2.start}" effect="fold"
locale="pl" pattern="dd/MM/yyyy"
mindate="#{visitPatientMB2.actualDate}"
required="true">
<p:ajax event="dateSelect"
listener="#{visitMB.enableCalendar()}"
update="cal" />
</p:calendar>
<p:outputLabel for="Do"
value="Do"></p:outputLabel>
<p:calendar id="Do" label="Do"
value="#{visitPatientMB2.end}" effect="fold"
locale="pl" pattern="dd/MM/yyyy"
disabled="#{visitMB.flag}"
mindate="#{visitPatientMB2.actualDate}"
required="true"/>
<p:outputLabel
value="Specjalizacja"></p:outputLabel>
<p:selectOneMenu id="specialization"
value="#{visitPatientMB2.user.specializationId}"
effect="fade" style="width:200px"
converter="#{specializationConverter}">
<f:selectItems
value="#{visitPatientMB2.allSpecialization}"
var="specialization"
itemValue="#{specialization}"
itemLabel="#{specialization.name}"/>
</p:selectOneMenu>
<center><p:commandButton
action="#{visitPatientMB2.searchStart()}"
value="Szukaj" /></center>
</p:panelGrid>
</p:panel>
</form>
this page causes method: visitPatientMB2.searchStart()
VisitPatientMB2 RequestBean:
@ManagedBean
@RequestScoped
public class VisitPatientMB2 {
@EJB
private VisitDaoLocal visitDao;
@EJB
private SpecializationDaoLocal specializationDao;
@EJB
private UserDaoLocal userDao;
private Specialization specialization;
private Visit visit;
private User user;
private Date actualDate = new Date();
private Date start;
private Date end;
private boolean flag = true;
private Integer myId;
public VisitPatientMB2() {
}
public void enableCalendar() {
if (start != null) {
flag = false;
}
}
public String searchStart() {
System.out.println("SEARCH START");
if (start.after(end)) {
sendErrorMessageToUser("Data zakoñczenie nie mo¿e byæ
wczeœniejsza ni¿ rozpoczêcia");
return null;
}
if (start.before(actualDate)) {
sendErrorMessageToUser("Data wizyty nie mo¿e byæ wczeœniejsza
ni¿ aktualna data");
return null;
}
return "searchStart";
}
public String visitRegister() {
System.out.println("visitRegister");
myId = (Integer) session.getAttribute("myId");
visit.setPatientId(userDao.find(myId));
try {
visitDao.update(visit);
sendInfoMessageToUser("Wizyta zosta³a dodana");
return "addVisit";
} catch (EJBException e) {
sendErrorMessageToUser("B³¹d zapisu na wizyte do bazy");
return null;
}
}
public List<Visit> getVisitFound() {
System.out.println("start" + start);
System.out.println("end" + end);
System.out.println("name" + user.getSpecializationId().getName());
myId = (Integer) session.getAttribute("myId");
return visitDao.visitSearch(start, end,
user.getSpecializationId().getName(), myId);
}
public List<Specialization> getAllSpecialization() {
return specializationDao.findAllSpecialization();
}
Method return searchStart and go to page searchResult, no redirect
<navigation-rule>
<from-view-id>/protected/patient/visitSearch.xhtml</from-view-id>
<navigation-case>
<from-outcome>home</from-outcome>
<to-view-id>/protected/patient/home.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>about</from-outcome>
<to-view-id>/protected/patient/about.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>gallery</from-outcome>
<to-view-id>/protected/patient/gallery.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>contact</from-outcome>
<to-view-id>/protected/patient/contact.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>myAccount</from-outcome>
<to-view-id>/protected/patient/patientPanel.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>visitList</from-outcome>
<to-view-id>/protected/patient/myVisits.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>visitRegister</from-outcome>
<to-view-id>/protected/patient/visitRegister.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>visitSearch</from-outcome>
<to-view-id>/protected/patient/visitSearch.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>history</from-outcome>
<to-view-id>/protected/patient/myHistory.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>logout</from-outcome>
<to-view-id>/home.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>editMyAccount</from-outcome>
<to-view-id>/protected/patient/myAccount.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>searchStart</from-outcome>
<to-view-id>/protected/patient/searchResult.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>addVisit</from-outcome>
<to-view-id>/protected/patient/home.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
and when I in the page searchResult i click save to visit and run the
method visitPatientMB2.visitRegister() but I have a error...
WARNING: /protected/patient/searchResult.xhtml @55,227
value="#{visitPatientMB2.visitFound}": java.lang.NullPointerException
javax.el.ELException: /protected/patient/searchResult.xhtml @55,227
value="#{visitPatientMB2.visitFound}": java.lang.NullPointerException
at
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIData.getValue(UIData.java:731)
at
org.primefaces.component.datatable.DataTable.getValue(DataTable.java:867)
at org.primefaces.component.api.UIData.getDataModel(UIData.java:579)
at org.primefaces.component.api.UIData.setRowModel(UIData.java:409)
at org.primefaces.component.api.UIData.setRowIndex(UIData.java:401)
at org.primefaces.component.api.UIData.processPhase(UIData.java:258)
at org.primefaces.component.api.UIData.processDecodes(UIData.java:227)
at javax.faces.component.UIForm.processDecodes(UIForm.java:225)
at
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
at
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:933)
at
com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at pl.ePrzychodnia.filter.FilterLogin.doFilter(FilterLogin.java:49)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at
com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
at
pl.ePrzychodnia.mb.VisitPatientMB2.getVisitFound(VisitPatientMB2.java:215)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:363)
at
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:138)
at com.sun.el.parser.AstValue.getValue(AstValue.java:183)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224)
at
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
... 46 more
Why i have null? I not redirect page, my bean is a request, why filed is
null?
I set in the method:
public List<Visit> getVisitFound() {
System.out.println("start" + start);
System.out.println("end" + end);
System.out.println("name" + user.getSpecializationId().getName());
myId = (Integer) session.getAttribute("myId");
return visitDao.visitSearch(start, end,
user.getSpecializationId().getName(), myId);
}
and I see, when i go the page search result. This method is invoked twice.
Why?
And when I run visitPatientMB2.visitRegister() in page searchResult method
starts the third time... This time fields have null. Example:
INFO: startSun Sep 01 00:00:00 CEST 2013
INFO: endSun Sep 29 00:00:00 CEST 2013
INFO: nameKardiolog
INFO: startSun Sep 01 00:00:00 CEST 2013
INFO: endSun Sep 29 00:00:00 CEST 2013
INFO: nameKardiolog
INFO: startnull
INFO: endnull
WARNING: /protected/patient/searchResult.xhtml @55,227
value="#{visitPatientMB2.visitFound}": java.lang.NullPointerException

RecusriveDirectoryIterator - Getting files within folder with specific params

RecusriveDirectoryIterator - Getting files within folder with specific params

My end-goal is to grab only jpg|png files from within a directory (that
has directories in it). I first started with this article and settled on
the OOP approach (since this seems to be the best way forward). Of course,
with this comes some complexities that I haven't found a good example for
thusfar. The following example (taken from the PHP docs page) seems to get
me part of the way there, but I haven't found a good way to match all of
the requirements (below the example):
$ritit = new RecursiveIteratorIterator(new
RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST );
$r = array();
foreach ($ritit as $splFileInfo) {
$path = $splFileInfo->isDir()
? array($splFileInfo->getFilename() => array())
: array($splFileInfo->getFilename());
for ($depth = $ritit->getDepth() - 1; $depth >= 0; $depth--) {
$path =
array($ritit->getSubIterator($depth)->current()->getFilename() =>
$path);
}
$r = array_merge_recursive($r, $path);
}
print_r($r);
What I'd like to do is:
Specify a $directory (let's say /media/galleries)
Have it only look at directories first (so if any files are in that
top-level directory it ignores them)
Check if each directory is readable (it may do this by default already)
List out each jpg|png file within these files (again, making sure each is
readable which I believe it may do by default)
Ignore any/all dot files in the FilesystemIterator seems to do, but I'm
still getting the dreaded .DS_Store files in the top-level)
Store these as a multi-dimensional array
The aforementioned example seems to be almost there, but any help to steer
me in the right direction would be greatly appreciated. Thanks!

Haskell sqrt type error

Haskell sqrt type error

OK, so I'm attempting to write a Haskell function which efficiently
detects all the factors of a given Int, n. Based off of the solution given
in this question, I've got the following:
-- returns a list of the factors of n
factors :: Int -> [Int]
factors n = sort . nub $ fs where
fs = foldr (++) [] [[m,n `div` m] | m <-
[1..lim+1], n `mod` m == 0]
lim = sqrt . fromIntegral $ n
Sadly, GHCi informs me that there is No instance for (Floating Int) in the
line containing lim = etc. etc.
I've read this answer, and the proposed solution works when typed into
GHCi directly - it allows me to call sqrt on an Int. However, when what
appears to be exactly the same code is placed in my function, it ceases to
work.
I'm relatively new to Haskell, so I'd greatly appreciate the help!

Top hat filter kernel

Top hat filter kernel

Can you please tell me how does the kernel of a 2D top hat filter looks
like? I created the following kernel,
0 0 0 -1 0 0 0
0 -1 -1 -1 -1 -1 0
0 -1 -1 1 -1 -1 0
-1 -1 1 1 1 -1 -1
0 -1 -1 1 -1 -1 0
0 -1 -1 -1 -1 -1 0
0 0 0 -1 0 0 0
does this qualify as a top hat filter kernel? If I convolute an image with
this matrix, is it equivalent to have done a top hat filtering operation?
Am sorry if the question is rudimentary, but your help is much
appreciated.

Friday, 30 August 2013

Simple string encryption in php and decryption in Java?

Simple string encryption in php and decryption in Java?

I need to transfer some json data from a php server endpoint to my Android
client, however I want to protect obvious reading of the data if the
endpoint gets exposed. So I plan to write some simple string encryption
function in the php endpoint and have my client decrypt it. Is there any
readily made library to do so?

Thursday, 29 August 2013

How to get value from property file inside jquery.html() function

How to get value from property file inside jquery.html() function

$("#divid").html($(data).html() + "<input type="checkbox" id="checkplease"
onclick="toggleCheckbox(this)"/> value="<g:message code="property.value"
/>");
I want to get the value of checkbox from property file. How should I get it?

Android Facebook Invite not working?

Android Facebook Invite not working?

I'm Integrated facebook 3.0 SDK in my project, last week facebook invite
working fine.
Today is not working, i'm not getting any error message in my logcat.
below image is displaying,

thanks, give some good idea to avoid this error.

Wednesday, 28 August 2013

Invalid operands for binary and

Invalid operands for binary and

I have this "assembly" file (containing only directives)S
// declare protected region as somewhere within the stack
.equiv prot_start, $stack_top & 0xFFFFFF00 - 0x1400
.equiv prot_end, $stack_top & 0xFFFFFF00 - 0x0C00
Combined with this linker script:
SECTIONS {
"$stack_top" = 0x10000;
}
Assembling produces this output
file.s: Assembler messages:
file.s: Error: invalid operands (*UND* and *ABS* sections) for `&' when
setting `prot_start'
file.s: Error: invalid operands (*UND* and *ABS* sections) for `&' when
setting `prot_end'
How can I make this work?

Exception Handling - What is the correct way to do it?

Exception Handling - What is the correct way to do it?

I have been using exception handling for some time and have installed
Resharper and now getting all sorts of messages saying I should and should
be doing this. Anyhoo, it says I shouldn't be using try and catch blocks
around my code. So where do I put them to catch exceptions? I have seen
people looking for certain exceptions like File not found, but what about
all the other errors or exceptions that are unique?
Does anyone have links for best practices for exception handling that
would keep re-sharper happy?
Thanks

Trace User activities across browser

Trace User activities across browser

How can I trace a User activities across different browser in same
device(Desktop,Mobile etc)?
Can anyone brief me about this?

iOS 6.1 Dynamic Library build and link

iOS 6.1 Dynamic Library build and link

I am trying to create a dynamic library for iOS and load it at runtime.
After taking a look at this question and this answer, I have been doing it
using iOSOpenDev and deploying everything on my iPhone. The xCode project
for the dylib is called KDylibTwo and the files I modiefied are:
KDylibTwo.h
#import <Foundation/Foundation.h>
@interface KDylibTwo : NSObject
-(void)run;
@end
KDylibTwo.m
#import "KDylibTwo.h"
@implementation KDylibTwo
-(id)init
{
if ((self = [super init]))
{
}
return self;
}
-(void)run{
NSLog(@"KDylibTwo loadded.");
}
@end
In order to test if my library works, after building it for profiling (the
way iOSOpenDev deploys it on iPhone), I can find it stored on my device at
/usr/lib/libKDylibTwo.dylib and built a tweak (again using iOSOpenDev),
hooking the SpringBoard as follows:
#include <dlfcn.h>
%hook SBApplicationIcon
-(void)launch{
NSLog(@"\n\n\n\n\n\n\nSBHook For libKDylibTwo.dylib");
void* dylibLink = dlopen("/usr/lib/libKDylibTwo.dylib", RTLD_NOW);
if(dylibLink == NULL) {
NSLog(@"Loading failed.");
} else {
NSLog(@"Dylib loaded.");
void (*function)(void);
*(void **)(&function) = dlsym(dylibLink, "run");
if (function) {
NSLog(@"Function found.");
(*function)();
} else {
NSLog(@"Function NOT found");
}
}
NSLog(@"End of code");
%log;
%orig;
}
%end
After installing the tweak on the device and tapping on an icon (that
would fire the hooked code), the Console output looks like:
Aug 28 13:03:35 Pudge Spring
Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: SBHook For
libKDylibTwo.dylib
Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: Dylib loaded.
Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: Function NOT found
Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: End of code
Aug 28 13:03:35 Pudge SpringBoard[18254] <Warning>: -[<SBApplicationIcon:
0x1d5008c0> launch]
My question is what am I doing wrong and the the library's function is not
called or executed! I think I should clarify that I am only talking about
jailbroken devices and not App Store development, so please don't go ahead
posting that it cannot be done!
Thank you in advance,
Panagiotis.

Spring mvc interceptor exception

Spring mvc interceptor exception

My project is baded on spring mvc, and I wrote a interceptor to intercept
request, I want to get parametrts from request, the follows is my code:
public boolean preHandle(HttpServletRequest request, HttpServletResponse
response, Object handler) throws Exception {
HandlerMethod maControl = (HandlerMethod) handler;
Method pmrResolver = (Method) maControl.getMethod();
String methodName = pmrResolver.getName();
....
}
but now it throws a exception:
java.lang.ClassCastException:
org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler
cannot be cast to org.springframework.web.method.HandlerMethod
I don't know why, I have configured in web.xml to avoid intercept static
source.

Tuesday, 27 August 2013

if else in wordpress page - always one or the other

if else in wordpress page - always one or the other

Have a page showing videos from a custom post type. on the video upload
page, users can decide if they want a video thumbnail, or their own photo.
I let them choose this with a radio button. variable is assigned as author
or video (video as default).
I am trying to set it to display author when custom field = author and
thumbnail when custom field = video.
all videos revert to the author thumbnail... maybe I'm missing something
obvious...
<?php
if (have_posts()) : while (have_posts()) : the_post();
$video_post_type = get_custom_fields('video_post_type');
endwhile;
else:
endif;
?>
<?php
<?php
$x = 1;
$loop = new WP_Query( array (
'post_type' => 'video',
'posts_per_page' => 12,
'paged' => get_query_var( 'paged')
) );
if ($loop->have_posts()) : while ($loop->have_posts()) :
$loop->the_post();
$do_not_duplicate = $post->ID;
$video_url=get_post_custom_values('video-url');
$thumb_url=null;
$pic_choice=get_post_custom_values('video-image');
if(strpos($video_url[0], 'youtube.com')!==false){
$url_string = parse_url($video_url[0], PHP_URL_QUERY);
parse_str($url_string, $args);
$vid_id = isset($args['v']) ? $args['v'] : false;
if($vid_id){
$thumb_url='http://img.youtube.com/vi/'.$vid_id.'/hqdefault.jpg';
}
}
if(strpos($video_url[0], 'vimeo.com')!==false){
$vid_id = basename($video_url[0]);
$thumb_url = getVimeoInfo($vid_id,"thumbnail_medium");
}
if(!$thumb_url){
$thumb_url= get_bloginfo('template_directory').'/img/vid-thumb.png';
}
?>
<div class="video-thumb">
<a href="<?php custom_fields('video-url'); ?>">
<?php if ($pic_choice = "author"):?>
<?php userphoto_the_author_photo();?>
<?php else:?>
<img src="<?php echo $thumb_url; ?>" width="200" height="150"/>
<?php endif; ?>
</a>
<div style="text-align:center;" class="video-meta">
<a href="<?php custom_fields('video-url'); ?>"><strong>
<?php the_title(); ?></strong></a> <br/>
<span class="vid-date"><?php custom_fields('video-date');
?></span> <br/>
<span class="vid-date"><?php custom_fields('video-speaker');
?></span>
<br/>
<span class="vid-date"><?php custom_fields('video-image'); ?></span>
<br/>
</div>
</div>
<?php
endwhile;
else:
endif;
?>
<div class="page-nav">
<?php wp_pagenavi(array( 'query' => $loop ) ); ?>
</div>

Adding a closing tag to the DOM before an element

Adding a closing tag to the DOM before an element

I'm needing to insert a closing tag before an element in the DOM. But
jQuery doesn't like the idea of inserting what it believes to be malformed
markup.
To provide a little context, I'm needing to do it this way because I am
unable to alter the code displayed by the Wordpress the_content()
function. All I'm doing is closing a wrapper div, which I will open again
after the next element, so there won't actually be any malformed code.
I suppose I'm looking for something similar to the following:
$('</div><!-- Close Mobile Wrapper -->').insertBefore('.right-col');
But the above renders nothing in the source. Is there any way around this?

Google Places API can't find places by name

Google Places API can't find places by name

I have an application that uses the places API to help find places near
destinations (like London). I prefer using nearby because it allows me to
focus on one area, and it's also cheaper compared to text searches.
Unfortunately, I get answers that don't make a lot of sense. As an
example, if I search for:
name=London Eye
I get zero results (with or without quotes around it).
But if I search by keyword:
keyword=ferris wheel
London Eye is returned. Here are the relevant queries:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[API_KEY]&sensor=false&location=51.52864165,-0.10179430&radius=47022&name=%22london%20eye%22
https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[API_KEY]&sensor=false&location=51.52864165,-0.10179430&radius=47022&keyword=ferris%20wheel
Is there some rhyme or reason to this?
Thanks!

Fragment not changing size of textview

Fragment not changing size of textview

I have an event the should change the size of a textview in my new
fragment that I create the textview is created in my relative layout
shared by my new fragment and my old fragment:
Fragment1 rightFragment;
rightFragment = new Fragment1();
Bundle args = new Bundle();
args.putInt("args", arguments);
rightFragment.setArguments(args);
android.support.v4.app.FragmentTransaction transaction =
getSupportFragmentManager()
.beginTransaction();
transaction.replace(R.id.fragment_container, rightFragment);
transaction.addToBackStack(null);
transaction.commit();
TextView textView = (TextView) findViewById(R.id.text);
textView.setTextSize(settings.getFloat("size", 24.0f));
When I execute this code in my activity, the textView in my old relative
layout is changed, not the new one. How can I make the textView in my new
layout work?

How to join multiple project with same structure

How to join multiple project with same structure

I want join multiple project with same structure, For example:
Project1 Layers:
Project.Project1.Domain - Project.Project1.Data -
Projaect.Project1.Service - Project.Project1.UI.Web
Project2 Layers:
Project.Project2.Domain - Project.Project2.Data -
Projaect.Project2.Service - Project.Project2.UI.Web
and ....
I have EntityFramework in Data layer and asp.net mvc for UI.Web layer.
I've made these projects in different teams.

Fatal error c1083 "afxwin.h"

Fatal error c1083 "afxwin.h"

I apologize for posting this question, When I compile, I get an error
fatal error C1083: Cannot open include file : 'afxwin.h' : No such file or
directory
Thanks very much if you can give a hand.
code:
#if !defined(AFX_STDAFX_H__39403C06_D7D2_4132_9BC8_80C5C886FB8B__INCLUDED_)
#define AFX_STDAFX_H__39403C06_D7D2_4132_9BC8_80C5C886FB8B__INCLUDED_
#if _MSC_VER > 1000
#pragma once

Maximum SQLite Database Size in Android Application

Maximum SQLite Database Size in Android Application

I am new to the Android Development.
Currently, I am working on one Android Application having a large amount
of data.
So I have thought that I should have to store some of those data locally.
I have one database having 2 tables.
Table-1's size is: 4.5 MB Table-2's size is: 3.5 MB currently.
i.e. Totally around 8.0 MB but in future database size can be increased
and may be reach to 10 MB.
Table-1: Rows(14927) and Columns(17) Table-2: Rows(9903) and Columns(38)
My doubt is that can i store this much data locally in an android
application or the application's speed can be affect by it.
I don't want to store these data in external storage. And I can't store it
on server database as I have to use these data many times in the
application. While the other data is on server as it must be used
centrally.
This is my point of view. But please give me your suggestions.
What to do if there is such size of database.
Please help me. Thanks in advance...:)

Monday, 26 August 2013

A real solution to a cubic equation – math.stackexchange.com

A real solution to a cubic equation – math.stackexchange.com

What is the easiest way to find the real solution of the equation
$x^3-6x^2+6x-2=0$? I know the solution to be $x=2+2^{2/3}+2^{1/3}$
(Mathematica) but I would like to find it analytically. If ...

angular-js angular-strap and ng-grid integration?

angular-js angular-strap and ng-grid integration?

Say, I've got multiple tabs and I want to use angular-straps to display
that. However, the content of each tab is dynamic based on an ajax call
for that given tab. Ideally could be derived from the tab id.
| Tab 1 | Tab 2| Tab 3|
So when Tab 1 is clicked, a call to the server is /get/result/tab1_id/ and
when Tab 2 is clicked, a call to the server is /get/result/tab2_id etc...
And use this result to populate a ng-grid somehow.
Angular has a lot of potential, but I am so new to it and a lot of ways of
doing things and I am not good in any. This stuff can be done in jquery in
no time with jtable etc.. but I am trying to learn angular js.
So please help.
Thanks & regards Tin

Adding a function to title close in jQuery dialog - event not firing up

Adding a function to title close in jQuery dialog - event not firing up

I'm assigning and extra class to Jquery modal .dialog() so I can custom
treat the title bar close (.ui-dialog-titlebar-close)
though it doesn't work for some reason
$(".extra_close .ui-dialog-titlebar-close").click(function () {
alert("hello");
});
no alert = just closes the dialog.
What I'm doing wrong?
Thank you Community

std::regex to find word within brackets inside a string, then replace it (and the brackets)

std::regex to find word within brackets inside a string, then replace it
(and the brackets)

Having some trouble with this one. I'm using std::regex for the first time
and the syntax is a little unintuitive to me.
I've got strings with stuff like [VARIABLE] and sometimes [VARIABLEA] \
[VARIABLEB].
Let's say for example I want to replace [VARIABLEA] with Windows and
[VARIABLEB] with System32, so the result would be Windows\System32.
What do you think the best regex would be for finding these matches? What
do you think the best method for replacing them is?
I basically have been streaming into a Stringstream for my replacements
(When I find a match i put in the the new value, when I don't i put in the
original key, for all else I just stream in). But I wasn't sure if
std::regex maybe provided some better option for this.
Here's the regex I've been trying: std::regex("\\\\*\\[[^\\]]*\\]\\\\*");
I'm on a fairly tight schedule and just been banging my head on the desk
for too long with this one. I know it's probably very simple, but I am a
slow learned. Thanks in advance for any help you can provide.

Update/Edit row on another page and send values back to the first page. (Datatable) Asp.net and Vb.net

Update/Edit row on another page and send values back to the first page.
(Datatable) Asp.net and Vb.net

I was wondering if you could help with this problem.(I'm a real beginner)
I have a datatable populated with values from textboxes. Now the problem
is that when clicking on edit button I want to open a new page to edit and
updating the selected row and then send values back to the gridview in
first page. I'm using VB.net

Changing text in splashscreen

Changing text in splashscreen

I have created a splashscreen in VB.Net and everythings works perfect
except the fact that I would like to change the loading text with multiple
texts who changes every x seconds during the loading.

Exemple : Dim LoadingTexts As String = {"charging 1...", "charging 2...",
"info1..."}
I have no idea how i can do this apart the fact that i surely have to use
a timer... But how ?
Actual code:
Public Class frmSplashScreen
Private stringTable() As String = {"Shovelling coal into the
server...", "Programming the flux capacitor...", _
"Searching for answer to live, the
universe and everything...",
"Waiting for Godot...", "Starting..."}
Private stringMove As Integer = 0
Sub New()
InitializeComponent()
End Sub
Public Overrides Sub ProcessCommand(ByVal cmd As System.Enum, ByVal
arg As Object)
MyBase.ProcessCommand(cmd, arg)
End Sub
Public Enum SplashScreenCommand
SomeCommandId
End Enum
Public Sub SplashTimer_Tick(sender As Object, e As EventArgs) Handles
SplashTimer.Tick
Me.SplashTimer.Enabled = False
Me.labelStarting.Text = stringTable(stringMove)
Me.labelStarting.Refresh()
stringMove += 1
If stringMove < stringTable.Length Then Me.SplashTimer.Enabled = True
End Sub
End Class
Thanks.

Android: Is there a way to detect pre-defined keywords and color it differently in EditText?

Android: Is there a way to detect pre-defined keywords and color it
differently in EditText?

I am working on an Android project that needs to detect some pre-defined
keywords in the EditText, and then color those keywords differently from
the other non-keywords, it's like Syntax Coloring in Eclipse.
For Example: The pre-defined word is
stackoverflow!
So, when the user type in the keyword stackoverflow in the EditText, it
will color the keyword-stackoverflow and should look like:

Is there anyone know how to do it? Thanks!

Porting threads to windows. Critical sections are very slow

Porting threads to windows. Critical sections are very slow

I'm porting some code to windows and found threading to be extremely slow.
The task takes 300 seconds on windows (with two xeon E5-2670 8 core 2.6ghz
= 16 core) and 3.5 seconds on linux (xeon E5-1607 4 core 3ghz). Using
vs2012 express.
I've got 32 threads all calling EnterCriticalSection(), popping an 80 byte
job of a std::stack, LeaveCriticalSection and doing some work (250k jobs
in total).
Before and after every critical section call I print the thread ID and
current time.
The wait time for a single thread's lock is ~160ms
To pop the job off the stack takes ~3ms
Calling leave takes ~3ms
The job takes ~1ms
(roughly same for Debug/Release, Debug takes a little longer. I'd love to
be able to properly profile the code :P)
Commenting out the job call makes the whole process take 2 seconds (still
more than linux).
I've tried both queryperformancecounter and timeGetTime, both give approx
the same result.
AFAIK the job never makes any sync calls, but I can't explain the slowdown
unless it does.
I have no idea why copying from a stack and calling pop takes so long.
Another very confusing thing is why a call to leave() takes so long.
Can anyone speculate on why it's running so slowly?
I wouldn't have thought the difference in processor would give a 100x
performance difference, but could it be at all related to dual CPUs?
(having to sync between separate CPUs than internal cores).
By the way, I'm aware of std::thread but want my library code to work with
pre C++11.

Determine infinite nested array in PHP

Determine infinite nested array in PHP

SO,
I have an issue with determining recursion in arrays in PHP. Assume that I
have a dynamic-generated array, which finally can looks like:
$rgData = [
['foo', 'bar', $rgTemp=[7, 31, true]],
[-5, &$rgData, 'baz']
];
(links to variables here are provided dynamically and may refer to an
array itself). Another sample:
$rgData = [
['foo', 'bar', $rgTemp=[7, 31, true]],
[-5, &$rgTemp, 'baz']
];
Both arrays have some references inside, but second looks good since it's
reference is not cycled. Later, due to my logic, I have to handle array
via recursive functions (something like array_walk_recursive) - and, of
cause, I got Fatal error due to infinite nested array recursion in case of
first sample above.
My question is - how to determine if an array has infinite recursion.
Note, that this question is more complicated than simple search link from
inside array to itself, because we can have something like:
$rgOne = [
['foo', 'bar'],
['baz']
];
$rgTwo = [6, 'test', &$rgOne];
$rgOne[1][] = &$rgTwo;
i.e. more complicated recursion. I found that PHP can resolve this somehow
in var_dump and similar functions - for example, dump of the third sample
will look like:
array(2) {
[0]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
}
[1]=>
array(2) {
[0]=>
string(3) "baz"
[1]=>
&array(3) {
[0]=>
int(6)
[1]=>
string(4) "test"
[2]=>
&array(2) {
[0]=>
array(2) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
}
[1]=>
*RECURSION*
}
}
}
}
i.e. _RECURSION_ was caught. Currently, I've tried to resolve a matter via
function:
function isLooped(&$rgData, &$rgCurrent=null)
{
foreach($rgData as $mKey=>$mValue)
{
if(is_array($mValue) && isset($rgCurrent) &&
$rgCurrent===$rgData /* that's where, it seems, I need help*/)
{
return true;
}
elseif(is_array($mValue) && isLooped($mValue, $rgData))
{
return true;
}
}
return false;
}
but with no success (and I know why - that comparison is invalid). The
only idea I have now is to do weird thing, like:
function isLooped(&$rgData)
{
$rgTemp = @var_export($rgData, 1);
return preg_match('/circular references/i', error_get_last()['message']);
}
but that is sad since I need at least copy my array data to some temporary
storage (and, besides, all of this looks like a glitch, not a proper
solution). So, may be there are some ideas of how to do that normal way?

How do you browse and upload a photo from an iPhoto Library to a website using a browser like Safari, Chrome, Firefox, etc

How do you browse and upload a photo from an iPhoto Library to a website
using a browser like Safari, Chrome, Firefox, etc

I've at a site that wants me to upload a photo. I choose Browse... but
when I get to iPhoto Library, it's opaque. Is there some way to browse and
choose one?

Sunday, 25 August 2013

Send files trough ajax post().serialize()

Send files trough ajax post().serialize()

This is a working script for send a form to a php file which process the
data. What should I modify to this code in order to send files? My form
has a file input and I want to keep this code.
Thanks in advance!
<script type="text/javascript">
$("#agregarpaquete").submit( function() {
$.post("cargar_paquete.php",$("#agregarpaquete").serialize(),function(res){
if(res == 1){
$("#exitopaquete").delay(200).fadeIn("slow"); //
Show success div
} else {
$("#fracasopaquete").delay(500).fadeIn("slow"); //
Show failure div
}
});
return false;
});
</script>

$A=\{f |f:\mathbb{Z}_+ \to \{0,1\}\}$ is uncountable

$A=\{f |f:\mathbb{Z}_+ \to \{0,1\}\}$ is uncountable

Consider the set $A=\{f |f:\mathbb{Z}_+ \to \{0,1\}\}$ I need to show that
it is uncountable.
I was trying to find a bijection between $A$ and $\mathbb{R}$ or if i can
show that there is no injection from $A$ to $\mathbb{Z}_+$ then also it'll
work !

Making Fieldset Collapsed on Load

Making Fieldset Collapsed on Load

I need to made all the Fieldset Collapsed when users see my page. So, to
see its content i should click on the Fieldset title. For Example: Here i
have created a jsFiddle which allows to collapse a non collapsed Fieldset,
here is the jQuery:
$(function(){
$('legend').click(function(){
$(this).parent().find('.content').slideToggle("slow");
});
});
But How to make all this Fieldset collapsed? and to see whats inside the
Fieldset people should click on the Fieldset title and then the the
Fieldset will be collapse? Thanks

i don't know how to make this program.. please help me.. tnx

i don't know how to make this program.. please help me.. tnx

Write a complete Java program that will fill an array with int values read
in from the keyboard, one per line, and outputs their sum as well as all
the numbers read in, with each number annotated to say what percentage it
contributes to the sum. Your program will ask the user how many integers
there will be, that will determine the length of the array. Sample Output:
How many integers will you enter? 4 Enter 4 integers, one per line: 2 1 1
2 The sum is 6. The numbers are: 2 which is 33.33% of the sum. 1 which is
16.67% of the sum. 1 which is 16.67% of the sum. 2 which is 33.33% of the
sum

Saturday, 24 August 2013

Any similar concept of "undefined" in other languages?

Any similar concept of "undefined" in other languages?

I know undefined is not equal to null. But is there any similar concepts
in the other languages like c#, C++ or java?

AWS SDK - No Such Key error when trying to rename a file

AWS SDK - No Such Key error when trying to rename a file

I have a rails app that makes direct client-side uploads to S3. The files
go into an uploads bucket I have, and then after validation if
everything's ok with the model they're attached to, I rename and move them
over to a permanent bucket. I've been trying to get this working with the
new sdk in the console and whenever I issue the move_to, or rename_to, or
even copy_to commands, i get an error.
gemfile
gem 'aws-sdk', '~> 1.0'
console
old_key = FileAttachment.find(1).file
AWS.config(access_key_id: ENV['AWS_ACCESS_KEY_ID'], secret_access_key:
ENV['AWS_SECRET_ACCESS_KEY'], region: 'us-east-1')
s3 = AWS::S3.new
bucket = s3.buckets['temp-uploads']
obj = bucket.objects[old_key]
obj.move_to('/uploads/model/id/hi')
AWS::S3::Errors::NoSuchKey: No Such Key
What gives???

using different functions javascript

using different functions javascript

I have this code below, I got the addList() function to work but the
secondPassed() is not working. I would like to output the the
secondPassed() in the label in the code. Any Help?
<!DOCTYPE html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript">
window.onload=function addList()
{
.....code goes here
}
window.onload = addList();
var seconds = 0;
function secondPassed() {
var minutes = Math.round((seconds - 30)/60);
var remainingSeconds = seconds % 60;
if (remainingSeconds < 10) {
remainingSeconds = "0" + remainingSeconds;
}
document.getElementById('countdown').innerHTML = minutes + ":" +
remainingSeconds;
if (seconds <60 ) {
seconds++;
}
}
var countdownTimer = setInterval('secondPassed()', 1000);
</script>
</head>
<body >
<table width="70%" border="1">
<tr>
<td colspan="2"> <label id = "countdown"
value="secondPassed()">0.00</label>
</td>
</tr>
<tr>
<td><p>How long did you balance</p>
<select id="selectNumber" ></select>
<label for="balance"> Seconds</label>
<p>&nbsp;</p></td>
<td>How did you find it?
<p>
<label>
<input type="radio" name="rGroup1" value="radio" id="rGroup1_0">
Easy</label>
<br>
<label>
<input type="radio" name="rGroup1" value="radio" id="rGroup1_1">
Fair</label>
<br>
<label>
<input type="radio" name="rGroup1" value="radio" id="rGroup1_2">
Challenging</label>
<br>
</p>
</td>
</tr>
</table>
</form>
</body>
</html>
I have tried using the two functions in two separate html pages and it
works well, but i am interested in using them both on the same html page.

Ruby on Rails Tutorial -- strange uses of upcase/downcase and case-insensitivity

Ruby on Rails Tutorial -- strange uses of upcase/downcase and
case-insensitivity

Working my way through Michael Hartl's excellent tutorial for Ruby on
Rails. I'm at the point where he creates a test that checks for duplicate
email addresses, and I'm a little confused about his use of upcase,
downcase, and case-insensitive checks.
The test (Listing 6.17) looks like this:
describe User do
before do
@user = User.new(name: "Example User", email: "user@example.com")
end
.
.
.
describe "when email address is already taken" do
before do
user_with_same_email = @user.dup
user_with_same_email.email = @user.email.upcase
user_with_same_email.save
end
it { should_not be_valid }
end
end
Note the call to upcase. All fine. But in his validity check (6.18), he
sets case sensitivity off.
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
What? Why did he convert the copy to uppercase if he was going to do a
case-insensitive validation?
Finally, in 6.20, he sets up a before_save block that converts a new
user's email to lowercase.
before_save { self.email = email.downcase }
That makes perfect sense, because you want lowercase in your database. But
I'm confused as to why he used uppercase in the test, given that the save
is going to convert the email address to lowercase anyway. Am I missing
something obvious?

Winform C# : Set default value to particular column in datagrid

Winform C# : Set default value to particular column in datagrid

Winform C#:
I have 3 columns in dataGrid in form such as ID,Name,Date. I have to set
particular value for Date column on each row on button click event.
I tried for Default property of datagrid but it will set default value
when new row add to datagrid.
Thanks.

Codeigniter Ajax dropdown

Codeigniter Ajax dropdown

controller(user.php)
<?php
class User extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this -> load -> model('country_model');
}
public function index()
{
$this->load->view('register');
}
public function register()
{
$data['countries'] = $this->country_model-> get_countries();
$this -> load -> view('post_view', $data);
}
public function get_cities($country)
{
$this->load->model('city_model');
header('Content-Type: application/x-json; charset=utf-8');
echo(json_encode($this->city_model->get_cities($country)));
}
}
City_model
<?php
class City_model extends CI_Model
{
public function __construct()
{
$this -> load -> database();
}
function get_cities($country = null)
{
$this->db->select('id, city_name');
if($country != NULL){
$this->db->where('country_id', $country);
}
$query = $this->db->get('cities');
$cities = array();
if($query->result())
{
foreach ($query->result() as $city)
{
$cities[$city->id] = $city->city_name;
}
return $cities;
}
else
{
return FALSE;
}
}
}
?>
country_model
<?php
class Country_model extends CI_Model
{
public function __construct()
{
$this -> load -> database();
}
function get_countries()
{
$this -> db -> select('id, country_name');
$query = $this -> db -> get('countries');
echo "countries";
$countries = array();
if ($query -> result()) {
foreach ($query->result() as $country) {
$countries[$country -> id] = $country -> country_name;
}
return $countries;
}
else
{
return FALSE;
}
}
}
?>
view file
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">// <![CDATA[
$(document).ready(function(){
$('#country').change(function(){ //any select change on the dropdown with
id country trigger this code
$("#cities > option").remove(); //first of all clear select items
var country_id = $('#country').val(); // here we are taking country id of
the selected one.
$.ajax({
type: "POST",
url: "http://localhost/task/user/get_cities/"+country_id, //here we are
calling our user controller and get_cities method with the country_id
success: function(cities) //we're calling the response json array 'cities'
{
$.each(cities,function(id,city) //here we're doing a foeach loop round
each city with id as the key and city as the value
{
var opt = $('<option />'); // here we're creating a new select option
with for each city
opt.val(id);
opt.text(city);
$('#cities').append(opt); //here we will append these new select options
to a dropdown with the id 'cities'
});
}
});
});
});
// ]]>
</script>
</head>
<body>
<?php $countries['#'] = 'Please Select'; ?>
<label for="country">Country: </label><?php echo
form_dropdown('country_id', $countries, '#', 'id="country"'); ?><br />
<?php $cities['#'] = 'Please Select'; ?>
<label for="city">City: </label><?php echo form_dropdown('city_id',
$cities, '#', 'id="cities"'); ?><br />
</body>
</html>
I am trying to populate the data from database using codeigniter ajax
dropdown. I couldnt able to get the value from database. I dont know where
i did mistake. Any help would appreciate.

SMS broadcasting programmatically

SMS broadcasting programmatically

Resource
Cell Broadcast is designed for simultaneous delivery to multiple users in
a specified area! WIKI DOC HERE
LOGIC NEED TO IMPLEMENT
how to broadcast sms in a perticular area people?
Code i know
i know how to send sms programmatically Need to know how to broadcast sms
programmatically in a perticular area people!

Friday, 23 August 2013

jQuery Waypoints Sticky Plugin Hides Slider Items

jQuery Waypoints Sticky Plugin Hides Slider Items

The Tools: I'm using Caleb Troughton's jQuery Waypoints plugin and its
extension plugin Sticky Elements to manage my header and make my
Flexslider sticky. The Problem: However, once the 'sticky' class becomes
assigned to the Flexslider's containing div the list items disappear but
only for about 1 fold worth of scroll then it comes back again.
I CANNOT figure it out after many hours and two different slider solutions
so I'm turning to SO. Any help would be greatly appreciated.
jQuery('.fixme').waypoint('sticky', {
wrapper: '<div class="sticky-wrapper"></div>',
stuckClass: 'stuck',
offset: 155
})
HTML:
<div class="fixme">
<section class="slider">
<div class="flexslider">
<ul class="slides">
<li>
<img src="image-here.jpg" width="805" height="400"/>
</li>
</ul>
</div>
</section>
</div>
CSS:
#corner_box_widget{ width: 805px; height: 500px; border: none; }
/*widget class, placeholder*/
.fixme{ width: 805px; /*background: none;*/ }
.stuck{ position: fixed; top: 150px; background: transparent; }

How to use Google Maps JavaScript API v3's Geocoding Service in Filter.js?

How to use Google Maps JavaScript API v3's Geocoding Service in Filter.js?

I am using filter.js in a website along with Google Maps API V3 as it
shows in its demo/example(of filter.js) with only one difference, my
requirements are to use Address instead of Latitude or Longitude and as
far I know it could be done using Geocoding Service of Google Maps. I have
to modify some of my code:
Before
addMarker: function(salon){
var that = this;
var marker = new google.maps.Marker({
position: new google.maps.LatLng(salon.lat, salon.lng),
map: this.map,
title: salon.title
});
marker.info_window_content = salon.title + '<br/> Treatments: ' +
salon.treatments + '<br/> Booking: ' + salon.bookings_1 + '<br/>
Address: ' + salon.address + '<br/><a href="' + salon.permalink + '">
View Full Details </a>'
this.markers[salon.id] = marker
google.maps.event.addListener(marker, 'click', function() {
that.infowindow.setContent(marker.info_window_content)
that.infowindow.open(that.map,marker);
});
},
After
addMarker: function(salon){
//new line for address
var salonaddress = salon.address1 + ' ' + salon.address2 + ' ' +
salon.address3 + ', ' + salon.city + ', ' + salon.state + ' ' +
salon.postal_code + ', ' + salon.country ;
console.log(" salonaddress: " + salonaddress)
var that = this;
geocoder.geocode( { 'address': salonaddress}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
that.map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: this.map,
title: salon.title,
position: results[0].geometry.location
});
marker.info_window_content = salon.title + '<br/> Treatments: '
+ salon.treatments + '<br/> Booking: ' + salon.bookings_1 +
'<br/> Address: ' + salon.address + '<br/><a href="' + salon.
permalink + '"> View Full Details </a>'
that.markers[salon.id] = marker
google.maps.event.addListener(marker, 'click', function() {
that.infowindow.setContent(marker.info_window_content)
that.infowindow.open(that.map,marker);
});
} else {
alert('Geocode was not successful for the following reason: ' +
status);
}
});
},
It looks like its working but it is not showing markers on map at all.
Trying to find my mistake but after many hours still could not fix it. Can
any one point out my coding mistake?

WYSIWYG Editor, mod_rewrite and sessions

WYSIWYG Editor, mod_rewrite and sessions

I'm using a WYSIWYG Editor on my site (sceditor) and also mod_rewrite
rules. The problem is any page which has a URL that has been rewritten
using mod_rewrite and contains the WYSIWYG editor logs out the user
whenever they visit it.
If I remove the javascript that initialises the editor, then the user
stays logged in, but obviously the textarea isn't converted.
Javascript for Initialising Editor
function initEditor() {
$("textarea").sceditor({
plugins: "bbcode",
toolbar:
"bold,italic,underline,strike|subscript,superscript|left,center,right|font,size,color|bulletlist,orderedlist|quote,image,link,youtube",
style: "/minified/jquery.sceditor.default.min.css",
resizeEnabled: false,
autoExpand: true,
autoUpdate: true
});
}
$("textarea").ready(function() {
initEditor();
});
I have tried including [L,QSA] tags on my rewrites but that didn't help.
My sessions are fine as they work on every page without the editor.
Does anyone have any idea why this is happening? I have put the javascript
through jslint and it says there are no major problems with it.

Excel Mac VBA Loop Through Cells and reset some values

Excel Mac VBA Loop Through Cells and reset some values

I currently have a worksheet that I have multiple people filling out every
day. There are 4 columns that the users fill out: C, E, H, & J (all
numerical values, one row per day of the month.)
The users fill in C, E, & H every day no matter what, but a lot of days
there is no value to put in column J. I need the value in J to be set to 0
if the user doesn't enter anything. Of course it would be easier to just
have the users enter 0, but I'm working with a complicated group of people
here.
Anyway, I want to use a macro that runs automatically when the user clicks
the save button (before it actually saves, of course), and have it do the
following: (I am more familiar with php, so I'm just typing this out how
I'm familiar - I'm sure my syntax is incorrect)
Foreach Row
If "column A" != "" {
If "column J" != "" {
//Everything is good, continue on...
} else {
CurrentRow.ColumnJ.value == 0
}//Value has been set - continue loop
}
//column A is blank, this day hasn't come yet - quit looping here
End Foreach
If anyone could help me out with this I'd appreciate it. With some
research, this is what I've come up with so far, and now I'm stuck…
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim curCell As Range
'Labor Flow Sheet'.Select
For Each curCell in Range( ???? )
If curCell.Value = "" Then
???????
End If
Next curCell
End Sub
Thanks in advance!

Setting up watchdog_set_period to max value causes reboot

Setting up watchdog_set_period to max value causes reboot

I don't much about how watchdog timer works in embedded environment and I
am facing issue related to watchdog timer
Maximum time out value defined in one of the macro is 55 and when we try
to set up this value from watchdog_set_period function ,our board is
getting reboot
#define Max_time_out 55
watchdog_set_period(int period)
where period = 55
Now is it something expected or how what is the reason for reboot
We are writing this period value to some driver which we are accessing
through file descriptor.

Creating a new Android Library in Android Studio

Creating a new Android Library in Android Studio

I've been searching the web for half a day now but I just can't figure out
how to create a new Android Library with Android Studio. I've tried doing
things like this: How to create a library project in Android Studio and an
application project that uses the library project But when I enter the New
Module menu it just says "Nothing to show". I can't find out why or how to
fix it. Is there a way to manually add a library? If so, how? I'm trying
to add an import method to my app so users can import a preferably rar
file or just a folder to be used in the app.
TL;DR: How can I add the option Android Library to my New Module menu
inside Android Library?

Thursday, 22 August 2013

delphi 6 how to sending email using CDO_TLB

delphi 6 how to sending email using CDO_TLB

i know this is an old topic and i have tried to look at the internet for a
solution. the code is a little straight forward but cannot make it to
work.
i already have the code but delphi 6 gives me a message
"SendUsing" configuration value is invalid
my goal is to send a file attach to my own gmail account.
procedure TForm1.Button1Click(Sender: TObject);
var
M: IMessage;
s: string;
begin
//uses CDO_TLB;
M := CoMessage.Create;
M.From := 'myname@gmail.com';
M.To_ := 'myname@gmail.com';
M.Subject := 'This is subject' + datetimetostr(now);
M.TextBody := 'This is text body' + datetimetostr(now);
s := 'http://schemas.microsoft.com/cdo/configuration/';
with M.Configuration.Fields do begin
Item[s + 'sendusing'].Value := cdoSendUsingPort;
Item[s + 'smtpserver'].Value := 'smtp.gmail.com';
Item[s + 'smtpauthenticate'].Value := cdoBasic ;
Item[s + 'sendusername'].Value := 'myname';
Item[s + 'sendpassword'].Value := 'mypassword';
Item[s + 'smtpserverport'].Value := 465;
Item[s + 'smtpusessl'].Value := False;
Item[s + 'smtpconnectiontimeout'].Value := 5; // default is 30 seconds
Update;
end;
try
M.Send;
// success
except
// fail
on E: Exception do
ShowMessage(E.Message);
end;
end;

Cant access localhost on my browsers

Cant access localhost on my browsers

I've just installed mamp for the first time onto my mac and I'm trying to
view some PHP files I've loaded into the htdocs secion of mamp. When I
type localhost into my browsers, it says it can't connect to the server.
What do I do to fix this?
I'm a complete rookie at this so any help would be appreciated.
Many thanks,

How do I calculate the no. of strings in a string array?

How do I calculate the no. of strings in a string array?

I came around this similar question. But the advantage I have is that i
know that each string is 260 char long.
Any hope?
int noOfStrings = sizeof(stringArray)/sizeof(stringArray[0]);
This doesn't work.

Getting the children tables in a mysql database which uses MyIsam engine

Getting the children tables in a mysql database which uses MyIsam engine

I need a sql instruction in mysql that allows me to retrieve the children
tables of a specific table, the peculiarity of this is that the database
uses the MyIsam engine, I think this is possible for I have used SchemaSpy
and the model that this tools produces signals the children tables, I
think this tool uses the key caché of MyISAM as a reference to detect the
children tables.

Convert an asynchronous function to a synchronous function

Convert an asynchronous function to a synchronous function

I use a certain Node.js class for text categorization. In its simplest
form, it looks like this:
function TextCategorizer(preprocessors) {
...
}
"preprocessors" is an array of functions of the form:
function(text) {
return "<modified text>"
}
They can be used, for example, to remove punctuations, convert to lower
case, etc.
I can use the TextCategorizer like this:
var cat = newTextCategorizer(preprocessors);
cat.train(text1,class1);
cat.train(text2,class2);
...
console.log(cat.classify(text3,class3);
The preprocessors are called in order for every training text and
classified text.
Now, I need to add a new preprocessor function - a spelling correcter. The
best spelling corrected I found works asynchronously (through a
web-service), so, the function looks like this:
correctSpelling(text, callback) {
...
callback(corrected_version_of_text);
}
i.e. it does not return a value, but rather calls a callback function with
the value.
My question is: how can I use the correctSpelling function, as one of the
preprocessors in the preprocessors array I send to TextCategorizer?

Checkbox value is always 'on'

Checkbox value is always 'on'

this is my checkbox
<label class="checkbox">
<input id="eu_want_team" name="eu_want_team" type="checkbox">
</label>
var eu_want_team = $('#eu_want_team').val();
alert(eu_want_team);
Its always displaying ON, is it checked or not. Whats the problem with it?

Wednesday, 21 August 2013

How to set one word name and leave empty last name in Google Mail?

How to set one word name and leave empty last name in Google Mail?

Issue
I discovered only indirect answers, so I attach a direct question and answer.
For some services is useful to have one name in the email header. When you
create email account Google by default does not allow to leave the name
field empty.
Solutions
1) Easy - login to Google Mail > open links "Settings > Accounts > Send
mail as > edit info" > change field "Name" to one word > Save Changes.
2) Hard way or if you want empty both names - login to Google Apps Admin >
open links "Users > choose user > Rename >" put special char "lrm" from
"Char map" U+200E to "Last name".
Indirect sources
Does my name get sent along with my email?
How can you change how your Gmail account name appears?
http://chris.calabrese.org/?p=271

HttpWebRequest.Method = "Search" Causes Login Timeout

HttpWebRequest.Method = "Search" Causes Login Timeout

I've been editing this question over and over as I've traversed these
errors, but I think I've been able to target the crucial issue.
I've been trying to connect to Exchange 2003 to get some information out
of the calendar. Originally, I thought the problem was that I couldn't
connect at all. The errors differed depending on which settings I used,
but I could never establish the connection. As it turns out, I can
connect--but when I use request.Method = "SEARCH" I consistently get a
(440) Login Timeout.
I don't understand. You'll see that I have another line commented out,
where I use Post as the request method. When I use that, it connects. It
doesn't bring back the data that I want (which is why the xml.Load is
commented out), but it connects to the server and returns something--a lot
of question marks.
But every example I can find online that does what I am trying to do uses
request.Method = "SEARCH". In particular, at MSDN, CodeProject, and this
blog post.
Maybe there's an element I'm missing that enables the "SEARCH" method, but
Ive tried a lot of variations. I've narrowed down the code below to the
most basic pieces.
I should probably mention that I'm trying to connect to a series of
mailboxes using a service account. I'm not sure what difference that would
make. I know the service account has all necessary permissions to access
these folders and edit them.
If there are any other diagnostics I can do, or any particular data I can
try to get back to test this connection, I'm open to suggestion. This is
my first time working with Exchange.
static void Main(string[] args)
{
string user = "user";
string password = "password";
string domain = "mysite.com";
string baseURI = @"http://mail.myserver.net/";
string mailbox = "exchange/t01";
string calendarURI = baseURI + mailbox + "/calendar";
string strQuery;
byte[] bytes = null;
strQuery = "<?xml version=\"1.0\"?><D:searchrequest xmlns:D =
\"DAV:\" >";
strQuery += "<D:sql>SELECT \"DAV:href\" FROM scope('hierarchical
traversal of \"";
strQuery += calendarURI + "\"')</D:sql></D:searchrequest>";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseURI
+ mailbox + "/calendar");
request.Credentials = new NetworkCredential(user, password, domain);
//request.Method = WebRequestMethods.Http.Post;
request.Method = "SEARCH";
bytes = Encoding.UTF8.GetBytes(strQuery);
Stream stream = request.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
stream.Close();
request.ContentType = "text/xml";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
XmlDocument xml = new XmlDocument();
//xml.Load(responseStream);
responseStream.Close();
Console.WriteLine("Successful login");
Console.ReadLine();
}

What's the regular expression for regular expressions?

What's the regular expression for regular expressions?

Ok, so it's late on a Wed night and this is for no good reason. But I'd
like to see one in any dialect, if it exists, just to be impressed.
-matthew

How to disable "smart" qoute replacement for Russian in MS Word?

How to disable "smart" qoute replacement for Russian in MS Word?

Looks like MS Word is degraded much from times I used it a lot...
How to disable "smart" quotes replacement for Russian? It is disabled in
AutoCorrect window but still works:

Apple Fullscreen screen switching back to main desktop

Apple Fullscreen screen switching back to main desktop

I'm new to Mac, so I apologize if I use the wrong terminology or am unclear.
I have two Thunderbolt displays and a Macbook Air, and I'm having a
problem with full screened applications. When I'm working on something
that is full screened, occasionally it will switch back to the main
desktop without me having pressed anything. If I'm typing in the full
screened window and my text editor gets focus when it switches back, It'll
type stuff into the text editor. This has led me to accidentally bugging
up code I've been writing without noticing :(
Anyone have any idea what is going on?

Qwt installation QT_PLUGIN_PATH

Qwt installation QT_PLUGIN_PATH

I have the following problem. I'm trying to use qwt qith Qt Creator, I
read the documentation downloaded the files, qmake, make, make install
worked fine and created everything under /usr/local/qwt-6.1.0. My Qt
folder is ~/Qt5.1.0
So I'm trying to change the QT_PLUGIN_PATH within the qt.conf file.
[Paths]
Libraries=../lib/qtcreator
Plugins=/usr/local/qwt-6.1.0/plugins:/plugins
Imports=imports
Qml2Imports=qml
But if I do the Qt Creator won't start, when I change it back to just
Plugins=plugins it works fine.
I also tryed the bashrc entry but no luck ether. Thanks for help.

TCP Sockets: "Rollback" after timeout occured

TCP Sockets: "Rollback" after timeout occured

This is a rather general question about TCP sockets. I got a client/server
application setup where messages are sent over the wire via TCP. The
implementation is done via C++ POCO, however the question is not related
to a certain technology.
A message can be a request (initiated by the client) or a response
(initiated by the server).
A request has the structure:
Message Header
Request Header
Parameters
A response has the structure
Message Header
Response Header
Parameters
I know TCP guarantees that sent packages will be delivered in the order
they have been sent. However, nothing can be assumed about the timespan a
delivery might need.
On both sides I have a read/send timeout configured. Now I wonder how to
have a clean set up on the transmitted data after a timeout. Don't know
how to express this in the right terms, so let me describe an example:
Server S sends a response to the client (Message Header, Response Header,
Parameters are put into the stream)
Client C receives the message header partially (e.g. the first 4 bytes of 12)
After these 4 bytes have been received, the reception timeout occurs
On client-side, an appropriate exception is thrown, the reception will be
stopped.
The client considers the package as invalid.
Now the problem is, when the client tries to receive another package, he
might receive the lasting part of the "old" response message header. From
the point of view of the currently processed transaction (send request/get
response), the client receives garbage.
So it seems that after a timeout has occured (no matter whether it has
been on client or server-side), the communication should continue with a
"clean setup", meaning that none of the communication partners will try to
send some old package data and that no old package data is stored within
the stream buffer of the respective socket.
So how are such situations commonly handled? Is there some kind of design
pattern / idiomatic way to solve this? How are such situations handled
within other TCP-based protocols, e.g. HTTP?
In all the TCP samples around the net I've never seen an implementation
that deals with those kind of problems...
Thank you in advance

Tuesday, 20 August 2013

How to print exact value of the program counter in C

How to print exact value of the program counter in C

I want to write a C program which would print the contents of the program
counter PC. Can this be done from user space, or assembly, or some
specific kernel routines are used?

What is loop0 and how do I e2fsck it?

What is loop0 and how do I e2fsck it?

EXT3-fs (sdd1): using internal journal
EXT3-fs (sdd1): mounted filesystem with ordered data mode
EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts:
EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts:
EXT4-fs (sdc1): mounted filesystem with ordered data mode. Opts:
Adding 4194296k swap on /dev/sdd2. Priority:-1 extents:1 across:4194296k SSD
kjournald starting. Commit interval 5 seconds
EXT3-fs (loop0): warning: maximal mount count reached, running e2fsck is
recommended
EXT3-fs (loop0): using internal journal
EXT3-fs (loop0): mounted filesystem with ordered data mode
(loop0) is mounted too many times. What is it? Is it important?
This is my fstab
#
# /etc/fstab
# Created by anaconda on Wed Nov 1 00:29:46 2000
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9fac7ae7-9948-4612-88dc-e652fc4ceb73 / ext4
defaults 1 1
UUID=1daa52c7-a5da-464d-a4c7-2ee19ef017af /boot ext3
defaults 1 2
UUID=12649fb1-fd53-4558-8a2a-79692ada8b19 swap swap
defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/usr/tmpDSK /tmp ext3 defaults,noauto
0 0
/dev/sda1 /home1 auto
auto,noatime,defaults 0 2
/dev/sdb1 /home2 auto
auto,noatime,defaults 0 2
/dev/sdc1 /home3 auto
auto,noatime,defaults 0 2

mongoid update elements within array

mongoid update elements within array

I am using mongoid 3.1 with Ruby 1.9.3 and I am trying to update a value
within an array. I can successfully perform the following command in
mongodb's CLI, but can't seem to find the appropriate solution/translation
for mongoid.
user.update( { activities: { $elemMatch: { uuid: "1111111-xxxx-xxxx" }}},
{ $set: { 'activities.$.submitted': true }})
For context the document looks like:
{
"_id" : ....,
"user_name" : "bob",
"activities: [
{
uuid: "1111111-xxxx-xxxx",
submitted: true,
},
{
uuid: "222222-xxxx-xxxx",
submitted: false,
},
{
uuid: "333333-xxxx-xxxx",
submitted: false,
}
]
}
The goal is to change submitted to true based on the uuid value. From what
I can tell, all of the "updating" solutions in mongoid only deal with the
attributes at the root of the document and can't have options for the $
positional operator.
Any help would be appreciated.
Thank you

Why do some assembly references have a version and others not when added through NuGet

Why do some assembly references have a version and others not when added
through NuGet

I'm adding all packages through NuGet, so I'm not manually tweaking the
Specific Version property in Visual Studio. However depending on which
package (or even which version) I add, I end up with different ways of how
the reference is added. As you can see below:
A reference to Autofac is added without a version.
A reference to AutoMapper is added, but the assembly version is added as
well. Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL"
Even stranger is the fact that the stable NuGet package of AutoMapper
doesn't add the version either (make sure you save the csproj file between
changing packages). What's the reason that packages added through the same
method (NuGet install package) results in different configurations?
<Reference Include="Autofac">
<HintPath>..\packages\Autofac.3.1.1\lib\portable-win+net40+sl50+wp8\Autofac.dll</HintPath>
</Reference>
<Reference Include="AutoMapper, Version=3.0.0.0, Culture=neutral,
processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\AutoMapper.3.0.0-ci1043\lib\windows8\AutoMapper.dll</HintPath>
</Reference>

Load random websites on page load

Load random websites on page load

Is there any option to open random pages in different tabs (in new tabs),
on page load
Regards http://www.idea-ads.com/

Changed Discovery Behavior of Alternative MinGW in Eclipse-CDT(8.2) Bundled in Kepler-version(4.3)

Changed Discovery Behavior of Alternative MinGW in Eclipse-CDT(8.2)
Bundled in Kepler-version(4.3)

When using an alternative MinGW version like e.g.,
mingwbuilds-gcc/g++-4.8.1, the CDT(8.2) bundled in the latest
Kepler-version(4.3) is not able to discover it as a MinGW tool chain. This
behavior is introduced with this latest release.
The MinGW discovery process works fine on such an alternative MinGW in
previous releases like Juno-SR2 bundled with CDT(8.1.1) and so on.
Indeed, there's a workaround to this problem by simply adding a file entry
named mingw32-gcc.exe in MinGW bin directory (e.g., by issuing touch
c:\MinGW\bin\mingw32-gcc.exe)

I've tried to find some documentation of the CDT tool chain discovery
process, especially for this latest CDT 8.2-version, without any success.
So, my question is: Where to find such documentation - if any?
Or, can anybody explain?

Many thanks in advance!

How to alert inline of button

How to alert inline of button

I know already how to alert by use javascript or Jquery. But just onclick
button I apply javascript external or internal. What I need is we alert
inline of button
Example : <button name="my_btn" id="my_btn" onClick="alert('Hello I am
alert')">Alert</button>
If it is possible please tell me. I am waiting for all of you
Thank regard, Yuth

Monday, 19 August 2013

SharedPreferences ListPreference NullPointerException

SharedPreferences ListPreference NullPointerException

I'm trying to set up a list of frequencies in my preferences xml but I
keep getting this error. I have attached all the related files too. I
believe that I set up the values correctly but I can't find where my error
currently is. Also, when I use the SharedPreferences.getString(key,
defaultValue) what value is returned? The ENTRY or the ENTRYVALUE?
My Error:
08-20 00:14:25.195: E/AndroidRuntime(1260): FATAL EXCEPTION: main
08-20 00:14:25.195: E/AndroidRuntime(1260): java.lang.NullPointerException
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.preference.ListPreference.findIndexOfValue(ListPreference.java:215)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.preference.ListPreference.getValueIndex(ListPreference.java:224)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.preference.ListPreference.getEntry(ListPreference.java:202)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.preference.ListPreference.getSummary(ListPreference.java:148)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.preference.Preference.onBindView(Preference.java:515)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.preference.Preference.getView(Preference.java:453)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:222)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.AbsListView.obtainView(AbsListView.java:2461)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.ListView.makeAndAddView(ListView.java:1775)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.ListView.fillDown(ListView.java:678)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.ListView.fillFromTop(ListView.java:739)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.ListView.layoutChildren(ListView.java:1628)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.AbsListView.onLayout(AbsListView.java:2296)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.View.layout(View.java:14063)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.ViewGroup.layout(ViewGroup.java:4603)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.View.layout(View.java:14063)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.ViewGroup.layout(ViewGroup.java:4603)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.View.layout(View.java:14063)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.ViewGroup.layout(ViewGroup.java:4603)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.View.layout(View.java:14063)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.ViewGroup.layout(ViewGroup.java:4603)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.View.layout(View.java:14063)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.ViewGroup.layout(ViewGroup.java:4603)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1994)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1815)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4518)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.Choreographer.doFrame(Choreographer.java:525)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.os.Handler.handleCallback(Handler.java:615)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.os.Looper.loop(Looper.java:137)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
android.app.ActivityThread.main(ActivityThread.java:4898)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
java.lang.reflect.Method.invokeNative(Native Method)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
java.lang.reflect.Method.invoke(Method.java:511)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-20 00:14:25.195: E/AndroidRuntime(1260): at
dalvik.system.NativeStart.main(Native Method)
xml layout:
<ListPreference
android:key="frequency_key"
android:title="Sample Rate"
android:defaultValue="8000"
android:entries="@array/freq_titles"
android:entryValues="@array/freq_values"
/>
xml array:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="freq_titles">
<item name="8000">8k Hz</item>
<item name="16000">16k Hz</item>
<item name="22050">22.05k Hz</item>
<item name="44100">44.1k Hz</item>
<item name="48000">48k Hz</item>
</string-array>
<integer-array name="freq_values">
<item name="8000">8000</item>
<item name="1600">16000</item>
<item name="22050">22050</item>
<item name="44100">44100</item>
<item name="48000">48000</item>
</integer-array>
</resources>