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
deprecated warnings in xcode and how to handle depracation
deprecated warnings in xcode and how to handle depracation
if ([self
respondsToSelector:@selector(dismissViewControllerAnimated:completion:)])
{[[self presentingViewController] dismissViewControllerAnimated:YES
completion:nil];} //post-iOS6.0
else {[self dismissModalViewControllerAnimated:YES];} //pre-iOS6.0
I'm doing the responds to selector (above) code to handle deprecated
methods. That way my app is compatible with older versions of iOS, but I'm
getting warnings in my code stating:
"'dismissModalViewControllerAnimated:' is deprecated: first deprecated in
iOS 6.0" I personally don't like any warning in my code, but more
importantly, I read somewhere that apple will complain about warnings in
your code.
1) Will Apple complain about warnings in your code?
2) Am I handling deprecated methods correctly?
3) Is there way to turn deprecated method method warnings off?
if ([self
respondsToSelector:@selector(dismissViewControllerAnimated:completion:)])
{[[self presentingViewController] dismissViewControllerAnimated:YES
completion:nil];} //post-iOS6.0
else {[self dismissModalViewControllerAnimated:YES];} //pre-iOS6.0
I'm doing the responds to selector (above) code to handle deprecated
methods. That way my app is compatible with older versions of iOS, but I'm
getting warnings in my code stating:
"'dismissModalViewControllerAnimated:' is deprecated: first deprecated in
iOS 6.0" I personally don't like any warning in my code, but more
importantly, I read somewhere that apple will complain about warnings in
your code.
1) Will Apple complain about warnings in your code?
2) Am I handling deprecated methods correctly?
3) Is there way to turn deprecated method method warnings off?
std::vector's push_back() causing a strange compile-time error message
std::vector's push_back() causing a strange compile-time error message
My snippet of code:
void
RMWavefrontFileImporter::loadVerticeIntoVector(const
std::vector<std:string> lineElements,
std::vector<const
RM3DVertice>* vertices)
{
assert(vertices);
std::unique_ptr<const RM3DVertice> verticeRef =
verticeWithElements(lineElements);
const RM3DVertice* vertice = verticeRef.get();
assert(vertice);
vertices->push_back(*vertice);
}
The error message I'm getting:
"Cannot initialize a parameter of type 'void *' with an lvalue of type
'const RM3DVertice *'"
I'm failing to see the problem. Is there anything obvious I'm missing?
My snippet of code:
void
RMWavefrontFileImporter::loadVerticeIntoVector(const
std::vector<std:string> lineElements,
std::vector<const
RM3DVertice>* vertices)
{
assert(vertices);
std::unique_ptr<const RM3DVertice> verticeRef =
verticeWithElements(lineElements);
const RM3DVertice* vertice = verticeRef.get();
assert(vertice);
vertices->push_back(*vertice);
}
The error message I'm getting:
"Cannot initialize a parameter of type 'void *' with an lvalue of type
'const RM3DVertice *'"
I'm failing to see the problem. Is there anything obvious I'm missing?
Error rvm CLI may not be called from within /etc/rvmrc
Error rvm CLI may not be called from within /etc/rvmrc
After installing a multiuser (systemwide) RVM on Fedora 17 I get the
following error when logging in:
Error:
/etc/rvmrc is for rvm settings only.
rvm CLI may NOT be called from within /etc/rvmrc.
Skipping the loading of /etc/rvmrc
and the following when logging out:
bash: return: can only `return' from a function or sourced script
My /etc/rvmrc file is
umask u=rwx,g=rwx,o=rx
I've searched Google and SO for answers and all that I find do not appear
to be relevant to this case, they are mostly OSX.
Does anyone know the cause of this?
After installing a multiuser (systemwide) RVM on Fedora 17 I get the
following error when logging in:
Error:
/etc/rvmrc is for rvm settings only.
rvm CLI may NOT be called from within /etc/rvmrc.
Skipping the loading of /etc/rvmrc
and the following when logging out:
bash: return: can only `return' from a function or sourced script
My /etc/rvmrc file is
umask u=rwx,g=rwx,o=rx
I've searched Google and SO for answers and all that I find do not appear
to be relevant to this case, they are mostly OSX.
Does anyone know the cause of this?
android: getView() calls items already deleted
android: getView() calls items already deleted
I have some troubles with my ListView. I've made my own Adapter to display
my custom item, with his getView() method. Basically i inserted a certain
number of items at the lunching of the app and then I made my own Thread
to load data from Internet, in order to update the old contents. The
problem is the follow: when i try to clear all the old items (to replace
them with the new data of the thread) then i got a null point exception,
probably caused by getView that call and already deleted item position (or
at least is my interpretation). Follow the code:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.risultati);
myList = new ArrayList<RisultatiClass>();
populateList();
populateListView();
}
private void populateListView() {
// TODO Auto-generated method stub
adapter = new MyListAdapter();
myListView = (ListView) findViewById(R.id.listViewRisultati);
myListView.setAdapter(adapter);
}
private void populateList() {
Thread thread = new Thread()
{
@Override
public void run() {
String str = ConnectionOperations.getUrlHtml("http://gradio...");
String[] colonne = str.split("!");
String[] sq1 = colonne[0].split(",");
String[] sq2 = colonne[1].split(",");
String[] gf1 = colonne[2].split(",");
String[] gf2 = colonne[3].split(",");
String[] ts = colonne[4].split(",");
Log.w("myApp", ""+myList.size()+"");
myList.clear();
adapter.notifyDataSetChanged();
Log.w("myApp", ""+myList.size()+"");
for (int i=0; i<sq1.length; i++){
myList.add(i,new
RisultatiClass(sq1[i],sq2[i],gf1[i],gf2[i],ts[i]));
}
}
};
thread.start();
// TODO Auto-generated method stub
myList.add(new RisultatiClass("Roma AA","Lazio","2","3","Mag 21:00"));
myList.add(new RisultatiClass("Napoli AA","Milan","0","5","Mag 21:00"));
myList.add(new RisultatiClass("Napoli","Milan","0","5",""));
myList.add(new RisultatiClass("Napoli","Milan","0","5",""));
myList.add(new RisultatiClass("Napoli","Milan","0","5",""));
myList.add(new RisultatiClass("Napoli","Milan","0","5",""));
}
//definisco l'adapter
private class MyListAdapter extends ArrayAdapter<RisultatiClass>{
public MyListAdapter(){
super(Risultati.this,R.layout.risultati_row,myList);
}
@Override
public View getView(int position,View convertView,ViewGroup parent){
//make sure we have a view to work with
View itemView = convertView;
if(itemView==null){
itemView = getLayoutInflater().inflate(R.layout.risultati_row,
parent,false);
}
//find the items
RisultatiClass currentItem = myList.get(position);
//fill the view
TextView sq1 = (TextView) itemView.findViewById(R.id.risultatiSq1);
sq1.setText(currentItem.getSq1());
TextView sq2 = (TextView) itemView.findViewById(R.id.risultatiSq2);
sq2.setText(currentItem.getSq2());
TextView ris1 = (TextView) itemView.findViewById(R.id.risultatiRis1);
ris1.setText(currentItem.getRis1());
TextView ris2 = (TextView) itemView.findViewById(R.id.risultatiRis2);
ris2.setText(currentItem.getRis2());
TextView timeStamp = (TextView)
itemView.findViewById(R.id.risultatiTimeStamp);
timeStamp.setText(currentItem.getTimeStamp());
return itemView;
}
Do you guys see any error? this is the log: 08-31 19:00:57.620:
E/AndroidRuntime(1416): java.lang.IndexOutOfBoundsException: Invalid index
3, size is 3 08-31 19:00:57.620: E/AndroidRuntime(1416): at
java.util.ArrayList.get(ArrayList.java:308)
I have some troubles with my ListView. I've made my own Adapter to display
my custom item, with his getView() method. Basically i inserted a certain
number of items at the lunching of the app and then I made my own Thread
to load data from Internet, in order to update the old contents. The
problem is the follow: when i try to clear all the old items (to replace
them with the new data of the thread) then i got a null point exception,
probably caused by getView that call and already deleted item position (or
at least is my interpretation). Follow the code:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.risultati);
myList = new ArrayList<RisultatiClass>();
populateList();
populateListView();
}
private void populateListView() {
// TODO Auto-generated method stub
adapter = new MyListAdapter();
myListView = (ListView) findViewById(R.id.listViewRisultati);
myListView.setAdapter(adapter);
}
private void populateList() {
Thread thread = new Thread()
{
@Override
public void run() {
String str = ConnectionOperations.getUrlHtml("http://gradio...");
String[] colonne = str.split("!");
String[] sq1 = colonne[0].split(",");
String[] sq2 = colonne[1].split(",");
String[] gf1 = colonne[2].split(",");
String[] gf2 = colonne[3].split(",");
String[] ts = colonne[4].split(",");
Log.w("myApp", ""+myList.size()+"");
myList.clear();
adapter.notifyDataSetChanged();
Log.w("myApp", ""+myList.size()+"");
for (int i=0; i<sq1.length; i++){
myList.add(i,new
RisultatiClass(sq1[i],sq2[i],gf1[i],gf2[i],ts[i]));
}
}
};
thread.start();
// TODO Auto-generated method stub
myList.add(new RisultatiClass("Roma AA","Lazio","2","3","Mag 21:00"));
myList.add(new RisultatiClass("Napoli AA","Milan","0","5","Mag 21:00"));
myList.add(new RisultatiClass("Napoli","Milan","0","5",""));
myList.add(new RisultatiClass("Napoli","Milan","0","5",""));
myList.add(new RisultatiClass("Napoli","Milan","0","5",""));
myList.add(new RisultatiClass("Napoli","Milan","0","5",""));
}
//definisco l'adapter
private class MyListAdapter extends ArrayAdapter<RisultatiClass>{
public MyListAdapter(){
super(Risultati.this,R.layout.risultati_row,myList);
}
@Override
public View getView(int position,View convertView,ViewGroup parent){
//make sure we have a view to work with
View itemView = convertView;
if(itemView==null){
itemView = getLayoutInflater().inflate(R.layout.risultati_row,
parent,false);
}
//find the items
RisultatiClass currentItem = myList.get(position);
//fill the view
TextView sq1 = (TextView) itemView.findViewById(R.id.risultatiSq1);
sq1.setText(currentItem.getSq1());
TextView sq2 = (TextView) itemView.findViewById(R.id.risultatiSq2);
sq2.setText(currentItem.getSq2());
TextView ris1 = (TextView) itemView.findViewById(R.id.risultatiRis1);
ris1.setText(currentItem.getRis1());
TextView ris2 = (TextView) itemView.findViewById(R.id.risultatiRis2);
ris2.setText(currentItem.getRis2());
TextView timeStamp = (TextView)
itemView.findViewById(R.id.risultatiTimeStamp);
timeStamp.setText(currentItem.getTimeStamp());
return itemView;
}
Do you guys see any error? this is the log: 08-31 19:00:57.620:
E/AndroidRuntime(1416): java.lang.IndexOutOfBoundsException: Invalid index
3, size is 3 08-31 19:00:57.620: E/AndroidRuntime(1416): at
java.util.ArrayList.get(ArrayList.java:308)
jQuery UI Drag n Drop failed to lock
jQuery UI Drag n Drop failed to lock
Basically I have an image (droppable) and text (draggable). They are
matched by the data-pair attribute I've set on them. However, when I try
to console.log($(this).data('pair')) inside the drop callback, it gives
undefined. This is my code.
function handleDrop(event, ui, cb) {
console.log( $(this).data('pair') );
console.log( $(this).attr('data-pair') );
console.log( ui.draggable.data('pair') );
var dropped = $(this).data('pair');
var dragged = ui.draggable.data('pair');
var match = false;
if(dragged === dropped) {
//Match - Lock in place and increment found
match = true;
$(this).droppable( 'disable' );
ui.draggable.addClass( 'correct' );
ui.draggable.draggable( 'disable' );
ui.draggable.draggable( 'option', 'revert', false );
ui.draggable.position({
of: $(this),
my: 'left top',
at: 'left top'
});
} else {
ui.draggable.draggable( 'option', 'revert', true );
}
cb(match);
}
//Create Droppables (image + droppable div)
//imgContainer = #imgWrapper
var tempImgContainer = $('<div id="imgContainer' + i + '"></div>');
$('<img id="img' + i + '" src="' + key + '">').appendTo(tempImgContainer);
$('<div id="textForImg' + i + '" data-pair="' + i + '"></div>').droppable({
accept: '#textWrapper div',
hoverClass: 'hovered',
drop: function(event, ui) {
handleDrop(event, ui, callback);
}
}).appendTo(tempImgContainer);
$(imgContainer).append(tempImgContainer);
//Create Draggable
//textContainer = #textWrapper
var tempTextContainer = $('<div id="textContainer' + i + '" data-pair="' +
i + '">' + val + '</div>').draggable({
//quizContainer is a wrapper for both imgWrapper and textWrapper.
Example #quizContainer1
containment: quizContainer,
stack: '#textWrapper div',
cursor: 'move',
revert: true,
snap: true
});
$(textContainer).append(tempTextContainer);
i += 1;
Basically I have an image (droppable) and text (draggable). They are
matched by the data-pair attribute I've set on them. However, when I try
to console.log($(this).data('pair')) inside the drop callback, it gives
undefined. This is my code.
function handleDrop(event, ui, cb) {
console.log( $(this).data('pair') );
console.log( $(this).attr('data-pair') );
console.log( ui.draggable.data('pair') );
var dropped = $(this).data('pair');
var dragged = ui.draggable.data('pair');
var match = false;
if(dragged === dropped) {
//Match - Lock in place and increment found
match = true;
$(this).droppable( 'disable' );
ui.draggable.addClass( 'correct' );
ui.draggable.draggable( 'disable' );
ui.draggable.draggable( 'option', 'revert', false );
ui.draggable.position({
of: $(this),
my: 'left top',
at: 'left top'
});
} else {
ui.draggable.draggable( 'option', 'revert', true );
}
cb(match);
}
//Create Droppables (image + droppable div)
//imgContainer = #imgWrapper
var tempImgContainer = $('<div id="imgContainer' + i + '"></div>');
$('<img id="img' + i + '" src="' + key + '">').appendTo(tempImgContainer);
$('<div id="textForImg' + i + '" data-pair="' + i + '"></div>').droppable({
accept: '#textWrapper div',
hoverClass: 'hovered',
drop: function(event, ui) {
handleDrop(event, ui, callback);
}
}).appendTo(tempImgContainer);
$(imgContainer).append(tempImgContainer);
//Create Draggable
//textContainer = #textWrapper
var tempTextContainer = $('<div id="textContainer' + i + '" data-pair="' +
i + '">' + val + '</div>').draggable({
//quizContainer is a wrapper for both imgWrapper and textWrapper.
Example #quizContainer1
containment: quizContainer,
stack: '#textWrapper div',
cursor: 'move',
revert: true,
snap: true
});
$(textContainer).append(tempTextContainer);
i += 1;
Some problems about Python 2.x
Some problems about Python 2.x
I have some problems about the dictionary Here my code:
tyler = { "name": "Tyler", "homework": [0.0, 87.0, 75.0, 22.0], "quizzes":
[0.0, 75.0, 78.0], "tests": [100.0, 100.0] }
def average (number): total = 0.0 for i in number: total = total +
number[i] return total/ len(number)
def get_average(student): return average(student["homework"])*0.1 +
average(student["quizzes"])*0.3 + average(student["tests"])*0.6
print get_average(tyler)
The error: TypeError: list indices must be integers, not float
Can anyone help me?? I don't know how to fix it?? Thank you so much.
I have some problems about the dictionary Here my code:
tyler = { "name": "Tyler", "homework": [0.0, 87.0, 75.0, 22.0], "quizzes":
[0.0, 75.0, 78.0], "tests": [100.0, 100.0] }
def average (number): total = 0.0 for i in number: total = total +
number[i] return total/ len(number)
def get_average(student): return average(student["homework"])*0.1 +
average(student["quizzes"])*0.3 + average(student["tests"])*0.6
print get_average(tyler)
The error: TypeError: list indices must be integers, not float
Can anyone help me?? I don't know how to fix it?? Thank you so much.
Friday, 30 August 2013
combo box items need to be updated after saving an new item from another tab
combo box items need to be updated after saving an new item from another tab
I have 2 tabs in a window form using Microsoft Visual Studio 2008.1st tab
is about Group.2nd tab is about Category.In 1st tab,I've already finished
to save,delete and update group data into "Group_tbl".In 2nd tab,I have a
group name combo box that is databinding with "Group_tbl" display "group
name" Group_tbl contains following fields. group_id group_name
group_description
The problem is - Unexpectedly,I need to save new group while I'm working
on 2nd tab.So,I go to 1st tab and saving group_id >>> "Med",group name >>>
"Medicine".Data saved successfully.Then,I go back into 2nd tab.The combo
box I'm binding with group_tbl is not updated.It's needed keeping update
after adding new entry.I realize it's updated when I close the program and
reload it.But,it's not convenient for users.I've tested refresh()
method.Nothing changed.There's no coding to show because the combo box is
mostly done by assigning properties in design form.I also tried this -
Private Sub cboCatGroupName_MouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles cboCatGroupName.MouseClick
GetDataConn(".\SQLEXPRESS", "rightstock", True)
Dim dataadapter As New SqlDataAdapter("SELECT group_name FROM
group_tbl", sqlConn)
Dim ds As New DataSet()
dataadapter.Fill(ds, "group_tbl")
sqlConn.Close()
cboCatGroupName.DataSource = ds
cboCatGroupName.DisplayMember = "group_tbl"
It doesn't show any error.And it's not updated.Actually,this is my first
time experience with databound combo box.I think I have a problem in
handling events and data adapter filling.
So,I'll be glad if somebody helps me.Really appreciate for all advices and
thank you all.
I have 2 tabs in a window form using Microsoft Visual Studio 2008.1st tab
is about Group.2nd tab is about Category.In 1st tab,I've already finished
to save,delete and update group data into "Group_tbl".In 2nd tab,I have a
group name combo box that is databinding with "Group_tbl" display "group
name" Group_tbl contains following fields. group_id group_name
group_description
The problem is - Unexpectedly,I need to save new group while I'm working
on 2nd tab.So,I go to 1st tab and saving group_id >>> "Med",group name >>>
"Medicine".Data saved successfully.Then,I go back into 2nd tab.The combo
box I'm binding with group_tbl is not updated.It's needed keeping update
after adding new entry.I realize it's updated when I close the program and
reload it.But,it's not convenient for users.I've tested refresh()
method.Nothing changed.There's no coding to show because the combo box is
mostly done by assigning properties in design form.I also tried this -
Private Sub cboCatGroupName_MouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles cboCatGroupName.MouseClick
GetDataConn(".\SQLEXPRESS", "rightstock", True)
Dim dataadapter As New SqlDataAdapter("SELECT group_name FROM
group_tbl", sqlConn)
Dim ds As New DataSet()
dataadapter.Fill(ds, "group_tbl")
sqlConn.Close()
cboCatGroupName.DataSource = ds
cboCatGroupName.DisplayMember = "group_tbl"
It doesn't show any error.And it's not updated.Actually,this is my first
time experience with databound combo box.I think I have a problem in
handling events and data adapter filling.
So,I'll be glad if somebody helps me.Really appreciate for all advices and
thank you all.
Thursday, 29 August 2013
Can i have a second partition with a full system in it, encrypted with FileVault/Truecrypt/Whatever?
Can i have a second partition with a full system in it, encrypted with
FileVault/Truecrypt/Whatever?
I would like to have a second partition in my laptop. The second
partition, differently from the first one, should be encrypted at a boot
level. It will contain all my work stuff.
Is it possible?
Is it secure?
FileVault/Truecrypt/Whatever?
I would like to have a second partition in my laptop. The second
partition, differently from the first one, should be encrypted at a boot
level. It will contain all my work stuff.
Is it possible?
Is it secure?
how much white is a frame using OpenCV
how much white is a frame using OpenCV
I have a GRAY image and I want to know the percentage of the white color
on it. I know that I can do these with two for-loop that check the color
of each pixel, but I was wondring if there any better method to do this ?
here is an example the image that I want to analyze :
I have a GRAY image and I want to know the percentage of the white color
on it. I know that I can do these with two for-loop that check the color
of each pixel, but I was wondring if there any better method to do this ?
here is an example the image that I want to analyze :
Failed to create sessionFactory object.org.hibernate.InvalidMappingException: Could not parse mapping document from resource Employee.hbm...
Failed to create sessionFactory
object.org.hibernate.InvalidMappingException: Could not parse mapping
document from resource Employee.hbm...
Here is my Employee.hbm.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package = "com.demo.hibernate.beans">
<class name="Employee" table="employee">
<meta attribute="class-description">
This class contains the employee detail.
</meta>
<id name="id" type="int" column="id">
<generator class="native"/>
</id>
<property name="firstName" column="first_name" type="string"/>
<property name="lastName" column="last_name" type="string"/>
<property name="salary" column="salary" type="int"/>
</class>
</hibernate-mapping>
While running hibernate i get the following exception
Failed to create sessionFactory
object.org.hibernate.InvalidMappingException: Could not parse mapping
document from resource Employee.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.demo.hibernate.beans.ManageEmployee.main(ManageEmployee.java:20)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping
document from resource Employee.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:575)
at
org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1593)
at
org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1561)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1540)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1514)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1434)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1420)
at com.demo.hibernate.beans.ManageEmployee.main(ManageEmployee.java:17)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping
document from input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:514)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:572)
... 7 more
Caused by: org.dom4j.DocumentException: www.hibernate.org Nested
exception: www.hibernate.org
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:505)
... 8 more
What can be the possible reason ?
object.org.hibernate.InvalidMappingException: Could not parse mapping
document from resource Employee.hbm...
Here is my Employee.hbm.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package = "com.demo.hibernate.beans">
<class name="Employee" table="employee">
<meta attribute="class-description">
This class contains the employee detail.
</meta>
<id name="id" type="int" column="id">
<generator class="native"/>
</id>
<property name="firstName" column="first_name" type="string"/>
<property name="lastName" column="last_name" type="string"/>
<property name="salary" column="salary" type="int"/>
</class>
</hibernate-mapping>
While running hibernate i get the following exception
Failed to create sessionFactory
object.org.hibernate.InvalidMappingException: Could not parse mapping
document from resource Employee.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.demo.hibernate.beans.ManageEmployee.main(ManageEmployee.java:20)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping
document from resource Employee.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:575)
at
org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1593)
at
org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1561)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1540)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1514)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1434)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1420)
at com.demo.hibernate.beans.ManageEmployee.main(ManageEmployee.java:17)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping
document from input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:514)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:572)
... 7 more
Caused by: org.dom4j.DocumentException: www.hibernate.org Nested
exception: www.hibernate.org
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:505)
... 8 more
What can be the possible reason ?
Wednesday, 28 August 2013
Searchf for Min and Max Age php Mysqli
Searchf for Min and Max Age php Mysqli
I already tried many times to look for information about searching in php
for min and max age from mysql database, but i can't find right
information what i need. First, i will explain what i mean and what i
want.
My database is as follows:
Db Name: Db_Name Table: users Column: age
I am writing a php script to let give a user option to fill in what he/she
want to search from (min)age to (max)age and as result, he gets a list
that shows all users from that (min)age to (max)age.
Example, he/she selected: 21-30 Then the list shows users with age:
21,22,23,24,25,26,27,28,29,30
For now, what i already did try is this:
<?php
$db = new mysqli('localhost', 'root', '', 'traindb');
$db->select_db("traindb");
if($db->connect_errno > 0) {
die('Er is een fout opgetreden: ' . $db->connect_error);
}
function leeftijden($age) {
$morgen['day'] = date('d');
$morgen['month'] = date('m');
$morgen['year'] = date('Y') - $age;
$datum = $morgen['day'] .'-' .$morgen['month'].'-' .$morgen['year'];
return $datum;
}
$maxDatum = leeftijden(18);
$minDatum = leeftijden(32);
$sqlRijder = 'SELECT * FROM users WHERE age BETWEEN CURDATE() - INTERVAL
'.$minDatum.' YEAR AND CURDATE() - INTERVAL '.$maxDatum.' YEAR';
if ($result = $db->query($sqlRijder)) {
printf("Select returned %d rows.\n", $result->num_rows);
$result->close();
}
$db->close();
?>
As result i get: Select returned 0 rows.
What am i doing wrong? Can anyone explain me how to this in right way?
Thanks!
I already tried many times to look for information about searching in php
for min and max age from mysql database, but i can't find right
information what i need. First, i will explain what i mean and what i
want.
My database is as follows:
Db Name: Db_Name Table: users Column: age
I am writing a php script to let give a user option to fill in what he/she
want to search from (min)age to (max)age and as result, he gets a list
that shows all users from that (min)age to (max)age.
Example, he/she selected: 21-30 Then the list shows users with age:
21,22,23,24,25,26,27,28,29,30
For now, what i already did try is this:
<?php
$db = new mysqli('localhost', 'root', '', 'traindb');
$db->select_db("traindb");
if($db->connect_errno > 0) {
die('Er is een fout opgetreden: ' . $db->connect_error);
}
function leeftijden($age) {
$morgen['day'] = date('d');
$morgen['month'] = date('m');
$morgen['year'] = date('Y') - $age;
$datum = $morgen['day'] .'-' .$morgen['month'].'-' .$morgen['year'];
return $datum;
}
$maxDatum = leeftijden(18);
$minDatum = leeftijden(32);
$sqlRijder = 'SELECT * FROM users WHERE age BETWEEN CURDATE() - INTERVAL
'.$minDatum.' YEAR AND CURDATE() - INTERVAL '.$maxDatum.' YEAR';
if ($result = $db->query($sqlRijder)) {
printf("Select returned %d rows.\n", $result->num_rows);
$result->close();
}
$db->close();
?>
As result i get: Select returned 0 rows.
What am i doing wrong? Can anyone explain me how to this in right way?
Thanks!
gcc compiler does not recognize my class when using shared_ptr
gcc compiler does not recognize my class when using shared_ptr
It's strange. I never ran into this problem before. I have a class called
Message. When compile message.cc, it's okay. But when compile another
class sign which uses Message class. GCC outputs error. I list my
commands, the first one succeeds
/usr/bin/c++ -g -I../codes/main/include
-I../codes/main/src/../../loki-0.1.7/include -Wall -o ./o/endian.cc.o -c
../codes/main/src/business/messages/message.cc
The second one failed. I guess gcc don't thinks Message is a valid class.
But why?
/usr/bin/c++ -g -I../codes/main/include
-I../codes/main/src/../../loki-0.1.7/include -Wall -o ./o/sign.cc.o -c
../codes/main/src/business/sign.cc
../codes/main/src/business/sign.cc: In member function 'virtual void
Sign::StartJob()':
../codes/main/src/business/sign.cc:49:21: error: template argument 1 is
invalid
shared_ptr<Message> init_request(new InitRequest());
^
../codes/main/src/business/sign.cc:49:35: error: invalid type in
declaration before '(' token
shared_ptr<Message> init_request(new InitRequest());
^
../codes/main/src/business/sign.cc:49:53: error: invalid conversion from
'InitRequest*' to 'int' [-fpermissive]
shared_ptr<Message> init_request(new InitRequest());
Any idea for profiling this problem?
It's strange. I never ran into this problem before. I have a class called
Message. When compile message.cc, it's okay. But when compile another
class sign which uses Message class. GCC outputs error. I list my
commands, the first one succeeds
/usr/bin/c++ -g -I../codes/main/include
-I../codes/main/src/../../loki-0.1.7/include -Wall -o ./o/endian.cc.o -c
../codes/main/src/business/messages/message.cc
The second one failed. I guess gcc don't thinks Message is a valid class.
But why?
/usr/bin/c++ -g -I../codes/main/include
-I../codes/main/src/../../loki-0.1.7/include -Wall -o ./o/sign.cc.o -c
../codes/main/src/business/sign.cc
../codes/main/src/business/sign.cc: In member function 'virtual void
Sign::StartJob()':
../codes/main/src/business/sign.cc:49:21: error: template argument 1 is
invalid
shared_ptr<Message> init_request(new InitRequest());
^
../codes/main/src/business/sign.cc:49:35: error: invalid type in
declaration before '(' token
shared_ptr<Message> init_request(new InitRequest());
^
../codes/main/src/business/sign.cc:49:53: error: invalid conversion from
'InitRequest*' to 'int' [-fpermissive]
shared_ptr<Message> init_request(new InitRequest());
Any idea for profiling this problem?
Switched one of my machines to Win 8. Now when I try to connect to one of my NAS drives, it requests a PW
Switched one of my machines to Win 8. Now when I try to connect to one of
my NAS drives, it requests a PW
I have three machines, one running Win 7, one Win RT and one Win 8. Both
the Win 7 and Win RT machines can both access both my NAS drives without
any problem.
The machine that is running Win 8 will no longer connect to the Buffalo
NAS drive. It keeps asking for a PW. When this machine was running Win 7 a
short week or so ago, it had no problem. I have assigned no security to
either of my NAS drives. I can see no reason for Win 8 to be asking for a
PW. To make it even odder, the other NAS drive connects just fine without
any problem. It's a Network Space Max drive.
So it would appear that the problem should be with the Buffalo drive and
Win 8 but I cannot find anything on this. Can anyone offer some insight?
Thanks,
Will
my NAS drives, it requests a PW
I have three machines, one running Win 7, one Win RT and one Win 8. Both
the Win 7 and Win RT machines can both access both my NAS drives without
any problem.
The machine that is running Win 8 will no longer connect to the Buffalo
NAS drive. It keeps asking for a PW. When this machine was running Win 7 a
short week or so ago, it had no problem. I have assigned no security to
either of my NAS drives. I can see no reason for Win 8 to be asking for a
PW. To make it even odder, the other NAS drive connects just fine without
any problem. It's a Network Space Max drive.
So it would appear that the problem should be with the Buffalo drive and
Win 8 but I cannot find anything on this. Can anyone offer some insight?
Thanks,
Will
Why does user NT AUTHORITY\LOCAL want to do a local launch of IPBusEnum?
Why does user NT AUTHORITY\LOCAL want to do a local launch of IPBusEnum?
I have Windows Vista Home Premium. A few months ago, I got a message on
boot-up that "Windows could not connect to the System Event Notification
Service" and that "This problem prevents standard users logging on to the
System". The message also suggested looking in the System Event viewer to
find the reason it occurred. Among various errors that I found was "The
application-specific permission settings do not grant Local Launch
permission for the COM Server application with CLSID
{C97FCC79-E628-407D-AE68-A06AD6D8B4D1} to the user NT AUTHORITY\LOCAL
SERVICE SID (S-1-5-19) from address LocalHost (Using LRPC). This security
permission can be modified using the Component Services administrative
tool."
I browsed the web and found many suggestions for "curing" the problem,
none of which gave satisfactory explanations as to why it occurred (and is
still occurring). I have found through the registry that the COM Server
application is IPBusEnum.
My questions are:
Why does NT AUTHORITY\LOCAL want to locally launch IPBusEnum?
Why does an apparently powerful user, NT AUTHORITY\LOCAL, need permission
to locally launch IPBusEnum?
Why, if it does not and never has had permission to do this, does Windows
now completely lock out non-Administrators from doing anything?
Could this be a virus or trojan? I am reluctant to grant this permission
without knowing the answers.
I have Windows Vista Home Premium. A few months ago, I got a message on
boot-up that "Windows could not connect to the System Event Notification
Service" and that "This problem prevents standard users logging on to the
System". The message also suggested looking in the System Event viewer to
find the reason it occurred. Among various errors that I found was "The
application-specific permission settings do not grant Local Launch
permission for the COM Server application with CLSID
{C97FCC79-E628-407D-AE68-A06AD6D8B4D1} to the user NT AUTHORITY\LOCAL
SERVICE SID (S-1-5-19) from address LocalHost (Using LRPC). This security
permission can be modified using the Component Services administrative
tool."
I browsed the web and found many suggestions for "curing" the problem,
none of which gave satisfactory explanations as to why it occurred (and is
still occurring). I have found through the registry that the COM Server
application is IPBusEnum.
My questions are:
Why does NT AUTHORITY\LOCAL want to locally launch IPBusEnum?
Why does an apparently powerful user, NT AUTHORITY\LOCAL, need permission
to locally launch IPBusEnum?
Why, if it does not and never has had permission to do this, does Windows
now completely lock out non-Administrators from doing anything?
Could this be a virus or trojan? I am reluctant to grant this permission
without knowing the answers.
How to retrieve images in cache memory?
How to retrieve images in cache memory?
I am using getExternalCacheDir() to store images in cache memory.the cache
images are being stored in sdcard. how to retrieve in image format ?.
I am using getExternalCacheDir() to store images in cache memory.the cache
images are being stored in sdcard. how to retrieve in image format ?.
Tuesday, 27 August 2013
Salesforce REST API without sharing
Salesforce REST API without sharing
I'm getting this error:
Implementation restriction: activity aggregate relationships only allow
security evaluation for non-admin users when a single parent record is
evaluated
When I do this query:
https://na1.salesforce.com/services/data/v28.0/query?q=SELECT Id, (SELECT
Id, Subject, ActivityType, Description FROM ActivityHistories) FROM
Opportunity
After reading this post, I think I need to change public with sharing
class to public without sharing, in APEX. How to achieve this if I'm
issuing REST API through POST request directly?
I'm getting this error:
Implementation restriction: activity aggregate relationships only allow
security evaluation for non-admin users when a single parent record is
evaluated
When I do this query:
https://na1.salesforce.com/services/data/v28.0/query?q=SELECT Id, (SELECT
Id, Subject, ActivityType, Description FROM ActivityHistories) FROM
Opportunity
After reading this post, I think I need to change public with sharing
class to public without sharing, in APEX. How to achieve this if I'm
issuing REST API through POST request directly?
How can constructor definitions from traits collide?
How can constructor definitions from traits collide?
In PHP 5.4.9, the following example triggers the fatal error "B has
colliding constructor definitions coming from traits".
trait T {
public function __construct () {
echo __CLASS__ . ": constructor called.\n";
}
}
class A {
use T;
}
class B extends A {
use T;
}
There's no problem when the trait contains a different method than the
constructor, and no problem when the constructor is actually copied into
the classes (without using traits, the "language-assisted copy & paste"
feature).
What's so special about the constructor here? Shouldn't PHP be able to
figure out that one of them overrides the other? I couldn't find anything
about this limitation in the manual.
This related question mentions a way to get around the problem (by using
aliases for trait methods), but not what's causing it in the first place.
In PHP 5.4.9, the following example triggers the fatal error "B has
colliding constructor definitions coming from traits".
trait T {
public function __construct () {
echo __CLASS__ . ": constructor called.\n";
}
}
class A {
use T;
}
class B extends A {
use T;
}
There's no problem when the trait contains a different method than the
constructor, and no problem when the constructor is actually copied into
the classes (without using traits, the "language-assisted copy & paste"
feature).
What's so special about the constructor here? Shouldn't PHP be able to
figure out that one of them overrides the other? I couldn't find anything
about this limitation in the manual.
This related question mentions a way to get around the problem (by using
aliases for trait methods), but not what's causing it in the first place.
Rspec/Rails: Failure/Error: click_on 'John Huston' ActionView::Template::Error: undefined method `name' for nil:NilClass
Rspec/Rails: Failure/Error: click_on 'John Huston'
ActionView::Template::Error: undefined method `name' for nil:NilClass
I am writing a spec for my rails app but keep getting the following error.
when I run rspec.
Failure/Error: click_on 'John Huston'
ActionView::Template::Error:
undefined method `name' for nil:NilClass
Here is the context for the line in which the error occurs:
it 'should display all entries belonging to a project' do
proj = FactoryGirl.create(:project, name: 'John Huston')
now = Time.now
later = now +3600
entries = 5.times.map do
FactoryGirl.create(:entry, project_id: proj.id, :date => 9/10/13,
:type_of_work => 'chump', :description => 'chumpin',
:phase_id => 8, :status => 'Draft' , :on_off_site
=> 'off', :user_id => 1, :start_time => now,
:end_time => later)
end
other_proj = FactoryGirl.create(:project, name: 'Groucho Marx')
other_entries = 2.times.map do
FactoryGirl.create(:entry, project_id: other_proj.id, :date =>
9/10/13, :type_of_work => 'chump', :description => 'thumpin',
:phase_id => 8, :status => 'Draft' , :on_off_site
=> 'off', :user_id => 1, :start_time => now,
:end_time => later)
end
visit projects_path
save_and_open_page
click_on 'John Huston'
Here is my project model:
class Project < ActiveRecord::Base
attr_accessible :name, :phases_attributes
has_many :entries
has_many :phases
accepts_nested_attributes_for :phases, allow_destroy: true
validates_presence_of :name
default_scope { order('LOWER(name)') }
def entries_by_user(user)
entries.where(:user_id => user.id)
end
def total_hours(user)
entries_by_user(user).map(&:total_time_as_hours).reduce(:+) || 0
end
end
Here are my project controllers:
class ProjectsController < InheritedResources::Base
# GET /projects
# GET /projects.json
def index
@projects = Project.all
authorize! :read, @projects
end
# GET /projects/1
# GET /projects/1.json
def show
@project = Project.find(params[:id])
authorize! :read, @project
end
# GET /projects/new
def new
@project = Project.new
authorize! :create, @project
end
# GET /projects/1/edit
def edit
@project = Project.find(params[:id])
end
# POST /projects
# POST /projects.json
def create
@project = Project.new(params[:project])
authorize! :create, @project
respond_to do |format|
if @project.save
format.html { redirect_to @project, notice: 'Project was
successfully created.' }
format.json { render action: 'show', status: :created, location:
@project }
else
format.html { render action: 'new' }
format.json { render json: @project.errors, status:
:unprocessable_entity }
end
end
end
# PATCH/PUT /projects/1
# PATCH/PUT /projects/1.json
def update
@project = Project.find(params[:id])
authorize! :edit, @project
respond_to do |format|
if @project.update_attributes(params[:project])
format.html { redirect_to @project, notice: 'Project was
successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @project.errors, status:
:unprocessable_entity }
end
end
end
# DELETE /projects/1
# DELETE /projects/1.json
def destroy
@project.destroy
respond_to do |format|
format.html { redirect_to projects_url }
format.json { head :no_content }
end
end
end
Here is my project show template:
%p{id: 'notice'}
= notice
%p
%strong
Project Name:
= @project.name
%ul
Phases:
-if @project.phases
-@project.phases.each do |phase|
%li
= phase.name
%table.entries
%thead
%tr
%th Project
%th User
%th Created By
%th Date
%th Start
%th End
%th Type
%th Status
%th On/Off
%th Phase
%th Description
%th Edit
%th Delete
%tbody
- if current_user
- @project.entries_by_user(current_user).each do |entry|
%tr
%td= entry.project.name
%td= entry.user.email
%td= entry.created_by
%td= entry.date
%td= entry.start_time.to_s(:time)
%td= entry.end_time.to_s(:time)
%td= entry.type_of_work
%td= entry.status
%td= entry.on_off_site
%td= entry.phase.name
%td= entry.description
%td= link_to 'Edit', edit_project_entry_path(:entry=>entry,
:id=>entry.id, :project_id=>@project.id)
%td= link_to 'Delete', entry, method: :delete, data: { confirm:
'Are you sure?' }
= link_to 'New Entry', new_project_entry_path(@project)
= link_to 'Edit', edit_project_path(@project)
= link_to 'Back', projects_path
My first thought was that in the show method of my projects controller
@projects was somehow not being properly set, and therefore was nil and
then when it called @projects.name in the show view, it was getting the
nil error. However, I tried wrapping that call to @projects.name with a if
@project to make sure @project was getting set but I got the same error as
before.
Any ideas?
Thank you!
ActionView::Template::Error: undefined method `name' for nil:NilClass
I am writing a spec for my rails app but keep getting the following error.
when I run rspec.
Failure/Error: click_on 'John Huston'
ActionView::Template::Error:
undefined method `name' for nil:NilClass
Here is the context for the line in which the error occurs:
it 'should display all entries belonging to a project' do
proj = FactoryGirl.create(:project, name: 'John Huston')
now = Time.now
later = now +3600
entries = 5.times.map do
FactoryGirl.create(:entry, project_id: proj.id, :date => 9/10/13,
:type_of_work => 'chump', :description => 'chumpin',
:phase_id => 8, :status => 'Draft' , :on_off_site
=> 'off', :user_id => 1, :start_time => now,
:end_time => later)
end
other_proj = FactoryGirl.create(:project, name: 'Groucho Marx')
other_entries = 2.times.map do
FactoryGirl.create(:entry, project_id: other_proj.id, :date =>
9/10/13, :type_of_work => 'chump', :description => 'thumpin',
:phase_id => 8, :status => 'Draft' , :on_off_site
=> 'off', :user_id => 1, :start_time => now,
:end_time => later)
end
visit projects_path
save_and_open_page
click_on 'John Huston'
Here is my project model:
class Project < ActiveRecord::Base
attr_accessible :name, :phases_attributes
has_many :entries
has_many :phases
accepts_nested_attributes_for :phases, allow_destroy: true
validates_presence_of :name
default_scope { order('LOWER(name)') }
def entries_by_user(user)
entries.where(:user_id => user.id)
end
def total_hours(user)
entries_by_user(user).map(&:total_time_as_hours).reduce(:+) || 0
end
end
Here are my project controllers:
class ProjectsController < InheritedResources::Base
# GET /projects
# GET /projects.json
def index
@projects = Project.all
authorize! :read, @projects
end
# GET /projects/1
# GET /projects/1.json
def show
@project = Project.find(params[:id])
authorize! :read, @project
end
# GET /projects/new
def new
@project = Project.new
authorize! :create, @project
end
# GET /projects/1/edit
def edit
@project = Project.find(params[:id])
end
# POST /projects
# POST /projects.json
def create
@project = Project.new(params[:project])
authorize! :create, @project
respond_to do |format|
if @project.save
format.html { redirect_to @project, notice: 'Project was
successfully created.' }
format.json { render action: 'show', status: :created, location:
@project }
else
format.html { render action: 'new' }
format.json { render json: @project.errors, status:
:unprocessable_entity }
end
end
end
# PATCH/PUT /projects/1
# PATCH/PUT /projects/1.json
def update
@project = Project.find(params[:id])
authorize! :edit, @project
respond_to do |format|
if @project.update_attributes(params[:project])
format.html { redirect_to @project, notice: 'Project was
successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @project.errors, status:
:unprocessable_entity }
end
end
end
# DELETE /projects/1
# DELETE /projects/1.json
def destroy
@project.destroy
respond_to do |format|
format.html { redirect_to projects_url }
format.json { head :no_content }
end
end
end
Here is my project show template:
%p{id: 'notice'}
= notice
%p
%strong
Project Name:
= @project.name
%ul
Phases:
-if @project.phases
-@project.phases.each do |phase|
%li
= phase.name
%table.entries
%thead
%tr
%th Project
%th User
%th Created By
%th Date
%th Start
%th End
%th Type
%th Status
%th On/Off
%th Phase
%th Description
%th Edit
%th Delete
%tbody
- if current_user
- @project.entries_by_user(current_user).each do |entry|
%tr
%td= entry.project.name
%td= entry.user.email
%td= entry.created_by
%td= entry.date
%td= entry.start_time.to_s(:time)
%td= entry.end_time.to_s(:time)
%td= entry.type_of_work
%td= entry.status
%td= entry.on_off_site
%td= entry.phase.name
%td= entry.description
%td= link_to 'Edit', edit_project_entry_path(:entry=>entry,
:id=>entry.id, :project_id=>@project.id)
%td= link_to 'Delete', entry, method: :delete, data: { confirm:
'Are you sure?' }
= link_to 'New Entry', new_project_entry_path(@project)
= link_to 'Edit', edit_project_path(@project)
= link_to 'Back', projects_path
My first thought was that in the show method of my projects controller
@projects was somehow not being properly set, and therefore was nil and
then when it called @projects.name in the show view, it was getting the
nil error. However, I tried wrapping that call to @projects.name with a if
@project to make sure @project was getting set but I got the same error as
before.
Any ideas?
Thank you!
Index - SQL - What is it? Uses? Types?
Index - SQL - What is it? Uses? Types?
I am learning SQL. Recently came across Indexes in SQL. Was not able to
understand fully. Can anyone explain what is an Index, uses and different
types in simple language.
Thanks in advance, Varu.
I am learning SQL. Recently came across Indexes in SQL. Was not able to
understand fully. Can anyone explain what is an Index, uses and different
types in simple language.
Thanks in advance, Varu.
PHP Fatal Error: Out of Memory when creating an image
PHP Fatal Error: Out of Memory when creating an image
I have a simple PHP script that takes an image that's been uploaded and
processes it with imagecreatefromjpeg. It works great on small images, but
not on larger ones. With an image of say, 5,799,936 bytes, I get the
following error:
Fatal error: Out of memory (allocated 56623104) (tried to allocate 3072
bytes)
If the image is less than 1MB, I get no such error.
I've ensured that I always use imagedestroy whenever an image has been
successfully processed, and I've used memory_get_usage() to see what's
currently in use (186260).
Is there anyway to get to the bottom of this error and change the outcome
-- or do I need to put a check in place for the size of the image, as the
server will never be able to process anything of that size. (If so, how
can I tell what size is OK for the server?)
I have a simple PHP script that takes an image that's been uploaded and
processes it with imagecreatefromjpeg. It works great on small images, but
not on larger ones. With an image of say, 5,799,936 bytes, I get the
following error:
Fatal error: Out of memory (allocated 56623104) (tried to allocate 3072
bytes)
If the image is less than 1MB, I get no such error.
I've ensured that I always use imagedestroy whenever an image has been
successfully processed, and I've used memory_get_usage() to see what's
currently in use (186260).
Is there anyway to get to the bottom of this error and change the outcome
-- or do I need to put a check in place for the size of the image, as the
server will never be able to process anything of that size. (If so, how
can I tell what size is OK for the server?)
Get timetracking report by logging Git workingcopy branch occupancy
Get timetracking report by logging Git workingcopy branch occupancy
I was wondering if there exist a script (python, or other runnable on
windows) that checks every say 1 minute which branch is currently checked
out in a git working copy.
That way it would be possible to estimate the time required for each
ticket/branch to get a time-tracking report.
I was wondering if there exist a script (python, or other runnable on
windows) that checks every say 1 minute which branch is currently checked
out in a git working copy.
That way it would be possible to estimate the time required for each
ticket/branch to get a time-tracking report.
Joomla! & VirtueMart - show product category instead of shop front?
Joomla! & VirtueMart - show product category instead of shop front?
I have a Joomla! 1.5.15 and VirtueMart 1.1.4 installation from a client
project and I need to change something I'm not sure how to.
I have one of my menu links pointing to the shop (menu item type:
VirtueMart) but it directs me to a front page (to be precise, it renders
the content in themes/default/templates/common/categoryChildlist.tpl.php).
What I want is for this link to make one of my product categories show.
I've tried several methods (without any luck so far):
Using header() doesn't work (I know, it's a pretty shameful trick, but I
had to try it).
Changing the menu item type doesn't work (you can't modify the link itself).
Modifying any of the browser_ files doesn't work either (at least, doesn't
look like it).
I'm a bit out of ideas... any hint?
I have a Joomla! 1.5.15 and VirtueMart 1.1.4 installation from a client
project and I need to change something I'm not sure how to.
I have one of my menu links pointing to the shop (menu item type:
VirtueMart) but it directs me to a front page (to be precise, it renders
the content in themes/default/templates/common/categoryChildlist.tpl.php).
What I want is for this link to make one of my product categories show.
I've tried several methods (without any luck so far):
Using header() doesn't work (I know, it's a pretty shameful trick, but I
had to try it).
Changing the menu item type doesn't work (you can't modify the link itself).
Modifying any of the browser_ files doesn't work either (at least, doesn't
look like it).
I'm a bit out of ideas... any hint?
Monday, 26 August 2013
Django template indentation guideline
Django template indentation guideline
There is PEP 8 for Python, but I haven't seen a preferred indentation
guideline for django templates.
What I mean is, I normally indent blocks like this:
<span>outside</span>
{% if condition %}
<span>within condition</span>
{% endif %}
<span>outside</span>
While this looks good on the editor, but it will look crap on view source
like this:
<span>outside</span>
<span>within condition</span>
<span>outside</span>
I would even look worse within the HTML indentation, see below:
<div>
<span>outside</span>
{% if condition %}
<span>within condition</span>
{% endif %}
</div>
will become:
<div>
<span>outside</span>
<span>within condition</span>
</div>
While I agree having better layout in editor is way way more important,
but I also get paranoid about the generated messy HTML source code.
There is PEP 8 for Python, but I haven't seen a preferred indentation
guideline for django templates.
What I mean is, I normally indent blocks like this:
<span>outside</span>
{% if condition %}
<span>within condition</span>
{% endif %}
<span>outside</span>
While this looks good on the editor, but it will look crap on view source
like this:
<span>outside</span>
<span>within condition</span>
<span>outside</span>
I would even look worse within the HTML indentation, see below:
<div>
<span>outside</span>
{% if condition %}
<span>within condition</span>
{% endif %}
</div>
will become:
<div>
<span>outside</span>
<span>within condition</span>
</div>
While I agree having better layout in editor is way way more important,
but I also get paranoid about the generated messy HTML source code.
Kafka Quickstart: java.lang.NoClassDefFoundError: scala/ScalaObject
Kafka Quickstart: java.lang.NoClassDefFoundError: scala/ScalaObject
I am working through the kafka quickstart:
http://kafka.apache.org/07/quickstart.html
I have coded up the Consumer and ConsumerThreadPool examples, eg
import kafka.consumer.KafkaStream;
import kafka.consumer.ConsumerIterator;
public class Consumer implements Runnable {
private KafkaStream m_stream;
private Integer m_threadNumber;
public Consumer(KafkaStream a_stream, Integer a_threadNumber) {
m_threadNumber = a_threadNumber;
m_stream = a_stream;
}
public void run() {
ConsumerIterator<byte[], byte[]> it = m_stream.iterator();
while (it.hasNext()) {
System.out.println("Thread " + m_threadNumber + ": " + new
String(it.next().message()));
}
System.out.println("Shutting down Thread: " + m_threadNumber);
}
}
A couple of other facets: I am using spring to manage my zookeeper:
import javax.inject.Named;
import java.util.Properties;
import kafka.consumer.ConsumerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("com.truecar.inventory.worker.core")
public class AppConfig {
@Bean
@Named("consumerConfig")
private static ConsumerConfig createConsumerConfig() {
String zookeeperAddress = "127.0.0.1:2181";
String groupId = "inventory";
Properties props = new Properties();
props.put("zookeeper.connect", zookeeperAddress);
props.put("group.id", groupId);
props.put("zookeeper.session.timeout.ms", "400");
props.put("zookeeper.sync.time.ms", "200");
props.put("auto.commit.interval.ms", "1000");
return new ConsumerConfig(props);
}
}
And I am compiling with Maven and the OneJar Maven plugin. However, I
compile and then run the resulting one jar I get the following error:
Aug 26, 2013 6:15:41 PM
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
registerDefaultFilters
INFO: JSR-330 'javax.inject.Named' annotation found and supported for
component scanning
Exception in thread "main" java.lang.reflect.InvocationTargetException
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:606)
at com.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.NoClassDefFoundError: scala/ScalaObject
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at com.simontuffs.onejar.JarClassLoader.defineClass(JarClassLoader.java:803)
at com.simontuffs.onejar.JarClassLoader.findClass(JarClassLoader.java:710)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at com.simontuffs.onejar.JarClassLoader.loadClass(JarClassLoader.java:630)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
at java.lang.Class.getDeclaredMethods(Class.java:1845)
at
org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:180)
at
org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:222)
at
org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:165)
at
org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:140)
at
org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:282)
at
org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at
org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:73)
at
com.truecar.inventory.worker.core.consumer.ConsumerThreadPool.<clinit>(ConsumerThreadPool.java:31)
at
com.truecar.inventory.worker.core.application.Starter.main(Starter.java:20)
... 6 more
Caused by: java.lang.ClassNotFoundException: scala.ScalaObject
at com.simontuffs.onejar.JarClassLoader.findClass(JarClassLoader.java:713)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at com.simontuffs.onejar.JarClassLoader.loadClass(JarClassLoader.java:630)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 27 more
Now, I know little about Kafka, and nothing about Scala. How do I fix
this? What should i try next? Is this a known issue? Do I need other
dependencies?
I am working through the kafka quickstart:
http://kafka.apache.org/07/quickstart.html
I have coded up the Consumer and ConsumerThreadPool examples, eg
import kafka.consumer.KafkaStream;
import kafka.consumer.ConsumerIterator;
public class Consumer implements Runnable {
private KafkaStream m_stream;
private Integer m_threadNumber;
public Consumer(KafkaStream a_stream, Integer a_threadNumber) {
m_threadNumber = a_threadNumber;
m_stream = a_stream;
}
public void run() {
ConsumerIterator<byte[], byte[]> it = m_stream.iterator();
while (it.hasNext()) {
System.out.println("Thread " + m_threadNumber + ": " + new
String(it.next().message()));
}
System.out.println("Shutting down Thread: " + m_threadNumber);
}
}
A couple of other facets: I am using spring to manage my zookeeper:
import javax.inject.Named;
import java.util.Properties;
import kafka.consumer.ConsumerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("com.truecar.inventory.worker.core")
public class AppConfig {
@Bean
@Named("consumerConfig")
private static ConsumerConfig createConsumerConfig() {
String zookeeperAddress = "127.0.0.1:2181";
String groupId = "inventory";
Properties props = new Properties();
props.put("zookeeper.connect", zookeeperAddress);
props.put("group.id", groupId);
props.put("zookeeper.session.timeout.ms", "400");
props.put("zookeeper.sync.time.ms", "200");
props.put("auto.commit.interval.ms", "1000");
return new ConsumerConfig(props);
}
}
And I am compiling with Maven and the OneJar Maven plugin. However, I
compile and then run the resulting one jar I get the following error:
Aug 26, 2013 6:15:41 PM
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
registerDefaultFilters
INFO: JSR-330 'javax.inject.Named' annotation found and supported for
component scanning
Exception in thread "main" java.lang.reflect.InvocationTargetException
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:606)
at com.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.NoClassDefFoundError: scala/ScalaObject
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at com.simontuffs.onejar.JarClassLoader.defineClass(JarClassLoader.java:803)
at com.simontuffs.onejar.JarClassLoader.findClass(JarClassLoader.java:710)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at com.simontuffs.onejar.JarClassLoader.loadClass(JarClassLoader.java:630)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
at java.lang.Class.getDeclaredMethods(Class.java:1845)
at
org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:180)
at
org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:222)
at
org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:165)
at
org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:140)
at
org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:282)
at
org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at
org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:73)
at
com.truecar.inventory.worker.core.consumer.ConsumerThreadPool.<clinit>(ConsumerThreadPool.java:31)
at
com.truecar.inventory.worker.core.application.Starter.main(Starter.java:20)
... 6 more
Caused by: java.lang.ClassNotFoundException: scala.ScalaObject
at com.simontuffs.onejar.JarClassLoader.findClass(JarClassLoader.java:713)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at com.simontuffs.onejar.JarClassLoader.loadClass(JarClassLoader.java:630)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 27 more
Now, I know little about Kafka, and nothing about Scala. How do I fix
this? What should i try next? Is this a known issue? Do I need other
dependencies?
Using MVVMCross and Monotouch, can you bind to a Dialog.Section Visible property?
Using MVVMCross and Monotouch, can you bind to a Dialog.Section Visible
property?
I am trying to bind the Visible property of a MVVMCross Dialog Section.
var refillSection = new Section() {
new StringElement("Refill").Bind(this, "SelectedCommand OpenExternal")
}.Bind(this, "Visible IsExternal,Converter=Visibility");
root.Add(refillSection);
I have also tried binding the Visible of the Element directly, but does
not work either.
var refillSection = new Section() {
new StringElement("Refill").Bind(this, "SelectedCommand
OpenExternal;Visible IsExternal,Converter=Visibility")
};
root.Add(refillSection);
Am I doing something wrong? I have the Visibility plugin installed.
property?
I am trying to bind the Visible property of a MVVMCross Dialog Section.
var refillSection = new Section() {
new StringElement("Refill").Bind(this, "SelectedCommand OpenExternal")
}.Bind(this, "Visible IsExternal,Converter=Visibility");
root.Add(refillSection);
I have also tried binding the Visible of the Element directly, but does
not work either.
var refillSection = new Section() {
new StringElement("Refill").Bind(this, "SelectedCommand
OpenExternal;Visible IsExternal,Converter=Visibility")
};
root.Add(refillSection);
Am I doing something wrong? I have the Visibility plugin installed.
Associate specific SLF4J logger with Jetty embedded
Associate specific SLF4J logger with Jetty embedded
I'm trying to assign a specific SLF4J logger instance to my Jetty embedded
server using the following lines of code:
Logger myLogger = LoggerFactory.getLogger("Web Server");
Log.setLog((org.eclipse.jetty.util.log.Logger) myLogger)
where myLogger is an instance of org.slf4j.Logger. This returns a
ClassCastException since
org.slf4j.impl.Log4jLoggerAdapter cannot be cast to
org.eclipse.jetty.util.log.Logger`
How then can I go about this process?
I'm trying to assign a specific SLF4J logger instance to my Jetty embedded
server using the following lines of code:
Logger myLogger = LoggerFactory.getLogger("Web Server");
Log.setLog((org.eclipse.jetty.util.log.Logger) myLogger)
where myLogger is an instance of org.slf4j.Logger. This returns a
ClassCastException since
org.slf4j.impl.Log4jLoggerAdapter cannot be cast to
org.eclipse.jetty.util.log.Logger`
How then can I go about this process?
Can I Share My Cable Internet Connection Through my ADSL Wireless modem + Router
Can I Share My Cable Internet Connection Through my ADSL Wireless modem +
Router
At first I want to say this question can be found by googling but I cannot
find any satisfactory answer. So I am posting it here.
I have a ZTE-ZXDSL-531 ADSL Modem. At first I used an ADSL broadband & I
could connect multiple devices in wireless to the internet using the
modem. So I think this is a hybrid modem with router. (Please correct me
if I am wrong).
Now I have switched to cable broadband (you know which comes with a
co-axial CAT 5 cable with a RJ45, which is connected directly to computer
cabinet).
My question is it possible to share this cable internet connection with
this hybrid modem? If not please give me the reason.
If possible how to connect it & how to configure the modem?
Thanks in advance
Router
At first I want to say this question can be found by googling but I cannot
find any satisfactory answer. So I am posting it here.
I have a ZTE-ZXDSL-531 ADSL Modem. At first I used an ADSL broadband & I
could connect multiple devices in wireless to the internet using the
modem. So I think this is a hybrid modem with router. (Please correct me
if I am wrong).
Now I have switched to cable broadband (you know which comes with a
co-axial CAT 5 cable with a RJ45, which is connected directly to computer
cabinet).
My question is it possible to share this cable internet connection with
this hybrid modem? If not please give me the reason.
If possible how to connect it & how to configure the modem?
Thanks in advance
Show options of selected options inside the same
Show options of selected options inside the same
There is an unordered list of 3 items, say A,B and C inside a <div>. Now
if I select an option A, it should again show a list of P, Q and R inside
the same <div> and if I select B, it should show an unordered list of X,Y
and Z plus it should have a back button as well.
<div>
<select>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<div>
Now upon selecting Option A, the following list should be displayed inside
the same <div>
<select>
<option value="P">P</option>
<option value="Q">Q</option>
<option value="R">R</option>
</select>
And like this, it is upto 3-4 levels down, for eg:- From A->P,Q,R. From
P->D,E,F. From D->S,R,T and similarly. All should be displayed inside the
same <div> tag.
I have searched bootstrap but didnt got the expected result. Can this be
done in bootstrap. If not, how can I approach this problem in jQuery?
There is an unordered list of 3 items, say A,B and C inside a <div>. Now
if I select an option A, it should again show a list of P, Q and R inside
the same <div> and if I select B, it should show an unordered list of X,Y
and Z plus it should have a back button as well.
<div>
<select>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<div>
Now upon selecting Option A, the following list should be displayed inside
the same <div>
<select>
<option value="P">P</option>
<option value="Q">Q</option>
<option value="R">R</option>
</select>
And like this, it is upto 3-4 levels down, for eg:- From A->P,Q,R. From
P->D,E,F. From D->S,R,T and similarly. All should be displayed inside the
same <div> tag.
I have searched bootstrap but didnt got the expected result. Can this be
done in bootstrap. If not, how can I approach this problem in jQuery?
PHP-FPM not working as global PHP handler on Apache, CentOS 6.4
PHP-FPM not working as global PHP handler on Apache, CentOS 6.4
I'm trying to switch PHP handler on my server from mod_php to PHP-FPM. But
something with my setup is worng. When I'm trying to open
server.com/info.php, it's being opened as standart txt file, not parsed
and shown as it should be shown:
<?php
phpinfo();
?>
Httpd and php-fpm logs showing nothing. httpd -M - shows mod_fastcgi
loaded. System:CentOS 6.4 x64, Apache 2.2.15.
PHP-5.5.3 compiled from source with such configuration:
./configure \
--prefix=/opt/php553-fpm \
--with-config-file-path=/opt/php553-fpm/etc \
--with-config-file-scan-dir=/opt/php553-fpm/etc/php.d \
--with-pdo-pgsql \
--with-zlib-dir \
--with-freetype-dir \
--enable-bcmath \
--enable-mbstring \
--with-libxml-dir=/usr \
--enable-soap \
--enable-calendar \
--with-curl \
--with-mcrypt \
--with-zlib \
--with-gd \
--with-pgsql \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-mysql \
--with-pdo-mysql \
--with-mysqli \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--enable-gd-native-ttf \
--with-openssl \
--with-libdir=lib64 \
--enable-ftp \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-gettext \
--enable-fpm \
--with-fpm-user=apache \
--with-fpm-group=apache
php-fpm process starting normally via init.d/php-fpm, and ready to listen
connections on 127.0.0.1:9000. netstat showing correct info. mod_fastcgi -
installed via yum
my httpd/fpm.conf
<IfModule mod_fastcgi.so>
<FilesMatch \.php$>
SetHandler php-script
</FilesMatch>
# AddHandler php-script .php
Action php-script /php.external
Alias /php.external /var/run/mod_fastcgi/php.fpm
FastCGIExternalServer /var/run/mod_fastcgi/php.fpm -host 127.0.0.1:9000
AddType application/x-httpd-fastphp5 .php
DirectoryIndex index.php
<Directory "/var/run/mod_fastcgi/">
Order deny,allow
Deny from all
<Files "php.fpm">
Order allow,deny
Allow from all
</Files>
</Directory>
</IfModule>
fastcgi.conf
User apache
Group apache
LoadModule fastcgi_module modules/mod_fastcgi.so
# dir for IPC socket files
FastCgiIpcDir /var/run/mod_fastcgi
# wrap all fastcgi script calls in suexec
FastCgiWrapper On
# global FastCgiConfig can be overridden by FastCgiServer options in vhost
config
FastCgiConfig -idle-timeout 20 -maxClassProcesses 1
php-fpm.conf and default pool 'www' confs are exactly same as everywhere
on internet described in many-many tutorials which not helping me this
time (. Only user and group in www.conf are "apache" - inserted during PHP
compilation from source.
Second question: PHP-FPM setup works only with files in document root?
Right now document root for me is /var/www/html. But several sites like
zabbix, phpmyadmin reside in "/home/vhosts" and they are subdirectories
and not virtualhosts. I see error when I try aceess server.com/pma:
Directory index forbidden by Options directive: /home/vhosts/pma/
Before I had mod_php compiled from same sources and everything worked.
Right now it's still registered in system path, but loading of mod_php in
httpd is disabled.
I'm trying to switch PHP handler on my server from mod_php to PHP-FPM. But
something with my setup is worng. When I'm trying to open
server.com/info.php, it's being opened as standart txt file, not parsed
and shown as it should be shown:
<?php
phpinfo();
?>
Httpd and php-fpm logs showing nothing. httpd -M - shows mod_fastcgi
loaded. System:CentOS 6.4 x64, Apache 2.2.15.
PHP-5.5.3 compiled from source with such configuration:
./configure \
--prefix=/opt/php553-fpm \
--with-config-file-path=/opt/php553-fpm/etc \
--with-config-file-scan-dir=/opt/php553-fpm/etc/php.d \
--with-pdo-pgsql \
--with-zlib-dir \
--with-freetype-dir \
--enable-bcmath \
--enable-mbstring \
--with-libxml-dir=/usr \
--enable-soap \
--enable-calendar \
--with-curl \
--with-mcrypt \
--with-zlib \
--with-gd \
--with-pgsql \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-mysql \
--with-pdo-mysql \
--with-mysqli \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--enable-gd-native-ttf \
--with-openssl \
--with-libdir=lib64 \
--enable-ftp \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-gettext \
--enable-fpm \
--with-fpm-user=apache \
--with-fpm-group=apache
php-fpm process starting normally via init.d/php-fpm, and ready to listen
connections on 127.0.0.1:9000. netstat showing correct info. mod_fastcgi -
installed via yum
my httpd/fpm.conf
<IfModule mod_fastcgi.so>
<FilesMatch \.php$>
SetHandler php-script
</FilesMatch>
# AddHandler php-script .php
Action php-script /php.external
Alias /php.external /var/run/mod_fastcgi/php.fpm
FastCGIExternalServer /var/run/mod_fastcgi/php.fpm -host 127.0.0.1:9000
AddType application/x-httpd-fastphp5 .php
DirectoryIndex index.php
<Directory "/var/run/mod_fastcgi/">
Order deny,allow
Deny from all
<Files "php.fpm">
Order allow,deny
Allow from all
</Files>
</Directory>
</IfModule>
fastcgi.conf
User apache
Group apache
LoadModule fastcgi_module modules/mod_fastcgi.so
# dir for IPC socket files
FastCgiIpcDir /var/run/mod_fastcgi
# wrap all fastcgi script calls in suexec
FastCgiWrapper On
# global FastCgiConfig can be overridden by FastCgiServer options in vhost
config
FastCgiConfig -idle-timeout 20 -maxClassProcesses 1
php-fpm.conf and default pool 'www' confs are exactly same as everywhere
on internet described in many-many tutorials which not helping me this
time (. Only user and group in www.conf are "apache" - inserted during PHP
compilation from source.
Second question: PHP-FPM setup works only with files in document root?
Right now document root for me is /var/www/html. But several sites like
zabbix, phpmyadmin reside in "/home/vhosts" and they are subdirectories
and not virtualhosts. I see error when I try aceess server.com/pma:
Directory index forbidden by Options directive: /home/vhosts/pma/
Before I had mod_php compiled from same sources and everything worked.
Right now it's still registered in system path, but loading of mod_php in
httpd is disabled.
synchronizedList access by multiple threads
synchronizedList access by multiple threads
I have very basic question about the SynchronizedList.
Lets say I have synchronizedList as -
List syncList = Collections.synchronizedList(new ArrayList<>())
Now my scenario is Thread A is trying to access add() api and Thread B
trying to access remove() api of synchronizedList. Will the Both thread
able to access the Both(add and remove) api at the same time.
I believe the threads should not access the api(add() and remove()) same
time. Please correct me if I am wrong.
I have very basic question about the SynchronizedList.
Lets say I have synchronizedList as -
List syncList = Collections.synchronizedList(new ArrayList<>())
Now my scenario is Thread A is trying to access add() api and Thread B
trying to access remove() api of synchronizedList. Will the Both thread
able to access the Both(add and remove) api at the same time.
I believe the threads should not access the api(add() and remove()) same
time. Please correct me if I am wrong.
Sunday, 25 August 2013
Getting issue in CGPath Scale
Getting issue in CGPath Scale
I am drawing polygon using CGPath and adding to CAShapeLayer.I want to
scale my CGPath when user click on it.I know how to scale CGPath.But when
i click my CGPath,my CGPath drawing far from centre while i am drawing
polygon in centre.Please help me.Thanking you.
I am drawing polygon using CGPath and adding to CAShapeLayer.I want to
scale my CGPath when user click on it.I know how to scale CGPath.But when
i click my CGPath,my CGPath drawing far from centre while i am drawing
polygon in centre.Please help me.Thanking you.
Finding my network's public IP address range
Finding my network's public IP address range
I am referring to the following instructions to setup Amazon EC2 web
services on my local machine: AWS-Security-Group
I do not know how to complete the first bullet under step 6.
How do I find my network's public IP address range?
I am referring to the following instructions to setup Amazon EC2 web
services on my local machine: AWS-Security-Group
I do not know how to complete the first bullet under step 6.
How do I find my network's public IP address range?
Flex 4: Replace one mxml instance with another destroys the bindings
Flex 4: Replace one mxml instance with another destroys the bindings
I want to replace on mxml instance with another. The instance I try to
replace is a custom component that has an object that I bind, component
that also has a skin that has a property I bind.
The issue I experience takes place when I replace the mxml instance with
another. All the properties I bind are still working in the custom
component but the property I bind in the custom component for the skin is
not working anymore.
This is the way I bind the custom skin property in the skin file:
<fx:Binding source="hostComponent.lineAlpha" destination="lineAlpha" />
What causes this to stop listening and what can I do to fix that?
I want to replace on mxml instance with another. The instance I try to
replace is a custom component that has an object that I bind, component
that also has a skin that has a property I bind.
The issue I experience takes place when I replace the mxml instance with
another. All the properties I bind are still working in the custom
component but the property I bind in the custom component for the skin is
not working anymore.
This is the way I bind the custom skin property in the skin file:
<fx:Binding source="hostComponent.lineAlpha" destination="lineAlpha" />
What causes this to stop listening and what can I do to fix that?
Json object to populate google maps
Json object to populate google maps
Im trying to get the data from my msql databse into a html document and
thenvturn it into a json object so later on i can call it to use in google
maps. I have no idea whats wrong with this json string though any ideas?.
And it woiuld be helpful if any of you had any idea how i would call it to
get the tables i wanted into the google maps api.
Here is my json object that kinda works.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="generator" content="CoffeeCup HTML Editor
(www.coffeecup.com)">
<meta name="dcterms.created" content="Sun, 25 Aug 2013
10:26:05 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<title></title>
</head>
<?php
$db =
mysql_connect("careemprod.cmsz241itecr.eu-west-1.rds.amazonaws.com","careem-3","l1mit3dAcc0untCr3dent1@ls");
mysql_select_db("careem", $db);
date_default_timezone_set("Asia/Dubai");
$query = mysql_query("select
booking.id,booking.pick_up_location_id,booking.drop_off_location_id,booking_time,location.latitude,location.longitude,location_type,count(booking.id)
from booking
left join trip on booking.id = trip.booking_id
left join location on booking.pick_up_location_id = location.id
where location.latitude != 0 and location.longitude != 0 and
location_type != 98 and location_type != 0
group by pick_up_location_id
order by count(booking.id) desc");
$rows = array();
while($result = mysql_fetch_assoc($query)) {
$row["booking.id"] = $result["booking_ID"];
$row["booking.pick_up_location_id"] =
$result["pick_up_location_id"];
$row["booking.drop_off_location_id"] =
$result["drop_off_location_id"];
$row["booking_time"] = $result["booking_time"];
$row["location.latitude"] = $result["lat"];
$row["location.longitude"] = $result["lng"];
$row["location_type"] = $result["location_type"];
$row["count(booking.id)"] = $result["booking_multiplyer"];}
{
header('Content-type: application/json');
print json_encode(array(''=>$result));
}
?>
<body>
</body>
</html>
Here is an idea how i would use the object.
PageLoad(s,e)
{
var jsonString =
document.getElementById("hidMarkers").value;//which includes
lat and long values as json object.
var markersJson = jQuery.parseJSON(jsonString);
for (var i = 0; i < markersJson.length; i++) {
var latLng = new
google.maps.LatLng(markersJson[i].lat,
markersJson[i].lng);
var marker = new google.maps.Marker({ position:
latLng, clickable: true, icon:
markersJson[i].iconPath, map:map });
}
}
Im trying to get the data from my msql databse into a html document and
thenvturn it into a json object so later on i can call it to use in google
maps. I have no idea whats wrong with this json string though any ideas?.
And it woiuld be helpful if any of you had any idea how i would call it to
get the tables i wanted into the google maps api.
Here is my json object that kinda works.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="generator" content="CoffeeCup HTML Editor
(www.coffeecup.com)">
<meta name="dcterms.created" content="Sun, 25 Aug 2013
10:26:05 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<title></title>
</head>
<?php
$db =
mysql_connect("careemprod.cmsz241itecr.eu-west-1.rds.amazonaws.com","careem-3","l1mit3dAcc0untCr3dent1@ls");
mysql_select_db("careem", $db);
date_default_timezone_set("Asia/Dubai");
$query = mysql_query("select
booking.id,booking.pick_up_location_id,booking.drop_off_location_id,booking_time,location.latitude,location.longitude,location_type,count(booking.id)
from booking
left join trip on booking.id = trip.booking_id
left join location on booking.pick_up_location_id = location.id
where location.latitude != 0 and location.longitude != 0 and
location_type != 98 and location_type != 0
group by pick_up_location_id
order by count(booking.id) desc");
$rows = array();
while($result = mysql_fetch_assoc($query)) {
$row["booking.id"] = $result["booking_ID"];
$row["booking.pick_up_location_id"] =
$result["pick_up_location_id"];
$row["booking.drop_off_location_id"] =
$result["drop_off_location_id"];
$row["booking_time"] = $result["booking_time"];
$row["location.latitude"] = $result["lat"];
$row["location.longitude"] = $result["lng"];
$row["location_type"] = $result["location_type"];
$row["count(booking.id)"] = $result["booking_multiplyer"];}
{
header('Content-type: application/json');
print json_encode(array(''=>$result));
}
?>
<body>
</body>
</html>
Here is an idea how i would use the object.
PageLoad(s,e)
{
var jsonString =
document.getElementById("hidMarkers").value;//which includes
lat and long values as json object.
var markersJson = jQuery.parseJSON(jsonString);
for (var i = 0; i < markersJson.length; i++) {
var latLng = new
google.maps.LatLng(markersJson[i].lat,
markersJson[i].lng);
var marker = new google.maps.Marker({ position:
latLng, clickable: true, icon:
markersJson[i].iconPath, map:map });
}
}
Saturday, 24 August 2013
set the default value of an input text with java script
set the default value of an input text with java script
my requirement is to save the entire "html" inside a div, but when i load
an "html" with text fields to a div and then editing the value of the text
box, the newly set value doesn't reflect in the core "html". I tried to
inspect the value with fire bug and it remains the same or no value at
all.With "jquery" i tried to set attribute but no attribute name value is
created. how can i set the value of text fields and then get that "html"
with the newly set value.
$("#txt").attr("value", "some value");
my requirement is to save the entire "html" inside a div, but when i load
an "html" with text fields to a div and then editing the value of the text
box, the newly set value doesn't reflect in the core "html". I tried to
inspect the value with fire bug and it remains the same or no value at
all.With "jquery" i tried to set attribute but no attribute name value is
created. how can i set the value of text fields and then get that "html"
with the newly set value.
$("#txt").attr("value", "some value");
Symfony 2 Configuration of directories
Symfony 2 Configuration of directories
I found some topics with similar problem, but I've never been able to fix
mine.
I've just started Symfony2 development. I work with MAMP. Before, my
project directory path was this path :
/Applications/MAMP/htdocs/TrainingProject/Symfony/
And my configuration on MAMP for "Document root" was :
/Applications/MAMP/htdocs/TrainingProject/Symfony/web/
With this paths, I can launch app_dev.php and app.php without problems.
I wanted to created a subfolder inside TrainingProject to organize couple
stuff... So I wanted to have this new path for my project :
/Applications/MAMP/htdocs/TrainingProject/THE_SUBFOLDER/Symfony/
So I've edit the Document root on MAMP settings :
/Applications/MAMP/htdocs/TrainingProject/THE_SUBFOLDER/Symfony/web/
After my changes, I have a really weird behavior!
http://localhost:8888/config.php works
http://localhost:8888/app_dev.php works
http://localhost:8888/ DOESN'T WORK !! ...
http://localhost:8888/app.php DOESN'T WORK !! ...
Another problem, for writing cache, it writes always on the old path. So
It creates a folder Symfony inside TrainingProject, with his subfolders
just for the CACHE...
With my previous architecture, everything worked!
I've already tried to empty the cache with this command :
php app/console cache:clear --env=prod --no-debug
Nothing changed...
Help please
I found some topics with similar problem, but I've never been able to fix
mine.
I've just started Symfony2 development. I work with MAMP. Before, my
project directory path was this path :
/Applications/MAMP/htdocs/TrainingProject/Symfony/
And my configuration on MAMP for "Document root" was :
/Applications/MAMP/htdocs/TrainingProject/Symfony/web/
With this paths, I can launch app_dev.php and app.php without problems.
I wanted to created a subfolder inside TrainingProject to organize couple
stuff... So I wanted to have this new path for my project :
/Applications/MAMP/htdocs/TrainingProject/THE_SUBFOLDER/Symfony/
So I've edit the Document root on MAMP settings :
/Applications/MAMP/htdocs/TrainingProject/THE_SUBFOLDER/Symfony/web/
After my changes, I have a really weird behavior!
http://localhost:8888/config.php works
http://localhost:8888/app_dev.php works
http://localhost:8888/ DOESN'T WORK !! ...
http://localhost:8888/app.php DOESN'T WORK !! ...
Another problem, for writing cache, it writes always on the old path. So
It creates a folder Symfony inside TrainingProject, with his subfolders
just for the CACHE...
With my previous architecture, everything worked!
I've already tried to empty the cache with this command :
php app/console cache:clear --env=prod --no-debug
Nothing changed...
Help please
Wordpress Theme Options Page - Radio Buttons not updating correctly
Wordpress Theme Options Page - Radio Buttons not updating correctly
I am currently working on the Theme Options Page of my Wordpress Theme.
As a base I'm using the "SAMPLE WORDPRESS THEME OPTIONS PAGE" by Ian Steward:
The Situation:
I've implemented two sets of radio-buttons like so:
The Problem:
They work as planned, the chosen options are applied.
Only problem: after saving the chosen radio buttons aren't selected anymore.
For the image above: If I would change both radio buttons and click save
only the very first radio button is selected, after the page has loaded
again.
The Code:
From the theme-options.php:
// Normal/Fixed Navigation Options
$fixed_navigation_options = array(
'Normal' => array(
'value' => ' ',
'label' => __( 'Normal', 'arrowcatch' )
),
'Fixed' => array(
'value' => 'is-fixed',
'label' => __( 'Fixed', 'arrowcatch' )
)
);
// Full-width/Contained Navigation Options
$contained_navigation_options = array(
'Full-width' => array(
'value' => ' ',
'label' => __( 'Full-width', 'arrowcatch' )
),
'Contained' => array(
'value' => 'is-contained',
'label' => __( 'Contained', 'arrowcatch' )
)
);
function arrowcatch_theme_options_page() {
global $select_options, $fixed_navigation_options,
$contained_navigation_options;
if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false; ?>
<div class="wrap">
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade">
<p><strong>Options saved!</strong></p>
</div>
<?php endif; ?>
<!-- Normal/Fixed Navigation -->
<tr valign="top"><th scope="row"><?php _e( 'Navigation Normal/Fixed',
'arrowcatch' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e(
'Navigation Normal/Fixed', 'arrowcatch' ); ?></span></legend>
<?php
if ( ! isset( $checked ) )
$checked = '';
foreach ( $fixed_navigation_options as $option ) {
$fixed_navigation_setting = $options['fixed_navigation'];
if ( '' != $fixed_navigation_setting ) {
if ( $options['fixed_navigation'] ==
$option['value'] ) {
$checked = "checked=\"checked\"";
} else {
$checked = '';
}
}
?>
<label class="description"><input type="radio"
name="arrowcatch_theme_options[fixed_navigation]"
value="<?php esc_attr_e( $option['value'] ); ?>" <?php
echo $checked; ?> /> <?php echo $option['label'];
?></label><br />
<?php
}
?>
</fieldset>
</td>
</tr>
<!-- Full-width/Contained Navigation -->
<tr valign="top"><th scope="row"><?php _e( 'Navigation
Full-width/Contained', 'arrowcatch' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e(
'Navigation Full-width/Contained', 'arrowcatch' );
?></span></legend>
<?php
if ( ! isset( $checked ) )
$checked = '';
foreach ( $contained_navigation_options as $option ) {
$contained_navigation_setting =
$options['contained_navigation'];
if ( '' != $contained_navigation_setting ) {
if ( $options['fixed_navigation'] ==
$option['value'] ) {
$checked = "checked=\"checked\"";
} else {
$checked = '';
}
}
?>
<label class="description"><input type="radio"
name="arrowcatch_theme_options[contained_navigation]"
value="<?php esc_attr_e( $option['value'] ); ?>" <?php
echo $checked; ?> /> <?php echo $option['label'];
?></label><br />
<?php
}
?>
</fieldset>
</td>
</tr>
Hope that's all the code thats needed.
Not sure what's going on there.
I'm very thankfull for any push in the right direction.
Thank you!
I am currently working on the Theme Options Page of my Wordpress Theme.
As a base I'm using the "SAMPLE WORDPRESS THEME OPTIONS PAGE" by Ian Steward:
The Situation:
I've implemented two sets of radio-buttons like so:
The Problem:
They work as planned, the chosen options are applied.
Only problem: after saving the chosen radio buttons aren't selected anymore.
For the image above: If I would change both radio buttons and click save
only the very first radio button is selected, after the page has loaded
again.
The Code:
From the theme-options.php:
// Normal/Fixed Navigation Options
$fixed_navigation_options = array(
'Normal' => array(
'value' => ' ',
'label' => __( 'Normal', 'arrowcatch' )
),
'Fixed' => array(
'value' => 'is-fixed',
'label' => __( 'Fixed', 'arrowcatch' )
)
);
// Full-width/Contained Navigation Options
$contained_navigation_options = array(
'Full-width' => array(
'value' => ' ',
'label' => __( 'Full-width', 'arrowcatch' )
),
'Contained' => array(
'value' => 'is-contained',
'label' => __( 'Contained', 'arrowcatch' )
)
);
function arrowcatch_theme_options_page() {
global $select_options, $fixed_navigation_options,
$contained_navigation_options;
if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false; ?>
<div class="wrap">
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade">
<p><strong>Options saved!</strong></p>
</div>
<?php endif; ?>
<!-- Normal/Fixed Navigation -->
<tr valign="top"><th scope="row"><?php _e( 'Navigation Normal/Fixed',
'arrowcatch' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e(
'Navigation Normal/Fixed', 'arrowcatch' ); ?></span></legend>
<?php
if ( ! isset( $checked ) )
$checked = '';
foreach ( $fixed_navigation_options as $option ) {
$fixed_navigation_setting = $options['fixed_navigation'];
if ( '' != $fixed_navigation_setting ) {
if ( $options['fixed_navigation'] ==
$option['value'] ) {
$checked = "checked=\"checked\"";
} else {
$checked = '';
}
}
?>
<label class="description"><input type="radio"
name="arrowcatch_theme_options[fixed_navigation]"
value="<?php esc_attr_e( $option['value'] ); ?>" <?php
echo $checked; ?> /> <?php echo $option['label'];
?></label><br />
<?php
}
?>
</fieldset>
</td>
</tr>
<!-- Full-width/Contained Navigation -->
<tr valign="top"><th scope="row"><?php _e( 'Navigation
Full-width/Contained', 'arrowcatch' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e(
'Navigation Full-width/Contained', 'arrowcatch' );
?></span></legend>
<?php
if ( ! isset( $checked ) )
$checked = '';
foreach ( $contained_navigation_options as $option ) {
$contained_navigation_setting =
$options['contained_navigation'];
if ( '' != $contained_navigation_setting ) {
if ( $options['fixed_navigation'] ==
$option['value'] ) {
$checked = "checked=\"checked\"";
} else {
$checked = '';
}
}
?>
<label class="description"><input type="radio"
name="arrowcatch_theme_options[contained_navigation]"
value="<?php esc_attr_e( $option['value'] ); ?>" <?php
echo $checked; ?> /> <?php echo $option['label'];
?></label><br />
<?php
}
?>
</fieldset>
</td>
</tr>
Hope that's all the code thats needed.
Not sure what's going on there.
I'm very thankfull for any push in the right direction.
Thank you!
C# XAML ScrollViewer to work without MaxHeight
C# XAML ScrollViewer to work without MaxHeight
I have a grid that further down have a StackPanel. I have defined the
row's height for the last to be "*", and in this very last row, is where
the StackPanel and all the control would inhabit.
So I have the bellow code in XAML for my StackPanel
<StackPanel Grid.Row="1" MaxHeight="333">
<StackPanel MaxHeight="333">
<ScrollViewer MaxHeight="333">
<TextBlock x:Name="lblRouteDetail" FontSize="35"
TextWrapping="Wrap"/>
</ScrollViewer>
</StackPanel>
</StackPanel>
Well, it worked, only that I have to constraint that the MaxHeight is 333,
without that, it won't work; the ScrollViewer won't work, the content in
the TextBlock wouldn't be scrollable.
Could you state where is my problem, and how to fix this things up?
I have a grid that further down have a StackPanel. I have defined the
row's height for the last to be "*", and in this very last row, is where
the StackPanel and all the control would inhabit.
So I have the bellow code in XAML for my StackPanel
<StackPanel Grid.Row="1" MaxHeight="333">
<StackPanel MaxHeight="333">
<ScrollViewer MaxHeight="333">
<TextBlock x:Name="lblRouteDetail" FontSize="35"
TextWrapping="Wrap"/>
</ScrollViewer>
</StackPanel>
</StackPanel>
Well, it worked, only that I have to constraint that the MaxHeight is 333,
without that, it won't work; the ScrollViewer won't work, the content in
the TextBlock wouldn't be scrollable.
Could you state where is my problem, and how to fix this things up?
Is that a good practice to throw exception from controller
Is that a good practice to throw exception from controller
Is that a good practice to throw exception from controller?
For instance we may throw IllegalStateException from some controller's
method if Request hasn't some attribute.
Also for instance we may throw IllegalArgumentException from some
controller's method if Request's parameter is not in appropriate
format/range.
Is that a good practice to throw exception from controller?
For instance we may throw IllegalStateException from some controller's
method if Request hasn't some attribute.
Also for instance we may throw IllegalArgumentException from some
controller's method if Request's parameter is not in appropriate
format/range.
how to protect jsp pages from being open source
how to protect jsp pages from being open source
I want to develop a commercial web application project. Is it possible so
that the jsp pages will not be open source. something like dll file of asp
pages.?
Thank you.
I want to develop a commercial web application project. Is it possible so
that the jsp pages will not be open source. something like dll file of asp
pages.?
Thank you.
Slowly scroll the content of a div on hover and stop on mouseoff
Slowly scroll the content of a div on hover and stop on mouseoff
Please take a look at this website
I'm trying to implement two arrows on top and bottom of the gallery so
when people mouse over the arrows, the content would scroll top and bottom
respectively.
Here is the code I'm currently using that scroll the content down when you
hover over the bottom arrow. But there are two issues with it:
I want the scrolling to stop when the user mouses off
Hopefully do not display the arrow(s) if there is no more content left to
scroll
if ( $("body").hasClass('projects') ) {
$("#jig1").height($(document).height() - 187);
$("#scroll-to-bottom").hover(
function () {
$("#jig1").animate({ scrollTop: $(document).height() }, 10000);
},
function () {
}
);
}
Can anyone offer an improved solution?
Please take a look at this website
I'm trying to implement two arrows on top and bottom of the gallery so
when people mouse over the arrows, the content would scroll top and bottom
respectively.
Here is the code I'm currently using that scroll the content down when you
hover over the bottom arrow. But there are two issues with it:
I want the scrolling to stop when the user mouses off
Hopefully do not display the arrow(s) if there is no more content left to
scroll
if ( $("body").hasClass('projects') ) {
$("#jig1").height($(document).height() - 187);
$("#scroll-to-bottom").hover(
function () {
$("#jig1").animate({ scrollTop: $(document).height() }, 10000);
},
function () {
}
);
}
Can anyone offer an improved solution?
Friday, 23 August 2013
Practical Use to Temp Files
Practical Use to Temp Files
What would be a practical use for temporary files (see code below)?
File temp = File.createTempFile("temp-file-name", ".tmp");
Why can't you store the data you would keep in the file in some variables?
If the file is (probably) going to be deleted on the program exit (as
"temp" implies), why even create them?
What would be a practical use for temporary files (see code below)?
File temp = File.createTempFile("temp-file-name", ".tmp");
Why can't you store the data you would keep in the file in some variables?
If the file is (probably) going to be deleted on the program exit (as
"temp" implies), why even create them?
Play 2 - Can't return Json object in Response
Play 2 - Can't return Json object in Response
I'm trying to do some RESTFull Web service POC using Play 2.1.3
I have the following class:
case class Student(id: Long,firstName: String,lastName: String)
Now I would like to create RESTfull URI which will get Json serialised
Student POJO and return the same POJO in response.
implicit val studentReads = Json.reads[Student]
implicit val studentWrites = Json.writes[Student]
def updateStudent = Action(parse.json){
request=>request.body.validate[Student].map{
case xs=>Ok(xs)}.recoverTotal{
e => BadRequest("Detected error:"+ JsError.toFlatJson(e))
}
}
But I'm getting compilation Error -
Cannot write an instance of entities.Student to HTTP response. Try to
define a
Writeable[entities.Student]
I just provided Writes[A] as an implicit variable.
What else do I missing?
I'm trying to do some RESTFull Web service POC using Play 2.1.3
I have the following class:
case class Student(id: Long,firstName: String,lastName: String)
Now I would like to create RESTfull URI which will get Json serialised
Student POJO and return the same POJO in response.
implicit val studentReads = Json.reads[Student]
implicit val studentWrites = Json.writes[Student]
def updateStudent = Action(parse.json){
request=>request.body.validate[Student].map{
case xs=>Ok(xs)}.recoverTotal{
e => BadRequest("Detected error:"+ JsError.toFlatJson(e))
}
}
But I'm getting compilation Error -
Cannot write an instance of entities.Student to HTTP response. Try to
define a
Writeable[entities.Student]
I just provided Writes[A] as an implicit variable.
What else do I missing?
Memory with incorrect voltage for motherboard
Memory with incorrect voltage for motherboard
I just bought an Intel DP35DP motherboard. Multiple sites tell me that
only 1.8V memory works.
I have 2x1GB sticks of 1.9-2.1V RAM, then another 2x1GB of 2.1V RAM.
The BIOS does detect all 4GB of memory. However it will not boot anything,
including Windows Installer, Ubuntu, etc.
Could the booting issue be caused by the RAM voltage is incorrect for the
motherboard?
Thanks.
I just bought an Intel DP35DP motherboard. Multiple sites tell me that
only 1.8V memory works.
I have 2x1GB sticks of 1.9-2.1V RAM, then another 2x1GB of 2.1V RAM.
The BIOS does detect all 4GB of memory. However it will not boot anything,
including Windows Installer, Ubuntu, etc.
Could the booting issue be caused by the RAM voltage is incorrect for the
motherboard?
Thanks.
Masas in quotients
Masas in quotients
Let $A$ be a von Neumann algebra and let $B$ be a norm-closed ideal of $A$
(but not necessarily WOT-closed). What one has to assume about $A$ and $B$
to ensure that if $M\subset A$ is a maximal abelian subalgebra, then $M /
(B\cap M)$ is a maximal algebian subalgebra of $A/B$? This is the case for
$A=B(H)$ and $B=K(H)$.
Let $A$ be a von Neumann algebra and let $B$ be a norm-closed ideal of $A$
(but not necessarily WOT-closed). What one has to assume about $A$ and $B$
to ensure that if $M\subset A$ is a maximal abelian subalgebra, then $M /
(B\cap M)$ is a maximal algebian subalgebra of $A/B$? This is the case for
$A=B(H)$ and $B=K(H)$.
invoice line tax info is not getting saved by webservice
invoice line tax info is not getting saved by webservice
I am creating invoice by the webservice. Everything is fine, I can see the
saved record. But invoice line tax line is not getting saved via
webservice. I dont know why. When I save by simply web. It is getting
saved. here is code
abc = {
'comment': False,
'origin': '123123',
'date_due': False,
'user_id': 1,
'account_id': 9,
'supplier_invoice_number': '1212323234444',
'partner_id': 6,
'journal_id': 1,
'date_invoice': False,
'fiscal_position': False,
'type': 'out_invoice',
'invoice_line':
[
[
0,
False,
{
'uos_id': 1,
'product_id': 20,
'name': 'HDD on Demand',
'price_unit': 18.0,
'account_id': 40,
'invoice_line_tax_id': [
4,
6
],
'quantity': 1.0
}
]
]
}
account_invoice = self.pool.get('account.invoice')
return account_invoice.create(cr, uid, abc, context)
Remember I am using OpenERP7 Thanks for immediate response.
I am creating invoice by the webservice. Everything is fine, I can see the
saved record. But invoice line tax line is not getting saved via
webservice. I dont know why. When I save by simply web. It is getting
saved. here is code
abc = {
'comment': False,
'origin': '123123',
'date_due': False,
'user_id': 1,
'account_id': 9,
'supplier_invoice_number': '1212323234444',
'partner_id': 6,
'journal_id': 1,
'date_invoice': False,
'fiscal_position': False,
'type': 'out_invoice',
'invoice_line':
[
[
0,
False,
{
'uos_id': 1,
'product_id': 20,
'name': 'HDD on Demand',
'price_unit': 18.0,
'account_id': 40,
'invoice_line_tax_id': [
4,
6
],
'quantity': 1.0
}
]
]
}
account_invoice = self.pool.get('account.invoice')
return account_invoice.create(cr, uid, abc, context)
Remember I am using OpenERP7 Thanks for immediate response.
Maximal ideals in rings
Maximal ideals in rings
Let $R$ be a ring with identity. Is it true that if $R$ has a finite
maximal right ideal then it MUST have a finite maximal two-sided ideal ?
Let $R$ be a ring with identity. Is it true that if $R$ has a finite
maximal right ideal then it MUST have a finite maximal two-sided ideal ?
Thursday, 22 August 2013
change accordion menu to dropdown menu
change accordion menu to dropdown menu
I have accordion menu but when sliding it pushes the content below it down
so I would like to make it drop down menu so that it will slide to the
right. I could use another one but I like the styles of it. can somebody
help me out, just the first li?
take a look here http://jsfiddle.net/RXRBm/1/ thanks for all the help.
I have accordion menu but when sliding it pushes the content below it down
so I would like to make it drop down menu so that it will slide to the
right. I could use another one but I like the styles of it. can somebody
help me out, just the first li?
take a look here http://jsfiddle.net/RXRBm/1/ thanks for all the help.
Initialize a property in Entity Framework that already has a constructor
Initialize a property in Entity Framework that already has a constructor
Is there ANY way to initialize a property in an Entity Framework entity
that has a collection?
This is the generated code for an Entity that has a collection:
public partial class MyEntity
{
public MyEntity()
{
this.MySubEntities = new HashSet<MySubEntity>();
}
public bool IsActive {get; set;}
public virtual ICollection<MySubEntity> MySubEntities {get; set;}
}
If I need to make a new MyEntity that I want to default to IsActive =
true, it cannot be done! (Unless I edit the T4 template.)
Please tell me there is a way to default IsActive = True without editing
the generated file (or the T4).
Is there ANY way to initialize a property in an Entity Framework entity
that has a collection?
This is the generated code for an Entity that has a collection:
public partial class MyEntity
{
public MyEntity()
{
this.MySubEntities = new HashSet<MySubEntity>();
}
public bool IsActive {get; set;}
public virtual ICollection<MySubEntity> MySubEntities {get; set;}
}
If I need to make a new MyEntity that I want to default to IsActive =
true, it cannot be done! (Unless I edit the T4 template.)
Please tell me there is a way to default IsActive = True without editing
the generated file (or the T4).
Cannot set InputType number in AlertDialog with EditText
Cannot set InputType number in AlertDialog with EditText
I have an AlertDialog with 2 EditText and I need that second edit text
show only the number in the android soft keyboard
My try is this
OnClickListener addNewItemListener = new OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder alert = new AlertDialog.Builder(
MyActivity.this);
LinearLayout myLayout= new LinearLayout(MyActivity.this);
myLayout.setOrientation(LinearLayout.VERTICAL);
alert.setTitle(R.string.add_title);
alert.setMessage(R.string.add_message);
final TextView t1 = new TextView(MyActivity.this);
t1.setText("Name");
final EditText input1 = new EditText(MyActivity.this);
final TextView t2 = new TextView(MyActivity.this);
t2.setText("Value");
EditText input2 = new EditText(MyActivity.this);
input2.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
final EditText input2f = input2;
myLayout.addView(t1);
myLayout.addView(input1);
myLayout.addView(t2);
myLayout.addView(input2f);
alert.setView(myLayout);
alert.setPositiveButton(R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
}
});
alert.setNegativeButton(R.string.add,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
try {
String name =
input1.getText().toString();
double value =
Double.parseDouble(input2f
.getText().toString());
addItem(name, value);
} catch (RuntimeException e) {
Alerts.DatiErrati(MyActivity.this);
}
}
});
alert.show();
}
};
unfortunately also the second EditText input2f show the standard text
keyboard, ignoring
input2.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
How could I fix this?
I have an AlertDialog with 2 EditText and I need that second edit text
show only the number in the android soft keyboard
My try is this
OnClickListener addNewItemListener = new OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder alert = new AlertDialog.Builder(
MyActivity.this);
LinearLayout myLayout= new LinearLayout(MyActivity.this);
myLayout.setOrientation(LinearLayout.VERTICAL);
alert.setTitle(R.string.add_title);
alert.setMessage(R.string.add_message);
final TextView t1 = new TextView(MyActivity.this);
t1.setText("Name");
final EditText input1 = new EditText(MyActivity.this);
final TextView t2 = new TextView(MyActivity.this);
t2.setText("Value");
EditText input2 = new EditText(MyActivity.this);
input2.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
final EditText input2f = input2;
myLayout.addView(t1);
myLayout.addView(input1);
myLayout.addView(t2);
myLayout.addView(input2f);
alert.setView(myLayout);
alert.setPositiveButton(R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
}
});
alert.setNegativeButton(R.string.add,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
try {
String name =
input1.getText().toString();
double value =
Double.parseDouble(input2f
.getText().toString());
addItem(name, value);
} catch (RuntimeException e) {
Alerts.DatiErrati(MyActivity.this);
}
}
});
alert.show();
}
};
unfortunately also the second EditText input2f show the standard text
keyboard, ignoring
input2.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
How could I fix this?
Bibliography using BiblateX, Xetex and bidi creating wrong punctuation
Bibliography using BiblateX, Xetex and bidi creating wrong punctuation
Although a Newbie, I have been using XeteX, bidi and BiblateX with great
success in Urdu. I have alphabetical footnotes with most of the secondary
sources in the endnotes. The endnotes and bibliography are in English,
whereas the rest is in Urdu.
However,the bibliography has a punctuation problem. Periods and
parentheses are not where they should be (see example). I have the feeling
it has to do with the LRE command. It's nearly as if the text is LRE in
the bibliography whereas the punctuation is still trying to work RLE. I
have tried all forms of bidi commands, that hasn't helped.
Any ideas?
My minimal example:
% !TEX TS-program = xelatex
\TeXXeTstate=1
\documentclass[12pt,a4paper]{memoir}
\usepackage[a5paper, left=.915in,right=.915in,top=1.651cm,bottom=1.524cm]
{geometry}
\usepackage{fontspec}% font selecting commands
\usepackage{xunicode}% unicode character macros
\usepackage{wrapfig}
\usepackage[footnotesize,justification=centering]{caption}
\usepackage{float}
\usepackage{framed}
\usepackage{libertine}
\usepackage{bidi}
\usepackage{perpage}
\defaultfontfeatures{Scale=MatchLowercase, Mapping=tex-text}
\setmainfont[Script=Arabic,Scale=1.3, WordSpace=1]{Jameel Noori Nastaleeq}
\newfontfamily\latin[Ligatures=TeX]{Linux Libertine O}
\newfontfamily\greek[Script=Greek]{Linux Libertine O}
\fontspec[Script=Arabic,Scale=1.0,WordSpace=1]{Nafees}
\rightfootnoterule
\usepackage[perpage,bottom]{footmisc}
\usepackage{csquotes}
\pretitle{\begin{center}\LARGE}
\posttitle{\par\end{center}\vskip 6em}
%%% ToC (table of contents)APPEARANCE
\maxtocdepth{subsection} % include subsections
\renewcommand{\cftchapterpagefont}{}
\renewcommand{\cftchapterfont}{} % no bold!
\renewcommand*{\contentsname}{ÝÀÑÓÊ ö ãÖÇãیä}
\chapterstyle{ger}
\renewcommand*{\chaptername}{ÈÇÈ}
\renewcommand{\thepart}{}
\renewcommand{\printpartname}{}
\let\origfootnote\footnote
\renewcommand{\footnote}[1]{\kern-.2em\origfootnote{#1}}
\renewcommand*{\thefootnote}{\alph{footnote}}
\makepagenote
\renewcommand*{\pagenotesubhead}[3]{\section*{#2 #1}}
\renewcommand*{\notesname}{äæŠÓ}
\renewcommand*{\notenuminnotes}[1]{\latin #1.\space}
\renewcommand*{\prenoteinnotes}{\par\noindent\hangindent 2em}
\usepackage[backend=biber,autocite=footnote,sortcites=true,
style=authortitle-icomp,block=space,notetype=endonly,firstinits=true,language=british]{biblatex}
\addbibresource{bibliography.bib}
\title
{˜ÊÇÈ\\
{æÛیÑÀ}}
\author{ÎÇä}
\begin{document}
\setRL
\maketitle
\newpage
\tableofcontents*
\newpage
 ÇیãÇä ˜ی Ïæš ãیŸ Ǫی ÊÑÞی ˜Ñ ÑÀÿ ʪÿ! Êæ
ªÑ ˜Ó äÿ  ˜æ ÓÇÆی ˜ی یÑæی ˜Ñäÿ Óÿ Ñæ˜
áیÇ¿
\footnote{áÊیæŸ 5:\! 7}
ÒÀÑ ˜ÿ یÇáÿ ˜æ ÀæäŠæŸ ʘ ÇõŠªÇ ˜Ñ ÇõÓ äÿ ÈáÇ̪̘ ÇæÑ ÒäÏÀ Ïáی
Óÿ ÒÀÑ ˜æ ی áیÇ۔ یÀÇŸ ʘ Àã Ìæ ÓÇʪ ʪÿ
ÒیÇÏÀ ÊÑ ÓäȪáÿ ÀæÆÿ ʪÿ۔ áی˜ä ÌÈ Ïی˜ªÇ
\autocite[56--78]{Najim}
˜À æÀ ÒÀÑ ˜æ ی ˜Ñ ÊÀÀ ʘ Àä یÇ Àÿ Êæ Àã Çäÿ ÂäÓæÄŸ ˜æ Ñæ˜
äÀ Ó˜ÿ۔ ãیŸ Ȫی Çäÿ Â Ñ ÞÇÈæ äÀ Ç Ó˜Ç Èá˜À ÒÇÑ æ
ÞØÇÑ Ñæäÿ áÇ۔
\autocite[33--34]{Murray1974}
%%print endnote
\newpage
\setLR{\printpagenotes*}
%%print endnote
\newpage
\printbibliography%[heading=bibliography]%
\end{document}
The bibliography.bib file linked to this:
@ARTICLE{Murray1974,
author = {Robert Murray},
title = {The Exhortation to Candidates for Ascetical Vows at Baptism in
the Ancient Syrian Church},
journal = {New Testament Studies},
year = {1974–75},
volume = {21},
pages = {58–79},
timestamp = {2013.03.13}
}
@BOOK{Najim,
title = {Antioch and Syrian Christianity},
author = {Najim, Michel},
editor = {Frazer, Terry},
subtitle = {A Chalcedonian Perspective on a Spiritual Heritage},
timestamp = {2011.08.29},
url = {www.stnicholasla.com/frmichel/antiochandsyriacchristianity.pdf},
urldate = {2011-08-31}
}
My second problem: I would like to get rid of the Chapter Heading
including the number above the Urdu title äæŠÓ. And I would like to center
the subheadings (sorry, these are not evident in the example), as Urdu
headings flush left doesn't look good.
Although a Newbie, I have been using XeteX, bidi and BiblateX with great
success in Urdu. I have alphabetical footnotes with most of the secondary
sources in the endnotes. The endnotes and bibliography are in English,
whereas the rest is in Urdu.
However,the bibliography has a punctuation problem. Periods and
parentheses are not where they should be (see example). I have the feeling
it has to do with the LRE command. It's nearly as if the text is LRE in
the bibliography whereas the punctuation is still trying to work RLE. I
have tried all forms of bidi commands, that hasn't helped.
Any ideas?
My minimal example:
% !TEX TS-program = xelatex
\TeXXeTstate=1
\documentclass[12pt,a4paper]{memoir}
\usepackage[a5paper, left=.915in,right=.915in,top=1.651cm,bottom=1.524cm]
{geometry}
\usepackage{fontspec}% font selecting commands
\usepackage{xunicode}% unicode character macros
\usepackage{wrapfig}
\usepackage[footnotesize,justification=centering]{caption}
\usepackage{float}
\usepackage{framed}
\usepackage{libertine}
\usepackage{bidi}
\usepackage{perpage}
\defaultfontfeatures{Scale=MatchLowercase, Mapping=tex-text}
\setmainfont[Script=Arabic,Scale=1.3, WordSpace=1]{Jameel Noori Nastaleeq}
\newfontfamily\latin[Ligatures=TeX]{Linux Libertine O}
\newfontfamily\greek[Script=Greek]{Linux Libertine O}
\fontspec[Script=Arabic,Scale=1.0,WordSpace=1]{Nafees}
\rightfootnoterule
\usepackage[perpage,bottom]{footmisc}
\usepackage{csquotes}
\pretitle{\begin{center}\LARGE}
\posttitle{\par\end{center}\vskip 6em}
%%% ToC (table of contents)APPEARANCE
\maxtocdepth{subsection} % include subsections
\renewcommand{\cftchapterpagefont}{}
\renewcommand{\cftchapterfont}{} % no bold!
\renewcommand*{\contentsname}{ÝÀÑÓÊ ö ãÖÇãیä}
\chapterstyle{ger}
\renewcommand*{\chaptername}{ÈÇÈ}
\renewcommand{\thepart}{}
\renewcommand{\printpartname}{}
\let\origfootnote\footnote
\renewcommand{\footnote}[1]{\kern-.2em\origfootnote{#1}}
\renewcommand*{\thefootnote}{\alph{footnote}}
\makepagenote
\renewcommand*{\pagenotesubhead}[3]{\section*{#2 #1}}
\renewcommand*{\notesname}{äæŠÓ}
\renewcommand*{\notenuminnotes}[1]{\latin #1.\space}
\renewcommand*{\prenoteinnotes}{\par\noindent\hangindent 2em}
\usepackage[backend=biber,autocite=footnote,sortcites=true,
style=authortitle-icomp,block=space,notetype=endonly,firstinits=true,language=british]{biblatex}
\addbibresource{bibliography.bib}
\title
{˜ÊÇÈ\\
{æÛیÑÀ}}
\author{ÎÇä}
\begin{document}
\setRL
\maketitle
\newpage
\tableofcontents*
\newpage
 ÇیãÇä ˜ی Ïæš ãیŸ Ǫی ÊÑÞی ˜Ñ ÑÀÿ ʪÿ! Êæ
ªÑ ˜Ó äÿ  ˜æ ÓÇÆی ˜ی یÑæی ˜Ñäÿ Óÿ Ñæ˜
áیÇ¿
\footnote{áÊیæŸ 5:\! 7}
ÒÀÑ ˜ÿ یÇáÿ ˜æ ÀæäŠæŸ ʘ ÇõŠªÇ ˜Ñ ÇõÓ äÿ ÈáÇ̪̘ ÇæÑ ÒäÏÀ Ïáی
Óÿ ÒÀÑ ˜æ ی áیÇ۔ یÀÇŸ ʘ Àã Ìæ ÓÇʪ ʪÿ
ÒیÇÏÀ ÊÑ ÓäȪáÿ ÀæÆÿ ʪÿ۔ áی˜ä ÌÈ Ïی˜ªÇ
\autocite[56--78]{Najim}
˜À æÀ ÒÀÑ ˜æ ی ˜Ñ ÊÀÀ ʘ Àä یÇ Àÿ Êæ Àã Çäÿ ÂäÓæÄŸ ˜æ Ñæ˜
äÀ Ó˜ÿ۔ ãیŸ Ȫی Çäÿ Â Ñ ÞÇÈæ äÀ Ç Ó˜Ç Èá˜À ÒÇÑ æ
ÞØÇÑ Ñæäÿ áÇ۔
\autocite[33--34]{Murray1974}
%%print endnote
\newpage
\setLR{\printpagenotes*}
%%print endnote
\newpage
\printbibliography%[heading=bibliography]%
\end{document}
The bibliography.bib file linked to this:
@ARTICLE{Murray1974,
author = {Robert Murray},
title = {The Exhortation to Candidates for Ascetical Vows at Baptism in
the Ancient Syrian Church},
journal = {New Testament Studies},
year = {1974–75},
volume = {21},
pages = {58–79},
timestamp = {2013.03.13}
}
@BOOK{Najim,
title = {Antioch and Syrian Christianity},
author = {Najim, Michel},
editor = {Frazer, Terry},
subtitle = {A Chalcedonian Perspective on a Spiritual Heritage},
timestamp = {2011.08.29},
url = {www.stnicholasla.com/frmichel/antiochandsyriacchristianity.pdf},
urldate = {2011-08-31}
}
My second problem: I would like to get rid of the Chapter Heading
including the number above the Urdu title äæŠÓ. And I would like to center
the subheadings (sorry, these are not evident in the example), as Urdu
headings flush left doesn't look good.
How to append data only once using jquery
How to append data only once using jquery
Below is the my code for clicking functionality of tabs.
<body>
<div class="row-fluid">
<div class="span1 offset1">
<div class="tabbable" align="center">
<ul class="nav nav-tabs nav-stacked">
<li class="active"><a href="#tabs-1"
data-toggle="tab">Eat</a>
</li>
<li><a href="#tabs-2">Drink</a>
</li>
</ul>
</div>
</div>
<div id="1"></div>
</div>
<script type="text/javascript">
$("a[href=#tabs-1]").click(function() {
for (i = 0; i < mytabs.length; i++) {
$('div').append("<br>" + mytabs[i] + "<br>");
}
});
</script>
</body>
And here I am using javascript to store the values of tabs in array
<script>
$(function() {
$("#tabbable").tabs();
});
var i;
var mytabs = new Array();
mytabs[0] = "Saab";
mytabs[1] = "Volvo";
mytabs[2] = "BMW";
</script>
Now I want that after clicking on tabs the values stored in data should
get displayed. But what my code is doing , It is showing the data as many
times as the data is stored in array. Means I want output as
Saab,Volvo,BMW but is displaying it three times. Can anyone help me in
this that what to use instead of append so that i get the desired output.
Below is the my code for clicking functionality of tabs.
<body>
<div class="row-fluid">
<div class="span1 offset1">
<div class="tabbable" align="center">
<ul class="nav nav-tabs nav-stacked">
<li class="active"><a href="#tabs-1"
data-toggle="tab">Eat</a>
</li>
<li><a href="#tabs-2">Drink</a>
</li>
</ul>
</div>
</div>
<div id="1"></div>
</div>
<script type="text/javascript">
$("a[href=#tabs-1]").click(function() {
for (i = 0; i < mytabs.length; i++) {
$('div').append("<br>" + mytabs[i] + "<br>");
}
});
</script>
</body>
And here I am using javascript to store the values of tabs in array
<script>
$(function() {
$("#tabbable").tabs();
});
var i;
var mytabs = new Array();
mytabs[0] = "Saab";
mytabs[1] = "Volvo";
mytabs[2] = "BMW";
</script>
Now I want that after clicking on tabs the values stored in data should
get displayed. But what my code is doing , It is showing the data as many
times as the data is stored in array. Means I want output as
Saab,Volvo,BMW but is displaying it three times. Can anyone help me in
this that what to use instead of append so that i get the desired output.
Wednesday, 21 August 2013
Is there anything wrog with this SQL query?
Is there anything wrog with this SQL query?
Folowing is the query returning zero rows, actually it shouldn't:
SELECT distinct(usr.user_id) FROM OCN.users AS usr,
OCN.users_groups_subscribe AS usr_grp, OCN.tests_users AS test_usr WHERE
usr.user_id=usr_grp.subscribe_user_id AND
usr.user_id=test_usr.test_user_user_id AND test_user_test_id=116 AND
(usr.user_first_name LIKE '%ajay%' OR usr.user_last_name LIKE '%ajay%')
ORDER BY usr.user_first_name, usr.user_last_name
Folowing is the query returning zero rows, actually it shouldn't:
SELECT distinct(usr.user_id) FROM OCN.users AS usr,
OCN.users_groups_subscribe AS usr_grp, OCN.tests_users AS test_usr WHERE
usr.user_id=usr_grp.subscribe_user_id AND
usr.user_id=test_usr.test_user_user_id AND test_user_test_id=116 AND
(usr.user_first_name LIKE '%ajay%' OR usr.user_last_name LIKE '%ajay%')
ORDER BY usr.user_first_name, usr.user_last_name
A 1-1 continuous function from a compact space A into a Hausdorff space B
A 1-1 continuous function from a compact space A into a Hausdorff space B
I am following a proof for the theorem:
Let g be a 1-1 continuous function from a compact space $A$ into a
Hausdorff space $B$. Then $A$ and $g[A]$ are homeomorphic.
Proof:Clearly $g:A -> g[A]$ is onto, and given that $g$ is 1-1 and
continuous, so $g^{-1} : g[A] -> A$ exists.It must be shown that $g^{-1}$
is continuous.$g^{-1}$ is continuous if for every closed subset of $F$ of
$A$, $(g^{-1})^{-1}[F] = g[F]$ is a closed subset of $g[A]$. Now, the
closed subset $F$ of a compact space $A$ is also compact. Since $g$ is
continuous, $g[F]$ is a compact subset of $g[A]$.
I did not understand the last sentence. How it will be true.
I am following a proof for the theorem:
Let g be a 1-1 continuous function from a compact space $A$ into a
Hausdorff space $B$. Then $A$ and $g[A]$ are homeomorphic.
Proof:Clearly $g:A -> g[A]$ is onto, and given that $g$ is 1-1 and
continuous, so $g^{-1} : g[A] -> A$ exists.It must be shown that $g^{-1}$
is continuous.$g^{-1}$ is continuous if for every closed subset of $F$ of
$A$, $(g^{-1})^{-1}[F] = g[F]$ is a closed subset of $g[A]$. Now, the
closed subset $F$ of a compact space $A$ is also compact. Since $g$ is
continuous, $g[F]$ is a compact subset of $g[A]$.
I did not understand the last sentence. How it will be true.
jQuery UI Slider, IE9, line-height issue
jQuery UI Slider, IE9, line-height issue
I am making a textbox with adjustable font via a slider. It works perfect
in every browser (Chrome, Safari, Firefox), except IE9 and IE10 I believe.
It even works in IE8.
I have the slider change the font-size and the line-height:
$("#slider").slider({
min:10,
max:40,
step:2,
value:16,
slide:function(e,ui){
$("#ta").css({'font-size':ui.value+'px','line-height':(ui.value+4)+'px'});
}
});
When I adjust it in Chrome, it looks like this:
IE9 looks like this:
Any clue how to get the line-height to actually work with the slider in IE9?
Fiddle: http://jsfiddle.net/qc9Xu/
I am making a textbox with adjustable font via a slider. It works perfect
in every browser (Chrome, Safari, Firefox), except IE9 and IE10 I believe.
It even works in IE8.
I have the slider change the font-size and the line-height:
$("#slider").slider({
min:10,
max:40,
step:2,
value:16,
slide:function(e,ui){
$("#ta").css({'font-size':ui.value+'px','line-height':(ui.value+4)+'px'});
}
});
When I adjust it in Chrome, it looks like this:
IE9 looks like this:
Any clue how to get the line-height to actually work with the slider in IE9?
Fiddle: http://jsfiddle.net/qc9Xu/
Apache ignoring mime-type
Apache ignoring mime-type
I have a page that is using JWPlayer to serve a video in a variety of
format choices (mp4, m4v, ogv, webm). However, when accessing the page
from Firefox (23.0.1) or with PHP curl, Apache is returning a header
indicating the content-type as text/plain. Firefox (and newer IE versions,
unless in compatibility mode) will not play the video. I have tried adding
the mime types in mime.types, httpd.conf, and in an .htaccess file in the
directory.
mime.types
video/mp4 mp4 m4v
video/ogg ogv
video/webm webm
httpd.conf
AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm
.htaccess
AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm
I have tried with and without the dot in front of the extensions (which as
I understand should work either way). I have restarted Apache. I have
verified that I am editing the right configuration files. Still Apache
continues to return the text/plain type. Where have I gone wrong?
I have a page that is using JWPlayer to serve a video in a variety of
format choices (mp4, m4v, ogv, webm). However, when accessing the page
from Firefox (23.0.1) or with PHP curl, Apache is returning a header
indicating the content-type as text/plain. Firefox (and newer IE versions,
unless in compatibility mode) will not play the video. I have tried adding
the mime types in mime.types, httpd.conf, and in an .htaccess file in the
directory.
mime.types
video/mp4 mp4 m4v
video/ogg ogv
video/webm webm
httpd.conf
AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm
.htaccess
AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm
I have tried with and without the dot in front of the extensions (which as
I understand should work either way). I have restarted Apache. I have
verified that I am editing the right configuration files. Still Apache
continues to return the text/plain type. Where have I gone wrong?
Formatting wordpress text-editor line breaks for fpdf
Formatting wordpress text-editor line breaks for fpdf
I'm currently working on a script that essentially takes a wordpress post
entry and pastes it into a pdf along with a bunch of other info.
When I look at how wordpress saves text from its editor to the database,
it stores linebreaks as simply new lines, without an html tag. (There must
be better way to say this but I don't know what it is.) The library that
I'm referencing, FPDF, seems to need an explicit <br/> or equivalent to do
a line break.
So my question is:
How do I tell my script to replace these wordpress linebreaks with a <br/>?
Or if you're familiar with FPDF and have a better suggestion, please feel
free to share.
I'm also looking for the intelligent way to refer to these sans-html-tag
"wordpress-created line breaks"
Help with any of these three issues would be much appreciated.
I'm currently working on a script that essentially takes a wordpress post
entry and pastes it into a pdf along with a bunch of other info.
When I look at how wordpress saves text from its editor to the database,
it stores linebreaks as simply new lines, without an html tag. (There must
be better way to say this but I don't know what it is.) The library that
I'm referencing, FPDF, seems to need an explicit <br/> or equivalent to do
a line break.
So my question is:
How do I tell my script to replace these wordpress linebreaks with a <br/>?
Or if you're familiar with FPDF and have a better suggestion, please feel
free to share.
I'm also looking for the intelligent way to refer to these sans-html-tag
"wordpress-created line breaks"
Help with any of these three issues would be much appreciated.
CMS File Extension
CMS File Extension
Fellow Forum Members, I'm working with a Common Source Data Base (CSDB)
which only imports tabular data as long as it has a CMS or CMSX extension.
From what I have Googled, the CMS extension represents Content Management
System.
My question to anyone out there is what application do I need to use for
the purpose of converting my tabular data currently housed in Excel over
to the CMS format? I checked already and Microsoft Excel does not export
as a CMS file. Is there an open source application that can handle CMS
format output? What is a CMS file? Is it coded using XML tags? Any help
will be greatly appreciated. Thanks.
Fellow Forum Members, I'm working with a Common Source Data Base (CSDB)
which only imports tabular data as long as it has a CMS or CMSX extension.
From what I have Googled, the CMS extension represents Content Management
System.
My question to anyone out there is what application do I need to use for
the purpose of converting my tabular data currently housed in Excel over
to the CMS format? I checked already and Microsoft Excel does not export
as a CMS file. Is there an open source application that can handle CMS
format output? What is a CMS file? Is it coded using XML tags? Any help
will be greatly appreciated. Thanks.
Validate Form and send unvalidated form inputs with angularJS
Validate Form and send unvalidated form inputs with angularJS
I have a question concerning angularJS.
I want to validate a form. If there is an error, I want do an action in
order to process the data further. I.e. users has not filled all fields,
but I want send the inputs nevertheless.
Thanks in advance...
I have a question concerning angularJS.
I want to validate a form. If there is an error, I want do an action in
order to process the data further. I.e. users has not filled all fields,
but I want send the inputs nevertheless.
Thanks in advance...
Tuesday, 20 August 2013
500 error in JSP
500 error in JSP
I am new to JSP. I am getting the following error whe I run my JSP code.
org.apache.jasper.JasperException: /jsps/mailServerConfigure.jsp(1411,24)
Invalid standard action
1411 line is
<input type="text" name="apn0" id="apn0" value= "<jsp:getPrpoerty name =
"header" property= "apn1" />" MAXLENGTH=30 size=15 />
I have getters and setters for the variables. What's wrong?
I am new to JSP. I am getting the following error whe I run my JSP code.
org.apache.jasper.JasperException: /jsps/mailServerConfigure.jsp(1411,24)
Invalid standard action
1411 line is
<input type="text" name="apn0" id="apn0" value= "<jsp:getPrpoerty name =
"header" property= "apn1" />" MAXLENGTH=30 size=15 />
I have getters and setters for the variables. What's wrong?
Dealing with special characters in object property names
Dealing with special characters in object property names
I am working with a database created by a university professor's intern.
Many of the fields have names like 'Revenues_(budget)'.
Currently when working with objects that have the fields as properties I
do something like
$f = 'Revenues_(budget)';
echo $obj->$f;
This works fine but I was wondering if there might be a more elegant or at
least concise way to handle these?
I am working with a database created by a university professor's intern.
Many of the fields have names like 'Revenues_(budget)'.
Currently when working with objects that have the fields as properties I
do something like
$f = 'Revenues_(budget)';
echo $obj->$f;
This works fine but I was wondering if there might be a more elegant or at
least concise way to handle these?
Print data from a text file into a raw format?
Print data from a text file into a raw format?
How can I get a text file and print the data into a raw format with all of
the /n and /r and other code(s)?
Thanks - Hyflex
How can I get a text file and print the data into a raw format with all of
the /n and /r and other code(s)?
Thanks - Hyflex
Drawing mulitple MKpolygons in a single
Drawing mulitple MKpolygons in a single
I'm using a MKMapView to display a map with a bunch of MKPolygons on it.
It can at times end up drawing 1000+ MKPolygons and is starting to affect
performance.
Is there a way to draw the polygons on the map more efficiently? Can I
draw them all in a single overlay?
I'm using a MKMapView to display a map with a bunch of MKPolygons on it.
It can at times end up drawing 1000+ MKPolygons and is starting to affect
performance.
Is there a way to draw the polygons on the map more efficiently? Can I
draw them all in a single overlay?
How to determine Controller's Area in ASP.NET MVC
How to determine Controller's Area in ASP.NET MVC
I have an ActionDescriptor from which I retrieve information about an
action and its controller:
ActionDescriptor desc = ...;
string action = desc.ActionName;
string controller = desc.ControllerDescriptor.ControllerName;
string area = ?;
I'm wondering if there is a better way to determine the controller's area
than having to parse its namespace, which I'm currently doing like so:
// e.g., Company.Areas.Foo.Controllers
var parts =
desc.ControllerDescriptor.ControllerType.Namespace.Split('.').ToList();
var areaIndex = parts.IndexOf("Areas");
if (areaIndex > -1) area = parts[areaIndex + 1];
// area = "Foo"
I have an ActionDescriptor from which I retrieve information about an
action and its controller:
ActionDescriptor desc = ...;
string action = desc.ActionName;
string controller = desc.ControllerDescriptor.ControllerName;
string area = ?;
I'm wondering if there is a better way to determine the controller's area
than having to parse its namespace, which I'm currently doing like so:
// e.g., Company.Areas.Foo.Controllers
var parts =
desc.ControllerDescriptor.ControllerType.Namespace.Split('.').ToList();
var areaIndex = parts.IndexOf("Areas");
if (areaIndex > -1) area = parts[areaIndex + 1];
// area = "Foo"
ActivityThread:source not found
ActivityThread:source not found
I am developping an android application to compare two still images. But
when Itried to debug the project I had source not found in ActivityThread.
here is my code
Finder class
package com.example.testmatching;
import java.util.LinkedList;
import java.util.List;
import org.opencv.calib3d.Calib3d;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.core.MatOfDMatch;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.MatOfPoint2f;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.features2d.DMatch;
import org.opencv.features2d.DescriptorExtractor;
import org.opencv.features2d.DescriptorMatcher;
import org.opencv.features2d.FeatureDetector;
import org.opencv.features2d.Features2d;
import org.opencv.features2d.KeyPoint;
import org.opencv.highgui.Highgui;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.RelativeLayout.LayoutParams;
//import org.opencv.core.MatOfPoint;
//import android.view.Menu;
public class Finder extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comparemain);
}
private static final int CV_LOAD_IMAGE_GRAYSCALE = 0;
private static final String TAG = "OCV::Activity";
//@Override
/*public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.comparemain, menu);
return true;
}*/
public void run(String pathObject, String pathScene, String pathResult) {
System.out.println("\nRunning FindObject");
Mat img_object = new Mat();
Utils.bitmapToMat(theImage, theImageMat ); // converts some Bitmap to
some Mat*/
Mat img_object =
Highgui.imread("C:/work/OpenCV4Android/".concat(pathObject),
CV_LOAD_IMAGE_GRAYSCALE); //0 = CV_LOAD_IMAGE_GRAYSCALE
Mat img_scene =
Highgui.imread("C:/work/OpenCV4Android/".concat(pathScene),
CV_LOAD_IMAGE_GRAYSCALE);
if( (img_object.empty()) || (img_scene.empty()) )
{ Log.d(TAG,"failing to read images");
//System.out.println("images non lues");
return;}
FeatureDetector detector = FeatureDetector.create(4); //4 = SURF
MatOfKeyPoint keypoints_object = new MatOfKeyPoint();
MatOfKeyPoint keypoints_scene = new MatOfKeyPoint();
detector.detect(img_object, keypoints_object);
detector.detect(img_scene, keypoints_scene);
DescriptorExtractor extractor = DescriptorExtractor.create(2); //2 =
SURF;
Mat descriptor_object = new Mat();
Mat descriptor_scene = new Mat() ;
extractor.compute(img_object, keypoints_object, descriptor_object);
extractor.compute(img_scene, keypoints_scene, descriptor_scene);
DescriptorMatcher matcher = DescriptorMatcher.create(1); // 1 =
FLANNBASED
MatOfDMatch matches = new MatOfDMatch();
matcher.match(descriptor_object, descriptor_scene, matches);
List<DMatch> matchesList = matches.toList();
Double max_dist = 0.0;
Double min_dist = 100.0;
for(int i = 0; i < descriptor_object.rows(); i++){
Double dist = (double) matchesList.get(i).distance;
if(dist < min_dist) min_dist = dist;
if(dist > max_dist) max_dist = dist;
}
System.out.println("-- Max dist : " + max_dist);
System.out.println("-- Min dist : " + min_dist);
LinkedList<DMatch> good_matches = new LinkedList<DMatch>();
MatOfDMatch gm = new MatOfDMatch();
for(int i = 0; i < descriptor_object.rows(); i++){
if(matchesList.get(i).distance < 3*min_dist){
good_matches.addLast(matchesList.get(i));
}
}
gm.fromList(good_matches);
Mat img_matches = new Mat();
Features2d.drawMatches(
img_object,
keypoints_object,
img_scene,
keypoints_scene,
gm,
img_matches,
new Scalar(255,0,0),
new Scalar(0,0,255),
new MatOfByte(),
2);
LinkedList<Point> objList = new LinkedList<Point>();
LinkedList<Point> sceneList = new LinkedList<Point>();
List<KeyPoint> keypoints_objectList = keypoints_object.toList();
List<KeyPoint> keypoints_sceneList = keypoints_scene.toList();
for(int i = 0; i<good_matches.size(); i++){
objList.addLast(keypoints_objectList.get(good_matches.get(i).queryIdx).pt);
sceneList.addLast(keypoints_sceneList.get(good_matches.get(i).trainIdx).pt);
}
MatOfPoint2f obj = new MatOfPoint2f();
obj.fromList(objList);
MatOfPoint2f scene = new MatOfPoint2f();
scene.fromList(sceneList);
//findHomography sert à trouver la transformation entre les good matches
Mat hg = Calib3d.findHomography(obj, scene);
Mat obj_corners = new Mat(4,1,CvType.CV_32FC2);
Mat scene_corners = new Mat(4,1,CvType.CV_32FC2);
obj_corners.put(0, 0, new double[] {0,0});
obj_corners.put(1, 0, new double[] {img_object.cols(),0});
obj_corners.put(2, 0, new double[]
{img_object.cols(),img_object.rows()});
obj_corners.put(3, 0, new double[] {0,img_object.rows()});
//obj_corners:input
Core.perspectiveTransform(obj_corners,scene_corners, hg);
Core.line(img_matches, new Point(scene_corners.get(0,0)), new
Point(scene_corners.get(1,0)), new Scalar(0, 255, 0),4);
Core.line(img_matches, new Point(scene_corners.get(1,0)), new
Point(scene_corners.get(2,0)), new Scalar(0, 255, 0),4);
Core.line(img_matches, new Point(scene_corners.get(2,0)), new
Point(scene_corners.get(3,0)), new Scalar(0, 255, 0),4);
Core.line(img_matches, new Point(scene_corners.get(3,0)), new
Point(scene_corners.get(0,0)), new Scalar(0, 255, 0),4);
//Sauvegarde du résultat
System.out.println(String.format("Writing %s", pathResult));
Boolean bool=false;
Highgui.imwrite(pathResult, img_matches);
if (bool == true)
Log.d(TAG, "SUCCESS writing image to external storage");
else
Log.d(TAG, "Fail writing image to external storage");
ImageView imageView = new ImageView(getApplicationContext());
//ImageView jpgView = (ImageView)findViewById(R.id.ImageView01);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
/**/Bitmap image = BitmapFactory.decodeFile(pathResult);
imageView.setImageBitmap(image);
//RelativeLayout rl = (RelativeLayout) findViewById(R.id.);
addContentView(imageView, lp);
}
}
main activity
package com.example.testmatching;
import com.example.testmatching.Finder;
public class COMPAREMainActivity {
public static Finder fn=new Finder();
public static void main(String[] args) {
// System.loadLibrary("opencv_java246");
fn.run("input1.png", "input2.png","resultat.png");
}
}
I put a breakpoint at that line
Mat img_object =
Highgui.imread("C:/work/OpenCV4Android/".concat(pathObject),
CV_LOAD_IMAGE_GRAYSCALE);
I want to test if the operation of reading the image from that folder
worked or not
I am developping an android application to compare two still images. But
when Itried to debug the project I had source not found in ActivityThread.
here is my code
Finder class
package com.example.testmatching;
import java.util.LinkedList;
import java.util.List;
import org.opencv.calib3d.Calib3d;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.core.MatOfDMatch;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.MatOfPoint2f;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.features2d.DMatch;
import org.opencv.features2d.DescriptorExtractor;
import org.opencv.features2d.DescriptorMatcher;
import org.opencv.features2d.FeatureDetector;
import org.opencv.features2d.Features2d;
import org.opencv.features2d.KeyPoint;
import org.opencv.highgui.Highgui;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.RelativeLayout.LayoutParams;
//import org.opencv.core.MatOfPoint;
//import android.view.Menu;
public class Finder extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comparemain);
}
private static final int CV_LOAD_IMAGE_GRAYSCALE = 0;
private static final String TAG = "OCV::Activity";
//@Override
/*public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.comparemain, menu);
return true;
}*/
public void run(String pathObject, String pathScene, String pathResult) {
System.out.println("\nRunning FindObject");
Mat img_object = new Mat();
Utils.bitmapToMat(theImage, theImageMat ); // converts some Bitmap to
some Mat*/
Mat img_object =
Highgui.imread("C:/work/OpenCV4Android/".concat(pathObject),
CV_LOAD_IMAGE_GRAYSCALE); //0 = CV_LOAD_IMAGE_GRAYSCALE
Mat img_scene =
Highgui.imread("C:/work/OpenCV4Android/".concat(pathScene),
CV_LOAD_IMAGE_GRAYSCALE);
if( (img_object.empty()) || (img_scene.empty()) )
{ Log.d(TAG,"failing to read images");
//System.out.println("images non lues");
return;}
FeatureDetector detector = FeatureDetector.create(4); //4 = SURF
MatOfKeyPoint keypoints_object = new MatOfKeyPoint();
MatOfKeyPoint keypoints_scene = new MatOfKeyPoint();
detector.detect(img_object, keypoints_object);
detector.detect(img_scene, keypoints_scene);
DescriptorExtractor extractor = DescriptorExtractor.create(2); //2 =
SURF;
Mat descriptor_object = new Mat();
Mat descriptor_scene = new Mat() ;
extractor.compute(img_object, keypoints_object, descriptor_object);
extractor.compute(img_scene, keypoints_scene, descriptor_scene);
DescriptorMatcher matcher = DescriptorMatcher.create(1); // 1 =
FLANNBASED
MatOfDMatch matches = new MatOfDMatch();
matcher.match(descriptor_object, descriptor_scene, matches);
List<DMatch> matchesList = matches.toList();
Double max_dist = 0.0;
Double min_dist = 100.0;
for(int i = 0; i < descriptor_object.rows(); i++){
Double dist = (double) matchesList.get(i).distance;
if(dist < min_dist) min_dist = dist;
if(dist > max_dist) max_dist = dist;
}
System.out.println("-- Max dist : " + max_dist);
System.out.println("-- Min dist : " + min_dist);
LinkedList<DMatch> good_matches = new LinkedList<DMatch>();
MatOfDMatch gm = new MatOfDMatch();
for(int i = 0; i < descriptor_object.rows(); i++){
if(matchesList.get(i).distance < 3*min_dist){
good_matches.addLast(matchesList.get(i));
}
}
gm.fromList(good_matches);
Mat img_matches = new Mat();
Features2d.drawMatches(
img_object,
keypoints_object,
img_scene,
keypoints_scene,
gm,
img_matches,
new Scalar(255,0,0),
new Scalar(0,0,255),
new MatOfByte(),
2);
LinkedList<Point> objList = new LinkedList<Point>();
LinkedList<Point> sceneList = new LinkedList<Point>();
List<KeyPoint> keypoints_objectList = keypoints_object.toList();
List<KeyPoint> keypoints_sceneList = keypoints_scene.toList();
for(int i = 0; i<good_matches.size(); i++){
objList.addLast(keypoints_objectList.get(good_matches.get(i).queryIdx).pt);
sceneList.addLast(keypoints_sceneList.get(good_matches.get(i).trainIdx).pt);
}
MatOfPoint2f obj = new MatOfPoint2f();
obj.fromList(objList);
MatOfPoint2f scene = new MatOfPoint2f();
scene.fromList(sceneList);
//findHomography sert à trouver la transformation entre les good matches
Mat hg = Calib3d.findHomography(obj, scene);
Mat obj_corners = new Mat(4,1,CvType.CV_32FC2);
Mat scene_corners = new Mat(4,1,CvType.CV_32FC2);
obj_corners.put(0, 0, new double[] {0,0});
obj_corners.put(1, 0, new double[] {img_object.cols(),0});
obj_corners.put(2, 0, new double[]
{img_object.cols(),img_object.rows()});
obj_corners.put(3, 0, new double[] {0,img_object.rows()});
//obj_corners:input
Core.perspectiveTransform(obj_corners,scene_corners, hg);
Core.line(img_matches, new Point(scene_corners.get(0,0)), new
Point(scene_corners.get(1,0)), new Scalar(0, 255, 0),4);
Core.line(img_matches, new Point(scene_corners.get(1,0)), new
Point(scene_corners.get(2,0)), new Scalar(0, 255, 0),4);
Core.line(img_matches, new Point(scene_corners.get(2,0)), new
Point(scene_corners.get(3,0)), new Scalar(0, 255, 0),4);
Core.line(img_matches, new Point(scene_corners.get(3,0)), new
Point(scene_corners.get(0,0)), new Scalar(0, 255, 0),4);
//Sauvegarde du résultat
System.out.println(String.format("Writing %s", pathResult));
Boolean bool=false;
Highgui.imwrite(pathResult, img_matches);
if (bool == true)
Log.d(TAG, "SUCCESS writing image to external storage");
else
Log.d(TAG, "Fail writing image to external storage");
ImageView imageView = new ImageView(getApplicationContext());
//ImageView jpgView = (ImageView)findViewById(R.id.ImageView01);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
/**/Bitmap image = BitmapFactory.decodeFile(pathResult);
imageView.setImageBitmap(image);
//RelativeLayout rl = (RelativeLayout) findViewById(R.id.);
addContentView(imageView, lp);
}
}
main activity
package com.example.testmatching;
import com.example.testmatching.Finder;
public class COMPAREMainActivity {
public static Finder fn=new Finder();
public static void main(String[] args) {
// System.loadLibrary("opencv_java246");
fn.run("input1.png", "input2.png","resultat.png");
}
}
I put a breakpoint at that line
Mat img_object =
Highgui.imread("C:/work/OpenCV4Android/".concat(pathObject),
CV_LOAD_IMAGE_GRAYSCALE);
I want to test if the operation of reading the image from that folder
worked or not
combobox steal keyboard from main window in pyqt
combobox steal keyboard from main window in pyqt
I'm writing a small pyqt program. I want the main window to to react to
arrow movement. I added an event to my MainGui class, keyPressEvent, that
handle this. The event work fine as long as I don't press certain buttons
such as Key_Up or Key_Down are directed to my (currently only) QComboBox
and not to my mainGui. I tried to give the focus to mainGui after each
paintEvent but then I need to double click on buttons/comboBox.
Then I tried to use the MousePressEvent to check if a certain element is
under the mouse. This work fine with the comboBox, but not with the
button.
So, how can I direct key events to the mainGui or give the focus to QButtons?
I'm writing a small pyqt program. I want the main window to to react to
arrow movement. I added an event to my MainGui class, keyPressEvent, that
handle this. The event work fine as long as I don't press certain buttons
such as Key_Up or Key_Down are directed to my (currently only) QComboBox
and not to my mainGui. I tried to give the focus to mainGui after each
paintEvent but then I need to double click on buttons/comboBox.
Then I tried to use the MousePressEvent to check if a certain element is
under the mouse. This work fine with the comboBox, but not with the
button.
So, how can I direct key events to the mainGui or give the focus to QButtons?
Monday, 19 August 2013
Missing Screenshot Status in itunes connect
Missing Screenshot Status in itunes connect
I developing an application in rhomobile and made a build for ios as .ipa
file and after uploading my binary file through application loader into
itunes connect i get the error status as Missing Screen shots which i have
attatched .i have added 2 screen shots in 3.5 and 4 inch display where 3.5
image sizes are 320*480 and 4 inch screenshots of size 640*960 .I have not
added any screenshots for ipad as this app is only for iphone .Do i need
to add ipad screenshots .i have deleted a launch image
namedDefault-568h@2x.png also .
thanks in advance
I developing an application in rhomobile and made a build for ios as .ipa
file and after uploading my binary file through application loader into
itunes connect i get the error status as Missing Screen shots which i have
attatched .i have added 2 screen shots in 3.5 and 4 inch display where 3.5
image sizes are 320*480 and 4 inch screenshots of size 640*960 .I have not
added any screenshots for ipad as this app is only for iphone .Do i need
to add ipad screenshots .i have deleted a launch image
namedDefault-568h@2x.png also .
thanks in advance
Mobile Website for Iphone
Mobile Website for Iphone
I want to know if it is possible to make a mobile website and store it in
my iPhone. My iPhone would be the localhost. If it is possible, do I need
to use any specific web technology for that?
As it is for now, what I want to do is pretty simple, I want the user to
input a value, then the website would generate a certain number of forms
based on the input of the user.
I want to know if it is possible to make a mobile website and store it in
my iPhone. My iPhone would be the localhost. If it is possible, do I need
to use any specific web technology for that?
As it is for now, what I want to do is pretty simple, I want the user to
input a value, then the website would generate a certain number of forms
based on the input of the user.
Autofill pop up boxes that appear in UIWebKit
Autofill pop up boxes that appear in UIWebKit
I am needing to autofil a login procedure for an app that a client wants.
Now when I am on "any" network other that their own one, I can just inject
JavaScript into the relevant fields. But when I connect to their Wi-Fi
this isn't possible because that website seems to get by passed - or
presented in a different way.
On a normal desktop browser and mobile safari I get an AlertView which
allows me to type in the credentials. However UIWebView doesn't allow this
and also it doesn't show up at all leaving the page blank.
Sorry for the long background - but the question is, is there anyway to
still have the login work automatically with that happening.
The information is stored securely in the app before anyone asks:-)
Thanks I advance.
I am needing to autofil a login procedure for an app that a client wants.
Now when I am on "any" network other that their own one, I can just inject
JavaScript into the relevant fields. But when I connect to their Wi-Fi
this isn't possible because that website seems to get by passed - or
presented in a different way.
On a normal desktop browser and mobile safari I get an AlertView which
allows me to type in the credentials. However UIWebView doesn't allow this
and also it doesn't show up at all leaving the page blank.
Sorry for the long background - but the question is, is there anyway to
still have the login work automatically with that happening.
The information is stored securely in the app before anyone asks:-)
Thanks I advance.
Include a file to an executable script, grab line 1 and line 2, assign them to data_holders
Include a file to an executable script, grab line 1 and line 2, assign
them to data_holders
Assume that there is a file named a.txt
which contains:
aaa
bbb
i need to create an executable script that
will grab these 2 lines from the a.txt
and then print them in the terminal.
in other words when i run..
./script
it needs to print
aaa:bbb
them to data_holders
Assume that there is a file named a.txt
which contains:
aaa
bbb
i need to create an executable script that
will grab these 2 lines from the a.txt
and then print them in the terminal.
in other words when i run..
./script
it needs to print
aaa:bbb
AMD APP include files are missing some functions and types
AMD APP include files are missing some functions and types
I'm writing OpenCL code on Windows7 + Cygwin + AMD APP (downloaded a few
weeks ago). My code works, but - some of the kernel-accessible functions
are missing from the header files, e.g.:
void barrier(cl_mem_fence_flags flags)
event_t async_work_group_copy(
__local gentype *dst,
const __global gentype *src,
size_t num_gentypes,
event_t event)
as well as the event_t data type. Like I said, this does not prevent
compilation, since the kernels are not compiled by my C compiler but by
the OpenCL library.
I'm writing OpenCL code on Windows7 + Cygwin + AMD APP (downloaded a few
weeks ago). My code works, but - some of the kernel-accessible functions
are missing from the header files, e.g.:
void barrier(cl_mem_fence_flags flags)
event_t async_work_group_copy(
__local gentype *dst,
const __global gentype *src,
size_t num_gentypes,
event_t event)
as well as the event_t data type. Like I said, this does not prevent
compilation, since the kernels are not compiled by my C compiler but by
the OpenCL library.
Subscribe to:
Comments (Atom)