Daily Archives

Articles indexed Saturday November 26 2011

Page 8/12 | < Previous Page | 4 5 6 7 8 9 10 11 12  | Next Page >

  • Where to place a query that should be included in all or most views

    - by Andrew
    In my application I have a sidebar which I want to include a list of pages. Cheating on the MVC setup, I can pretty easily display this as follows (in HAML): # layouts/_sidebar.html.haml %h4 Pages %ul.pages - for page in Page.all %li= link_to page.title, page Now, this works just fine, but clearly it's against the convention. The problem is, this shared layout partial is present in most (but not all) views, and therefore to serve the pages from the controller layer would mean needing to inject an instance variable into almost every controller action in the application. That isn't very clean or DRY. So, how would you handle this kind of situation? Is there a clean, DRY place to put this kind of a simple query that respects Rails MVC convention better?

    Read the article

  • Accept All Cookies via HttpClient

    - by Vinay
    So this is currently how my app is set up: 1.) Login Activity. 2.) Once logged in, other activities may be fired up that use PHP scripts that require the cookies sent from logging in. I am using one HttpClient across my app to ensure that the same cookies are used, but my problem is that I am getting 2 of the 3 cookies rejected. I do not care about the validity of the cookies, but I do need them to be accepted. I tried setting the CookiePolicy, but that hasn't worked either. This is what logcat is saying: 11-26 10:33:57.613: WARN/ResponseProcessCookies(271): Cookie rejected: "[version: 0] [name: cookie_user_id][value: 1][domain: www.trackallthethings.com][path: trackallthethings][expiry: Sun Nov 25 11:33:00 CST 2012]". Illegal path attribute "trackallthethings". Path of origin: "/mobile-api/login.php" 11-26 10:33:57.593: WARN/ResponseProcessCookies(271): Cookie rejected: "[version: 0][name: cookie_session_id][value: 1985208971][domain: www.trackallthethings.com][path: trackallthethings][expiry: Sun Nov 25 11:33:00 CST 2012]". Illegal path attribute "trackallthethings". Path of origin: "/mobile-api/login.php" I am sure that my actual code is correct (my app still logs in correctly, just doesn't accept the aforementioned cookies), but here it is anyway: HttpGet httpget = new HttpGet(//MY URL); HttpResponse response; response = Main.httpclient.execute(httpget); HttpEntity entity = response.getEntity(); InputStream in = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder sb = new StringBuilder(); From here I use the StringBuilder to simply get the String of the response. Nothing fancy. I understand that the reason my cookies are being rejected is because of an "Illegal path attribute" (I am running a script at /mobile-api/login.php whereas the cookie will return with a path of just "/" for trackallthethings), but I would like to accept the cookies anyhow. Is there a way to do this?

    Read the article

  • WHy am I unable to add text along with <%# Container.DataItem %> in repeater in user control

    - by Jamie Hartnoll
    I have a User Control which is dynamically placed by CodeBehind as follows: Dim myControl As Control = CType(Page.LoadControl("~/Controls/mainMenu.ascx"), Control) If InStr(Request.ServerVariables("url"), "/Login.aspx") <= 0 Then mainMenu.Controls.Add(myControl) End If As per an example from my previous question on here. Within this Control is a repeater which calls a database to generate values. My Repeater mark-up is as follows <asp:Repeater runat="server" ID="locationRepeater" OnItemDataBound="getQuestionCount"> <ItemTemplate> <p id='locationQuestions' title='<%# Container.DataItem %>' runat='server'></p> </ItemTemplate> </asp:Repeater> The example above works fine, but I want to be able to prepend text to <%# Container.DataItem %> in the title attribute of that <p to print to the browser like this is some text DATA_ITEM_OUTPUT When I try to do that though, it prints this is some text <%# Container.DataItem %> exactly like that, ie, turning <%# Container.DataItem %> into text, NOT the value from the repeater code. It was working fine before I made it into a dynamically inserted control, so I am thinking I might have something being generated in the wrong order, but given that it works without any prepended text, I am stumped to fix it! I'm new to .net and using vb.net, please could someone point me in the right direction?

    Read the article

  • finding shortest valid path in a colored-edge graphs

    - by user1067083
    Given a directed graph G, with edges colored either green or purple, and a vertex S in G, I must find an algorithm that finds the shortest path from s to each vertex in G so the path includes at most two purple edges (and green as much as needed). I thought of BFS on G after removing all the purple edges, and for every vertex that the shortest path is still infinity, do something to try to find it, but I'm kinda stuck, and it takes alot of the running time as well... Any other suggestions? Thanks in advance

    Read the article

  • Pro ASP.Net MVC 3 Entity Framework Sports Store tutorial

    - by gary7
    Following the tutorial in the book "Pro ASP.Net MVC 3 Entity Framework" in Chapter 9 - Image Uploads section; asks that the Product class be updated with two new columns - public byte ImageData, and public string ImageType. It also directs that the database be updated with these two columns via the server explorer. After these updates, the discussion directs that the Entity Framework Conceptual Model be updated via the SportsStore.EDMX file. This file does not exist in the source code for the project, and was not used in the project to begin with. Obvious errata for the book. Adding the ADO.NET Entity Data Model to the Project then overrides the EFProduct reposistory (conceptual model used throughout the project) which inherits from the interface IProductsRepository; and results in errors within the mapping. If the project is debugged after the columns are added, an error is thrown related to the new added columns. Has anyone resolved this issue in the project? I haven't found any solutions so far. Thanks!

    Read the article

  • Using proxy models

    - by smallB
    I've created Proxy model by subclassing QAbstractProxyModel and connected it as a model to my view. I also set up source model for this proxy model. Unfortunately something is wrong because I'm not getting anything displayed on my listView (it works perfectly when I have my model supplied as a model to view but when I supply this proxy model it just doesn't work). Here are some snippets from my code: #ifndef FILES_PROXY_MODEL_H #define FILES_PROXY_MODEL_H #include <QAbstractProxyModel> #include "File_List_Model.h" class File_Proxy_Model: public QAbstractProxyModel { public: explicit File_Proxy_Model(File_List_Model* source_model) { setSourceModel(source_model); } virtual QModelIndex mapFromSource(const QModelIndex & sourceIndex) const { return index(sourceIndex.row(),sourceIndex.column()); } virtual QModelIndex mapToSource(const QModelIndex & proxyIndex) const { return index(proxyIndex.row(),proxyIndex.column()); } virtual int columnCount(const QModelIndex & parent = QModelIndex()) const { return sourceModel()->columnCount(); } virtual int rowCount(const QModelIndex & parent = QModelIndex()) const { return sourceModel()->rowCount(); } virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const { return createIndex(row,column); } virtual QModelIndex parent(const QModelIndex & index) const { return QModelIndex(); } }; #endif // FILES_PROXY_MODEL_H //and this is a dialog class: Line_Counter::Line_Counter(QWidget *parent) : QDialog(parent), model_(new File_List_Model(this)), proxy_model_(new File_Proxy_Model(model_)), sel_model_(new QItemSelectionModel(proxy_model_,this)) { setupUi(this); setup_mvc_(); } void Line_Counter::setup_mvc_() { listView->setModel(proxy_model_); listView->setSelectionModel(sel_model_); }

    Read the article

  • A file is being http posted, how can I reference the parameter by index?

    - by Blankman
    An XML file is being posted to a url that my spring mvc is responding to. In .NET, I could do this: request.Form[0] request.Form["abc"] or request.QueryString[0] request.QueryString["some_key"] Now with spring/servlets it seems I can only do this: request.getParameter("some_key") or get all the names or values. When someone is posting a file to a url, using http post, won't this be just a single request parameter then? Can I get the parameter using index with servlets?

    Read the article

  • Generic factory of generic containers

    - by Feuermurmel
    I have a generic abstract class Factory<T> with a method createBoxedInstance() which returns instances of T created by implementations of createInstance() wrapped in the generic container Box<T>. abstract class Factory<T> { abstract T createInstance(); public final Box<T> createBoxedInstance() { return new Box<T>(createInstance()); } public final class Box<T> { public final T content; public Box(T content) { this.content = content; } } } At some points I need a container of type Box<S> where S is an ancestor of T. Is it possible to make createBoxedInstance() itself generic so that it will return instances of Box<S> where S is chosen by the caller? Sadly, defining the function as follows does not work as a type parameter cannot be declared using the super keyword, only used. public final <S super T> Box<S> createBoxedInstance() { return new Box<S>(createInstance()); } The only alternative I see, is to make all places that need an instance of Box<S> accept Box<? extends S> which makes the container's content member assignable to S. Is there some way around this without re-boxing the instances of T into containers of type Box<S>? (I know I could just cast the Box<T> to a Box<S> but I would feel very, very guilty.)

    Read the article

  • Android Contact Picker

    - by user1066398
    I was wondering: Is it possible to customize the Android Contact Picker so that it can also allow adding a new contact as a menu option in the default contact list? At the moment, if I invoke the contact picker from my activity, it only displays the default contact list. I would also like the user to be able to create a new contact if it did not exist already. I have searched this quite a lot but do not find appropriate API to do this. There is nothing in ContactContract as far as I can see.

    Read the article

  • Delphi Client-Server Application using Firebird 2.5 embedded connection error

    - by Japster
    0 down vote favorite 1 share [fb] share [tw] I have got a lengthy question to ask. First of all Im still very new when it comes to Delphi programming and my experience has beem mostly developing small single user database applications using ADO and an Access database. I need to take the transition now to a client server application and this is where the problem starts. I decided to use Firebird 2.5 embeded as my database, as it is open source, and it is can be used with the interbase components in Delphi and that multiple clients can access the database simultanously. So I followed the interbase tutorial in Delphi. I managed to connect the client to the server and see the data in the example (While both are running on my pc), but when i tried to move the client to another pc, keeping the server on mine and running it to see if I can connect to the server it gave me the following error. Exception EIdSocketError in module clientDemo.exe at 0029DCAC. Socket Error # 10061 Connection refused. I understand that this might be because the host is defined as localhost in the client. But here is my first question. In the TSQLConncetion you can set die hostname under Driver-Hostname. The thing I want to know is how do you do this at run time, as I cannot get the property when I try and make an edit box to allow the user to enter the value and then set it via code like for example: SQLConncetion1.Driver.Hostname := edtHost.text; This cannot be done this way and the only way I see you can set the hostname is with the object inspector, but that is not available at runtime and I need to set the hostname on the client when the program is running the first time, so how do you set the hostname/IP address at runtime? Im using Delphi XE2 There is still a lot of questions to come especially when it comes to deployment, but I will take this piece by piece and I appreciate the advice.

    Read the article

  • Android RandomAccessFile usage from resource

    - by lacas
    my code is String fileIn = resources.getResourceName(resourceID); Log.e("fileIn", fileIn); //BufferedReader buffer = new BufferedReader(new InputStreamReader(fileIn)); RandomAccessFile buffer = null; try { buffer = new RandomAccessFile(fileIn, "r"); } catch (FileNotFoundException e) { Log.e("err", ""+e); } /fileIn(6062): ls3d.gold.paper:raw/wwe_obj i get 11-26 15:06:35.027: ERROR/err(6062): java.io.FileNotFoundException: /ls3d.gold.paper:raw/wwe_obj (No such file or directory) How can I access a file using randomaccessfile in java? How can I load from a resource? (R.raw.wwe_obj)

    Read the article

  • Integrating CKeditor to my symfony2 project

    - by Jishnu G Nair
    I was trying to integrate ckeditor to my symfony2 project so that some of the textarea will have the ckeditor html editor. I brought the ckeditor on my required textarea by calling the class="ckeditor" in my form. The issue that I am facing now is that when I use the ckeditor the submit button of my form will not work instead I will have to use the built in "Save" option of the ckeditor toolbar for submitting the form. When I remove the ckeditor from the textareas and use normal textarea the submit button seems to work. I do not want to use the "Save" button on the ckeditor toolbar to submit my form. Is there a workaround to make the submit button work? Tried googling out for possible solutions but could not find any. P.S: I would also like to know if there are other html text editors like ckeditor that would work well with symfony2 and link to implementation instructions.

    Read the article

  • Javascript Global Variables Not Working as expected. Help?

    - by capri corn
    I am new to Javascript. I am facing a problem with global variables. I can't figure out that why the global variables are not working as the code looks ok. Please Help me solve this problem. I will breifly explain the code first.I have some text on a page which changes to text field when clicked. When I define the variables inside the functions body the code starts working fine. When these variables are defined globally as in the following code, the console displays this error: the variable is not defined. Here my code: <!DOCTYPE HTML> <html> <head> <title>Span to Text Box - Demo - DOM</title> <script type="text/javascript" language="javascript"> var textNode = document.getElementById('text'); var textValue = textNode.firstChild.nodeValue; var textboxNode = document.getElementById('textbox'); var doneButton = document.getElementById('done'); function change() { textboxNode.setAttribute('value', textValue); textNode.style.display = 'none'; textboxNode.setAttribute('type','text'); doneButton.setAttribute('type','button'); } function changeBack() { textNode.firstChild.nodeValue = textboxNode.value; textNode.style.display = 'block'; textboxNode.setAttribute('type', 'hidden'); doneButton.setAttribute('type','hidden'); } </script> </head> <body> <p id="text" onClick="change()">Click me!</p> <form onSubmit="return false;"> <input type="hidden" id="textbox" /> <input type="hidden" id="done" onClick="changeBack()" value="Done" /> </form> </body> </html> Please Help! Thanks in Advance.

    Read the article

  • Is there a project setting that controls getting to Game Center's Sandbox?

    - by CBGraham
    This is different from the others; it's cool. I know that your Bundle Identifier needs to match your iTunes Connect's version. I know you need to make a new AppleID through your dev app and not through Game Center. Most people get this fixed when they force quit their app and game center and launch theirs first. I am not one of those people. If I take the GKTapper tutorial and use my game's Bundle Identifier as the only change, things are good. On launch, it asks me if I want to use an existing or make a new account. But more importantly, it says * Sandbox *. (Before I log in, mind you; this is not an account problem at all.) Once inside I can see my achievements. If I load my game, I has a sad. On launch I get the same dialog, but it does not say Sandbox. My game is two weeks away from being done after many long months. Moving everything in to a new project is possible, but a pain. So the question is: What magic setting does GKTapper or a new project have that my game that I started in June does not that lets you get to Game Center's Sandbox?

    Read the article

  • <html:select> inside <logic:iterate>

    - by TPT Gin
    I have an itemList and for each item, a dropdown list of ratings is displayed. After user rates each item in itemList, i want to store those rates in an array. How can I do it? selectedRate below is of Integer type, and the code failed to solve the problem. <logic:iterate id="item" name="itemList"> <tr> <td> <html:select name="aForm" property="selectedRate"> <html:optionsCollection name="allRates" label="description" value="value" /> </html:select> </td> </tr> </logic:iterate>

    Read the article

  • Defining an implementation independent version of the global object in JavaScript

    - by Aadit M Shah
    I'm trying to define the global object in JavaScript in a single line as follows: var global = this.global || this; The above statement is in the global scope. Hence in browsers the this pointer is an alias for the window object. Assuming that it's the first line of JavaScript to be executed in the context of the current web page, the value of global will always be the same as that of the this pointer or the window object. In CommonJS implementations, such as RingoJS and node.js the this pointer points to the current ModuleScope. However, we can access the global object through the property global defined on the ModuleScope. Hence we can access it via the this.global property. Hence this code snippet works in all browsers and in at least RingoJS and node.js, but I have not tested other CommomJS implementations. Thus I would like to know if this code will not yield correct results when run on any other CommonJS implementation, and if so how I may fix it. Eventually, I intend to use it in a lambda expression for my implementation independent JavaScript framework as follows (idea from jQuery): (function (global) { // javascript framework })(this.global || this);

    Read the article

  • AWS:EC2:: Could not connect FTP client?

    - by heathub
    My Server OS: Amazon Linux I am trying to set up ftp. I have: Installed vsftpd open port 20-21 open port 1024 - 1048 Basically, I followed every of these steps Start vsftpd service (the status indicate [ok]) I use filezilla for my ftp client. Here is my setting/configuration: Host: ec2-XX-XX-XXX-XX.compute-1.amazonaws.com Port: -(blank, but I have tried 20 and 21 though) Server Type: FTP - File Transder Protocol Logon Type: Normal Username: (tried root and ec2-user) Transfer mode: Tried passive and active I always has this error: Status: Waiting to retry... Status: Resolving address of ec2-XX-XX-XXX-XX.compute-1.amazonaws.com Status: Connecting to XX.XX.XXX.XX:21... Error: Connection timed out Error: Could not connect to server Have I missed any configuration/settings? EDIT After execute the /sbin/iptables -L -n Here is the result: Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination

    Read the article

  • Project Server 2007 install issue - ProjectEventService won't start

    - by Brian Meinertz
    Trying to install PS2007 with SP1 on Server 2003. The install goes fine, but when running the SharePoint Configuration Wizard, it fails at stage 6 of 12 with the error: Failed to register SharePoint Services. An exception of type System.InvalidOperationException was thrown. Additional exception information: Cannot start service ProjectEventService on computer '.'. From the PSCDiagnostics log: Exception: System.InvalidOperationException: Cannot start service ProjectEventService on computer '.'. --- System.ComponentModel.Win32Exception: The service did not respond to the start or control request in a timely fashion. The ProjectEventService (Microsoft Office Project Server Event) won't even start manually using the Network Service account. Starting the service with a domain account works, but subsequently running the Config Wizard causes the service to be removed and re-provisioned to run using the Network Service account, which again fails. Presumably Network Service needs elevated permissions, but even adding it to the local Admin group makes no difference. Anyone come across this sort of issue before?

    Read the article

  • Disabled admin account on Win 2008 R2

    - by James Bates
    I accidentally disabled the administrator account on an install of Windows Server 2008 R2 via the net user command. Now I cant get an elevated command prompt to re-enable the admin user, nor do any privileged operation that requires an admin password. Normally I would type in a password and click yes but there is no password field and yes is grayed out. How can I re-enable the administrator account?

    Read the article

  • Forms Authentication across Sub-Domains on local IIS

    - by Parminder
    I asked this question at SO http://stackoverflow.com/questions/8278015/forms-nauthentication-across-sub-domains-on-local-iis Now asking it here. I know a cookie can be shared across multiple subdomains using the setting <forms name=".ASPXAUTH" loginUrl="Login/" protection="Validation" timeout="120" path="/" domain=".mydomain.com"/> in Web.config. But how to replicate same thing on local machine. I am using windows 7 and IIS 7 on my laptop. So I have sites localhost.users/ for my actual site users.mysite.com localhost.host/ for host.mysite.com and similar.

    Read the article

  • Better performance with memcached cluster or local memcaches?

    - by Nicholas Tolley Cottrell
    I have a small cluster of servers balancing a Java web app. Currently I have 3 memcached servers caching data and all web apps shares all 3 memcached instances. I often get strange slowdowns and timeouts to some of the memcacheds and I wondering if there is a good way of analyzing the performance. I am wondering whether my iptables rules (or some other system limitation) are blocking/slowing connections. I am considering reconfiguring the web apps so that they only query the memcached process on their own localhost.

    Read the article

  • Iptables: masquarading and routing

    - by nixnotwin
    I have a WAN router which is linked to isp over a /30 WAN subnet. But it also servers as a router to a /29 local public WAN subnet which is connected to few of my servers. The traffic from /29 gets routed to ISP via /30 subnet. For a wired reason I want to masqarade (NAT) the interface which has /30 ip. So the interface with /30 ip should appear as masquaraded for my 192.168.1.0/24 network and it also should act as a normal non-NAT router for my WAN public subnet /29. Can this be done with iptables on a Linux machine?

    Read the article

  • Node.js Build failed: -> task failed (error#2)?

    - by Richard Hedges
    I'm trying to install Node.js on my CentOS server. I run ./configure and it runs perfectly fine. I then run the 'make' command and it produces the following: [5/38] libv8.a: deps/v8/SConstruct - out/Release/libv8.a /usr/local/bin/python "/root/node/tools/scons/scons.py" -j 1 -C "/root/node/out/Release/" -Y "/root/node/deps/v8" visibility=default mode=release arch=ia32 toolchain=gcc library=static snapshot=on scons: Reading SConscript files ... ImportError: No module named bz2: File "/root/node/deps/v8/SConstruct", line 37: import js2c, utils File "/root/node/deps/v8/tools/js2c.py", line 36: import bz2 Waf: Leaving directory `/root/node/out' Build failed: - task failed (err #2): {task: libv8.a SConstruct - libv8.a} make: * [program] Error 1 I've done some searching on Google but I can't seem to find anything to help. Most of what I've found is for Cygwin anyway, and I'm on CentOS 4.9. Like I said, the ./configure went through perfectly fine with no errors, so there's nothing there that I can see. EDIT I've got a little further. Now I just need to upgrade G++ to version 4 (or higher). I tried yum update gcc but no luck, so I tried yum install gcc44, which resulted in no luck either. Has anyone got any ideas as to how I can update G++?

    Read the article

  • With a node.js powered server on EC2, how can I decrease the TCP connection time?

    - by talentedmrjones
    While profiling my application I've noticed that in the Firebug Net panel, the "Connecting" time—that is the time waiting for a TCP connection—is consistently around 70–100ms. See image below: Of course in the grand scheme of things, 100ms is not long, but I have seen other services that respond with 0ms Connect time. So if other servers can, I should be able to as well. Any thoughts on how I might even beging to troubleshoot this?

    Read the article

  • FreeBSD Ports: How can I see all dependencies for a port, and all subdependencies for those dependencies?

    - by Stefan Lasiewski
    I'm trying to build a port which depends on apache-ant. I thought I could run make build-depends-list to see all dependencies required by this port: # make build-depends-list /usr/ports/devel/apache-ant /usr/ports/java/jdk16 /usr/ports/math/gmp But after installing everything, the port had a dependency list which was a mile long: apache-ant-1.8.1 desktop-file-utils-0.15_2 gamin-0.1.10_4 gettext-0.18.1.1 gio-fam-backend-2.26.1 glib-2.26.1_1 gmp-5.0.1 inputproto-2.0 javavmwrapper-2.3.5 kbproto-1.0.4 libX11-1.3.3_1,1 libXau-1.0.5 libXdmcp-1.0.3 libXext-1.1.1,1 libXi-1.3,1 libXtst-1.1.0 libiconv-1.13.1_1 libpthread-stubs-0.3_3 libxcb-1.7 pcre-8.12 perl-5.10.1_3 pkg-config-0.25_1 python26-2.6.6 recordproto-1.14 unzip-6.0 xextproto-7.1.1 xproto How can I see all dependencies, and all subdependencies for a port?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12  | Next Page >