Daily Archives

Articles indexed Sunday May 9 2010

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

  • Handling Application Logic in Multiple AsyncTask onPostExecute()s

    - by stormin986
    I have three simultaneous instances of an AsyncTask for download three files. When two particular ones finish, at the end of onPostExecute() I check a flag set by each, and if both are true, I call startActivity() for the next Activity. I am currently seeing the activity called twice, or something that resembles this type of behavior. Since the screen does that 'swipe left' kind of transition to the next activity, it sometimes does it twice (and when I hit back, it goes back to the same activity). It's obvious two versions of the activity that SHOULD only get called once are being put on the Activity stack. The only way I can find that this is possible is if both AsyncTasks' onPostExecute() executed SO simultaneously that they were virtually running the same lines at the same time, since I set the 'itemXdownloaded' flag to true right before I check for both and call startActivity(). But this is happening enough that it's very hard for me to believe that both downloads are finishing precisely at the same time and having their onPostExecute()s so close together... Any thoughts on what could be going on here? General gist of code (details removed, ignore any syntactical errors I may have edited in): // In onPostExecute() switch (downloadID) { case DL1: dl1complete = true; break; case DL2: dl2complete = true; break; case DL3: dl3complete = true; break; } // If 1 and 2 are done, move on (DL3 still going in background) if ( downloadID != DL3 && dl1complete && dl2complete) { ParentClass.this.startActivity(new Intent(ParentClass.this, NextActivity.class)); }

    Read the article

  • XML validation in Java - why does this fail?

    - by jd
    hi, first time dealing with xml, so please be patient. the code below is probably evil in a million ways (I'd be very happy to hear about all of them), but the main problem is of course that it doesn't work :-) public class Test { private static final String JSDL_SCHEMA_URL = "http://schemas.ggf.org/jsdl/2005/11/jsdl"; private static final String JSDL_POSIX_APPLICATION_SCHEMA_URL = "http://schemas.ggf.org/jsdl/2005/11/jsdl-posix"; public static void main(String[] args) { System.out.println(Test.createJSDLDescription("/bin/echo", "hello world")); } private static String createJSDLDescription(String execName, String args) { Document jsdlJobDefinitionDocument = getJSDLJobDefinitionDocument(); String xmlString = null; // create the elements Element jobDescription = jsdlJobDefinitionDocument.createElement("JobDescription"); Element application = jsdlJobDefinitionDocument.createElement("Application"); Element posixApplication = jsdlJobDefinitionDocument.createElementNS(JSDL_POSIX_APPLICATION_SCHEMA_URL, "POSIXApplication"); Element executable = jsdlJobDefinitionDocument.createElement("Executable"); executable.setTextContent(execName); Element argument = jsdlJobDefinitionDocument.createElement("Argument"); argument.setTextContent(args); //join them into a tree posixApplication.appendChild(executable); posixApplication.appendChild(argument); application.appendChild(posixApplication); jobDescription.appendChild(application); jsdlJobDefinitionDocument.getDocumentElement().appendChild(jobDescription); DOMSource source = new DOMSource(jsdlJobDefinitionDocument); validateXML(source); try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StreamResult result = new StreamResult(new StringWriter()); transformer.transform(source, result); xmlString = result.getWriter().toString(); } catch (Exception e) { e.printStackTrace(); } return xmlString; } private static Document getJSDLJobDefinitionDocument() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try { builder = factory.newDocumentBuilder(); } catch (Exception e) { e.printStackTrace(); } DOMImplementation domImpl = builder.getDOMImplementation(); Document theDocument = domImpl.createDocument(JSDL_SCHEMA_URL, "JobDefinition", null); return theDocument; } private static void validateXML(DOMSource source) { try { URL schemaFile = new URL(JSDL_SCHEMA_URL); Sche maFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(schemaFile); Validator validator = schema.newValidator(); DOMResult result = new DOMResult(); validator.validate(source, result); System.out.println("is valid"); } catch (Exception e) { e.printStackTrace(); } } } it spits out a somewhat odd message: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'JobDescription'. One of '{"http://schemas.ggf.org/jsdl/2005/11/jsdl":JobDescription}' is expected. Where am I going wrong here? Thanks a lot

    Read the article

  • DispatcherOperations.Wait()

    - by Mark
    What happens if you call dispatcherOperation.Wait() on an operation that has already completed? Also, the docs say that it returns a DispatcherOperationStatus, but wouldn't that always be Completed since it (supposedly) doesn't return until it's done? I was trying to use it like this: private void Update() { while (ops.Count > 0) ops.Dequeue().Wait(); } public void Add(T item) { lock (sync) { if (dispatcher.CheckAccess()) { list.Add(item); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item)); } else { ops.Enqueue(dispatcher.BeginInvoke(new Action<T>(Add), item)); } } } I'm using this in WPF, so all the Add operations have to occur on the UI thread, but I figured I could basically just queue them up without having to wait for it to switch threads, and then just call Update() before any read operations to ensure that the list is up to date, but my program started hanging.

    Read the article

  • What's a good Perl OO interface for creating and sending email?

    - by aidan
    I'm looking for a simple (OO?) approach to email creation and sending. Something like $e = Email->new(to => "test <[email protected]>", from => "from <[email protected]>"); $e->plain_text($plain_version); $e->html($html_version); $e->attach_file($some_file_object); I've found Email::MIME::CreateHTML, which looks great in almost every way, except that it does not seem to support file attachments. Also, I'm considering writing these emails to a database and having a cronjob send them at a later date. This means that I would need a $e->as_text() sub to return the entire email, including attachments, as raw text which I could stuff into the db. And so I would then need a way of sending the raw emails - what would be a good way of achieving this? Many thanks

    Read the article

  • Mapscript queryByPoint return no results

    - by lucian.jp
    I have a dynamically generated mapfile made with c# mapscript that is defined like: MAP EXTENT 5.91828 45.63552 5.92346 45.65051 IMAGECOLOR 192 192 192 IMAGETYPE png SIZE 256 256 STATUS ON TRANSPARENT TRUE UNITS METERS NAME "GMAP_TILE" OUTPUTFORMAT NAME "png" MIMETYPE "image/png" DRIVER "GD/PNG" EXTENSION "png" IMAGEMODE "PC256" TRANSPARENT TRUE END SYMBOL NAME "circle" TYPE ELLIPSE FILLED TRUE POINTS 1 1 END END SYMBOL NAME ">" TYPE TRUETYPE ANTIALIAS TRUE CHARACTER ">" GAP -20 FONT "arial" POSITION CC END PROJECTION "proj=merc" "a=6378137" "b=6378137" "lat_ts=0.0" "lon_0=0.0" "x_0=0.0" "y_0=0" "units=m" "k=1.0" "nadgrids=@null" END LEGEND IMAGECOLOR 255 255 255 KEYSIZE 20 10 KEYSPACING 5 5 LABEL SIZE MEDIUM TYPE BITMAP BUFFER 0 COLOR 0 0 0 FORCE FALSE MINDISTANCE -1 MINFEATURESIZE -1 OFFSET 0 0 PARTIALS TRUE END POSITION LL STATUS OFF END QUERYMAP COLOR 255 255 0 SIZE -1 -1 STATUS ON STYLE HILITE END SCALEBAR ALIGN CENTER COLOR 0 0 0 IMAGECOLOR 255 255 255 INTERVALS 4 LABEL SIZE MEDIUM TYPE BITMAP BUFFER 0 COLOR 0 0 0 FORCE FALSE MINDISTANCE -1 MINFEATURESIZE -1 OFFSET 0 0 PARTIALS TRUE END POSITION LL SIZE 200 3 STATUS OFF STYLE 0 UNITS MILES END WEB IMAGEPATH "" IMAGEURL "" QUERYFORMAT text/html LEGENDFORMAT text/html BROWSEFORMAT text/html END LAYER NAME "Troncons" PROJECTION "proj=longlat" "ellps=WGS84" "datum=WGS84" END STATUS DEFAULT TEMPLATE "nofile.html" TOLERANCE 100 TOLERANCEUNITS METERS TYPE LINE UNITS METERS CLASS NAME "Troncons" STYLE ANGLE 360 COLOR 0 0 255 SIZE 5 SYMBOL "circle" WIDTH 5 END STYLE ANGLE 360 COLOR 0 0 0 SIZE 12 SYMBOL ">" WIDTH 1 END END FEATURE POINTS 5.91828 45.63552 5.91876 45.63611 5.91898 45.6364 5.91936 45.63701 5.91952 45.63731 5.91968 45.63762 5.91993 45.63825 5.92003 45.63856 5.92018 45.63919 5.92028 45.63983 5.92031 45.64014 5.92033 45.64046 5.92034 45.64077 5.92034 45.64108 5.92034 45.64171 5.92035 45.64234 5.92035 45.6428 5.92037 45.6433 5.9204 45.64394 5.92046 45.64458 5.92056 45.64522 5.92062 45.64554 5.92069 45.64586 5.92077 45.64617 5.92097 45.64679 5.92122 45.64739 5.92136 45.64769 5.92169 45.64828 5.92207 45.64886 5.92228 45.64914 5.92272 45.64969 5.92321 45.65023 5.92346 45.65051 END END END END I try to queryByPoint to retreive the index of the shape clciked near. In the code below I made a specific test function with fixed point instead of points passed by parameter so I am sure the point I use is actually part of a feature. In my case I use the first point of the only feature contained in mapfile. public string GetTronconId() { //_map is my dynamically created mapObj if (_map != null) for (int i = 0; i < _map.numlayers; i++) { layerObj layer = _map.getLayer(i); // Code never pass this point if (layer.queryByPoint(_map, new pointObj(5.91898, 45.6364, 0, 0), (int) MS_QUERY_MODE.MS_QUERY_MULTIPLE, 100) == (int) MS_RETURN_VALUE.MS_SUCCESS) { int numresults = layer.getNumResults(); if (numresults != 0) { layer.open(); for (int j = 0; j < numresults; j++) { resultCacheMemberObj resultat = layer.getResult(j); shapeObj shape = null; if (layer.getShape(shape, resultat.tileindex, resultat.shapeindex) == (int) MS_RETURN_VALUE.MS_SUCCESS) return shape.getValue(0); } } } } return null; } I have a dummy TEMPLATE set, I do not eveen have to use the tolerance since the point is derectly in a shape, but the queryByPoint keep returning me MS_FAILURE. From my searches on the web everything seem to be OK. Any idea?

    Read the article

  • Where has my parallel port gone? ioperm(888,1,1) returns -1.

    - by marcusw
    I have an old Dell Dimension 8200 running Gentoo which I use solely to control various things using the parallel port. After shutting it down a few weeks ago, I started it up again today and tried to access the parallel port like I usually do. Unfortunately, my code bombed out when it tried to call ioperm(888,1,1) to grab the parallel port which returned an error code of -1. There have been no changes to the system be it hardware or software, no updates, no tweaking, no dropping the case, no over-amping the data pins, nothing. The port and the software have been working fine for months with no changes, and were working fine when I shut it down last. Running my code with root privileges changes nothing. What is breaking this and how can I fix it?

    Read the article

  • SVN checkout/export too long to download

    - by user41671
    Hi, My checkout/export session in svn is kinda weird. The file is just a 300KB in size but the downloading keeps going and it reaches a megabytes in size. The file is in RPM format. I don't know if the file is corrupt or the SVN has a bug. I tried to download the file using web browser and seems the downloading works fine. What probably is the main problem is here?

    Read the article

  • Changes to grub in ubuntu 10

    - by jdege
    I've been running CentOS 5 for some years. I've decided to upgrade to Ubuntu, and with 10.04 just out, this seemed like a good time. I'm a tad paranoid, so I started off with a new set of drives - one to install on, one to backup to, and one as a spare. I removed my existing CentOS 5 drives, and did an install, and had no problems. I installed the server version, and used the default full-disk LVM installation. Next, I copies my backup scripts over, edited them to work with the new configuration, and did a test backup. That worked fine, as well. Then comes the real test, could I do an install of the backup onto the spare drive? (I won't put anything of importance on a system that doesn't have a reliable backup, and if I've never done a restore, it's not reliable.) I booted from a System Rescue CD (ver 1.5.3), with the spare drive as /dev/sda, and the backup drive as /dev/sdb. I had no trouble in partitioning, configuring LVM, formatting, making swap, or restoring the file systems. But when I got to restoring grub to the MBR, I ran into problems. My restore instructions from CentOS 5 said run grub, then enter two commands: root (hd0,0) setup (hd0) The first command exits with an error: "Checking if /boot/grub/stage1 exists ... no" I did some googling around, and found that the Grub2 included in recent Ubuntus is very different than the Grub 0.97 included in CentOS 5. One site suggested I use: grub-install --root-dir=/mnt/restore /dev/sda That appeared to work, but when I booted from the drive, I ended up at a grub prompt. Any ideas as to what I need to do? It seems like a simple problem, but my attempts at searching out answers on the web are being swamped by references to the old version of Grub. Help would be appreciated.

    Read the article

  • CodePlex Daily Summary for Saturday, May 08, 2010

    CodePlex Daily Summary for Saturday, May 08, 2010New ProjectsBizSpark Camp Sample Code: This sample project demonstrates best practices when developing Windows Phone 7 appliactions with Azure. **This code is meant only as a sample f...CLB Article Module: The CLB Article Module is a simple DotNetNuke Module for Article writers. This module is designed to provide a simple location for article/screenc...cvplus: a computer vision libraryDemina: Demina is a simple keyframe based 2d skeletal animation system. It's developed in C# using XNA.Expo Live: Expo LiveFeedMonster: FeedMonster is a Cross platform Really Simple Syndication reader made to allow you to easily follow updates to your favorite sites. Its made using ...GamePad to KeyBoard: GamePad to KeyBoard (GP2KB) is a small app that lets you define an associated keyboard key for each button in your XBox 360 controller. This way, y...huanhuan's project: moajfiodsafasLazyNet: Lazynet Allows users to save the proxy settings and IP addresses of wireless networks. This makes it easier for users that move a lot between diffe...mfcfetionapi: mfcfetionapiMocking BizTalk: Mocking BizTalk is a set of tools aimed at bringing Mock Object concepts in BizTalk solution testing. Actually it consists in a set of MockPipelin...nkSWFControl: nkSWFControl is a ASP.NET control that provides numberous ways for publishing SWF movies in your pages. The project goal is to become defacto ...Property Pack for EPiServer CMS: With EPiServer CMS 6 it's possible to create a wide variety of custom property types that have customized settings in each usage. This Property Pac...SPRoleAssignment: SPRoleAssignment makes it easier for programmers to assign custom item level permissions. You can now easily grant or remove permissions to certain...Thats-Me Dot Net API: Thats-Me Dot Net API is a library which implements the Thats-Me.ch API for the Dot Net Framework.The Information Literacy Education Learning Environment (ILE): Written in C# utilizing the .net framework the Information Literacy Education (ILE) learning environment is designed to deliver information litera...tinytian: Tools, shared.Unidecode Sharp: UnidecodeSharp is a C# port of Python and Perl Unidecode module. Intended to transliterate an Unicode object into an ASCII string, no matter what l...Wave 4: Wave 4 is a platform for professional bloggers, integrated with many social networking services.New ReleasesµManager for MaNGOS: 0.8.6: Improvements: Supports up to MaNGOS revision 9692 (may support higher revisions, this is dependent on any changes made to the database structure b...BFBC2 PRoCon: PRoCon 0.3.5.0: Release Notes CommingBizSpark Camp Sample Code: Initial Check-in: There are two downloads available for this project. There is a windows phone 7 application that calls webservices hosted in Azure. And there is a...Bojinx: Bojinx Core V4.5.11: Minor release that fixes several minor bugs and adds more error prevention logic. Fixed: You will no longer get a null pointer error when loading ...CuttingEdge.Logging: CuttingEdge.Logging v1.2.2: CuttingEdge.Logging is a library that helps the programmer output log statements to a variety of output targets in .NET applications. The design is...DotNetNuke® Events: 05.01.00 Beta 1: Please take note: this is a Beta releaseThis is a not a formal Release of DNN Events 05.01.00. This is a beta version, which is not extensively te...dylan.NET: dylan.NET v. 9.8: This is the latest version of dylan.NET features the new locimport statement, improved error handling and other new stuff and bug fixes.Free Silverlight & WPF Chart Control - Visifire: Visifire SL and WPF Charts v3.0.9 beta 2 Released: Hi, This release contains the following enhancements: * New Property named ClosestPlotDistance has been implemented in Axis. It defines the d...Free Silverlight & WPF Chart Control - Visifire: Visifire SL and WPF Charts v3.5.2 beta 2 Released: Hi, This release contains the following enhancements: * New Property named ClosestPlotDistance has been implemented in Axis. It defines the d...GamePad to KeyBoard: GP2KB v0.1: First public version of GamePad to KeyBoard.Global: Version 0.1: This is the first beta stable release of this assembly. Check out the Test console app to see how some of the stuff works. EnjoyHtml Agility Pack: 1.4.0 Stable: 1.4.0 Adds some serious new features to Html Agility Pack to make it work nicer in a LINQ driven .NET World. The HtmlNodeCollection and HtmlAttribu...LazyNet: Beta Release: This is the Beta Version, All functionality has been implemented but needs further testing for bugs.Mercury Particle Engine: Mercury Particle Engine 3.1.0.0: Long overdue release of the latest version of Mercury Particle Engine, this release is changeset #66009NazTek.Extension.Clr4: NazTek.Extension.Clr4 Binary Cab: Includes bin, config, and chm filesnetDumbster: netDumbster 1.0: netDumbster release 1.0Opalis Community Releases: Workflow Examples (May 7, 2010): The Opalis team is providing some sample Workflows (policies) for customers and partners to help you get started in creating your own workflows in ...patterns & practices SharePoint Guidance: SPG2010 Drop10: SharePoint Guidance Drop Notes Microsoft patterns and practices ****************************************** ***************************************...Shake - C# Make: Shake v0.1.9: First public release including samples. Basic tasks: - MSBuild task (msbuild command line with parameters) - SVN command line client with checkout...SPRoleAssignment: Role Assigment Project [Eng]: SPRoleAssignment makes it easier for programmers to assign custom item level permissions. You can now easily grant or remove permissions to certain...SQL Server Metadata Toolkit 2008: Alpha 7 SQL Server Metadata Toolkit: The changes in this are to the Parser, and a change to handle WITH CTE's within the Analyzers. The Parser now handles CAST better, EXEC, EXECUTE, ...StackOverflow Desktop Client in C# and WPF: StackOverflow Client 0.5: Made the popup thinner, removed the extra icon and title. The questions on the popup automatically change every 5 seconds.TimeSpanExt: TimeSpanExt 1.0: This had been stuck in beta for a long time, so I'm glad to finally make the full release.Transcriber: Transcriber V0.2.0: First alpha release. See Issue Tracker for known bugs and incomplete features.Unidecode Sharp: UnidecodeSharp 0.04: First release. Tested and stable. Versions duplicates Perl and Python ones.Visual Studio 2010 AutoScroller Extension: AutoScroller v0.3: A Visual studio 2010 auto-scroller extension. Simply hold down your middle mouse button and drag the mouse in the direction you wish to scroll, fu...Visual Studio 2010 Test Case Import Utilities: V 1.0 (RC2): Work Item Migrator With the prior releases of Test Case Migrator ( Beta and RC1), it was possible to: migrate test cases (along with test steps) ...Word Add-in For Ontology Recognition: Technology Preview, Beta 2 - May 2010: This is a technology preview release of the Word Add-in for Ontology Recognition for Word. These are some of the updates included in this version:...Most Popular ProjectsWBFS ManagerRawrAJAX Control ToolkitMicrosoft SQL Server Product Samples: DatabaseSilverlight Toolkitpatterns & practices – Enterprise LibraryWindows Presentation Foundation (WPF)Microsoft SQL Server Community & SamplesASP.NETPHPExcelMost Active Projectspatterns & practices – Enterprise LibraryAJAX Control FrameworkRawrThe Information Literacy Education Learning Environment (ILE)Caliburn: An Application Framework for WPF and SilverlightBlogEngine.NETpatterns & practices - UnityjQuery Library for SharePoint Web ServicesNB_Store - Free DotNetNuke Ecommerce Catalog ModuleTweetSharp

    Read the article

  • Flex list control itemrenderer issue

    - by Jerry
    Hi Guys I am working on a small photo Gallery. I create a xml file and try to link it to my List control with itemrenderer. However, when I tried to save the file, I got access of undefined property data. Here is my code...and thanks a lot! <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Declarations> <fx:Model id="pictureXML" source="data/pictures.xml"/> <s:ArrayList id="pictureArray" source="{pictureXML.picture}"/> </fx:Declarations> <s:List id="pictureGrid" dataProvider="{pictureArray}" horizontalCenter="0" top="20"> <s:itemRenderer> <fx:Component> <s:HGroup> <mx:Image source="images/big/{data.source}" /> <s:Label text="{data.caption}"/> </s:HGroup> </fx:Component> </s:itemRenderer> </s:List> </s:Application> My xml <?xml version="1.0"?> <album> <picture> <source>city1.jpg </source> <caption>City View 1</caption> </picture> <picture> <source>city2.jpg </source> <caption>City View 2</caption> </picture> <picture> <source>city3.jpg </source> <caption>City View 3</caption> </picture> <picture> <source>city4.jpg </source> <caption>City View 4</caption> </picture> <picture> <source>city5.jpg </source> <caption>City View 5</caption> </picture> <picture> <source>city6.jpg </source> <caption>City View 6</caption> </picture> <picture> <source>city7.jpg </source> <caption>City View 7</caption> </picture> <picture> <source>city8.jpg </source> <caption>City View 8</caption> </picture> <picture> <source>city9.jpg </source> <caption>City View 9</caption> </picture> <picture> <source>city10.jpg </source> <caption>City View 10</caption> </picture> </album> I appreciate any helps!!!

    Read the article

  • Explicit C# interface implementation of interfaces that inherit from other interfaces

    - by anthony
    Consider the following three interfaces: interface IBaseInterface { event EventHandler SomeEvent; } interface IInterface1 : IBaseInterface { ... } interface IInterface 2 : IBaseInterface { ... } Now consider the following class that implements both IInterface1 and IInterface 2: class Foo : IInterface1, IInterface2 { event EventHandler IInterface1.SomeEvent { add { ... } remove { ... } } event EventHandler IInterface2.SomeEvent { add { ... } remove { ... } } } This results in an error because SomeEvent is not part of IInterface1 or IInterface2, it is part of IBaseInterface. How can the class Foo implement both IInterface1 and IInterface2?

    Read the article

  • Is it possible to chain -ms-filters in CSS?

    - by Jakub Hampl
    Does anyone know of a way to chain the proprietary filter properties in CSS. For example I have a div.example and I want to give it a background gradient and a drop shadow. So I'd like to do something like this: div.example { /* gradient */ filter: progid:DXImageTransform.Microsoft.Gradient(startColorstr=#cb141e78,endColorstr=#cb1dde78); /* shadow */ filter: progid:DXImageTransform.Microsoft.dropShadow(color=00143c, offX=0, offY=3, positive=true); } Except this will of course leave only the drop shadow. Anyone know a good workaround?

    Read the article

  • Rails: common approach for handling exceptions in restful actions on objects that have been destroye

    - by Greg
    It is very common in Rails for an objects_controller controller to have RESTful edit and destroy actions like so: def edit @object = Object.find(params[:id]) end def destroy @object = Object.find(params[:id]) @object.destroy redirect_to :back end With an associated view that provides edit and destroy links like so: <%= link_to "Edit the Object", edit_object_path(object) %> <%= link_to "Delete", object, :confirm => 'Are you sure?', :method => :delete %> And it is easy to blow this up. If I open two browser windows, A and B, destroy an object with the "Delete" link in browser A and then press the "Edit" link in browser B, the find() in the edit action throws an exception. Obviously there are several ways to deal with this in the edit action: catch the exception and recover gracefully use @object = find(:first, "conditions... etc. and test the @object before going further But seeing as this is such a common pattern, I would love to know how other folks deal with this situation.

    Read the article

  • ASP.NET declare a CSS stylesheet one time only

    - by Grant
    Hi, if i have a single CSS stylesheet for a website and only want to declare it once, that is, not use the following code on every aspx page.. <link href="stylesheets/general.css" rel="stylesheet" type="text/css" /> Am i forced to use a .master page? or is there another way to do this..

    Read the article

  • ui.datepicker.js form validation (solved)

    - by lena
    Hi, I'm using ui.datepicker.js and I want to validate the date field to make sure the user select a date. I have tried function allow_submit() { var f = document.all.frm; if (f.date.value == "") { jAlert("Please select a date"); return false; } //if return true; } and also have try if (f.date.value == "0000-00-00") { without succes Any clue?

    Read the article

  • Restricting Access in ERB code.

    - by LGFaler
    I am trying to build a CMS using ERB. Is there a way you can give ERB code read-only access to your models? For instance, I want to be able to load any information on my models (Model.all, Model.find_by_slug, Model.find_by_name, Model.other_model.name, etc...), but I don't want to be able to change this data. Can you disable ERB from executing commands that would make database changes (Model.save, Model.update, Model.delete, Model.destroy, etc.)???

    Read the article

  • Set width of Button in Android

    - by Mohit Deshpande
    How can I set a fixed width for an Android button? Everytime I try to set a fixed width it fills the current parent (the RelativeView). Here is my XML: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/relativelayout" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <EditText android:layout_height="wrap_content" android:editable="false" android:layout_width="fill_parent" android:id="@+id/output"></EditText> <Button android:layout_height="wrap_content" android:id="@+id/Button01" android:layout_below="@id/output" android:text="7" android:layout_width="wrap_content"></Button> <Button android:layout_below="@id/output" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/Button02" android:layout_toRightOf="@+id/Button01" android:text="8"></Button> <Button android:layout_below="@id/output" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/Button03" android:layout_toRightOf="@+id/Button02" android:text="9"></Button> </RelativeLayout> How would I give it a FIXED width?

    Read the article

  • Copying from istream never stops

    - by the_drow
    This bit of code runs infinitely: copy(istream_iterator<char>(cin), istream_iterator<char>(), back_inserter(buff)); The behavior I was expecting is that it will stop when I press enter. However it doesn't. buff is a vector of chars.

    Read the article

  • What is an example of MVC in PHP?

    - by waiwai933
    I'm trying to understand the MVC pattern. Here's what I think MV is: Model: <?php if($a == 2){ $variable = 'two'; } else{ $variable = 'not two'; } $this->output->addContent($variable); $this->output->displayContent(); ?> View: <?php class output{ private $content; public function addContent($var){ $this->content = 'The variable is '.$var; } public function displayContent(){ include 'header.php'; echo $content; include 'footer.php'; } } ?> Is this right? If so, what is the controller?

    Read the article

  • PHP get "Application Root" in Xampp on Windows correctly

    - by Michael Mao
    Hi all: I found this thread on StackOverflow about how to get the "Application Root" from inside my web app. However, most of the approaches suggested in that thread can hardly be applied to my Xampp on Windows. Say, I've got a "common.php" which stays inside my web app's app directory: / /app/common.php /protected/index.php In my common.php, what I've got is like this: define('DOCROOT', $_SERVER['DOCUMENT_ROOT']); define('ABSPATH', dirname(__FILE__)); define('COMMONSCRIPT', $_SERVER['PHP_SELF']); After I required the common.php inside the /protected/index.php, I found this: C:/xampp/htdocs //<== echo DOCROOT; C:\xampp\htdocs\comic\app //<== echo ABSPATH /comic/protected/index.php //<== echo COMMONSCRIPT So the most troublesome part is the path delimiters are not universal, plus, it seems all superglobals from the $_SERVER[] asso array, such as $_SERVER['PHP_SELF'], are relative to the "caller" script, not the "callee" script. It seems that I can only rely on dirname(__FILE__) to make sure this always returns an absolute path to the common.php file. I can certainly parse the returning values from DOCROOT and ABSPATH and then calculate the correct "application root". For instance, I can compare the parts after htdocs and substitute all backslashes with slashes to get a unix-like path I wonder is this the right way to handle this? What if I deploy my web app on a LAMP environment? would this environment-dependent approach bomb me out? I have used some PHP frameworks such as CakePHP and CodeIgniter, to be frank, They just work on either LAMP or WAMP, but I am not sure how they approached such a elegant solution. Many thanks in advance for all the hints and suggestions.

    Read the article

  • System.Threading.Timer example to run and display seconds until you click a button

    - by Roy
    Hi, I am having some issues creating an asp.net page using C# When you first click a button it starts the display of seconds via a label control. When you click the button again the seconds stop. Currently my code behind looks like this: System.Threading.Timer Timer; bool endProcess = false; int i = 0; protected void Page_Load(object sender, EventArgs e) { Timer = new System.Threading.Timer(TimerCallback, null, 10, 10); } private void TimerCallback(object state) { Label1.Text = i.ToString(); i++; if (endProcess == true) { Timer.Dispose(); return; } } public void Button1_Click(object sender, System.EventArgs e) { endProcess = true; }

    Read the article

  • Debian packaging of a Python package.

    - by chrisdew
    I need to write (or find) a script to create a Debian package (using python-support) from a Python package. The Python package will be pure Python (no C extensions). The Python package (for testing purposes) will just be a directory with an empty __init__.py file and a single Python module, package_test.py. The packaging script must use python-support to provide the correct bytecode for possible multiple installations of Python on a target platform. (i.e. v2.5 and v2.6 on Ubuntu Jaunty.) Most advice I find while googling are just examples nasty hacks that don't even use python-support or python-central. I have so far spent hours researching this, and the best I can come up with is to hack around the script from an existing open source project - but I don't know which bits are required for what I'm doing. Has anyone here made a Debian package out of a Python package in a reasonably non-hacky way? I'm starting to think that it will take me more than a week to go from no knowledge of Debian packaging and python-support to getting a working script. How long has it taken others? Any advice? Chris.

    Read the article

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