PostId
int64
4
11.8M
PostCreationDate
stringlengths
19
19
OwnerUserId
int64
1
1.57M
OwnerCreationDate
stringlengths
10
19
ReputationAtPostCreation
int64
-55
461k
OwnerUndeletedAnswerCountAtPostTime
int64
0
21.5k
Title
stringlengths
3
250
BodyMarkdown
stringlengths
5
30k
Tag1
stringlengths
1
25
Tag2
stringlengths
1
25
Tag3
stringlengths
1
25
Tag4
stringlengths
1
25
Tag5
stringlengths
1
25
PostClosedDate
stringlengths
19
19
OpenStatus
stringclasses
5 values
unified_texts
stringlengths
32
30.1k
OpenStatus_id
int64
0
4
11,297,795
07/02/2012 16:43:02
1,264,018
03/12/2012 11:50:57
1
1
Why will deleting 2D array in this way fail (C++)?
In the following codes I try to build a 2D array with c++, but when I run this program it fails. #include <iostream> #include <vector> using namespace std; int obtain_options( char ** optionLine) { vector< char*> options; options.push_back("abc"); options.push_back("def"); std::copy(options.begin(), options.end(), const_cast< char**>(optionLine)); return options.size(); } int main(int ac, char* av[]) { char** optionLine; int len; optionLine = new char* [2]; for (int i= 0; i<2; i++) { optionLine[i] = new char [200]; } for (int i=0; i<2; i++) { cout<<optionLine[i]<<endl; } for (int i=0; i<2; i++) delete [] (optionLine[i]); delete []optionLine; return 0; } I understand there are some problems with allocating memory to optionLine in function obtain_options(), and if I change obtain_options() in this way, it will work: int obtain_options( char ** optionLine) { vector< char*> options; char *t1 = new char [100]; t1[0] = 'a'; t1[1] = 'b'; t1[2] = 'c'; t1[3] = '/0'; options.push_back(t1); char *t2 = new char [100]; t2[0] = 'd'; t2[1] = 'e'; t2[2] = 'f'; t2[3] = '/0'; options.push_back(t2); std::copy(options.begin(), options.end(), const_cast< char**>(optionLine)); return options.size(); } My question is if I do not change obtain_options(), how could I delete the 2D array optionLine in a proper way.
c++
null
null
null
null
null
open
Why will deleting 2D array in this way fail (C++)? === In the following codes I try to build a 2D array with c++, but when I run this program it fails. #include <iostream> #include <vector> using namespace std; int obtain_options( char ** optionLine) { vector< char*> options; options.push_back("abc"); options.push_back("def"); std::copy(options.begin(), options.end(), const_cast< char**>(optionLine)); return options.size(); } int main(int ac, char* av[]) { char** optionLine; int len; optionLine = new char* [2]; for (int i= 0; i<2; i++) { optionLine[i] = new char [200]; } for (int i=0; i<2; i++) { cout<<optionLine[i]<<endl; } for (int i=0; i<2; i++) delete [] (optionLine[i]); delete []optionLine; return 0; } I understand there are some problems with allocating memory to optionLine in function obtain_options(), and if I change obtain_options() in this way, it will work: int obtain_options( char ** optionLine) { vector< char*> options; char *t1 = new char [100]; t1[0] = 'a'; t1[1] = 'b'; t1[2] = 'c'; t1[3] = '/0'; options.push_back(t1); char *t2 = new char [100]; t2[0] = 'd'; t2[1] = 'e'; t2[2] = 'f'; t2[3] = '/0'; options.push_back(t2); std::copy(options.begin(), options.end(), const_cast< char**>(optionLine)); return options.size(); } My question is if I do not change obtain_options(), how could I delete the 2D array optionLine in a proper way.
0
11,298,065
07/02/2012 17:02:48
1,117,438
12/27/2011 10:11:40
248
15
accessing codename one resource editor elements
I am trying to quickly create a mock up app using [CODENAME ONE][1] [1]: http://www.codenameone.com I am finding the resource editor difficult to understand. 1) I create a form and place a button on it. 2) I created another form with the message "Hellow World" 3) I add an action event to the button on FORM 1 using the resource editor and netbeans opens up with a method implementing that action. 4)Now I wish to write in that method to some code to display form2 ("Hello World") . How do i do this? Q1) How do i refer the object of form2 in this case? Q2)Also, on the display of form2 , I wish to add a textbox on it. how do i do this using resource editor? My basic question is how can we reference elements created by resource editor via CODE?
lwuit
lwuit-resource-editor
codenameone
null
null
null
open
accessing codename one resource editor elements === I am trying to quickly create a mock up app using [CODENAME ONE][1] [1]: http://www.codenameone.com I am finding the resource editor difficult to understand. 1) I create a form and place a button on it. 2) I created another form with the message "Hellow World" 3) I add an action event to the button on FORM 1 using the resource editor and netbeans opens up with a method implementing that action. 4)Now I wish to write in that method to some code to display form2 ("Hello World") . How do i do this? Q1) How do i refer the object of form2 in this case? Q2)Also, on the display of form2 , I wish to add a textbox on it. how do i do this using resource editor? My basic question is how can we reference elements created by resource editor via CODE?
0
11,298,066
07/02/2012 17:02:55
506,693
11/13/2010 12:18:20
33
4
Is there a way to use symfony2 entity validations as doctrine validations?
I'm developing a Symfony2 application which uses a few forms. The data from the forms is persisted into a MySQL db using Doctrine2. I set up some constraints on the entities using Symfony annotations. Now, when the user fails to enter appropriate data into a form, he get's an error message, but, when I try to manipulate the same entities using a Command object I don't get any exception or error whatsoever. From the documentation I read, Symfony's and Doctrine's validation work as separate mechanisms, now... is there a way to to make them work as one? What I'm trying to avoid is writing the same validations for the entity objects in order to use them as frontend and backend validations. Thanks.
symfony-2.0
doctrine2
null
null
null
null
open
Is there a way to use symfony2 entity validations as doctrine validations? === I'm developing a Symfony2 application which uses a few forms. The data from the forms is persisted into a MySQL db using Doctrine2. I set up some constraints on the entities using Symfony annotations. Now, when the user fails to enter appropriate data into a form, he get's an error message, but, when I try to manipulate the same entities using a Command object I don't get any exception or error whatsoever. From the documentation I read, Symfony's and Doctrine's validation work as separate mechanisms, now... is there a way to to make them work as one? What I'm trying to avoid is writing the same validations for the entity objects in order to use them as frontend and backend validations. Thanks.
0
11,297,941
07/02/2012 16:53:09
351,385
05/26/2010 20:58:59
5,443
283
Is a static readonly value type lifted in a closure?
If I have the following: static readonly TimeSpan ExpiredAfter = TimeSpan.FromMilliseconds(60000); foreach (ModuleInfo info in moduleList.Where(i => DateTime.Now - i.LastPulseTime > ExpiredAfter).ToArray()) moduleList.Remove(info); Does ExpiredAfter get lifted or does the compiler know it can access it directly? Would it be more efficient to write it like this: static readonly TimeSpan ExpiredAfter = TimeSpan.FromMilliseconds(60000); static bool HasExpired(ModuleInfo i) { return DateTime.Now - i.LastPulseTime > ExpiredAfter; } foreach (ModuleInfo info in moduleList.Where(HasExpired).ToArray()) moduleList.Remove(info);
c#
closures
null
null
null
null
open
Is a static readonly value type lifted in a closure? === If I have the following: static readonly TimeSpan ExpiredAfter = TimeSpan.FromMilliseconds(60000); foreach (ModuleInfo info in moduleList.Where(i => DateTime.Now - i.LastPulseTime > ExpiredAfter).ToArray()) moduleList.Remove(info); Does ExpiredAfter get lifted or does the compiler know it can access it directly? Would it be more efficient to write it like this: static readonly TimeSpan ExpiredAfter = TimeSpan.FromMilliseconds(60000); static bool HasExpired(ModuleInfo i) { return DateTime.Now - i.LastPulseTime > ExpiredAfter; } foreach (ModuleInfo info in moduleList.Where(HasExpired).ToArray()) moduleList.Remove(info);
0
11,298,068
07/02/2012 17:03:18
1,255,372
03/07/2012 17:56:52
31
1
Rails AJAX: Neither Success Nor Fail Callback Triggering
I have the following AJAX code embedded in some JavaScript: $.ajax({ type: 'POST', url: '/books', data: {'book[author]':tags[i].book.author, 'book[edition]':tags[i].book.edition, 'book[title]':tags[i].book.title, 'book[url]':newBookUrl}, dataType: 'json', async: false, success: function(data){ mapcode+=" href='javascript:lightbox("+data+")' />"; alert(mapcode); }, fail: function(){mapcode+=" href='' onclick='return false;' />"; alert(mapcode);} }); It's calling on the create method in this model: def create book = Book.new(params[:book]) if (Book.find_by_url(book.url)) book = Book.find_by_url(book.url) else book.save end book.users << current_user render :json => book.url end For some reason, neither the success nor the fail callback are triggering. Otherwise, the AJAX seems to be working. The new data is uploaded to the database, and according to Firebug, I get book.url returned in JSON. Any idea what's happening here?
ruby-on-rails
ajax
null
null
null
null
open
Rails AJAX: Neither Success Nor Fail Callback Triggering === I have the following AJAX code embedded in some JavaScript: $.ajax({ type: 'POST', url: '/books', data: {'book[author]':tags[i].book.author, 'book[edition]':tags[i].book.edition, 'book[title]':tags[i].book.title, 'book[url]':newBookUrl}, dataType: 'json', async: false, success: function(data){ mapcode+=" href='javascript:lightbox("+data+")' />"; alert(mapcode); }, fail: function(){mapcode+=" href='' onclick='return false;' />"; alert(mapcode);} }); It's calling on the create method in this model: def create book = Book.new(params[:book]) if (Book.find_by_url(book.url)) book = Book.find_by_url(book.url) else book.save end book.users << current_user render :json => book.url end For some reason, neither the success nor the fail callback are triggering. Otherwise, the AJAX seems to be working. The new data is uploaded to the database, and according to Firebug, I get book.url returned in JSON. Any idea what's happening here?
0
11,298,069
07/02/2012 17:03:20
1,496,673
07/02/2012 16:55:52
1
0
Should CSS scale be used to create a responsive design?
I'm considering designing my site at the maximum size and then using scale to reduce it's size based on the viewing browser. Basically if I build at 1920x1080 and then you login at 1280x720 I'll scale by .66. I'll obviously use sencha.io to adjust images delivered based on scale down as well. Any thoughts on this approach?
css3
scale
responsive-design
null
null
07/09/2012 18:16:43
not constructive
Should CSS scale be used to create a responsive design? === I'm considering designing my site at the maximum size and then using scale to reduce it's size based on the viewing browser. Basically if I build at 1920x1080 and then you login at 1280x720 I'll scale by .66. I'll obviously use sencha.io to adjust images delivered based on scale down as well. Any thoughts on this approach?
4
11,298,071
07/02/2012 17:03:37
1,456,890
06/14/2012 17:20:30
1
0
Can't get Jdom to work with android 1.6 or 2.1 using Eclipse
I'm trying to install jdom onto Eclipse so that I can use it in my Android project. I'd like it to be Android 1.6 but that hasn't worked, I've also been trying to get it to work on android 2.1 and that still hasn't worked. I've downloaded jdom 2.0.2 and I've put the .jar file into the build library and yet still import org.jdom.Document; or any import org.jdom doesn't work. Does anyone know what to do, and if not is there any other xml parser where you don't need to know the tag/element names before it parses them?
android
xml
eclipse
install
jdom
null
open
Can't get Jdom to work with android 1.6 or 2.1 using Eclipse === I'm trying to install jdom onto Eclipse so that I can use it in my Android project. I'd like it to be Android 1.6 but that hasn't worked, I've also been trying to get it to work on android 2.1 and that still hasn't worked. I've downloaded jdom 2.0.2 and I've put the .jar file into the build library and yet still import org.jdom.Document; or any import org.jdom doesn't work. Does anyone know what to do, and if not is there any other xml parser where you don't need to know the tag/element names before it parses them?
0
11,298,072
07/02/2012 17:04:01
1,494,560
07/01/2012 17:32:22
7
0
Transfer data from ashx to aspx. Make asp image control identify which image to show - asp.net c#
page.aspx.cs code: HttpContext.Current.Session["id1"] = id1.ToString(); Server.Transfer("Handler.ashx"); //Getting error Image1.ImageUrl = "~/Handler.ashx?ID=" + id1.ToString(); HttpContext.Current.Session["id2"] = id2.ToString(); Server.Transfer("Handler.ashx"); //Getting error Image2.ImageUrl = "~/Handler.ashx?ID=" + id2.ToString(); Handler.ashx code: public void ProcessRequest(HttpContext context) { int id = Convert.ToInt32(context.Session["id1"]); byte[] IMG = class.ReadImg(id); context.Response.ContentType = "image/jpg"; context.Response.BinaryWrite(IMG); } public void ProcessRequest2(HttpContext context2) { int id = Convert.ToInt32(context2.Session["id2"]); byte[] IMG2 = class.ReadImg(id); context2.Response.ContentType = "image/jpg"; context2.Response.BinaryWrite(IMG2); } page.aspx code: <asp:Image ID="Image1" runat="server" />//How to define thats gonna show image of id1 <asp:Image ID="Image2" runat="server" />//How to define thats gonna show image of id2 **Question:** 1- I'm not able to transfer data from page.aspx to Handler.ashx 2- I dont know how to make asp-image-control to identify which image it should show according to the id (maybe something with request.queryString that i dont understand) Help!! Thanks :]
c#
asp.net
image
handler
null
null
open
Transfer data from ashx to aspx. Make asp image control identify which image to show - asp.net c# === page.aspx.cs code: HttpContext.Current.Session["id1"] = id1.ToString(); Server.Transfer("Handler.ashx"); //Getting error Image1.ImageUrl = "~/Handler.ashx?ID=" + id1.ToString(); HttpContext.Current.Session["id2"] = id2.ToString(); Server.Transfer("Handler.ashx"); //Getting error Image2.ImageUrl = "~/Handler.ashx?ID=" + id2.ToString(); Handler.ashx code: public void ProcessRequest(HttpContext context) { int id = Convert.ToInt32(context.Session["id1"]); byte[] IMG = class.ReadImg(id); context.Response.ContentType = "image/jpg"; context.Response.BinaryWrite(IMG); } public void ProcessRequest2(HttpContext context2) { int id = Convert.ToInt32(context2.Session["id2"]); byte[] IMG2 = class.ReadImg(id); context2.Response.ContentType = "image/jpg"; context2.Response.BinaryWrite(IMG2); } page.aspx code: <asp:Image ID="Image1" runat="server" />//How to define thats gonna show image of id1 <asp:Image ID="Image2" runat="server" />//How to define thats gonna show image of id2 **Question:** 1- I'm not able to transfer data from page.aspx to Handler.ashx 2- I dont know how to make asp-image-control to identify which image it should show according to the id (maybe something with request.queryString that i dont understand) Help!! Thanks :]
0
11,298,074
07/02/2012 17:04:12
1,231,844
02/24/2012 23:18:39
190
14
Check various CoreData objects
I think the easiest way to do this would be to fetch all the objects of the desired entity and then check for the attribute I need. My question is: How to I fetch the data and store it in an `NSArray`?
cocoa-touch
core-data
null
null
null
null
open
Check various CoreData objects === I think the easiest way to do this would be to fetch all the objects of the desired entity and then check for the attribute I need. My question is: How to I fetch the data and store it in an `NSArray`?
0
11,298,079
07/02/2012 17:04:37
1,169,578
01/25/2012 15:55:07
563
32
what to do with long queries with parameters in .net web apps
Suppose you have a long, complicated query to pull needed results that takes some parameters. Any will do, but for the sake of an example: SELECT q.PROD_ID, q.NAME, q.STANDARD_PROD, q.DESCRIPTION, q.PART_NUMBER, q.COMMENTS, q.DESCRIPTION_URL, PROD_CATEGORY.DESCRIPTION AS CATEGORY_DESCRIPTION, PROD_TYPES.DESCRIPTION AS PROD_TYPE FROM (SELECT PROD.PROD_ID, PROD.PROD_TYPE_ID, PROD.NAME, PROD.STANDARD_PROD, PROD.PROD_CATEGORY_ID, PROD.DESCRIPTION, PROD.PART_NUMBER, PROD.COMMENTS, PROD.DESCRIPTION_URL FROM (SELECT PROD_ID, PROD_TYPE_ID FROM XREF_PRODSYS WHERE (PROD_TYPE_ID = (SELECT PROD_TYPE_ID FROM PROD_TYPES WHERE (NAME LIKE @prod_type_name)))) AS p LEFT OUTER JOIN PROD ON p.PROD_ID = PROD.PROD_ID WHERE (PROD.NAME LIKE @prod_name) AND (PROD.HIDDEN = 0)) AS q LEFT OUTER JOIN PROD_CATEGORY ON q.PROD_CATEGORY_ID = PROD_CATEGORY.PROD_CATEGORY_ID LEFT OUTER JOIN PROD_TYPES ON q.PROD_TYPE_ID = PROD_TYPES.PROD_TYPE_ID This particular query takes two parameters, presumably passed to the .NET web app through GET/POST. Is there a cleaner way to store such a long query, rather than putting it in the C# source of the webapp page? I know the below "quick and dirty" approach works fine, but it does make the code expand a lot and become a bit unmanageable. For example: //inside Page_Load... SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Parameters.Add("@prod_type_name", SqlDbType.VarChar).Value = _type_name; cmd.Parameters.Add("@prod_name", SqlDbType.VarChar).Value = _prod_name; cmd.CommandText = @" SELECT q.PROD_ID, q.NAME, q.STANDARD_PROD, q.DESCRIPTION, q.PART_NUMBER, q.COMMENTS, q.DESCRIPTION_URL, PROD_CATEGORY.DESCRIPTION AS CATEGORY_DESCRIPTION, PROD_TYPES.DESCRIPTION AS PROD_TYPE FROM (SELECT PROD.PROD_ID, PROD.PROD_TYPE_ID, PROD.NAME, PROD.STANDARD_PROD, PROD.PROD_CATEGORY_ID, PROD.DESCRIPTION, PROD.PART_NUMBER, PROD.COMMENTS, PROD.DESCRIPTION_URL FROM (SELECT PROD_ID, PROD_TYPE_ID FROM XREF_PRODSYS WHERE (PROD_TYPE_ID = (SELECT PROD_TYPE_ID FROM PROD_TYPES WHERE (NAME LIKE @prod_type_name)))) AS p LEFT OUTER JOIN PROD ON p.PROD_ID = PROD.PROD_ID WHERE (PROD.NAME LIKE @prod_name) AND (PROD.HIDDEN = 0)) AS q LEFT OUTER JOIN PROD_CATEGORY ON q.PROD_CATEGORY_ID = PROD_CATEGORY.PROD_CATEGORY_ID LEFT OUTER JOIN PROD_TYPES ON q.PROD_TYPE_ID = PROD_TYPES.PROD_TYPE_ID "; //... do stuff with cmd
c#
web-applications
.net-4.0
sql-server-2008-r2
iis-7.5
null
open
what to do with long queries with parameters in .net web apps === Suppose you have a long, complicated query to pull needed results that takes some parameters. Any will do, but for the sake of an example: SELECT q.PROD_ID, q.NAME, q.STANDARD_PROD, q.DESCRIPTION, q.PART_NUMBER, q.COMMENTS, q.DESCRIPTION_URL, PROD_CATEGORY.DESCRIPTION AS CATEGORY_DESCRIPTION, PROD_TYPES.DESCRIPTION AS PROD_TYPE FROM (SELECT PROD.PROD_ID, PROD.PROD_TYPE_ID, PROD.NAME, PROD.STANDARD_PROD, PROD.PROD_CATEGORY_ID, PROD.DESCRIPTION, PROD.PART_NUMBER, PROD.COMMENTS, PROD.DESCRIPTION_URL FROM (SELECT PROD_ID, PROD_TYPE_ID FROM XREF_PRODSYS WHERE (PROD_TYPE_ID = (SELECT PROD_TYPE_ID FROM PROD_TYPES WHERE (NAME LIKE @prod_type_name)))) AS p LEFT OUTER JOIN PROD ON p.PROD_ID = PROD.PROD_ID WHERE (PROD.NAME LIKE @prod_name) AND (PROD.HIDDEN = 0)) AS q LEFT OUTER JOIN PROD_CATEGORY ON q.PROD_CATEGORY_ID = PROD_CATEGORY.PROD_CATEGORY_ID LEFT OUTER JOIN PROD_TYPES ON q.PROD_TYPE_ID = PROD_TYPES.PROD_TYPE_ID This particular query takes two parameters, presumably passed to the .NET web app through GET/POST. Is there a cleaner way to store such a long query, rather than putting it in the C# source of the webapp page? I know the below "quick and dirty" approach works fine, but it does make the code expand a lot and become a bit unmanageable. For example: //inside Page_Load... SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Parameters.Add("@prod_type_name", SqlDbType.VarChar).Value = _type_name; cmd.Parameters.Add("@prod_name", SqlDbType.VarChar).Value = _prod_name; cmd.CommandText = @" SELECT q.PROD_ID, q.NAME, q.STANDARD_PROD, q.DESCRIPTION, q.PART_NUMBER, q.COMMENTS, q.DESCRIPTION_URL, PROD_CATEGORY.DESCRIPTION AS CATEGORY_DESCRIPTION, PROD_TYPES.DESCRIPTION AS PROD_TYPE FROM (SELECT PROD.PROD_ID, PROD.PROD_TYPE_ID, PROD.NAME, PROD.STANDARD_PROD, PROD.PROD_CATEGORY_ID, PROD.DESCRIPTION, PROD.PART_NUMBER, PROD.COMMENTS, PROD.DESCRIPTION_URL FROM (SELECT PROD_ID, PROD_TYPE_ID FROM XREF_PRODSYS WHERE (PROD_TYPE_ID = (SELECT PROD_TYPE_ID FROM PROD_TYPES WHERE (NAME LIKE @prod_type_name)))) AS p LEFT OUTER JOIN PROD ON p.PROD_ID = PROD.PROD_ID WHERE (PROD.NAME LIKE @prod_name) AND (PROD.HIDDEN = 0)) AS q LEFT OUTER JOIN PROD_CATEGORY ON q.PROD_CATEGORY_ID = PROD_CATEGORY.PROD_CATEGORY_ID LEFT OUTER JOIN PROD_TYPES ON q.PROD_TYPE_ID = PROD_TYPES.PROD_TYPE_ID "; //... do stuff with cmd
0
11,298,080
07/02/2012 17:04:51
1,469,540
06/20/2012 14:20:49
163
9
Java: Best way to work with Locales in Swing (with change at Runntime)?
I thought about the best way to implement localisation with runtime in Swing. Currently I solve the problem like that: JMenu menuData = new JMenu("Data"); menuData.setName("mainframe.menu.data"); // property key localeChangedListener.add(menuData); The LocaleChangedListener: public class SwingLocaleChangedListener implements LocaleChangedListener { private ArrayList<AbstractButton> abstractButtons; @Override public void localeChanged(ResourceBundle rb) { logger.info("Locale changed to '" + rb.getLocale() + "'"); for (AbstractButton b : abstractButtons) { b.setText(rb.getString(b.getName())); } } public boolean add(AbstractButton b) { initAbstractButtons(); return abstractButtons.add(b); } private void initAbstractButtons() { if (abstractButtons == null) { this.abstractButtons = new ArrayList<AbstractButton>(); } } } And the registration of the Listener: public class GuiBundleManager { private String filePrefix = "language.lang"; private ResourceBundle rb = null; private LocaleChangedListener listener = null; private static GuiBundleManager instance = null; private GuiBundleManager() { setLocale(Locale.getDefault()); } public String getString(String key) { return rb.getString(key); } public String[] getStringArray(String key) { return rb.getStringArray(key); } public Locale getLocale() { return rb.getLocale(); } public void setLocale(Locale l) { rb = ResourceBundle.getBundle(filePrefix, l); if (listener != null) { listener.localeChanged(rb); } } public LocaleChangedListener getLocaleChangedListener() { return listener; } public void setLocaleChangedListener(LocaleChangedListener listener) { this.listener = listener; if (listener != null) { listener.localeChanged(rb); } } public static GuiBundleManager get() { if (instance == null) { instance = new GuiBundleManager(); } return instance; } } . . An other way I'm thinking of is using Component.setLocale() combined with an PropertyChangedListener: public abstract class GUIComponentFactory { public JLabel createLocalisedJLabel(final String key) { final JLabel label = new JLabel(GuiBundleManager.get().getString(key)); label.addPropertyChangeListener("locale", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { label.setText(GuiBundleManager.get().getString(key)); for(Component c : getComponents()){ c.setLocale(e.getNewValue()); } } }); return label; } . . . } Maybe you have a better solution
java
swing
locale
null
null
07/04/2012 11:54:12
off topic
Java: Best way to work with Locales in Swing (with change at Runntime)? === I thought about the best way to implement localisation with runtime in Swing. Currently I solve the problem like that: JMenu menuData = new JMenu("Data"); menuData.setName("mainframe.menu.data"); // property key localeChangedListener.add(menuData); The LocaleChangedListener: public class SwingLocaleChangedListener implements LocaleChangedListener { private ArrayList<AbstractButton> abstractButtons; @Override public void localeChanged(ResourceBundle rb) { logger.info("Locale changed to '" + rb.getLocale() + "'"); for (AbstractButton b : abstractButtons) { b.setText(rb.getString(b.getName())); } } public boolean add(AbstractButton b) { initAbstractButtons(); return abstractButtons.add(b); } private void initAbstractButtons() { if (abstractButtons == null) { this.abstractButtons = new ArrayList<AbstractButton>(); } } } And the registration of the Listener: public class GuiBundleManager { private String filePrefix = "language.lang"; private ResourceBundle rb = null; private LocaleChangedListener listener = null; private static GuiBundleManager instance = null; private GuiBundleManager() { setLocale(Locale.getDefault()); } public String getString(String key) { return rb.getString(key); } public String[] getStringArray(String key) { return rb.getStringArray(key); } public Locale getLocale() { return rb.getLocale(); } public void setLocale(Locale l) { rb = ResourceBundle.getBundle(filePrefix, l); if (listener != null) { listener.localeChanged(rb); } } public LocaleChangedListener getLocaleChangedListener() { return listener; } public void setLocaleChangedListener(LocaleChangedListener listener) { this.listener = listener; if (listener != null) { listener.localeChanged(rb); } } public static GuiBundleManager get() { if (instance == null) { instance = new GuiBundleManager(); } return instance; } } . . An other way I'm thinking of is using Component.setLocale() combined with an PropertyChangedListener: public abstract class GUIComponentFactory { public JLabel createLocalisedJLabel(final String key) { final JLabel label = new JLabel(GuiBundleManager.get().getString(key)); label.addPropertyChangeListener("locale", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { label.setText(GuiBundleManager.get().getString(key)); for(Component c : getComponents()){ c.setLocale(e.getNewValue()); } } }); return label; } . . . } Maybe you have a better solution
2
11,280,253
07/01/2012 07:23:01
1,493,951
07/01/2012 06:47:08
1
0
JAVA: Cannot call another class
I'm making a Java program that can solve the roots using the quadratic equation by giving a, b, and c. Here is the main code: //main file class Call { public static void main(String args []) { double a=Double.parseDouble(args[0]); double b=Double.parseDouble(args[1]); double c=Double.parseDouble(args[3]); Receiver r = new Receiver("."); if (r.determine(a,b,c)=true) { double root1=r.Root; double root2=r.Root2; System.out.println("The first root is +root1"); System.out.println("The second root is +root2"); } else { System.out.println("Not a number"); } } } Now here's the class I'm trying to call but couldn't. class Receiver { public boolean determine(double a, double b, double c) { double value=b*b-4*a*c; if (value<0) return false; else return true; } public double Root(double a, double b, double c) { double value=b*b-4*a*c; double root=(-b+ Math.sqrt(value))/(2*a); return root; } public double Root2(double a, double b, double c) { double value=b*b-4*a*c; double root2=(-b- Math.sqrt(value))/(2*a); return root2; } } I made sure that I compiled the Receiver.java already. But when I compile Call.java, I get this error: Call.java:14:error:cannot find symbol Receiver r= new Receiver(); symbol: class Receiver location: class Call
java
class
compilation
call
null
null
open
JAVA: Cannot call another class === I'm making a Java program that can solve the roots using the quadratic equation by giving a, b, and c. Here is the main code: //main file class Call { public static void main(String args []) { double a=Double.parseDouble(args[0]); double b=Double.parseDouble(args[1]); double c=Double.parseDouble(args[3]); Receiver r = new Receiver("."); if (r.determine(a,b,c)=true) { double root1=r.Root; double root2=r.Root2; System.out.println("The first root is +root1"); System.out.println("The second root is +root2"); } else { System.out.println("Not a number"); } } } Now here's the class I'm trying to call but couldn't. class Receiver { public boolean determine(double a, double b, double c) { double value=b*b-4*a*c; if (value<0) return false; else return true; } public double Root(double a, double b, double c) { double value=b*b-4*a*c; double root=(-b+ Math.sqrt(value))/(2*a); return root; } public double Root2(double a, double b, double c) { double value=b*b-4*a*c; double root2=(-b- Math.sqrt(value))/(2*a); return root2; } } I made sure that I compiled the Receiver.java already. But when I compile Call.java, I get this error: Call.java:14:error:cannot find symbol Receiver r= new Receiver(); symbol: class Receiver location: class Call
0
11,280,254
07/01/2012 07:23:23
1,158,379
01/19/2012 11:44:41
73
10
Strange behaviour when get current month in C#
This is small code. But I couldn't find whats wrong with it. In my application I want to get the current month in long month format(ex:January). I used the following two lines of code. DateTime now = DateTime.Now; string month = now.Month.ToString("MMMM",CultureInfo.CurrentCulture); but its return "MMMM" for the values of month. Can anybody tell me whats wrong in this code.
c#
c#-3.0
datetime-format
null
null
null
open
Strange behaviour when get current month in C# === This is small code. But I couldn't find whats wrong with it. In my application I want to get the current month in long month format(ex:January). I used the following two lines of code. DateTime now = DateTime.Now; string month = now.Month.ToString("MMMM",CultureInfo.CurrentCulture); but its return "MMMM" for the values of month. Can anybody tell me whats wrong in this code.
0
11,280,256
07/01/2012 07:24:06
777,273
05/31/2011 07:53:59
38
1
How to use XmlTextWriter to write a object into XML?
I generated a Class with a XML Schema (.xsd) using the Visual Studio xsd tool. Now I have the class and I want to output that object back into XML as defined by my xsd. I am wondering how to do that. Thank you!
c#
.net
xml
xsd
xmltextwriter
null
open
How to use XmlTextWriter to write a object into XML? === I generated a Class with a XML Schema (.xsd) using the Visual Studio xsd tool. Now I have the class and I want to output that object back into XML as defined by my xsd. I am wondering how to do that. Thank you!
0
11,280,261
07/01/2012 07:24:53
1,386,369
05/10/2012 06:58:23
53
2
How to switch the point to previous line after a } was input?
I am working with emacs24 with cc-mode, I want to know how to make my emacs more "clever". After I type a }, it will auto insert a new line and indent as excepted. I want to know how to switch the point to previous line. For example, when i define a function, Now my emacs behavior is: void f() { } //point "//point" is the position of cursor after } was input. But i want is this: void f() { //point } I hope the position of cursor can switch to previous line and indent automatically. I know emacs can do this, but I don't know how to do it, who can help me?
emacs
elisp
cc-mode
null
null
null
open
How to switch the point to previous line after a } was input? === I am working with emacs24 with cc-mode, I want to know how to make my emacs more "clever". After I type a }, it will auto insert a new line and indent as excepted. I want to know how to switch the point to previous line. For example, when i define a function, Now my emacs behavior is: void f() { } //point "//point" is the position of cursor after } was input. But i want is this: void f() { //point } I hope the position of cursor can switch to previous line and indent automatically. I know emacs can do this, but I don't know how to do it, who can help me?
0
11,280,263
07/01/2012 07:25:04
1,227,166
02/23/2012 00:06:14
17
1
C C++ - Visual Studio 2010 doesn't indent C code
Does anyone knows why Visual Studio 2010 does not indent C code and how may I make it indent automatically, i.e. while I type (I already know the keyboard shortcuts) the C code? Thanks!
c
visual-studio-2010
indent
null
null
null
open
C C++ - Visual Studio 2010 doesn't indent C code === Does anyone knows why Visual Studio 2010 does not indent C code and how may I make it indent automatically, i.e. while I type (I already know the keyboard shortcuts) the C code? Thanks!
0
11,280,265
07/01/2012 07:25:56
1,492,155
12/04/2011 22:16:02
1
0
delay time for the menu items to display its subitems
At the moment, my site displays the menu items horizontally and when the user hover over each one, its submenuitems are displayed. However, by the time the user tries to click on the subitem, they disappear. Is there any way I could delay the time in which the subitems are visible? Thank you
html
css
menu
drop
null
null
open
delay time for the menu items to display its subitems === At the moment, my site displays the menu items horizontally and when the user hover over each one, its submenuitems are displayed. However, by the time the user tries to click on the subitem, they disappear. Is there any way I could delay the time in which the subitems are visible? Thank you
0
11,280,267
07/01/2012 07:26:22
1,184,095
02/02/2012 01:54:49
6
0
create dynamically created columns from a table in mysql
i would like to create virtual columns that are dynamic where the values are being generated based on a join table. i have the following table called types: id, name 1, TypeA 2, TypeB and i have a table called category id, name, type 1, a, 1 2, b, 2 i would like to have a query that returns the following category name, TypeA, TypeB a, 1, 0 b, 0, 1 is this possible to do in mysql?
mysql
null
null
null
null
null
open
create dynamically created columns from a table in mysql === i would like to create virtual columns that are dynamic where the values are being generated based on a join table. i have the following table called types: id, name 1, TypeA 2, TypeB and i have a table called category id, name, type 1, a, 1 2, b, 2 i would like to have a query that returns the following category name, TypeA, TypeB a, 1, 0 b, 0, 1 is this possible to do in mysql?
0
11,280,270
07/01/2012 07:26:44
846,351
07/15/2011 11:20:02
505
14
Creating ViewModels WIth Common Properties with OnPropertyChanged?
I relised I have lots of models view models with those two properties public Visibility OkButtonVisibility { get{ return _OkButtonVisibility;} set{ _OkButtonVisibility = value; RaisePropertyChanged("OkButtonVisibility"); } } public Visibility CancelButtonVisibility { get{ return _CancelButtonVisibility;} set{ _CancelButtonVisibility = value; RaisePropertyChanged("CancelButtonVisibility"); } } I wanted to create attachable interface for them like this: Interface IOKandCancelButtonsVM { public Visibility OkButtonVisibility { get{ return _OkButtonVisibility;} set{ _OkButtonVisibility = value; RaisePropertyChanged("OkButtonVisibility"); } } public Visibility CancelButtonVisibility { get{ return _CancelButtonVisibility;} set{ _CancelButtonVisibility = value; RaisePropertyChanged("CancelButtonVisibility"); } } and have my viewmodels that use this to inherite them and another interfaces with proxy properties like this class VM1:BaseVM,IOKandCancelButtonsVM,IOtherCommonPropertyVM { } but then I relaised my new interfaces don't impliment `INotifyChanged`. would it be a bad idea to have`IOKandCancelButtonsVM` impliment `BaseVM` and have `VM1` explicitly impliment `BaseVM`? I never dealt with class inheriting same interface twice and not sure what to do.
c#
wpf
design-patterns
mvvm
null
null
open
Creating ViewModels WIth Common Properties with OnPropertyChanged? === I relised I have lots of models view models with those two properties public Visibility OkButtonVisibility { get{ return _OkButtonVisibility;} set{ _OkButtonVisibility = value; RaisePropertyChanged("OkButtonVisibility"); } } public Visibility CancelButtonVisibility { get{ return _CancelButtonVisibility;} set{ _CancelButtonVisibility = value; RaisePropertyChanged("CancelButtonVisibility"); } } I wanted to create attachable interface for them like this: Interface IOKandCancelButtonsVM { public Visibility OkButtonVisibility { get{ return _OkButtonVisibility;} set{ _OkButtonVisibility = value; RaisePropertyChanged("OkButtonVisibility"); } } public Visibility CancelButtonVisibility { get{ return _CancelButtonVisibility;} set{ _CancelButtonVisibility = value; RaisePropertyChanged("CancelButtonVisibility"); } } and have my viewmodels that use this to inherite them and another interfaces with proxy properties like this class VM1:BaseVM,IOKandCancelButtonsVM,IOtherCommonPropertyVM { } but then I relaised my new interfaces don't impliment `INotifyChanged`. would it be a bad idea to have`IOKandCancelButtonsVM` impliment `BaseVM` and have `VM1` explicitly impliment `BaseVM`? I never dealt with class inheriting same interface twice and not sure what to do.
0
11,349,370
07/05/2012 17:23:08
845,746
07/15/2011 03:17:29
5
0
Importing Excel into DataGridView
I'm making a program where two databases are merged together.... I can import an excel spreadsheet into a DataGridView with this code: string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.xls;Extended Properties=""Excel 8.0;HDR=YES;IMEX=1"""; DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb"); DbDataAdapter adapter = factory.CreateDataAdapter(); DbCommand selectCommand = factory.CreateCommand(); selectCommand.CommandText = "SELECT * FROM [All Carpets to Excel$]"; DbConnection connection = factory.CreateConnection(); connection.ConnectionString = connectionString; selectCommand.Connection = connection; adapter.SelectCommand = selectCommand; data = new DataSet(); adapter.Fill(data); dataGridView1.DataSource = data.Tables[0].DefaultView; The problem I'm having is that I'm trying to find a way to change the source file to path that is returned by a dialog box. I have a string file that contains the file path. How do I incorporate this into the connection string? Or maybe there is an altogether better way to do this? Thanks! Luke
c#
excel
datagridview
dialog
connection-string
null
open
Importing Excel into DataGridView === I'm making a program where two databases are merged together.... I can import an excel spreadsheet into a DataGridView with this code: string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.xls;Extended Properties=""Excel 8.0;HDR=YES;IMEX=1"""; DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb"); DbDataAdapter adapter = factory.CreateDataAdapter(); DbCommand selectCommand = factory.CreateCommand(); selectCommand.CommandText = "SELECT * FROM [All Carpets to Excel$]"; DbConnection connection = factory.CreateConnection(); connection.ConnectionString = connectionString; selectCommand.Connection = connection; adapter.SelectCommand = selectCommand; data = new DataSet(); adapter.Fill(data); dataGridView1.DataSource = data.Tables[0].DefaultView; The problem I'm having is that I'm trying to find a way to change the source file to path that is returned by a dialog box. I have a string file that contains the file path. How do I incorporate this into the connection string? Or maybe there is an altogether better way to do this? Thanks! Luke
0
11,349,371
07/05/2012 17:23:09
1,381,251
05/08/2012 05:33:22
7
0
MongoDB / Node.JS: Get attribute value from document
I have a document: { "_id":ObjectId("someID") "email":"[email protected]" } I would like to retrieve "[email protected]" so that I can pass this value to the browser. How do I do that? I saw these SO posts, but I don't understand the solution at all:<br> http://stackoverflow.com/questions/8033366/how-to-get-string-value-inside-a-mongodb-document?rq=1 <br> http://stackoverflow.com/questions/8030578/how-to-get-value-from-a-mongodb-document?rq=1
node.js
mongodb
null
null
null
null
open
MongoDB / Node.JS: Get attribute value from document === I have a document: { "_id":ObjectId("someID") "email":"[email protected]" } I would like to retrieve "[email protected]" so that I can pass this value to the browser. How do I do that? I saw these SO posts, but I don't understand the solution at all:<br> http://stackoverflow.com/questions/8033366/how-to-get-string-value-inside-a-mongodb-document?rq=1 <br> http://stackoverflow.com/questions/8030578/how-to-get-value-from-a-mongodb-document?rq=1
0
11,349,373
07/05/2012 17:23:20
961,913
09/23/2011 20:19:39
162
5
JQuery set width of table TH
Im using telerik mvc grid with custom row templete. So since im done with my row template i have problem with th`s width. Looks like its bug or something dont work..cant set width properly so i cant to make simple document ready function to set width of each th. function SetWidth(){ var ths = $('th'); var element = ths[0]; element.width(100); } Then ill manually set 0 = 100, 1 = 110, 2 = 300 px and so on. But when i try to add width of 'element' , it gives me error. Uncaught TypeError: Property 'width' of object #<HTMLTableCellElement> is not a function Whats the problem?
jquery
jquery-selectors
telerik
null
null
null
open
JQuery set width of table TH === Im using telerik mvc grid with custom row templete. So since im done with my row template i have problem with th`s width. Looks like its bug or something dont work..cant set width properly so i cant to make simple document ready function to set width of each th. function SetWidth(){ var ths = $('th'); var element = ths[0]; element.width(100); } Then ill manually set 0 = 100, 1 = 110, 2 = 300 px and so on. But when i try to add width of 'element' , it gives me error. Uncaught TypeError: Property 'width' of object #<HTMLTableCellElement> is not a function Whats the problem?
0
11,349,377
07/05/2012 17:23:49
1,493,927
07/01/2012 06:22:36
28
0
creating table through XML file in mysql and in oracle
I have a query , suppose let say I have an xml which contains the data for a table , Now is there any way in oracle amd my sql , for example if I want that table to be get created in a database in my sql and in oracle also ..that I some how i can import that XML file and that table get created in database, Please advise
java
mysql
oracle
null
null
null
open
creating table through XML file in mysql and in oracle === I have a query , suppose let say I have an xml which contains the data for a table , Now is there any way in oracle amd my sql , for example if I want that table to be get created in a database in my sql and in oracle also ..that I some how i can import that XML file and that table get created in database, Please advise
0
11,349,378
07/05/2012 17:23:51
1,338,823
04/17/2012 12:59:14
1
0
Merged two images --> 4 times the size! How do I reduce the file size?
I merge two images using the code below. One base image without transparency, one overlay image with transparency. The file-size of the images one there own is 20kb and 5kb, respectively. Once I merged the two images, the resulting file-size is > 100kb, thus at least 4 times the combined size of 25kb. I expected a file-size less than 25kb. public static void mergeTwoImages(BufferedImage base, BufferedImage overlay, String destPath, String imageName) { // create the new image, canvas size is the max. of both image sizes int w = Math.max(base.getWidth(), overlay.getWidth()); int h = Math.max(base.getHeight(), overlay.getHeight()); BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); // paint both images, preserving the alpha channels Graphics2D g2 = combined.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.drawImage(base, 0, 0, null ); g2.drawImage(overlay, 0, 0, null); g2.dispose(); // Save as new image saveImage(combined, destPath + "/" + imageName + "_merged.png"); } My application has to be with very good performance, thus can anyone explain me why this effect happens and how I can reduce the resulting file size? Thanks a lot!
java
image-processing
graphics
merge
bufferedimage
null
open
Merged two images --> 4 times the size! How do I reduce the file size? === I merge two images using the code below. One base image without transparency, one overlay image with transparency. The file-size of the images one there own is 20kb and 5kb, respectively. Once I merged the two images, the resulting file-size is > 100kb, thus at least 4 times the combined size of 25kb. I expected a file-size less than 25kb. public static void mergeTwoImages(BufferedImage base, BufferedImage overlay, String destPath, String imageName) { // create the new image, canvas size is the max. of both image sizes int w = Math.max(base.getWidth(), overlay.getWidth()); int h = Math.max(base.getHeight(), overlay.getHeight()); BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); // paint both images, preserving the alpha channels Graphics2D g2 = combined.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.drawImage(base, 0, 0, null ); g2.drawImage(overlay, 0, 0, null); g2.dispose(); // Save as new image saveImage(combined, destPath + "/" + imageName + "_merged.png"); } My application has to be with very good performance, thus can anyone explain me why this effect happens and how I can reduce the resulting file size? Thanks a lot!
0
11,349,380
07/05/2012 17:23:59
796,997
06/14/2011 04:17:17
143
4
Complex LINQ Statement C# / MVC3
Ok so I have not done much LINQ and would like assistance either with the correct statement or a good tutorial on how to build the correct statement. Also, could you tell me if using LINQ is even the best practice for this. I have noticed my controller action have been looking quite untidy since I have been using the LINQ queries. Would it be better to use SQL stored procedures or something. I don't have much experience with Stored Procedures either so if that's the case I'd appreciate a good reference. I have 2 tables - Bids, Moves If a person creates a Move then I would like for them to be able to see Bids associated with that Move. Right now here is the logic I am using so the User can only see their Move. FYI - I have started to integrate in Bids but unsuccessfully so please either build on existing attempt at getting bids. public ActionResult Index() { if (User.Identity.IsAuthenticated) { MembershipUser currentUser = Membership.GetUser(); Guid currentUserId = (Guid)currentUser.ProviderUserKey; if (currentUser != null && currentUser.ProviderUserKey != null && currentUser.IsApproved) { var viewModel = new HomePagingViewModel { Moves = moveRepo.Moves.Where(m => m.UserId == currentUserId) .OrderByDescending(m => m.MoveId) .Take(MovePageSize), ClientMovePagingInfo = new PagingInfo { CurrentPage = 1, ItemsPerPage = MovePageSize, TotalItems = moveRepo.Moves.Count() }, Bids = bidRepo.Bids.Where(b => b.UserId == currentUserId) .OrderByDescending(b => b.BidId) }; return View(viewModel); } } return View(db.Moves.ToList()); } public ActionResult Moves(int page = 1) { if (User.Identity.IsAuthenticated) { MembershipUser currentUser = Membership.GetUser(); Guid currentUserId = (Guid)currentUser.ProviderUserKey; if (currentUser != null && currentUser.ProviderUserKey != null && currentUser.IsApproved) { var moves = db.Moves.Where(move => move.UserId == currentUserId) .OrderByDescending(m => m.MoveId) .Skip((page - 1) * MovePageSize) .Take(MovePageSize); if (Request.IsAjaxRequest()) { return PartialView("_Moves", moves); } } } return View(db.Moves.ToList()); }
c#
asp.net-mvc-3
linq
null
null
07/05/2012 18:07:42
not a real question
Complex LINQ Statement C# / MVC3 === Ok so I have not done much LINQ and would like assistance either with the correct statement or a good tutorial on how to build the correct statement. Also, could you tell me if using LINQ is even the best practice for this. I have noticed my controller action have been looking quite untidy since I have been using the LINQ queries. Would it be better to use SQL stored procedures or something. I don't have much experience with Stored Procedures either so if that's the case I'd appreciate a good reference. I have 2 tables - Bids, Moves If a person creates a Move then I would like for them to be able to see Bids associated with that Move. Right now here is the logic I am using so the User can only see their Move. FYI - I have started to integrate in Bids but unsuccessfully so please either build on existing attempt at getting bids. public ActionResult Index() { if (User.Identity.IsAuthenticated) { MembershipUser currentUser = Membership.GetUser(); Guid currentUserId = (Guid)currentUser.ProviderUserKey; if (currentUser != null && currentUser.ProviderUserKey != null && currentUser.IsApproved) { var viewModel = new HomePagingViewModel { Moves = moveRepo.Moves.Where(m => m.UserId == currentUserId) .OrderByDescending(m => m.MoveId) .Take(MovePageSize), ClientMovePagingInfo = new PagingInfo { CurrentPage = 1, ItemsPerPage = MovePageSize, TotalItems = moveRepo.Moves.Count() }, Bids = bidRepo.Bids.Where(b => b.UserId == currentUserId) .OrderByDescending(b => b.BidId) }; return View(viewModel); } } return View(db.Moves.ToList()); } public ActionResult Moves(int page = 1) { if (User.Identity.IsAuthenticated) { MembershipUser currentUser = Membership.GetUser(); Guid currentUserId = (Guid)currentUser.ProviderUserKey; if (currentUser != null && currentUser.ProviderUserKey != null && currentUser.IsApproved) { var moves = db.Moves.Where(move => move.UserId == currentUserId) .OrderByDescending(m => m.MoveId) .Skip((page - 1) * MovePageSize) .Take(MovePageSize); if (Request.IsAjaxRequest()) { return PartialView("_Moves", moves); } } } return View(db.Moves.ToList()); }
1
11,349,383
07/05/2012 17:24:03
1,485,710
06/27/2012 12:56:38
6
0
Strange QT program crash with setBrush function of QGraphicsEllipseItem
I created a class Elipse which represents an elipse with a text inside. The parent class is QGraphicsEllipseItem. Here is the constructor; its not the final version, I will expand it when the problem is fixed: Ellipse::Ellipse(const char* text, qreal x, qreal y, QGraphicsItem* parent, QGraphicsScene* scene) : QGraphicsEllipseItem(parent, scene) { this->text = new QGraphicsTextItem(text, this); this->text->setPos(x, y); this->text->setTextWidth(ELLIPSE_WIDTH); this->setRect(x, y, ELLIPSE_WIDTH, ELLIPSE_HEIGHT); this->setFlag(QGraphicsItem::ItemIsMovable); this->setBrush(QBrush(Qt::white)); this->setZValue(1.0); } In another class I implemented a function which creates an Ellipse, puts it in the right scene and stores it in a vector to access it later. bool GUI::createEllipse(const char* name, qreal x, qreal y, int scene) { if(scene == 1) { Ellipse* ellipse = new Ellipse(name, x, y, 0, scene_1); // ellipses_1->push_back(ellipse); } else if(scene == 2) { Ellipse* ellipse = new Ellipse(name, x, y, 0, scene_2); // ellipse->setBrush(QBrush(Qt::red)); ellipses_2->push_back(ellipse); } else return false; gui->get().graphic_1->show(); gui->get().graphic_2->show(); return true; } The problem is following line "ellipse->setBrush(QBrush(Qt::red));". I don't need this line, because I set the color in the constructor. But if I delete this line, the program crashes after calling gui->show(); app->exec() does not get called. The strange thing is: When I execute this line in the else-if part, but delete it in the if part (just put away the "//" in the code above), the program runs. The Ellipses in scene_1 are then colored white, the Ellipses in scene_2 are colored red. The other way round works aswell. But why does the program crash when I don't execute this line inside the function? I know, i can just call the function with parameter Qt::white, but i really wanna know why there is a problem. I'm using Eclipse. I already tried cleaning and rebuilding the project; it doesn't help. I hope somebody knows why this occurs.
c++
eclipse
qt
ellipse
null
null
open
Strange QT program crash with setBrush function of QGraphicsEllipseItem === I created a class Elipse which represents an elipse with a text inside. The parent class is QGraphicsEllipseItem. Here is the constructor; its not the final version, I will expand it when the problem is fixed: Ellipse::Ellipse(const char* text, qreal x, qreal y, QGraphicsItem* parent, QGraphicsScene* scene) : QGraphicsEllipseItem(parent, scene) { this->text = new QGraphicsTextItem(text, this); this->text->setPos(x, y); this->text->setTextWidth(ELLIPSE_WIDTH); this->setRect(x, y, ELLIPSE_WIDTH, ELLIPSE_HEIGHT); this->setFlag(QGraphicsItem::ItemIsMovable); this->setBrush(QBrush(Qt::white)); this->setZValue(1.0); } In another class I implemented a function which creates an Ellipse, puts it in the right scene and stores it in a vector to access it later. bool GUI::createEllipse(const char* name, qreal x, qreal y, int scene) { if(scene == 1) { Ellipse* ellipse = new Ellipse(name, x, y, 0, scene_1); // ellipses_1->push_back(ellipse); } else if(scene == 2) { Ellipse* ellipse = new Ellipse(name, x, y, 0, scene_2); // ellipse->setBrush(QBrush(Qt::red)); ellipses_2->push_back(ellipse); } else return false; gui->get().graphic_1->show(); gui->get().graphic_2->show(); return true; } The problem is following line "ellipse->setBrush(QBrush(Qt::red));". I don't need this line, because I set the color in the constructor. But if I delete this line, the program crashes after calling gui->show(); app->exec() does not get called. The strange thing is: When I execute this line in the else-if part, but delete it in the if part (just put away the "//" in the code above), the program runs. The Ellipses in scene_1 are then colored white, the Ellipses in scene_2 are colored red. The other way round works aswell. But why does the program crash when I don't execute this line inside the function? I know, i can just call the function with parameter Qt::white, but i really wanna know why there is a problem. I'm using Eclipse. I already tried cleaning and rebuilding the project; it doesn't help. I hope somebody knows why this occurs.
0
11,349,384
07/05/2012 17:24:04
1,484,717
06/27/2012 06:29:17
3
0
escape sequence? using quotes in Qstring
Im using qt creator 2.4 I need to use a string say hi"world" in my code. I have tried to use Qstring and std ::string and I know / is the escape sequence but the IDE doesnt understand it as an escape sequence and gives errors when I write "hi/"world/"" I can use any string format that can be converted into Qstring. Any ideas what I'm doing wrong?
c++
c
qt
escaping
null
null
open
escape sequence? using quotes in Qstring === Im using qt creator 2.4 I need to use a string say hi"world" in my code. I have tried to use Qstring and std ::string and I know / is the escape sequence but the IDE doesnt understand it as an escape sequence and gives errors when I write "hi/"world/"" I can use any string format that can be converted into Qstring. Any ideas what I'm doing wrong?
0
11,349,386
07/05/2012 17:24:07
1,223,654
02/21/2012 14:54:11
1
0
concide top of one div to bottom of the other div both with height:auto; in css
I want to position a comments container relative to the post container . But the Post text can be of different size so i made it auto height . same for the comment container as it can contain any number of comments . but if i position the comment container as #wallwrap .comment_container_out { position:absolute; width:150px; bottom:-15px; left:80px; } it concides the bottom of the comment container to the bottom of the post container so when the number of comments increase , the height of the comment container also increases but it expands to upward direction while i want it to expand in the downward direction. The post container is #wallwrap .text_post { position:relative; left:20px; font-size:10px; font-family:Helvetica,Arial, sans-serif; color:#000; background-color:#fff; padding:5px 10px; width:220px; }
css
null
null
null
null
null
open
concide top of one div to bottom of the other div both with height:auto; in css === I want to position a comments container relative to the post container . But the Post text can be of different size so i made it auto height . same for the comment container as it can contain any number of comments . but if i position the comment container as #wallwrap .comment_container_out { position:absolute; width:150px; bottom:-15px; left:80px; } it concides the bottom of the comment container to the bottom of the post container so when the number of comments increase , the height of the comment container also increases but it expands to upward direction while i want it to expand in the downward direction. The post container is #wallwrap .text_post { position:relative; left:20px; font-size:10px; font-family:Helvetica,Arial, sans-serif; color:#000; background-color:#fff; padding:5px 10px; width:220px; }
0
11,226,474
06/27/2012 12:41:50
1,074,524
12/01/2011 00:37:29
5
0
Frequency of elements in matrix - Matlab
From a function that i run in matlab i get a 225x400 matrix. I want to count the frequency of each element in this matrix, meaning that i need to calculate how many times each elements appears on the the matrix. My matrix name is "Idiff" I am using: B=unique(Idiff); to find the unique elements in the Idiff matrix. I receive a column of 1138 elements, so i understand that these elements are unique and all the other elements in the Idiff matrix are these elements repeated. Now i try to count how many times each unique element appears in my Idiff matrix by using: C=histc(Idiff,B); But what i get is a column of 47761 elements and i get confused. Can you help me?
matlab
frequency
frequency-distribution
null
null
null
open
Frequency of elements in matrix - Matlab === From a function that i run in matlab i get a 225x400 matrix. I want to count the frequency of each element in this matrix, meaning that i need to calculate how many times each elements appears on the the matrix. My matrix name is "Idiff" I am using: B=unique(Idiff); to find the unique elements in the Idiff matrix. I receive a column of 1138 elements, so i understand that these elements are unique and all the other elements in the Idiff matrix are these elements repeated. Now i try to count how many times each unique element appears in my Idiff matrix by using: C=histc(Idiff,B); But what i get is a column of 47761 elements and i get confused. Can you help me?
0
11,226,476
06/27/2012 12:42:06
1,421,005
05/28/2012 05:15:22
40
1
How to put array values in a string or integer?
Can anybody please tell me how to put array values into a string or integer. Suppose an array a=[1,2,3]. After converting it should be like 1) string=123 and for integer it should be number=123. Thanks and regards,
iphone
null
null
null
null
null
open
How to put array values in a string or integer? === Can anybody please tell me how to put array values into a string or integer. Suppose an array a=[1,2,3]. After converting it should be like 1) string=123 and for integer it should be number=123. Thanks and regards,
0
11,226,477
06/27/2012 12:42:07
1,040,718
11/10/2011 22:42:51
145
4
connecting to Postgres with Perl
I have installed Postgres in my machine, and I'm trying to connect to it using `Perl`. $database = "heatmap"; $user = "postgres"; $password = "<password>"; #connect to MySQL database my $db = DBI->connect( "DBI:Pg:database=$db;", $user, $password ) or die "Can't Connect to database: $DBI::errstr\n"; However, I'm getting the following error: DBI connect('database=;','postgres',...) failed: FATAL: password authentication failed for user "souzamor" at C:/Users/souzamor/workspace/Parser/Parser.pl line 13. Can't Connect to database: FATAL: password authentication failed for user "souzamor" `souzamor` is my Windows username. However, I'm trying to connect as `postgres`. I went ahead and created an user called `souzamor` in Postgres, but I got: DBI connect('database=;','souzamor',...) failed: FATAL: database "user='souzamor'" does not exist at C:/Users/souzamor/workspace/Parser/Parser.pl line 13. Can't Connect to database: FATAL: database "user='souzamor'" does not exist I'm totally new with Postgres. Any ideas? Thanks
perl
postgresql
null
null
null
null
open
connecting to Postgres with Perl === I have installed Postgres in my machine, and I'm trying to connect to it using `Perl`. $database = "heatmap"; $user = "postgres"; $password = "<password>"; #connect to MySQL database my $db = DBI->connect( "DBI:Pg:database=$db;", $user, $password ) or die "Can't Connect to database: $DBI::errstr\n"; However, I'm getting the following error: DBI connect('database=;','postgres',...) failed: FATAL: password authentication failed for user "souzamor" at C:/Users/souzamor/workspace/Parser/Parser.pl line 13. Can't Connect to database: FATAL: password authentication failed for user "souzamor" `souzamor` is my Windows username. However, I'm trying to connect as `postgres`. I went ahead and created an user called `souzamor` in Postgres, but I got: DBI connect('database=;','souzamor',...) failed: FATAL: database "user='souzamor'" does not exist at C:/Users/souzamor/workspace/Parser/Parser.pl line 13. Can't Connect to database: FATAL: database "user='souzamor'" does not exist I'm totally new with Postgres. Any ideas? Thanks
0
11,226,478
06/27/2012 12:42:12
1,386,988
05/10/2012 11:53:40
6
0
android save content on setContentView()
I created an activity in which i created two classes so that on click of radiobutton i am setting the content using setContentView(). But my problem is when i try to switch between the two layouts the content of one layout is destroyed.... i have also tried making two activities for two layouts and use Intent to call another activity... Can anyone suggest me a method to switch between layouts with saving the contents. I also tried using android:saveenabled="true" for the particular widget.
android
android-layout
null
null
null
null
open
android save content on setContentView() === I created an activity in which i created two classes so that on click of radiobutton i am setting the content using setContentView(). But my problem is when i try to switch between the two layouts the content of one layout is destroyed.... i have also tried making two activities for two layouts and use Intent to call another activity... Can anyone suggest me a method to switch between layouts with saving the contents. I also tried using android:saveenabled="true" for the particular widget.
0
11,226,486
06/27/2012 12:42:26
1,283,105
03/21/2012 10:24:56
11
0
How to get user checkin info from facebook using userid
Note: I am using node.js I am getting real time updates through graph API for field checkin. like that { uid "1255434277" id "1255434277" time 1340796712 changed_fields [ 0 "checkins" ] } ] now i want to retrieve user checkins using user id i know for that i need access token to call graph API like this https://graph.facebook.com/1255434277/checkins?access_token=? but i don't know how to get access token in node.js for this user so i can get its checkins information.
node.js
facebook-graph-api
null
null
null
null
open
How to get user checkin info from facebook using userid === Note: I am using node.js I am getting real time updates through graph API for field checkin. like that { uid "1255434277" id "1255434277" time 1340796712 changed_fields [ 0 "checkins" ] } ] now i want to retrieve user checkins using user id i know for that i need access token to call graph API like this https://graph.facebook.com/1255434277/checkins?access_token=? but i don't know how to get access token in node.js for this user so i can get its checkins information.
0
11,226,487
06/27/2012 12:42:32
1,212,207
02/15/2012 19:13:18
8
0
Not loading a view in Codeigniter
here is a small peice off code that i wrote. But I am not getting the data in the view. It says undefined variable in the view Controller $data= array(); $data['']= json_decode(file_get_contents('http://localhost:8888/api/colleges')); $this->load->view('colleges/index',$data); View foreach($data as $college) : ?> <ul> <li><label>ID:</label> <?php echo $college;?></li> </ul> <?php endforeach;?>
php
html
codeigniter
null
null
null
open
Not loading a view in Codeigniter === here is a small peice off code that i wrote. But I am not getting the data in the view. It says undefined variable in the view Controller $data= array(); $data['']= json_decode(file_get_contents('http://localhost:8888/api/colleges')); $this->load->view('colleges/index',$data); View foreach($data as $college) : ?> <ul> <li><label>ID:</label> <?php echo $college;?></li> </ul> <?php endforeach;?>
0
11,471,443
07/13/2012 13:25:59
1,507,959
07/06/2012 22:24:13
1
0
XML in different urls merge into one single XML
I have single XML files which depend on an ID passed as a variable in the URL. I need to combine the first 100 to a single XML, I am using PHP. Example: URL for XML 1: example.com/file?id=1 URL for XML 2: example.com/file?id=2 XML 1: <books> <book> <name>Name 1</name> <number>123456</number> </book> </books> XML 2 <books> <book> <name>Name 2</name> <number>987654</number> </book> </books> Desired XML result using PHP: <books> <book> <name>Name 1</name> <number>123456</number> </book> <book> <name>Name 2</name> <number>987654</number> </book> </books> Any suggestion? Thanks!
xml
null
null
null
null
null
open
XML in different urls merge into one single XML === I have single XML files which depend on an ID passed as a variable in the URL. I need to combine the first 100 to a single XML, I am using PHP. Example: URL for XML 1: example.com/file?id=1 URL for XML 2: example.com/file?id=2 XML 1: <books> <book> <name>Name 1</name> <number>123456</number> </book> </books> XML 2 <books> <book> <name>Name 2</name> <number>987654</number> </book> </books> Desired XML result using PHP: <books> <book> <name>Name 1</name> <number>123456</number> </book> <book> <name>Name 2</name> <number>987654</number> </book> </books> Any suggestion? Thanks!
0
11,471,444
07/13/2012 13:26:00
1,523,566
07/13/2012 12:42:50
1
0
How to make changes on sharepoint intranet?
I will begin working on a sharepoint site, and I have to change the way this site manages the documents (Word format). The purpose is to manage the documents in paragraphs, so that you can have the right document made of the paragraphes that match with your search. The problem is that I know nothing about sharepoint. Do you have any idea about how I can do it? With which programming langage? I heard that jQuery helps managing sharepoint web sites, do you think it's a good idea? Thank you for your help.
sharepoint
intranet
documents
paragraphs
null
null
open
How to make changes on sharepoint intranet? === I will begin working on a sharepoint site, and I have to change the way this site manages the documents (Word format). The purpose is to manage the documents in paragraphs, so that you can have the right document made of the paragraphes that match with your search. The problem is that I know nothing about sharepoint. Do you have any idea about how I can do it? With which programming langage? I heard that jQuery helps managing sharepoint web sites, do you think it's a good idea? Thank you for your help.
0
11,471,445
07/13/2012 13:26:07
1,435,159
06/04/2012 12:34:08
20
0
Distorted circle in android using canvas
Paint p = new Paint(); p.setAntiAlias(true); p.setColor(Color.DKGRAY); int y=getWindowManager().getDefaultDisplay().getWidth(); Config conf = Bitmap.Config.RGB_565; Bitmap bmp =Bitmap.createBitmap(y,y,conf); Canvas c = new Canvas(bmp); c.drawCircle(y/2 ,y/2, y/3, p); iv.setBackgroundDrawable(new BitmapDrawable(bmp)); By this code i do get circle ,which is looking as:- ![](http://i.imgur.com/soY3U.png) Now the problem is that it doesnt look like a true circle ,and it looks like an oval shape.. So what should i do ?? Thanks in advance,....
android
canvas
bitmap
circle
null
null
open
Distorted circle in android using canvas === Paint p = new Paint(); p.setAntiAlias(true); p.setColor(Color.DKGRAY); int y=getWindowManager().getDefaultDisplay().getWidth(); Config conf = Bitmap.Config.RGB_565; Bitmap bmp =Bitmap.createBitmap(y,y,conf); Canvas c = new Canvas(bmp); c.drawCircle(y/2 ,y/2, y/3, p); iv.setBackgroundDrawable(new BitmapDrawable(bmp)); By this code i do get circle ,which is looking as:- ![](http://i.imgur.com/soY3U.png) Now the problem is that it doesnt look like a true circle ,and it looks like an oval shape.. So what should i do ?? Thanks in advance,....
0
11,451,798
07/12/2012 12:25:01
197,229
08/06/2009 19:20:13
7,288
159
Recreating/fixing a WinAPI ODBC connection
We create and cache ODBC connections created using [SQLDriverConnect][1]; we've found circumstances where the connection becomes lost... prepared statements stop working, etc. I didn't see an obvious function to test a connection/statement is valid, or to reset/re-create a connection, which seems like it would be a fairly common pattern. Can anyone suggest how this is best implemented? [1]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms715433%28v=vs.85%29.aspx "SQLDriverConnect"
c++
winapi
visual-c++
odbc
null
null
open
Recreating/fixing a WinAPI ODBC connection === We create and cache ODBC connections created using [SQLDriverConnect][1]; we've found circumstances where the connection becomes lost... prepared statements stop working, etc. I didn't see an obvious function to test a connection/statement is valid, or to reset/re-create a connection, which seems like it would be a fairly common pattern. Can anyone suggest how this is best implemented? [1]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms715433%28v=vs.85%29.aspx "SQLDriverConnect"
0
11,471,466
07/13/2012 13:28:19
1,437,301
06/05/2012 12:01:33
1
0
Twig - display a property inside an entity item
I have an entity that has an items property that is an array of item entities. the item entity has id and name properties. what I want to do is to get entity.items and display all name properties, separated by commas. the way I have it now: <tr> <th>Items</th> <td> {% for item in entity.items %} {{ item.name }} {% endfor %} </td> </tr> But it is not separated by commas. I tried the [Join][1] filter, but I can't find a way to use it in this situation, since I have an array of objects. [1]: http://twig.sensiolabs.org/doc/filters/join.html
symfony-2.0
doctrine
entity
twig
arraycollection
null
open
Twig - display a property inside an entity item === I have an entity that has an items property that is an array of item entities. the item entity has id and name properties. what I want to do is to get entity.items and display all name properties, separated by commas. the way I have it now: <tr> <th>Items</th> <td> {% for item in entity.items %} {{ item.name }} {% endfor %} </td> </tr> But it is not separated by commas. I tried the [Join][1] filter, but I can't find a way to use it in this situation, since I have an array of objects. [1]: http://twig.sensiolabs.org/doc/filters/join.html
0
11,386,866
07/08/2012 21:30:03
1,473,641
06/22/2012 01:01:01
6
1
What am I doing wrong when creating this function with a for and while loop?
Why does the first code work but not the second when they are the same? The second was just broken down into another function. It's supposed to not delete the string when the user inputs 'no'. This one works. If user inputs 'no', it doesnt delete anything. def remove(): f = open('codilist.txt') coname = raw_input('What company do you want to remove? ') # company name tmpfile = open('codilist.tmp', 'w') for line in f: if coname.upper() in line: while True: answer = raw_input('Are you sure you want to remove company?\nyes or no?') if answer == 'yes': print line.upper() + '...has been removed.' break elif answer == 'no': f.close() tmpfile.close() return else: print 'Please choose yes or no.' else: tmpfile.write(line) f.close() tmpfile.close() os.rename('codilist.tmp', 'codilist.txt') This one does not work. If user inputs 'no', it deletes the string anyways. def find_and_remove(f,coname,tmpfile): for line in f: if coname.upper() in line: while True: answer = raw_input('Are you sure you want to remove company?\nyes or no?') if answer == 'yes': print line.upper() + '...has been removed.' break elif answer == 'no': f.close() tmpfile.close() return else: print 'Please choose yes or no.' else: tmpfile.write(line) def remove(): f = open('codilist.txt') coname = raw_input('What company do you want to remove? ') # company name tmpfile = open('codilist.tmp', 'w') find_and_remove(f,coname,tmpfile) f.close() tmpfile.close() os.rename('codilist.tmp', 'codilist.txt')
function
null
null
null
null
null
open
What am I doing wrong when creating this function with a for and while loop? === Why does the first code work but not the second when they are the same? The second was just broken down into another function. It's supposed to not delete the string when the user inputs 'no'. This one works. If user inputs 'no', it doesnt delete anything. def remove(): f = open('codilist.txt') coname = raw_input('What company do you want to remove? ') # company name tmpfile = open('codilist.tmp', 'w') for line in f: if coname.upper() in line: while True: answer = raw_input('Are you sure you want to remove company?\nyes or no?') if answer == 'yes': print line.upper() + '...has been removed.' break elif answer == 'no': f.close() tmpfile.close() return else: print 'Please choose yes or no.' else: tmpfile.write(line) f.close() tmpfile.close() os.rename('codilist.tmp', 'codilist.txt') This one does not work. If user inputs 'no', it deletes the string anyways. def find_and_remove(f,coname,tmpfile): for line in f: if coname.upper() in line: while True: answer = raw_input('Are you sure you want to remove company?\nyes or no?') if answer == 'yes': print line.upper() + '...has been removed.' break elif answer == 'no': f.close() tmpfile.close() return else: print 'Please choose yes or no.' else: tmpfile.write(line) def remove(): f = open('codilist.txt') coname = raw_input('What company do you want to remove? ') # company name tmpfile = open('codilist.tmp', 'w') find_and_remove(f,coname,tmpfile) f.close() tmpfile.close() os.rename('codilist.tmp', 'codilist.txt')
0
11,386,868
07/08/2012 21:30:31
643,759
03/03/2011 21:50:26
24
0
Create runnable jar from command line
In folder `~/code/` I have `bin/ src/ lib/` A manifest.txt is created in ~/ with the content: Main-class: test.MyMainClass Class-Path: lib/*.jar Then in ~ I used command `jar cfm d.jar manifest.txt code/` then I run `java -jar d.jar` it says `Exception in thread "main" java.lang.NoClassDefFoundError: test/MyMainClass Caused by: java.lang.ClassNotFoundException: test.MyMainClass`
java
null
null
null
null
null
open
Create runnable jar from command line === In folder `~/code/` I have `bin/ src/ lib/` A manifest.txt is created in ~/ with the content: Main-class: test.MyMainClass Class-Path: lib/*.jar Then in ~ I used command `jar cfm d.jar manifest.txt code/` then I run `java -jar d.jar` it says `Exception in thread "main" java.lang.NoClassDefFoundError: test/MyMainClass Caused by: java.lang.ClassNotFoundException: test.MyMainClass`
0
11,386,869
07/08/2012 21:30:52
392,115
07/14/2010 22:21:41
197
10
Change Rails Console (IRB) Ruby Version OSX
I am having some trouble getting rails to run with the correct version of ruby in the rails console. I would like to use ruby 1.9.3 in the rails console. When I run RVM list I get: rvm rubies ruby-1.9.3-p0 [ x86_64 ] =* ruby-1.9.3-p194 [ x86_64 ] # => - current # =* - current && default # * - default When I run rbenv global I get: rbenv global 1.9.3-p194 When I run RUBY_VERSION in 'rails console' irb(main):001:0> RUBY_VERSION => "1.8.7" Thanks in advance for your help.
ruby-on-rails
ruby
rvm
irb
rbenv
null
open
Change Rails Console (IRB) Ruby Version OSX === I am having some trouble getting rails to run with the correct version of ruby in the rails console. I would like to use ruby 1.9.3 in the rails console. When I run RVM list I get: rvm rubies ruby-1.9.3-p0 [ x86_64 ] =* ruby-1.9.3-p194 [ x86_64 ] # => - current # =* - current && default # * - default When I run rbenv global I get: rbenv global 1.9.3-p194 When I run RUBY_VERSION in 'rails console' irb(main):001:0> RUBY_VERSION => "1.8.7" Thanks in advance for your help.
0
11,386,873
07/08/2012 21:31:27
630,383
02/23/2011 14:48:58
32
5
Show vs ShowDialog issues with both
I have been writing a little application where Form1 opens, checks that a config file is present and correct, and then hides in the Task Bar until an API call is received. When this happens I would like a new Form to open in the bottom right corner and show various details, but am having the following issues: Form2 form2 = new Form2(); form2.TopMost = true; form2.TopLevel = true; form2.ShowDialog(); Above: Doesn't always open on-top of everything Form2 form2 = new Form2(); form2.TopMost = true; form2.TopLevel = true; form2.Show(); Above, opens like (hard to see, but the Text Boxes should be greyed out as Disabled and Readonly, and there is black text next to each Text Field which is now invisible, but has a white background): ![screenshot][1] [1]: http://img546.imageshack.us/img546/5517/screenshot20120708at222.png "screenshot" Thanks in advance!
c#
null
null
null
null
null
open
Show vs ShowDialog issues with both === I have been writing a little application where Form1 opens, checks that a config file is present and correct, and then hides in the Task Bar until an API call is received. When this happens I would like a new Form to open in the bottom right corner and show various details, but am having the following issues: Form2 form2 = new Form2(); form2.TopMost = true; form2.TopLevel = true; form2.ShowDialog(); Above: Doesn't always open on-top of everything Form2 form2 = new Form2(); form2.TopMost = true; form2.TopLevel = true; form2.Show(); Above, opens like (hard to see, but the Text Boxes should be greyed out as Disabled and Readonly, and there is black text next to each Text Field which is now invisible, but has a white background): ![screenshot][1] [1]: http://img546.imageshack.us/img546/5517/screenshot20120708at222.png "screenshot" Thanks in advance!
0
11,386,818
07/08/2012 21:23:00
932,727
09/07/2011 12:45:57
182
10
Titanium ACS with WP7
Does anyone know if ACS, a Cloud Storage service by Titanium is compatible with Windows Phone 7? I've been trying to look on the web for details but haven't found anything useful. Any help is highly appreciated.
windows-phone-7
titanium
null
null
null
null
open
Titanium ACS with WP7 === Does anyone know if ACS, a Cloud Storage service by Titanium is compatible with Windows Phone 7? I've been trying to look on the web for details but haven't found anything useful. Any help is highly appreciated.
0
11,386,876
07/08/2012 21:31:42
1,319,248
04/07/2012 15:24:01
1
0
How to encode and decode Files as Base64 in Cocoa / Objective-C
I am currently trying to get a small soap client to work, which includes to send a certificate file within the xml of the request. I have no trouble getting the file into an NSData object - but then I have to convert it to some Base64 String. Environment is Mac OSX, Xcode 4.3. I have found a lot of older posting dealing with that - but the best I found was some code that made use of OpenSSL libs and where containing loads of deprecated methods. So, my question is as follows: Is there a better way than to use the OpenSSL libs? If yes, do you perchance have some URL or more recent code scraps? If no, I guess there is some project out there which deals with Base64 that can be recommended. After all Base64 is not that uncommon. Thanks for your help!
objective-c
cocoa
base64
xcode4.3
null
null
open
How to encode and decode Files as Base64 in Cocoa / Objective-C === I am currently trying to get a small soap client to work, which includes to send a certificate file within the xml of the request. I have no trouble getting the file into an NSData object - but then I have to convert it to some Base64 String. Environment is Mac OSX, Xcode 4.3. I have found a lot of older posting dealing with that - but the best I found was some code that made use of OpenSSL libs and where containing loads of deprecated methods. So, my question is as follows: Is there a better way than to use the OpenSSL libs? If yes, do you perchance have some URL or more recent code scraps? If no, I guess there is some project out there which deals with Base64 that can be recommended. After all Base64 is not that uncommon. Thanks for your help!
0
11,386,880
07/08/2012 21:32:10
1,228,936
02/23/2012 17:07:28
140
11
Add target="_top" to Expression Engine Login Form Tag
I'm using the login form tag inside of a fancybox iframe. For my return parameter, I'm using `<?php echo $_SERVER['HTTP_REFERER']; ?>`, so that it takes the user back to whichever page they started from. Unfortunately, it takes them back to that page within the iframe. How do I add a `target="_top"` attribute to the return link, or some other jQuery call that will close the iframe and manage the redirect within the parent window? Thanks, ty
jquery
fancybox
expressionengine
targeting
null
null
open
Add target="_top" to Expression Engine Login Form Tag === I'm using the login form tag inside of a fancybox iframe. For my return parameter, I'm using `<?php echo $_SERVER['HTTP_REFERER']; ?>`, so that it takes the user back to whichever page they started from. Unfortunately, it takes them back to that page within the iframe. How do I add a `target="_top"` attribute to the return link, or some other jQuery call that will close the iframe and manage the redirect within the parent window? Thanks, ty
0
11,386,882
07/08/2012 21:32:34
1,510,585
07/08/2012 21:17:42
1
0
Rails Image Upload to S3 with carrierwave and fog
Hello ive been developing a web appliaction and want to give users teh posibility of uploading profile pictures. Ive spent a lot of time trying to get carrierwave and fog to work with s3 but have not managed to acomplish it. Any help you can give me is much apreciated. My uploader class. class PhotoUploader < CarrierWave::Uploader::Base storage :fog def store_dir "uploads/#images/#{model.class.to_s.underscore}" end end The fog initializer CarrierWave.configure do |config| config.fog_credentials = { :provider => 'AWS', :aws_access_key_id => 'xxx', :aws_secret_access_key => 'yyy', } config.fog_directory = 'pictures_dev' config.fog_public = true config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} end Users model class User include Mongoid::Document .... has_one :photo .... end Photo Model class Photo include Mongoid::Document attr_accessible :name, :image field :image, :type => String field :name, :type => String belongs_to :user mount_uploader :image, PhotoUploader end Photo Controller class PhotoController < ApplicationController def update @photo = Photo.find(params[:id]) if @photo.update_attributes(params[:image]) flash[:success] = "Your have updated your settings successfully." else flash[:error] = "Sorry! We are unable to update your settings. Please check your fields and try again." end redirect_to(:back) end Upload form = form_for @photo, :html => {:multipart => true} do |f| %p %label Photo = image_tag(@user.image_url) if @photo.image? = f.file_field :image = f.submit This is all I can think of that is relevant, if anyone need me to post more code ill be happy to. I am honestly stumped and any help is appreciated.
ruby-on-rails
ruby
amazon-s3
carrierwave
fog
null
open
Rails Image Upload to S3 with carrierwave and fog === Hello ive been developing a web appliaction and want to give users teh posibility of uploading profile pictures. Ive spent a lot of time trying to get carrierwave and fog to work with s3 but have not managed to acomplish it. Any help you can give me is much apreciated. My uploader class. class PhotoUploader < CarrierWave::Uploader::Base storage :fog def store_dir "uploads/#images/#{model.class.to_s.underscore}" end end The fog initializer CarrierWave.configure do |config| config.fog_credentials = { :provider => 'AWS', :aws_access_key_id => 'xxx', :aws_secret_access_key => 'yyy', } config.fog_directory = 'pictures_dev' config.fog_public = true config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} end Users model class User include Mongoid::Document .... has_one :photo .... end Photo Model class Photo include Mongoid::Document attr_accessible :name, :image field :image, :type => String field :name, :type => String belongs_to :user mount_uploader :image, PhotoUploader end Photo Controller class PhotoController < ApplicationController def update @photo = Photo.find(params[:id]) if @photo.update_attributes(params[:image]) flash[:success] = "Your have updated your settings successfully." else flash[:error] = "Sorry! We are unable to update your settings. Please check your fields and try again." end redirect_to(:back) end Upload form = form_for @photo, :html => {:multipart => true} do |f| %p %label Photo = image_tag(@user.image_url) if @photo.image? = f.file_field :image = f.submit This is all I can think of that is relevant, if anyone need me to post more code ill be happy to. I am honestly stumped and any help is appreciated.
0
11,386,883
07/08/2012 21:32:36
1,198,201
02/08/2012 20:30:12
64
4
scale background image
I would like to scale up and down a background image in my page. I've tried multiple things but nothing quite seems to work the way I want. :( The url of my page is http://quaaoutlodge.com/drupal-7.14/ and for each link, there's a different background image. I know the size and quality of the images will need to be optimized but I first want to figure out the techincal part of it. If someone please coudl assist in getting this going? Thank you very much! Ron
html
css
website
background-image
null
null
open
scale background image === I would like to scale up and down a background image in my page. I've tried multiple things but nothing quite seems to work the way I want. :( The url of my page is http://quaaoutlodge.com/drupal-7.14/ and for each link, there's a different background image. I know the size and quality of the images will need to be optimized but I first want to figure out the techincal part of it. If someone please coudl assist in getting this going? Thank you very much! Ron
0
11,713,408
07/29/2012 22:09:05
1,108,431
12/20/2011 18:10:41
88
6
Partial Arrays by reference
My question is simple: Is it possible to, like I would do in C++, to retrieve two parts of an array in VBA by reference? It's been a while since I coded in C++, so I can't quite remember how I do it right now. Maybe if I remember, I'll have an example. What I am trying to do is sort an array of objects by a single Double-type property. I've done it before in C++, just don't have the source code anymore. I doubt that there is a predefined function to use for this, but if anybody knows a better solution, it'll be welcomed greatly. ;) This is basically what I want: source array(0, 1, 2, 3, 4, 5) split source array in two array a(0, 1, 2) array b(3, 4, 5) set array a(0) = 4 array a(4, 1, 2) array b(3, 4, 5) source array(4, 1, 2, 3, 4, 5) Of course this is only an abstract description. I apologize if there already is a question dealing with this, I then have not found it.
vb.net
vba
reference
array-sorting
null
null
open
Partial Arrays by reference === My question is simple: Is it possible to, like I would do in C++, to retrieve two parts of an array in VBA by reference? It's been a while since I coded in C++, so I can't quite remember how I do it right now. Maybe if I remember, I'll have an example. What I am trying to do is sort an array of objects by a single Double-type property. I've done it before in C++, just don't have the source code anymore. I doubt that there is a predefined function to use for this, but if anybody knows a better solution, it'll be welcomed greatly. ;) This is basically what I want: source array(0, 1, 2, 3, 4, 5) split source array in two array a(0, 1, 2) array b(3, 4, 5) set array a(0) = 4 array a(4, 1, 2) array b(3, 4, 5) source array(4, 1, 2, 3, 4, 5) Of course this is only an abstract description. I apologize if there already is a question dealing with this, I then have not found it.
0
11,713,416
07/29/2012 22:09:56
849,137
07/17/2011 23:08:19
1,598
67
How to get the end URL of a HTML image request?
You know this link: http://media.photobucket.com/image/graphics/PennilessTeacher/Graphics/monster.jpg?o=8 redirects to this link: http://i1133.photobucket.com/albums/m581/PennilessTeacher/Graphics/monster.jpg Well, let's say I have: <img src='http://media.photobucket.com/image/graphics/PennilessTeacher/Graphics/monster.jpg?o=8' width='blah' height = 'blah'/> The request to the image URL will be redirected. I want to know the **end** URL. So in this case, it would be `http://i1133.photobucket.com/albums/m581/PennilessTeacher/Graphics/monster.jpg`. I previously asked a question about fetching the status code of a cross domain image request, which seems to be impossible without a server side script doing the `http` request. Server side scripts are out of the question here. I need the request to be processed on the client's side, as some of the sites the image element will be pointing to require some specific cookies that sit on the client side, which I obviously cannot help myself to as they're for a completely different domain. If that makes any sense... Any client side language will do. Whether I know it or not. Suggestions people? Or am I totally screwed?
javascript
jquery
html
img
src
null
open
How to get the end URL of a HTML image request? === You know this link: http://media.photobucket.com/image/graphics/PennilessTeacher/Graphics/monster.jpg?o=8 redirects to this link: http://i1133.photobucket.com/albums/m581/PennilessTeacher/Graphics/monster.jpg Well, let's say I have: <img src='http://media.photobucket.com/image/graphics/PennilessTeacher/Graphics/monster.jpg?o=8' width='blah' height = 'blah'/> The request to the image URL will be redirected. I want to know the **end** URL. So in this case, it would be `http://i1133.photobucket.com/albums/m581/PennilessTeacher/Graphics/monster.jpg`. I previously asked a question about fetching the status code of a cross domain image request, which seems to be impossible without a server side script doing the `http` request. Server side scripts are out of the question here. I need the request to be processed on the client's side, as some of the sites the image element will be pointing to require some specific cookies that sit on the client side, which I obviously cannot help myself to as they're for a completely different domain. If that makes any sense... Any client side language will do. Whether I know it or not. Suggestions people? Or am I totally screwed?
0
11,713,418
07/29/2012 22:10:16
234,152
12/17/2009 21:40:48
2,321
87
Exposing COM events to VBScript (ATL)
I have built a COM server DLL in C++ with ATL by using the "ATL simple object" wizard. I followed Microsoft's [ATLDLLCOMServer][1] example. Everything works well except for one thing: **I do not receive COM events in VBScript**. I do receive the events in C#. I had events working in VBScript in an earlier MFC-based implementation as ActiveX control. My control is defined like this: class ATL_NO_VTABLE CSetACLCOMServer : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CSetACLCOMServer, &CLSID_SetACLCOMServer>, public IConnectionPointContainerImpl<CSetACLCOMServer>, public CProxy_ISetACLCOMServerEvents<CSetACLCOMServer>, public IDispatchImpl<ISetACLCOMServer, &IID_ISetACLCOMServer, &LIBID_SetACLCOMLibrary, /*wMajor =*/ 1, /*wMinor =*/ 0>, public IProvideClassInfo2Impl<&CLSID_SetACLCOMServer, NULL, &LIBID_SetACLCOMLibrary> /* Required for event support in VBS */ { public: BEGIN_COM_MAP(CSetACLCOMServer) COM_INTERFACE_ENTRY(ISetACLCOMServer) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(IConnectionPointContainer) COM_INTERFACE_ENTRY(IProvideClassInfo) COM_INTERFACE_ENTRY(IProvideClassInfo2) END_COM_MAP() BEGIN_CONNECTION_POINT_MAP(CSetACLCOMServer) CONNECTION_POINT_ENTRY(__uuidof(_ISetACLCOMServerEvents)) END_CONNECTION_POINT_MAP() [...] In VBScript I use the COM object like this: set objSetACL = WScript.CreateObject("SetACL.SetACL", "SetACL_") ' Catch and print messages from the SetACL COM server which are passed (fired) as events. ' The name postfix of this function (MessageEvent) must be identical to the event name ' as defined by SetACL. ' The prefix (SetACL_) can be set freely in the call to WScript.CreateObject sub SetACL_MessageEvent (Message) WScript.Echo Message end sub The relevant parts of the IDL look like this: [ object, uuid(E1B57CA5-FD7F-4304-BC0A-8BEBDE231D53), dual, nonextensible, pointer_default(unique), helpstring("SetACL COM Interface") ] interface ISetACLCOMServer : IDispatch { }; [ uuid(00D4DCD3-02B9-4A71-AB61-2283504620C8), version(1.0), helpstring ("SetACL Type Library") ] library SetACLCOMLibrary { importlib("stdole2.tlb"); [ uuid(35F76182-7F52-4D6A-BD6E-1317345F98FB), helpstring ("SetACL Event Interface") ] dispinterface _ISetACLCOMServerEvents { properties: methods: [id(1), helpstring("Receives string messages that would appear on the screen in the command line version")] void MessageEvent([in] BSTR message); }; [ uuid(13379563-8F21-4579-8AC7-CBCD488735DB), helpstring ("SetACL COM Server"), ] coclass SetACLCOMServer { [default] interface ISetACLCOMServer; [default, source] dispinterface _ISetACLCOMServerEvents; }; }; The **problem**: SetACL_MessageEvent never gets called. What I have tried: - After reading [this KB article][2] I added the implementation of IProvideClassInfo2, but that did not help. - This [FAQ][3] mentions that outgoing interface should not defined as a dual interfaces. I removed the "dual" from my interface definition, but that did not help. [1]: http://code.msdn.microsoft.com/windowsdesktop/ATLDllCOMServer-09df00e4 [2]: http://support.microsoft.com/default.aspx?scid=kb;en-us;200839 [3]: http://support.microsoft.com/kb/166480
c++
events
com
vbscript
atl
null
open
Exposing COM events to VBScript (ATL) === I have built a COM server DLL in C++ with ATL by using the "ATL simple object" wizard. I followed Microsoft's [ATLDLLCOMServer][1] example. Everything works well except for one thing: **I do not receive COM events in VBScript**. I do receive the events in C#. I had events working in VBScript in an earlier MFC-based implementation as ActiveX control. My control is defined like this: class ATL_NO_VTABLE CSetACLCOMServer : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CSetACLCOMServer, &CLSID_SetACLCOMServer>, public IConnectionPointContainerImpl<CSetACLCOMServer>, public CProxy_ISetACLCOMServerEvents<CSetACLCOMServer>, public IDispatchImpl<ISetACLCOMServer, &IID_ISetACLCOMServer, &LIBID_SetACLCOMLibrary, /*wMajor =*/ 1, /*wMinor =*/ 0>, public IProvideClassInfo2Impl<&CLSID_SetACLCOMServer, NULL, &LIBID_SetACLCOMLibrary> /* Required for event support in VBS */ { public: BEGIN_COM_MAP(CSetACLCOMServer) COM_INTERFACE_ENTRY(ISetACLCOMServer) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(IConnectionPointContainer) COM_INTERFACE_ENTRY(IProvideClassInfo) COM_INTERFACE_ENTRY(IProvideClassInfo2) END_COM_MAP() BEGIN_CONNECTION_POINT_MAP(CSetACLCOMServer) CONNECTION_POINT_ENTRY(__uuidof(_ISetACLCOMServerEvents)) END_CONNECTION_POINT_MAP() [...] In VBScript I use the COM object like this: set objSetACL = WScript.CreateObject("SetACL.SetACL", "SetACL_") ' Catch and print messages from the SetACL COM server which are passed (fired) as events. ' The name postfix of this function (MessageEvent) must be identical to the event name ' as defined by SetACL. ' The prefix (SetACL_) can be set freely in the call to WScript.CreateObject sub SetACL_MessageEvent (Message) WScript.Echo Message end sub The relevant parts of the IDL look like this: [ object, uuid(E1B57CA5-FD7F-4304-BC0A-8BEBDE231D53), dual, nonextensible, pointer_default(unique), helpstring("SetACL COM Interface") ] interface ISetACLCOMServer : IDispatch { }; [ uuid(00D4DCD3-02B9-4A71-AB61-2283504620C8), version(1.0), helpstring ("SetACL Type Library") ] library SetACLCOMLibrary { importlib("stdole2.tlb"); [ uuid(35F76182-7F52-4D6A-BD6E-1317345F98FB), helpstring ("SetACL Event Interface") ] dispinterface _ISetACLCOMServerEvents { properties: methods: [id(1), helpstring("Receives string messages that would appear on the screen in the command line version")] void MessageEvent([in] BSTR message); }; [ uuid(13379563-8F21-4579-8AC7-CBCD488735DB), helpstring ("SetACL COM Server"), ] coclass SetACLCOMServer { [default] interface ISetACLCOMServer; [default, source] dispinterface _ISetACLCOMServerEvents; }; }; The **problem**: SetACL_MessageEvent never gets called. What I have tried: - After reading [this KB article][2] I added the implementation of IProvideClassInfo2, but that did not help. - This [FAQ][3] mentions that outgoing interface should not defined as a dual interfaces. I removed the "dual" from my interface definition, but that did not help. [1]: http://code.msdn.microsoft.com/windowsdesktop/ATLDllCOMServer-09df00e4 [2]: http://support.microsoft.com/default.aspx?scid=kb;en-us;200839 [3]: http://support.microsoft.com/kb/166480
0
11,713,424
07/29/2012 22:11:08
1,358,522
04/26/2012 11:13:07
20
0
ORDER BY before GROUP BY
I have a page showing a list of persons with whom you have been chatting to. Currently it's showing the persons you have been chatting to, and the OLDEST message. However, it should show the NEWEST message. This is the query: SELECT * FROM post WHERE fk_user_to = '$userid' GROUP BY fk_user_from ORDER BY datotime DESC and the table structure post_id || fk_user_to || fk_user_from || message || datotime
sql
null
null
null
null
null
open
ORDER BY before GROUP BY === I have a page showing a list of persons with whom you have been chatting to. Currently it's showing the persons you have been chatting to, and the OLDEST message. However, it should show the NEWEST message. This is the query: SELECT * FROM post WHERE fk_user_to = '$userid' GROUP BY fk_user_from ORDER BY datotime DESC and the table structure post_id || fk_user_to || fk_user_from || message || datotime
0
11,160,034
06/22/2012 16:09:39
509,627
11/16/2010 14:33:02
1,322
177
How to store an in and boolean as a pair
We have a number of properties in several classes where the property is presently an int and a boolean. The int is the value and the boolean is true if that int has been set. We need this pairing because we are representing an object that has levels of properties where if it is not set at one level, it uses the setting at the level above. This approach lets us record at each level what its value is and if it was set at that level or inherited. It works great. However we can end up with literally 100,000 of these objects. And that's a ton of memory, a ton of garbage collection, etc. So, any ideas how we can somehow do this better. We looked at an array of ints and booleans with enums as the index. But that feels really awkward, which generally means more opportunities to get something wrong (ie introduce bugs). Any suggestions? thanks - dave
java
primitive-types
null
null
null
null
open
How to store an in and boolean as a pair === We have a number of properties in several classes where the property is presently an int and a boolean. The int is the value and the boolean is true if that int has been set. We need this pairing because we are representing an object that has levels of properties where if it is not set at one level, it uses the setting at the level above. This approach lets us record at each level what its value is and if it was set at that level or inherited. It works great. However we can end up with literally 100,000 of these objects. And that's a ton of memory, a ton of garbage collection, etc. So, any ideas how we can somehow do this better. We looked at an array of ints and booleans with enums as the index. But that feels really awkward, which generally means more opportunities to get something wrong (ie introduce bugs). Any suggestions? thanks - dave
0
11,327,316
07/04/2012 10:32:33
1,299,892
03/29/2012 05:27:18
20
0
how to join tables in hbase
I have to join tables in Hbase. I integrated HIVE and HBase and that is working well. I can query using HIVE. But can somebody help me how to join tables in HBase without using HIVE. I think using mapreduce we can achieve this, if so can anybody share a working example that I can refer. Please share your opinions.
mapreduce
hbase
null
null
null
null
open
how to join tables in hbase === I have to join tables in Hbase. I integrated HIVE and HBase and that is working well. I can query using HIVE. But can somebody help me how to join tables in HBase without using HIVE. I think using mapreduce we can achieve this, if so can anybody share a working example that I can refer. Please share your opinions.
0
11,327,318
07/04/2012 10:32:42
1,262,350
03/11/2012 14:01:57
11
1
jQuery: set value for element from array
This may be hard to explain, but I have array like this: myarray = { "class1" : "value1" "class2" : "value2" "class3" : "value3" ... } and I have script $.each(myarray,function(i,val){ try{ var it=0; $("." + i).each(function(it){ switch($("." + i)[it].nodeName){ case "SPAN":case "A":case "DIV": $("." + i).html(val); break; case "INPUT": try{ switch($("." + i).attr("type")){ case "submit": $("." + i).attr("value",val); break; case "text":case "password":case "email": $("." + i).attr("placeholder",val); break; } }catch(err){ } break; case "IMG": $("." + i).attr("alt",val); $("." + i).attr("title",val); break; } }); }catch(err){ // Nothing } }); Effect of code for <code>span</code>, <code>a</code>, <code>div</code> should be this: Was: <span class="class1"></span> Is: <span class="class1">value1</span> and for <code>input</code> where <code>type=submit</code>, it should be this: Was: <input type="submit" class="class2" /> Is: <input type="submit" class="class2" value="value2" /> Code effects for <code>span</code>, <code>a</code>, <code>div</code> and <code>input[type=submit]</code>, but this won't set <code>placeholder</code>s. Why?
javascript
jquery
null
null
null
null
open
jQuery: set value for element from array === This may be hard to explain, but I have array like this: myarray = { "class1" : "value1" "class2" : "value2" "class3" : "value3" ... } and I have script $.each(myarray,function(i,val){ try{ var it=0; $("." + i).each(function(it){ switch($("." + i)[it].nodeName){ case "SPAN":case "A":case "DIV": $("." + i).html(val); break; case "INPUT": try{ switch($("." + i).attr("type")){ case "submit": $("." + i).attr("value",val); break; case "text":case "password":case "email": $("." + i).attr("placeholder",val); break; } }catch(err){ } break; case "IMG": $("." + i).attr("alt",val); $("." + i).attr("title",val); break; } }); }catch(err){ // Nothing } }); Effect of code for <code>span</code>, <code>a</code>, <code>div</code> should be this: Was: <span class="class1"></span> Is: <span class="class1">value1</span> and for <code>input</code> where <code>type=submit</code>, it should be this: Was: <input type="submit" class="class2" /> Is: <input type="submit" class="class2" value="value2" /> Code effects for <code>span</code>, <code>a</code>, <code>div</code> and <code>input[type=submit]</code>, but this won't set <code>placeholder</code>s. Why?
0
11,327,322
07/04/2012 10:32:52
555,951
12/28/2010 12:00:50
386
10
save found site for a google query
Goal: Google a query "foo" -> found lots results -> browse and find one best answer to "foo" -> save the link of that answer, so that next time i can be directly brought to it. I know that you can use google search history to store all your search queries, but it does not allow you to save a specific link or customize the search results to your own flavor. Some idea? thanks!
google
null
null
null
null
null
open
save found site for a google query === Goal: Google a query "foo" -> found lots results -> browse and find one best answer to "foo" -> save the link of that answer, so that next time i can be directly brought to it. I know that you can use google search history to store all your search queries, but it does not allow you to save a specific link or customize the search results to your own flavor. Some idea? thanks!
0
11,327,304
07/04/2012 10:31:43
1,479,798
06/25/2012 11:24:01
6
0
How to differentiate headings in a Microsoft Word file using Microsoft.Office.Interop.Word ?
I want to find all the headings in a word document which is of font size greater than the text below it, all the headings are of same font size else all the headings are bold while the text below it are not bold and I want to save all these headings in a list. How can I achieve this?? I'm learner in Office.Interop.Word any assistance will help me a lot.
c#-4.0
word
office-interop
null
null
null
open
How to differentiate headings in a Microsoft Word file using Microsoft.Office.Interop.Word ? === I want to find all the headings in a word document which is of font size greater than the text below it, all the headings are of same font size else all the headings are bold while the text below it are not bold and I want to save all these headings in a list. How can I achieve this?? I'm learner in Office.Interop.Word any assistance will help me a lot.
0
11,650,297
07/25/2012 13:00:16
1,331,370
04/13/2012 10:48:14
40
0
How to write JPQL query using multiple members of same collection?
I have a noticication entity that has OneToMany relationship with its parameters, which is a list of NotificationParamEntity objects. The code for both classes looks like: // Notification Entity @Entity @Table (name = "NOTIFICATIONS") public class NotificationEntity { ...... @OneToMany (mappedBy = "notification") private List<NotificationParamEntity> params; ...... } // Notification Parameter Entity @Entity @Table (name = "NOTIFICATIONS_PARAM") public class NotificationParamEntity { ...... @Column (name = "KEY", length = 40, nullable = false) @Enumerated (EnumType.STRING) private NotificationParameterEnum key; @Column (name = "VALUE", length = 4000, nullable = false) private String value; ...... } Now I can use the query below to get the notification that has a parameter named "P1" and with a value "V1": > SELECT DISTINCT anEntity FROM NotificationEntity anEntity, IN > (anEntity.params) p WHERE p.key = "P1" AND p.value = 'V1' But when I want to find out the notification that has two specified parameters(P1=V1 and P2=V2), my query below failed to find anything: > SELECT DISTINCT anEntity FROM NotificationEntity anEntity, IN > (anEntity.params) p WHERE p.key = "P1" AND p.value = 'V1' AND p.key = "P2" AND p.value = "V2" I can understand why it doesn't work: there is no parameter that can have two different keys, so the query return nothing. But how to make this work? Assume I have a notification entity that has two parameters, one is named P1 and value is V1, the other one is P2 and the value is V2, how can I find this notification entity with JPQL query?
jpa
collections
jpql
onetomany
null
null
open
How to write JPQL query using multiple members of same collection? === I have a noticication entity that has OneToMany relationship with its parameters, which is a list of NotificationParamEntity objects. The code for both classes looks like: // Notification Entity @Entity @Table (name = "NOTIFICATIONS") public class NotificationEntity { ...... @OneToMany (mappedBy = "notification") private List<NotificationParamEntity> params; ...... } // Notification Parameter Entity @Entity @Table (name = "NOTIFICATIONS_PARAM") public class NotificationParamEntity { ...... @Column (name = "KEY", length = 40, nullable = false) @Enumerated (EnumType.STRING) private NotificationParameterEnum key; @Column (name = "VALUE", length = 4000, nullable = false) private String value; ...... } Now I can use the query below to get the notification that has a parameter named "P1" and with a value "V1": > SELECT DISTINCT anEntity FROM NotificationEntity anEntity, IN > (anEntity.params) p WHERE p.key = "P1" AND p.value = 'V1' But when I want to find out the notification that has two specified parameters(P1=V1 and P2=V2), my query below failed to find anything: > SELECT DISTINCT anEntity FROM NotificationEntity anEntity, IN > (anEntity.params) p WHERE p.key = "P1" AND p.value = 'V1' AND p.key = "P2" AND p.value = "V2" I can understand why it doesn't work: there is no parameter that can have two different keys, so the query return nothing. But how to make this work? Assume I have a notification entity that has two parameters, one is named P1 and value is V1, the other one is P2 and the value is V2, how can I find this notification entity with JPQL query?
0
11,650,268
07/25/2012 12:58:39
485,115
10/23/2010 15:15:25
2,506
62
Best performant immutable Seq for measuring length
For whatever reason there was no notion on that in [Performance Characteristics Doc](http://docs.scala-lang.org/overviews/collections/performance-characteristics.html), so I dug into the sources and found out that `List` and `Queue` seem to have *O(n)*, since they iterate thru all members. The `Vector` seems to have *O(1)*, since it simply subtracts one `Int` from another. Now, it doesn't matter whether the collection is append- or prepend-oriented, but either one of them must be *O(1)*, and there's no need for performant `apply`. Is `Vector` the correct choice? Which would you suggest?
scala
collections
immutable
null
null
null
open
Best performant immutable Seq for measuring length === For whatever reason there was no notion on that in [Performance Characteristics Doc](http://docs.scala-lang.org/overviews/collections/performance-characteristics.html), so I dug into the sources and found out that `List` and `Queue` seem to have *O(n)*, since they iterate thru all members. The `Vector` seems to have *O(1)*, since it simply subtracts one `Int` from another. Now, it doesn't matter whether the collection is append- or prepend-oriented, but either one of them must be *O(1)*, and there's no need for performant `apply`. Is `Vector` the correct choice? Which would you suggest?
0
11,650,306
07/25/2012 13:00:43
1,471,938
06/21/2012 11:25:17
419
21
aws beanstalk us-west ami needed?
I need to build some custom AMIs using Amazon's Elastic Beanstalk amis as a starting point (with Java and Tomcat). I know what the values are for the US, but what are they for the eu-west-1 region?
amazon-web-services
beanstalk
ami
null
null
null
open
aws beanstalk us-west ami needed? === I need to build some custom AMIs using Amazon's Elastic Beanstalk amis as a starting point (with Java and Tomcat). I know what the values are for the US, but what are they for the eu-west-1 region?
0
11,650,307
07/25/2012 13:00:43
1,068,677
11/28/2011 04:03:07
358
23
Is it Blueprint CSS framework out of date?
I want to use blueprint css framework but last version release was over year ago. Neither commits in Github repository. Has it being mantained?
css
blueprint-css
null
null
null
null
open
Is it Blueprint CSS framework out of date? === I want to use blueprint css framework but last version release was over year ago. Neither commits in Github repository. Has it being mantained?
0
11,650,308
07/25/2012 13:00:46
1,192,353
09/30/2011 10:03:40
51
8
page flash after jquery execution in phonegap
/* enter code here */ $( '#signupbtn1' ).live('click',function(event) { $('#header').slideUp('fast'); $('#content').slideDown('fast'); }); just simple code of show hide, but the jquery effect is not smooth in phonegap also the page is blinking after loading.. any idea
jquery
iphone
phonegap
null
null
null
open
page flash after jquery execution in phonegap === /* enter code here */ $( '#signupbtn1' ).live('click',function(event) { $('#header').slideUp('fast'); $('#content').slideDown('fast'); }); just simple code of show hide, but the jquery effect is not smooth in phonegap also the page is blinking after loading.. any idea
0
11,650,309
07/25/2012 13:00:48
57,428
01/21/2009 08:23:46
73,918
1,754
May I have a full list of Windows Azure Diagnostics performance counter name?
When enabling performance counters in Windows Azure Diagnostics I have to specify the counters using some magic string literals like `\Processor(_Total)\% Processor Time`. I can't find a list of possible string literals. Is there a list anywhere?
windows
performance
azure
performance-counters
windows-azure-diagnostics
null
open
May I have a full list of Windows Azure Diagnostics performance counter name? === When enabling performance counters in Windows Azure Diagnostics I have to specify the counters using some magic string literals like `\Processor(_Total)\% Processor Time`. I can't find a list of possible string literals. Is there a list anywhere?
0
11,650,310
07/25/2012 13:00:52
1,546,655
07/23/2012 18:32:59
1
0
TomCat Hardware minimum specs and suggested specs
Management has asked me to "google" and find the minimum/suggested hardware specs for a Tomcat server. I don't know what applications will be on the server, or how many applications. We have about 50 Lotus Notes applications, which are mostly just document repositories, that we will be re-writing. The applications could have anywhere from 5 users to 50 users. We also have about 20 VB6 apps that will be rewritten. Most of them only have 2-10 users each. I know it isn't much information, but there asking me to get some info. thanks
tomcat
null
null
null
null
07/28/2012 10:57:17
off topic
TomCat Hardware minimum specs and suggested specs === Management has asked me to "google" and find the minimum/suggested hardware specs for a Tomcat server. I don't know what applications will be on the server, or how many applications. We have about 50 Lotus Notes applications, which are mostly just document repositories, that we will be re-writing. The applications could have anywhere from 5 users to 50 users. We also have about 20 VB6 apps that will be rewritten. Most of them only have 2-10 users each. I know it isn't much information, but there asking me to get some info. thanks
2
11,471,476
07/13/2012 13:28:36
1,492,955
06/30/2012 11:58:25
1
0
Audio Stream buffers within 8 secs on Emulator but takes almost 50 secs to buffer on a Phone
I have tried the code on the emulator using Platform 2.2 API level 8 as well as an Emulator using Platform 4.0.3 using API level 15 .. it works perfectly and starts the stream in about 5 secs. But when i run the code on my HTC one x (Android Version 4.0.3)or tried running it on the HTC Desire S(Android Version 2.3.5) Here is my code public static MediaPlayer mp; public String url = "http://vprbbc.streamguys.net:80/vprbbc24.mp3"; public void onCreate(Bundle savedInstanceState) { mp = new MediaPlayer(); try { mp.setDataSource(url); mp.setOnErrorListener(this); mp.setOnPreparedListener(this); mp.prepareAsync(); } catch(IOException e){ e.printStackTrace(); } } // close of onCreate public void onPrepared(MediaPlayer player) { mp.start(); } Please help - i need this working soon.
android
audio
mediaplayer
audio-streaming
android-mediaplayer
null
open
Audio Stream buffers within 8 secs on Emulator but takes almost 50 secs to buffer on a Phone === I have tried the code on the emulator using Platform 2.2 API level 8 as well as an Emulator using Platform 4.0.3 using API level 15 .. it works perfectly and starts the stream in about 5 secs. But when i run the code on my HTC one x (Android Version 4.0.3)or tried running it on the HTC Desire S(Android Version 2.3.5) Here is my code public static MediaPlayer mp; public String url = "http://vprbbc.streamguys.net:80/vprbbc24.mp3"; public void onCreate(Bundle savedInstanceState) { mp = new MediaPlayer(); try { mp.setDataSource(url); mp.setOnErrorListener(this); mp.setOnPreparedListener(this); mp.prepareAsync(); } catch(IOException e){ e.printStackTrace(); } } // close of onCreate public void onPrepared(MediaPlayer player) { mp.start(); } Please help - i need this working soon.
0
11,471,485
07/13/2012 13:28:58
1,178,152
01/30/2012 13:32:53
11
0
php PRINTF parse error
I'm getting the error Parse error: parse error in C:\wamp\www\wp-content\themes\yoko\child-category.php on line 14 this is the printf function i'm trying to use. What is wrong here? <h1 class="page-title"><?php printf( __( 'Watch %s', 'yoko' ), '<span class = "cat_tit">'. get_category_parents($cat, TRUE, ' &raquo; ') . single_cat_title( '', false ) . '</span> Online' ); ?></h1> I tried added commas and periods but couldn't fix it.
php
parsing
printf
null
null
null
open
php PRINTF parse error === I'm getting the error Parse error: parse error in C:\wamp\www\wp-content\themes\yoko\child-category.php on line 14 this is the printf function i'm trying to use. What is wrong here? <h1 class="page-title"><?php printf( __( 'Watch %s', 'yoko' ), '<span class = "cat_tit">'. get_category_parents($cat, TRUE, ' &raquo; ') . single_cat_title( '', false ) . '</span> Online' ); ?></h1> I tried added commas and periods but couldn't fix it.
0
11,471,486
07/13/2012 13:28:59
1,140,828
01/10/2012 12:28:59
218
4
Facebook app compromised/hacked
I haven't used my facebook app for a while, and when I tried to access it today, it didn't want to load. When I disabled secure browsing, Chrome gave me the following warning when I loaded the app from the canvas url: "apps.facebook.com contains content from methuenedge.com, a site known to distribute malware. Your computer might catch a virus if you visit this site." How can I solve this issue? Could my app secret have been compromised? If so, and if I need to reset my app secret, will current users of my app still have access to it or do they need to re-install? Thank You
facebook
null
null
null
null
null
open
Facebook app compromised/hacked === I haven't used my facebook app for a while, and when I tried to access it today, it didn't want to load. When I disabled secure browsing, Chrome gave me the following warning when I loaded the app from the canvas url: "apps.facebook.com contains content from methuenedge.com, a site known to distribute malware. Your computer might catch a virus if you visit this site." How can I solve this issue? Could my app secret have been compromised? If so, and if I need to reset my app secret, will current users of my app still have access to it or do they need to re-install? Thank You
0
11,471,491
07/13/2012 13:29:23
1,243,960
03/01/2012 23:30:42
250
1
How to use alias and sum them together in select query
I have the following queries below. I'd like to use the aliases and add them together but SQL does not allow that. Any suggestions on how I can go about this without repeating the queries again? Using Microsoft SQL Server 2008 SELECT SUM(CASE WHEN rg.category = 'Space' THEN ((rg.score*20)) END) As space, SUM(CASE WHEN rg.category = 'QPR' THEN ((rg.score*20)) END) As qpr, (space + qpr) As result FROM rg_fin As rg JOIN...../*query goes on*/
sql
database
query
select
null
null
open
How to use alias and sum them together in select query === I have the following queries below. I'd like to use the aliases and add them together but SQL does not allow that. Any suggestions on how I can go about this without repeating the queries again? Using Microsoft SQL Server 2008 SELECT SUM(CASE WHEN rg.category = 'Space' THEN ((rg.score*20)) END) As space, SUM(CASE WHEN rg.category = 'QPR' THEN ((rg.score*20)) END) As qpr, (space + qpr) As result FROM rg_fin As rg JOIN...../*query goes on*/
0
11,471,494
07/13/2012 13:29:44
1,474,682
06/22/2012 11:36:20
22
0
Website hosting with a VPS - need some answers
I'm a fairly talented web developer now and I would like to start undertaking freelance work. Obviously, I want to be professional and offer website hosting as well. Now as a student, I don't have the money or my own property to run a web server. My question concerns a VPS. I really can't wrap my head around how they work. I've been looking at a few and what I want to know is the stages involved in hosting a website with a VPS. What I'm confused over: 1) Do I buy a domain name from 123.reg for example or via my VPS interface? 2) How to get my .html and .css and .js files onto the VPS? - is there some kind of UI provided 3) Any recommendations on a good VPS to host purely client side web pages HTML, CSS, Javascript (I'm a mac user) I'm not even sure these are the steps but can someone shed some light on what I have to do to be able to offer hosting. Very confused!
javascript
html
css
web
vps
07/13/2012 13:50:13
off topic
Website hosting with a VPS - need some answers === I'm a fairly talented web developer now and I would like to start undertaking freelance work. Obviously, I want to be professional and offer website hosting as well. Now as a student, I don't have the money or my own property to run a web server. My question concerns a VPS. I really can't wrap my head around how they work. I've been looking at a few and what I want to know is the stages involved in hosting a website with a VPS. What I'm confused over: 1) Do I buy a domain name from 123.reg for example or via my VPS interface? 2) How to get my .html and .css and .js files onto the VPS? - is there some kind of UI provided 3) Any recommendations on a good VPS to host purely client side web pages HTML, CSS, Javascript (I'm a mac user) I'm not even sure these are the steps but can someone shed some light on what I have to do to be able to offer hosting. Very confused!
2
11,471,496
07/13/2012 13:29:56
977,828
10/04/2011 05:14:05
23
1
Alternative way to threads under Android
Android's Java and Oracle's Java are slightly different. Is it possible to use the following actors or coroutines * http://code.google.com/p/jetlang/ * http://incubator.apache.org/s4/ * http://www.malhar.net/sriram/kilim/ * http://code.google.com/p/coroutines/ also for Android in order to avoid to use threads and share more code between Android's Java and Oracle's Java? Are there other frameworks available for both Java versions. Thank you in advance.
android
multithreading
parallel-processing
actor
coroutine
null
open
Alternative way to threads under Android === Android's Java and Oracle's Java are slightly different. Is it possible to use the following actors or coroutines * http://code.google.com/p/jetlang/ * http://incubator.apache.org/s4/ * http://www.malhar.net/sriram/kilim/ * http://code.google.com/p/coroutines/ also for Android in order to avoid to use threads and share more code between Android's Java and Oracle's Java? Are there other frameworks available for both Java versions. Thank you in advance.
0
11,471,497
07/13/2012 13:30:03
1,523,569
07/13/2012 12:43:33
1
0
Make Zip code boundaries in Google Map API
****I have seen all the responses to a similar question, however, they are all either old, or no one has answered them**** I have been given a task to obtain zip codes and display there corresponding boundaries to the user on a google map. Such as this example: http://maps.huge.info/zip.htm I am writing this code in JavaScript and using Google Map API. ***I simply want user to input a zip code and a marker drops down to their destination with a border representing that zip code area.*** I see that Google map currently has something in their map code that allows one to see the boundaries if someone puts a zip code on maps.google.com. I have used polygons but this wouldn't help make a border around a certain zip code. Any suggestions on how to obtain this? Thanks in advance!
javascript
google-maps
google
google-maps-api-3
zipcode
null
open
Make Zip code boundaries in Google Map API === ****I have seen all the responses to a similar question, however, they are all either old, or no one has answered them**** I have been given a task to obtain zip codes and display there corresponding boundaries to the user on a google map. Such as this example: http://maps.huge.info/zip.htm I am writing this code in JavaScript and using Google Map API. ***I simply want user to input a zip code and a marker drops down to their destination with a border representing that zip code area.*** I see that Google map currently has something in their map code that allows one to see the boundaries if someone puts a zip code on maps.google.com. I have used polygons but this wouldn't help make a border around a certain zip code. Any suggestions on how to obtain this? Thanks in advance!
0
11,471,501
07/13/2012 13:30:11
1,306,351
04/01/2012 13:45:35
84
0
SUM of a table's field whether a user exists or not
I have a script to count a users points in a simple achievements type script, then display them on a web page in order. I have the following mySQL function, but if a user doesn't have any points as yet (i.e there is no 'pa.userid' to be found, then the user does not get fetched at all) SELECT u.userid, SUM(IF(pa.plus = '1', pa.points_amount, 0)) - SUM(IF(pa.plus = '0', pa.points_amount, 0)) AS points FROM awarded_points pa, users u WHERE u.userid = pa.userid GROUP BY u.userid ORDER BY points DESC LIMIT 10 How would i go about making the above code include users that haven't yet got any points? Is it a complicated change?
mysql
sum
null
null
null
null
open
SUM of a table's field whether a user exists or not === I have a script to count a users points in a simple achievements type script, then display them on a web page in order. I have the following mySQL function, but if a user doesn't have any points as yet (i.e there is no 'pa.userid' to be found, then the user does not get fetched at all) SELECT u.userid, SUM(IF(pa.plus = '1', pa.points_amount, 0)) - SUM(IF(pa.plus = '0', pa.points_amount, 0)) AS points FROM awarded_points pa, users u WHERE u.userid = pa.userid GROUP BY u.userid ORDER BY points DESC LIMIT 10 How would i go about making the above code include users that haven't yet got any points? Is it a complicated change?
0
11,471,502
07/13/2012 13:30:11
540,587
12/13/2010 13:56:05
128
6
Can I deploy CakePHP web application and BottlePy base WebServices API on same server?
I have a CakePHP based web application deployed on Apache (LAMP stack). Now I am doing a Web Services API using bottlePy that will expose services to be consumed by an Android application. The thing is both the applications will be working of the same MySql DB tables and reading/writing to the same. The reason its been done this way is because the CakaPHP based application is already available and was done a while back. Now we have a need to do an Android app and hence need to expose a Web Services API and since I am more comfortable with Python I would rather use. But before I dive deep in this direction I wanted to get answer to the following: 1. Can I have both the CakePHP web app and BottlePy based Web Services API served from the same Apache server? If not what will be an alternate? 2. Will two different apps accessing the same MySQL DB cause any issues in terms of locks, data integrity etc? 3. Anything else I need to be careful about?
web-services
apache
cakephp
web-applications
bottle
null
open
Can I deploy CakePHP web application and BottlePy base WebServices API on same server? === I have a CakePHP based web application deployed on Apache (LAMP stack). Now I am doing a Web Services API using bottlePy that will expose services to be consumed by an Android application. The thing is both the applications will be working of the same MySql DB tables and reading/writing to the same. The reason its been done this way is because the CakaPHP based application is already available and was done a while back. Now we have a need to do an Android app and hence need to expose a Web Services API and since I am more comfortable with Python I would rather use. But before I dive deep in this direction I wanted to get answer to the following: 1. Can I have both the CakePHP web app and BottlePy based Web Services API served from the same Apache server? If not what will be an alternate? 2. Will two different apps accessing the same MySQL DB cause any issues in terms of locks, data integrity etc? 3. Anything else I need to be careful about?
0
11,471,504
07/13/2012 13:30:13
472,695
10/11/2010 21:15:06
683
19
Forcing unordered struct fields in C
I'm working on rewriting translator of object-oriented language into C for optimizing puproses and I've run into design issue. Consider following class in pseudo-language: class C { int a; double b; int c; constructor C(int value) { this.a = value; this.b = this.a / 10.0; this.c = 0; } void say() { print(this.b); } } When going straightforward, we can express this class as struct like that (skipping error checks): typedef struct { int a; double b; int c; } _class_C; _class_C* _ctor_C(int value) { this = malloc(sizeof(_class_C)); this->a = value; this->b = this->a / 10.0; this->c = 0; return this; } void _method_C_say(_class_C *this) { printf("%.2f", this->b); } void _dtor_C(_class_C *this) { free(this); } This solution suffers from the promise C compilers are bound with — do not add, remove or change order of fields in struct. So despite the fact fields `a` and `c` are not used, they will bloat the code. **How can I achieve "unordered fields" behavior?** If I had only one static `C`, it could be written as follows: int _staticfield_C_a; double _staticfield_C_b; int _staticfield_C_c; void _ctor_C(int value) { _staticfield_C_a = value; _staticfield_C_b = _staticfield_C_a / 10.0; _staticfield_C_c = 0; } void _staticmethod_C_say() { printf("%.2f", _staticfield_C_b); } so compiler can optimize out redundant or unused fields up to sole `_staticfield_C_b`, but what solution should I use when `C` can be instantiated in dynamic, and I don't mind the order of fields, memory layout and code human-readability at all?
c
optimization
data-structures
struct
null
null
open
Forcing unordered struct fields in C === I'm working on rewriting translator of object-oriented language into C for optimizing puproses and I've run into design issue. Consider following class in pseudo-language: class C { int a; double b; int c; constructor C(int value) { this.a = value; this.b = this.a / 10.0; this.c = 0; } void say() { print(this.b); } } When going straightforward, we can express this class as struct like that (skipping error checks): typedef struct { int a; double b; int c; } _class_C; _class_C* _ctor_C(int value) { this = malloc(sizeof(_class_C)); this->a = value; this->b = this->a / 10.0; this->c = 0; return this; } void _method_C_say(_class_C *this) { printf("%.2f", this->b); } void _dtor_C(_class_C *this) { free(this); } This solution suffers from the promise C compilers are bound with — do not add, remove or change order of fields in struct. So despite the fact fields `a` and `c` are not used, they will bloat the code. **How can I achieve "unordered fields" behavior?** If I had only one static `C`, it could be written as follows: int _staticfield_C_a; double _staticfield_C_b; int _staticfield_C_c; void _ctor_C(int value) { _staticfield_C_a = value; _staticfield_C_b = _staticfield_C_a / 10.0; _staticfield_C_c = 0; } void _staticmethod_C_say() { printf("%.2f", _staticfield_C_b); } so compiler can optimize out redundant or unused fields up to sole `_staticfield_C_b`, but what solution should I use when `C` can be instantiated in dynamic, and I don't mind the order of fields, memory layout and code human-readability at all?
0
11,471,175
07/13/2012 13:09:42
359,650
06/06/2010 11:30:22
548
6
How to dynamically attach a function to an object
*I know there are a few similar questions already on `SO` ([1][1], [2][2], [3][3]) but unfortunately my limited knowledge of `JS` doesn't allow me to extrapolate the scenarios to my personal use case, hence this question.* I have the following piece of code which allows me to dynamically attach to and call from an object some functions, which works fine ([available on `JsFiddle`][4]): **JavaScript**: $.extend(true, window, { "MyPlugin": { "dynamicFunction": dummy_function } }); function dummy_function() { } function real_function(string) { alert(string); } function dynamic_call(function_name, text) { MyPlugin["dynamicFunction"] = eval(function_name); MyPlugin["dynamicFunction"](text); }​ **HTML:** <button onClick="dynamic_call('real_function','some text');">click me</button>​ **How can I achieve the same functionality without the use of `eval`?** [1]: http://stackoverflow.com/questions/676721/calling-dynamic-function-with-dynamic-parameters-in-javascript [2]: http://stackoverflow.com/questions/10419538/javascript-dynamic-function-name [3]: http://stackoverflow.com/questions/9644246/javascript-dynamically-attaching-functions-to-objects [4]: http://jsfiddle.net/DHPHB/3/
javascript
function
object
dynamic
null
null
open
How to dynamically attach a function to an object === *I know there are a few similar questions already on `SO` ([1][1], [2][2], [3][3]) but unfortunately my limited knowledge of `JS` doesn't allow me to extrapolate the scenarios to my personal use case, hence this question.* I have the following piece of code which allows me to dynamically attach to and call from an object some functions, which works fine ([available on `JsFiddle`][4]): **JavaScript**: $.extend(true, window, { "MyPlugin": { "dynamicFunction": dummy_function } }); function dummy_function() { } function real_function(string) { alert(string); } function dynamic_call(function_name, text) { MyPlugin["dynamicFunction"] = eval(function_name); MyPlugin["dynamicFunction"](text); }​ **HTML:** <button onClick="dynamic_call('real_function','some text');">click me</button>​ **How can I achieve the same functionality without the use of `eval`?** [1]: http://stackoverflow.com/questions/676721/calling-dynamic-function-with-dynamic-parameters-in-javascript [2]: http://stackoverflow.com/questions/10419538/javascript-dynamic-function-name [3]: http://stackoverflow.com/questions/9644246/javascript-dynamically-attaching-functions-to-objects [4]: http://jsfiddle.net/DHPHB/3/
0
11,349,389
07/05/2012 17:24:12
1,489,861
06/28/2012 22:14:17
1
0
How to detect tomcat context reload
I have a config.properties file to store Credentials and IP address for my application as Key Value pairs. However writes to this properties file reloads the application context in tomcat. I am writing to properties file as below URL propUrl=this.getClass().getClassLoader().getResource(PROPERTIES_FILE); prop.store(new FileOutputStream(propUrl.getPath()), null); So, 1.) Is there a way to detect a tomcat context reload in Java. or 2.) Is there a way to prevent context reload and read the config.properties file
java
tomcat
web-applications
null
null
null
open
How to detect tomcat context reload === I have a config.properties file to store Credentials and IP address for my application as Key Value pairs. However writes to this properties file reloads the application context in tomcat. I am writing to properties file as below URL propUrl=this.getClass().getClassLoader().getResource(PROPERTIES_FILE); prop.store(new FileOutputStream(propUrl.getPath()), null); So, 1.) Is there a way to detect a tomcat context reload in Java. or 2.) Is there a way to prevent context reload and read the config.properties file
0
11,349,397
07/05/2012 17:24:57
1,222,665
02/21/2012 06:02:20
13
0
Setting up Blackberry Project(above version 5) in Phonegap using IDE to implement push notification.
Hi I am developing a mobile app using phonegap for android, iphone and blackberry platforms and .I need the notification should be invoked from J2EE server to BB when a new message gets created .. This means J2EE server pushes the notification and BB mobile device gets the notification I need to put a push notification feature in my app, so that my server can poll my app and then put the notification if there is any new notification. On browsing the net i found out that there are plugins for phonegap for both iphone and android which help in showing the notification.But did not find any useful resources for Blackberry.:( I am following http://docs.blackberry.com/en/developers/deliverables/30152/Push_Service_SDK-Installation_and_Configuration_Guide--1648741-0622124431-001-1.1.0.16-US.pdf But facing some environment challenge (Setting up SDK in IDE for Blackberry in phonegap). To use that SDk we need the IDE, but using ant I think it not possible . I need some sample examples for creating the Phonegap project for Blackberry using IDE. I want to get a push notification in Blackberry using phonegap can some one help me in performing this or any links which explains this with html,js is really helpful. Thank you.
blackberry
phonegap
push-notification
phonegap-plugins
null
null
open
Setting up Blackberry Project(above version 5) in Phonegap using IDE to implement push notification. === Hi I am developing a mobile app using phonegap for android, iphone and blackberry platforms and .I need the notification should be invoked from J2EE server to BB when a new message gets created .. This means J2EE server pushes the notification and BB mobile device gets the notification I need to put a push notification feature in my app, so that my server can poll my app and then put the notification if there is any new notification. On browsing the net i found out that there are plugins for phonegap for both iphone and android which help in showing the notification.But did not find any useful resources for Blackberry.:( I am following http://docs.blackberry.com/en/developers/deliverables/30152/Push_Service_SDK-Installation_and_Configuration_Guide--1648741-0622124431-001-1.1.0.16-US.pdf But facing some environment challenge (Setting up SDK in IDE for Blackberry in phonegap). To use that SDk we need the IDE, but using ant I think it not possible . I need some sample examples for creating the Phonegap project for Blackberry using IDE. I want to get a push notification in Blackberry using phonegap can some one help me in performing this or any links which explains this with html,js is really helpful. Thank you.
0
11,349,404
07/05/2012 17:25:35
1,004,959
10/20/2011 10:11:04
133
2
DataRow.RowError is not getting copied when using DataTable.Load
I have to copy rows from one table to another. In the source table I can have RowError set on rows. When I do this: targetTable.BeginLoadData(); targetTable.Load( new DataTableReader( sourceTable ) ) targetTable.EndLoadData(); The target table does not get row errors copied on its rows from source table. Can anyone tell what am I supposed to do to make it work? Thanks.
c#
.net
ado.net
datatable
null
null
open
DataRow.RowError is not getting copied when using DataTable.Load === I have to copy rows from one table to another. In the source table I can have RowError set on rows. When I do this: targetTable.BeginLoadData(); targetTable.Load( new DataTableReader( sourceTable ) ) targetTable.EndLoadData(); The target table does not get row errors copied on its rows from source table. Can anyone tell what am I supposed to do to make it work? Thanks.
0
11,317,257
07/03/2012 18:49:53
1,123,123
12/30/2011 15:26:07
809
80
Windows-Mobile perform action after form is shown.
I am developing a windows mobile application, and I want to do something after a form (a loading screen) is displayed to the user. normally, I have a Form.Shown event, but with the .net compact framework v3.5, I can't find this event. Does anyone know of an equivalent to the Shown event or a simple workaround I could use? I don't want to do my own multi-threading if I can help it.
c#
winforms
events
compact-framework
windows-mobile-6.5
null
open
Windows-Mobile perform action after form is shown. === I am developing a windows mobile application, and I want to do something after a form (a loading screen) is displayed to the user. normally, I have a Form.Shown event, but with the .net compact framework v3.5, I can't find this event. Does anyone know of an equivalent to the Shown event or a simple workaround I could use? I don't want to do my own multi-threading if I can help it.
0
11,317,259
07/03/2012 18:49:58
1,044,665
11/13/2011 22:24:30
12
0
Complicated crystal report help - Semicolon in the database field value
i have a database column named Firstname and Categories. FirstName | Categories Mike | Blue; Green ; Red Peter | Green; Red Paul | Red; Blue I want to generate a report in this format **Blue :** Mike Paul **Green:** Mike Peter **Red:** Peter Paul The problem is i cannot change the access database column value, it has to have a semicolon to sepearte the values. How can i acheive this ?? I am using crystal reports and i am not a pro user, but i learn stuff easily. Any help will be appreciated. Thank you!
ms-access
crystal-reports
report
null
null
null
open
Complicated crystal report help - Semicolon in the database field value === i have a database column named Firstname and Categories. FirstName | Categories Mike | Blue; Green ; Red Peter | Green; Red Paul | Red; Blue I want to generate a report in this format **Blue :** Mike Paul **Green:** Mike Peter **Red:** Peter Paul The problem is i cannot change the access database column value, it has to have a semicolon to sepearte the values. How can i acheive this ?? I am using crystal reports and i am not a pro user, but i learn stuff easily. Any help will be appreciated. Thank you!
0
11,406,862
07/10/2012 04:58:11
1,494,968
07/02/2012 01:41:07
1
0
I am now being parsed using SAX
I am now being parsed using SAX. my source code : class SAXParser extends DefaultHandler { static int i = 0; ArrayList<ArrayList<String>> ar = new ArrayList<ArrayList<String>>(); ArrayList<String> id = new ArrayList<String>(); public void startElement(String uri, String localName, String qName, Attributes atts) { if (qName.equals("row")) { int idx = 0; id.add(idx, atts.getValue(0)); idx++; id.add(idx, atts.getValue(3)); ar.add(i, id); i++; //idx = 0; } } } So, For example, XML file is <users> <row Id="-1" DisplayName="Apple"> <row ID="1" DisplayName="Banana"> <row ID="2" DisplayName="Orange"> </users> If you run the program over, result is [2,Orange,1,Banana,-1,Apple], [2,Orange,1,Banana,-1,Apple], [2,Orange,1,Banana,-1,Apple], [2,Orange,1,Banana,-1,Apple] in ar So, I want that result is [-1, Apple], [1, Banana], [2, Orange] in ar. Somebody help me.
java
parsing
sax
null
null
null
open
I am now being parsed using SAX === I am now being parsed using SAX. my source code : class SAXParser extends DefaultHandler { static int i = 0; ArrayList<ArrayList<String>> ar = new ArrayList<ArrayList<String>>(); ArrayList<String> id = new ArrayList<String>(); public void startElement(String uri, String localName, String qName, Attributes atts) { if (qName.equals("row")) { int idx = 0; id.add(idx, atts.getValue(0)); idx++; id.add(idx, atts.getValue(3)); ar.add(i, id); i++; //idx = 0; } } } So, For example, XML file is <users> <row Id="-1" DisplayName="Apple"> <row ID="1" DisplayName="Banana"> <row ID="2" DisplayName="Orange"> </users> If you run the program over, result is [2,Orange,1,Banana,-1,Apple], [2,Orange,1,Banana,-1,Apple], [2,Orange,1,Banana,-1,Apple], [2,Orange,1,Banana,-1,Apple] in ar So, I want that result is [-1, Apple], [1, Banana], [2, Orange] in ar. Somebody help me.
0
11,409,641
07/10/2012 08:44:14
1,465,402
06/19/2012 05:05:53
6
0
quartz scheduler 1.6.6 do not fire the task sometime without any exception
we originally using quartz 1.5.X, it works property, now when we upgrade to quartz 1.6.6, this issue occurred, we're using -cluster environment, -jdbcjobstorecmp -this issue happens sometime, when I execute the same job at another terminal while hung, throw org.quartz.ObjectAlreadyExistsException -after some analysis seem XXXJob.execute not get called By cross checking our code, logs and database, I found the XXXJob.Execute(JobExecutionContext context) not get called. does anyone know is there a know issue of quartz 1.6.6 ?
quartz-scheduler
null
null
null
null
null
open
quartz scheduler 1.6.6 do not fire the task sometime without any exception === we originally using quartz 1.5.X, it works property, now when we upgrade to quartz 1.6.6, this issue occurred, we're using -cluster environment, -jdbcjobstorecmp -this issue happens sometime, when I execute the same job at another terminal while hung, throw org.quartz.ObjectAlreadyExistsException -after some analysis seem XXXJob.execute not get called By cross checking our code, logs and database, I found the XXXJob.Execute(JobExecutionContext context) not get called. does anyone know is there a know issue of quartz 1.6.6 ?
0
11,409,642
07/10/2012 08:44:16
1,340,565
04/18/2012 06:49:10
34
0
Disable Back Home button Android 3.1
I have an application running on Samsung Galaxy Tab 8.9 Android 3.1. I have to disable Back button. I know that <category android:name="android.intent.category.HOME" /> disables the Home button. But i dont want to disable the Home button, only the Back button i want to disable. Thanks everyone..
android
disable
back-button
android-3.1
null
null
open
Disable Back Home button Android 3.1 === I have an application running on Samsung Galaxy Tab 8.9 Android 3.1. I have to disable Back button. I know that <category android:name="android.intent.category.HOME" /> disables the Home button. But i dont want to disable the Home button, only the Back button i want to disable. Thanks everyone..
0
11,410,242
07/10/2012 09:20:50
906,329
08/22/2011 17:01:19
3
1
What is the best practice for formatting parameters in web service operations?
If a operation in a given web service accept a parameter, which should be in a given format, what is the best practice of handling this scenario (where do we format the parameter) ? There are 2 place where the formatting can be done. 1. At the consumer's end 2. Within the web service operation Please make your suggestions.
service
parameters
formatting
practice
best-in-place
null
open
What is the best practice for formatting parameters in web service operations? === If a operation in a given web service accept a parameter, which should be in a given format, what is the best practice of handling this scenario (where do we format the parameter) ? There are 2 place where the formatting can be done. 1. At the consumer's end 2. Within the web service operation Please make your suggestions.
0
3,102,756
06/23/2010 14:55:24
234,304
12/18/2009 03:59:24
101
4
Serialize a django-haystack queryset
I want to export the results I have in a Queryset that I obtain from a haystack search view. In order to do this, I've found the best way is by doing it asyncronally, so I'm using Celery and Rabbitmq to manage the task and there create the file and iterate over all the results and then notify the user via email that the file is ready for them to grab it. However, in order to pass Celery the QuerySet, I need to serialize it. Is there a quick way to do this? Or should I copy the request parameters and redo the search?
django
django-haystack
null
null
null
null
open
Serialize a django-haystack queryset === I want to export the results I have in a Queryset that I obtain from a haystack search view. In order to do this, I've found the best way is by doing it asyncronally, so I'm using Celery and Rabbitmq to manage the task and there create the file and iterate over all the results and then notify the user via email that the file is ready for them to grab it. However, in order to pass Celery the QuerySet, I need to serialize it. Is there a quick way to do this? Or should I copy the request parameters and redo the search?
0
3,102,758
06/23/2010 14:55:35
1,569
08/16/2008 18:38:06
3,590
99
How can I use two different databases with Linq to SQL?
I'm starting out with Linq To SQL, fiddling around with Linqpad and I'm trying to duplicate a SQL script which joins on tables in separate databases on the same server (SQL Server 2008). The TSQL query looks approximately like this: using MainDatabase go insert Event_Type(code, description) select distinct t1.code_id, t2.desc from OtherDatabase..codes t1 left join OtherDatabase..lookup t2 on t1.key_id = t2.key_id and t2.category = 'Action 7' where t2.desc is not null I'm basically trying to figure out how to do a cross-database insertion. Is this possible with Linq To SQL (and is it possible in Linqpad?)
sql-server
linq
linq-to-sql
tsql
linqpad
null
open
How can I use two different databases with Linq to SQL? === I'm starting out with Linq To SQL, fiddling around with Linqpad and I'm trying to duplicate a SQL script which joins on tables in separate databases on the same server (SQL Server 2008). The TSQL query looks approximately like this: using MainDatabase go insert Event_Type(code, description) select distinct t1.code_id, t2.desc from OtherDatabase..codes t1 left join OtherDatabase..lookup t2 on t1.key_id = t2.key_id and t2.category = 'Action 7' where t2.desc is not null I'm basically trying to figure out how to do a cross-database insertion. Is this possible with Linq To SQL (and is it possible in Linqpad?)
0
11,410,111
07/10/2012 09:12:10
662,017
03/16/2011 07:16:59
52
0
Eclipse does not recognize java package
I added my java project to github using the git plugin in eclipse. I even added src directory and committed. After I committed The programs says that that class User which is in the package in.jcap.sanctuary.pojo is not a type. I restarted the project many times, but after committing to the git repository if I create any new class in eclipse I get the same error as above
java
eclipse
git
eclipse-plugin
egit
null
open
Eclipse does not recognize java package === I added my java project to github using the git plugin in eclipse. I even added src directory and committed. After I committed The programs says that that class User which is in the package in.jcap.sanctuary.pojo is not a type. I restarted the project many times, but after committing to the git repository if I create any new class in eclipse I get the same error as above
0
11,567,556
07/19/2012 19:01:19
1,535,794
07/18/2012 18:36:27
6
0
How does Scala handle Java style package statements
This sounds embarrassing. My purpose is to understand how Scala treats package statements, written in the Java style. To this end, I wrote up a little example class (that I named DinnerTimeP.scala as below: package dinnertime class Dinner { val veggie = "broccoli" def announceDinner(veggie: String) { println("Dinner happens to be tasteless " + veggie + " soup") } } I have a folder called scaladev, under which I have created the package folder, dinnertime. Under this package lives DinnerTimeP.scala. On the DOS command I then navigate to dinnertime and compile the file DinnerTimeP (the name sounds silly) with scalac as below. C:\scala-2.9.1.final\scala-2.9.1.final\scaladev\dinnertime>set CLASSPATH=.;C:\scala- 2.9.1.final\scala-2.9.1.final\scaladev C:\scala-2.9.1.final\scala-2.9.1.final\scaladev\dinnertime>scalac DinnerTimeP.scala I was hoping to find Dinner.class generated right under the dinnertime folder and sitting next to the source file DinnerTimeP.scala. To confirm my understanding, I created a HelloWorld.java program under the same folder: package dinnertime; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } } I compiled HelloWorld.java on the command line as follows: C:\scala-2.9.1.final\scala-2.9.1.final\scaladev\dinnertime>javac HelloWorld.java The HelloWorld.class file was generated right next to its source file. This was the exact situation I wanted to see with the Scala source file and its compiled file. Instead I see a new package folder generated by Scala inside the package folder dinnertime. This might be naive. I am probably betraying a fundamental understanding of Scala and packages, but I was perplexed by this behaviour. This is the problem I can't explain to myself: Why is the nested package created for the newly generated class file. This is the problem to which I which I had hoped to solve, based on my own sincere efforts Because my experience with Scala at the present time is limited, I have resorted to asking the Scala gurus on stackoverflow to help me understand what is going on and why? Is there a reason for this nested package to be created by Scala and not by Java?
java
scala
packages
scalac
null
null
open
How does Scala handle Java style package statements === This sounds embarrassing. My purpose is to understand how Scala treats package statements, written in the Java style. To this end, I wrote up a little example class (that I named DinnerTimeP.scala as below: package dinnertime class Dinner { val veggie = "broccoli" def announceDinner(veggie: String) { println("Dinner happens to be tasteless " + veggie + " soup") } } I have a folder called scaladev, under which I have created the package folder, dinnertime. Under this package lives DinnerTimeP.scala. On the DOS command I then navigate to dinnertime and compile the file DinnerTimeP (the name sounds silly) with scalac as below. C:\scala-2.9.1.final\scala-2.9.1.final\scaladev\dinnertime>set CLASSPATH=.;C:\scala- 2.9.1.final\scala-2.9.1.final\scaladev C:\scala-2.9.1.final\scala-2.9.1.final\scaladev\dinnertime>scalac DinnerTimeP.scala I was hoping to find Dinner.class generated right under the dinnertime folder and sitting next to the source file DinnerTimeP.scala. To confirm my understanding, I created a HelloWorld.java program under the same folder: package dinnertime; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } } I compiled HelloWorld.java on the command line as follows: C:\scala-2.9.1.final\scala-2.9.1.final\scaladev\dinnertime>javac HelloWorld.java The HelloWorld.class file was generated right next to its source file. This was the exact situation I wanted to see with the Scala source file and its compiled file. Instead I see a new package folder generated by Scala inside the package folder dinnertime. This might be naive. I am probably betraying a fundamental understanding of Scala and packages, but I was perplexed by this behaviour. This is the problem I can't explain to myself: Why is the nested package created for the newly generated class file. This is the problem to which I which I had hoped to solve, based on my own sincere efforts Because my experience with Scala at the present time is limited, I have resorted to asking the Scala gurus on stackoverflow to help me understand what is going on and why? Is there a reason for this nested package to be created by Scala and not by Java?
0
11,531,409
07/17/2012 21:52:50
1,521,068
07/12/2012 14:20:54
6
0
Copy Table from SQL database to VB.NET database
I have created a database (dbTest) and a table (tblFactSaleZ) in my VB (VS2010) project. I would like to copy a table on our corporate SQL Server to my VB project database. Here's what I've tried, and the results I've received. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim con As SqlConnection = New SqlConnection("Server = ovp-l-r8mxe5m;" & "Initial Catalog = dbTest;" & "Trusted_Connection=TRUE") con.Open() Dim cmdA As SqlCommand = New SqlCommand("SELECT * INTO tblFactSaleZ " & _ "FROM [OVP-S-BPCDEVD].[CMP].[dbo].[tblFactSales] " & _ "WHERE DATATYPE='FORECAST' AND TIMEID='20120700'", con) cmdA.ExecuteNonQuery() MessageBox.Show("Records Moved Successfully.", "Move Complete", _ MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) End Sub RESULT: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
sql
select-into
vb
null
null
08/01/2012 13:45:46
too localized
Copy Table from SQL database to VB.NET database === I have created a database (dbTest) and a table (tblFactSaleZ) in my VB (VS2010) project. I would like to copy a table on our corporate SQL Server to my VB project database. Here's what I've tried, and the results I've received. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim con As SqlConnection = New SqlConnection("Server = ovp-l-r8mxe5m;" & "Initial Catalog = dbTest;" & "Trusted_Connection=TRUE") con.Open() Dim cmdA As SqlCommand = New SqlCommand("SELECT * INTO tblFactSaleZ " & _ "FROM [OVP-S-BPCDEVD].[CMP].[dbo].[tblFactSales] " & _ "WHERE DATATYPE='FORECAST' AND TIMEID='20120700'", con) cmdA.ExecuteNonQuery() MessageBox.Show("Records Moved Successfully.", "Move Complete", _ MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) End Sub RESULT: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
3
11,567,559
07/19/2012 19:01:37
1,492,967
06/30/2012 12:07:31
61
1
How to place one div inside another one?
Im trying to place one div inside another one <div id="test"> <img src="img/sky.jpg"> this is a test </div> function inner(){ var abc = document.getElementById("test"); document.getElementById("main").innerHTML = abc; } </script> It doesn't work. Is it possible at all ?
javascript
html
null
null
null
null
open
How to place one div inside another one? === Im trying to place one div inside another one <div id="test"> <img src="img/sky.jpg"> this is a test </div> function inner(){ var abc = document.getElementById("test"); document.getElementById("main").innerHTML = abc; } </script> It doesn't work. Is it possible at all ?
0
11,567,560
07/19/2012 19:01:45
1,538,830
07/19/2012 18:43:50
1
0
unable to print,no of characters using getchar, in ubuntu
i am new to c, and to ubuntu. i wrote a very simple program to count the no of characters using while and getchar(). The program is: #include <stdio.h> main() { int i; int c= 0; while ( ( i = getchar() ) != EOF ){ c++ ; } printf( "%d characters\n" , c) ; return 0; } i saved it and compiled it using, gcc c1.c -o c1. No errors reported. I executed the program, ./c1 . I give the input as daniweb. and i press enter, but the count is displayed. what went wrong? is it infinte loop? how does getchar() determine EOF when input is given from keyboard?
ubuntu
getchar
null
null
null
null
open
unable to print,no of characters using getchar, in ubuntu === i am new to c, and to ubuntu. i wrote a very simple program to count the no of characters using while and getchar(). The program is: #include <stdio.h> main() { int i; int c= 0; while ( ( i = getchar() ) != EOF ){ c++ ; } printf( "%d characters\n" , c) ; return 0; } i saved it and compiled it using, gcc c1.c -o c1. No errors reported. I executed the program, ./c1 . I give the input as daniweb. and i press enter, but the count is displayed. what went wrong? is it infinte loop? how does getchar() determine EOF when input is given from keyboard?
0
11,567,562
07/19/2012 19:01:54
1,467,188
06/19/2012 17:45:57
34
0
iOS increasing memory usage with two view controllers
I have two ViewControllers.. the first one is a grid of UIButtons, and the second one is a detailed description based on the button they press. I'm expecting that after they press a UIButton, and then press the back button in the navigation bar, the net change in memory should be zero. Instead, I'm seeing an increase in memory, and I have no idea why. What happens when a user clicks the back button? How do I completely dismiss the detailed ViewController, completely releasing it from memory? Is there something specific I have to do? ARC, xcode 4.2.1, iOS 5.0+ Thanks! EDIT: I used the leaks tool, and there were no leaks discovered.
ios
xcode
memory
null
null
null
open
iOS increasing memory usage with two view controllers === I have two ViewControllers.. the first one is a grid of UIButtons, and the second one is a detailed description based on the button they press. I'm expecting that after they press a UIButton, and then press the back button in the navigation bar, the net change in memory should be zero. Instead, I'm seeing an increase in memory, and I have no idea why. What happens when a user clicks the back button? How do I completely dismiss the detailed ViewController, completely releasing it from memory? Is there something specific I have to do? ARC, xcode 4.2.1, iOS 5.0+ Thanks! EDIT: I used the leaks tool, and there were no leaks discovered.
0
11,567,374
07/19/2012 18:49:31
1,516,791
07/11/2012 06:12:38
55
2
How to use git with Symfony 2?
I installed Symfony 2 with Composer (following the 'master' guides), and it created this .git/config file: [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git://github.com/symfony/symfony-standard pushurl = [email protected]:symfony/symfony-standard.git [branch "master"] remote = origin merge = refs/heads/master [remote "composer"] url = git://github.com/symfony/symfony-standard fetch = +refs/heads/*:refs/remotes/composer/* I don't want to interfere with what Composer did here since I don't know how it works, and I want to be able to update the vendors in the future. So how do I add my own repository for 'myapp' and commit/push to it? I usually do 'git remote add origin ...' and only work with that, but now there are two repositories in the file, plus the one I need to add.
php
git
symfony-2.0
null
null
null
open
How to use git with Symfony 2? === I installed Symfony 2 with Composer (following the 'master' guides), and it created this .git/config file: [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git://github.com/symfony/symfony-standard pushurl = [email protected]:symfony/symfony-standard.git [branch "master"] remote = origin merge = refs/heads/master [remote "composer"] url = git://github.com/symfony/symfony-standard fetch = +refs/heads/*:refs/remotes/composer/* I don't want to interfere with what Composer did here since I don't know how it works, and I want to be able to update the vendors in the future. So how do I add my own repository for 'myapp' and commit/push to it? I usually do 'git remote add origin ...' and only work with that, but now there are two repositories in the file, plus the one I need to add.
0
11,567,563
07/19/2012 19:01:57
1,387,523
05/10/2012 15:24:35
1
0
Android NDK JNI Rot13 algorithm not working; same algorithm with gcc works great - ideas?
I am attempting to implement a Rot13 algorithm using the NDK and for all the different ways to manipulate the string buffer, I cannot seem to get the original string buffer to take the new values as the algorithm progresses. The same code works everytime using gcc on linux. I think it may be the optimizer, but adding APP_OPTIM := debug to my Android.mk did not work either. Any ideas or help would be great! #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "FOO", __VA_ARGS__)) jbyteArray Java_NativeUtils_foo(JNIEnv* env, jobject obj, jstring item) { int upper, i, a, c; char p[9]; const char *d; //char *p = item; const char *s = (*env)->GetStringUTFChars(env, item, 0); //len = (*env)->GetStringUTFLength(env, item); //** make a copy strncpy(p, s, 8); p[8] = '\0'; (*env)->ReleaseStringUTFChars(env, item, s); LOGI("GG1"); LOGI(p); for (i=0; p[i] != 0; i++) { LOGI("GG2"); a =~ (int)p[i]; c = ~a-1 / ( ~(a|32) / 13*2-11 ) * 13; p[i] = (char)c; //** for log output d = (const char *)&c; LOGI(d); } LOGI("GG3"); LOGI(p); //** convert back to a Java type jbyteArray out = (*env)->NewByteArray(env, 8); (*env)->SetByteArrayRegion(env, out, 0, 8, (jbyte *)p); LOGI("GG4"); LOGI(out); return out; } output: ( 3521): GG1 ( 3521): 12345693 ( 3521): GG2 ( 3521): 1 ( 3521): GG2 ( 3521): 2 ( 3521): GG2 ( 3521): 3 ( 3521): GG2 ( 3521): 4 ( 3521): GG2 ( 3521): 5 ( 3521): GG2 ( 3521): 6 ( 3521): GG2 ( 3521): 9 ( 3521): GG2 ( 3521): 3 ( 3521): GG3 ( 3521): 12345693 ( 3521): GG4 ( 3521): ?? -( 3521): Rot13 in:12345693... out:12345693... > the input is the same as the output and not shifted by 13 ! > > =============== > GCC version #include <stdio.h> #include <string.h> main(int argc, char** argv) { int upper, i, a, c; char p[9]; char *in; in = argv[1]; strncpy(p, in, 8); p[8] = '\0'; printf("in ...%s... p ...%s...", in, p); for (i=0; p[i] != 0; i++) { a =~ (int)p[i]; c = (~a-1 / ( ~(a|32) / 13*2-11 ) * 13); p[i] = (char)c; } printf("out ...%s...", p); //while(a=~getchar())putchar(~a-1/(~(a|32)/13*2-11)*13);} } > output: > $./a.out Freddy > in ...Freddy... p ...Freddy...out ...Serqql... > > $./a.out Serqql > in ...Serqql... p ...Serqql...out ...Freddy...
android-ndk
jni
null
null
null
null
open
Android NDK JNI Rot13 algorithm not working; same algorithm with gcc works great - ideas? === I am attempting to implement a Rot13 algorithm using the NDK and for all the different ways to manipulate the string buffer, I cannot seem to get the original string buffer to take the new values as the algorithm progresses. The same code works everytime using gcc on linux. I think it may be the optimizer, but adding APP_OPTIM := debug to my Android.mk did not work either. Any ideas or help would be great! #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "FOO", __VA_ARGS__)) jbyteArray Java_NativeUtils_foo(JNIEnv* env, jobject obj, jstring item) { int upper, i, a, c; char p[9]; const char *d; //char *p = item; const char *s = (*env)->GetStringUTFChars(env, item, 0); //len = (*env)->GetStringUTFLength(env, item); //** make a copy strncpy(p, s, 8); p[8] = '\0'; (*env)->ReleaseStringUTFChars(env, item, s); LOGI("GG1"); LOGI(p); for (i=0; p[i] != 0; i++) { LOGI("GG2"); a =~ (int)p[i]; c = ~a-1 / ( ~(a|32) / 13*2-11 ) * 13; p[i] = (char)c; //** for log output d = (const char *)&c; LOGI(d); } LOGI("GG3"); LOGI(p); //** convert back to a Java type jbyteArray out = (*env)->NewByteArray(env, 8); (*env)->SetByteArrayRegion(env, out, 0, 8, (jbyte *)p); LOGI("GG4"); LOGI(out); return out; } output: ( 3521): GG1 ( 3521): 12345693 ( 3521): GG2 ( 3521): 1 ( 3521): GG2 ( 3521): 2 ( 3521): GG2 ( 3521): 3 ( 3521): GG2 ( 3521): 4 ( 3521): GG2 ( 3521): 5 ( 3521): GG2 ( 3521): 6 ( 3521): GG2 ( 3521): 9 ( 3521): GG2 ( 3521): 3 ( 3521): GG3 ( 3521): 12345693 ( 3521): GG4 ( 3521): ?? -( 3521): Rot13 in:12345693... out:12345693... > the input is the same as the output and not shifted by 13 ! > > =============== > GCC version #include <stdio.h> #include <string.h> main(int argc, char** argv) { int upper, i, a, c; char p[9]; char *in; in = argv[1]; strncpy(p, in, 8); p[8] = '\0'; printf("in ...%s... p ...%s...", in, p); for (i=0; p[i] != 0; i++) { a =~ (int)p[i]; c = (~a-1 / ( ~(a|32) / 13*2-11 ) * 13); p[i] = (char)c; } printf("out ...%s...", p); //while(a=~getchar())putchar(~a-1/(~(a|32)/13*2-11)*13);} } > output: > $./a.out Freddy > in ...Freddy... p ...Freddy...out ...Serqql... > > $./a.out Serqql > in ...Serqql... p ...Serqql...out ...Freddy...
0
11,567,564
07/19/2012 19:02:13
1,308,525
04/02/2012 16:26:25
6
0
Magento index page loads but 404 errors on all others
Currently I am struggling with the categories and products showing 404 errors when I navigate away from the working home page. I was able to install Magento and I am using a copy of an existing working site. The purpose is to use this new site as my dev sandbox. I am using Magento 1.11. This is also a multiple store site. Things I have tried: Reindex the Catalog URL Rewrite, this unfortunately never completes. to try and solve this I have deleted all the lock files and then i have also deleted all the entries in the core_url_rewrite table. I have also changed the Base URL in the core_config_data folder to my new url. Thank you in advance!
magento
http-status-code-404
null
null
null
null
open
Magento index page loads but 404 errors on all others === Currently I am struggling with the categories and products showing 404 errors when I navigate away from the working home page. I was able to install Magento and I am using a copy of an existing working site. The purpose is to use this new site as my dev sandbox. I am using Magento 1.11. This is also a multiple store site. Things I have tried: Reindex the Catalog URL Rewrite, this unfortunately never completes. to try and solve this I have deleted all the lock files and then i have also deleted all the entries in the core_url_rewrite table. I have also changed the Base URL in the core_config_data folder to my new url. Thank you in advance!
0
11,567,522
07/19/2012 18:59:05
1,232,048
02/25/2012 03:35:59
104
4
Javascript object literal inside object literal
In the following JavaScript example, are we seeing 2 object literals as properties of an object literal? dw_Tooltip.content_vars = { link1: { img: 'images/dw-btn.gif', txt: 'dyn-web button', w: 100 }, link2: { img: 'images/dot-com-btn.gif', txt: 'dyn-web.com button', w: 184 } }
javascript
oop
object
null
null
07/20/2012 01:52:45
not a real question
Javascript object literal inside object literal === In the following JavaScript example, are we seeing 2 object literals as properties of an object literal? dw_Tooltip.content_vars = { link1: { img: 'images/dw-btn.gif', txt: 'dyn-web button', w: 100 }, link2: { img: 'images/dot-com-btn.gif', txt: 'dyn-web.com button', w: 184 } }
1
11,262,056
06/29/2012 12:46:42
1,357,113
04/25/2012 19:57:48
79
3
Each element of JSON array on new line in HTML using XSLT
I create a JSON object in my XSLT stylesheet. It's difficult to read by eye when viewing the HTML source. I'm wondering if there's a way in my XSLT template to cause a visual line break so each `{...},` is on a new line. It would make it so much easier to read by eye... Currently: [{ .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }] Desired: [ { .... }, { .... }, { .... }, { .... }, etc., etc. ] I'm not sure what to do in XSLT that would cause the break and then I'm sure there is something JSON requires for the break to be valid?
asp.net
json
xslt-1.0
null
null
null
open
Each element of JSON array on new line in HTML using XSLT === I create a JSON object in my XSLT stylesheet. It's difficult to read by eye when viewing the HTML source. I'm wondering if there's a way in my XSLT template to cause a visual line break so each `{...},` is on a new line. It would make it so much easier to read by eye... Currently: [{ .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }, { .... }] Desired: [ { .... }, { .... }, { .... }, { .... }, etc., etc. ] I'm not sure what to do in XSLT that would cause the break and then I'm sure there is something JSON requires for the break to be valid?
0
11,262,057
06/29/2012 12:46:44
1,014,732
10/26/2011 14:13:10
16
0
How to reuse a custom form made in SPD in a VS web template?
I have created a custom newform.aspx for one of my SharePoint lists, I would like to use this newform.aspx in my Visual Studio web template, how can I do ? I've looked for the for to include it in a mapped folder but I couldn't find it. Thank you for your help or ideas :)
sharepoint
sharepoint-designer
null
null
null
null
open
How to reuse a custom form made in SPD in a VS web template? === I have created a custom newform.aspx for one of my SharePoint lists, I would like to use this newform.aspx in my Visual Studio web template, how can I do ? I've looked for the for to include it in a mapped folder but I couldn't find it. Thank you for your help or ideas :)
0
11,262,067
06/29/2012 12:47:28
641,409
03/02/2011 15:00:21
59
3
Rails app: Reconnect juggernaut redis after forking?
I'm working on a Rails app that is using [Juggernaut](https://github.com/maccman/juggernaut) to push data to clients at regular intervals. I use a controller action to get the pushing started; but since the pushing is often a long process (10 minutes or more), I am using spawn to fork the task. For example: def start_pushing spawn_block(:argv => "juggernaut-pushing") do for x in y Juggernaut.publish(stuff in here) sleep(30) # delay before publishing next item end end end The problem is that I find this error in the log file when I hit the start_pushing action: spawn> Exception in child[27898] - Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking. So I added the following right inside the spawn_block, hoping it would fix the problem: require 'redis' $redis.client.disconnect $redis = Redis.new(:host => 'localhost', :port => 6379) It didn't seem to fix it, though the action has been working intermittently even before I added this to reset $redis. I'm thinking that perhaps resetting $redis isn't doing anything; Juggernaut is still accessing an old connection. Does that seem likely? How would I make sure that Juggernaut uses a new Redis connection? Please let me know of any questions about what I'm describing. I appreciate the help, because I'm stuck right now.
ruby-on-rails
redis
spawn
juggernaut
null
null
open
Rails app: Reconnect juggernaut redis after forking? === I'm working on a Rails app that is using [Juggernaut](https://github.com/maccman/juggernaut) to push data to clients at regular intervals. I use a controller action to get the pushing started; but since the pushing is often a long process (10 minutes or more), I am using spawn to fork the task. For example: def start_pushing spawn_block(:argv => "juggernaut-pushing") do for x in y Juggernaut.publish(stuff in here) sleep(30) # delay before publishing next item end end end The problem is that I find this error in the log file when I hit the start_pushing action: spawn> Exception in child[27898] - Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking. So I added the following right inside the spawn_block, hoping it would fix the problem: require 'redis' $redis.client.disconnect $redis = Redis.new(:host => 'localhost', :port => 6379) It didn't seem to fix it, though the action has been working intermittently even before I added this to reset $redis. I'm thinking that perhaps resetting $redis isn't doing anything; Juggernaut is still accessing an old connection. Does that seem likely? How would I make sure that Juggernaut uses a new Redis connection? Please let me know of any questions about what I'm describing. I appreciate the help, because I'm stuck right now.
0
11,262,069
06/29/2012 12:47:32
992,124
10/12/2011 19:13:27
21
0
Best way to retrieve periodic data from facebook which is NOT provided by facebook realtime api
My application requires some information (like online_presence) to be fetched out for user from fb on regular interval (say 1 minute). Actually my requirement says that I should get/fetch information only if someone from user friend list goes offline or comes online. What I am doing now is polling fb on regular interval of 1 min to check who is online/offline for a particular user, however this polling concept has very bad impact on performance, also after a certain number of polling request in a day(say 1 million a day) fb start throwing error. Also, online_presence about information user's friends is not provided by fb real time update api. So can anyone please suggest a better approach to query online presence other than polling continuously. Thanks.
facebook
facebook-graph-api
facebook-fql
null
null
null
open
Best way to retrieve periodic data from facebook which is NOT provided by facebook realtime api === My application requires some information (like online_presence) to be fetched out for user from fb on regular interval (say 1 minute). Actually my requirement says that I should get/fetch information only if someone from user friend list goes offline or comes online. What I am doing now is polling fb on regular interval of 1 min to check who is online/offline for a particular user, however this polling concept has very bad impact on performance, also after a certain number of polling request in a day(say 1 million a day) fb start throwing error. Also, online_presence about information user's friends is not provided by fb real time update api. So can anyone please suggest a better approach to query online presence other than polling continuously. Thanks.
0