gmail Sidebar gadget is not showing
i am following this tutorial
https://developers.google.com/gmail/sidebar_gadgets when i am trying to
add a Hello World sidebar gadget to my gmail. i first hosted it on
http://cloudfactor9.appspot.com/ after that i added it in gadgets as you
can see in screen shot after that when i signout and signin into my gmail
there is no Hello World widget.can any one please tell why i am not able
to see Hello World widget ?? screenshot of gmail is
Saturday, 31 August 2013
Needs help in looping and to remove duplication
Needs help in looping and to remove duplication
helo everybody, I developed a code to search "-" and "/" and then to
compare and arrange them .. But unfortunatly, it only works for two
strings to compare and if more than two strings compared by loop, it gives
redundent data .. Help me, Thankx in anticipation ..
for($x=1, $y = 2; $x<$arrlength, $y<$arrlength; $x++, $y++) {
switch ($sort[$x])
{
case (strncasecmp($sort[$x],$sort[$y],strpos($sort[$x],'-')) == 0):
if
(substr(substr($sort[$x],0,strpos($sort[$y],'/')),0,strpos($sort[$y],'-'))
== false ){
echo " <TH class=\"tr1 td26\"><table><caption><P class=\"p16
ft4\">".substr($sort[$y],0,strpos($sort[$x],'-'))."</P></caption></table>";
echo "<P class=\"p12
ft4\">".ltrim(substr($sort[$x],strpos($sort[$x],'-')),"-")."</p></TH>";
echo " <TH class=\"tr1 td26\"><P class=\"p12
ft4\">".ltrim(substr($sort[$y],strpos($sort[$y],'-')),"-")."</P></TH>";
}
else {
echo " <TH class=\"tr1 td26\">";
echo " <table><caption><u><P class=\"p16
ft4\">".rtrim(rtrim((ltrim(substr(substr($sort[$x],strpos(strpos($sort[$x],'-'),'/')),strpos($sort[$x],'/')),"/")),ltrim(substr($sort[$x],strpos($sort[$x],'-')),"-")),"-")."</p><u></caption></table>";
echo "<P class=\"p12
ft4\">".ltrim(substr($sort[$x],strpos($sort[$x],'-')),"-")."</p></TH>";
echo " <TH class=\"tr1 td26\"><P class=\"p12
ft4\">".ltrim(substr($sort[$y],strpos($sort[$y],'-')),"-")."</P></TH>";
}
break;
case (strncasecmp($sort[$x],$sort[$y],strpos($sort[$x],'-')) <= 0):
echo " <TH class=\"tr1 td26\"><P class=\"p12
ft4\">".$sort[$x]."</P></TH>";
break;
case ((strncasecmp($sort[$x],$sort[$y],strpos($sort[$x],'/')) == 0) &&
(substr(substr($sort[$y],0,strpos($sort[$y],'/')),0,strpos($sort[$y],'-'))
!== false )) :
echo " <P class=\"p17
ft4\">".substr($sort[$y],0,strpos($sort[$x],'/'))."</P>";
break;
}
}
helo everybody, I developed a code to search "-" and "/" and then to
compare and arrange them .. But unfortunatly, it only works for two
strings to compare and if more than two strings compared by loop, it gives
redundent data .. Help me, Thankx in anticipation ..
for($x=1, $y = 2; $x<$arrlength, $y<$arrlength; $x++, $y++) {
switch ($sort[$x])
{
case (strncasecmp($sort[$x],$sort[$y],strpos($sort[$x],'-')) == 0):
if
(substr(substr($sort[$x],0,strpos($sort[$y],'/')),0,strpos($sort[$y],'-'))
== false ){
echo " <TH class=\"tr1 td26\"><table><caption><P class=\"p16
ft4\">".substr($sort[$y],0,strpos($sort[$x],'-'))."</P></caption></table>";
echo "<P class=\"p12
ft4\">".ltrim(substr($sort[$x],strpos($sort[$x],'-')),"-")."</p></TH>";
echo " <TH class=\"tr1 td26\"><P class=\"p12
ft4\">".ltrim(substr($sort[$y],strpos($sort[$y],'-')),"-")."</P></TH>";
}
else {
echo " <TH class=\"tr1 td26\">";
echo " <table><caption><u><P class=\"p16
ft4\">".rtrim(rtrim((ltrim(substr(substr($sort[$x],strpos(strpos($sort[$x],'-'),'/')),strpos($sort[$x],'/')),"/")),ltrim(substr($sort[$x],strpos($sort[$x],'-')),"-")),"-")."</p><u></caption></table>";
echo "<P class=\"p12
ft4\">".ltrim(substr($sort[$x],strpos($sort[$x],'-')),"-")."</p></TH>";
echo " <TH class=\"tr1 td26\"><P class=\"p12
ft4\">".ltrim(substr($sort[$y],strpos($sort[$y],'-')),"-")."</P></TH>";
}
break;
case (strncasecmp($sort[$x],$sort[$y],strpos($sort[$x],'-')) <= 0):
echo " <TH class=\"tr1 td26\"><P class=\"p12
ft4\">".$sort[$x]."</P></TH>";
break;
case ((strncasecmp($sort[$x],$sort[$y],strpos($sort[$x],'/')) == 0) &&
(substr(substr($sort[$y],0,strpos($sort[$y],'/')),0,strpos($sort[$y],'-'))
!== false )) :
echo " <P class=\"p17
ft4\">".substr($sort[$y],0,strpos($sort[$x],'/'))."</P>";
break;
}
}
Is it possible to sort items in FSO with classic asp?
Is it possible to sort items in FSO with classic asp?
Im using the following code on an old IIS machine to generate XML for a
mobile app I have built for android and ios devices... it works, but I am
now wanting to figure out how I would go about SORTING by date last
modified so the list has the NEWEST files at top... my question is, based
on how I have my code structured below,
is this possible with my existing code ( sorting 'x' somehow? )?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.ContentType = "text/xml"%>
<%Response.AddHeader "Content-Type","text/xml"%>
<songlist>
<%
dim fs,fo,x
dim i
set fs=Server.CreateObject("Scripting.FileSystemObject")
'point to a specific folder on the server to get files listing from...
set fo=fs.GetFolder(Server.MapPath("./songs"))
i = -1
for each x in fo.files
'loop through all the files found, use var 'i' as a counter for each...
i = i + 1
'only get files where the extension is 'mp3' -- we only want the mp3 files
to show in list...
if right(x,3) = "mp3" then
%>
<song>
<songid><%=i%></songid>
<name><%= replace(replace(x.Name, "-", " "), ".mp3", "")%></name>
<filename><%=x.Name%></filename>
<datemodified><%=x.DateLastModified%></datemodified>
</song>
<%
end if
next
set fo=nothing
set fs=nothing
%>
</songlist>
Im using the following code on an old IIS machine to generate XML for a
mobile app I have built for android and ios devices... it works, but I am
now wanting to figure out how I would go about SORTING by date last
modified so the list has the NEWEST files at top... my question is, based
on how I have my code structured below,
is this possible with my existing code ( sorting 'x' somehow? )?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.ContentType = "text/xml"%>
<%Response.AddHeader "Content-Type","text/xml"%>
<songlist>
<%
dim fs,fo,x
dim i
set fs=Server.CreateObject("Scripting.FileSystemObject")
'point to a specific folder on the server to get files listing from...
set fo=fs.GetFolder(Server.MapPath("./songs"))
i = -1
for each x in fo.files
'loop through all the files found, use var 'i' as a counter for each...
i = i + 1
'only get files where the extension is 'mp3' -- we only want the mp3 files
to show in list...
if right(x,3) = "mp3" then
%>
<song>
<songid><%=i%></songid>
<name><%= replace(replace(x.Name, "-", " "), ".mp3", "")%></name>
<filename><%=x.Name%></filename>
<datemodified><%=x.DateLastModified%></datemodified>
</song>
<%
end if
next
set fo=nothing
set fs=nothing
%>
</songlist>
MySQL really unexpected error. BIGINT out of range
MySQL really unexpected error. BIGINT out of range
I have this kinda complicated query that is well explained in this
question. I haven't changed anything in the query or anything relating to
this system , however I suddenly started getting this error
BIGINT UNSIGNED value is out of range in '(_db.ads.impressions_total -
(cast(((curdate()) - cast(_db.ads.start as date)) as unsigned) *
_db.ads.impressions_perday))'
I'm really confused, I guess something is not caching right but what can I
do? I really need help..
I have this kinda complicated query that is well explained in this
question. I haven't changed anything in the query or anything relating to
this system , however I suddenly started getting this error
BIGINT UNSIGNED value is out of range in '(_db.ads.impressions_total -
(cast(((curdate()) - cast(_db.ads.start as date)) as unsigned) *
_db.ads.impressions_perday))'
I'm really confused, I guess something is not caching right but what can I
do? I really need help..
Return not returning variable value
Return not returning variable value
I wrote a practice program for my class, and everything in it works except
for returning the value of a variable. My question is, why isn't it
returning the value? Here is sample code I wrote out to avoid having to
copy and paste large parts of code that aren't relevant.
#include <iostream>
using std::cout; using std::cin;
using std::endl; using std::fixed;
#include <iomanip>
using std::setw; using std::setprecision;
int testing();
int main()
{
testing();
return 0;
}
int testing() {
int debtArray[] = {4,5,6,7,9,};
int total = 0;
for(int debt = 0; debt < 5; debt++) {
total += debtArray[debt];
}
return total;
}
I wrote a practice program for my class, and everything in it works except
for returning the value of a variable. My question is, why isn't it
returning the value? Here is sample code I wrote out to avoid having to
copy and paste large parts of code that aren't relevant.
#include <iostream>
using std::cout; using std::cin;
using std::endl; using std::fixed;
#include <iomanip>
using std::setw; using std::setprecision;
int testing();
int main()
{
testing();
return 0;
}
int testing() {
int debtArray[] = {4,5,6,7,9,};
int total = 0;
for(int debt = 0; debt < 5; debt++) {
total += debtArray[debt];
}
return total;
}
Keep Tab Bar on Modal Segue
Keep Tab Bar on Modal Segue
So my app's navigation is based around the use of a Tab Bar, and long
story short, I'm having to use a Modal Segue to access one of my View
Controllers. Is it possible for me to place some kind of code in the View
Controller in order to keep the Tab Bar visible (as a Modal always appears
on top of the previous view)?
Because my destination view is embedded in a navigation controller, I
can't simply push to it.
Help, lol. Thanks, B
So my app's navigation is based around the use of a Tab Bar, and long
story short, I'm having to use a Modal Segue to access one of my View
Controllers. Is it possible for me to place some kind of code in the View
Controller in order to keep the Tab Bar visible (as a Modal always appears
on top of the previous view)?
Because my destination view is embedded in a navigation controller, I
can't simply push to it.
Help, lol. Thanks, B
Android CustomAdapter - Variable must provide either dimension expressions or an array
Android CustomAdapter - Variable must provide either dimension expressions
or an array
I am creating a Custom ArrayAdapter as per:
http://www.ezzylearning.com/tutorial.aspx?tid=1763429, however I am
getting error on this line:
Drawer drawer_data[] = new Drawer[] {
that Variable must provide either dimension expressions or an array
Drawer.java
public class Drawer {
public int mIcon;
public String mText;
public Drawer() {
super();
}
public Drawer(int mIcon, String mTitle) {
super();
this.mIcon = mIcon;
this.mText = mTitle;
}
}
Drawer_CustomAdapter.java
public class Drawer_CustomAdapter extends ArrayAdapter<Drawer> {
Context context;
int layoutResourceId;
Drawer data[] = null;
public Drawer_CustomAdapter(Context context, int layoutResourceId,
Drawer[] data) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = data;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
DrawerHolder holder = null;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater)
((Activity)context).getLayoutInflater();
convertView = inflater.inflate(layoutResourceId, parent, false);
holder = new DrawerHolder();
holder.mIcon = (ImageView)
convertView.findViewById(R.id.drawer_icon);
holder.mText = (TextView)
convertView.findViewById(R.id.drawer_text);
convertView.setTag(holder);
} else {
holder = (DrawerHolder) convertView.getTag();
}
Drawer drawer = data[position];
holder.mIcon.setImageResource(drawer.mIcon);
holder.mText.setText(drawer.mText);
return convertView;
}
static class DrawerHolder {
ImageView mIcon;
TextView mText;
}
}
Activity
Drawer drawer_data[] = new Drawer[] { // <<<< ERROR
for(int i=0; i<mDrawerItems; i++) {
new Drawer(mDrawerIcons[i],mDrawerItems[i]);
}
};
DrawerAdaper adapter = new
DrawerAdapter(this,R.layout.drawer_list_item,drawer_data);
mDrawerList.setAdapter(adapter);
I looked at this but I don't know how to modify my code.
New Error: NullPointerEception stack trace:
08-31 14:05:39.604: E/AndroidRuntime(14724): FATAL EXCEPTION: main
08-31 14:05:39.604: E/AndroidRuntime(14724): java.lang.NullPointerException
08-31 14:05:39.604: E/AndroidRuntime(14724): at
com.TVGenius.DrawerAdapter.getView(DrawerAdapter.java:42)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.AbsListView.obtainView(AbsListView.java:2461)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.ListView.makeAndAddView(ListView.java:1775)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.ListView.fillDown(ListView.java:678)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.ListView.fillFromTop(ListView.java:739)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.ListView.layoutChildren(ListView.java:1628)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.AbsListView.onLayout(AbsListView.java:2296)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:672)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1992)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1813)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.Choreographer.doFrame(Choreographer.java:525)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.os.Handler.handleCallback(Handler.java:615)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.os.Looper.loop(Looper.java:137)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.app.ActivityThread.main(ActivityThread.java:4898)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
java.lang.reflect.Method.invokeNative(Native Method)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
java.lang.reflect.Method.invoke(Method.java:511)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
dalvik.system.NativeStart.main(Native Method)
or an array
I am creating a Custom ArrayAdapter as per:
http://www.ezzylearning.com/tutorial.aspx?tid=1763429, however I am
getting error on this line:
Drawer drawer_data[] = new Drawer[] {
that Variable must provide either dimension expressions or an array
Drawer.java
public class Drawer {
public int mIcon;
public String mText;
public Drawer() {
super();
}
public Drawer(int mIcon, String mTitle) {
super();
this.mIcon = mIcon;
this.mText = mTitle;
}
}
Drawer_CustomAdapter.java
public class Drawer_CustomAdapter extends ArrayAdapter<Drawer> {
Context context;
int layoutResourceId;
Drawer data[] = null;
public Drawer_CustomAdapter(Context context, int layoutResourceId,
Drawer[] data) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = data;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
DrawerHolder holder = null;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater)
((Activity)context).getLayoutInflater();
convertView = inflater.inflate(layoutResourceId, parent, false);
holder = new DrawerHolder();
holder.mIcon = (ImageView)
convertView.findViewById(R.id.drawer_icon);
holder.mText = (TextView)
convertView.findViewById(R.id.drawer_text);
convertView.setTag(holder);
} else {
holder = (DrawerHolder) convertView.getTag();
}
Drawer drawer = data[position];
holder.mIcon.setImageResource(drawer.mIcon);
holder.mText.setText(drawer.mText);
return convertView;
}
static class DrawerHolder {
ImageView mIcon;
TextView mText;
}
}
Activity
Drawer drawer_data[] = new Drawer[] { // <<<< ERROR
for(int i=0; i<mDrawerItems; i++) {
new Drawer(mDrawerIcons[i],mDrawerItems[i]);
}
};
DrawerAdaper adapter = new
DrawerAdapter(this,R.layout.drawer_list_item,drawer_data);
mDrawerList.setAdapter(adapter);
I looked at this but I don't know how to modify my code.
New Error: NullPointerEception stack trace:
08-31 14:05:39.604: E/AndroidRuntime(14724): FATAL EXCEPTION: main
08-31 14:05:39.604: E/AndroidRuntime(14724): java.lang.NullPointerException
08-31 14:05:39.604: E/AndroidRuntime(14724): at
com.TVGenius.DrawerAdapter.getView(DrawerAdapter.java:42)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.AbsListView.obtainView(AbsListView.java:2461)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.ListView.makeAndAddView(ListView.java:1775)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.ListView.fillDown(ListView.java:678)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.ListView.fillFromTop(ListView.java:739)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.ListView.layoutChildren(ListView.java:1628)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.AbsListView.onLayout(AbsListView.java:2296)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:672)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.View.layout(View.java:14055)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewGroup.layout(ViewGroup.java:4604)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1992)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1813)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.Choreographer.doFrame(Choreographer.java:525)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.os.Handler.handleCallback(Handler.java:615)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.os.Looper.loop(Looper.java:137)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
android.app.ActivityThread.main(ActivityThread.java:4898)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
java.lang.reflect.Method.invokeNative(Native Method)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
java.lang.reflect.Method.invoke(Method.java:511)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-31 14:05:39.604: E/AndroidRuntime(14724): at
dalvik.system.NativeStart.main(Native Method)
In htaccess, is a redirect of "/index.php?main_page=" to "" safe?
In htaccess, is a redirect of "/index.php?main_page=" to "" safe?
I have migrated to a new PHP CMS that has redirects, but the old site used
the convention...
/index.php?main_page=
frequently. Would it be possible to alter this in htaccess without risking
issues, that for example might redirect the same code on the admin I might
not be aware of?
I have migrated to a new PHP CMS that has redirects, but the old site used
the convention...
/index.php?main_page=
frequently. Would it be possible to alter this in htaccess without risking
issues, that for example might redirect the same code on the admin I might
not be aware of?
Friday, 30 August 2013
Can't start my import statements with the top-level module (the source folder)
Can't start my import statements with the top-level module (the source
folder)
I seem to be running into this issue intermittently.
Sometimes I have a PyDev project in which I get compile errors if I try to
start my imports with the name of the top-level folder. So, suppose my
project looks like this:
+ myproject
- __init__.py
- a.py
- b.py
+ package1
- c.py
- __init__.py
+ package2
- d.py
- e.py
- __init__.py
If I'm in file a.py, it won't let me do imports like this, for example:
from myproject.b import foo
import myproject.b
The same goes for any file. They all compile just fine if I leave off
"myproject" from the imports statement like this:
from b import foo
import b
Just like in the diagram, I definitely have a top-level __init__.py, and
both the myproject folder and its parent are on the Python path. The
myproject folder is also the source folder for the project.
I need the complete import statement because places I'm deploying this
code to won't have the myproject folder on their path. Some other projects
that seem to be configured the same way don't have this problem, and I've
tried the usual cleaning/restarting.
Any idea as to what's going on here?
Thanks!
folder)
I seem to be running into this issue intermittently.
Sometimes I have a PyDev project in which I get compile errors if I try to
start my imports with the name of the top-level folder. So, suppose my
project looks like this:
+ myproject
- __init__.py
- a.py
- b.py
+ package1
- c.py
- __init__.py
+ package2
- d.py
- e.py
- __init__.py
If I'm in file a.py, it won't let me do imports like this, for example:
from myproject.b import foo
import myproject.b
The same goes for any file. They all compile just fine if I leave off
"myproject" from the imports statement like this:
from b import foo
import b
Just like in the diagram, I definitely have a top-level __init__.py, and
both the myproject folder and its parent are on the Python path. The
myproject folder is also the source folder for the project.
I need the complete import statement because places I'm deploying this
code to won't have the myproject folder on their path. Some other projects
that seem to be configured the same way don't have this problem, and I've
tried the usual cleaning/restarting.
Any idea as to what's going on here?
Thanks!
Thursday, 29 August 2013
In VB.Net, when using a CheckBox with a Button appearance, how can you truly center-align the text?
In VB.Net, when using a CheckBox with a Button appearance, how can you
truly center-align the text?
I'm using three CheckBoxes in a VB.Net program that are designed to look
like Buttons. I want to center-align the text on these CheckBoxes, so that
it is always perfectly in the center of the CheckBox. So I tried setting
the TextAlign property to MiddleCenter, but that didn't exactly work:
These are not truly center-aligned; they're basically right-aligned
against some sort of invisible wall that's close to the center. Messing
with the CheckAlign property doesn't seem to have any impact. It may be
worth mentioning that those five buttons above are actually RadioButtons,
and they didn't have this problem.
How can this issue be corrected? Thanks!
truly center-align the text?
I'm using three CheckBoxes in a VB.Net program that are designed to look
like Buttons. I want to center-align the text on these CheckBoxes, so that
it is always perfectly in the center of the CheckBox. So I tried setting
the TextAlign property to MiddleCenter, but that didn't exactly work:
These are not truly center-aligned; they're basically right-aligned
against some sort of invisible wall that's close to the center. Messing
with the CheckAlign property doesn't seem to have any impact. It may be
worth mentioning that those five buttons above are actually RadioButtons,
and they didn't have this problem.
How can this issue be corrected? Thanks!
Setting markers in plot according to values in list
Setting markers in plot according to values in list
Say I have a list that looks like this:
list_a = [[1.2, 0.5, 3.1,...], [7.3, 1.5, 3.9,...], [100, 200, 150, ...]]
The first and second sub-lists in that list define my (x, y) values which
I want to plot. The third sub-list contains values associated to each (x,
y) point (say a certain property). These associated values can only be one
of three values: 100, 150, 200; which means that each (x, y) pair has
either a 100, a 150 or a 200value attached to it.
I want to plot these (x, y) points in a scatter plot but giving to each of
them a marker according to the values in this third list.
So, I'd want for example (not real code of course):
if list_a[2][item] == 100 then use marker = 'o' (circle marker)
if list_a[2][item] == 150 then use marker = 's' (square marker)
if list_a[2][item] == 200 then use marker = '^' (triangle_up marker)
The only way I can think of doing this is re-packaging list_a so that all
(x, y) pairs associated with the same value in the third list are moved to
its own list, like so:
list_100 =[[subset of x values], [subset of y values]]
list_150 =[[subset of x values], [subset of y values]]
list_200 =[[subset of x values], [subset of y values]]
and then plot each list separately, setting the appropriate marker each time:
plot.scatter(list_100[0], list_100[1], marker='o')
plot.scatter(list_150[0], list_150[1], marker='s')
plot.scatter(list_200[0], list_200[1], marker='^')
I'd like to know if there's a way of doing this without needing to
re-package the original list and then setting several separated plots for
each value in the third sub-list.
Say I have a list that looks like this:
list_a = [[1.2, 0.5, 3.1,...], [7.3, 1.5, 3.9,...], [100, 200, 150, ...]]
The first and second sub-lists in that list define my (x, y) values which
I want to plot. The third sub-list contains values associated to each (x,
y) point (say a certain property). These associated values can only be one
of three values: 100, 150, 200; which means that each (x, y) pair has
either a 100, a 150 or a 200value attached to it.
I want to plot these (x, y) points in a scatter plot but giving to each of
them a marker according to the values in this third list.
So, I'd want for example (not real code of course):
if list_a[2][item] == 100 then use marker = 'o' (circle marker)
if list_a[2][item] == 150 then use marker = 's' (square marker)
if list_a[2][item] == 200 then use marker = '^' (triangle_up marker)
The only way I can think of doing this is re-packaging list_a so that all
(x, y) pairs associated with the same value in the third list are moved to
its own list, like so:
list_100 =[[subset of x values], [subset of y values]]
list_150 =[[subset of x values], [subset of y values]]
list_200 =[[subset of x values], [subset of y values]]
and then plot each list separately, setting the appropriate marker each time:
plot.scatter(list_100[0], list_100[1], marker='o')
plot.scatter(list_150[0], list_150[1], marker='s')
plot.scatter(list_200[0], list_200[1], marker='^')
I'd like to know if there's a way of doing this without needing to
re-package the original list and then setting several separated plots for
each value in the third sub-list.
Javascript: Object context overwritten?
Javascript: Object context overwritten?
I understand there is some sort of context mix up in the following
Javascript code I have.
Could someone explain my why I have this problem and how to solve the issue?
I have a class called Model which seems to work just fine. In this class
is a method called update(). This will perform an AJAX call to the backend
and parse the returned JSON. That's where things get tricky. The correct
query is sent to the backend and the correct JSON is sent back. However,
during parsing, there is some kind of collision or context issue between
both models.
I call the update function through another object called View. This View
object has a list of models (instances of Model). The view will then call
each update function of each view. This works great until the returned
data is parsed.
In the following code, everything is good until the line where there's the
comment "/!\ HERE /!\".
this.update = function(dbi) {
console.log('Updating model ' + this.name + '.');
var modelObj = this; // This is used to have a reference to 'this' Model
while in other contexts.
if (this.columns.length == 0) {
/* Let's build all the columns */
$("[id^='" + this.ref + "']").each(function() {
var colName = $(this).attr('id').split('-')[1];
if (modelObj.columns.indexOf(colName) == -1) {
modelObj.columns.push(colName);
}
});
}
/* Let's build the bindings. */
var allBindings = {};
for (placeholder in this.bindings) {
allBindings[placeholder] = this.bindings[placeholder].val();
}
$.post(path + 'inc/fetch.php', {
dbi : dbi,
table : this.table,
columns : btoa(this.columns),
limit : this.limit,
offset : this.offset,
distinct : this.distinct,
where : btoa(this.where),
bindings : btoa(JSON.stringify(allBindings))
}, function(data) {
if (!data.valid) {
$("#userError>p>span.userMessage").html(data.msg);
$("#userError").dialog({
width : 500,
buttons : {
'Dismiss' : function() {
$(this).dialog("close");
}
}
});
} else {
/* The data returned by the backend is simply JSON data with the
key-value pair. There is one key per row returned. */
var numRows = 0; // /!\ HERE /!\ Starting here, displaying the data
variable will always display the first of two objects.
for ( var rowID in data) {
if (rowID == 'valid')
continue;
numRows++;
for (column in data[rowID]) {
console.log('[' + modelObj.str() + '] setting #' + modelObj.ref +
'-' + column + ' to [' + data[rowID][column] + ']');
var el = $('#' + modelObj.ref + '-' + column);
var val = data[rowID][column];
switch (el[0].nodeName) {
case "SELECT":
el.html('<option val="' + val + "'>" + val + "</option>");
break;
case "TD":
el.text(val);
break;
case "INPUT":
el.val(val);
break;
default:
console.log('Dont know how to display "' + val + '"!');
}
}
}
if (numRows < modelObj.columns.length) {
for ( var cNo in modelObj.columns) {
var column = modelObj.columns[cNo];
console.log("col = " + column);
console.log('data');
console.log(data);
console.log('columns');
console.log(modelObj.columns);
console.log('[0] of ' + '#' + modelObj.ref)
var par = $('#' + modelObj.ref).nodeName;
var el = $('#' + modelObj.ref + '-' + column);
var val = data[0][column];
switch (par) {
case "SELECT":
el.html('<option val="' + val + "'>" + val + "</option>");
break;
case "TABLE":
var limit = $('#' + modelObj.ref + ">tr").length - 1; // The
first line (tr) is the header.
for ( var missingRow in limit) {
if (data.hasOwnProperty(missingRow) == 0 ||
data[missingRow].hasOwnProperty(column) == 0) {
console.log('[' + modelObj.str() + '] setting #' +
modelObj.ref + '-' + column + ' to [N/A]')
$('#' + modelObj.ref + '-' + column + '-' +
missingRow).text('N/A');
}
}
break;
case "INPUT":
el.val(val);
break;
default:
console.log('Dont know how to display "' + val + '"!');
}
}
}
}
}, "json");
};
Any thought is helpful. Thanks in advance.
I understand there is some sort of context mix up in the following
Javascript code I have.
Could someone explain my why I have this problem and how to solve the issue?
I have a class called Model which seems to work just fine. In this class
is a method called update(). This will perform an AJAX call to the backend
and parse the returned JSON. That's where things get tricky. The correct
query is sent to the backend and the correct JSON is sent back. However,
during parsing, there is some kind of collision or context issue between
both models.
I call the update function through another object called View. This View
object has a list of models (instances of Model). The view will then call
each update function of each view. This works great until the returned
data is parsed.
In the following code, everything is good until the line where there's the
comment "/!\ HERE /!\".
this.update = function(dbi) {
console.log('Updating model ' + this.name + '.');
var modelObj = this; // This is used to have a reference to 'this' Model
while in other contexts.
if (this.columns.length == 0) {
/* Let's build all the columns */
$("[id^='" + this.ref + "']").each(function() {
var colName = $(this).attr('id').split('-')[1];
if (modelObj.columns.indexOf(colName) == -1) {
modelObj.columns.push(colName);
}
});
}
/* Let's build the bindings. */
var allBindings = {};
for (placeholder in this.bindings) {
allBindings[placeholder] = this.bindings[placeholder].val();
}
$.post(path + 'inc/fetch.php', {
dbi : dbi,
table : this.table,
columns : btoa(this.columns),
limit : this.limit,
offset : this.offset,
distinct : this.distinct,
where : btoa(this.where),
bindings : btoa(JSON.stringify(allBindings))
}, function(data) {
if (!data.valid) {
$("#userError>p>span.userMessage").html(data.msg);
$("#userError").dialog({
width : 500,
buttons : {
'Dismiss' : function() {
$(this).dialog("close");
}
}
});
} else {
/* The data returned by the backend is simply JSON data with the
key-value pair. There is one key per row returned. */
var numRows = 0; // /!\ HERE /!\ Starting here, displaying the data
variable will always display the first of two objects.
for ( var rowID in data) {
if (rowID == 'valid')
continue;
numRows++;
for (column in data[rowID]) {
console.log('[' + modelObj.str() + '] setting #' + modelObj.ref +
'-' + column + ' to [' + data[rowID][column] + ']');
var el = $('#' + modelObj.ref + '-' + column);
var val = data[rowID][column];
switch (el[0].nodeName) {
case "SELECT":
el.html('<option val="' + val + "'>" + val + "</option>");
break;
case "TD":
el.text(val);
break;
case "INPUT":
el.val(val);
break;
default:
console.log('Dont know how to display "' + val + '"!');
}
}
}
if (numRows < modelObj.columns.length) {
for ( var cNo in modelObj.columns) {
var column = modelObj.columns[cNo];
console.log("col = " + column);
console.log('data');
console.log(data);
console.log('columns');
console.log(modelObj.columns);
console.log('[0] of ' + '#' + modelObj.ref)
var par = $('#' + modelObj.ref).nodeName;
var el = $('#' + modelObj.ref + '-' + column);
var val = data[0][column];
switch (par) {
case "SELECT":
el.html('<option val="' + val + "'>" + val + "</option>");
break;
case "TABLE":
var limit = $('#' + modelObj.ref + ">tr").length - 1; // The
first line (tr) is the header.
for ( var missingRow in limit) {
if (data.hasOwnProperty(missingRow) == 0 ||
data[missingRow].hasOwnProperty(column) == 0) {
console.log('[' + modelObj.str() + '] setting #' +
modelObj.ref + '-' + column + ' to [N/A]')
$('#' + modelObj.ref + '-' + column + '-' +
missingRow).text('N/A');
}
}
break;
case "INPUT":
el.val(val);
break;
default:
console.log('Dont know how to display "' + val + '"!');
}
}
}
}
}, "json");
};
Any thought is helpful. Thanks in advance.
Wednesday, 28 August 2013
How to write variable of activity that contains fargment class from inside current Fragment?
How to write variable of activity that contains fargment class from inside
current Fragment?
i have an activity with indefinite number of fragments. Inside fragments
there is a variable that need to access in the activity to call an intend
from activity bar correctly. But only the variable of the current fragment
is on screen. This is because the call depends of the fragment you are.
Due to fragment manager creates three fragment at a time can't write a
variable calling from inside fragment because i don't know who is the last
that writes variable. Need to identify the fragment is displayed. I tried
from inside to control visibility overriding setUserVisibleHint(boolean b)
and write variable when true but same happends. not guaranteed that the
current fragment is the last writting. I also tried getting the current
fragment from activity to call fragment method and get this variable. But
is difficult to identify current fragment. I tried this:
getsupportFragmentManager().findFragmentByTag("android:switcher:"+R.id.myViewPager+":"+myViewPager.getCurrentItem()).getVariable();
But have null Pointer Exception.
Thanks for suggestions!
current Fragment?
i have an activity with indefinite number of fragments. Inside fragments
there is a variable that need to access in the activity to call an intend
from activity bar correctly. But only the variable of the current fragment
is on screen. This is because the call depends of the fragment you are.
Due to fragment manager creates three fragment at a time can't write a
variable calling from inside fragment because i don't know who is the last
that writes variable. Need to identify the fragment is displayed. I tried
from inside to control visibility overriding setUserVisibleHint(boolean b)
and write variable when true but same happends. not guaranteed that the
current fragment is the last writting. I also tried getting the current
fragment from activity to call fragment method and get this variable. But
is difficult to identify current fragment. I tried this:
getsupportFragmentManager().findFragmentByTag("android:switcher:"+R.id.myViewPager+":"+myViewPager.getCurrentItem()).getVariable();
But have null Pointer Exception.
Thanks for suggestions!
Many lags with my Desktop
Many lags with my Desktop
I have this problem for over 3 months now.My desktop computer after some
hours it gets some lags like some 3-5'' and then runs smoothly about a
minute or two and then again lags e.t.c..This issue doesn't happen always
for example it might pass a day by and this doesn't show up.Also seconds
before the lag the cursor becomes some kind of a narrow and yellowish.Any
clues please help , have someone else had the same problem .
specs (windows7 x64 ultimate, i5 with 1156 socket with an asus
motherboard,gts 450 gigabyte graphics card)
Furthermore it must be on the hardware the issue cause I reinstalled
windows .
I have this problem for over 3 months now.My desktop computer after some
hours it gets some lags like some 3-5'' and then runs smoothly about a
minute or two and then again lags e.t.c..This issue doesn't happen always
for example it might pass a day by and this doesn't show up.Also seconds
before the lag the cursor becomes some kind of a narrow and yellowish.Any
clues please help , have someone else had the same problem .
specs (windows7 x64 ultimate, i5 with 1156 socket with an asus
motherboard,gts 450 gigabyte graphics card)
Furthermore it must be on the hardware the issue cause I reinstalled
windows .
add Equality Comparer class to base class for custom property classes in c#
add Equality Comparer class to base class for custom property classes in c#
i'm using the ConcurrentDictionary were the key is made of a class with
public properties.
after playing around with the code from (HashCode on decimal with
IEqualityComparer in a ConcurrentDictionary) I wanted to find a solution,
so I don't have to implement the class with interface IEqualityComparer
for every property class I make.
I already made a base class that can check whether or not all public
properties are set (or at least not the default value). So, I thought, let
give it a try and add the IEqualityComparer class to the base class.
so far, I had this and it does work.
using System.Collections.Concurrent;
using System.Collections.Generic;
private void SomeMethod()
{
ConcurrentDictionary<TwoUintsOneStringsKeyInfo,int> test = new
ConcurrentDictionary<TwoUintsOneStringsKeyInfo, int>(new
TwoUintsOneStringsKeyInfo.EqualityComparerElevenUintsKeyInfo());
test.TryAdd(new TwoUintsOneStringsKeyInfo { IdOne = 1, IdTwo = 2,
mySTring = "Hi" }, 1);
test.TryAdd(new TwoUintsOneStringsKeyInfo { IdOne = 2, IdTwo = 3,
mySTring = "hello" }, 2);
test.TryAdd(new TwoUintsOneStringsKeyInfo { IdOne = 3, IdTwo = 4 }, 3);
int result;
test.TryGetValue(new TwoUintsOneStringsKeyInfo { IdOne = 2, IdTwo = 3,
mySTring = "hello" }, out result);
}
public class PropertyBaseClass
{
public bool AllPublicProperiesAreSet()
{
//some logic (removed for now. Not important for the question)
}
public class EqualityComparerElevenUintsKeyInfo :
IEqualityComparer<TwoUintsOneStringsKeyInfo>
{
public int GetHashCode(TwoUintsOneStringsKeyInfo obj)
{
int hash = 17;
System.Reflection.PropertyInfo[] properties =
this.GetType().GetProperties();
foreach(System.Reflection.PropertyInfo p in properties)
hash = hash * 23 + p.GetValue(this).GetHashCode();
return hash;
}
public bool Equals(TwoUintsOneStringsKeyInfo x,
TwoUintsOneStringsKeyInfo y)
{
return x.IdOne == y.IdOne &&
x.IdTwo == y.IdTwo;
}
}
}
public class TwoUintsOneStringsKeyInfo : PropertyBaseClass
{
public uint IdOne { get; set; }
public uint IdTwo { get; set; }
public string mySTring { get; set; }
}
I made this example with just three properties. Normally there are more
and also more different types and I just don't want to make a custom class
to be used in the concurrentDictionary for every property class.
Thing is (of course), the way it is now, it will only work for property
classes of type TwoUintsOneStringsKeyInfo, because I have to specify it
when implementing the IEqualityComparer<>.
Is there any way I can implement the EqualityComparerElevenUintsKeyInfo
class to the base class and making it flexible in a way that the
EqualityComparerElevenUintsKeyInfo checks which class implements
EqualityComparerElevenUintsKeyInfo and use that class as parameter for
IEqualityComparer, GetHashCode and Equals (if it can be done to do what I
want, I'll of course will change the Equals method as well.
Suggestions?
Kind regards,
Matthijs
i'm using the ConcurrentDictionary were the key is made of a class with
public properties.
after playing around with the code from (HashCode on decimal with
IEqualityComparer in a ConcurrentDictionary) I wanted to find a solution,
so I don't have to implement the class with interface IEqualityComparer
for every property class I make.
I already made a base class that can check whether or not all public
properties are set (or at least not the default value). So, I thought, let
give it a try and add the IEqualityComparer class to the base class.
so far, I had this and it does work.
using System.Collections.Concurrent;
using System.Collections.Generic;
private void SomeMethod()
{
ConcurrentDictionary<TwoUintsOneStringsKeyInfo,int> test = new
ConcurrentDictionary<TwoUintsOneStringsKeyInfo, int>(new
TwoUintsOneStringsKeyInfo.EqualityComparerElevenUintsKeyInfo());
test.TryAdd(new TwoUintsOneStringsKeyInfo { IdOne = 1, IdTwo = 2,
mySTring = "Hi" }, 1);
test.TryAdd(new TwoUintsOneStringsKeyInfo { IdOne = 2, IdTwo = 3,
mySTring = "hello" }, 2);
test.TryAdd(new TwoUintsOneStringsKeyInfo { IdOne = 3, IdTwo = 4 }, 3);
int result;
test.TryGetValue(new TwoUintsOneStringsKeyInfo { IdOne = 2, IdTwo = 3,
mySTring = "hello" }, out result);
}
public class PropertyBaseClass
{
public bool AllPublicProperiesAreSet()
{
//some logic (removed for now. Not important for the question)
}
public class EqualityComparerElevenUintsKeyInfo :
IEqualityComparer<TwoUintsOneStringsKeyInfo>
{
public int GetHashCode(TwoUintsOneStringsKeyInfo obj)
{
int hash = 17;
System.Reflection.PropertyInfo[] properties =
this.GetType().GetProperties();
foreach(System.Reflection.PropertyInfo p in properties)
hash = hash * 23 + p.GetValue(this).GetHashCode();
return hash;
}
public bool Equals(TwoUintsOneStringsKeyInfo x,
TwoUintsOneStringsKeyInfo y)
{
return x.IdOne == y.IdOne &&
x.IdTwo == y.IdTwo;
}
}
}
public class TwoUintsOneStringsKeyInfo : PropertyBaseClass
{
public uint IdOne { get; set; }
public uint IdTwo { get; set; }
public string mySTring { get; set; }
}
I made this example with just three properties. Normally there are more
and also more different types and I just don't want to make a custom class
to be used in the concurrentDictionary for every property class.
Thing is (of course), the way it is now, it will only work for property
classes of type TwoUintsOneStringsKeyInfo, because I have to specify it
when implementing the IEqualityComparer<>.
Is there any way I can implement the EqualityComparerElevenUintsKeyInfo
class to the base class and making it flexible in a way that the
EqualityComparerElevenUintsKeyInfo checks which class implements
EqualityComparerElevenUintsKeyInfo and use that class as parameter for
IEqualityComparer, GetHashCode and Equals (if it can be done to do what I
want, I'll of course will change the Equals method as well.
Suggestions?
Kind regards,
Matthijs
Place holder is not working
Place holder is not working
Place holder is not working in IE-9,so I used the below code for place
holder.
jQuery(function () {
debugger;
jQuery.support.placeholder = false;
test = document.createElement('input');
if ('placeholder' in test) jQuery.support.placeholder = true;
});
// This adds placeholder support to browsers that wouldn't otherwise
support it.
$(function () {
if (!$.support.placeholder) {
var active = document.activeElement;
$(':text').focus(function () {
if ($(this).attr('placeholder') != '' && $(this).val() ==
$(this).attr('placeholder')) {
$(this).val('').removeClass('hasPlaceholder');
}
}).blur(function () {
if ($(this).attr('placeholder') != '' && ($(this).val() == ''
|| $(this).val() == $(this).attr('placeholder'))) {
$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
}
});
$(':text').blur();
$(active).focus();
$('form:eq(0)').submit(function () {
$(':text.hasPlaceholder').val('');
});
}
});
When I am taking the value of test,it shows null.How can I get the details
of all input tag?
Place holder is not working in IE-9,so I used the below code for place
holder.
jQuery(function () {
debugger;
jQuery.support.placeholder = false;
test = document.createElement('input');
if ('placeholder' in test) jQuery.support.placeholder = true;
});
// This adds placeholder support to browsers that wouldn't otherwise
support it.
$(function () {
if (!$.support.placeholder) {
var active = document.activeElement;
$(':text').focus(function () {
if ($(this).attr('placeholder') != '' && $(this).val() ==
$(this).attr('placeholder')) {
$(this).val('').removeClass('hasPlaceholder');
}
}).blur(function () {
if ($(this).attr('placeholder') != '' && ($(this).val() == ''
|| $(this).val() == $(this).attr('placeholder'))) {
$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
}
});
$(':text').blur();
$(active).focus();
$('form:eq(0)').submit(function () {
$(':text.hasPlaceholder').val('');
});
}
});
When I am taking the value of test,it shows null.How can I get the details
of all input tag?
Tuesday, 27 August 2013
Customising application menus [on hold]
Customising application menus [on hold]
I want to write a script that allows me to modify the menus of a given
application. how can that be accomplished? i.e. where does OSX keep its
menu definitions? are they in xml or some other easily editable format?
I want to write a script that allows me to modify the menus of a given
application. how can that be accomplished? i.e. where does OSX keep its
menu definitions? are they in xml or some other easily editable format?
Validate multiple inputs with AJAX/JQUERY and change css of wrong inputs only
Validate multiple inputs with AJAX/JQUERY and change css of wrong inputs only
I have a form which has multiple inputs with the same name and brackets like:
<input name=foo[] id=foo[]/>
I'm using the brackets to process the input as array with PHP and because
the amount of inputs is not fixed.
I'm trying to add some form validation with AJAX/JQUERY because each input
must contain a value that's already in the database. Once checked I want
to change the CSS of the input to green if correct and red if wrong.
The AJAX part is working but I can't get JQUERY to change the CSS of the
inputs.
Here's the code I'm using:
<script>
$(document).change(function(){
$('input[id="foo[]"]').each(function(){
$(this).change(validate);
});
});
function validate(){
var foo = $(this).val();
if(foo == "" || foo.length < 4){
$('input[id="foo[]"]').css('border', '3px #C33 solid');
}else{
jQuery.ajax({
type: "POST",
url: "common/check.php",
data: 'foo='+ foo,
cache: false,
success: function(response){
if(response == 0){
$('input[id="foo[]"]').css('border', '3px #C33 solid');
}else{
$('input[id="foo[]"]').css('border', '3px #00FF00 solid');
}
}
});
}
}
</script>
Thanks for your help!
I have a form which has multiple inputs with the same name and brackets like:
<input name=foo[] id=foo[]/>
I'm using the brackets to process the input as array with PHP and because
the amount of inputs is not fixed.
I'm trying to add some form validation with AJAX/JQUERY because each input
must contain a value that's already in the database. Once checked I want
to change the CSS of the input to green if correct and red if wrong.
The AJAX part is working but I can't get JQUERY to change the CSS of the
inputs.
Here's the code I'm using:
<script>
$(document).change(function(){
$('input[id="foo[]"]').each(function(){
$(this).change(validate);
});
});
function validate(){
var foo = $(this).val();
if(foo == "" || foo.length < 4){
$('input[id="foo[]"]').css('border', '3px #C33 solid');
}else{
jQuery.ajax({
type: "POST",
url: "common/check.php",
data: 'foo='+ foo,
cache: false,
success: function(response){
if(response == 0){
$('input[id="foo[]"]').css('border', '3px #C33 solid');
}else{
$('input[id="foo[]"]').css('border', '3px #00FF00 solid');
}
}
});
}
}
</script>
Thanks for your help!
iOS textviews not expanding in scrollview in landscape
iOS textviews not expanding in scrollview in landscape
I had a view with some textviews in it that were working as I wanted. The
expanded to a the same right-margin whether in landscape or portrait.
I recently have tried changing the normal view to a scrollview. I've had
no luck getting these text views to expand as they once did, though. When
in landscape mode everything stays huddled over on the left side with the
same width as a portrait phone.
Here is some code.
- (void)viewDidLoad {
CGSize screen = [self handleScreenOrientation];
[(UIScrollView *)self.view setContentSize:CGSizeMake(screen.width,
screen.height)];
}
- (CGSize)handleScreenOrientation {
UIInterfaceOrientation orientation = [[UIApplication
sharedApplication] statusBarOrientation];
CGRect screenRect = [[UIScreen mainScreen] bounds];
if (orientation == UIDeviceOrientationPortrait || orientation ==
UIDeviceOrientationPortraitUpsideDown ) {
return CGSizeMake(screenRect.size.width, screenRect.size.height);
}
else {
return CGSizeMake(screenRect.size.height, screenRect.size.width);
}
}
- (void)
willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
CGSize screen = [self handleScreenOrientation:toInterfaceOrientation];
UIScrollView *scrollView = (UIScrollView *)self.view;
scrollView.frame = CGRectMake(0, 0, screen.width, screen.height);
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width,
scrollView.frame.size.height);
[scrollView setNeedsDisplay];
}
The method handleScreenOrientation with the passed orientation is the same
as the one w/ no parameters, just it uses the passed orientation instead
of the current orientation of the status bar.
I've checked and my scrollview is set to autoresize subviews.
Any ideas would be much appreciated. Thanks.
I had a view with some textviews in it that were working as I wanted. The
expanded to a the same right-margin whether in landscape or portrait.
I recently have tried changing the normal view to a scrollview. I've had
no luck getting these text views to expand as they once did, though. When
in landscape mode everything stays huddled over on the left side with the
same width as a portrait phone.
Here is some code.
- (void)viewDidLoad {
CGSize screen = [self handleScreenOrientation];
[(UIScrollView *)self.view setContentSize:CGSizeMake(screen.width,
screen.height)];
}
- (CGSize)handleScreenOrientation {
UIInterfaceOrientation orientation = [[UIApplication
sharedApplication] statusBarOrientation];
CGRect screenRect = [[UIScreen mainScreen] bounds];
if (orientation == UIDeviceOrientationPortrait || orientation ==
UIDeviceOrientationPortraitUpsideDown ) {
return CGSizeMake(screenRect.size.width, screenRect.size.height);
}
else {
return CGSizeMake(screenRect.size.height, screenRect.size.width);
}
}
- (void)
willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
CGSize screen = [self handleScreenOrientation:toInterfaceOrientation];
UIScrollView *scrollView = (UIScrollView *)self.view;
scrollView.frame = CGRectMake(0, 0, screen.width, screen.height);
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width,
scrollView.frame.size.height);
[scrollView setNeedsDisplay];
}
The method handleScreenOrientation with the passed orientation is the same
as the one w/ no parameters, just it uses the passed orientation instead
of the current orientation of the status bar.
I've checked and my scrollview is set to autoresize subviews.
Any ideas would be much appreciated. Thanks.
c++ multidimensional array multiple data types
c++ multidimensional array multiple data types
I am trying to create a multidimensional array in c++ where there's a
string and an int involved. I tried int test[1][2] = {{"a", 1}, {"b", 2},
{"c", 3}}; but g++ gave me the following:
example.cpp: In function 'int getServer(std::string)':
error: too many initializers for 'int [1][2]'
error: invalid conversion from 'const char*' to 'int' [-fpermissive]
I tried to use char test[1][2] as well for the initializer, but this
didn't work.
I am trying to create a multidimensional array in c++ where there's a
string and an int involved. I tried int test[1][2] = {{"a", 1}, {"b", 2},
{"c", 3}}; but g++ gave me the following:
example.cpp: In function 'int getServer(std::string)':
error: too many initializers for 'int [1][2]'
error: invalid conversion from 'const char*' to 'int' [-fpermissive]
I tried to use char test[1][2] as well for the initializer, but this
didn't work.
Show the jQuery dialog after X seconds of page scroll
Show the jQuery dialog after X seconds of page scroll
Using jQuery 1.7.1, I want to show a dialog box to the user for both these
circumstances...
Approximately after 15 seconds when the page has finished loading if no
user interaction has been done i.e. page scroll, link click. The dialog
box should appear.
If after say 10 seconds an interaction (page scroll / form field click) no
further action has been done and the user is still on the same page. The
dialog box should appear.
The purpose of this is to show a 'do you need any help / feedback' dialog
to a user if they are still on the same page for a number of seconds and
haven't scrolled or have scrolled and not interacted on the page i.e.
clicked a link / form field.
In the dialog i will show a 'No help needed' link which needs to hide the
dialog and stop it opening again during the session. So if this link is
clicked the dialog and counter must be stopped for the remainder of that
php session.
Using jQuery 1.7.1, I want to show a dialog box to the user for both these
circumstances...
Approximately after 15 seconds when the page has finished loading if no
user interaction has been done i.e. page scroll, link click. The dialog
box should appear.
If after say 10 seconds an interaction (page scroll / form field click) no
further action has been done and the user is still on the same page. The
dialog box should appear.
The purpose of this is to show a 'do you need any help / feedback' dialog
to a user if they are still on the same page for a number of seconds and
haven't scrolled or have scrolled and not interacted on the page i.e.
clicked a link / form field.
In the dialog i will show a 'No help needed' link which needs to hide the
dialog and stop it opening again during the session. So if this link is
clicked the dialog and counter must be stopped for the remainder of that
php session.
Java: Generic method overloading ambiguity stackoverflow.com
Java: Generic method overloading ambiguity – stackoverflow.com
Consider the following code: public class Converter { public <K>
MyContainer<K> pack(K key, String[] values) { return new
MyContainer<>(key); } public ...
Consider the following code: public class Converter { public <K>
MyContainer<K> pack(K key, String[] values) { return new
MyContainer<>(key); } public ...
Access Router UI behind another router without setting up port forwarding
Access Router UI behind another router without setting up port forwarding
Ok, I'm sure this is a strange scenario. I hope some of you gurus can help
me brainstorm a solution. I have an OpenWRT router. It is behind another
router that I don't have control over (and can't setup port forwarding
on). My router hosts a web UI for configuration. The router that my router
is plugged into is plugged into a modem that does not have a static ip
address. So, it looks something like this:
Modem (with Dynamic IP) --> Their Router (192.168.1.1) --> My Router
(192.168.2.1)
So, I would like to be able to configure my router from the internet. How
can I do that? I have full control over my router. I also have control
over an internet facing linux box. Is there some way I could have my
router ssh into the linux server and use the static ip of the linux server
to access my UI? Just to be clear...I don't want to ssh into my router, I
want to access the User Interface of it. Thanks for any ideas you can
offer!
EV
Ok, I'm sure this is a strange scenario. I hope some of you gurus can help
me brainstorm a solution. I have an OpenWRT router. It is behind another
router that I don't have control over (and can't setup port forwarding
on). My router hosts a web UI for configuration. The router that my router
is plugged into is plugged into a modem that does not have a static ip
address. So, it looks something like this:
Modem (with Dynamic IP) --> Their Router (192.168.1.1) --> My Router
(192.168.2.1)
So, I would like to be able to configure my router from the internet. How
can I do that? I have full control over my router. I also have control
over an internet facing linux box. Is there some way I could have my
router ssh into the linux server and use the static ip of the linux server
to access my UI? Just to be clear...I don't want to ssh into my router, I
want to access the User Interface of it. Thanks for any ideas you can
offer!
EV
Monday, 26 August 2013
iOS : Get top colors from every pixels of an image
iOS : Get top colors from every pixels of an image
In my project I need to show the top three colours for an image given
(look at the sample image below) . The functionality requirement is I have
to get the top three colours in every pixel of an image individually then
those have to be calculated for all pixels. finally top three presented
colours in given image have to be listed as output . (had a look at
GPUImage but i could't found any code for my requirement) . Thanks ..
In my project I need to show the top three colours for an image given
(look at the sample image below) . The functionality requirement is I have
to get the top three colours in every pixel of an image individually then
those have to be calculated for all pixels. finally top three presented
colours in given image have to be listed as output . (had a look at
GPUImage but i could't found any code for my requirement) . Thanks ..
Does dataChanged signal in QAbstractItemModel include the change of its children?
Does dataChanged signal in QAbstractItemModel include the change of its
children?
For example, I change a parent and its children. Is it enough to just emit
a dataChanged signal for only the parent index?
children?
For example, I change a parent and its children. Is it enough to just emit
a dataChanged signal for only the parent index?
Difficulties after booting with a new OS
Difficulties after booting with a new OS
It's ASUS S56CM with UEFI firmware, x64-bit, Win8, i3 processor, 500gb
hdd(496gb and 4gb-marked as boot and 1Mb forgot what it was marked with) ,
24gb ssd(18gb and 4gb-marked as OEM partition), 4gb ram. The system used
to boot under 2secs and the desktop was responsive the next second. Only
HDD used to be visible in windows explorer. I installed Win8 PRO using
Windows Os disk as Win8 which was pre installed got corrupted. The first
difficulty was my disk wasn't recognised under UEFI. Rather I booted it
under BIOS and I wasn't able to install windows in any drive. The thing
was that Windows under BIOS cant be installed on GPT style drives. I used
gparted to convert GPT drives to NTFS drives and installed windows on my
hdd. Now with windows on hdd with 4gb hdd empty and idle, the ssd with
18+4 partitions are not in use, all my partitions including 4gb Hdd, 1Mb
Hdd, 18gb ssd, 4gb ssd are now visible in windows explorer and boot takes
3:27min with desktop responding after 2:26min. The Question is "How to
restore my device to its first state being 2sec instant on, while using
SSD??"
It's ASUS S56CM with UEFI firmware, x64-bit, Win8, i3 processor, 500gb
hdd(496gb and 4gb-marked as boot and 1Mb forgot what it was marked with) ,
24gb ssd(18gb and 4gb-marked as OEM partition), 4gb ram. The system used
to boot under 2secs and the desktop was responsive the next second. Only
HDD used to be visible in windows explorer. I installed Win8 PRO using
Windows Os disk as Win8 which was pre installed got corrupted. The first
difficulty was my disk wasn't recognised under UEFI. Rather I booted it
under BIOS and I wasn't able to install windows in any drive. The thing
was that Windows under BIOS cant be installed on GPT style drives. I used
gparted to convert GPT drives to NTFS drives and installed windows on my
hdd. Now with windows on hdd with 4gb hdd empty and idle, the ssd with
18+4 partitions are not in use, all my partitions including 4gb Hdd, 1Mb
Hdd, 18gb ssd, 4gb ssd are now visible in windows explorer and boot takes
3:27min with desktop responding after 2:26min. The Question is "How to
restore my device to its first state being 2sec instant on, while using
SSD??"
How to split a list of values into a variable and how to make a insert function work under a for each loop in postgreSQL
How to split a list of values into a variable and how to make a insert
function work under a for each loop in postgreSQL
I am Having two Tables.
partyList
create table partyList
(
sno serial NOT NULL,
Party_title text,
Party_venue text,
Party_date date,
Party_list character varying
);
list
create table list(
sno integer,
participant_name text
);
This is the full SQL FIDDLE.
I want to call a function which can insert values into both tables. and my
output should look like this . partyList table
| SNO | PARTY_TITLE | PARTY_VENUE | PARTY_DATE |
PARTY_LIST |
-------------------------------------------------------------------------------------------------------------------------------------------
| 1 | games | indoor stadium | August, 10 2013 00:00:00+0000 |
ronald;sania;sachin;pointing;samueal;gibbs;gayle;smith; |
| 2 | dance | stage | August, 15 2013 00:00:00+0000 |
micheal jakson; britney ; daddy yankee; ar rehaman; jestin bebber; |
list table
| SNO | PARTICIPANT_NAME |
--------------------------
| 1 | ronald |
| 1 | sania |
| 1 | sachin |
| 1 | pointing |
| 1 | samueal |
| 1 | gibbs |
| 1 | gayle |
| 1 | smith |
| 2 | micheal jakson |
| 2 | britney |
| 2 | daddy yankee |
| 2 | ar rehaman |
| 2 | jestin bebber |
When i call my function by these values as in example below.
insert_function('games','indoor
stadium','08-10-2013','ronald;sania;sachin;pointing;samueal;gibbs;gayle;smith;'),
('dance','stage','08-15-2013','micheal jakson; britney ; daddy yankee; ar
rehaman; jestin bebber;');
Is there a way to split the list items and call the insert query of the
list table in a loop ?
function work under a for each loop in postgreSQL
I am Having two Tables.
partyList
create table partyList
(
sno serial NOT NULL,
Party_title text,
Party_venue text,
Party_date date,
Party_list character varying
);
list
create table list(
sno integer,
participant_name text
);
This is the full SQL FIDDLE.
I want to call a function which can insert values into both tables. and my
output should look like this . partyList table
| SNO | PARTY_TITLE | PARTY_VENUE | PARTY_DATE |
PARTY_LIST |
-------------------------------------------------------------------------------------------------------------------------------------------
| 1 | games | indoor stadium | August, 10 2013 00:00:00+0000 |
ronald;sania;sachin;pointing;samueal;gibbs;gayle;smith; |
| 2 | dance | stage | August, 15 2013 00:00:00+0000 |
micheal jakson; britney ; daddy yankee; ar rehaman; jestin bebber; |
list table
| SNO | PARTICIPANT_NAME |
--------------------------
| 1 | ronald |
| 1 | sania |
| 1 | sachin |
| 1 | pointing |
| 1 | samueal |
| 1 | gibbs |
| 1 | gayle |
| 1 | smith |
| 2 | micheal jakson |
| 2 | britney |
| 2 | daddy yankee |
| 2 | ar rehaman |
| 2 | jestin bebber |
When i call my function by these values as in example below.
insert_function('games','indoor
stadium','08-10-2013','ronald;sania;sachin;pointing;samueal;gibbs;gayle;smith;'),
('dance','stage','08-15-2013','micheal jakson; britney ; daddy yankee; ar
rehaman; jestin bebber;');
Is there a way to split the list items and call the insert query of the
list table in a loop ?
Using jQuery to change CSS attributes with delay
Using jQuery to change CSS attributes with delay
How can i use jQuery to change the CSS attributes of a HTML element with
delay.
Imagine this scenario. I have a div with bg color blue. I want it to fade
out and when it fades back in i want the bg color to be red.
I tried this.
$("div").fadeOut().delay(500).css("background-color","red").fadeIn();
While fading out the div already changes the color to red before it fades
in. It does not follow the sequence of chained events. How can I make this
happen in one single line.
How can i use jQuery to change the CSS attributes of a HTML element with
delay.
Imagine this scenario. I have a div with bg color blue. I want it to fade
out and when it fades back in i want the bg color to be red.
I tried this.
$("div").fadeOut().delay(500).css("background-color","red").fadeIn();
While fading out the div already changes the color to red before it fades
in. It does not follow the sequence of chained events. How can I make this
happen in one single line.
Sunday, 25 August 2013
$scope is updated in view and not in controller for angularJs
$scope is updated in view and not in controller for angularJs
I have a scope defined in a controller as mentioned below :
$scope.countries = [{
name : 'India', code : 'IA'
}, {
name : 'Israel', code : 'IS'
}];
$scope.selectedCountries = [
'IA'
];
$scope.$watch('selectedCountries', function(newValue, oldValue) {
console.log ('data');
});
Now when the value changes in controller using select dropdown, the value
changes are reflected in view. But the watch is never called, as the scope
is not changed. Any idea why the scope is not updating ?
I have a scope defined in a controller as mentioned below :
$scope.countries = [{
name : 'India', code : 'IA'
}, {
name : 'Israel', code : 'IS'
}];
$scope.selectedCountries = [
'IA'
];
$scope.$watch('selectedCountries', function(newValue, oldValue) {
console.log ('data');
});
Now when the value changes in controller using select dropdown, the value
changes are reflected in view. But the watch is never called, as the scope
is not changed. Any idea why the scope is not updating ?
Getting the pointer back to the first line - QFile
Getting the pointer back to the first line - QFile
Read the data from the file and keep it in a QHash as follows:
QHash<int, QVector<float> >
My data file doesn't contain headers, so when I first create vectors and
then enter the file loop I miss the data which is on the first line. My
source is :
QFile file("...\\a.csv");
if(!file.open(QIODevice::ReadOnly))
{
QMessageBox::warning(0, "Error", file.errorString());
}
QString fileLine = file.readLine();
QStringList fileLineSplit = fileLine.split(',');
hashKeySize = fileLineSplit.size();
for(int t=0; t<hashKeySize; t++)
{
QVector<float> vec;
hash_notClustered[t] = vec;
}
while(!file.atEnd())
{
QString line = file.readLine();
QStringList list = line.split(',');
for(int t = 0; t<list.size(); t++)
{
hash_notClustered[t].push_back(list[t].toFloat());
}
}
Q: how can I get the pointer back to the first line when looping with
while(!file.atEnd()) not to miss the first line?
Read the data from the file and keep it in a QHash as follows:
QHash<int, QVector<float> >
My data file doesn't contain headers, so when I first create vectors and
then enter the file loop I miss the data which is on the first line. My
source is :
QFile file("...\\a.csv");
if(!file.open(QIODevice::ReadOnly))
{
QMessageBox::warning(0, "Error", file.errorString());
}
QString fileLine = file.readLine();
QStringList fileLineSplit = fileLine.split(',');
hashKeySize = fileLineSplit.size();
for(int t=0; t<hashKeySize; t++)
{
QVector<float> vec;
hash_notClustered[t] = vec;
}
while(!file.atEnd())
{
QString line = file.readLine();
QStringList list = line.split(',');
for(int t = 0; t<list.size(); t++)
{
hash_notClustered[t].push_back(list[t].toFloat());
}
}
Q: how can I get the pointer back to the first line when looping with
while(!file.atEnd()) not to miss the first line?
How do I handle, parse, a colon in the url with httparty and json
How do I handle, parse, a colon in the url with httparty and json
I'm trying to parse the Mochi Media API on my site. Unfortunately, they
make use of colons in their API URLs....
http://feedmonger.mochimedia.com/feeds/query/?q=(recommendation:>=0) and
category:action&partner_id=XXXX
The question is, using httparty, how do I parse that url given that the
:query/options hash will automatically convert to a standard query string:
get('/myNewApiUrl', :query => {:key => value}) |
http://base/myNewApiUrl?key=value&key2=value2
I need something to handle this:
get('/myNewApiUrl', :query => {:key => value}) |
http://base/myNewApiUrl?key:value&key2=value2
Can anyone help me out... just about ready to bang my head against a wall. :/
I'm trying to parse the Mochi Media API on my site. Unfortunately, they
make use of colons in their API URLs....
http://feedmonger.mochimedia.com/feeds/query/?q=(recommendation:>=0) and
category:action&partner_id=XXXX
The question is, using httparty, how do I parse that url given that the
:query/options hash will automatically convert to a standard query string:
get('/myNewApiUrl', :query => {:key => value}) |
http://base/myNewApiUrl?key=value&key2=value2
I need something to handle this:
get('/myNewApiUrl', :query => {:key => value}) |
http://base/myNewApiUrl?key:value&key2=value2
Can anyone help me out... just about ready to bang my head against a wall. :/
Saturday, 24 August 2013
Lose formatting in SugarCRM SubPanel when new record is created
Lose formatting in SugarCRM SubPanel when new record is created
Over the past couple weeks I have begin learning SugarCRM development. My
first project onmthe platform is my own Project management modules.
Below is the image of the Project DetailView screen. In the SubPanel is
the Project Tasks.
Using AJAX I was able to add a checkbox that alternates to change the
Status field for a Task between 3 possible Status's. Open, In_Progress,
and Complete.
On a Success callback from the AJAX request, it updates the UI to update
the Checkbox image, updates the Status column with the appropriate
background color and text, and then also does some math to correct the
Project Stats Counter for Closed and Open tasks count.
http://i.stack.imgur.com/wrze5.png
So this is all working great so far but there is 1 major problem. When you
use the Quick Create form to create a new task on the SubPanel... it
reloads the SubPanel with plain text and I lose all my formatting. The
formatting for the Checkbox field and the Status field vis currently
applied through a Hook called $hook_array['process_record']
In my research I have discovered many people run into this problem but I
have yet to really find a solution. I know anything is possible so I am
really hoping a Sugar guru can help me out here? Any ideas?
Over the past couple weeks I have begin learning SugarCRM development. My
first project onmthe platform is my own Project management modules.
Below is the image of the Project DetailView screen. In the SubPanel is
the Project Tasks.
Using AJAX I was able to add a checkbox that alternates to change the
Status field for a Task between 3 possible Status's. Open, In_Progress,
and Complete.
On a Success callback from the AJAX request, it updates the UI to update
the Checkbox image, updates the Status column with the appropriate
background color and text, and then also does some math to correct the
Project Stats Counter for Closed and Open tasks count.
http://i.stack.imgur.com/wrze5.png
So this is all working great so far but there is 1 major problem. When you
use the Quick Create form to create a new task on the SubPanel... it
reloads the SubPanel with plain text and I lose all my formatting. The
formatting for the Checkbox field and the Status field vis currently
applied through a Hook called $hook_array['process_record']
In my research I have discovered many people run into this problem but I
have yet to really find a solution. I know anything is possible so I am
really hoping a Sugar guru can help me out here? Any ideas?
Making shell scripts robust against location they're called from
Making shell scripts robust against location they're called from
What is the best way to write a shell script that will access files
relative to it such that it doesn't matter where I call it from? "Easy"
means the easiest/recommended way that will work across different
systems/shells.
Example
Say I have a folder ~/MyProject with subfolders scripts/ and files/. In
scripts/, I have a shell script foo.sh that wants to access files in
files/:
if [ -f "../files/somefile.ext" ]; then
echo "File found"
else
echo "File not found"
fi
It'll work fine If I do cd ~/MyProject/scripts && ./foo.sh, but it will
fail with cd ~/MyProject && scripts/foo.sh.
What is the best way to write a shell script that will access files
relative to it such that it doesn't matter where I call it from? "Easy"
means the easiest/recommended way that will work across different
systems/shells.
Example
Say I have a folder ~/MyProject with subfolders scripts/ and files/. In
scripts/, I have a shell script foo.sh that wants to access files in
files/:
if [ -f "../files/somefile.ext" ]; then
echo "File found"
else
echo "File not found"
fi
It'll work fine If I do cd ~/MyProject/scripts && ./foo.sh, but it will
fail with cd ~/MyProject && scripts/foo.sh.
Understanding Transaction Isolation Levels
Understanding Transaction Isolation Levels
I am new to the topic, and I am trying to verify what I understand. so
please consider the following example:-
Transaction contains a select and update statements, where update
statement depends on the result set returned from the select statement.
User A and B concurrently executes the transaction, Both users selected
the data and about to execute Update. If User A executes the update first,
User B will probably have a bug; because it has not up to date result set.
This is called Phantom Read case.
For serializable isolation level: The above case will never happen.
Transactions are completely isolated and can't work concurrently.
Transaction of User B can't execute the select statement till User A
completed its transaction. User B will Wait till transaction A complete.
For Repeatable read isolation level: Transaction B can read but cannot do
modifications for data. Which can cause a Phantom Read.
Can you say whether this is a right understanding?
I am new to the topic, and I am trying to verify what I understand. so
please consider the following example:-
Transaction contains a select and update statements, where update
statement depends on the result set returned from the select statement.
User A and B concurrently executes the transaction, Both users selected
the data and about to execute Update. If User A executes the update first,
User B will probably have a bug; because it has not up to date result set.
This is called Phantom Read case.
For serializable isolation level: The above case will never happen.
Transactions are completely isolated and can't work concurrently.
Transaction of User B can't execute the select statement till User A
completed its transaction. User B will Wait till transaction A complete.
For Repeatable read isolation level: Transaction B can read but cannot do
modifications for data. Which can cause a Phantom Read.
Can you say whether this is a right understanding?
Referencing through super class/interface reference - Java
Referencing through super class/interface reference - Java
I am new to Java and I understand the underlying basic concepts of
inheritance. I have a question regarding referencing through superclass.
As the methods of class inherited from a superclass or implemented using
an interface can be referenced through a superclass reference (interface
or class). How would it work when both extends and implements are involved
with a class?
class A {
void test() {
System.out.println("One");
}
}
interface J {
void first();
}
// This class object can referenced using A like A a = new B()
class B extends A {
// code
}
// This class object can referenced using J like J j = new B()
class B implements J {
// code
}
// my question is what happens in case of below which referencing for
runtime polymorphism?
class B extends A implements J {
// code
}
Which fails to compile with:
Main.java:16: error: duplicate class: B
class B implements J {
^
Main.java:21: error: duplicate class: B
class B extends A implements J {
^
2 errors
I am new to Java and I understand the underlying basic concepts of
inheritance. I have a question regarding referencing through superclass.
As the methods of class inherited from a superclass or implemented using
an interface can be referenced through a superclass reference (interface
or class). How would it work when both extends and implements are involved
with a class?
class A {
void test() {
System.out.println("One");
}
}
interface J {
void first();
}
// This class object can referenced using A like A a = new B()
class B extends A {
// code
}
// This class object can referenced using J like J j = new B()
class B implements J {
// code
}
// my question is what happens in case of below which referencing for
runtime polymorphism?
class B extends A implements J {
// code
}
Which fails to compile with:
Main.java:16: error: duplicate class: B
class B implements J {
^
Main.java:21: error: duplicate class: B
class B extends A implements J {
^
2 errors
intersection of line and circle
intersection of line and circle
I want to define the point X dynamically. Now I have defined the point at
-90° but I want to make it changeable depending on the place of O. (I know
there are similar questions, but I don't find the answer on my problem.)
\documentclass{article}
\usepackage{pgfplots}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{center}
\begin{tikzpicture}
\coordinate (M) at (0,0) ;
\coordinate (O) at (canvas polar cs:angle=90,radius=3cm) ;
\coordinate (A) at (canvas polar cs:angle=-130,radius=3cm);
\coordinate (B) at (canvas polar cs:angle=-30,radius=3cm) ;
\coordinate (X) at (canvas polar cs:angle=-90,radius=3cm);
\draw (M) circle (3cm);
\draw (A) -- (M) -- (B);
\draw (A) -- (O) -- (B);
\tkzDrawLine[dashed, add= 0.2 and 1.3,color=black](O,M)
\tkzDrawPoints(O,A,B,M,X);
\tkzLabelPoints[left](A,M);
\tkzLabelPoints[below right](X);
\tkzLabelPoints[above left](O);
\tkzLabelPoints(B);
\tkzMarkAngle[fill= red,size=1.5cm, opacity=.4](A,M,B);
\tkzMarkAngle[fill= red,size=1.5cm, opacity=.4](A,O,B);
\tkzLabelAngle[pos = 1.2](A,O,M){$2$};
\tkzLabelAngle[pos = 1.2](M,O,B){$1$};
\tkzLabelAngle[pos = 1.1](A,M,X){$2$};
\tkzLabelAngle[pos = 1.1](X,M,B){$1$};
\end{tikzpicture}
\end{center}
\end{document}
I want to define the point X dynamically. Now I have defined the point at
-90° but I want to make it changeable depending on the place of O. (I know
there are similar questions, but I don't find the answer on my problem.)
\documentclass{article}
\usepackage{pgfplots}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{center}
\begin{tikzpicture}
\coordinate (M) at (0,0) ;
\coordinate (O) at (canvas polar cs:angle=90,radius=3cm) ;
\coordinate (A) at (canvas polar cs:angle=-130,radius=3cm);
\coordinate (B) at (canvas polar cs:angle=-30,radius=3cm) ;
\coordinate (X) at (canvas polar cs:angle=-90,radius=3cm);
\draw (M) circle (3cm);
\draw (A) -- (M) -- (B);
\draw (A) -- (O) -- (B);
\tkzDrawLine[dashed, add= 0.2 and 1.3,color=black](O,M)
\tkzDrawPoints(O,A,B,M,X);
\tkzLabelPoints[left](A,M);
\tkzLabelPoints[below right](X);
\tkzLabelPoints[above left](O);
\tkzLabelPoints(B);
\tkzMarkAngle[fill= red,size=1.5cm, opacity=.4](A,M,B);
\tkzMarkAngle[fill= red,size=1.5cm, opacity=.4](A,O,B);
\tkzLabelAngle[pos = 1.2](A,O,M){$2$};
\tkzLabelAngle[pos = 1.2](M,O,B){$1$};
\tkzLabelAngle[pos = 1.1](A,M,X){$2$};
\tkzLabelAngle[pos = 1.1](X,M,B){$1$};
\end{tikzpicture}
\end{center}
\end{document}
JSON to Android error
JSON to Android error
I have a successfully converted data from database into json format, my
json data is as follows
{"room":[{"id":"1044","location":"kathmandu","title":"room room rome",
"quantity":"2","price":"1000","contact":"9811111111","area":"1500",
"description":"kjkfs ksdjfsd kj","address":"kat"}],"success":1}
I want to view these data on android, my json parser code is
package com.iwantnew.www;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import android.util.Log;
public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
// constructor
public JSONParser() {
}
// function get json from url
// by making HTTP POST or GET mehtod
public JSONObject makeHttpRequest(String url, String method,
List<NameValuePair> params) {
// Making HTTP request
try {
// check for request method
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}else if(method == "GET"){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
}
}
my view room java file is intended to extract the json data
package com.iwantnew.www;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
//import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class viewroom extends ListActivity {
// url to make request
private static String url =
"http://10.0.2.2/iWant/src/android_view_all_room.php";
// JSON Node names
private static final String TAG_ROOM = "room";
// private static final String TAG_SUCCESS = "success";
private static final String TAG_ID = "id";
private static final String TAG_LOCATION = "location";
private static final String TAG_TITLE = "title";
private static final String TAG_QUANTITY = "quantity";
private static final String TAG_PRICE = "price";
private static final String TAG_CONTACT = "contact";
private static final String TAG_AREA = "area";
private static final String TAG_DESCRIPTION = "description";
private static final String TAG_ADDRESS = "address";
// contacts JSONArray
JSONArray room = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_room);
// Hashmap for ListView
ArrayList<HashMap<String, String>> roomList = new
ArrayList<HashMap<String, String>>();
// Creating JSON Parser instance
JSONParser jParser = new JSONParser();
List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
JSONObject json = jParser.makeHttpRequest(url, "GET", params);
try {
// Getting Array of Contacts
room = json.getJSONArray(TAG_ROOM);
// looping through All Contacts
for(int i = 0; i < room.length(); i++){
JSONObject c = room.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_ID);
String location = c.getString(TAG_LOCATION);
String quantity = c.getString(TAG_QUANTITY);
String address = c.getString(TAG_ADDRESS);
String price = c.getString(TAG_PRICE);
String contact = c.getString(TAG_CONTACT);
String area = c.getString(TAG_AREA);
String description = c.getString(TAG_DESCRIPTION);
String title = c.getString(TAG_TITLE);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_ID, id);
map.put(TAG_LOCATION, location);
map.put(TAG_QUANTITY, quantity);
map.put(TAG_ADDRESS, address);
map.put(TAG_PRICE, price);
map.put(TAG_CONTACT, contact);
map.put(TAG_AREA, area);
map.put(TAG_DESCRIPTION, description);
map.put(TAG_TITLE, title);
// adding HashList to ArrayList
roomList.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(this, roomList,
R.layout.list_room,
new String[] { TAG_TITLE, TAG_LOCATION, TAG_PRICE }, new
int[] {
R.id.title, R.id.location, R.id.price });
setListAdapter(adapter);
// selecting single ListView item
ListView lv = getListView();
// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String title = ((TextView)
view.findViewById(R.id.title)).getText().toString();
String location = ((TextView)
view.findViewById(R.id.location)).getText().toString();
String price = ((TextView)
view.findViewById(R.id.price)).getText().toString();
// Starting new intent
Intent in = new Intent(getApplicationContext(),
SingleRoomActivity.class);
in.putExtra(TAG_TITLE, title);
in.putExtra(TAG_LOCATION, location);
in.putExtra(TAG_PRICE, price);
startActivity(in);
}
});
}
}
the singleroom activity class is intended to show data about clicked room
only, it is as follows
package com.iwantnew.www;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class SingleRoomActivity extends Activity {
private static final String TAG_TITLE = "title";
private static final String TAG_LOCATION = "location";
private static final String TAG_PRICE = "price";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.single_room);
// getting intent data
Intent in = getIntent();
// Get JSON values from previous intent
String title = in.getStringExtra(TAG_TITLE);
String location = in.getStringExtra(TAG_LOCATION);
String price = in.getStringExtra(TAG_PRICE);
// Displaying all values on the screen
TextView lblTitle = (TextView) findViewById(R.id.title_label);
TextView lblLocation = (TextView) findViewById(R.id.location_label);
TextView lblPrice = (TextView) findViewById(R.id.price_label);
lblTitle.setText(title);
lblLocation.setText(location);
lblPrice.setText(price);
}
}
and here is the log cat error i get. :(
http://pastebin.com/q4yQxKvF
I have a successfully converted data from database into json format, my
json data is as follows
{"room":[{"id":"1044","location":"kathmandu","title":"room room rome",
"quantity":"2","price":"1000","contact":"9811111111","area":"1500",
"description":"kjkfs ksdjfsd kj","address":"kat"}],"success":1}
I want to view these data on android, my json parser code is
package com.iwantnew.www;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import android.util.Log;
public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
// constructor
public JSONParser() {
}
// function get json from url
// by making HTTP POST or GET mehtod
public JSONObject makeHttpRequest(String url, String method,
List<NameValuePair> params) {
// Making HTTP request
try {
// check for request method
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}else if(method == "GET"){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
}
}
my view room java file is intended to extract the json data
package com.iwantnew.www;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
//import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class viewroom extends ListActivity {
// url to make request
private static String url =
"http://10.0.2.2/iWant/src/android_view_all_room.php";
// JSON Node names
private static final String TAG_ROOM = "room";
// private static final String TAG_SUCCESS = "success";
private static final String TAG_ID = "id";
private static final String TAG_LOCATION = "location";
private static final String TAG_TITLE = "title";
private static final String TAG_QUANTITY = "quantity";
private static final String TAG_PRICE = "price";
private static final String TAG_CONTACT = "contact";
private static final String TAG_AREA = "area";
private static final String TAG_DESCRIPTION = "description";
private static final String TAG_ADDRESS = "address";
// contacts JSONArray
JSONArray room = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_room);
// Hashmap for ListView
ArrayList<HashMap<String, String>> roomList = new
ArrayList<HashMap<String, String>>();
// Creating JSON Parser instance
JSONParser jParser = new JSONParser();
List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
JSONObject json = jParser.makeHttpRequest(url, "GET", params);
try {
// Getting Array of Contacts
room = json.getJSONArray(TAG_ROOM);
// looping through All Contacts
for(int i = 0; i < room.length(); i++){
JSONObject c = room.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_ID);
String location = c.getString(TAG_LOCATION);
String quantity = c.getString(TAG_QUANTITY);
String address = c.getString(TAG_ADDRESS);
String price = c.getString(TAG_PRICE);
String contact = c.getString(TAG_CONTACT);
String area = c.getString(TAG_AREA);
String description = c.getString(TAG_DESCRIPTION);
String title = c.getString(TAG_TITLE);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_ID, id);
map.put(TAG_LOCATION, location);
map.put(TAG_QUANTITY, quantity);
map.put(TAG_ADDRESS, address);
map.put(TAG_PRICE, price);
map.put(TAG_CONTACT, contact);
map.put(TAG_AREA, area);
map.put(TAG_DESCRIPTION, description);
map.put(TAG_TITLE, title);
// adding HashList to ArrayList
roomList.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(this, roomList,
R.layout.list_room,
new String[] { TAG_TITLE, TAG_LOCATION, TAG_PRICE }, new
int[] {
R.id.title, R.id.location, R.id.price });
setListAdapter(adapter);
// selecting single ListView item
ListView lv = getListView();
// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String title = ((TextView)
view.findViewById(R.id.title)).getText().toString();
String location = ((TextView)
view.findViewById(R.id.location)).getText().toString();
String price = ((TextView)
view.findViewById(R.id.price)).getText().toString();
// Starting new intent
Intent in = new Intent(getApplicationContext(),
SingleRoomActivity.class);
in.putExtra(TAG_TITLE, title);
in.putExtra(TAG_LOCATION, location);
in.putExtra(TAG_PRICE, price);
startActivity(in);
}
});
}
}
the singleroom activity class is intended to show data about clicked room
only, it is as follows
package com.iwantnew.www;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class SingleRoomActivity extends Activity {
private static final String TAG_TITLE = "title";
private static final String TAG_LOCATION = "location";
private static final String TAG_PRICE = "price";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.single_room);
// getting intent data
Intent in = getIntent();
// Get JSON values from previous intent
String title = in.getStringExtra(TAG_TITLE);
String location = in.getStringExtra(TAG_LOCATION);
String price = in.getStringExtra(TAG_PRICE);
// Displaying all values on the screen
TextView lblTitle = (TextView) findViewById(R.id.title_label);
TextView lblLocation = (TextView) findViewById(R.id.location_label);
TextView lblPrice = (TextView) findViewById(R.id.price_label);
lblTitle.setText(title);
lblLocation.setText(location);
lblPrice.setText(price);
}
}
and here is the log cat error i get. :(
http://pastebin.com/q4yQxKvF
Samsung Galaxy S2 boot loop
Samsung Galaxy S2 boot loop
Today I updated my S2 with the android version provided by the carrier,
but I thought it went wrong because of the lack of space on /storage and
afterwords some of the apps lost their settings. Also after the update all
the apps started to have disk space errors when trying to update, so I
deleted some of the apps or moved them to external sd, but still had
little space on the 2Gb partition. I looked for a rooting solution and
since I'm on Ubuntu I downloaded Heimdall. I downloaded the latest
firmware version for I9100 from sammobile.com and in console I ran the
following command (saw this in a tutorial)
sudo heimdall flash --factoryfs factoryfs.img
And I got this error
Uploading FACTORYFS
21%
ERROR: Failed to confirm end of file transfer sequence!
FACTORYFS upload failed!
Ending session...
Rebooting device...
Re-attaching kernel driver...
Now everytime I try to boot my phone it goes into recovery mode.
How can I get pass the booting sequence and install a new and functional
android rooted version? Am I missing something in the process, is my first
attempt to root my phone.
Today I updated my S2 with the android version provided by the carrier,
but I thought it went wrong because of the lack of space on /storage and
afterwords some of the apps lost their settings. Also after the update all
the apps started to have disk space errors when trying to update, so I
deleted some of the apps or moved them to external sd, but still had
little space on the 2Gb partition. I looked for a rooting solution and
since I'm on Ubuntu I downloaded Heimdall. I downloaded the latest
firmware version for I9100 from sammobile.com and in console I ran the
following command (saw this in a tutorial)
sudo heimdall flash --factoryfs factoryfs.img
And I got this error
Uploading FACTORYFS
21%
ERROR: Failed to confirm end of file transfer sequence!
FACTORYFS upload failed!
Ending session...
Rebooting device...
Re-attaching kernel driver...
Now everytime I try to boot my phone it goes into recovery mode.
How can I get pass the booting sequence and install a new and functional
android rooted version? Am I missing something in the process, is my first
attempt to root my phone.
suggest me good html and java script library for create zooming user interface? [on hold]
suggest me good html and java script library for create zooming user
interface? [on hold]
suggest me good html and java script library for create zooming user
interface that can create canvas that have zooming button and scroll for
ios.
interface? [on hold]
suggest me good html and java script library for create zooming user
interface that can create canvas that have zooming button and scroll for
ios.
Friday, 23 August 2013
How can I create an if else statement with this situatiion?
How can I create an if else statement with this situatiion?
I want a command that if I enter nothing or null value it will not execute
my insert command.Im using c# and sql server. My code is like this:
SqlCommand cmd = con.CreateCommand(); cmd.CommandText = "INSERT INTO
Records ([Student ID], [First Name], [Last Name], [Middle Initial],
Gender, Address, Status, Year, Email, Course, [Contact Number]) VALUES (
@StudentID, @FirstName, @LastName , @MiddleInitial, @Gender, @Address,
@Status, @Year, @Email, @Course, @ContactNumber)";
SqlParameter p1 = new SqlParameter("@StudentID", SqlDbType.NChar);
p1.Value = textBox1.Text;
cmd.Parameters.Add(p1);
SqlParameter p2 = new SqlParameter("@FirstName", SqlDbType.NVarChar);
p2.Value = textBox2.Text;
cmd.Parameters.Add(p2);
SqlParameter p3 = new SqlParameter("@LastName", SqlDbType.NVarChar);
p3.Value = textBox3.Text;
cmd.Parameters.Add(p3);
SqlParameter p4 = new SqlParameter("@MiddleInitial",
SqlDbType.NChar);
p4.Value = comboBox1.Text;
cmd.Parameters.Add(p4);
SqlParameter p5 = new SqlParameter("@Gender", SqlDbType.NChar);
p5.Value = comboBox2.Text;
cmd.Parameters.Add(p5);
SqlParameter p6 = new SqlParameter("@Address", SqlDbType.VarChar);
p6.Value = textBox4.Text;
cmd.Parameters.Add(p6);
SqlParameter p7 = new SqlParameter("@Status", SqlDbType.NChar);
p7.Value = comboBox3.Text;
cmd.Parameters.Add(p7);
SqlParameter p8 = new SqlParameter("@Year", SqlDbType.VarChar);
p8.Value = comboBox4.Text;
cmd.Parameters.Add(p8);
SqlParameter p9 = new SqlParameter("@Email", SqlDbType.VarChar);
p9.Value = textBox5.Text;
cmd.Parameters.Add(p9);
SqlParameter p10 = new SqlParameter("@Course", SqlDbType.VarChar);
p10.Value = comboBox5.Text;
cmd.Parameters.Add(p10);
SqlParameter p11 = new SqlParameter("@ContactNumber",
SqlDbType.VarChar);
p11.Value = textBox6.Text;
cmd.Parameters.Add(p11);
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";
comboBox4.Text = "";
comboBox5.Text = "";
MessageBox.Show("Data Inserted!", "Information ... ",
MessageBoxButtons.OK, MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1);
cmd.ExecuteNonQuery();
con.Close();
I want a command that if I enter nothing or null value it will not execute
my insert command.Im using c# and sql server. My code is like this:
SqlCommand cmd = con.CreateCommand(); cmd.CommandText = "INSERT INTO
Records ([Student ID], [First Name], [Last Name], [Middle Initial],
Gender, Address, Status, Year, Email, Course, [Contact Number]) VALUES (
@StudentID, @FirstName, @LastName , @MiddleInitial, @Gender, @Address,
@Status, @Year, @Email, @Course, @ContactNumber)";
SqlParameter p1 = new SqlParameter("@StudentID", SqlDbType.NChar);
p1.Value = textBox1.Text;
cmd.Parameters.Add(p1);
SqlParameter p2 = new SqlParameter("@FirstName", SqlDbType.NVarChar);
p2.Value = textBox2.Text;
cmd.Parameters.Add(p2);
SqlParameter p3 = new SqlParameter("@LastName", SqlDbType.NVarChar);
p3.Value = textBox3.Text;
cmd.Parameters.Add(p3);
SqlParameter p4 = new SqlParameter("@MiddleInitial",
SqlDbType.NChar);
p4.Value = comboBox1.Text;
cmd.Parameters.Add(p4);
SqlParameter p5 = new SqlParameter("@Gender", SqlDbType.NChar);
p5.Value = comboBox2.Text;
cmd.Parameters.Add(p5);
SqlParameter p6 = new SqlParameter("@Address", SqlDbType.VarChar);
p6.Value = textBox4.Text;
cmd.Parameters.Add(p6);
SqlParameter p7 = new SqlParameter("@Status", SqlDbType.NChar);
p7.Value = comboBox3.Text;
cmd.Parameters.Add(p7);
SqlParameter p8 = new SqlParameter("@Year", SqlDbType.VarChar);
p8.Value = comboBox4.Text;
cmd.Parameters.Add(p8);
SqlParameter p9 = new SqlParameter("@Email", SqlDbType.VarChar);
p9.Value = textBox5.Text;
cmd.Parameters.Add(p9);
SqlParameter p10 = new SqlParameter("@Course", SqlDbType.VarChar);
p10.Value = comboBox5.Text;
cmd.Parameters.Add(p10);
SqlParameter p11 = new SqlParameter("@ContactNumber",
SqlDbType.VarChar);
p11.Value = textBox6.Text;
cmd.Parameters.Add(p11);
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";
comboBox4.Text = "";
comboBox5.Text = "";
MessageBox.Show("Data Inserted!", "Information ... ",
MessageBoxButtons.OK, MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1);
cmd.ExecuteNonQuery();
con.Close();
ODE45 speed up and for loops
ODE45 speed up and for loops
I have a coupled first order ODE to solve of the form
dy = f(t,x) dx = d(f,x)
which depend on a common parameter which I have to solve for over some
range. I can solve the system using ODE45 and a for loops which increments
the parameter of interest at each loop, however, this is very slow!!! Can
I avoid solving this problem in loops? Or what is best practice with
problems of this type.
I have a coupled first order ODE to solve of the form
dy = f(t,x) dx = d(f,x)
which depend on a common parameter which I have to solve for over some
range. I can solve the system using ODE45 and a for loops which increments
the parameter of interest at each loop, however, this is very slow!!! Can
I avoid solving this problem in loops? Or what is best practice with
problems of this type.
Writing on the same line in FORTRAN
Writing on the same line in FORTRAN
In FORTRAN, each time one uses WRITE a new line is produced. In order to
control the working of a program that is being executed, I would like to
write on screen the current value of a variable, but always on the same
line (erasing the previous value and starting at the beginning of the
line). That is, something like
1 CONTINUE
"update the value of a"
WRITE(*,*) a
BACKSPACE "screen"
GOTO 1
Something like WRITE(*,*,ADVANCE='NO') (incorrect anyway) is not quite
what I need: this would write all the values of "a" one after another on a
very long line.
Thanks in advance
In FORTRAN, each time one uses WRITE a new line is produced. In order to
control the working of a program that is being executed, I would like to
write on screen the current value of a variable, but always on the same
line (erasing the previous value and starting at the beginning of the
line). That is, something like
1 CONTINUE
"update the value of a"
WRITE(*,*) a
BACKSPACE "screen"
GOTO 1
Something like WRITE(*,*,ADVANCE='NO') (incorrect anyway) is not quite
what I need: this would write all the values of "a" one after another on a
very long line.
Thanks in advance
How to update_all() with subquery referring to the record being updated in Rails
How to update_all() with subquery referring to the record being updated in
Rails
I'm trying to implement an equivalent of the following (postgres)SQL
statement in rails:
UPDATE events AS A
SET A.has_repeated = EXISTS(SELECT *
FROM events AS B
WHERE A.event_type_id = B.event_type_id
AND B.started_at > A.finished_at
AND B.started_at - A.finished_at <= 7)
That is I need to mark all events that have an event of the same
event_type_id having happened within 7 days.
I want to implement is as a class method of Event that I could use like:
Event.where( some conditions ).limit( ... ).offset( ...).mark_repeats()
so the generated SQL would have corresponding WHERE, LIMIT and OFFSET
clauses appended.
I started with a broken implementation:
def Event.mark_repeats
update_all( 'has_repeated = EXISTS( ...etc... )' )
end
but then I couldn't find where to specify the first table alias (A). I
tried with:
def Event.mark_repeats
from('events AS A').update_all( 'has_repeated = EXISTS( ...etc... )' )
end
but it didn't work.
My current implementation is:
def Event.mark_repeats
sql = "UPDATE events AS A SET has_repeated = #{repetition_criterion_sql}"
if current_scope
sql += "\n#{current_scope.where_sql.try(:gsub,/"events"/,'A')}"
end
connection.update_sql sql
end
which doesn't respect limit or offset and feels generally fragile,
especially the way I have to replace "events" with the alias.
Is there a better way to accomplish this - a different SQL technique to
accomplish the same end, or a different rails abstraction to express the
problem in?
Rails
I'm trying to implement an equivalent of the following (postgres)SQL
statement in rails:
UPDATE events AS A
SET A.has_repeated = EXISTS(SELECT *
FROM events AS B
WHERE A.event_type_id = B.event_type_id
AND B.started_at > A.finished_at
AND B.started_at - A.finished_at <= 7)
That is I need to mark all events that have an event of the same
event_type_id having happened within 7 days.
I want to implement is as a class method of Event that I could use like:
Event.where( some conditions ).limit( ... ).offset( ...).mark_repeats()
so the generated SQL would have corresponding WHERE, LIMIT and OFFSET
clauses appended.
I started with a broken implementation:
def Event.mark_repeats
update_all( 'has_repeated = EXISTS( ...etc... )' )
end
but then I couldn't find where to specify the first table alias (A). I
tried with:
def Event.mark_repeats
from('events AS A').update_all( 'has_repeated = EXISTS( ...etc... )' )
end
but it didn't work.
My current implementation is:
def Event.mark_repeats
sql = "UPDATE events AS A SET has_repeated = #{repetition_criterion_sql}"
if current_scope
sql += "\n#{current_scope.where_sql.try(:gsub,/"events"/,'A')}"
end
connection.update_sql sql
end
which doesn't respect limit or offset and feels generally fragile,
especially the way I have to replace "events" with the alias.
Is there a better way to accomplish this - a different SQL technique to
accomplish the same end, or a different rails abstraction to express the
problem in?
Self-learning Mathematics
Self-learning Mathematics
My question is very elementary, but I hope that you will endure it.
I am currently in a CS Master's program and I notice that my skills in
mathematics are lacking. My calculus course was 10 years ago. I know I can
take remedial courses, but I was hoping to do some self study to learn
mathematics because it is something that I have always wished to
understand, just never had a lot of time nor knew exactly what order in
which to learn topics.
What books could anyone recommend that would take me from College Algebra
to Calculus and anything beyond.
Also, does anyone know a hierarchical structure of all mathematical fields?
Thanks, xeralti
My question is very elementary, but I hope that you will endure it.
I am currently in a CS Master's program and I notice that my skills in
mathematics are lacking. My calculus course was 10 years ago. I know I can
take remedial courses, but I was hoping to do some self study to learn
mathematics because it is something that I have always wished to
understand, just never had a lot of time nor knew exactly what order in
which to learn topics.
What books could anyone recommend that would take me from College Algebra
to Calculus and anything beyond.
Also, does anyone know a hierarchical structure of all mathematical fields?
Thanks, xeralti
When is a correspondence constant or fixed?
When is a correspondence constant or fixed?
Given that $X,Y$ are subsets of some Euclidean space, when is $$ f:X
\rightrightarrows Y$$ a constant correspondence? What exactly does a
constant correspondence mean? An example would make the point clearer for
me. May somebody suggest a more appropriate tag for the question?
Given that $X,Y$ are subsets of some Euclidean space, when is $$ f:X
\rightrightarrows Y$$ a constant correspondence? What exactly does a
constant correspondence mean? An example would make the point clearer for
me. May somebody suggest a more appropriate tag for the question?
Thursday, 22 August 2013
Failing tests when including .in files
Failing tests when including .in files
My code works fine when I manually input the shift and text, but when I
try to test it using the .in files (e.g. c1.in) it just prints out "Enter
shift: Enter text:" and then exits. I'm not sure how to fix my code so
that it can pass the tests. Any help would be appreciated.
My code:
#include <stdio.h>
int encode(int ch, int shift);
int rotate_right(int ch, int shift);
int rotate_left(int ch, int shift);
int main() {
int ch;
int shift;
printf("Enter shift: ");
scanf("%d", &shift);
printf("Enter text: ");
while((ch = getchar()) != EOF) {
putchar(encode(ch, shift));
}
return 0;
}
int encode(int ch, int shift) {
char newLetter;
shift = shift % 26;
if (shift > 0) {
newLetter = rotate_right(ch, shift);
} else if (shift < 0) {
newLetter = rotate_left(ch, shift);
} else {
newLetter = ch;
}
return newLetter;
}
int rotate_right(int ch, int shift) {
char newLetter;
if (ch > 64 && ch < 91) {
if (shift < 91 - ch) {
newLetter = ch + shift;
} else {
newLetter = ch + shift - 26;
}
} else if (ch > 96 && ch < 123) {
if (shift < 123 - ch) {
newLetter = ch + shift;
} else {
newLetter = ch + shift - 26;
}
} else {
newLetter = ch;
}
return newLetter;
}
int rotate_left(int ch, int shift) {
char newLetter;
shift = -shift;
if (ch > 64 && ch < 91) {
if (shift < ch - 64) {
newLetter = ch - shift;
} else {
newLetter = ch - shift + 26;
}
} else if (ch > 96 && ch < 123) {
if (shift < ch - 96) {
newLetter = ch - shift;
} else {
newLetter = ch - shift + 26;
}
} else {
newLetter = ch;
}
return newLetter;
}
c1.in:
19
Aolyl pz h apkl pu aol hmmhpyz vm tlu
Dopjo ahrlu ha aol msvvk, slhkz vu av mvyabul;
Vtpaalk, hss aol cvfhnl vm aolpy spml
Pz ivbuk pu zohssvdz huk pu tpzlyplz.
Thanks.
My code works fine when I manually input the shift and text, but when I
try to test it using the .in files (e.g. c1.in) it just prints out "Enter
shift: Enter text:" and then exits. I'm not sure how to fix my code so
that it can pass the tests. Any help would be appreciated.
My code:
#include <stdio.h>
int encode(int ch, int shift);
int rotate_right(int ch, int shift);
int rotate_left(int ch, int shift);
int main() {
int ch;
int shift;
printf("Enter shift: ");
scanf("%d", &shift);
printf("Enter text: ");
while((ch = getchar()) != EOF) {
putchar(encode(ch, shift));
}
return 0;
}
int encode(int ch, int shift) {
char newLetter;
shift = shift % 26;
if (shift > 0) {
newLetter = rotate_right(ch, shift);
} else if (shift < 0) {
newLetter = rotate_left(ch, shift);
} else {
newLetter = ch;
}
return newLetter;
}
int rotate_right(int ch, int shift) {
char newLetter;
if (ch > 64 && ch < 91) {
if (shift < 91 - ch) {
newLetter = ch + shift;
} else {
newLetter = ch + shift - 26;
}
} else if (ch > 96 && ch < 123) {
if (shift < 123 - ch) {
newLetter = ch + shift;
} else {
newLetter = ch + shift - 26;
}
} else {
newLetter = ch;
}
return newLetter;
}
int rotate_left(int ch, int shift) {
char newLetter;
shift = -shift;
if (ch > 64 && ch < 91) {
if (shift < ch - 64) {
newLetter = ch - shift;
} else {
newLetter = ch - shift + 26;
}
} else if (ch > 96 && ch < 123) {
if (shift < ch - 96) {
newLetter = ch - shift;
} else {
newLetter = ch - shift + 26;
}
} else {
newLetter = ch;
}
return newLetter;
}
c1.in:
19
Aolyl pz h apkl pu aol hmmhpyz vm tlu
Dopjo ahrlu ha aol msvvk, slhkz vu av mvyabul;
Vtpaalk, hss aol cvfhnl vm aolpy spml
Pz ivbuk pu zohssvdz huk pu tpzlyplz.
Thanks.
Processing form on same page vs separate page
Processing form on same page vs separate page
What are the advantages/disadvantages of processing forms on the same page
vs on a separate page? I'm using PHP to handle my forms. Any input is
appreciated.
What are the advantages/disadvantages of processing forms on the same page
vs on a separate page? I'm using PHP to handle my forms. Any input is
appreciated.
Preserve user preferences upon app update
Preserve user preferences upon app update
I am using the Preference class for storing user settings in my app.
How can I ensure these settings are preserved upon issuing app updates?
I am using the Preference class for storing user settings in my app.
How can I ensure these settings are preserved upon issuing app updates?
How to send a image and save in the folder create from user-android
How to send a image and save in the folder create from user-android
I first created the main thing in which the user can create and name the
folder, pushing the button moves to the next the camera's. After the
folder is created but the images can not save them in the path that comes
dall'intent. I am confused totally and I apologize for my English
final String direct = this.getIntent().getStringExtra("key");
public static final int MEDIA_TYPE_IMAGE = 1;
/** Create a file Uri for saving an image or video */
Uri uriSavedImage=Uri.fromFile(new File( direct + "photo.jpg"));
final Uri getOutputMediaFileUri(int type){
return Uri.fromFile(getOutputMediaFile(type));
}
/** Create a File for saving an image or video */
final File getOutputMediaFile(int type){
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing this.
File mediaStorageDir = new
File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES ), "direct" );
// This location works best if you want the created images to be shared
// between applications and persist after your app has been uninstalled.
// Create the storage directory if it does not exist
if (! mediaStorageDir.exists()){
if (! mediaStorageDir.mkdirs()){
Log.d("MyCameraApp", "failed to create directory");
return null;
}
}
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new
Date());
File mediaFile;
if (type == MEDIA_TYPE_IMAGE){
mediaFile = new File(mediaStorageDir.getPath() + File.separator +
"IMG_"+ timeStamp + ".jpg");
} else {
return null;
}
return mediaFile;
}
}
Main is this
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
EditText text = (EditText)findViewById(R.id.editText1);
EditText text2 = (EditText)findViewById(R.id.editText2);
EditText text3 = (EditText)findViewById(R.id.editText3);
@Override
public void onClick(View v) {
final String name = text.getText().toString();
final String placeName = text2.getText().toString();
final String dettaglio =text3.getText().toString();
String place = placeName.substring(0,3);
String direct = name + place + dettaglio ;
File folder = new File("/sdcard/CameraTest/" + direct + "/");
folder.mkdirs();
Intent myIntent = new Intent(MainActivity.this,
CameraView.class);
myIntent.putExtra("key", "/sdcard/CameraTest/" + direct + "/");
startActivity(myIntent);
}
});
}
}
I first created the main thing in which the user can create and name the
folder, pushing the button moves to the next the camera's. After the
folder is created but the images can not save them in the path that comes
dall'intent. I am confused totally and I apologize for my English
final String direct = this.getIntent().getStringExtra("key");
public static final int MEDIA_TYPE_IMAGE = 1;
/** Create a file Uri for saving an image or video */
Uri uriSavedImage=Uri.fromFile(new File( direct + "photo.jpg"));
final Uri getOutputMediaFileUri(int type){
return Uri.fromFile(getOutputMediaFile(type));
}
/** Create a File for saving an image or video */
final File getOutputMediaFile(int type){
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing this.
File mediaStorageDir = new
File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES ), "direct" );
// This location works best if you want the created images to be shared
// between applications and persist after your app has been uninstalled.
// Create the storage directory if it does not exist
if (! mediaStorageDir.exists()){
if (! mediaStorageDir.mkdirs()){
Log.d("MyCameraApp", "failed to create directory");
return null;
}
}
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new
Date());
File mediaFile;
if (type == MEDIA_TYPE_IMAGE){
mediaFile = new File(mediaStorageDir.getPath() + File.separator +
"IMG_"+ timeStamp + ".jpg");
} else {
return null;
}
return mediaFile;
}
}
Main is this
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
EditText text = (EditText)findViewById(R.id.editText1);
EditText text2 = (EditText)findViewById(R.id.editText2);
EditText text3 = (EditText)findViewById(R.id.editText3);
@Override
public void onClick(View v) {
final String name = text.getText().toString();
final String placeName = text2.getText().toString();
final String dettaglio =text3.getText().toString();
String place = placeName.substring(0,3);
String direct = name + place + dettaglio ;
File folder = new File("/sdcard/CameraTest/" + direct + "/");
folder.mkdirs();
Intent myIntent = new Intent(MainActivity.this,
CameraView.class);
myIntent.putExtra("key", "/sdcard/CameraTest/" + direct + "/");
startActivity(myIntent);
}
});
}
}
Wednesday, 21 August 2013
jQuery Animation not working right
jQuery Animation not working right
I am new to javascript and jQuery but I am trying to do some cool
animations on my website and the code is probably a bit long to post here.
I am building a cool new student portfolio page for myself and am having
an issue with jQuery animations I believe.
My Website is http://timherbert.net
My problem is that if you click on development then try to click on the
design button that appears in the nav, the animation won't work. The other
side works perfectly well clicking on design and then development brings
me back to the other side. I've struggled to figure out this bug and why
it won't work and am baffled.
As I said I am new to this kind of thing so please be gentle. But things I
am doing wrong and need to correct and other critiques would be greatly
appreciated.
All of my scripts are linked at the bottom of the page and main.js is my
main javascript file. I'll post a couple of my functions here and maybe
someone will spot a problem there. I apologize for the crazy indentation
in the code as struggled posting it here.
function rightButton(){
$('.theatre').empty();
$('#content').slideUp();
$('#content-wrapper').toggleClass('overflow');
$('#content-wrapper').removeAttr('style', "");
$("#rightRect").removeClass('cursor');
$("#rightRect").addClass('zz');
$("#rightRect").animate({right:'87%'});
$(content2).appendTo('.theatre');
$('#leftRect').animate({right:'87%'});
$('#social-icons').css({'right': 20 + 'px'});
$('#design-more').animate({right:'-597%'});
$('#design-more').slideDown();
setTimeout(function() { var h = $('.theatre').height();
var hh =
$('#hodgepodge').height();
$('#rightRect').css({'height': h + 'px'});
$('#hodge').css({'height': hh - 20 + 'px'});
$('#rnav').slideDown();
$('#tooltip').tooltip();
$('.tooltip1').tooltip();
$('.tooltip2').tooltip();
$('.tooltip3').tooltip();
}
function leftButton(){
setTimeout(function() {
$('.theatre').empty();
$(content1).appendTo('.theatre');
$('#social-icons').css({'right': 220 + 'px'});
$('#tooltip').tooltip();
$('.tooltip1').tooltip();
$('.tooltip2').tooltip();
$('.tooltip3').tooltip();
}, 20);
$("#leftRect").addClass('yy');
$("#leftRect").animate({left:'86%'});
$('#lnav').fadeIn();
$('#lnav').fadeTo('0.2');
$('#content').slideUp()
$('#rightRect').animate({left:'87%'});
$("#leftRect").addClass('yy');
}
I am new to javascript and jQuery but I am trying to do some cool
animations on my website and the code is probably a bit long to post here.
I am building a cool new student portfolio page for myself and am having
an issue with jQuery animations I believe.
My Website is http://timherbert.net
My problem is that if you click on development then try to click on the
design button that appears in the nav, the animation won't work. The other
side works perfectly well clicking on design and then development brings
me back to the other side. I've struggled to figure out this bug and why
it won't work and am baffled.
As I said I am new to this kind of thing so please be gentle. But things I
am doing wrong and need to correct and other critiques would be greatly
appreciated.
All of my scripts are linked at the bottom of the page and main.js is my
main javascript file. I'll post a couple of my functions here and maybe
someone will spot a problem there. I apologize for the crazy indentation
in the code as struggled posting it here.
function rightButton(){
$('.theatre').empty();
$('#content').slideUp();
$('#content-wrapper').toggleClass('overflow');
$('#content-wrapper').removeAttr('style', "");
$("#rightRect").removeClass('cursor');
$("#rightRect").addClass('zz');
$("#rightRect").animate({right:'87%'});
$(content2).appendTo('.theatre');
$('#leftRect').animate({right:'87%'});
$('#social-icons').css({'right': 20 + 'px'});
$('#design-more').animate({right:'-597%'});
$('#design-more').slideDown();
setTimeout(function() { var h = $('.theatre').height();
var hh =
$('#hodgepodge').height();
$('#rightRect').css({'height': h + 'px'});
$('#hodge').css({'height': hh - 20 + 'px'});
$('#rnav').slideDown();
$('#tooltip').tooltip();
$('.tooltip1').tooltip();
$('.tooltip2').tooltip();
$('.tooltip3').tooltip();
}
function leftButton(){
setTimeout(function() {
$('.theatre').empty();
$(content1).appendTo('.theatre');
$('#social-icons').css({'right': 220 + 'px'});
$('#tooltip').tooltip();
$('.tooltip1').tooltip();
$('.tooltip2').tooltip();
$('.tooltip3').tooltip();
}, 20);
$("#leftRect").addClass('yy');
$("#leftRect").animate({left:'86%'});
$('#lnav').fadeIn();
$('#lnav').fadeTo('0.2');
$('#content').slideUp()
$('#rightRect').animate({left:'87%'});
$("#leftRect").addClass('yy');
}
Python multiprocess, fast computation of a big matrix
Python multiprocess, fast computation of a big matrix
everyone, I am trying to make the following computation.
I have an 2D n*d numpy array A, each of its row is a d-dimensional
datapoint x. I want to compute a n*n matrix B, each of its element B[i, j
] = f( A[i], A[j]), where f(p,q) is a symmetric function applies to every
possible pair of datapints, e.g. sum(p*q)
Since n and d can be very large, n~200000, d~1000, this computation is
very slow, I am trying to speed it up using multiprocessing.Pool()
This is the code I am having so far, I am intentionally ignore the
symmetry property ( B[i,j]==B[j,i]) for simplicity.
p = Pool(cpu_count())
for i, x in enumerate(A):
B[i] = p.map(functools.partial(f , x) , A)
I am fixing one parameter of f() as one element of A, and apply map() = to
the iterable nparray A, so that I can get the answer for one row at a
time.
The problem with this is the speed, it is even slower than my original
elementwise computation when I tried it with (n,d) = (1000, 100).
After reading many other related posts, I guess this is because the
function f() has been pickled and unpickled back and forth, inducing huge
overhead.
Do I guess it right? Is there a better way of doing this ?
Thanks in advance.
everyone, I am trying to make the following computation.
I have an 2D n*d numpy array A, each of its row is a d-dimensional
datapoint x. I want to compute a n*n matrix B, each of its element B[i, j
] = f( A[i], A[j]), where f(p,q) is a symmetric function applies to every
possible pair of datapints, e.g. sum(p*q)
Since n and d can be very large, n~200000, d~1000, this computation is
very slow, I am trying to speed it up using multiprocessing.Pool()
This is the code I am having so far, I am intentionally ignore the
symmetry property ( B[i,j]==B[j,i]) for simplicity.
p = Pool(cpu_count())
for i, x in enumerate(A):
B[i] = p.map(functools.partial(f , x) , A)
I am fixing one parameter of f() as one element of A, and apply map() = to
the iterable nparray A, so that I can get the answer for one row at a
time.
The problem with this is the speed, it is even slower than my original
elementwise computation when I tried it with (n,d) = (1000, 100).
After reading many other related posts, I guess this is because the
function f() has been pickled and unpickled back and forth, inducing huge
overhead.
Do I guess it right? Is there a better way of doing this ?
Thanks in advance.
Heroku deploys without formatting?
Heroku deploys without formatting?
Let me start by saying I'm very new to heroku/ruby/rails. I'm going
through the Ruby on Rails Tutorial by Michael Hartl and when I deploy my
app on a local server using 'rails s' everything shows up fine. However,
when I push my app to heroku and deploy it using 'heroku open' the app
seems to skip all the assets. I verified that the asset pipeline is
enabled but I still can't get to get my app to deploy on heroku with any
formatting.
I've been looking at the heroku logs but it seems that the only error is a
FATAL SignalException but I'm not sure what that's referring to. Also if
someone could explain whether or not a Deprecation Warning is serious, I'd
be very thankful.
heroku logs:
2013-08-20T23:23:14.690294+00:00 app[web.1]: [2013-08-20 23:23:14] FATAL
SignalException: SIGTERM
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `select'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in
start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in `start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/handler/webrick.rb:13:in
`run'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in
`start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:268:in
`start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:55:in
`block in <top (required)>'
2013-08-20T23:23:14.690514+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:50:in
`<top (required)>'
2013-08-20T23:23:14.690514+00:00 app[web.1]: script/rails:6:in `require'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:50:in
`tap'
2013-08-20T23:23:14.690514+00:00 app[web.1]: script/rails:6:in `<main>'
2013-08-20T23:23:14.690825+00:00 app[web.1]: [2013-08-20 23:23:14] INFO
going to shutdown ...
2013-08-20T23:23:14.691003+00:00 app[web.1]: [2013-08-20 23:23:14] INFO
WEBrick::HTTPServer#start done.
2013-08-20T23:23:14.691149+00:00 app[web.1]: Exiting
2013-08-20T23:23:16.134514+00:00 heroku[web.1]: Process exited with status
143
2013-08-20T23:23:17.437119+00:00 heroku[web.1]: Starting process with
command `bundle exec rails server -p 45415`
2013-08-20T23:23:20.063810+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-08-20T23:23:20.063810+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-08-20T23:23:20.892393+00:00 app[web.1]: SECURITY WARNING: No
secret option provided to Rack::Session::Cookie.
2013-08-20T23:23:20.892393+00:00 app[web.1]: This poses a security
threat. It is strongly recommended that you
2013-08-20T23:23:20.892393+00:00 app[web.1]: future versions will
even invalidate your existing user cookies.
2013-08-20T23:23:20.892393+00:00 app[web.1]: Called from:
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.3/lib/action_dispatch/middleware/session/abstract_store.rb:28:in
`initialize'.
2013-08-20T23:23:20.892393+00:00 app[web.1]: provide a secret to
prevent exploits that may be possible from crafted
2013-08-20T23:23:20.892393+00:00 app[web.1]: cookies. This will
not be supported in future versions of Rack, and
2013-08-20T23:23:20.892393+00:00 app[web.1]:
2013-08-20T23:23:21.462460+00:00 heroku[web.1]: State changed from
starting to up
2013-08-20T23:23:21.255176+00:00 app[web.1]: [2013-08-20 23:23:21] INFO
WEBrick 1.3.1
2013-08-20T23:23:21.255176+00:00 app[web.1]: [2013-08-20 23:23:21] INFO
ruby 2.0.0 (2013-06-27) [x86_64-linux]
2013-08-20T23:23:21.255549+00:00 app[web.1]: [2013-08-20 23:23:21] INFO
WEBrick::HTTPServer#start: pid=2 port=45415
2013-08-20T23:23:26.146248+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-08-20T23:23:26.146248+00:00 app[web.1]:
2013-08-20T23:23:26.146248+00:00 app[web.1]:
2013-08-20T23:23:26.146248+00:00 app[web.1]: Started GET "/" for
69.254.153.186 at 2013-08-20 23:23:26 +0000
2013-08-20T23:23:26.146248+00:00 app[web.1]: => Booting WEBrick
2013-08-20T23:23:26.146248+00:00 app[web.1]: => Rails 3.2.3 application
starting in production on http://0.0.0.0:45415
2013-08-20T23:23:26.146248+00:00 app[web.1]: => Call with -d to detach
2013-08-20T23:23:26.489483+00:00 app[web.1]: Rendered
static_pages/home.html.erb within layouts/application (2.2ms)
2013-08-20T23:23:26.481456+00:00 app[web.1]: Processing by
StaticPagesController#home as HTML
2013-08-20T23:23:26.496375+00:00 app[web.1]: Rendered
layouts/_header.html.erb (1.3ms)
2013-08-20T23:23:26.494575+00:00 app[web.1]: Rendered
layouts/_shim.html.erb (0.3ms)
2013-08-20T23:23:26.497960+00:00 app[web.1]: Completed 200 OK in 16ms
(Views: 15.8ms | ActiveRecord: 0.0ms)
2013-08-20T23:23:26.497774+00:00 app[web.1]: Rendered
layouts/_footer.html.erb (0.9ms)
2013-08-20T23:23:26.670396+00:00 heroku[router]: at=info method=GET
path=/assets/application-3428e82709d7645135002c8fadfafdc6.js
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=4ms service=20ms status=200 bytes=642
2013-08-20T23:23:26.693364+00:00 heroku[router]: at=info method=GET
path=/assets/application-7270767b2a9e9fff880aa5de378ca791.css
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=26ms status=200 bytes=0
2013-08-20T23:23:26.795663+00:00 heroku[router]: at=info method=GET
path=/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=1ms service=9ms status=200 bytes=6646
2013-08-20T23:23:26.506094+00:00 heroku[router]: at=info method=GET path=/
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=380ms status=304 bytes=0
2013-08-21T00:29:30.830550+00:00 heroku[web.1]: Idling
2013-08-21T00:29:35.491771+00:00 heroku[web.1]: Stopping all processes
with SIGTERM
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `select'
2013-08-21T00:29:36.117015+00:00 app[web.1]: [2013-08-21 00:29:36] FATAL
SignalException: SIGTERM
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in
`start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in `start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:55:in
`block in <top (required)>'
2013-08-21T00:29:36.117176+00:00 app[web.1]: script/rails:6:in `<main>'
2013-08-21T00:29:36.117176+00:00 app[web.1]: [2013-08-21 00:29:36] INFO
going to shutdown ...
2013-08-21T00:29:36.117176+00:00 app[web.1]: [2013-08-21 00:29:36] INFO
WEBrick::HTTPServer#start done.
2013-08-21T00:29:36.117176+00:00 app[web.1]: Exiting
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:268:in
`start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in
start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/handler/webrick.rb:13:in
`run'
2013-08-21T00:29:36.117176+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:50:in
`<top (required)>'
2013-08-21T00:29:36.117176+00:00 app[web.1]: script/rails:6:in `require'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:50:in
`tap'
2013-08-21T00:29:37.526666+00:00 heroku[web.1]: State changed from up to down
2013-08-21T00:29:37.523783+00:00 heroku[web.1]: Process exited with status
143
2013-08-21T22:25:21.381126+00:00 heroku[web.1]: Unidling
2013-08-21T22:25:21.381126+00:00 heroku[web.1]: State changed from down to
starting
2013-08-21T22:25:27.384489+00:00 heroku[web.1]: Starting process with
command `bundle exec rails server -p 5284`
2013-08-21T22:25:33.072380+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-08-21T22:25:33.072739+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-08-21T22:25:33.666165+00:00 app[web.1]: SECURITY WARNING: No
secret option provided to Rack::Session::Cookie.
2013-08-21T22:25:33.666165+00:00 app[web.1]: This poses a security
threat. It is strongly recommended that you
2013-08-21T22:25:33.666165+00:00 app[web.1]: provide a secret to
prevent exploits that may be possible from crafted
2013-08-21T22:25:33.666165+00:00 app[web.1]: cookies. This will
not be supported in future versions of Rack, and
2013-08-21T22:25:33.666165+00:00 app[web.1]: future versions will
even invalidate your existing user cookies.
2013-08-21T22:25:33.666165+00:00 app[web.1]: Called from:
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.3/lib/action_dispatch/middleware/session/abstract_store.rb:28:in
`initialize'.
2013-08-21T22:25:33.666165+00:00 app[web.1]:
2013-08-21T22:25:34.000370+00:00 app[web.1]: [2013-08-21 22:25:34] INFO
WEBrick::HTTPServer#start: pid=2 port=5284
2013-08-21T22:25:34.000010+00:00 app[web.1]: [2013-08-21 22:25:33] INFO
WEBrick 1.3.1
2013-08-21T22:25:34.000010+00:00 app[web.1]: [2013-08-21 22:25:33] INFO
ruby 2.0.0 (2013-06-27) [x86_64-linux]
2013-08-21T22:25:34.121184+00:00 heroku[web.1]: State changed from
starting to up
2013-08-21T22:25:35.491396+00:00 app[web.1]: => Rails 3.2.3 application
starting in production on http://0.0.0.0:5284
2013-08-21T22:25:35.491396+00:00 app[web.1]: => Call with -d to detach
2013-08-21T22:25:35.491396+00:00 app[web.1]: => Booting WEBrick
2013-08-21T22:25:35.491396+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-08-21T22:25:35.491396+00:00 app[web.1]:
2013-08-21T22:25:35.491396+00:00 app[web.1]:
2013-08-21T22:25:35.491396+00:00 app[web.1]: Started GET "/" for
69.254.153.186 at 2013-08-21 22:25:35 +0000
2013-08-21T22:25:35.800959+00:00 app[web.1]: Processing by
StaticPagesController#home as HTML
2013-08-21T22:25:35.808774+00:00 app[web.1]: Rendered
static_pages/home.html.erb within layouts/application (2.0ms)
2013-08-21T22:25:35.813736+00:00 app[web.1]: Rendered
layouts/_shim.html.erb (0.3ms)
2013-08-21T22:25:35.815682+00:00 app[web.1]: Rendered
layouts/_header.html.erb (1.3ms)
2013-08-21T22:25:35.817164+00:00 app[web.1]: Rendered
layouts/_footer.html.erb (0.9ms)
2013-08-21T22:25:35.817399+00:00 app[web.1]: Completed 200 OK in 16ms
(Views: 15.7ms | ActiveRecord: 0.0ms)
2013-08-21T22:25:35.821307+00:00 heroku[router]: at=info method=GET path=/
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=345ms status=200 bytes=1862
2013-08-21T22:25:36.462464+00:00 heroku[router]: at=info method=GET
path=/assets/application-3428e82709d7645135002c8fadfafdc6.js
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=7ms status=304 bytes=0
2013-08-21T22:25:36.825347+00:00 heroku[router]: at=info method=GET
path=/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=15ms status=304 bytes=0
2013-08-21T22:25:36.172492+00:00 heroku[router]: at=info method=GET
path=/assets/application-7270767b2a9e9fff880aa5de378ca791.css
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=8ms status=304 bytes=0
Let me start by saying I'm very new to heroku/ruby/rails. I'm going
through the Ruby on Rails Tutorial by Michael Hartl and when I deploy my
app on a local server using 'rails s' everything shows up fine. However,
when I push my app to heroku and deploy it using 'heroku open' the app
seems to skip all the assets. I verified that the asset pipeline is
enabled but I still can't get to get my app to deploy on heroku with any
formatting.
I've been looking at the heroku logs but it seems that the only error is a
FATAL SignalException but I'm not sure what that's referring to. Also if
someone could explain whether or not a Deprecation Warning is serious, I'd
be very thankful.
heroku logs:
2013-08-20T23:23:14.690294+00:00 app[web.1]: [2013-08-20 23:23:14] FATAL
SignalException: SIGTERM
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `select'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in
start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in `start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/handler/webrick.rb:13:in
`run'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in
`start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:268:in
`start'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:55:in
`block in <top (required)>'
2013-08-20T23:23:14.690514+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:50:in
`<top (required)>'
2013-08-20T23:23:14.690514+00:00 app[web.1]: script/rails:6:in `require'
2013-08-20T23:23:14.690294+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:50:in
`tap'
2013-08-20T23:23:14.690514+00:00 app[web.1]: script/rails:6:in `<main>'
2013-08-20T23:23:14.690825+00:00 app[web.1]: [2013-08-20 23:23:14] INFO
going to shutdown ...
2013-08-20T23:23:14.691003+00:00 app[web.1]: [2013-08-20 23:23:14] INFO
WEBrick::HTTPServer#start done.
2013-08-20T23:23:14.691149+00:00 app[web.1]: Exiting
2013-08-20T23:23:16.134514+00:00 heroku[web.1]: Process exited with status
143
2013-08-20T23:23:17.437119+00:00 heroku[web.1]: Starting process with
command `bundle exec rails server -p 45415`
2013-08-20T23:23:20.063810+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-08-20T23:23:20.063810+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-08-20T23:23:20.892393+00:00 app[web.1]: SECURITY WARNING: No
secret option provided to Rack::Session::Cookie.
2013-08-20T23:23:20.892393+00:00 app[web.1]: This poses a security
threat. It is strongly recommended that you
2013-08-20T23:23:20.892393+00:00 app[web.1]: future versions will
even invalidate your existing user cookies.
2013-08-20T23:23:20.892393+00:00 app[web.1]: Called from:
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.3/lib/action_dispatch/middleware/session/abstract_store.rb:28:in
`initialize'.
2013-08-20T23:23:20.892393+00:00 app[web.1]: provide a secret to
prevent exploits that may be possible from crafted
2013-08-20T23:23:20.892393+00:00 app[web.1]: cookies. This will
not be supported in future versions of Rack, and
2013-08-20T23:23:20.892393+00:00 app[web.1]:
2013-08-20T23:23:21.462460+00:00 heroku[web.1]: State changed from
starting to up
2013-08-20T23:23:21.255176+00:00 app[web.1]: [2013-08-20 23:23:21] INFO
WEBrick 1.3.1
2013-08-20T23:23:21.255176+00:00 app[web.1]: [2013-08-20 23:23:21] INFO
ruby 2.0.0 (2013-06-27) [x86_64-linux]
2013-08-20T23:23:21.255549+00:00 app[web.1]: [2013-08-20 23:23:21] INFO
WEBrick::HTTPServer#start: pid=2 port=45415
2013-08-20T23:23:26.146248+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-08-20T23:23:26.146248+00:00 app[web.1]:
2013-08-20T23:23:26.146248+00:00 app[web.1]:
2013-08-20T23:23:26.146248+00:00 app[web.1]: Started GET "/" for
69.254.153.186 at 2013-08-20 23:23:26 +0000
2013-08-20T23:23:26.146248+00:00 app[web.1]: => Booting WEBrick
2013-08-20T23:23:26.146248+00:00 app[web.1]: => Rails 3.2.3 application
starting in production on http://0.0.0.0:45415
2013-08-20T23:23:26.146248+00:00 app[web.1]: => Call with -d to detach
2013-08-20T23:23:26.489483+00:00 app[web.1]: Rendered
static_pages/home.html.erb within layouts/application (2.2ms)
2013-08-20T23:23:26.481456+00:00 app[web.1]: Processing by
StaticPagesController#home as HTML
2013-08-20T23:23:26.496375+00:00 app[web.1]: Rendered
layouts/_header.html.erb (1.3ms)
2013-08-20T23:23:26.494575+00:00 app[web.1]: Rendered
layouts/_shim.html.erb (0.3ms)
2013-08-20T23:23:26.497960+00:00 app[web.1]: Completed 200 OK in 16ms
(Views: 15.8ms | ActiveRecord: 0.0ms)
2013-08-20T23:23:26.497774+00:00 app[web.1]: Rendered
layouts/_footer.html.erb (0.9ms)
2013-08-20T23:23:26.670396+00:00 heroku[router]: at=info method=GET
path=/assets/application-3428e82709d7645135002c8fadfafdc6.js
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=4ms service=20ms status=200 bytes=642
2013-08-20T23:23:26.693364+00:00 heroku[router]: at=info method=GET
path=/assets/application-7270767b2a9e9fff880aa5de378ca791.css
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=26ms status=200 bytes=0
2013-08-20T23:23:26.795663+00:00 heroku[router]: at=info method=GET
path=/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=1ms service=9ms status=200 bytes=6646
2013-08-20T23:23:26.506094+00:00 heroku[router]: at=info method=GET path=/
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=380ms status=304 bytes=0
2013-08-21T00:29:30.830550+00:00 heroku[web.1]: Idling
2013-08-21T00:29:35.491771+00:00 heroku[web.1]: Stopping all processes
with SIGTERM
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `select'
2013-08-21T00:29:36.117015+00:00 app[web.1]: [2013-08-21 00:29:36] FATAL
SignalException: SIGTERM
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in
`start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in `start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:55:in
`block in <top (required)>'
2013-08-21T00:29:36.117176+00:00 app[web.1]: script/rails:6:in `<main>'
2013-08-21T00:29:36.117176+00:00 app[web.1]: [2013-08-21 00:29:36] INFO
going to shutdown ...
2013-08-21T00:29:36.117176+00:00 app[web.1]: [2013-08-21 00:29:36] INFO
WEBrick::HTTPServer#start done.
2013-08-21T00:29:36.117176+00:00 app[web.1]: Exiting
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:268:in
`start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in
start'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/handler/webrick.rb:13:in
`run'
2013-08-21T00:29:36.117176+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:50:in
`<top (required)>'
2013-08-21T00:29:36.117176+00:00 app[web.1]: script/rails:6:in `require'
2013-08-21T00:29:36.117015+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.3/lib/rails/commands.rb:50:in
`tap'
2013-08-21T00:29:37.526666+00:00 heroku[web.1]: State changed from up to down
2013-08-21T00:29:37.523783+00:00 heroku[web.1]: Process exited with status
143
2013-08-21T22:25:21.381126+00:00 heroku[web.1]: Unidling
2013-08-21T22:25:21.381126+00:00 heroku[web.1]: State changed from down to
starting
2013-08-21T22:25:27.384489+00:00 heroku[web.1]: Starting process with
command `bundle exec rails server -p 5284`
2013-08-21T22:25:33.072380+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-08-21T22:25:33.072739+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-08-21T22:25:33.666165+00:00 app[web.1]: SECURITY WARNING: No
secret option provided to Rack::Session::Cookie.
2013-08-21T22:25:33.666165+00:00 app[web.1]: This poses a security
threat. It is strongly recommended that you
2013-08-21T22:25:33.666165+00:00 app[web.1]: provide a secret to
prevent exploits that may be possible from crafted
2013-08-21T22:25:33.666165+00:00 app[web.1]: cookies. This will
not be supported in future versions of Rack, and
2013-08-21T22:25:33.666165+00:00 app[web.1]: future versions will
even invalidate your existing user cookies.
2013-08-21T22:25:33.666165+00:00 app[web.1]: Called from:
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.3/lib/action_dispatch/middleware/session/abstract_store.rb:28:in
`initialize'.
2013-08-21T22:25:33.666165+00:00 app[web.1]:
2013-08-21T22:25:34.000370+00:00 app[web.1]: [2013-08-21 22:25:34] INFO
WEBrick::HTTPServer#start: pid=2 port=5284
2013-08-21T22:25:34.000010+00:00 app[web.1]: [2013-08-21 22:25:33] INFO
WEBrick 1.3.1
2013-08-21T22:25:34.000010+00:00 app[web.1]: [2013-08-21 22:25:33] INFO
ruby 2.0.0 (2013-06-27) [x86_64-linux]
2013-08-21T22:25:34.121184+00:00 heroku[web.1]: State changed from
starting to up
2013-08-21T22:25:35.491396+00:00 app[web.1]: => Rails 3.2.3 application
starting in production on http://0.0.0.0:5284
2013-08-21T22:25:35.491396+00:00 app[web.1]: => Call with -d to detach
2013-08-21T22:25:35.491396+00:00 app[web.1]: => Booting WEBrick
2013-08-21T22:25:35.491396+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-08-21T22:25:35.491396+00:00 app[web.1]:
2013-08-21T22:25:35.491396+00:00 app[web.1]:
2013-08-21T22:25:35.491396+00:00 app[web.1]: Started GET "/" for
69.254.153.186 at 2013-08-21 22:25:35 +0000
2013-08-21T22:25:35.800959+00:00 app[web.1]: Processing by
StaticPagesController#home as HTML
2013-08-21T22:25:35.808774+00:00 app[web.1]: Rendered
static_pages/home.html.erb within layouts/application (2.0ms)
2013-08-21T22:25:35.813736+00:00 app[web.1]: Rendered
layouts/_shim.html.erb (0.3ms)
2013-08-21T22:25:35.815682+00:00 app[web.1]: Rendered
layouts/_header.html.erb (1.3ms)
2013-08-21T22:25:35.817164+00:00 app[web.1]: Rendered
layouts/_footer.html.erb (0.9ms)
2013-08-21T22:25:35.817399+00:00 app[web.1]: Completed 200 OK in 16ms
(Views: 15.7ms | ActiveRecord: 0.0ms)
2013-08-21T22:25:35.821307+00:00 heroku[router]: at=info method=GET path=/
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=345ms status=200 bytes=1862
2013-08-21T22:25:36.462464+00:00 heroku[router]: at=info method=GET
path=/assets/application-3428e82709d7645135002c8fadfafdc6.js
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=7ms status=304 bytes=0
2013-08-21T22:25:36.825347+00:00 heroku[router]: at=info method=GET
path=/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=15ms status=304 bytes=0
2013-08-21T22:25:36.172492+00:00 heroku[router]: at=info method=GET
path=/assets/application-7270767b2a9e9fff880aa5de378ca791.css
host=peaceful-sierra-3634.herokuapp.com fwd="69.254.153.186" dyno=web.1
connect=2ms service=8ms status=304 bytes=0
std::lock_guard segfaults on construction?
std::lock_guard segfaults on construction?
I'm attempting to access a shared std::queue using a std::mutex and a
std::lock_guard. The mutex (pending_md_mtx_) is a member variable of
another object (whose address is valid). My code seems to be segfault'ing
on the construction of the lock_guard.
Any ideas? Should I be using a std::unique_lock (or some other object)
instead? Running GCC 4.6 (--std=c++0x) under Ubuntu Linux.
void enqueue_md(Packet* packet)
{
std::lock_guard<std::mutex> lock(pending_md_mtx_);
pending_md_.push(packet);
}
GDB Stacktrace:
(gdb) bt
#0 __pthread_mutex_lock (mutex=0x2f20aa75e6f4000) at pthread_mutex_lock.c:50
#1 0x000000000041a2dc in __gthread_mutex_lock (__mutex=0xff282ceacb40) at
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:742
#2 lock (this=0xff282ceacb40) at /usr/include/c++/4.6/mutex:90
#3 lock_guard (__m=..., this=0x7f2874fc4db0) at
/usr/include/c++/4.6/mutex:445
#4 driver::Driver<Listener, false>::enqueue_md (this=0xff282ceac8a0,
packet=...) at exec/../../driver/Driver.hpp:95
I'm attempting to access a shared std::queue using a std::mutex and a
std::lock_guard. The mutex (pending_md_mtx_) is a member variable of
another object (whose address is valid). My code seems to be segfault'ing
on the construction of the lock_guard.
Any ideas? Should I be using a std::unique_lock (or some other object)
instead? Running GCC 4.6 (--std=c++0x) under Ubuntu Linux.
void enqueue_md(Packet* packet)
{
std::lock_guard<std::mutex> lock(pending_md_mtx_);
pending_md_.push(packet);
}
GDB Stacktrace:
(gdb) bt
#0 __pthread_mutex_lock (mutex=0x2f20aa75e6f4000) at pthread_mutex_lock.c:50
#1 0x000000000041a2dc in __gthread_mutex_lock (__mutex=0xff282ceacb40) at
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h:742
#2 lock (this=0xff282ceacb40) at /usr/include/c++/4.6/mutex:90
#3 lock_guard (__m=..., this=0x7f2874fc4db0) at
/usr/include/c++/4.6/mutex:445
#4 driver::Driver<Listener, false>::enqueue_md (this=0xff282ceac8a0,
packet=...) at exec/../../driver/Driver.hpp:95