Mention 2 modifications that can be done to a linked list data structure
so that it is converted into a binary tree data structure?
It's an A level question. I looked it out on google but only programs are
found. I need theory explanation.
Saturday, 31 August 2013
Recursive realtion solution in terms of variable(p) in Mathematica
Recursive realtion solution in terms of variable(p) in Mathematica
u[0, 0] =1 u[m, n] =(1/(p + m + m^2)) (m*u[(m - 1), n] + n*u[(m + 1), (n -
2)] + m*(m - 1)*u[(m - 2), (n + 2)])
I want u[m,n] in terms of p; don't want answer like u[0,2]=2u[1,0]/p only
in terms of p; like I want value of u[m,n] for different value of m and n.
u[0, 0] =1 u[m, n] =(1/(p + m + m^2)) (m*u[(m - 1), n] + n*u[(m + 1), (n -
2)] + m*(m - 1)*u[(m - 2), (n + 2)])
I want u[m,n] in terms of p; don't want answer like u[0,2]=2u[1,0]/p only
in terms of p; like I want value of u[m,n] for different value of m and n.
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.
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?
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
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
why is the following code not behving correctly?
why is the following code not behving correctly?
I wrote following piece of code to verify if the input is a valid pan
number using regular expressions. It is returning "NO" for ABCDS1234Y.
void process(string inp)
{
string panex= "[A-Z]{5}[0-9]{4}[A-Z]{1}";
regex panreg(panex,regex_constants::basic);
if(regex_match(inp,panreg))
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
http://ideone.com/fgGScw
is there something wrong with compiler or the regular expression.
I wrote following piece of code to verify if the input is a valid pan
number using regular expressions. It is returning "NO" for ABCDS1234Y.
void process(string inp)
{
string panex= "[A-Z]{5}[0-9]{4}[A-Z]{1}";
regex panreg(panex,regex_constants::basic);
if(regex_match(inp,panreg))
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
http://ideone.com/fgGScw
is there something wrong with compiler or the regular expression.
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!
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!
Arrangement of "list items" in listview using html
Arrangement of "list items" in listview using html
This is my first "phonegap" application project, so done with the listview
in html based on the requirement but listview is not properly formatted
(ie one below the other), how to make the items to display one below the
other. please help me.
here's my code for listview
<div>
<ul data-role="listview" data-inset="true">
<li><a href="#">
<img src="images/c3.jpeg" align="left">
<h3>CONGRATULATIONS</h3>
</a>
</li>
<li><a href="#">
<img src="images/c2.jpeg" align="left">
<h3>HOLYDAY</h3>
</a>
</li>
<li><a href="#">
<img src="images/card1.jpeg" align="left">
<h3> I'M SORRY </h3>
</a>
</li>
<li><a href="#">
<img src="images/c4.jpg" align="left">
<h3> HAPPY BIRTHDAY </h3>
</a>
</li>
<li><a href="#">
<img src="images/c5.jpg" align="left">
<h3> MISSING U</h3>
</a>
</li>
<li><a href="#">
<img src="images/images.jpg" align="left">
<h3> ENGAGEMENT</h3>
</a>
</li>
![device output][1]
This is my first "phonegap" application project, so done with the listview
in html based on the requirement but listview is not properly formatted
(ie one below the other), how to make the items to display one below the
other. please help me.
here's my code for listview
<div>
<ul data-role="listview" data-inset="true">
<li><a href="#">
<img src="images/c3.jpeg" align="left">
<h3>CONGRATULATIONS</h3>
</a>
</li>
<li><a href="#">
<img src="images/c2.jpeg" align="left">
<h3>HOLYDAY</h3>
</a>
</li>
<li><a href="#">
<img src="images/card1.jpeg" align="left">
<h3> I'M SORRY </h3>
</a>
</li>
<li><a href="#">
<img src="images/c4.jpg" align="left">
<h3> HAPPY BIRTHDAY </h3>
</a>
</li>
<li><a href="#">
<img src="images/c5.jpg" align="left">
<h3> MISSING U</h3>
</a>
</li>
<li><a href="#">
<img src="images/images.jpg" align="left">
<h3> ENGAGEMENT</h3>
</a>
</li>
![device output][1]
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?
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
Why use setTimeout in deferred
Why use setTimeout in deferred
I tried to understand of how deferred works,so in all of them they use
setTimeout.
this.callbacks;// array of functions reference
this.callbacks.forEach(function(callback){
window.setTimeout(function(){
callback(data);
},0);
});
one example from this questions that use setTimeout
resolve: function (data) {
this.promise.okCallbacks.forEach(function(callback) {
window.setTimeout(function () {
callback(data)
}, 0);
});
},
What is the different between calling functions in loop by setTimeout than
callback(); or callback.call();
I tried to understand of how deferred works,so in all of them they use
setTimeout.
this.callbacks;// array of functions reference
this.callbacks.forEach(function(callback){
window.setTimeout(function(){
callback(data);
},0);
});
one example from this questions that use setTimeout
resolve: function (data) {
this.promise.okCallbacks.forEach(function(callback) {
window.setTimeout(function () {
callback(data)
}, 0);
});
},
What is the different between calling functions in loop by setTimeout than
callback(); or callback.call();
Testing an online shop: buster vs. selenium
Testing an online shop: buster vs. selenium
I'm new to test driven development.
My project is an online shop with legacy Java backend and a static grid
based UI implemented with JSP and a light touch of Javascript/JQuery. We
have two different versions of the UI: one for mobile and one for desktop
browsers.
My task is to choose a test framework and I am thinking to choose between
BusterJS and Selenium. I've been reading a little about both and this is
what I understood:
Selenium is older and has a bigger community plus an IDE that runs on
Firefox and allows rapid test prototyping. It allows running tests in
parallel and supports several programming languages.
Buster.JS is in beta with big promises for the future. We need to write
tests in Javascript.
That's pretty much what I know about them.
We want to test the functionality of our online shop so it doesn't break
between releases (both back-end and front-end). What test frame work do
you recommend and why?
I'm new to test driven development.
My project is an online shop with legacy Java backend and a static grid
based UI implemented with JSP and a light touch of Javascript/JQuery. We
have two different versions of the UI: one for mobile and one for desktop
browsers.
My task is to choose a test framework and I am thinking to choose between
BusterJS and Selenium. I've been reading a little about both and this is
what I understood:
Selenium is older and has a bigger community plus an IDE that runs on
Firefox and allows rapid test prototyping. It allows running tests in
parallel and supports several programming languages.
Buster.JS is in beta with big promises for the future. We need to write
tests in Javascript.
That's pretty much what I know about them.
We want to test the functionality of our online shop so it doesn't break
between releases (both back-end and front-end). What test frame work do
you recommend and why?
Wednesday, 28 August 2013
Why this select query to Oracle database doesn't work?
Why this select query to Oracle database doesn't work?
First I tested simple cases:
cmd.Parameters.Add(new OracleParameter(":paramCode",
OracleDbType.NVarchar2)).Value = userCode;
cmd.CommandText = "SELECT * FROM VIEWUSERDATA WHERE Codigo = :paramCode";
cmd.CommandType = System.Data.CommandType.Text;
OracleDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
//Works, retrieve data
}
Another:
cmd.Parameters.Add(new OracleParameter(":paramRole",
OracleDbType.NVarchar2)).Value = userRole;
cmd.CommandText = "SELECT * FROM VIEWUSERDATA WHERE Role = :paramRole";
...
while (reader.Read())
{
//Also works
}
But when join, doesn't work.
cmd.Parameters.Add(new OracleParameter(":paramCode",
OracleDbType.NVarchar2)).Value = userCode;
cmd.Parameters.Add(new OracleParameter(":paramRole",
OracleDbType.NVarchar2)).Value = userRole;
cmd.CommandText = "SELECT * FROM VIEWUSERDATA WHERE Role = :paramRole AND
Code = :paramCode";
...
while (reader.Read())//don't retrieve anything
{
}
Data exists, If I do the query in an external query editor(window) works
fine.
Thanks.
First I tested simple cases:
cmd.Parameters.Add(new OracleParameter(":paramCode",
OracleDbType.NVarchar2)).Value = userCode;
cmd.CommandText = "SELECT * FROM VIEWUSERDATA WHERE Codigo = :paramCode";
cmd.CommandType = System.Data.CommandType.Text;
OracleDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
//Works, retrieve data
}
Another:
cmd.Parameters.Add(new OracleParameter(":paramRole",
OracleDbType.NVarchar2)).Value = userRole;
cmd.CommandText = "SELECT * FROM VIEWUSERDATA WHERE Role = :paramRole";
...
while (reader.Read())
{
//Also works
}
But when join, doesn't work.
cmd.Parameters.Add(new OracleParameter(":paramCode",
OracleDbType.NVarchar2)).Value = userCode;
cmd.Parameters.Add(new OracleParameter(":paramRole",
OracleDbType.NVarchar2)).Value = userRole;
cmd.CommandText = "SELECT * FROM VIEWUSERDATA WHERE Role = :paramRole AND
Code = :paramCode";
...
while (reader.Read())//don't retrieve anything
{
}
Data exists, If I do the query in an external query editor(window) works
fine.
Thanks.
How to "convert" processor/chipset name to /proc/cpuinfo output?
How to "convert" processor/chipset name to /proc/cpuinfo output?
I'm trying to choose a laptop and see "Chipset" and "CPU" being listed as
a codename.
Sometimes there is an article in Wikipedia about the processor or chipset
mentioning it's features, sometimes not.
How to know in advance what "cat /proc/cpuinfo" will output (i.e. what
features the processor will exactly support) without actually buying the
device?
For example, how to know in advance if hardware is capable for video
adapter pass-thought into KVM virtual machine?
I'm trying to choose a laptop and see "Chipset" and "CPU" being listed as
a codename.
Sometimes there is an article in Wikipedia about the processor or chipset
mentioning it's features, sometimes not.
How to know in advance what "cat /proc/cpuinfo" will output (i.e. what
features the processor will exactly support) without actually buying the
device?
For example, how to know in advance if hardware is capable for video
adapter pass-thought into KVM virtual machine?
My android app can download but doesnt appear in my downloaded apps
My android app can download but doesnt appear in my downloaded apps
My new android app can download from the playstore but doesn't appear in
my downloaded apps. When i download it from the play store usually there
is an option to 'open' the app aswell as 'uninstall', only the uninstall
button is visible. (http://i.imgur.com/jNTvJq2.png notice the missing open
button)
here's the my manifest, there were no errors during all the tests i ran.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jackattackapps.bigl"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/iconimage"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
<activity
android:name="com.jackattackapps.bigl.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.jackattackapps.bigl.Splashscreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SPLASHSCREEN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
And this is the activity that is supposed to load on the start of the
application.
package com.jackattackapps.bigl;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splashscreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
Thread timer = new Thread(){
public void run(){
try{
MediaPlayer ourSong =
MediaPlayer.create(Splashscreen.this, R.raw.splashsound);
ourSong.start();
sleep(2300);
}
catch (InterruptedException e){
e.printStackTrace();
} finally {
Intent openMainActivity = new
Intent("android.intent.action.MAINACTIVITY");
startActivity(openMainActivity);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
if more information is needed just comment, help would be appreciated
greatly.
My new android app can download from the playstore but doesn't appear in
my downloaded apps. When i download it from the play store usually there
is an option to 'open' the app aswell as 'uninstall', only the uninstall
button is visible. (http://i.imgur.com/jNTvJq2.png notice the missing open
button)
here's the my manifest, there were no errors during all the tests i ran.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jackattackapps.bigl"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/iconimage"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
<activity
android:name="com.jackattackapps.bigl.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.jackattackapps.bigl.Splashscreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SPLASHSCREEN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
And this is the activity that is supposed to load on the start of the
application.
package com.jackattackapps.bigl;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splashscreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
Thread timer = new Thread(){
public void run(){
try{
MediaPlayer ourSong =
MediaPlayer.create(Splashscreen.this, R.raw.splashsound);
ourSong.start();
sleep(2300);
}
catch (InterruptedException e){
e.printStackTrace();
} finally {
Intent openMainActivity = new
Intent("android.intent.action.MAINACTIVITY");
startActivity(openMainActivity);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
if more information is needed just comment, help would be appreciated
greatly.
Fresh install of Windows keeps freezing
Fresh install of Windows keeps freezing
I got a computer from a friend who said he got some viruses and that he
didn't have the time to fix it. I decided to just reformat and do a fresh
install. Windows 7 installed fine but after booting in, it would freeze
every twenty minutes or so and I would have to reboot.
I thought maybe I messed up installing something so I reinstalled it.
Still froze. I put in a Debian LiveCD I had lying around and that worked
fine. Booted back into Win7, but safe mode this time, and that worked fine
as well.
Any ideas?
I got a computer from a friend who said he got some viruses and that he
didn't have the time to fix it. I decided to just reformat and do a fresh
install. Windows 7 installed fine but after booting in, it would freeze
every twenty minutes or so and I would have to reboot.
I thought maybe I messed up installing something so I reinstalled it.
Still froze. I put in a Debian LiveCD I had lying around and that worked
fine. Booted back into Win7, but safe mode this time, and that worked fine
as well.
Any ideas?
Selecting only top result from two table query
Selecting only top result from two table query
Here are my two tables:
Songs:
+--------+---------------------+
| SongID | SongDeviceID |
+--------+---------------------+
| 3278 | 1079287588763212246 |
| 3279 | 1079287588763212221 |
| 3280 | 1079287588763212230 |
+--------+---------------------+
Votes:
+--------+--------+
| SongID | UserID |
+--------+--------+
| 3278 | 71 |
| 3278 | 72 |
| 3279 | 71 |
+--------+--------+
I am trying to count the number of entries in the votes table (for each
unique SongID and return the SongDeviceID of the entry with the most.
This is what I have so far:
SELECT SongID,COUNT(*) from votes GROUP BY SongID order by count(*) DESC
Which returns:
+--------+----------+
| SongID | Count(*) |
+--------+----------+
| 3278 | 2 |
| 3279 | 1 |
+--------+----------+
How to return only the first , the highest?
How to return the SongDeviceID from the song table opposed to the SongID?
Here are my two tables:
Songs:
+--------+---------------------+
| SongID | SongDeviceID |
+--------+---------------------+
| 3278 | 1079287588763212246 |
| 3279 | 1079287588763212221 |
| 3280 | 1079287588763212230 |
+--------+---------------------+
Votes:
+--------+--------+
| SongID | UserID |
+--------+--------+
| 3278 | 71 |
| 3278 | 72 |
| 3279 | 71 |
+--------+--------+
I am trying to count the number of entries in the votes table (for each
unique SongID and return the SongDeviceID of the entry with the most.
This is what I have so far:
SELECT SongID,COUNT(*) from votes GROUP BY SongID order by count(*) DESC
Which returns:
+--------+----------+
| SongID | Count(*) |
+--------+----------+
| 3278 | 2 |
| 3279 | 1 |
+--------+----------+
How to return only the first , the highest?
How to return the SongDeviceID from the song table opposed to the SongID?
Tuesday, 27 August 2013
Can't write image file on actual server
Can't write image file on actual server
I'm working with android and try to create an app that able to upload
several image to the server. I had tried to upload the image to my
localhost using xampp, it works well. But when I try to upload to my
enterprise server I can't find my file, in the other word. The file can't
be written. I don't know what make it failed? This is my code
Upload tp XAMPP
Connection string private static final String url_photo =
"http://192.168.7.110/blabla/base.php";
Path static final String path =
"C:\\xampp\\htdocs\\psn_asset_oracle\\Images\\";
Upload to actual enterprise server
Connection String private static final String url_photo =
"http://192.168.4.27/oracle/logam/am/data_images/android_image/base.php";
Path static final String path =
"http://192.168.4.27/oracle/logam/am/data_images/android_image/";
My code to upload to server
params_p.add(new BasicNameValuePair("image_name_1",
image_name_1));
params_p.add(new BasicNameValuePair("image_name_2",
image_name_2));
params_p.add(new BasicNameValuePair("image_name_3",
image_name_3));
params_p.add(new BasicNameValuePair("image_name_4",
image_name_4));
json_photo = jsonParser.makeHttpRequest(url_photo, "POST", params_p);
ArrayList<NameValuePair> params_p = new ArrayList<NameValuePair>();
PHP code
if(isset($_POST["image_name_1"]) && isset($_POST["image_name_2"]) &&
isset($_POST["image_name_3"]) && isset($_POST["image_name_4"])
&& isset($_POST["image_1"]) && isset($_POST["image_2"]) &&
isset($_POST["image_3"]) && isset($_POST["image_4"]))
{
$image_name_1 = $_POST["image_name_1"];
$image_name_2 = $_POST["image_name_2"];
$image_name_3 = $_POST["image_name_3"];
$image_name_4 = $_POST["image_name_4"];
$image_1 = $_POST["image_1"];
$image_2 = $_POST["image_2"];
$image_3 = $_POST["image_3"];
$image_4 = $_POST["image_4"];
/*---------base64 decoding utf-8 string-----------*/
$binary_1=base64_decode($image_1);
$binary_2=base64_decode($image_2);
$binary_3=base64_decode($image_3);
$binary_4=base64_decode($image_4);
/*-----------set binary, utf-8 bytes----------*/
header('Content-Type: bitmap; charset=utf-8');
/*---------------open specified directory and put image on
it------------------*/
$file_1 = fopen($image_name_1, 'wb');
$file_2 = fopen($image_name_2, 'wb');
$file_3 = fopen($image_name_3, 'wb');
$file_4 = fopen($image_name_4, 'wb');
/*---------------------assign image to file
system-----------------------------*/
fwrite($file_1, $binary_1);
fclose($file_1);
fwrite($file_2, $binary_2);
fclose($file_2);
fwrite($file_3, $binary_3);
fclose($file_3);
fwrite($file_4, $binary_4);
fclose($file_4);
$response["message"] = "Success";
echo json_encode($response);
}
I've contact my DBA and asked to give me permission to write the file, and
it still doesn't work. The error is json doesn't give "Success" as message
that indicate the file failed to be written. I will appreciate any help.
Thank you.
I'm working with android and try to create an app that able to upload
several image to the server. I had tried to upload the image to my
localhost using xampp, it works well. But when I try to upload to my
enterprise server I can't find my file, in the other word. The file can't
be written. I don't know what make it failed? This is my code
Upload tp XAMPP
Connection string private static final String url_photo =
"http://192.168.7.110/blabla/base.php";
Path static final String path =
"C:\\xampp\\htdocs\\psn_asset_oracle\\Images\\";
Upload to actual enterprise server
Connection String private static final String url_photo =
"http://192.168.4.27/oracle/logam/am/data_images/android_image/base.php";
Path static final String path =
"http://192.168.4.27/oracle/logam/am/data_images/android_image/";
My code to upload to server
params_p.add(new BasicNameValuePair("image_name_1",
image_name_1));
params_p.add(new BasicNameValuePair("image_name_2",
image_name_2));
params_p.add(new BasicNameValuePair("image_name_3",
image_name_3));
params_p.add(new BasicNameValuePair("image_name_4",
image_name_4));
json_photo = jsonParser.makeHttpRequest(url_photo, "POST", params_p);
ArrayList<NameValuePair> params_p = new ArrayList<NameValuePair>();
PHP code
if(isset($_POST["image_name_1"]) && isset($_POST["image_name_2"]) &&
isset($_POST["image_name_3"]) && isset($_POST["image_name_4"])
&& isset($_POST["image_1"]) && isset($_POST["image_2"]) &&
isset($_POST["image_3"]) && isset($_POST["image_4"]))
{
$image_name_1 = $_POST["image_name_1"];
$image_name_2 = $_POST["image_name_2"];
$image_name_3 = $_POST["image_name_3"];
$image_name_4 = $_POST["image_name_4"];
$image_1 = $_POST["image_1"];
$image_2 = $_POST["image_2"];
$image_3 = $_POST["image_3"];
$image_4 = $_POST["image_4"];
/*---------base64 decoding utf-8 string-----------*/
$binary_1=base64_decode($image_1);
$binary_2=base64_decode($image_2);
$binary_3=base64_decode($image_3);
$binary_4=base64_decode($image_4);
/*-----------set binary, utf-8 bytes----------*/
header('Content-Type: bitmap; charset=utf-8');
/*---------------open specified directory and put image on
it------------------*/
$file_1 = fopen($image_name_1, 'wb');
$file_2 = fopen($image_name_2, 'wb');
$file_3 = fopen($image_name_3, 'wb');
$file_4 = fopen($image_name_4, 'wb');
/*---------------------assign image to file
system-----------------------------*/
fwrite($file_1, $binary_1);
fclose($file_1);
fwrite($file_2, $binary_2);
fclose($file_2);
fwrite($file_3, $binary_3);
fclose($file_3);
fwrite($file_4, $binary_4);
fclose($file_4);
$response["message"] = "Success";
echo json_encode($response);
}
I've contact my DBA and asked to give me permission to write the file, and
it still doesn't work. The error is json doesn't give "Success" as message
that indicate the file failed to be written. I will appreciate any help.
Thank you.
create sql table in SQLServer with the name of the current session variable c#
create sql table in SQLServer with the name of the current session
variable c#
I am developing an application in c #. Net and I need to create a table in
sql with the name of the current session variable. How I can send the
value of the session variable to current sql server to create this query?
My idea is something like this: In sql server:
CREATE TABLE Customer_ + 'current user name' // current session variable
in c#
(First_Name char(50),
Last_Name char(50),
Address char(50),
City char(50),
Country char(25),
Birth_Date datetime);
Thank you very much for your help.
variable c#
I am developing an application in c #. Net and I need to create a table in
sql with the name of the current session variable. How I can send the
value of the session variable to current sql server to create this query?
My idea is something like this: In sql server:
CREATE TABLE Customer_ + 'current user name' // current session variable
in c#
(First_Name char(50),
Last_Name char(50),
Address char(50),
City char(50),
Country char(25),
Birth_Date datetime);
Thank you very much for your help.
Kendo UI Sparkline - Datasource/Series/Categories
Kendo UI Sparkline - Datasource/Series/Categories
I have a Kendo UI Sparkline now that I am populating from my model with
the following:
@(Html.Kendo().Sparkline()
.Name("jph-graph")
.Theme("black")
.Type(SparklineType.Column)
.Tooltip(tooltip => tooltip.Format("{0:n2}"))
.Data(Model.jphList.Select(g => g.value).ToList())
)
The Sparkline populates properly with that.
I want to add a category so that I can include that value in my ToolTip.
All I could find were references to using the category, so I started
trying to use .DataSource so I could implement that. Now I can't even get
the Sparkline to populate with the defined Datasource and Series, much
less get the Category working. Here is the code that I have that does NOT
populate the Sparkline.
@(Html.Kendo().Sparkline()
.Name("jph-graph")
.Theme("black")
.Type(SparklineType.Column)
.Tooltip(tooltip => tooltip.Format("{0:n2}"))
.DataSource(ds => Model.jphList.Select(g => new { date =
g.production_date, value = g.value }).ToList())
.Series(series => series.Column("value"))
)
Any help would be appreciated.
I have a Kendo UI Sparkline now that I am populating from my model with
the following:
@(Html.Kendo().Sparkline()
.Name("jph-graph")
.Theme("black")
.Type(SparklineType.Column)
.Tooltip(tooltip => tooltip.Format("{0:n2}"))
.Data(Model.jphList.Select(g => g.value).ToList())
)
The Sparkline populates properly with that.
I want to add a category so that I can include that value in my ToolTip.
All I could find were references to using the category, so I started
trying to use .DataSource so I could implement that. Now I can't even get
the Sparkline to populate with the defined Datasource and Series, much
less get the Category working. Here is the code that I have that does NOT
populate the Sparkline.
@(Html.Kendo().Sparkline()
.Name("jph-graph")
.Theme("black")
.Type(SparklineType.Column)
.Tooltip(tooltip => tooltip.Format("{0:n2}"))
.DataSource(ds => Model.jphList.Select(g => new { date =
g.production_date, value = g.value }).ToList())
.Series(series => series.Column("value"))
)
Any help would be appreciated.
Delphi QuickReports: Master/ Detail report
Delphi QuickReports: Master/ Detail report
I need to create a QuickReport in Delphi xe that is laid out as:
+================ | Report Header +================
+=================Master (DataSource = Subject Table --Primary key:
SubjectID)======================== | Detail Band (Single Record, repeats)
. +=================Detail (DataSource = Teachers
Table)======================== | Child band (Auto-stretching) .
+======================================
+============================= | Report Footer (fixed size)
+=============================
Can anyone help me and give me a small example or expalin me how to do this.
I need to create a QuickReport in Delphi xe that is laid out as:
+================ | Report Header +================
+=================Master (DataSource = Subject Table --Primary key:
SubjectID)======================== | Detail Band (Single Record, repeats)
. +=================Detail (DataSource = Teachers
Table)======================== | Child band (Auto-stretching) .
+======================================
+============================= | Report Footer (fixed size)
+=============================
Can anyone help me and give me a small example or expalin me how to do this.
Finding comments in a string
Finding comments in a string
I have file which has comments at the top.
e.g.
/**
* Comments for file.
*
*/
Using PHP, I read content of file using file_get_contents into variable
now I want to get value present inside comment. For above example expected
result would be
* Comments for file
*
*
Which means I want content inside those /** and */. This file can have
multiple comments but I want the very first which is at the top of file.
Any ideas/help please ?
I have file which has comments at the top.
e.g.
/**
* Comments for file.
*
*/
Using PHP, I read content of file using file_get_contents into variable
now I want to get value present inside comment. For above example expected
result would be
* Comments for file
*
*
Which means I want content inside those /** and */. This file can have
multiple comments but I want the very first which is at the top of file.
Any ideas/help please ?
Windows 7 keyboard input hangs while reading from usb hard drive
Windows 7 keyboard input hangs while reading from usb hard drive
There is a strange behavior of windows 7. I like to listen to music while
coding (surprising), so I always carry with me my usb storage and play
music from it. Sometimes while playing a song it kind of "hangs" (guess
loads the buffer). What is strange that my mouse keeps working, but any
input that I type is not appearing until it "releases". Why does it
happens? Why it doesn't receive IO from keyboard but does receive mouse?
Why does the system hang at all, shouldn't interrupts handle this?
There is a strange behavior of windows 7. I like to listen to music while
coding (surprising), so I always carry with me my usb storage and play
music from it. Sometimes while playing a song it kind of "hangs" (guess
loads the buffer). What is strange that my mouse keeps working, but any
input that I type is not appearing until it "releases". Why does it
happens? Why it doesn't receive IO from keyboard but does receive mouse?
Why does the system hang at all, shouldn't interrupts handle this?
how to understand "Classes must be defined before they are used " in php manual of keyword "extends"
how to understand "Classes must be defined before they are used " in php
manual of keyword "extends"
I get to php file a.php
<?php
class A extends B {}
class B{}
php a.php
>>>no error
b.php
<?php
class A extends B {}
class B extends C {}
class C{}
php b.php
>>>>Fatal error: Class 'B' not found in t1.php on line 2
according to php.net manual
>>>>Classes must be defined before they are used! If you want the class
Named_Cart to extend the class Cart, you will have to define the class
Cart first. If you want to create another class called
Yellow_named_cart based on the class Named_Cart you have to define
Named_Cart first. To make it short: the order in which the classes are
defined is important.<<<<
so anyboy pls explain why a.php get no "Fatal Error".
manual of keyword "extends"
I get to php file a.php
<?php
class A extends B {}
class B{}
php a.php
>>>no error
b.php
<?php
class A extends B {}
class B extends C {}
class C{}
php b.php
>>>>Fatal error: Class 'B' not found in t1.php on line 2
according to php.net manual
>>>>Classes must be defined before they are used! If you want the class
Named_Cart to extend the class Cart, you will have to define the class
Cart first. If you want to create another class called
Yellow_named_cart based on the class Named_Cart you have to define
Named_Cart first. To make it short: the order in which the classes are
defined is important.<<<<
so anyboy pls explain why a.php get no "Fatal Error".
Monday, 26 August 2013
How to select random subset of cases in SPSS based on student number?
How to select random subset of cases in SPSS based on student number?
I am setting some student assignments where most students will be using
SPSS. In order to encourage students to do their own work, I want students
to have a partially unique dataset. Thus, I'd like to get each to the open
the master data file, and then get the student to run a couple of lines of
syntax that produces a unique data file. In pseudo code, I'd like to do
something like the following where 12345551234 is a student number:
set random number generator = 12345551234
select 90% random subset ofcases and drop the rest.
What is simple SPSS syntax dropping a subset of cases from the data file?
I am setting some student assignments where most students will be using
SPSS. In order to encourage students to do their own work, I want students
to have a partially unique dataset. Thus, I'd like to get each to the open
the master data file, and then get the student to run a couple of lines of
syntax that produces a unique data file. In pseudo code, I'd like to do
something like the following where 12345551234 is a student number:
set random number generator = 12345551234
select 90% random subset ofcases and drop the rest.
What is simple SPSS syntax dropping a subset of cases from the data file?
running lithium quickstart with mongodb
running lithium quickstart with mongodb
As a newbie, I followed this link:
http://www.blakeerickson.com/posts/2013/04/07/how_to_correctly_configure_ubuntu_to_run_lithium_php
and this link:
http://lithify.me/docs/manual/quickstart
to install and run the Lithium tutorial. Everything is OK until the
MongoDB accessing. I got the following:
Deprecated: Mongo::__construct(): The 'timeout' option is deprecated.
Please use 'connectTimeoutMS' instead in
/home/takpo/www/my_app/libraries/lithium/data/source/MongoDb.php on line
261
Quickstart Manual API More
⟁
© Union Of RAD 2013
message and the form items are not seen. Could someone help?
Thanks,
Tak
As a newbie, I followed this link:
http://www.blakeerickson.com/posts/2013/04/07/how_to_correctly_configure_ubuntu_to_run_lithium_php
and this link:
http://lithify.me/docs/manual/quickstart
to install and run the Lithium tutorial. Everything is OK until the
MongoDB accessing. I got the following:
Deprecated: Mongo::__construct(): The 'timeout' option is deprecated.
Please use 'connectTimeoutMS' instead in
/home/takpo/www/my_app/libraries/lithium/data/source/MongoDb.php on line
261
Quickstart Manual API More
⟁
© Union Of RAD 2013
message and the form items are not seen. Could someone help?
Thanks,
Tak
How to rename database in Heroku?
How to rename database in Heroku?
I've created a new database in Heroku, showing in my dashboard; when I go
to settings, it does not allow me to rename, stating 'Internal Server
Error'. What can I do to rename my database?
I've created a new database in Heroku, showing in my dashboard; when I go
to settings, it does not allow me to rename, stating 'Internal Server
Error'. What can I do to rename my database?
Java Program that accepts input and meanwhile runs a timer
Java Program that accepts input and meanwhile runs a timer
I want to make a small java program that does the following: When it
starts running, a timer of 00:00 starts as well at the same time. Then,
the program asks the user for a user input (only "*" can be given) and
when it's inserted, it prints the very next number that has 0 in its last
digit of the timer. Example: program runs, timer as well, user gives *,
meanwhile, before it is inserted (by enter), timer continues to run and
when it is inserted, the timer is at 00:35 for example, and at 00:40 it
prints 00:40. Continues to run.. is at 01:32, gets insert, prints 01:40 at
that time, etc. Kinda confusing huh? :)
I don't know how to accomplish this, what should I read? Thanks a lot
I want to make a small java program that does the following: When it
starts running, a timer of 00:00 starts as well at the same time. Then,
the program asks the user for a user input (only "*" can be given) and
when it's inserted, it prints the very next number that has 0 in its last
digit of the timer. Example: program runs, timer as well, user gives *,
meanwhile, before it is inserted (by enter), timer continues to run and
when it is inserted, the timer is at 00:35 for example, and at 00:40 it
prints 00:40. Continues to run.. is at 01:32, gets insert, prints 01:40 at
that time, etc. Kinda confusing huh? :)
I don't know how to accomplish this, what should I read? Thanks a lot
IOS chat realtime
IOS chat realtime
I want to create an IOS app that uses realtime chat. I have done thorough
research and I came across parse, PubNub, QuickBox and read up on XMPP. I
decided I would open up the question on here. What would be the best
approach for creating an app, were the user can communicate individually
with other users who also use the application.
Thanks
I want to create an IOS app that uses realtime chat. I have done thorough
research and I came across parse, PubNub, QuickBox and read up on XMPP. I
decided I would open up the question on here. What would be the best
approach for creating an app, were the user can communicate individually
with other users who also use the application.
Thanks
Core Plot : Is a sliced (little split from the rest) like pie chart possible?
Core Plot : Is a sliced (little split from the rest) like pie chart possible?
Am using core plot to draw graphs in an iOS App. can we draw such a pie
chart (where the orange slice seems to be a bit away from the rest of the
pie) with core plot?
Any help please?
Am using core plot to draw graphs in an iOS App. can we draw such a pie
chart (where the orange slice seems to be a bit away from the rest of the
pie) with core plot?
Any help please?
Meaning of "." in printf
Meaning of "." in printf
I was just reading the classic K&R and encountered the following syntax:
printf("%.*s",max,s);
What is the meaning of "." here?When I don't apply a "." here,then whole
string is printed,but when we don't apply a "." ,atmost max characters are
printed.I will be really thankful if anyone could explain this.
I was just reading the classic K&R and encountered the following syntax:
printf("%.*s",max,s);
What is the meaning of "." here?When I don't apply a "." here,then whole
string is printed,but when we don't apply a "." ,atmost max characters are
printed.I will be really thankful if anyone could explain this.
Unable Facebook comment unless liked
Unable Facebook comment unless liked
I want to use facebook comment box on my Wordpress website and what i am
trying to do is if a user didn't like the facebook page whey wont be able
send a comment.
That means if the user (signed in Facebook) not liked the Facebook page
they wont see facebook comment box.
I hope it's clear.
I want to use facebook comment box on my Wordpress website and what i am
trying to do is if a user didn't like the facebook page whey wont be able
send a comment.
That means if the user (signed in Facebook) not liked the Facebook page
they wont see facebook comment box.
I hope it's clear.
Issue in getting the complete address from lat and long in android device
Issue in getting the complete address from lat and long in android device
I am using the below code and getting the null value in addresses .Code is
as follows:-
Geocoder geocoder;
List<Address> addresses;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
geocoder = new Geocoder(this, Locale.getDefault());
try {
addresses = geocoder.getFromLocation(28.5202154,77.2006815, 1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String address = addresses.get(0).getAddressLine(0);
String city = addresses.get(0).getAddressLine(1);
String country = addresses.get(0).getAddressLine(2);
Toast.makeText(
MainActivity.this,""+address+" "+city+" "+country,
Toast.LENGTH_LONG).show();
}
when I debug the code, it gives an exception which is caught in catch
block is Service not available and when i run the same code in other
device it excutes normally and gives the complete address as required.
Guys please try to solve this issue.Thanks in advance!!
I am using the below code and getting the null value in addresses .Code is
as follows:-
Geocoder geocoder;
List<Address> addresses;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
geocoder = new Geocoder(this, Locale.getDefault());
try {
addresses = geocoder.getFromLocation(28.5202154,77.2006815, 1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String address = addresses.get(0).getAddressLine(0);
String city = addresses.get(0).getAddressLine(1);
String country = addresses.get(0).getAddressLine(2);
Toast.makeText(
MainActivity.this,""+address+" "+city+" "+country,
Toast.LENGTH_LONG).show();
}
when I debug the code, it gives an exception which is caught in catch
block is Service not available and when i run the same code in other
device it excutes normally and gives the complete address as required.
Guys please try to solve this issue.Thanks in advance!!
Find out what's holding a lock on a file with WinAPIs
Find out what's holding a lock on a file with WinAPIs
At times when I'm trying to delete an exe file for one of my processes I
get the following error from GetLastError:
Error: 32
The process cannot access the file because it is being used by another
process.
Is there a way to find out what's holding a lock on that file using C++
and WinAPIs?
At times when I'm trying to delete an exe file for one of my processes I
get the following error from GetLastError:
Error: 32
The process cannot access the file because it is being used by another
process.
Is there a way to find out what's holding a lock on that file using C++
and WinAPIs?
Sunday, 25 August 2013
Android-KSOAP Java.IO.IOException error
Android-KSOAP Java.IO.IOException error
Please refer to the attached screenshots. I'm new in Android and was
trying my hands on accessing web-service from Android. The ws is in .net.
I tried the code for accessing ws using KSOAP (the same code available in
this website at many qa). But I'm getting error at the final step of
calling the ws, i.e. androidHttpTransport.call(SOAP_ACTION, envelope);
step. Please help me to understand what might have caused this. Let me
know if you need any more details.
![Error Screenshot 1]: http://i.imgur.com/q4BCAib.jpg ![Error Screenshot
2]: http://i.imgur.com/tos3BEP.jpg
Please refer to the attached screenshots. I'm new in Android and was
trying my hands on accessing web-service from Android. The ws is in .net.
I tried the code for accessing ws using KSOAP (the same code available in
this website at many qa). But I'm getting error at the final step of
calling the ws, i.e. androidHttpTransport.call(SOAP_ACTION, envelope);
step. Please help me to understand what might have caused this. Let me
know if you need any more details.
![Error Screenshot 1]: http://i.imgur.com/q4BCAib.jpg ![Error Screenshot
2]: http://i.imgur.com/tos3BEP.jpg
bumblebee + wine + directx9 not working
bumblebee + wine + directx9 not working
I'm trying to run dxdiag or any other DX9 game from bumblebee+wine and no
luck. These games works well without bumblebee in integrated graphic card.
And no wine soft works well with bumblebee.
primusrun
$ primusrun bash
$ wine dxdiag
primus: warning: recreating incompatible pbuffer
primus: warning: recreating incompatible pbuffer
$
syslog output:
rtkit-daemon[2489]: Successfully made thread 23036 of process 23036 (n/a)
owned by '1000' RT at priority 3.
rtkit-daemon[2489]: Supervising 1 threads of 1 processes of 1 users.
kernel: [147774.078061] bbswitch: enabling discrete graphics
kernel: [147774.221739] pci 0000:01:00.0: power state changed by ACPI to D0
kernel: [147774.245670] vgaarb: device changed decodes:
PCI:0000:01:00.0,olddecodes=none,decodes=none:owns=none
kernel: [147774.245900] NVRM: loading NVIDIA UNIX x86_64 Kernel Module
304.88 Wed Mar 27 14:26:46 PDT 2013
acpid: client 23009[0:1002] has disconnected
acpid: client 23009[0:1002] has disconnected
acpid: client connected from 23066[0:1002]
acpid: 1 client rule loaded
acpid: client connected from 23066[0:1002]
acpid: 1 client rule loaded
bumblebeed[11391]: [XORG] (WW) NVIDIA(0): Unable to get display device for
DPI computation.
rtkit-daemon[2489]: Successfully made thread 23071 of process 23033 (n/a)
owned by '1000' RT at priority 2.
rtkit-daemon[2489]: Supervising 2 threads of 2 processes of 1 users.
kernel: [147778.018119] bbswitch: disabling discrete graphics
kernel: [147778.030858] pci 0000:01:00.0: Refused to change power state,
currently in D0
kernel: [147778.030896] pci 0000:01:00.0: power state changed by ACPI to
D3cold
optirun has similar result:
$ optirun bash
$ wine dxdiag
[VGL] NOTICE: Pixel format of 2D X server does not match pixel format of
[VGL] Pbuffer. Disabling PBO readback.
$
The syslog has the same error with optirun:
bumblebeed[11391]: [XORG] (WW) NVIDIA(0): Unable to get display device for
DPI computation.
Any help? thank you!
I'm trying to run dxdiag or any other DX9 game from bumblebee+wine and no
luck. These games works well without bumblebee in integrated graphic card.
And no wine soft works well with bumblebee.
primusrun
$ primusrun bash
$ wine dxdiag
primus: warning: recreating incompatible pbuffer
primus: warning: recreating incompatible pbuffer
$
syslog output:
rtkit-daemon[2489]: Successfully made thread 23036 of process 23036 (n/a)
owned by '1000' RT at priority 3.
rtkit-daemon[2489]: Supervising 1 threads of 1 processes of 1 users.
kernel: [147774.078061] bbswitch: enabling discrete graphics
kernel: [147774.221739] pci 0000:01:00.0: power state changed by ACPI to D0
kernel: [147774.245670] vgaarb: device changed decodes:
PCI:0000:01:00.0,olddecodes=none,decodes=none:owns=none
kernel: [147774.245900] NVRM: loading NVIDIA UNIX x86_64 Kernel Module
304.88 Wed Mar 27 14:26:46 PDT 2013
acpid: client 23009[0:1002] has disconnected
acpid: client 23009[0:1002] has disconnected
acpid: client connected from 23066[0:1002]
acpid: 1 client rule loaded
acpid: client connected from 23066[0:1002]
acpid: 1 client rule loaded
bumblebeed[11391]: [XORG] (WW) NVIDIA(0): Unable to get display device for
DPI computation.
rtkit-daemon[2489]: Successfully made thread 23071 of process 23033 (n/a)
owned by '1000' RT at priority 2.
rtkit-daemon[2489]: Supervising 2 threads of 2 processes of 1 users.
kernel: [147778.018119] bbswitch: disabling discrete graphics
kernel: [147778.030858] pci 0000:01:00.0: Refused to change power state,
currently in D0
kernel: [147778.030896] pci 0000:01:00.0: power state changed by ACPI to
D3cold
optirun has similar result:
$ optirun bash
$ wine dxdiag
[VGL] NOTICE: Pixel format of 2D X server does not match pixel format of
[VGL] Pbuffer. Disabling PBO readback.
$
The syslog has the same error with optirun:
bumblebeed[11391]: [XORG] (WW) NVIDIA(0): Unable to get display device for
DPI computation.
Any help? thank you!
Store hash password and encrypted data with this password in db? [migrated]
Store hash password and encrypted data with this password in db? [migrated]
I'm currently developping a django application.
I need to store user data. This data must be unavailable to any other user
or admin
I've created a dedicated user account system (no using dj auth). (Maybe I
could modified it, but this is not the subject here..)
User password is hashed with passlib.
User data is encrypted using AES and user password (not hashed :p) as
secret key.
I'm wondering :
Is it safe to keep hashed password and encrypted data, when encryption
used this password as secret key ?
What can I do with AES IV used to crypt user data ? Generate it when I
create the user and keep it in user table, next to hashed password ?
I'm currently developping a django application.
I need to store user data. This data must be unavailable to any other user
or admin
I've created a dedicated user account system (no using dj auth). (Maybe I
could modified it, but this is not the subject here..)
User password is hashed with passlib.
User data is encrypted using AES and user password (not hashed :p) as
secret key.
I'm wondering :
Is it safe to keep hashed password and encrypted data, when encryption
used this password as secret key ?
What can I do with AES IV used to crypt user data ? Generate it when I
create the user and keep it in user table, next to hashed password ?
jquery is unable to set the prettyCheckable radio button programmatically
jquery is unable to set the prettyCheckable radio button programmatically
on button click i tried all the things. but nithing works. please help
$('#rdTypeAdd').buttonset();
$('[name="rdTypeAdd"][value="+"]').prop("checked", true);
$('#rdTypeAdd').buttonset("refresh");
//$('[name="rdTypeAdd"][value="+"]').attr("checked", true);
//$('[name="rdTypeAdd"][value="+"]').prop("checked",
true).trigger("change");
//($('.rdTypeAdd').prop('checked',true));
on button click i tried all the things. but nithing works. please help
$('#rdTypeAdd').buttonset();
$('[name="rdTypeAdd"][value="+"]').prop("checked", true);
$('#rdTypeAdd').buttonset("refresh");
//$('[name="rdTypeAdd"][value="+"]').attr("checked", true);
//$('[name="rdTypeAdd"][value="+"]').prop("checked",
true).trigger("change");
//($('.rdTypeAdd').prop('checked',true));
Saturday, 24 August 2013
Invalid URI error with MongoDB connection string but only when run on Azure? (ASP.NET Web Role)
Invalid URI error with MongoDB connection string but only when run on
Azure? (ASP.NET Web Role)
I have an ASP.NET MVC Web Role that communicates with a remote server
running MongoDB. The connection string has the credentials in it. When I
run the the MVC Web Role on localhost it works fine. However, when I
publish the MVC Web Role to Azure and run it I get the following
error/stack trace:
Invalid URI: There is an invalid sequence in the string.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.UriFormatException:
Invalid URI: There is an invalid sequence in the string.
Source Error:
An unhandled exception was generated during the execution of the current
web request.
Information regarding the origin and location of the exception can be
identified using
the exception stack trace below.
Stack Trace:
[UriFormatException: Invalid URI: There is an invalid sequence in the
string.]
System.Uri.UnescapeString(Char* pStr, Int32 start, Int32 end, Char[]
dest, Int32& destPosition, Char rsvd1, Char rsvd2, Char rsvd3,
UnescapeMode unescapeMode, UriParser syntax, Boolean isQuery, Boolean
readOnlyConfig) +618
System.Uri.UnescapeDataString(String stringToUnescape) +280
MongoDB.Driver.MongoUrlBuilder.Parse(String url) +237
MongoDB.Driver.MongoUrl..ctor(String url) +47
MongoDB.Driver.MongoUrl.Create(String url) +121
MongoDB.Driver.MongoServer.Create(String connectionString) +54
MongoDatabaseWrapper.get_Database() +30
Why would the UnescapeString() method or this stack of calls behave
differently if the code is running on my local PC versus on Azure?
Azure? (ASP.NET Web Role)
I have an ASP.NET MVC Web Role that communicates with a remote server
running MongoDB. The connection string has the credentials in it. When I
run the the MVC Web Role on localhost it works fine. However, when I
publish the MVC Web Role to Azure and run it I get the following
error/stack trace:
Invalid URI: There is an invalid sequence in the string.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.UriFormatException:
Invalid URI: There is an invalid sequence in the string.
Source Error:
An unhandled exception was generated during the execution of the current
web request.
Information regarding the origin and location of the exception can be
identified using
the exception stack trace below.
Stack Trace:
[UriFormatException: Invalid URI: There is an invalid sequence in the
string.]
System.Uri.UnescapeString(Char* pStr, Int32 start, Int32 end, Char[]
dest, Int32& destPosition, Char rsvd1, Char rsvd2, Char rsvd3,
UnescapeMode unescapeMode, UriParser syntax, Boolean isQuery, Boolean
readOnlyConfig) +618
System.Uri.UnescapeDataString(String stringToUnescape) +280
MongoDB.Driver.MongoUrlBuilder.Parse(String url) +237
MongoDB.Driver.MongoUrl..ctor(String url) +47
MongoDB.Driver.MongoUrl.Create(String url) +121
MongoDB.Driver.MongoServer.Create(String connectionString) +54
MongoDatabaseWrapper.get_Database() +30
Why would the UnescapeString() method or this stack of calls behave
differently if the code is running on my local PC versus on Azure?
Continuing a "stopped" iCloud restore on iOS
Continuing a "stopped" iCloud restore on iOS
I was restoring my iPhone 5 to the latest iOS and chose restore via
iCloud. The restore process - especially for apps - was frustratingly slow
and actually stopped frozen after a while.
After trying several other options, I finally "Cancelled" the iCloud
Restore operation and then manually installed the apps via iTunes, as well
as synced songs, etc.
Now for some of the apps, data is missing and my Photos also appear to be
incomplete. Since I "cancelled" the iCloud Restore (and was warned about
not being able to do this again), is there any way at all I can coax
iCloud into streaming the app data back into the installed app folders, as
well as getting my photos? Would there perhaps be two separate ways of
doing that?
Or is the only other option to "Erase Content and Settings" and do the
restore process all over again, allowing Photos to restore gradually via
iCloud, while installing apps via iTunes parallely (without "Cancelling"
the iCloud restore)?
If the answer to the last question is "Sadly, yes", then can it be assumed
that if the app is installed via iTunes anyway, iOS will proceed to
restore the app's data from iCloud? Or does the app HAVE to be installed
OTA for the data to also be restored from iCloud?
Thanks.
,Dev
I was restoring my iPhone 5 to the latest iOS and chose restore via
iCloud. The restore process - especially for apps - was frustratingly slow
and actually stopped frozen after a while.
After trying several other options, I finally "Cancelled" the iCloud
Restore operation and then manually installed the apps via iTunes, as well
as synced songs, etc.
Now for some of the apps, data is missing and my Photos also appear to be
incomplete. Since I "cancelled" the iCloud Restore (and was warned about
not being able to do this again), is there any way at all I can coax
iCloud into streaming the app data back into the installed app folders, as
well as getting my photos? Would there perhaps be two separate ways of
doing that?
Or is the only other option to "Erase Content and Settings" and do the
restore process all over again, allowing Photos to restore gradually via
iCloud, while installing apps via iTunes parallely (without "Cancelling"
the iCloud restore)?
If the answer to the last question is "Sadly, yes", then can it be assumed
that if the app is installed via iTunes anyway, iOS will proceed to
restore the app's data from iCloud? Or does the app HAVE to be installed
OTA for the data to also be restored from iCloud?
Thanks.
,Dev
PHP syntax error trying to build array within while loop with mysql resultset
PHP syntax error trying to build array within while loop with mysql resultset
Why do I get an unexpected ']' error on the $columnArray[]... line?
<?php
$con=mysqli_connect("localhost","user","password","test");
if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " .
mysqli_connect_error();}
$sql = "SELECT column_comment,column_name FROM information_schema.columns
WHERE table_name = 'mytable';
$query = mysqli_query($con,$sql) or die(mysql_error());
$columnArray = array();
$columnArray = array();
while($result = mysqli_fetch_array($query)){
$columnArray[] = array('column_comment' => $result['column_comment'],
'column_name' => $result['column_name']);
}
PHP Parse error: syntax error, unexpected ']', expecting identifier
(T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
Why do I get an unexpected ']' error on the $columnArray[]... line?
<?php
$con=mysqli_connect("localhost","user","password","test");
if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " .
mysqli_connect_error();}
$sql = "SELECT column_comment,column_name FROM information_schema.columns
WHERE table_name = 'mytable';
$query = mysqli_query($con,$sql) or die(mysql_error());
$columnArray = array();
$columnArray = array();
while($result = mysqli_fetch_array($query)){
$columnArray[] = array('column_comment' => $result['column_comment'],
'column_name' => $result['column_name']);
}
PHP Parse error: syntax error, unexpected ']', expecting identifier
(T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
Haskell tuple function composition
Haskell tuple function composition
I have started learning Haskell from Introduction to FP using Haskell by
Richard Bird, but I am stuck in proving the following:
pair (f, g) . h = pair (f . h, g . h)
The definitions of pair is the following:
pair :: (a -> b, a -> c) -> a -> (b, c)
pair (f, g) x = (f x, g x)
Could someone point me in the right direction? Please keep in mind that I
am only at the beginning. Thanks in advance!
I have started learning Haskell from Introduction to FP using Haskell by
Richard Bird, but I am stuck in proving the following:
pair (f, g) . h = pair (f . h, g . h)
The definitions of pair is the following:
pair :: (a -> b, a -> c) -> a -> (b, c)
pair (f, g) x = (f x, g x)
Could someone point me in the right direction? Please keep in mind that I
am only at the beginning. Thanks in advance!
Autocomplete div under textfield
Autocomplete div under textfield
In my site I have a text field that has to function as a autocomplete box.
I use this code:
<input type="text" class="input2" style="margin-bottom:0px;"
id="customersearchfield">
<div id="customersearchresult" style="display:none; position:absolute;
z-index:999; background:#fff; color:black; ">
CSS:
.input2{
display: inline;
margin-top: 4px;
padding: 3px;
border: 0px;
width: 200px;
}
This does not work as expected. The resultdiv is placed directly under the
textfield vertically, but not aligned horizontally. It just aligns to the
left side of the browser window.
How to get the top left corner of the resultdiv directly under the bottom
left corner of the text field so that it appears directly under the
textfield?
In my site I have a text field that has to function as a autocomplete box.
I use this code:
<input type="text" class="input2" style="margin-bottom:0px;"
id="customersearchfield">
<div id="customersearchresult" style="display:none; position:absolute;
z-index:999; background:#fff; color:black; ">
CSS:
.input2{
display: inline;
margin-top: 4px;
padding: 3px;
border: 0px;
width: 200px;
}
This does not work as expected. The resultdiv is placed directly under the
textfield vertically, but not aligned horizontally. It just aligns to the
left side of the browser window.
How to get the top left corner of the resultdiv directly under the bottom
left corner of the text field so that it appears directly under the
textfield?
eclipse isn't working after reinstalling jre and jdk
eclipse isn't working after reinstalling jre and jdk
I used eclipse for android development. today I reinstalled the jre and
jdk for a wrong reason, after that my eclipse doesn't work and says: A
java runtime environment (jre) or java development kit (jdk) is needed in
order to run eclipse... but i know that they are installed on my computer
and when i use a new eclipse it doesn't have any problems for starting but
when i changed the workspace to one which i used with my ex-eclipse, a lot
of the codes were underlined red showing they have errors. it seems that
the current sdk is not same with the older eclipse. this version is older.
what should i do? is there any way to bring my ex-eclipse working again?
I used eclipse for android development. today I reinstalled the jre and
jdk for a wrong reason, after that my eclipse doesn't work and says: A
java runtime environment (jre) or java development kit (jdk) is needed in
order to run eclipse... but i know that they are installed on my computer
and when i use a new eclipse it doesn't have any problems for starting but
when i changed the workspace to one which i used with my ex-eclipse, a lot
of the codes were underlined red showing they have errors. it seems that
the current sdk is not same with the older eclipse. this version is older.
what should i do? is there any way to bring my ex-eclipse working again?
What is the purpose of pie weights?
What is the purpose of pie weights?
Some pie recipes call for placing weights on the pastry when it is cooked
prior to the addition of fillings.
Why is this necessary? What effect does it have?
Some pie recipes call for placing weights on the pastry when it is cooked
prior to the addition of fillings.
Why is this necessary? What effect does it have?
Friday, 23 August 2013
How do I Creating Virtual Machines on an Ubuntu Server that I am running through VMPLAYER
How do I Creating Virtual Machines on an Ubuntu Server that I am running
through VMPLAYER
Downloaded ISO for the Ubuntu 12.04.03 server. Run through VMPLAYER set up
completed successfully. Now what I don't understand is how do I set up
other Virtual machines (like windows 7) on this server and keep that
virtual machine host-only. Is that possible?
through VMPLAYER
Downloaded ISO for the Ubuntu 12.04.03 server. Run through VMPLAYER set up
completed successfully. Now what I don't understand is how do I set up
other Virtual machines (like windows 7) on this server and keep that
virtual machine host-only. Is that possible?
renaming a file PHP mySQL
renaming a file PHP mySQL
I have a problem with renaming pictures in my gallery, here I have a
picture named
FIRST TIME PublicImg-0123456789.jpg and that's the ID to define the img
SECOND PublicImg-0123456789[_I_ADD_TITLE_HERE_FIRST].jpg till now it works
PERFECTLY but when I decide to rename it again
It works by this way
PublicImg-0123456789[_I_ADD_TITLE_HERE_FIRST][_I_ADD_TITLE_HERE_SECOND].jpg
I can't find a way to keep ONLY the ID and add a text, and I don't wanna
keep in my TABLE the ORIGIN urls because I have urls for the image and the
thumbnail and a small image too, if I add three columns this will be so
ugly.
so guys any ideas ? :D
BTW here is the Code
/////////
// Fichier IMAGE a renommer
$nom_image_old = preg_replace
('#./Images/'.$_SESSION['username'].'/#','', $_GET['img'] );
$nom_image_old = preg_replace ('#.jpg#','', $nom_image_old );
// Fichier Miniature a renommer
$nom_thumb_old = preg_replace
('#./Images/'.$_SESSION['username'].'#',
'./Thumbnails/'.$_SESSION['username'].'' ,$_GET['img']);
// Fichier Resized a renommer
$nom_resized_old = preg_replace
('#./Images/'.$_SESSION['username'].'/#',
'./Images/'.$_SESSION['username'].'/resized/' ,$_GET['img']);
$req2 = $BDD->prepare('SELECT * FROM images_users WHERE
img_uploader = :username AND img_url = :url ');
$req2->execute(array('username'=> $_SESSION['username'], 'url' =>
$_GET['img'] ));
while ($donnees = $req2->fetch())
{
if ( isset($_POST['rename'])
AND isset($_GET['img'])
AND isset($_POST['renommer'])
AND !empty($_POST['renommer'])
AND (strlen($_POST['renommer'])) <= 30)
{
$nom_image_new =
str_replace('.'.$infosfichier['extension'],
'_'.strip_tags($_POST['renommer']).'.'.$infosfichier['extension']
,$donnees['img_url']);
$nom_thumb_new =
str_replace('.'.$infosfichier['extension'],
'_'.strip_tags($_POST['renommer']).'.'.$infosfichier['extension']
,$donnees['thumb_url']);
$nom_resized_new =
str_replace('.'.$infosfichier['extension'],
'_'.strip_tags($_POST['renommer']).'.'.$infosfichier['extension']
,$donnees['resized_url']);
// on remplace les escpaces par des underscore (_) grace
la fonction preg_replace
rename ( $_GET['img'] = preg_replace('#[ |:]#',
'_',$_GET['img']) , $nom_image_new = preg_replace('#[
|:]#', '_', $nom_image_new) ) ;
rename ( $nom_thumb_old = preg_replace('#[ |:]#',
'_',$nom_thumb_old ) , $nom_thumb_new = preg_replace('#[
|:]#', '_',$nom_thumb_new) ) ;
rename ( $nom_resized_old = preg_replace('#[ |:]#',
'_',$nom_resized_old) , $nom_resized_new =
preg_replace('#[ |:]#', '_',$nom_resized_new) ) ;
header('Refresh: 0; url=affichage.php?img='.
$nom_image_new .'');
$req2->closeCursor();
// on rennome les données existant dans la table
$req = $BDD->prepare('UPDATE images_users SET
img_url
=:NEW_img_url,
thumb_url
=:NEW_thumb_url,
resized_url
=:NEW_resized_url,
img_description
=:NEW_img_description,
img_modification = NOW()
WHERE img_uploader =:username
AND img_url
=:img_url_old
');
$req->execute(array(
'NEW_img_url' =>
$nom_image_new,
'NEW_thumb_url' =>
$nom_thumb_new,
'NEW_resized_url' =>
$nom_resized_new,
'NEW_img_description' => '',
'username' =>
$_SESSION['username'],
'img_url_old' => $_GET['img'],
));
exit();
}}
/////////
I have a problem with renaming pictures in my gallery, here I have a
picture named
FIRST TIME PublicImg-0123456789.jpg and that's the ID to define the img
SECOND PublicImg-0123456789[_I_ADD_TITLE_HERE_FIRST].jpg till now it works
PERFECTLY but when I decide to rename it again
It works by this way
PublicImg-0123456789[_I_ADD_TITLE_HERE_FIRST][_I_ADD_TITLE_HERE_SECOND].jpg
I can't find a way to keep ONLY the ID and add a text, and I don't wanna
keep in my TABLE the ORIGIN urls because I have urls for the image and the
thumbnail and a small image too, if I add three columns this will be so
ugly.
so guys any ideas ? :D
BTW here is the Code
/////////
// Fichier IMAGE a renommer
$nom_image_old = preg_replace
('#./Images/'.$_SESSION['username'].'/#','', $_GET['img'] );
$nom_image_old = preg_replace ('#.jpg#','', $nom_image_old );
// Fichier Miniature a renommer
$nom_thumb_old = preg_replace
('#./Images/'.$_SESSION['username'].'#',
'./Thumbnails/'.$_SESSION['username'].'' ,$_GET['img']);
// Fichier Resized a renommer
$nom_resized_old = preg_replace
('#./Images/'.$_SESSION['username'].'/#',
'./Images/'.$_SESSION['username'].'/resized/' ,$_GET['img']);
$req2 = $BDD->prepare('SELECT * FROM images_users WHERE
img_uploader = :username AND img_url = :url ');
$req2->execute(array('username'=> $_SESSION['username'], 'url' =>
$_GET['img'] ));
while ($donnees = $req2->fetch())
{
if ( isset($_POST['rename'])
AND isset($_GET['img'])
AND isset($_POST['renommer'])
AND !empty($_POST['renommer'])
AND (strlen($_POST['renommer'])) <= 30)
{
$nom_image_new =
str_replace('.'.$infosfichier['extension'],
'_'.strip_tags($_POST['renommer']).'.'.$infosfichier['extension']
,$donnees['img_url']);
$nom_thumb_new =
str_replace('.'.$infosfichier['extension'],
'_'.strip_tags($_POST['renommer']).'.'.$infosfichier['extension']
,$donnees['thumb_url']);
$nom_resized_new =
str_replace('.'.$infosfichier['extension'],
'_'.strip_tags($_POST['renommer']).'.'.$infosfichier['extension']
,$donnees['resized_url']);
// on remplace les escpaces par des underscore (_) grace
la fonction preg_replace
rename ( $_GET['img'] = preg_replace('#[ |:]#',
'_',$_GET['img']) , $nom_image_new = preg_replace('#[
|:]#', '_', $nom_image_new) ) ;
rename ( $nom_thumb_old = preg_replace('#[ |:]#',
'_',$nom_thumb_old ) , $nom_thumb_new = preg_replace('#[
|:]#', '_',$nom_thumb_new) ) ;
rename ( $nom_resized_old = preg_replace('#[ |:]#',
'_',$nom_resized_old) , $nom_resized_new =
preg_replace('#[ |:]#', '_',$nom_resized_new) ) ;
header('Refresh: 0; url=affichage.php?img='.
$nom_image_new .'');
$req2->closeCursor();
// on rennome les données existant dans la table
$req = $BDD->prepare('UPDATE images_users SET
img_url
=:NEW_img_url,
thumb_url
=:NEW_thumb_url,
resized_url
=:NEW_resized_url,
img_description
=:NEW_img_description,
img_modification = NOW()
WHERE img_uploader =:username
AND img_url
=:img_url_old
');
$req->execute(array(
'NEW_img_url' =>
$nom_image_new,
'NEW_thumb_url' =>
$nom_thumb_new,
'NEW_resized_url' =>
$nom_resized_new,
'NEW_img_description' => '',
'username' =>
$_SESSION['username'],
'img_url_old' => $_GET['img'],
));
exit();
}}
/////////
Displaying database information on a page
Displaying database information on a page
a little bit new to php. I'm currently building a unique hits counter for
a project where the count will go up one if the users ip isn't in the
database, how would I implement the "count" into html?
PHP
<?php
$connect_error = 'Sorry, we\'re experiencing connection problems.';
mysql_connect('localhost', 'root', 'password') or die($connect_error);
mysql_select_db('hit_counter_database') or die($connect_error);
$user_ip = $_SERVER['REMOTE_ADDR'];
function ip_exits($ip){
global $user_ip;
$query = "SELECT `ip` FROM `hits_ip` WHERE `ip` = '$user_ip'";
$query_run = mysql_query($query);
$query_num_rows = mysql_num_rows($query_run);
if($query_num_rows) ==0) {
return false;
}else ($query_num_rows) >= 1){
return true;
}
}
function ip_add($ip) {
$query = "INSERT INTO `hits_ip` VALUES ('$ip')";
@$query_run = mysql_query($query);
}
function update_count(){
$query = "SELECT `count` FROM `hits_count`";
if (@$query_run = mysql_query($query)){
$count = mysql_result($query_run, 0, 'count');
$count_inc = $count + 1;
$query_update = "UPDATE `hits_count` SET `count` = '$count_inc'";
$query_update_run = mysql_query($query_update);
}
}
if(!ip_exists($user_ip){
update_count();
ip_add($user_ip);
}
?>
Thanks In advance :)
a little bit new to php. I'm currently building a unique hits counter for
a project where the count will go up one if the users ip isn't in the
database, how would I implement the "count" into html?
PHP
<?php
$connect_error = 'Sorry, we\'re experiencing connection problems.';
mysql_connect('localhost', 'root', 'password') or die($connect_error);
mysql_select_db('hit_counter_database') or die($connect_error);
$user_ip = $_SERVER['REMOTE_ADDR'];
function ip_exits($ip){
global $user_ip;
$query = "SELECT `ip` FROM `hits_ip` WHERE `ip` = '$user_ip'";
$query_run = mysql_query($query);
$query_num_rows = mysql_num_rows($query_run);
if($query_num_rows) ==0) {
return false;
}else ($query_num_rows) >= 1){
return true;
}
}
function ip_add($ip) {
$query = "INSERT INTO `hits_ip` VALUES ('$ip')";
@$query_run = mysql_query($query);
}
function update_count(){
$query = "SELECT `count` FROM `hits_count`";
if (@$query_run = mysql_query($query)){
$count = mysql_result($query_run, 0, 'count');
$count_inc = $count + 1;
$query_update = "UPDATE `hits_count` SET `count` = '$count_inc'";
$query_update_run = mysql_query($query_update);
}
}
if(!ip_exists($user_ip){
update_count();
ip_add($user_ip);
}
?>
Thanks In advance :)
How can I confirm that my Jekyll is installed well?
How can I confirm that my Jekyll is installed well?
This is my test page. I'm on windows 8.1
http://hypergroups.github.io/
jekyll --server --auto
This is my test page. I'm on windows 8.1
http://hypergroups.github.io/
jekyll --server --auto
How to Insert Data in Database through DataGridView in Windows Form Application C#
How to Insert Data in Database through DataGridView in Windows Form
Application C#
I am making a windows form application in c# , in which there is a grid
view control which is bind to SQL server database. All want, to let user
press CTRL + N and a new row appears as the first row of grid view and on
entering data in that row, data should be inserted into database by
pressing enter and with all validation checks. For this I am using text
boxes, but don't know how to do it with grid view.
Application C#
I am making a windows form application in c# , in which there is a grid
view control which is bind to SQL server database. All want, to let user
press CTRL + N and a new row appears as the first row of grid view and on
entering data in that row, data should be inserted into database by
pressing enter and with all validation checks. For this I am using text
boxes, but don't know how to do it with grid view.
Website down due less memory buffer available
Website down due less memory buffer available
My website down due less memory buffer available (linux server php and mysql)
I loggedin through ssh and checked for free space by following command
free -m
and i got below result
It shows only 465 mb free memory out of 12GB. Now I tried to find what
services are consuming most of the memory I executed below command
top
and i got below result this shows total memory consumption to less than 20%.
Does any one know how to find where my memory is consumed or which
services are consuming most of the memory.
Whether I have done it in right way. How can i reduce the memory
consumption so that my website doesn't go down. Is there need to increase
RAM.
My website down due less memory buffer available (linux server php and mysql)
I loggedin through ssh and checked for free space by following command
free -m
and i got below result
It shows only 465 mb free memory out of 12GB. Now I tried to find what
services are consuming most of the memory I executed below command
top
and i got below result this shows total memory consumption to less than 20%.
Does any one know how to find where my memory is consumed or which
services are consuming most of the memory.
Whether I have done it in right way. How can i reduce the memory
consumption so that my website doesn't go down. Is there need to increase
RAM.
Thursday, 22 August 2013
Getting Context from other class causing NPE
Getting Context from other class causing NPE
I'm trying to call a new activity in non-activity class using this codes:
Intent usage = new Intent(UsageActivity.getContext(),UsageActivity.class);
usage.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
UsageActivity.getContext().startActivity(usage);
and I have a UsageActivity that has this codes:
public static Context mContext;
below the onCreate()
mContext = getBaseContext();
i created a method like this:
public static Context getContext() {
return mContext;
}
It throws an exception saying this:
04-25 17:30:00.485: W/System.err(6518): java.lang.NullPointerException
04-25 17:30:00.501: W/System.err(6518): at
android.content.ComponentName.<init>(ComponentName.java:75)
04-25 17:30:00.501: W/System.err(6518): at
android.content.Intent.<init>(Intent.java:2823)
04-25 17:30:00.501: W/System.err(6518): at
com.itaxeeta.server.Search.onPostExecute(Search.java:219)
Does my way of creating a context was wrong? any thoghts will be highly
appreciated.
I'm trying to call a new activity in non-activity class using this codes:
Intent usage = new Intent(UsageActivity.getContext(),UsageActivity.class);
usage.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
UsageActivity.getContext().startActivity(usage);
and I have a UsageActivity that has this codes:
public static Context mContext;
below the onCreate()
mContext = getBaseContext();
i created a method like this:
public static Context getContext() {
return mContext;
}
It throws an exception saying this:
04-25 17:30:00.485: W/System.err(6518): java.lang.NullPointerException
04-25 17:30:00.501: W/System.err(6518): at
android.content.ComponentName.<init>(ComponentName.java:75)
04-25 17:30:00.501: W/System.err(6518): at
android.content.Intent.<init>(Intent.java:2823)
04-25 17:30:00.501: W/System.err(6518): at
com.itaxeeta.server.Search.onPostExecute(Search.java:219)
Does my way of creating a context was wrong? any thoghts will be highly
appreciated.
Deleting a pointer to global variable?
Deleting a pointer to global variable?
So, i have two global variables, that i want to point to object of a
certain class. I have them declared in one .h file as
extern Obj* pointer.
I inicialize that variable inside my main function, as follows:
pointer = new Obj();
later on, i call some functions inside main etc. Can i call delete
operator at the end of main, like so:
delete pointer;
My main, in general would look like:
int main(){
pointer = new Obj();
...
delete pointer;
}
So, i have two global variables, that i want to point to object of a
certain class. I have them declared in one .h file as
extern Obj* pointer.
I inicialize that variable inside my main function, as follows:
pointer = new Obj();
later on, i call some functions inside main etc. Can i call delete
operator at the end of main, like so:
delete pointer;
My main, in general would look like:
int main(){
pointer = new Obj();
...
delete pointer;
}
How to align two sets of timestamps
How to align two sets of timestamps
This was a tricky question to name. Here is what I am trying to do: I have
two sets of timestamps. I name the first one t_x and the second one t_y.
For one t_x there are several corresponding t_y's.
For example, take t_x = [1,4,6] and we have t_y[1] = [1,3,7], t_y[4] =
[2,4,6] and t_y[6] = [5,6,7].
This could be plotted in a (t_x, t_y) graph. Now I am taking the set of
slopes, which is (t_y1 - t_y2)/(t_x1 - t_x2), for t_x1 "close" to t_x2 and
t_y1 "close" to t_y2.
The question here is the following: what would be the most time-efficient
way to process the slopes? Is there a good data structure to hold the
timestamps in order to speed up the calculation?
I am using mostly python by the way, but I can read most common languages.
This was a tricky question to name. Here is what I am trying to do: I have
two sets of timestamps. I name the first one t_x and the second one t_y.
For one t_x there are several corresponding t_y's.
For example, take t_x = [1,4,6] and we have t_y[1] = [1,3,7], t_y[4] =
[2,4,6] and t_y[6] = [5,6,7].
This could be plotted in a (t_x, t_y) graph. Now I am taking the set of
slopes, which is (t_y1 - t_y2)/(t_x1 - t_x2), for t_x1 "close" to t_x2 and
t_y1 "close" to t_y2.
The question here is the following: what would be the most time-efficient
way to process the slopes? Is there a good data structure to hold the
timestamps in order to speed up the calculation?
I am using mostly python by the way, but I can read most common languages.
What is scope in Javascript?
What is scope in Javascript?
I don't understand what the scope is. I've read somewhere that scope is
the way to access varible. But I find it hard to come up with a case when
a variable is accesible through scope. All varibles inside a function can
be accessed through context of either 'global' or 'activation/variable'
object or through closure. Here is the piece of code to demonstrate what I
mean:
var global_var = 7;
var f = (function() {
var closure_var = 5;
return function() {
var local_var = 3;
alert(local_var); // alerts 3 - visible through context as
Activation Object's property
alert(closure_var); // alerts 5 - visible through closure
alert(global_var); // alerts 7 - visible through context as
Global Object's property
alert(this.global_var); // alerts 7 - visible through context as
Global Object's property
}
})();
f();
So what is scope? Here is the extract from here and my comments:
// a globally-scoped variable
var a=1;
// global scope
function one(){
alert(a);
}
// no, it's accessible as global object's context
// local scope
function two(a){
alert(a);
}
// no, it's accessible as activation object's context
I don't understand what the scope is. I've read somewhere that scope is
the way to access varible. But I find it hard to come up with a case when
a variable is accesible through scope. All varibles inside a function can
be accessed through context of either 'global' or 'activation/variable'
object or through closure. Here is the piece of code to demonstrate what I
mean:
var global_var = 7;
var f = (function() {
var closure_var = 5;
return function() {
var local_var = 3;
alert(local_var); // alerts 3 - visible through context as
Activation Object's property
alert(closure_var); // alerts 5 - visible through closure
alert(global_var); // alerts 7 - visible through context as
Global Object's property
alert(this.global_var); // alerts 7 - visible through context as
Global Object's property
}
})();
f();
So what is scope? Here is the extract from here and my comments:
// a globally-scoped variable
var a=1;
// global scope
function one(){
alert(a);
}
// no, it's accessible as global object's context
// local scope
function two(a){
alert(a);
}
// no, it's accessible as activation object's context
Grid scrollbar below grid
Grid scrollbar below grid
I use DevExpress and I have a GridView.Data for the grid is generated
dynamically.I want to set scrollbars if there is not enough space on the
screen,but I don't know how.I have tried to set overflow:auto,but then I
have to set height,which is different every time.I could use CSS3 calc()
function but it is not supported on Android.If i set height to 100% the
scrollbar goes below grid and last few rows can't be seen.Do you have any
suggestions?I don't want to use Javascript.
I use DevExpress and I have a GridView.Data for the grid is generated
dynamically.I want to set scrollbars if there is not enough space on the
screen,but I don't know how.I have tried to set overflow:auto,but then I
have to set height,which is different every time.I could use CSS3 calc()
function but it is not supported on Android.If i set height to 100% the
scrollbar goes below grid and last few rows can't be seen.Do you have any
suggestions?I don't want to use Javascript.
Wednesday, 21 August 2013
R Studio does not install pacjages
R Studio does not install pacjages
I have a problem when I am trying to install r-packages in my Windows 7. I
have R Studio 2.15.3
When I try to install a new package a window pops-up asking me if I want
to create a new folder to save the package as there isn't one. But when I
click yes, nothing happens. When I try to type the command in the R
console then I came up with this:
Warning in install.packages : cannot create dir 'C:\Users\ΠαÏις',
reason 'Permission denied' Error in install.packages : unable to create
'C:/Users/ΠαÏις/Documents/R/win-library/2.15'
Does anyone knows where the problem lie?
Cheers
Paris
I have a problem when I am trying to install r-packages in my Windows 7. I
have R Studio 2.15.3
When I try to install a new package a window pops-up asking me if I want
to create a new folder to save the package as there isn't one. But when I
click yes, nothing happens. When I try to type the command in the R
console then I came up with this:
Warning in install.packages : cannot create dir 'C:\Users\ΠαÏις',
reason 'Permission denied' Error in install.packages : unable to create
'C:/Users/ΠαÏις/Documents/R/win-library/2.15'
Does anyone knows where the problem lie?
Cheers
Paris
Is it possible that "ensconce," "sconce," and "abscond" could be cognates?
Is it possible that "ensconce," "sconce," and "abscond" could be cognates?
It seems impossible that "sconce" and "ensconce" are not cognate. However,
according to The Etymological Dictionary:
sconce (n.) Look up sconce at Dictionary.com late 14c., "candlestick with
a screen," a shortening of Old French esconse "lantern, hiding place,"
from Medieval Latin sconsa, from Latin absconsa, fem. past participle of
abscondere "to hide" (see abscond). Meaning "metal bracket-candlestick
fastened to a wall" is recorded from mid-15c. ensconce (v.) Look up
ensconce at Dictionary.com 1580s, "to cover with a fort," from en- (1)
"make, put in" + sconce "small fortification, shelter," perhaps via
French, probably from Dutch schans "earthwork" (cf. Middle High German
schanze "bundle of sticks"), of uncertain origin. Related: Ensconced.
It seems impossible that "sconce" and "ensconce" are not cognate. However,
according to The Etymological Dictionary:
sconce (n.) Look up sconce at Dictionary.com late 14c., "candlestick with
a screen," a shortening of Old French esconse "lantern, hiding place,"
from Medieval Latin sconsa, from Latin absconsa, fem. past participle of
abscondere "to hide" (see abscond). Meaning "metal bracket-candlestick
fastened to a wall" is recorded from mid-15c. ensconce (v.) Look up
ensconce at Dictionary.com 1580s, "to cover with a fort," from en- (1)
"make, put in" + sconce "small fortification, shelter," perhaps via
French, probably from Dutch schans "earthwork" (cf. Middle High German
schanze "bundle of sticks"), of uncertain origin. Related: Ensconced.
how to setup logwatch to record pure-ftpd deleted files
how to setup logwatch to record pure-ftpd deleted files
I just installed logwatch and I would like to log deleted files from
pure-ftpd. I'm using cloudlinux and cpanel.
Here are my settings:
/usr/share/logwatch/default.conf/
########################################################
# This was written and is maintained by:
# Kirk Bauer <kirk@kaybee.org>
#
# Please send all comments, suggestions, bug reports,
# etc, to kirk@kaybee.org.
#
########################################################
# NOTE:
# All these options are the defaults if you run logwatch with no
# command-line arguments. You can override all of these on the
# command-line.
# You can put comments anywhere you want to. They are effective for the
# rest of the line.
# this is in the format of <name> = <value>. Whitespace at the beginning
# and end of the lines is removed. Whitespace before and after the = sign
# is removed. Everything is case *insensitive*.
# Yes = True = On = 1
# No = False = Off = 0
# Default Log Directory
# All log-files are assumed to be given relative to this directory.
LogDir = /var/log
# You can override the default temp directory (/tmp) here
TmpDir = /var/cache/logwatch
#Output/Format Options
#By default Logwatch will print to stdout in text with no encoding.
#To make email Default set Output = mail to save to file set Output = file
Output = stdout
#To make Html the default formatting Format = html
Format = text
#To make Base64 [aka uuencode] Encode = base64
Encode = none
# Default person to mail reports to. Can be a local account or a
# complete email address. Variable Output should be set to mail, or
# --output mail should be passed on command line to enable mail feature.
MailTo = @gmail.com
# WHen using option --multiemail, it is possible to specify a different
# email recipient per host processed. For example, to send the report
# for hostname host1 to user@example.com, use:
#Mailto_host1 = user@example.com
# Multiple recipients can be specified by separating them with a space.
# Default person to mail reports from. Can be a local account or a
# complete email address.
MailFrom = Logwatch
# if set, the results will be saved in <filename> instead of mailed
# or displayed. Be sure to set Output = file also.
#Filename = /tmp/logwatch
# Use archives? If set to 'Yes', the archives of logfiles
# (i.e. /var/log/messages.1 or /var/log/messages.1.gz) will
# be searched in addition to the /var/log/messages file.
# This usually will not do much if your range is set to just
# 'Yesterday' or 'Today'... it is probably best used with
# By default this is now set to Yes. To turn off Archives uncomment this.
#Archives = No
# Range = All
# The default time range for the report...
# The current choices are All, Today, Yesterday
Range = yesterday
# The default detail level for the report.
# This can either be Low, Med, High or a number.
# Low = 0
# Med = 5
# High = 10
Detail = 10
# The 'Service' option expects either the name of a filter
# (in /usr/share/logwatch/scripts/services/*) or 'All'.
# The default service(s) to report on. This should be left as All for
# most people.
Service = All
# You can also disable certain services (when specifying all)
Service = "-zz-network" # Prevents execution of zz-network service, which
# prints useful network configuration info.
Service = "-zz-sys" # Prevents execution of zz-sys service, which
# prints useful system configuration info.
Service = "-eximstats" # Prevents execution of eximstats service, which
# is a wrapper for the eximstats program.
# If you only cared about FTP messages, you could use these 2 lines
# instead of the above:
#Service = ftpd-messages # Processes ftpd messages in /var/log/messages
#Service = ftpd-xferlog # Processes ftpd messages in /var/log/xferlog
# Maybe you only wanted reports on PAM messages, then you would use:
#Service = pam_pwdb # PAM_pwdb messages - usually quite a bit
#Service = pam # General PAM messages... usually not many
# You can also choose to use the 'LogFile' option. This will cause
# logwatch to only analyze that one logfile.. for example:
#LogFile = messages
# will process /var/log/messages. This will run all the filters that
# process that logfile. This option is probably not too useful to
# most people. Setting 'Service' to 'All' above analyzes all LogFiles
# anyways...
#
# By default we assume that all Unix systems have sendmail or a
sendmail-like MTA.
# The mailer code prints a header with To: From: and Subject:.
# At this point you can change the mailer to anything that can handle this
output
# stream.
# TODO test variables in the mailer string to see if the To/From/Subject
can be set
# From here with out breaking anything. This would allow mail/mailx/nail
etc..... -mgt
mailer = "/usr/sbin/sendmail -t"
#
# With this option set to 'Yes', only log entries for this particular host
# (as returned by 'hostname' command) will be processed. The hostname
# can also be overridden on the commandline (with --hostname option). This
# can allow a log host to process only its own logs, or Logwatch can be
# run once per host included in the logfiles.
#
# The default is to report on all log entries, regardless of its source host.
# Note that some logfiles do not include host information and will not be
# influenced by this setting.
#
#HostLimit = Yes
# vi: shiftwidth=3 tabstop=3 et
/etc/logwatch/conf/override.conf
# Configuration overrides for specific logfiles/services may be placed here.
logfiles/exim: LogFile = exim_mainlog
logfiles/http: LogFile = /usr/local/apache/logs/access_log
services/pop3: *OnlyService = cpanelpop
services/pop3: *RemoveHeaders = 1
services/pureftpd: LogFile = messages
services/pureftpd: $show_logins = 1
services/pureftpd: $show_logouts = 1
services/pureftpd: $show_new_connections = 1
Thanks in advance.
I just installed logwatch and I would like to log deleted files from
pure-ftpd. I'm using cloudlinux and cpanel.
Here are my settings:
/usr/share/logwatch/default.conf/
########################################################
# This was written and is maintained by:
# Kirk Bauer <kirk@kaybee.org>
#
# Please send all comments, suggestions, bug reports,
# etc, to kirk@kaybee.org.
#
########################################################
# NOTE:
# All these options are the defaults if you run logwatch with no
# command-line arguments. You can override all of these on the
# command-line.
# You can put comments anywhere you want to. They are effective for the
# rest of the line.
# this is in the format of <name> = <value>. Whitespace at the beginning
# and end of the lines is removed. Whitespace before and after the = sign
# is removed. Everything is case *insensitive*.
# Yes = True = On = 1
# No = False = Off = 0
# Default Log Directory
# All log-files are assumed to be given relative to this directory.
LogDir = /var/log
# You can override the default temp directory (/tmp) here
TmpDir = /var/cache/logwatch
#Output/Format Options
#By default Logwatch will print to stdout in text with no encoding.
#To make email Default set Output = mail to save to file set Output = file
Output = stdout
#To make Html the default formatting Format = html
Format = text
#To make Base64 [aka uuencode] Encode = base64
Encode = none
# Default person to mail reports to. Can be a local account or a
# complete email address. Variable Output should be set to mail, or
# --output mail should be passed on command line to enable mail feature.
MailTo = @gmail.com
# WHen using option --multiemail, it is possible to specify a different
# email recipient per host processed. For example, to send the report
# for hostname host1 to user@example.com, use:
#Mailto_host1 = user@example.com
# Multiple recipients can be specified by separating them with a space.
# Default person to mail reports from. Can be a local account or a
# complete email address.
MailFrom = Logwatch
# if set, the results will be saved in <filename> instead of mailed
# or displayed. Be sure to set Output = file also.
#Filename = /tmp/logwatch
# Use archives? If set to 'Yes', the archives of logfiles
# (i.e. /var/log/messages.1 or /var/log/messages.1.gz) will
# be searched in addition to the /var/log/messages file.
# This usually will not do much if your range is set to just
# 'Yesterday' or 'Today'... it is probably best used with
# By default this is now set to Yes. To turn off Archives uncomment this.
#Archives = No
# Range = All
# The default time range for the report...
# The current choices are All, Today, Yesterday
Range = yesterday
# The default detail level for the report.
# This can either be Low, Med, High or a number.
# Low = 0
# Med = 5
# High = 10
Detail = 10
# The 'Service' option expects either the name of a filter
# (in /usr/share/logwatch/scripts/services/*) or 'All'.
# The default service(s) to report on. This should be left as All for
# most people.
Service = All
# You can also disable certain services (when specifying all)
Service = "-zz-network" # Prevents execution of zz-network service, which
# prints useful network configuration info.
Service = "-zz-sys" # Prevents execution of zz-sys service, which
# prints useful system configuration info.
Service = "-eximstats" # Prevents execution of eximstats service, which
# is a wrapper for the eximstats program.
# If you only cared about FTP messages, you could use these 2 lines
# instead of the above:
#Service = ftpd-messages # Processes ftpd messages in /var/log/messages
#Service = ftpd-xferlog # Processes ftpd messages in /var/log/xferlog
# Maybe you only wanted reports on PAM messages, then you would use:
#Service = pam_pwdb # PAM_pwdb messages - usually quite a bit
#Service = pam # General PAM messages... usually not many
# You can also choose to use the 'LogFile' option. This will cause
# logwatch to only analyze that one logfile.. for example:
#LogFile = messages
# will process /var/log/messages. This will run all the filters that
# process that logfile. This option is probably not too useful to
# most people. Setting 'Service' to 'All' above analyzes all LogFiles
# anyways...
#
# By default we assume that all Unix systems have sendmail or a
sendmail-like MTA.
# The mailer code prints a header with To: From: and Subject:.
# At this point you can change the mailer to anything that can handle this
output
# stream.
# TODO test variables in the mailer string to see if the To/From/Subject
can be set
# From here with out breaking anything. This would allow mail/mailx/nail
etc..... -mgt
mailer = "/usr/sbin/sendmail -t"
#
# With this option set to 'Yes', only log entries for this particular host
# (as returned by 'hostname' command) will be processed. The hostname
# can also be overridden on the commandline (with --hostname option). This
# can allow a log host to process only its own logs, or Logwatch can be
# run once per host included in the logfiles.
#
# The default is to report on all log entries, regardless of its source host.
# Note that some logfiles do not include host information and will not be
# influenced by this setting.
#
#HostLimit = Yes
# vi: shiftwidth=3 tabstop=3 et
/etc/logwatch/conf/override.conf
# Configuration overrides for specific logfiles/services may be placed here.
logfiles/exim: LogFile = exim_mainlog
logfiles/http: LogFile = /usr/local/apache/logs/access_log
services/pop3: *OnlyService = cpanelpop
services/pop3: *RemoveHeaders = 1
services/pureftpd: LogFile = messages
services/pureftpd: $show_logins = 1
services/pureftpd: $show_logouts = 1
services/pureftpd: $show_new_connections = 1
Thanks in advance.
Nivo Slider Fails to Show 3rd Image in Chrome
Nivo Slider Fails to Show 3rd Image in Chrome
The page in question can be viewed here:
http://quiltersrule.com/beta/index.html and of course just use chrome to
view the code.
I noticed that 80% of the time, my 3rd slider image just plain doesn't
show. The slider just collapses until it moves onto my placeholder image
#4. I have no idea what is going on. The image is the same size as the
others, and I don't suspect a loading-time issue.
This only seems to happen in Chrome. I have not tried FF, and it does not
happen in IE.
The page in question can be viewed here:
http://quiltersrule.com/beta/index.html and of course just use chrome to
view the code.
I noticed that 80% of the time, my 3rd slider image just plain doesn't
show. The slider just collapses until it moves onto my placeholder image
#4. I have no idea what is going on. The image is the same size as the
others, and I don't suspect a loading-time issue.
This only seems to happen in Chrome. I have not tried FF, and it does not
happen in IE.
synchronizing workers Algorithm
synchronizing workers Algorithm
I have a scenario, where i am monitoring a dozen of stocks.
Worker
worker (a method) takes a stock (assigned by manager), Monitors it for 5
consecutive negative Units. Each unit is say 0.5% of a stock price. Eg:
for a stock, costing 100$. Each unit is 50C.
If its price falls to 99.4$ => One unit down. (Intermediate fluctuations
in a unit are OK.)
If its price falls to 98.8$ => Two units down from 100$
If its price falls to 98.4$ => Three units down from 100$
IF a stock price goes down by 5 units, the worker reports to manager. End
method here. iF a stock price moves up by 2 units, report to manager and
end method here.
Manager
Assigns a worker for each of these dozen stocks. (Calling the same method.
Thread: Non Blocking) Wait till all of them terminate. check if all of the
stocks are moving up/down.
If all are moving up, Call "Handle_Rising Market" method
If all are moving down, Call "Handle_Crashing_Market" method
If some are moving up, and some moving down, Call worker again for each of
them, Manager must end only when all report either UP or DOWN. till then
the check must go on.
I am looking for the fastest algorithm. This is a traditional Worker
manager problem, with extra scenarios. The repeated check to ensure that
all of them are moving up/down is where i am stuck! Any advice is highly
appreciated.
I have a scenario, where i am monitoring a dozen of stocks.
Worker
worker (a method) takes a stock (assigned by manager), Monitors it for 5
consecutive negative Units. Each unit is say 0.5% of a stock price. Eg:
for a stock, costing 100$. Each unit is 50C.
If its price falls to 99.4$ => One unit down. (Intermediate fluctuations
in a unit are OK.)
If its price falls to 98.8$ => Two units down from 100$
If its price falls to 98.4$ => Three units down from 100$
IF a stock price goes down by 5 units, the worker reports to manager. End
method here. iF a stock price moves up by 2 units, report to manager and
end method here.
Manager
Assigns a worker for each of these dozen stocks. (Calling the same method.
Thread: Non Blocking) Wait till all of them terminate. check if all of the
stocks are moving up/down.
If all are moving up, Call "Handle_Rising Market" method
If all are moving down, Call "Handle_Crashing_Market" method
If some are moving up, and some moving down, Call worker again for each of
them, Manager must end only when all report either UP or DOWN. till then
the check must go on.
I am looking for the fastest algorithm. This is a traditional Worker
manager problem, with extra scenarios. The repeated check to ensure that
all of them are moving up/down is where i am stuck! Any advice is highly
appreciated.
Is it possible to retrieve a call without having recorded it?
Is it possible to retrieve a call without having recorded it?
I made an important call and I want to listen to it again. Unfortunately I
didn't install any application to record calls. Is it possible ? Are calls
recorded somewhere ?
I made an important call and I want to listen to it again. Unfortunately I
didn't install any application to record calls. Is it possible ? Are calls
recorded somewhere ?
How to Prevent External Hard Drives from Sleeping in Windows 8.1
How to Prevent External Hard Drives from Sleeping in Windows 8.1
This is a new problem for me with Win 8.1. For context (though it
shouldn't really matter), I have an external HD enclosure that I use for
media and other stuff that doesn't need to be extra-speedy. It's my
in-case-of-a-flood-grab-this-thing-and-go enclosure, so it has data on it
that I work with throughout the day. The enclosure (like most) has
separate power switch. When the OS turns tells it to go to sleep, it needs
to be physically turned back on. So when Windows tells it to go to sleep,
nothing can access the drives until I push the button.
Anyway.
With Win7 and Win8, some simple adjustments to the power settings to turn
"USB selective suspend setting" off stopped the enclosure and its drives
from going to sleep.
With 8.1, this isn't the case. I believe I've hit all of the obvious power
settings, so looking for something I've missed.
Power settings: USB selective suspend: DISABLED Turn off hard disk after:
NEVER Device manager | all USB Root Hubs | Power Management | Allow My
Computer to Turn Off This Device: DISABLED
I can hack my way around this with an every-10-minute script that writes
and deletes a file to one of the drives, but I'd rather have an answer to
Win 8.1's change to USB power management.
This is a new problem for me with Win 8.1. For context (though it
shouldn't really matter), I have an external HD enclosure that I use for
media and other stuff that doesn't need to be extra-speedy. It's my
in-case-of-a-flood-grab-this-thing-and-go enclosure, so it has data on it
that I work with throughout the day. The enclosure (like most) has
separate power switch. When the OS turns tells it to go to sleep, it needs
to be physically turned back on. So when Windows tells it to go to sleep,
nothing can access the drives until I push the button.
Anyway.
With Win7 and Win8, some simple adjustments to the power settings to turn
"USB selective suspend setting" off stopped the enclosure and its drives
from going to sleep.
With 8.1, this isn't the case. I believe I've hit all of the obvious power
settings, so looking for something I've missed.
Power settings: USB selective suspend: DISABLED Turn off hard disk after:
NEVER Device manager | all USB Root Hubs | Power Management | Allow My
Computer to Turn Off This Device: DISABLED
I can hack my way around this with an every-10-minute script that writes
and deletes a file to one of the drives, but I'd rather have an answer to
Win 8.1's change to USB power management.
Tuesday, 20 August 2013
How to kill mousemove after click in this jquery function?
How to kill mousemove after click in this jquery function?
This is a button that follows mouse movement. I would like to stop this
button when mouse is clicked on it!
jQuery( document ).ready( function() {
$( "#enbfb-button-wrapper-5" ).parent().mousemove( function( e ) {
jQuery( "#enbfb-button-wrapper-5" ).css( {
top: e.pageY - 10, left: e.pageX + 30
} );
} );
I think I have to kill mousemove! How to do that please?
thanks
This is a button that follows mouse movement. I would like to stop this
button when mouse is clicked on it!
jQuery( document ).ready( function() {
$( "#enbfb-button-wrapper-5" ).parent().mousemove( function( e ) {
jQuery( "#enbfb-button-wrapper-5" ).css( {
top: e.pageY - 10, left: e.pageX + 30
} );
} );
I think I have to kill mousemove! How to do that please?
thanks
How do you know which substitutions to make to cancel out a term?
How do you know which substitutions to make to cancel out a term?
I am doing problem B45 from Ivan Niven's "Maxima and Minima Without
Calculus" which says:
"Consider the quadratic polynomial $f(x, y)=ax^2+2bxy+cy^2+dx+cy+k$ ,
where the coefficients are real constants with $a>0$ and $c>0$ . In case
$b \not =0$ , verify that the transformation $x=X-by/a$ produces a
quadratic polynomial $f(X-by/a , y)$ with no $Xy$ term."
The reason why he didn't want an $Xy$ terms is because if there is none
then the function is easy to minimize by minimizing the two variables
separately. My question is, what steps led to the substitution $x=X-by/a$?
How did he know that making this substitution would lead you to having no
$Xy$ term? How can this method be extended more generally to other
functions? Thanks.
I am doing problem B45 from Ivan Niven's "Maxima and Minima Without
Calculus" which says:
"Consider the quadratic polynomial $f(x, y)=ax^2+2bxy+cy^2+dx+cy+k$ ,
where the coefficients are real constants with $a>0$ and $c>0$ . In case
$b \not =0$ , verify that the transformation $x=X-by/a$ produces a
quadratic polynomial $f(X-by/a , y)$ with no $Xy$ term."
The reason why he didn't want an $Xy$ terms is because if there is none
then the function is easy to minimize by minimizing the two variables
separately. My question is, what steps led to the substitution $x=X-by/a$?
How did he know that making this substitution would lead you to having no
$Xy$ term? How can this method be extended more generally to other
functions? Thanks.
Missing values after joining tables in SQLite
Missing values after joining tables in SQLite
This is relationship between tables in SQLite database. There I am trying
to join 5 tables.
SELECT * FROM r_ele
WHERE r_ele.value LIKE '‚Å‚à%'
Query above returns this result(which is ok). The table next to this
missing words in red!
But when I try join tables, some values are missing.
SELECT e.id AS entry_id,
re.value AS re_value,
GROUP_CONCAT(DISTINCT ke.value) AS ke_value,
GROUP_CONCAT(DISTINCT g.value) AS g_value
FROM (entry e
INNER JOIN k_ele ke ON e.id = ke.fk
INNER JOIN r_ele re ON e.id = re.fk
INNER JOIN sense s ON e.id = s.fk
INNER JOIN gloss g ON s.id = g.fk)
WHERE g.lang IS NULL AND re_value LIKE '‚Å‚à%'
GROUP BY re.value
ORDER BY re_value;
Result:
What I am doing wrong? What should I do in order to avoid missing some
values from table 'r_ele'?
This is relationship between tables in SQLite database. There I am trying
to join 5 tables.
SELECT * FROM r_ele
WHERE r_ele.value LIKE '‚Å‚à%'
Query above returns this result(which is ok). The table next to this
missing words in red!
But when I try join tables, some values are missing.
SELECT e.id AS entry_id,
re.value AS re_value,
GROUP_CONCAT(DISTINCT ke.value) AS ke_value,
GROUP_CONCAT(DISTINCT g.value) AS g_value
FROM (entry e
INNER JOIN k_ele ke ON e.id = ke.fk
INNER JOIN r_ele re ON e.id = re.fk
INNER JOIN sense s ON e.id = s.fk
INNER JOIN gloss g ON s.id = g.fk)
WHERE g.lang IS NULL AND re_value LIKE '‚Å‚à%'
GROUP BY re.value
ORDER BY re_value;
Result:
What I am doing wrong? What should I do in order to avoid missing some
values from table 'r_ele'?
how to move google email acct to new phone
how to move google email acct to new phone
I just got an HTC DNA (old phone is HTC Incredible). I need to move my
gmail acct to new phone. I then need to remove a new gmail acct I created
in error. Thanks, Jim.
I just got an HTC DNA (old phone is HTC Incredible). I need to move my
gmail acct to new phone. I then need to remove a new gmail acct I created
in error. Thanks, Jim.
Script not printing word count
Script not printing word count
I have a script to find the word repetition in alist:
newm = [u'life', u'selection', u'squire', u'naturalist', u'patriarch',
u'home', u'man', u'public', u'nbsp', u'born', u'naturalist', u'theory',
u'selectionbecame', u'foundation', u'country', u'gentleman',
u'suggesting', u'class', u'time', u'death', u'evolutionary', u'imagery',
u'ofscience', u'literature']
print newm
#count for list
counts = defaultdict(int)
print "uyti"
for x in newm:
counts[x]+=1
print counts
This program does not even print "uyti". What is the error?
I have a script to find the word repetition in alist:
newm = [u'life', u'selection', u'squire', u'naturalist', u'patriarch',
u'home', u'man', u'public', u'nbsp', u'born', u'naturalist', u'theory',
u'selectionbecame', u'foundation', u'country', u'gentleman',
u'suggesting', u'class', u'time', u'death', u'evolutionary', u'imagery',
u'ofscience', u'literature']
print newm
#count for list
counts = defaultdict(int)
print "uyti"
for x in newm:
counts[x]+=1
print counts
This program does not even print "uyti". What is the error?
Find by both conditions (both conditions appear)
Find by both conditions (both conditions appear)
I have the next li-s:
your ad was Approved
your name was Approved
your ad was Deleted
I want to find by both conditions:
I tried the next thing:
$("#notification-list").find(
"li:contains('was Approved'), li:not(:contains('your ad'))).each(function
() {
}
but I got:
your ad was Approved (I got it cause 'your ad' is found here and 'was
Approved')
your name was Approved (I got it cause 'was Approved' is found)
your ad was Deleted (I got it cause 'your ad' is found)
I want to get only the items that contains both things:
your ad was Approved (I got it cause 'your ad' is found here and 'was
Approved')
I tried:
$("#notification-list").find(
"li:contains('was Approved') and li:not(:contains('your
ad'))).each(function () {
}
but it doesn't work.
any help appreciated!
I have the next li-s:
your ad was Approved
your name was Approved
your ad was Deleted
I want to find by both conditions:
I tried the next thing:
$("#notification-list").find(
"li:contains('was Approved'), li:not(:contains('your ad'))).each(function
() {
}
but I got:
your ad was Approved (I got it cause 'your ad' is found here and 'was
Approved')
your name was Approved (I got it cause 'was Approved' is found)
your ad was Deleted (I got it cause 'your ad' is found)
I want to get only the items that contains both things:
your ad was Approved (I got it cause 'your ad' is found here and 'was
Approved')
I tried:
$("#notification-list").find(
"li:contains('was Approved') and li:not(:contains('your
ad'))).each(function () {
}
but it doesn't work.
any help appreciated!
The relationship between the two objects cannot be defined
The relationship between the two objects cannot be defined
I want add and edit items in Users. I use this code.
DataContext db = new DataContext();
private void Save()
{
User user = (SelectedUser == null) ? new User() :
db.User.Find(SelectedUser.UserName);
user.FirstName = FirstName;
user.CcRowIndex = CcRowIndex;
user.Image = Image;
user.LastName = LastName;
user.OrganizationalPostId = OrganizationalPost;
user.OrganizationalUnitId = OrganizationalUnit;
user.Password = Password;
user.Signature = Signature;
user.SubsetUsers = SubsetUsersList;
user.UserName = UserName;
if (SelectedUser == null)
{
db.User.Add(user);
}
db.SaveChanges();
}
I add Items, but when i edit items i get error
The relationship between the two objects cannot be defined because they
are attached to different ObjectContext objects.+ savechange of
datacontext
I want add and edit items in Users. I use this code.
DataContext db = new DataContext();
private void Save()
{
User user = (SelectedUser == null) ? new User() :
db.User.Find(SelectedUser.UserName);
user.FirstName = FirstName;
user.CcRowIndex = CcRowIndex;
user.Image = Image;
user.LastName = LastName;
user.OrganizationalPostId = OrganizationalPost;
user.OrganizationalUnitId = OrganizationalUnit;
user.Password = Password;
user.Signature = Signature;
user.SubsetUsers = SubsetUsersList;
user.UserName = UserName;
if (SelectedUser == null)
{
db.User.Add(user);
}
db.SaveChanges();
}
I add Items, but when i edit items i get error
The relationship between the two objects cannot be defined because they
are attached to different ObjectContext objects.+ savechange of
datacontext
Monday, 19 August 2013
$.ajax()function with json data from javascript array to a php processing file
$.ajax()function with json data from javascript array to a php processing
file
i trying to use json for the first time with $.ajax() i got the values of
checkboxes and other needed data to a php file for processing and posting
to mysqldb through an array for the data section of $.ajax() function but
would get an empty array[] on my php file. When i try using javascript
debugging tool from my browser i got the reprot
**Uncaught SyntaxError: Unexpected end of input jquery-1.9.0.min.js:1
st.extend.parseJSON jquery-1.9.0.min.js:1
(anonymous function) index.php?url=account/registration/:297
st.event.dispatch jquery-1.9.0.min.js:2
y.handle**
the array i produced looks like this at the console log
[checkbox1: "COM 101", semester: "1st Semester", mid: "7", checkbox2:
"COM 112", checkbox3: "STA 111"…]
checkbox1: "COM 101"
checkbox2: "COM 112"
checkbox3: "STA 111"
checkbox4: "STA 112"
checkbox5: "MTH 111"
length: 0
mid: "7"
semester: "1st Semester"
on my php processing file i did print_r on the json data but got an
Array[] as a result
this is my javascript code block "myDataArray is a global variable"
$('#mytable2').on('change',function(e){
var rel = e.target.getAttribute('rel');
console.log(e.target.value+ " "+ e.target.checked)
if(rel === globals.payment_target && e.target.checked===true){
myDataArray[e.target.getAttribute("name")]= e.target.value;
myDataArray["semester"] = $("#semester").val()
myDataArray["mid"] = $("#mid").val()
}
if(rel === globals.payment_target && e.target.checked ===false){
delete myDataArray[e.target.getAttribute("name")]
console.log(myDataArray)
}
});
$('#mytable2').on('click',function(e){
var rel = e.target.getAttribute('rel');
console.log(e.target.value+ " "+ e.target.getAttribute('name'))
if(rel === globals.payment_target && e.target.value
=="Register"){
console.log(myDataArray)
var jsonstring = $.parseJSON(myDataArray);
var myglob =JSON.stringify(globals)
console.log(myglob)
$.ajax({url:'courseregistration.php',
type:'POST',data:{data:jsonstring},success:
function(result){
$('#putmehere').html("<h4
style='text-align:center'>"+result+"</h4>")
alert(result)
}
})
}
});
and this what the php file looks like
$data = json_decode($_POST['data']);
print_r($data);
i just can't figure out what the problem is. can someone please tell me
what is wrong with the way i'm doing it or suggest a better way
file
i trying to use json for the first time with $.ajax() i got the values of
checkboxes and other needed data to a php file for processing and posting
to mysqldb through an array for the data section of $.ajax() function but
would get an empty array[] on my php file. When i try using javascript
debugging tool from my browser i got the reprot
**Uncaught SyntaxError: Unexpected end of input jquery-1.9.0.min.js:1
st.extend.parseJSON jquery-1.9.0.min.js:1
(anonymous function) index.php?url=account/registration/:297
st.event.dispatch jquery-1.9.0.min.js:2
y.handle**
the array i produced looks like this at the console log
[checkbox1: "COM 101", semester: "1st Semester", mid: "7", checkbox2:
"COM 112", checkbox3: "STA 111"…]
checkbox1: "COM 101"
checkbox2: "COM 112"
checkbox3: "STA 111"
checkbox4: "STA 112"
checkbox5: "MTH 111"
length: 0
mid: "7"
semester: "1st Semester"
on my php processing file i did print_r on the json data but got an
Array[] as a result
this is my javascript code block "myDataArray is a global variable"
$('#mytable2').on('change',function(e){
var rel = e.target.getAttribute('rel');
console.log(e.target.value+ " "+ e.target.checked)
if(rel === globals.payment_target && e.target.checked===true){
myDataArray[e.target.getAttribute("name")]= e.target.value;
myDataArray["semester"] = $("#semester").val()
myDataArray["mid"] = $("#mid").val()
}
if(rel === globals.payment_target && e.target.checked ===false){
delete myDataArray[e.target.getAttribute("name")]
console.log(myDataArray)
}
});
$('#mytable2').on('click',function(e){
var rel = e.target.getAttribute('rel');
console.log(e.target.value+ " "+ e.target.getAttribute('name'))
if(rel === globals.payment_target && e.target.value
=="Register"){
console.log(myDataArray)
var jsonstring = $.parseJSON(myDataArray);
var myglob =JSON.stringify(globals)
console.log(myglob)
$.ajax({url:'courseregistration.php',
type:'POST',data:{data:jsonstring},success:
function(result){
$('#putmehere').html("<h4
style='text-align:center'>"+result+"</h4>")
alert(result)
}
})
}
});
and this what the php file looks like
$data = json_decode($_POST['data']);
print_r($data);
i just can't figure out what the problem is. can someone please tell me
what is wrong with the way i'm doing it or suggest a better way
A basic doubt on linear maps
A basic doubt on linear maps
Let $f$ be a linear map from $V$ to its field set, say $F$. Now if
$f(v)=0$ does it necessarily imply that $v=0$. I don't think so. $v=0$ is
one solution, but it need not be the only solution because $f$ need not be
one-to-one. Is this correct ?
Let $f$ be a linear map from $V$ to its field set, say $F$. Now if
$f(v)=0$ does it necessarily imply that $v=0$. I don't think so. $v=0$ is
one solution, but it need not be the only solution because $f$ need not be
one-to-one. Is this correct ?
Failed to load module from user agent at localhost
Failed to load module from user agent at localhost
When I tried to run GWT quick start tutorial I got this error message!
How can I fix this issue?
P.S.
I already installed GWT Developer plugin for Firefox 1.23
I installed eclipse from ubuntu 13.04 repository (version 3.8.1)
I already GWT from ubuntu 13.04 repository (version 2.4.0)
00:27:29.230 [ERROR] [hellostupid] Failed to load module 'hellostupid'
from user agent 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:23.0)
Gecko/20100101 Firefox/23.0' at localhost:40544
java.lang.NullPointerException: null at
com.google.gwt.dev.javac.JsniChecker.getSuppressedWarnings(JsniChecker.java:565)
at
com.google.gwt.dev.javac.JsniChecker$JsniDeclChecker.visit(JsniChecker.java:135)
at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1233)
at
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:679)
at com.google.gwt.dev.javac.JsniChecker.check(JsniChecker.java:615) at
com.google.gwt.dev.javac.JsniChecker.check(JsniChecker.java:559) at
com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater$UnitProcessorImpl.process(CompilationStateBuilder.java:83)
at
com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.process(JdtCompiler.java:251)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:464)
at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:710) at
com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:235)
at
com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:447)
at
com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:370)
at
com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:360)
at
com.google.gwt.dev.DevModeBase$UiBrowserWidgetHostImpl.createModuleSpaceHost(DevModeBase.java:110)
at
com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:197)
at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:724)
When I tried to run GWT quick start tutorial I got this error message!
How can I fix this issue?
P.S.
I already installed GWT Developer plugin for Firefox 1.23
I installed eclipse from ubuntu 13.04 repository (version 3.8.1)
I already GWT from ubuntu 13.04 repository (version 2.4.0)
00:27:29.230 [ERROR] [hellostupid] Failed to load module 'hellostupid'
from user agent 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:23.0)
Gecko/20100101 Firefox/23.0' at localhost:40544
java.lang.NullPointerException: null at
com.google.gwt.dev.javac.JsniChecker.getSuppressedWarnings(JsniChecker.java:565)
at
com.google.gwt.dev.javac.JsniChecker$JsniDeclChecker.visit(JsniChecker.java:135)
at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1233)
at
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:679)
at com.google.gwt.dev.javac.JsniChecker.check(JsniChecker.java:615) at
com.google.gwt.dev.javac.JsniChecker.check(JsniChecker.java:559) at
com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater$UnitProcessorImpl.process(CompilationStateBuilder.java:83)
at
com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.process(JdtCompiler.java:251)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:464)
at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:710) at
com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:235)
at
com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:447)
at
com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:370)
at
com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:360)
at
com.google.gwt.dev.DevModeBase$UiBrowserWidgetHostImpl.createModuleSpaceHost(DevModeBase.java:110)
at
com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:197)
at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:724)
htaccess simplified and remove need for trailing a slash
htaccess simplified and remove need for trailing a slash
I am writing my very first htaccess and would like help cleaning it up and
understanding it. The first issue I am having is with mulitple parameters.
my current setup looks like:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !/(_modules|css|files|ico|img|js)/
RewriteRule ^([^/]*)/([^/]*)$ index.php?p1=$1 [L]
RewriteCond %{REQUEST_FILENAME} !/(_modules|css|files|ico|img|js)/
RewriteRule ^([^/]*)/([^/]*)$ index.php?p1=$1&p2=$2 [L]
RewriteCond %{REQUEST_FILENAME} !/(_modules|css|files|ico|img|js)/
RewriteRule ^([^/]*)/([^/]*)$ index.php?p1=$1&p2=$2&p3=$3 [L]
RewriteCond %{REQUEST_FILENAME} !/(_modules|css|files|ico|img|js)/
RewriteRule ^([^/]*)/([^/]*)$ index.php?p1=$1&p2=$2&p3=$3&p4=$4 [L]
Is there a way to simplify this to handle up to a maximum of 4 parameters
with all of them being optional? Which leads me to me next problem that it
seems that if you need to have a trailing slash after the parameters
unless you are using all 4 parameters.
In short I would like my urls to look like this...
http://www.example.com/home
http://www.example.com/home/
http://www.example.com/blog/i-am-a-title
http://www.example.com/blog/i-am-a-title/
http://www.example.com/varable1/varable2/varable3/varable4
http://www.example.com/varable1/varable2/varable3/varable4/
I'll appreciate any help that you can provide.
I am writing my very first htaccess and would like help cleaning it up and
understanding it. The first issue I am having is with mulitple parameters.
my current setup looks like:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !/(_modules|css|files|ico|img|js)/
RewriteRule ^([^/]*)/([^/]*)$ index.php?p1=$1 [L]
RewriteCond %{REQUEST_FILENAME} !/(_modules|css|files|ico|img|js)/
RewriteRule ^([^/]*)/([^/]*)$ index.php?p1=$1&p2=$2 [L]
RewriteCond %{REQUEST_FILENAME} !/(_modules|css|files|ico|img|js)/
RewriteRule ^([^/]*)/([^/]*)$ index.php?p1=$1&p2=$2&p3=$3 [L]
RewriteCond %{REQUEST_FILENAME} !/(_modules|css|files|ico|img|js)/
RewriteRule ^([^/]*)/([^/]*)$ index.php?p1=$1&p2=$2&p3=$3&p4=$4 [L]
Is there a way to simplify this to handle up to a maximum of 4 parameters
with all of them being optional? Which leads me to me next problem that it
seems that if you need to have a trailing slash after the parameters
unless you are using all 4 parameters.
In short I would like my urls to look like this...
http://www.example.com/home
http://www.example.com/home/
http://www.example.com/blog/i-am-a-title
http://www.example.com/blog/i-am-a-title/
http://www.example.com/varable1/varable2/varable3/varable4
http://www.example.com/varable1/varable2/varable3/varable4/
I'll appreciate any help that you can provide.
Disable click Youtube iframe
Disable click Youtube iframe
I need to disable click of the Youtube iframe or set difference click.
I tried to put a div in front the iframe but it doesn't work.
Here is my code:
$(".youtube").each(function () {
var div = this;
var offset = $(this).offset();
var x = offset.left;
var y = offset.top;
var height = $(this).height();
var width = $(this).width();
var divInFront = '<div style="position:absolute; height:' + height +
'; width:' + width + '; top:' + y + '; left:' + x + ';" ></div>';
$("body").append(divInFront);
});
I need to disable click of the Youtube iframe or set difference click.
I tried to put a div in front the iframe but it doesn't work.
Here is my code:
$(".youtube").each(function () {
var div = this;
var offset = $(this).offset();
var x = offset.left;
var y = offset.top;
var height = $(this).height();
var width = $(this).width();
var divInFront = '<div style="position:absolute; height:' + height +
'; width:' + width + '; top:' + y + '; left:' + x + ';" ></div>';
$("body").append(divInFront);
});
Sunday, 18 August 2013
Adding an Existing Java Project to Git repo
Adding an Existing Java Project to Git repo
Alright, I'm about to go completely insane about this.
I'm trying to add an existing java project from the workspace to my git
repository. I do the usual, it's all:
git init/committed/remote origin/pushed
however
The only thing appearing is an empty folder. Why? I've been googling for
far too long than I dare to admit but without success.
How do I add a folder, with quite a lot of subfolders, to my github repo.
I'm using git version 1.8.3.2 on Linux
Thanks in advance.
Alright, I'm about to go completely insane about this.
I'm trying to add an existing java project from the workspace to my git
repository. I do the usual, it's all:
git init/committed/remote origin/pushed
however
The only thing appearing is an empty folder. Why? I've been googling for
far too long than I dare to admit but without success.
How do I add a folder, with quite a lot of subfolders, to my github repo.
I'm using git version 1.8.3.2 on Linux
Thanks in advance.
convert co-ordinate d-m-s to decimal degrees using awk
convert co-ordinate d-m-s to decimal degrees using awk
My input is a tab-separated text file with lat long in D-M-S. I require
output to be in decimal degrees I have code in php, but this is very slow
to calculate. Can this be done quicker using awk?
node name id latitude longitude seq
nodex name1 70 N53-24-31.126 W6-20-46.982 59126
nodex name2 173 N53-20-28.885 W6-14-52.400 16190X
nodex name3 173 N53-20-28.885 W6-14-52.400 16191T
Formula:
if ($dirLat == 'N') {$signLat = '+';} Else {$signLat = '-';}
if ($dirLat == 'E') {$signLon = '+';} Else {$signLon = '-';}
$latitudeDecimalDeg = $signLat . ($degLat + ($minLat/60) + ($secLat/3600));
$longitudeDecimalDeg = $signLon . ($degLon + ($minLon/60) + ($secLon/3600));
My input is a tab-separated text file with lat long in D-M-S. I require
output to be in decimal degrees I have code in php, but this is very slow
to calculate. Can this be done quicker using awk?
node name id latitude longitude seq
nodex name1 70 N53-24-31.126 W6-20-46.982 59126
nodex name2 173 N53-20-28.885 W6-14-52.400 16190X
nodex name3 173 N53-20-28.885 W6-14-52.400 16191T
Formula:
if ($dirLat == 'N') {$signLat = '+';} Else {$signLat = '-';}
if ($dirLat == 'E') {$signLon = '+';} Else {$signLon = '-';}
$latitudeDecimalDeg = $signLat . ($degLat + ($minLat/60) + ($secLat/3600));
$longitudeDecimalDeg = $signLon . ($degLon + ($minLon/60) + ($secLon/3600));
@font-face issues with Firefox
@font-face issues with Firefox
It may only be an issue with Firefox but whenever visiting the site using
www. as a prefix the embedded fonts don't load even when using an absolute
path.
I don't know if there are ways to reinforce this using CSS or there is
some kind of DNS issues with the www. that I need to edit, but I'm all out
of options of how to fix this.
could anyone share some help with this?
http://garrettlockhart.com http://www.garrettlockhart.com
@font-face {
font-family: 'Book';
src: url('fonts/futurastdbook.eot');
src: local('☺'), url('fonts/futurastdbook.woff') format('woff'),
url('fonts/futurastdbook.ttf') format('truetype'),
url('fonts/futurastdbook.svg') format('svg');
}
@font-face {
font-family: 'Bold';
src: url('fonts/FuturaStd-Bold.eot');
src: local('☺'), url('fonts/FuturaStd-Bold.woff')
format('woff'), url('fonts/FuturaStd-Bold.ttf') format('truetype'),
url('fonts/FuturaStd-Bold.svg') format('svg');
}
@font-face {
font-family: 'Medium';
src: url('fonts/futurastdmedium.eot');
src: local('☺'), url('fonts/futurastdmedium.woff')
format('woff'), url('fonts/futurastdmedium.ttf') format('truetype'),
url('fonts/futurastdmedium.svg') format('svg');
}
It may only be an issue with Firefox but whenever visiting the site using
www. as a prefix the embedded fonts don't load even when using an absolute
path.
I don't know if there are ways to reinforce this using CSS or there is
some kind of DNS issues with the www. that I need to edit, but I'm all out
of options of how to fix this.
could anyone share some help with this?
http://garrettlockhart.com http://www.garrettlockhart.com
@font-face {
font-family: 'Book';
src: url('fonts/futurastdbook.eot');
src: local('☺'), url('fonts/futurastdbook.woff') format('woff'),
url('fonts/futurastdbook.ttf') format('truetype'),
url('fonts/futurastdbook.svg') format('svg');
}
@font-face {
font-family: 'Bold';
src: url('fonts/FuturaStd-Bold.eot');
src: local('☺'), url('fonts/FuturaStd-Bold.woff')
format('woff'), url('fonts/FuturaStd-Bold.ttf') format('truetype'),
url('fonts/FuturaStd-Bold.svg') format('svg');
}
@font-face {
font-family: 'Medium';
src: url('fonts/futurastdmedium.eot');
src: local('☺'), url('fonts/futurastdmedium.woff')
format('woff'), url('fonts/futurastdmedium.ttf') format('truetype'),
url('fonts/futurastdmedium.svg') format('svg');
}
WSO2 Identity Server REST and SOAP call
WSO2 Identity Server REST and SOAP call
WSO2 Identity Server : I am new to WSO2 Identity Server. Could somebody
help to get list of REST call and soap call supported by WSO2 Identity
Server
WSO2 Identity Server : I am new to WSO2 Identity Server. Could somebody
help to get list of REST call and soap call supported by WSO2 Identity
Server
How to use generic delegates in C#
How to use generic delegates in C#
I have these classes:
public interface IPerson
{
string Name { get; set; }
}
public class Person : IPerson
{
public string Name { get; set; }
}
public interface IRoom
{
List<Furniture> Furnitures { get; set; }
List<Person> People { get; set; }
}
public class Room : IRoom
{
public List<Furniture> Furnitures { get; set; }
public List<Person> People { get; set; }
}
public enum Furniture
{
Table,
Chair
}
And I have this extension method:
public static void Assign<T>(this IRoom sender, Func<IRoom,ICollection<T>>
property, T value)
{
// How do I actually add a Chair to the List<Furniture>?
}
And I want to use it like this:
var room = new Room();
room.Assign(x => x.Furnitures, Furniture.Chair);
room.Assign(x => x.People, new Person() { Name = "Joe" });
But I have no idea how to add T to ICollection.
Trying to learn generics and delegates. I know
room.Furnitures.Add(Furniture.Chair) works better :)
I have these classes:
public interface IPerson
{
string Name { get; set; }
}
public class Person : IPerson
{
public string Name { get; set; }
}
public interface IRoom
{
List<Furniture> Furnitures { get; set; }
List<Person> People { get; set; }
}
public class Room : IRoom
{
public List<Furniture> Furnitures { get; set; }
public List<Person> People { get; set; }
}
public enum Furniture
{
Table,
Chair
}
And I have this extension method:
public static void Assign<T>(this IRoom sender, Func<IRoom,ICollection<T>>
property, T value)
{
// How do I actually add a Chair to the List<Furniture>?
}
And I want to use it like this:
var room = new Room();
room.Assign(x => x.Furnitures, Furniture.Chair);
room.Assign(x => x.People, new Person() { Name = "Joe" });
But I have no idea how to add T to ICollection.
Trying to learn generics and delegates. I know
room.Furnitures.Add(Furniture.Chair) works better :)
Subscribe to:
Comments (Atom)